diff --git a/src/instructions.rs b/src/instructions.rs index 59f2b8a..c9a79ff 100644 --- a/src/instructions.rs +++ b/src/instructions.rs @@ -16,6 +16,7 @@ use std::rc::Rc; const HISTORY_STORAGE_ADDRESS: Address = address!("0x0000F90827F1C53a10cb7A02335B175320002935"); const HISTORY_SERVE_WINDOW: u64 = 8191; +const DIFFICULTY: U256 = U256::ZERO; /// Holds the EVM instruction table for Scroll. pub struct ScrollInstructions { @@ -67,6 +68,7 @@ where /// - `TLOAD` /// - `SELFDESTRUCT` /// - `MCOPY` +/// - `DIFFICULTY` pub fn make_scroll_instruction_table( ) -> InstructionTable { let mut table = instruction_table::(); @@ -78,6 +80,7 @@ pub fn make_scroll_instruction_table; table[opcode::SELFDESTRUCT as usize] = selfdestruct::; table[opcode::MCOPY as usize] = mcopy::; + table[opcode::DIFFICULTY as usize] = difficulty::; table } @@ -216,6 +219,16 @@ fn mcopy(context: InstructionContext interpreter.memory.copy(dst, src, len); } +/// Implements the DIFFICULTY instruction. +/// +/// Pushes the block difficulty(default to 0) onto the stack. +pub fn difficulty( + context: InstructionContext<'_, H, WIRE>, +) { + gas!(context.interpreter, gas::BASE); + push!(context.interpreter, DIFFICULTY); +} + // HELPER FUNCTIONS // ================================================================================================