Skip to content

Commit

Permalink
chore: resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Aug 30, 2024
1 parent 925745e commit db7424c
Show file tree
Hide file tree
Showing 8 changed files with 1,195 additions and 269 deletions.
1,335 changes: 1,139 additions & 196 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ cometbft-proto = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.g
cometbft-light-client = { git = "https://github.com/bnb-chain/greenfield-cometbft-rs.git", rev = "1282547" }
prost = { version = "0.12.6" }
bls_on_arkworks = "0.3.0"
tendermint = { git = "https://github.com/bnb-chain/tendermint-rs-parlia", tag = "v0.1.0-beta.1", features = ["secp256k1"] }
tendermint = { git = "https://github.com/bnb-chain/tendermint-rs-parlia", rev = "8c21ccbd58a174e07eed2c9343e63ccd00f0fbd5", features = ["secp256k1"] }
parity-bytes = { version = "0.1.2", default-features = false }

# SHA2-256 and RIPEMD-160
Expand Down
6 changes: 5 additions & 1 deletion crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,11 @@ impl PrecompileSpecId {
#[cfg(feature = "opbnb")]
FERMAT => Self::FERMAT,
#[cfg(any(feature = "bsc", feature = "opbnb"))]
HABER | HABER_FIX | WRIGHT | BOHR => Self::HABER,
HABER => Self::HABER,
#[cfg(feature = "opbnb")]
WRIGHT => Self::HABER,
#[cfg(feature = "bsc")]
HABER_FIX | BOHR => Self::HABER,
LATEST => Self::LATEST,
}
}
Expand Down
50 changes: 46 additions & 4 deletions crates/primitives/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub enum SpecId {
MERGE = 15, // Paris/Merge 15537394 (TTD: 58750000000000000000000)
SHANGHAI = 16, // Shanghai 17034870 (Timestamp: 1681338455)
CANCUN = 17, // Cancun 19426587 (Timestamp: 1710338135)
PRAGUE = 18, // Praque TBD
PRAGUE_EOF = 19, // Praque+EOF TBD
PRAGUE = 18, // Prague TBD
PRAGUE_EOF = 19, // Prague+EOF TBD
#[default]
LATEST = u8::MAX,
}
Expand Down Expand Up @@ -71,8 +71,9 @@ pub enum SpecId {
HABER = 23,
WRIGHT = 24,
FJORD = 25,
PRAGUE = 26,
PRAGUE_EOF = 27,
GRANITE = 26,
PRAGUE = 27,
PRAGUE_EOF = 28,
#[default]
LATEST = u8::MAX,
}
Expand Down Expand Up @@ -179,6 +180,8 @@ impl From<&str> for SpecId {
"Ecotone" => SpecId::ECOTONE,
#[cfg(feature = "optimism")]
"Fjord" => SpecId::FJORD,
#[cfg(feature = "optimism")]
"Granite" => SpecId::GRANITE,
#[cfg(feature = "bsc")]
"Ramanujan" => SpecId::RAMANUJAN,
#[cfg(feature = "bsc")]
Expand Down Expand Up @@ -259,6 +262,8 @@ impl From<SpecId> for &'static str {
SpecId::ECOTONE => "Ecotone",
#[cfg(feature = "optimism")]
SpecId::FJORD => "Fjord",
#[cfg(feature = "optimism")]
SpecId::GRANITE => "Granite",
#[cfg(feature = "bsc")]
SpecId::RAMANUJAN => "Ramanujan",
#[cfg(feature = "bsc")]
Expand Down Expand Up @@ -380,10 +385,13 @@ spec!(CANYON, CanyonSpec);
spec!(ECOTONE, EcotoneSpec);
#[cfg(feature = "optimism")]
spec!(FJORD, FjordSpec);
#[cfg(feature = "optimism")]
spec!(GRANITE, GraniteSpec);
#[cfg(feature = "opbnb")]
spec!(FERMAT, FermatSpec);
#[cfg(feature = "opbnb")]
spec!(WRIGHT, WrightSpec);

#[cfg(all(not(feature = "optimism"), not(feature = "bsc")))]
#[macro_export]
macro_rules! spec_to_generic {
Expand Down Expand Up @@ -557,6 +565,10 @@ macro_rules! spec_to_generic {
use $crate::FjordSpec as SPEC;
$e
}
$crate::SpecId::GRANITE => {
use $crate::GraniteSpec as SPEC;
$e
}
}
}};
}
Expand Down Expand Up @@ -718,6 +730,8 @@ mod tests {
spec_to_generic!(ECOTONE, assert_eq!(SPEC::SPEC_ID, ECOTONE));
#[cfg(feature = "optimism")]
spec_to_generic!(FJORD, assert_eq!(SPEC::SPEC_ID, FJORD));
#[cfg(feature = "optimism")]
spec_to_generic!(GRANITE, assert_eq!(SPEC::SPEC_ID, GRANITE));
#[cfg(not(feature = "bsc"))]
spec_to_generic!(PRAGUE, assert_eq!(SPEC::SPEC_ID, PRAGUE));
#[cfg(not(feature = "bsc"))]
Expand Down Expand Up @@ -881,4 +895,32 @@ mod optimism_tests {
assert!(SpecId::enabled(SpecId::FJORD, SpecId::ECOTONE));
assert!(SpecId::enabled(SpecId::FJORD, SpecId::FJORD));
}

#[test]
fn test_granite_post_merge_hardforks() {
assert!(GraniteSpec::enabled(SpecId::MERGE));
assert!(GraniteSpec::enabled(SpecId::SHANGHAI));
assert!(GraniteSpec::enabled(SpecId::CANCUN));
assert!(!GraniteSpec::enabled(SpecId::LATEST));
assert!(GraniteSpec::enabled(SpecId::BEDROCK));
assert!(GraniteSpec::enabled(SpecId::REGOLITH));
assert!(GraniteSpec::enabled(SpecId::CANYON));
assert!(GraniteSpec::enabled(SpecId::ECOTONE));
assert!(GraniteSpec::enabled(SpecId::FJORD));
assert!(GraniteSpec::enabled(SpecId::GRANITE));
}

#[test]
fn test_granite_post_merge_hardforks_spec_id() {
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::MERGE));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::SHANGHAI));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::CANCUN));
assert!(!SpecId::enabled(SpecId::GRANITE, SpecId::LATEST));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::BEDROCK));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::REGOLITH));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::CANYON));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::ECOTONE));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::FJORD));
assert!(SpecId::enabled(SpecId::GRANITE, SpecId::GRANITE));
}
}
19 changes: 4 additions & 15 deletions crates/revm/src/bsc/handler_register.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Handler related to BNB-Smart-chain
use crate::primitives::KECCAK_EMPTY;
use crate::{
handler::register::EvmHandler,
interpreter::Gas,
Expand Down Expand Up @@ -89,14 +88,14 @@ pub fn collect_system_reward<SPEC: Spec, EXT, DB: Database>(
tx_fee = tx_fee.saturating_add(*data_fee);
}

let (system_account, _) = context
let system_account = context
.evm
.inner
.journaled_state
.load_account(SYSTEM_ADDRESS, &mut context.evm.inner.db)?;

system_account.mark_touch();
system_account.info.balance = system_account.info.balance.saturating_add(tx_fee);
system_account.data.mark_touch();
system_account.data.info.balance = system_account.data.info.balance.saturating_add(tx_fee);

Ok(())
}
Expand Down Expand Up @@ -126,17 +125,7 @@ pub fn output<EXT, DB: Database>(
let instruction_result = result.into_interpreter_result();

// reset journal and return present state.
let (mut state, logs) = context.evm.journaled_state.finalize();

// clear code of authorized accounts.
for authorized in core::mem::take(&mut context.evm.inner.valid_authorizations).into_iter() {
let account = state
.get_mut(&authorized)
.expect("Authorized account must exist");
account.info.code = None;
account.info.code_hash = KECCAK_EMPTY;
account.storage.clear();
}
let (state, logs) = context.evm.journaled_state.finalize();

let result = match instruction_result.result.into() {
SuccessOrHalt::Success(reason) => ExecutionResult::Success {
Expand Down
1 change: 0 additions & 1 deletion crates/revm/src/handler/handle_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub mod pre_execution;
pub mod validation;

// Exports

pub use execution::{
ExecutionHandler, FrameCallHandle, FrameCallReturnHandle, FrameCreateHandle,
FrameCreateReturnHandle, InsertCallOutcomeHandle, InsertCreateOutcomeHandle,
Expand Down
1 change: 0 additions & 1 deletion crates/revm/src/handler/mainnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod pre_execution;
mod validation;

// Public exports

pub use execution::{
call, call_return, create, create_return, eofcreate, eofcreate_return, execute_frame,
insert_call_outcome, insert_create_outcome, insert_eofcreate_outcome, last_frame_return,
Expand Down

Large diffs are not rendered by default.

0 comments on commit db7424c

Please sign in to comment.