Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: skip usage of ScrollPostExecutionContext #98

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/scroll/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ workspace = true
revm = { version = "18.0.0", features = ["std"], default-features = false }

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

# misc
serde = { workspace = true, optional = true }
Expand All @@ -26,21 +26,21 @@ default = ["std"]
dev = ["revm/dev"]
arbitrary = [
"revm/arbitrary",
"reth-scroll-primitives/arbitrary"
"reth-scroll-primitives?/arbitrary"
]
asm-keccak = ["revm/asm-keccak"]
c-kzg = ["revm/c-kzg"]
optimism = ["revm/optimism"]
serde = [
"revm/serde",
"serde/std",
"reth-scroll-primitives/serde"
"dep:serde",
"reth-scroll-primitives?/serde"
]
scroll = ["revm/scroll-poseidon-codehash"]
scroll = ["revm/scroll-poseidon-codehash", "dep:reth-scroll-primitives"]
test-utils = ["revm/test-utils"]
std = [
"revm/std",
"serde/std"
"serde?/std"
]

blst = ["revm/blst"]
Expand Down
17 changes: 10 additions & 7 deletions crates/scroll/revm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@

#![warn(unused_crate_dependencies)]

#[cfg(feature = "serde")]
use serde as _;

#[cfg(feature = "scroll")]
pub mod states;
#[cfg(feature = "test-utils")]
#[cfg(all(feature = "scroll", feature = "test-utils"))]
mod test_utils;

#[cfg(feature = "scroll")]
pub use crate::states::ScrollAccountInfo as AccountInfo;
#[cfg(not(feature = "scroll"))]
pub use revm::primitives::AccountInfo;

#[cfg(all(feature = "optimism", not(feature = "scroll")))]
pub use revm::{primitives::OptimismFields, L1BlockInfo, L1_BLOCK_CONTRACT};

Expand All @@ -21,12 +30,6 @@ pub use revm::{
JournaledState,
};

#[cfg(feature = "scroll")]
pub use crate::states::ScrollAccountInfo as AccountInfo;
#[cfg(not(feature = "scroll"))]
pub use revm::primitives::AccountInfo;
pub use states::ScrollAccountInfo;

/// Shared module, available for all feature flags.
pub mod shared {
pub use revm::{db::states::BundleState, primitives::AccountInfo};
Expand Down
24 changes: 13 additions & 11 deletions crates/scroll/revm/src/states/account_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,24 @@ pub struct ScrollAccountInfo {
}

impl From<(AccountInfo, &ScrollPostExecutionContext)> for ScrollAccountInfo {
fn from((info, context): (AccountInfo, &ScrollPostExecutionContext)) -> Self {
let context = context.get(&info.code_hash).copied();
let (code_size, poseidon_code_hash) = context
.or_else(|| {
info.code
.as_ref()
.map(|code| (code.len() as u64, hash_code(code.original_byte_slice())))
})
.unwrap_or((0, POSEIDON_EMPTY));
fn from((info, _context): (AccountInfo, &ScrollPostExecutionContext)) -> Self {
// TODO(scroll): uncomment once use of the revm sdk pattern is adopted. Tracked in
// https://github.com/scroll-tech/reth/issues/97
// let context = context.get(&info.code_hash).copied();
// let (code_size, poseidon_code_hash) = context
// .or_else(|| {
// info.code
// .as_ref()
// .map(|code| (code.len() as u64, hash_code(code.original_byte_slice())))
// })
// .unwrap_or((0, POSEIDON_EMPTY));
Self {
balance: info.balance,
nonce: info.nonce,
code_hash: info.code_hash,
code: info.code,
code_size,
poseidon_code_hash,
code_size: info.code_size as u64,
poseidon_code_hash: info.poseidon_code_hash,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/scroll/revm/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
shared::AccountInfo,
states::{
ScrollAccountInfoRevert, ScrollAccountRevert, ScrollPlainStateReverts, ScrollStateChangeset,
ScrollAccountInfo, ScrollAccountInfoRevert, ScrollAccountRevert, ScrollPlainStateReverts,
ScrollStateChangeset,
},
ScrollAccountInfo,
};
use reth_scroll_primitives::poseidon::{hash_code, POSEIDON_EMPTY};
use revm::db::{
Expand Down
Loading