Skip to content

Commit

Permalink
feat: mutually exclusive features scroll and optimism
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 committed Dec 4, 2024
1 parent 5e4ad1d commit a740f3d
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 156 deletions.
109 changes: 75 additions & 34 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions bins/revm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ bytes = "1.7"
hex = "0.4"
revm = { path = "../../crates/revm", version = "18.0.0", default-features=false }
microbench = "0.5"
alloy-sol-macro = "0.8.11"
alloy-sol-types = "0.8.11"
alloy-sol-macro = "0.8.10"
alloy-sol-types = "0.8.10"
regex = "1.10.6"
eyre = "0.6.12"

Expand Down
12 changes: 7 additions & 5 deletions crates/interpreter/src/instructions/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub fn extcodecopy<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter,
.set_data(memory_offset, code_offset, len, &code);
}

#[cfg(not(feature = "scroll"))]
#[cfg(any(not(feature = "scroll"), feature = "optimism"))]
pub fn blockhash<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
gas!(interpreter, gas::BLOCKHASH);
pop_top!(interpreter, number);
Expand All @@ -147,7 +147,7 @@ pub fn blockhash<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, ho
*number = U256::from_be_bytes(hash.0);
}

#[cfg(feature = "scroll")]
#[cfg(all(feature = "scroll", not(feature = "optimism")))]
pub fn blockhash<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
use revm_primitives::BLOCK_HASH_HISTORY;

Expand Down Expand Up @@ -228,7 +228,8 @@ pub fn sstore<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host:
/// Store value to transient storage
pub fn tstore<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
cfg_if::cfg_if! {
if #[cfg(feature = "scroll")] {
if #[cfg(all(feature = "scroll", not(feature = "optimism")))]
{
check!(interpreter, CURIE);
} else {
check!(interpreter, CANCUN);
Expand All @@ -247,7 +248,8 @@ pub fn tstore<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host:
/// Load value from transient storage
pub fn tload<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
cfg_if::cfg_if! {
if #[cfg(feature = "scroll")] {
if #[cfg(all(feature = "scroll", not(feature = "optimism")))]
{
check!(interpreter, CURIE);
} else {
check!(interpreter, CANCUN);
Expand Down Expand Up @@ -298,7 +300,7 @@ pub fn selfdestruct<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter,
require_non_staticcall!(interpreter);
pop_address!(interpreter, target);

#[cfg(feature = "scroll")]
#[cfg(all(feature = "scroll", not(feature = "optimism")))]
if SPEC::enabled(PRE_BERNOULLI) {
interpreter.instruction_result = InstructionResult::NotActivated;
return;
Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/instructions/host_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn gasprice<H: Host + ?Sized>(interpreter: &mut Interpreter, host: &mut H) {

/// EIP-3198: BASEFEE opcode
pub fn basefee<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, host: &mut H) {
#[cfg(feature = "scroll")]
#[cfg(all(feature = "scroll", not(feature = "optimism")))]
if !SPEC::enabled(CURIE) {
interpreter.instruction_result = crate::InstructionResult::NotActivated;
return;
Expand Down
3 changes: 2 additions & 1 deletion crates/interpreter/src/instructions/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ pub fn msize<H: Host + ?Sized>(interpreter: &mut Interpreter, _host: &mut H) {
// EIP-5656: MCOPY - Memory copying instruction
pub fn mcopy<H: Host + ?Sized, SPEC: Spec>(interpreter: &mut Interpreter, _host: &mut H) {
cfg_if::cfg_if! {
if #[cfg(feature = "scroll")] {
if #[cfg(all(feature = "scroll", not(feature = "optimism")))]
{
check!(interpreter, CURIE);
} else {
check!(interpreter, CANCUN);
Expand Down
10 changes: 5 additions & 5 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,15 @@ impl PrecompileSpecId {
CANCUN => Self::CANCUN,
PRAGUE | OSAKA => Self::PRAGUE,
LATEST => Self::LATEST,
#[cfg(feature = "optimism")]
#[cfg(all(feature = "optimism", not(feature = "scroll")))]
BEDROCK | REGOLITH | CANYON => Self::BERLIN,
#[cfg(feature = "optimism")]
#[cfg(all(feature = "optimism", not(feature = "scroll")))]
ECOTONE | FJORD | GRANITE | HOLOCENE => Self::CANCUN,
#[cfg(feature = "scroll")]
#[cfg(all(feature = "scroll", not(feature = "optimism")))]
PRE_BERNOULLI => Self::PRE_BERNOULLI,
#[cfg(feature = "scroll")]
#[cfg(all(feature = "scroll", not(feature = "optimism")))]
BERNOULLI | CURIE => Self::BERNOULLI,
#[cfg(feature = "scroll")]
#[cfg(all(feature = "scroll", not(feature = "optimism")))]
EUCLID => Self::EUCLID,
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/env/handler_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl HandlerCfg {
}

/// Creates new `HandlerCfg` instance with the optimism feature.
#[cfg(feature = "optimism")]
#[cfg(all(feature = "optimism", not(feature = "scroll")))]
pub fn new_with_optimism(spec_id: SpecId, is_optimism: bool) -> Self {
Self {
spec_id,
Expand All @@ -61,7 +61,7 @@ impl HandlerCfg {
}

/// Creates new `HandlerCfg` instance with the scroll feature.
#[cfg(feature = "scroll")]
#[cfg(all(feature = "scroll", not(feature = "optimism")))]
pub fn new_with_scroll(spec_id: SpecId, is_scroll: bool) -> Self {
Self { spec_id, is_scroll }
}
Expand Down
Loading

0 comments on commit a740f3d

Please sign in to comment.