diff --git a/crates/primitives/src/env.rs b/crates/primitives/src/env.rs index 1c64b735fb..14bcd60e69 100644 --- a/crates/primitives/src/env.rs +++ b/crates/primitives/src/env.rs @@ -94,6 +94,13 @@ pub struct OptimismFields { pub enveloped_tx: Option, } +#[cfg(feature = "taiko")] +#[derive(Clone, Debug, Default, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct TaikoFields { + pub is_anchor: bool +} + impl BlockEnv { /// Takes `blob_excess_gas` saves it inside env /// and calculates `blob_fee` with [`BlobGasAndFee`]. @@ -183,6 +190,11 @@ pub struct TxEnv { #[cfg_attr(feature = "serde", serde(flatten))] #[cfg(feature = "optimism")] pub optimism: OptimismFields, + + #[cfg_attr(feature = "serde", serde(flatten))] + #[cfg(feature = "taiko")] + pub optimism: TaikoFields, + } impl TxEnv { @@ -306,6 +318,9 @@ pub struct CfgEnv { /// compilation with the optimism feature flag. #[cfg(feature = "optimism")] pub optimism: bool, + + #[cfg(feature = "taiko")] + pub taiko: bool, } impl CfgEnv { @@ -368,6 +383,16 @@ impl CfgEnv { pub fn is_optimism(&self) -> bool { false } + + #[cfg(feature = "taiko")] + pub fn is_taiko(&self) -> bool { + self.taiko + } + + #[cfg(not(feature = "taiko"))] + pub fn is_taiko(&self) -> bool { + false + } } /// What bytecode analysis to perform. @@ -406,6 +431,8 @@ impl Default for CfgEnv { disable_base_fee: false, #[cfg(feature = "optimism")] optimism: false, + #[cfg(feature = "taiko")] + taiko: false, } } } @@ -442,6 +469,8 @@ impl Default for TxEnv { max_fee_per_blob_gas: None, #[cfg(feature = "optimism")] optimism: OptimismFields::default(), + #[cfg(feature = "taiko")] + taiko: TaikoFields::default(), } } } @@ -503,6 +532,11 @@ impl Env { } } + #[cfg(feature = "taiko")] + if self.cfg.taiko { + // TODO:(Cecilia) + } + let gas_limit = self.tx.gas_limit; let effective_gas_price = self.effective_gas_price(); let is_create = self.tx.transact_to.is_create(); @@ -622,6 +656,11 @@ impl Env { return Ok(()); } + #[cfg(feature = "taiko")] + if self.cfg.taiko { + // TODO(Cecilia): do we do anything with this? + } + // Check that the transaction's nonce is correct if let Some(tx) = self.tx.nonce { let state = account.info.nonce; @@ -711,6 +750,12 @@ mod tests { .is_ok()); } + #[cfg(feature = "taiko")] + #[test] + fn test_taiko() { + // TODO(Cecilia): taiko tests + } + #[test] fn test_validate_tx_chain_id() { let mut env = Env::default(); diff --git a/crates/primitives/src/specification.rs b/crates/primitives/src/specification.rs index 741271535b..130b607410 100644 --- a/crates/primitives/src/specification.rs +++ b/crates/primitives/src/specification.rs @@ -31,6 +31,8 @@ pub enum SpecId { BEDROCK = 128, #[cfg(feature = "optimism")] REGOLITH = 129, + #[cfg(feature = "taiko")] + KATLA = 100, // TODO(Cecilia): update this range of bits LATEST = u8::MAX, } @@ -58,6 +60,10 @@ impl SpecId { return false; } } + #[cfg(feature = "taiko")] + { + // TODO(Cecilia): update this range of bits + } our as u8 >= other as u8 } @@ -84,6 +90,8 @@ impl From<&str> for SpecId { "Bedrock" => SpecId::BEDROCK, #[cfg(feature = "optimism")] "Regolith" => SpecId::REGOLITH, + #[cfg(feature = "taiko")] + "Katla" => SpecId::KATLA, _ => Self::LATEST, } } @@ -110,6 +118,17 @@ pub trait Spec: Sized { return false; } } + #[cfg(feature = "taiko")] + { + // TODO(Cecilia): update this range of bits + let is_self_taiko = Self::SPEC_ID == SpecId::KATLA; + let input_not_taiko = spec_id != SpecId::KATLA; + let after_merge = spec_id > SpecId::MERGE; + + if is_self_taiko && input_not_taiko && after_merge { + return false; + } + } Self::SPEC_ID as u8 >= spec_id as u8 } @@ -152,6 +171,10 @@ spec!(BEDROCK, BedrockSpec); #[cfg(feature = "optimism")] spec!(REGOLITH, RegolithSpec); +// Taiko Hardforks +#[cfg(feature = "taiko")] +spec!(KATLA, KatlaSpec); + #[cfg(feature = "optimism")] #[cfg(test)] mod tests { @@ -197,3 +220,21 @@ mod tests { assert!(SpecId::enabled(SpecId::REGOLITH, SpecId::REGOLITH)); } } + +#[cfg(feature = "taiko")] +#[cfg(test)] +mod tests { + use super::*; + + // TODO(Cecilia): update this range of bits + #[test] + fn test_katla_post_merge_hardforks() { + assert!(SpecId::enabled(SpecId::MERGE)); + assert!(!SpecId::enabled(SpecId::SHANGHAI)); + assert!(!SpecId::enabled(SpecId::CANCUN)); + assert!(!SpecId::enabled(SpecId::LATEST)); + assert!(!SpecId::enabled(SpecId::BEDROCK)); + assert!(!SpecId::enabled(SpecId::REGOLITH)); + assert!(SpecId::enabled(SpecId::KATLA)); + } +} \ No newline at end of file diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index 577b219e3f..ca4b84b7f2 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -21,6 +21,9 @@ use revm_precompile::{Precompile, Precompiles}; #[cfg(feature = "optimism")] use crate::optimism; +#[cfg(feature = "taiko")] +use crate::taiko; + pub struct EVMData<'a, DB: Database> { pub env: &'a mut Env, pub journaled_state: JournaledState,