Skip to content

Commit 2251a5e

Browse files
committed
update
1 parent f4c9cea commit 2251a5e

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
66

77
[dependencies]
88
# revm
9-
revm = { git = "https://github.com/scroll-tech/revm", default-features = false, features = ["enable_eip7702", "enable_eip7623", "enable_eip7939"] }
9+
revm = { git = "https://github.com/scroll-tech/revm", default-features = false, features = ["enable_eip7702", "enable_eip7623"] }
1010
revm-primitives = { git = "https://github.com/scroll-tech/revm", default-features = false }
1111
revm-inspector = { git = "https://github.com/scroll-tech/revm", default-features = false }
1212

src/builder.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ impl DefaultScrollContext for ScrollContext<EmptyDB> {
6161
let mut cfg = CfgEnv::new_with_spec(spec);
6262
cfg.enable_eip7702 = spec >= ScrollSpecId::EUCLID;
6363
cfg.enable_eip7623 = spec >= ScrollSpecId::FEYNMAN;
64-
cfg.enable_eip7939 = spec >= ScrollSpecId::GALILEO;
6564

6665
Context::mainnet()
6766
.with_tx(ScrollTransaction::default())
@@ -82,12 +81,6 @@ pub trait FeynmanEipActivations: EuclidEipActivations {
8281
fn maybe_with_eip_7623(self) -> Self;
8382
}
8483

85-
/// Activates specific EIP's for Galileo.
86-
pub trait GalileoEipActivations: FeynmanEipActivations {
87-
/// Activates EIP-7939 if the spec is at least at Galileo.
88-
fn maybe_with_eip_7939(self) -> Self;
89-
}
90-
9184
impl<DB: Database> EuclidEipActivations for ScrollContext<DB> {
9285
fn maybe_with_eip_7702(mut self) -> Self {
9386
self.cfg.enable_eip7702 = self.cfg.spec >= ScrollSpecId::EUCLID;
@@ -102,12 +95,5 @@ impl<DB: Database> FeynmanEipActivations for ScrollContext<DB> {
10295
}
10396
}
10497

105-
impl<DB: Database> GalileoEipActivations for ScrollContext<DB> {
106-
fn maybe_with_eip_7939(mut self) -> Self {
107-
self.cfg.enable_eip7939 = self.cfg.spec >= ScrollSpecId::GALILEO;
108-
self
109-
}
110-
}
111-
11298
pub type ScrollContext<DB> =
11399
Context<BlockEnv, ScrollTransaction<TxEnv>, CfgEnv<ScrollSpecId>, DB, Journal<DB>, L1BlockInfo>;

src/instructions.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ where
6969
/// - `SELFDESTRUCT`
7070
/// - `MCOPY`
7171
/// - `DIFFICULTY`
72+
/// - `CLZ`
7273
pub fn make_scroll_instruction_table<WIRE: InterpreterTypes, HOST: ScrollContextTr>(
7374
) -> InstructionTable<WIRE, HOST> {
7475
let mut table = instruction_table::<WIRE, HOST>();
@@ -82,6 +83,7 @@ pub fn make_scroll_instruction_table<WIRE: InterpreterTypes, HOST: ScrollContext
8283
table[opcode::SELFDESTRUCT as usize] = Instruction::new(selfdestruct::<WIRE, HOST>, 0);
8384
table[opcode::MCOPY as usize] = Instruction::new(mcopy::<WIRE, HOST>, 0);
8485
table[opcode::DIFFICULTY as usize] = Instruction::new(difficulty::<WIRE, HOST>, 2);
86+
table[opcode::CLZ as usize] = Instruction::new(clz::<WIRE, HOST>, 5);
8587

8688
table
8789
}
@@ -245,6 +247,23 @@ pub fn difficulty<WIRE: InterpreterTypes, H: Host + ?Sized>(
245247
push!(context.interpreter, DIFFICULTY);
246248
}
247249

250+
/// Implements the CLZ instruction
251+
///
252+
/// EIP-7939 count leading zeros.
253+
fn clz<WIRE: InterpreterTypes, H: ScrollContextTr>(context: InstructionContext<'_, H, WIRE>) {
254+
let host = context.host;
255+
let interpreter = context.interpreter;
256+
if !host.cfg().spec().is_enabled_in(ScrollSpecId::GALILEO) {
257+
interpreter.halt(InstructionResult::NotActivated);
258+
return;
259+
}
260+
261+
popn_top!([], op1, context.interpreter);
262+
263+
let leading_zeros = op1.leading_zeros();
264+
*op1 = U256::from(leading_zeros);
265+
}
266+
248267
// HELPER FUNCTIONS
249268
// ================================================================================================
250269

0 commit comments

Comments
 (0)