From 4e0ea88edf446be0ac7faf7195d1a09169f0d629 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Mon, 29 Jul 2024 15:15:53 +0800 Subject: [PATCH 1/4] feat: add bohr upgrade for BSC --- crates/precompile/src/lib.rs | 2 ++ crates/primitives/src/specification.rs | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index c340d0d1..764496f2 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -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, } } diff --git a/crates/primitives/src/specification.rs b/crates/primitives/src/specification.rs index 14b73641..161382be 100644 --- a/crates/primitives/src/specification.rs +++ b/crates/primitives/src/specification.rs @@ -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, @@ -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, } } @@ -289,6 +292,8 @@ impl From for &'static str { SpecId::HABER => "Haber", #[cfg(feature = "bsc")] SpecId::HABER_FIX => "HaberFix", + #[cfg(feature = "bsc")] + SpecId::BOHR => "Bohr", SpecId::LATEST => "Latest", } } @@ -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 } From aecb708f317e79a104f2f963117d217dfab3da18 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Mon, 29 Jul 2024 15:57:07 +0800 Subject: [PATCH 2/4] fix lint error --- crates/precompile/src/bls12_381/pairing.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/precompile/src/bls12_381/pairing.rs b/crates/precompile/src/bls12_381/pairing.rs index e0c50dd8..fbf232c4 100644 --- a/crates/precompile/src/bls12_381/pairing.rs +++ b/crates/precompile/src/bls12_381/pairing.rs @@ -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 From b0bd90b1e256f12b22117b9167d92a0c6513bd93 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Mon, 29 Jul 2024 15:58:29 +0800 Subject: [PATCH 3/4] fix lint error --- crates/interpreter/src/gas/calc.rs | 2 +- crates/precompile/src/bls12_381/utils.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/interpreter/src/gas/calc.rs b/crates/interpreter/src/gas/calc.rs index 4d8aba4d..cc83cf6c 100644 --- a/crates/interpreter/src/gas/calc.rs +++ b/crates/interpreter/src/gas/calc.rs @@ -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, diff --git a/crates/precompile/src/bls12_381/utils.rs b/crates/precompile/src/bls12_381/utils.rs index a2ed3cd8..b576fcc5 100644 --- a/crates/precompile/src/bls12_381/utils.rs +++ b/crates/precompile/src/bls12_381/utils.rs @@ -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 { if input.len() != SCALAR_LENGTH { return Err(PrecompileError::Other(format!( From ecd902dfe3e5fb79f5e63cbbe053e578d6393df8 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Mon, 29 Jul 2024 16:01:40 +0800 Subject: [PATCH 4/4] fix lint error --- crates/revm/src/db/states/state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/revm/src/db/states/state.rs b/crates/revm/src/db/states/state.rs index b3f35891..196565bb 100644 --- a/crates/revm/src/db/states/state.rs +++ b/crates/revm/src/db/states/state.rs @@ -204,7 +204,7 @@ impl State { /// 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 {