Skip to content

Commit c7aee3a

Browse files
committed
init
1 parent 23cbac4 commit c7aee3a

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

crates/primitives/src/env.rs

+45
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ pub struct OptimismFields {
9494
pub enveloped_tx: Option<Bytes>,
9595
}
9696

97+
#[cfg(feature = "taiko")]
98+
#[derive(Clone, Debug, Default, PartialEq, Eq)]
99+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
100+
pub struct TaikoFields {
101+
pub is_anchor: bool
102+
}
103+
97104
impl BlockEnv {
98105
/// Takes `blob_excess_gas` saves it inside env
99106
/// and calculates `blob_fee` with [`BlobGasAndFee`].
@@ -183,6 +190,11 @@ pub struct TxEnv {
183190
#[cfg_attr(feature = "serde", serde(flatten))]
184191
#[cfg(feature = "optimism")]
185192
pub optimism: OptimismFields,
193+
194+
#[cfg_attr(feature = "serde", serde(flatten))]
195+
#[cfg(feature = "taiko")]
196+
pub optimism: TaikoFields,
197+
186198
}
187199

188200
impl TxEnv {
@@ -306,6 +318,9 @@ pub struct CfgEnv {
306318
/// compilation with the optimism feature flag.
307319
#[cfg(feature = "optimism")]
308320
pub optimism: bool,
321+
322+
#[cfg(feature = "taiko")]
323+
pub taiko: bool,
309324
}
310325

311326
impl CfgEnv {
@@ -368,6 +383,16 @@ impl CfgEnv {
368383
pub fn is_optimism(&self) -> bool {
369384
false
370385
}
386+
387+
#[cfg(feature = "taiko")]
388+
pub fn is_taiko(&self) -> bool {
389+
self.taiko
390+
}
391+
392+
#[cfg(not(feature = "taiko"))]
393+
pub fn is_taiko(&self) -> bool {
394+
false
395+
}
371396
}
372397

373398
/// What bytecode analysis to perform.
@@ -406,6 +431,8 @@ impl Default for CfgEnv {
406431
disable_base_fee: false,
407432
#[cfg(feature = "optimism")]
408433
optimism: false,
434+
#[cfg(feature = "taiko")]
435+
taiko: false,
409436
}
410437
}
411438
}
@@ -442,6 +469,8 @@ impl Default for TxEnv {
442469
max_fee_per_blob_gas: None,
443470
#[cfg(feature = "optimism")]
444471
optimism: OptimismFields::default(),
472+
#[cfg(feature = "taiko")]
473+
taiko: TaikoFields::default(),
445474
}
446475
}
447476
}
@@ -503,6 +532,11 @@ impl Env {
503532
}
504533
}
505534

535+
#[cfg(feature = "taiko")]
536+
if self.cfg.taiko {
537+
// TODO:(Cecilia)
538+
}
539+
506540
let gas_limit = self.tx.gas_limit;
507541
let effective_gas_price = self.effective_gas_price();
508542
let is_create = self.tx.transact_to.is_create();
@@ -622,6 +656,11 @@ impl Env {
622656
return Ok(());
623657
}
624658

659+
#[cfg(feature = "taiko")]
660+
if self.cfg.taiko {
661+
// TODO(Cecilia): do we do anything with this?
662+
}
663+
625664
// Check that the transaction's nonce is correct
626665
if let Some(tx) = self.tx.nonce {
627666
let state = account.info.nonce;
@@ -711,6 +750,12 @@ mod tests {
711750
.is_ok());
712751
}
713752

753+
#[cfg(feature = "taiko")]
754+
#[test]
755+
fn test_taiko() {
756+
// TODO(Cecilia): taiko tests
757+
}
758+
714759
#[test]
715760
fn test_validate_tx_chain_id() {
716761
let mut env = Env::default();

crates/primitives/src/specification.rs

+41
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pub enum SpecId {
3131
BEDROCK = 128,
3232
#[cfg(feature = "optimism")]
3333
REGOLITH = 129,
34+
#[cfg(feature = "taiko")]
35+
KATLA = 100, // TODO(Cecilia): update this range of bits
3436
LATEST = u8::MAX,
3537
}
3638

@@ -58,6 +60,10 @@ impl SpecId {
5860
return false;
5961
}
6062
}
63+
#[cfg(feature = "taiko")]
64+
{
65+
// TODO(Cecilia): update this range of bits
66+
}
6167

6268
our as u8 >= other as u8
6369
}
@@ -84,6 +90,8 @@ impl From<&str> for SpecId {
8490
"Bedrock" => SpecId::BEDROCK,
8591
#[cfg(feature = "optimism")]
8692
"Regolith" => SpecId::REGOLITH,
93+
#[cfg(feature = "taiko")]
94+
"Katla" => SpecId::KATLA,
8795
_ => Self::LATEST,
8896
}
8997
}
@@ -110,6 +118,17 @@ pub trait Spec: Sized {
110118
return false;
111119
}
112120
}
121+
#[cfg(feature = "taiko")]
122+
{
123+
// TODO(Cecilia): update this range of bits
124+
let is_self_taiko = Self::SPEC_ID == SpecId::KATLA;
125+
let input_not_taiko = spec_id != SpecId::KATLA;
126+
let after_merge = spec_id > SpecId::MERGE;
127+
128+
if is_self_taiko && input_not_taiko && after_merge {
129+
return false;
130+
}
131+
}
113132

114133
Self::SPEC_ID as u8 >= spec_id as u8
115134
}
@@ -152,6 +171,10 @@ spec!(BEDROCK, BedrockSpec);
152171
#[cfg(feature = "optimism")]
153172
spec!(REGOLITH, RegolithSpec);
154173

174+
// Taiko Hardforks
175+
#[cfg(feature = "taiko")]
176+
spec!(KATLA, KatlaSpec);
177+
155178
#[cfg(feature = "optimism")]
156179
#[cfg(test)]
157180
mod tests {
@@ -197,3 +220,21 @@ mod tests {
197220
assert!(SpecId::enabled(SpecId::REGOLITH, SpecId::REGOLITH));
198221
}
199222
}
223+
224+
#[cfg(feature = "taiko")]
225+
#[cfg(test)]
226+
mod tests {
227+
use super::*;
228+
229+
// TODO(Cecilia): update this range of bits
230+
#[test]
231+
fn test_katla_post_merge_hardforks() {
232+
assert!(SpecId::enabled(SpecId::MERGE));
233+
assert!(!SpecId::enabled(SpecId::SHANGHAI));
234+
assert!(!SpecId::enabled(SpecId::CANCUN));
235+
assert!(!SpecId::enabled(SpecId::LATEST));
236+
assert!(!SpecId::enabled(SpecId::BEDROCK));
237+
assert!(!SpecId::enabled(SpecId::REGOLITH));
238+
assert!(SpecId::enabled(SpecId::KATLA));
239+
}
240+
}

crates/revm/src/evm_impl.rs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ use revm_precompile::{Precompile, Precompiles};
2121
#[cfg(feature = "optimism")]
2222
use crate::optimism;
2323

24+
#[cfg(feature = "taiko")]
25+
use crate::taiko;
26+
2427
pub struct EVMData<'a, DB: Database> {
2528
pub env: &'a mut Env,
2629
pub journaled_state: JournaledState,

0 commit comments

Comments
 (0)