Skip to content

Commit

Permalink
feat: add bohr hardfork for bsc (#49)
Browse files Browse the repository at this point in the history
* feat: add bohr upgrade for BSC

* fix lint error

* fix lint error

* fix lint error
  • Loading branch information
yutianwu authored Jul 31, 2024
1 parent 0fceb63 commit 8a18176
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/interpreter/src/gas/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ pub const fn selfdestruct_cost(spec_id: SpecId, res: SelfDestructResult) -> u64
/// * Account access gas. after berlin it can be cold or warm.
/// * Transfer value gas. If value is transferred and balance of target account is updated.
/// * If account is not existing and needs to be created. After Spurious dragon
/// this is only accounted if value is transferred.
/// this is only accounted if value is transferred.
#[inline]
pub const fn call_cost(
spec_id: SpecId,
Expand Down
1 change: 1 addition & 0 deletions crates/precompile/src/bls12_381/pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const INPUT_LENGTH: usize = 384;
/// following structure:
/// * 128 bytes of G1 point encoding
/// * 256 bytes of G2 point encoding
///
/// Each point is expected to be in the subgroup of order q.
/// Output is 32 bytes where first 31 bytes are equal to 0x00 and the last byte
/// is 0x01 if pairing result is equal to the multiplicative identity in a pairing
Expand Down
4 changes: 2 additions & 2 deletions crates/precompile/src/bls12_381/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ pub(super) fn remove_padding(input: &[u8]) -> Result<&[u8; FP_LENGTH], Precompil
///
/// From [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537):
/// * A scalar for the multiplication operation is encoded as 32 bytes by performing BigEndian
/// encoding of the corresponding (unsigned) integer.
/// encoding of the corresponding (unsigned) integer.
///
/// We do not check that the scalar is a canonical Fr element, because the EIP specifies:
/// * The corresponding integer is not required to be less than or equal than main subgroup order
/// `q`.
/// `q`.
pub(super) fn extract_scalar_input(input: &[u8]) -> Result<blst_scalar, PrecompileError> {
if input.len() != SCALAR_LENGTH {
return Err(PrecompileError::Other(format!(
Expand Down
2 changes: 2 additions & 0 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ impl PrecompileSpecId {
HABER => Self::HABER,
#[cfg(feature = "bsc")]
HABER_FIX => Self::HABER,
#[cfg(feature = "bsc")]
BOHR => Self::HABER,
LATEST => Self::LATEST,
}
}
Expand Down
7 changes: 6 additions & 1 deletion crates/primitives/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub enum SpecId {
CANCUN = 29, // Cancun timestamp(1718863500)
HABER = 30, // Haber timestamp(1718863500)
HABER_FIX = 31, // HaberFix timestamp(1720591588)
BOHR = 32, // Bohr timestamp(1720591588)

/// Not enabled in bsc
DAO_FORK = 100,
Expand Down Expand Up @@ -213,6 +214,8 @@ impl From<&str> for SpecId {
"Haber" => SpecId::HABER,
#[cfg(feature = "bsc")]
"HaberFix" => SpecId::HABER_FIX,
#[cfg(feature = "bsc")]
"Bohr" => SpecId::BOHR,
_ => Self::LATEST,
}
}
Expand Down Expand Up @@ -289,6 +292,8 @@ impl From<SpecId> for &'static str {
SpecId::HABER => "Haber",
#[cfg(feature = "bsc")]
SpecId::HABER_FIX => "HaberFix",
#[cfg(feature = "bsc")]
SpecId::BOHR => "Bohr",
SpecId::LATEST => "Latest",
}
}
Expand Down Expand Up @@ -646,7 +651,7 @@ macro_rules! spec_to_generic {
use $crate::PragueEofSpec as SPEC;
$e
}
$crate::SpecId::HABER | $crate::SpecId::HABER_FIX => {
$crate::SpecId::HABER | $crate::SpecId::HABER_FIX | $crate::SpecId::BOHR => {
use $crate::HaberSpec as SPEC;
$e
}
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/db/states/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<DB: Database> State<DB> {
/// NOTE: If either:
/// * The [State] has not been built with [StateBuilder::with_bundle_update], or
/// * The [State] has a [TransitionState] set to `None` when
/// [State::merge_transitions] is called,
/// [State::merge_transitions] is called,
///
/// this will panic.
pub fn take_bundle(&mut self) -> BundleState {
Expand Down

0 comments on commit 8a18176

Please sign in to comment.