tempo_revm/
instructions.rs1use crate::evm::TempoContext;
2use alloy_evm::Database;
3use revm::{
4 handler::instructions::EthInstructions,
5 interpreter::{Instruction, InstructionContext, interpreter::EthInterpreter, push},
6};
7use tempo_chainspec::hardfork::TempoHardfork;
8
9const MILLIS_TIMESTAMP: u8 = 0x4F;
11
12const MILLIS_TIMESTAMP_GAS_COST: u64 = 2;
14
15type TempoInstructionContext<'a, DB> = InstructionContext<'a, TempoContext<DB>, EthInterpreter>;
17
18fn millis_timestamp<DB: Database>(context: TempoInstructionContext<'_, DB>) {
20 push!(context.interpreter, context.host.block.timestamp_millis());
21}
22
23pub(crate) fn tempo_instructions<DB: Database>(
25 spec: TempoHardfork,
26) -> EthInstructions<EthInterpreter, TempoContext<DB>> {
27 let mut instructions = EthInstructions::new_mainnet_with_spec(spec.into());
28 if !spec.is_t1c() {
29 instructions.insert_instruction(
30 MILLIS_TIMESTAMP,
31 Instruction::new(millis_timestamp, MILLIS_TIMESTAMP_GAS_COST),
32 );
33 }
34 instructions
35}