Skip to content

Commit

Permalink
fix lints + feature check
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Edison <[email protected]>
  • Loading branch information
greged93 committed Nov 19, 2024
1 parent 64ac891 commit 6c120a1
Show file tree
Hide file tree
Showing 32 changed files with 278 additions and 110 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/ethereum/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ secp256k1.workspace = true
serde_json.workspace = true
alloy-genesis.workspace = true

reth-scroll-primitives.workspace = true

[features]
default = ["std"]
std = [
Expand All @@ -52,3 +54,4 @@ std = [
"revm-primitives/std",
"secp256k1/std"
]
scroll = []
26 changes: 16 additions & 10 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,10 @@ mod tests {
balance: U256::ZERO,
bytecode_hash: Some(keccak256(BEACON_ROOTS_CODE.clone())),
nonce: 1,
// TODO (scroll): remove at last Scroll `Account` related PR.
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
&BEACON_ROOTS_CODE,
)),
};

db.insert_account(
Expand All @@ -346,8 +348,10 @@ mod tests {
nonce: 1,
balance: U256::ZERO,
bytecode_hash: Some(keccak256(WITHDRAWAL_REQUEST_PREDEPLOY_CODE.clone())),
// TODO (scroll): remove at last Scroll `Account` related PR.
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
&WITHDRAWAL_REQUEST_PREDEPLOY_CODE,
)),
};

db.insert_account(
Expand Down Expand Up @@ -711,8 +715,10 @@ mod tests {
balance: U256::ZERO,
bytecode_hash: Some(keccak256(HISTORY_STORAGE_CODE.clone())),
nonce: 1,
// TODO (scroll): remove at last Scroll `Account` related PR.
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
&HISTORY_STORAGE_CODE,
)),
};

db.insert_account(
Expand Down Expand Up @@ -1069,8 +1075,8 @@ mod tests {
nonce: 1,
balance: U256::from(ETH_TO_WEI),
bytecode_hash: None,
// TODO (scroll): remove at last Scroll `Account` related PR.
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::empty()),
},
None,
HashMap::default(),
Expand Down Expand Up @@ -1157,8 +1163,8 @@ mod tests {
nonce: 1,
balance: U256::from(ETH_TO_WEI),
bytecode_hash: None,
// TODO (scroll): remove at last Scroll `Account` related PR.
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::empty()),
},
None,
HashMap::default(),
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ std = [
]
test-utils = [
"arbitrary",
"reth-codecs/test-utils"
"reth-codecs/test-utils",
"revm-primitives/test-utils"
]
arbitrary = [
"std",
Expand Down
37 changes: 28 additions & 9 deletions crates/primitives-traits/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,13 @@ mod tests {

#[test]
fn test_empty_account() {
let mut acc =
Account { nonce: 0, balance: U256::ZERO, bytecode_hash: None, ..Default::default() };
let mut acc = Account {
nonce: 0,
balance: U256::ZERO,
bytecode_hash: None,
#[cfg(feature = "scroll")]
account_extension: Some(Default::default()),
};
// Nonce 0, balance 0, and bytecode hash set to None is considered empty.
assert!(acc.is_empty());

Expand Down Expand Up @@ -313,7 +318,8 @@ mod tests {
nonce: 1,
balance: U256::from(1000),
bytecode_hash: None,
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(Default::default()),
};
assert!(!acc_no_bytecode.has_bytecode(), "Account should not have bytecode");

Expand All @@ -322,7 +328,8 @@ mod tests {
nonce: 1,
balance: U256::from(1000),
bytecode_hash: Some(KECCAK_EMPTY),
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(Default::default()),
};
assert!(acc_empty_bytecode.has_bytecode(), "Account should have bytecode");

Expand All @@ -331,24 +338,33 @@ mod tests {
nonce: 1,
balance: U256::from(1000),
bytecode_hash: Some(B256::from_slice(&[0x11u8; 32])),
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
&[0x11u8; 32],
)),
};
assert!(acc_with_bytecode.has_bytecode(), "Account should have bytecode");
}

#[test]
fn test_account_get_bytecode_hash() {
// Account with no bytecode (should return KECCAK_EMPTY)
let acc_no_bytecode =
Account { nonce: 0, balance: U256::ZERO, bytecode_hash: None, ..Default::default() };
let acc_no_bytecode = Account {
nonce: 0,
balance: U256::ZERO,
bytecode_hash: None,
#[cfg(feature = "scroll")]
account_extension: Some(Default::default()),
};
assert_eq!(acc_no_bytecode.get_bytecode_hash(), KECCAK_EMPTY, "Should return KECCAK_EMPTY");

// Account with bytecode hash set to KECCAK_EMPTY
let acc_empty_bytecode = Account {
nonce: 1,
balance: U256::from(1000),
bytecode_hash: Some(KECCAK_EMPTY),
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(Default::default()),
};
assert_eq!(
acc_empty_bytecode.get_bytecode_hash(),
Expand All @@ -362,7 +378,10 @@ mod tests {
nonce: 1,
balance: U256::from(1000),
bytecode_hash: Some(bytecode_hash),
..Default::default()
#[cfg(feature = "scroll")]
account_extension: Some(reth_scroll_primitives::AccountExtension::from_bytecode(
&[0x11u8; 32],
)),
};
assert_eq!(
acc_with_bytecode.get_bytecode_hash(),
Expand Down
9 changes: 6 additions & 3 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ workspace = true
reth-primitives-traits.workspace = true
reth-ethereum-forks.workspace = true
reth-static-file-types.workspace = true
revm-primitives = { workspace = true, features = ["serde"] }
reth-codecs = { workspace = true, optional = true }

# ethereum
Expand All @@ -29,6 +28,9 @@ alloy-serde = { workspace = true, optional = true }
alloy-eips = { workspace = true, features = ["serde"] }
alloy-trie = { workspace = true, features = ["serde"] }

# scroll
revm-primitives = { package = "reth-scroll-revm", path = "../scroll/revm", features = ["serde"] }

# optimism
op-alloy-rpc-types = { workspace = true, optional = true }
op-alloy-consensus = { workspace = true, features = [
Expand Down Expand Up @@ -67,7 +69,7 @@ reth-codecs = { workspace = true, features = ["test-utils"] }
reth-primitives-traits = { workspace = true, features = ["arbitrary"] }
reth-testing-utils.workspace = true
reth-trie-common.workspace = true
revm-primitives = { workspace = true, features = ["arbitrary"] }
revm-primitives = { package = "reth-scroll-revm", path = "../scroll/revm", features = ["arbitrary"] }

alloy-eips = { workspace = true, features = ["arbitrary"] }
alloy-genesis.workspace = true
Expand Down Expand Up @@ -143,14 +145,15 @@ alloy-compat = [
"dep:alloy-rpc-types",
"dep:alloy-serde",
"dep:op-alloy-rpc-types",
"dep:alloy-network",
"dep:alloy-network",
]
test-utils = [
"reth-primitives-traits/test-utils",
"reth-chainspec/test-utils",
"reth-codecs?/test-utils",
"reth-trie-common/test-utils",
"arbitrary",
"revm-primitives/test-utils"
]
serde-bincode-compat = [
"alloy-consensus/serde-bincode-compat",
Expand Down
5 changes: 3 additions & 2 deletions crates/scroll/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ workspace = true
reth-revm.workspace = true

# scroll
reth-scroll-primitives.workspace = true
reth-scroll-primitives = { workspace = true, optional = true }
reth-scroll-revm.workspace = true
reth-scroll-storage.workspace = true
reth-scroll-storage = { workspace = true, optional = true }

# misc
auto_impl.workspace = true

[features]
scroll = [
"reth-scroll-primitives",
"reth-scroll-revm/scroll",
"reth-scroll-storage/scroll",
]
6 changes: 4 additions & 2 deletions crates/scroll/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ test-fuzz.workspace = true
[features]
default = ["std"]
std = [
"serde/std"
"serde/std",
"alloy-primitives/std"
]
arbitrary = [
"dep:arbitrary",
"alloy-primitives/arbitrary"
"alloy-primitives/arbitrary",
"reth-codecs/arbitrary"
]
12 changes: 10 additions & 2 deletions crates/scroll/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@ serde = { workspace = true, optional = true }

[features]
default = ["std"]
arbitrary = ["revm/arbitrary"]
arbitrary = [
"revm/arbitrary",
"reth-scroll-primitives/arbitrary"
]
asm-keccak = ["revm/asm-keccak"]
c-kzg = ["revm/c-kzg"]
optimism = ["revm/optimism"]
serde = [
"revm/serde",
"serde/std"
]
scroll = []
test-utils = ["revm/test-utils"]
std = ["revm/std"]
std = [
"revm/std",
"serde/std"
]
6 changes: 5 additions & 1 deletion crates/scroll/revm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

pub mod states;

#[cfg(feature = "optimism")]
pub use revm::primitives::OptimismFields;

pub use revm::{
db::*,
inspector_handle_register,
primitives::{
keccak256, Bytecode, BytecodeDecodeError, JumpTable, LegacyAnalyzedBytecode, TxEnv,
keccak256, AuthorizationList, Bytecode, BytecodeDecodeError, JumpTable,
LegacyAnalyzedBytecode, TxEnv, TxKind,
},
Evm, EvmBuilder, GetInspector,
};
Expand Down
6 changes: 6 additions & 0 deletions crates/stages/stages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ reth-trie-db = { workspace = true, features = ["metrics"] }

reth-testing-utils = { workspace = true, optional = true }

# scroll
reth-scroll-primitives = { workspace = true, optional = true }

alloy-primitives.workspace = true
alloy-consensus.workspace = true

Expand Down Expand Up @@ -74,6 +77,8 @@ reth-trie = { workspace = true, features = ["test-utils"] }
reth-provider = { workspace = true, features = ["test-utils"] }
reth-network-peers.workspace = true

reth-scroll-primitives.workspace = true

alloy-rlp.workspace = true
itertools.workspace = true
tokio = { workspace = true, features = ["rt", "sync", "macros"] }
Expand Down Expand Up @@ -114,6 +119,7 @@ test-utils = [
"reth-trie/test-utils",
"reth-prune-types/test-utils",
]
scroll = ["reth-scroll-primitives"]

[[bench]]
name = "criterion"
Expand Down
Loading

0 comments on commit 6c120a1

Please sign in to comment.