diff --git a/Cargo.lock b/Cargo.lock index 545e39190424..ee56abd5b14f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,7 +132,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "arbitrary", - "c-kzg", + "c-kzg 1.0.2", "proptest", "proptest-derive", "serde", @@ -166,7 +166,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "arbitrary", - "c-kzg", + "c-kzg 1.0.2", "derive_more", "once_cell", "proptest", @@ -1577,6 +1577,19 @@ dependencies = [ "serde", ] +[[package]] +name = "c-kzg" +version = "1.0.0" +source = "git+https://github.com/brechtpd/c-kzg-4844?branch=for-alpha7#3bf0372e8c7a4ba908aff65da0508fcaaf9d38e6" +dependencies = [ + "blst", + "cc", + "glob", + "hex", + "libc", + "serde", +] + [[package]] name = "c-kzg" version = "1.0.2" @@ -2698,14 +2711,23 @@ name = "ef-tests" version = "1.0.0-rc.2" dependencies = [ "alloy-rlp", + "anyhow", "rayon", "reth-chainspec", "reth-db", "reth-db-api", "reth-evm-ethereum", + "reth-network-api", + "reth-node-ethereum", "reth-primitives", "reth-provider", + "reth-revm", + "reth-rpc", + "reth-rpc-types", + "reth-rpc-types-compat", "reth-stages", + "reth-tasks", + "reth-transaction-pool", "serde", "serde_json", "thiserror", @@ -5331,18 +5353,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "p256" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" -dependencies = [ - "ecdsa", - "elliptic-curve", - "primeorder", - "sha2 0.10.8", -] - [[package]] name = "page_size" version = "0.6.0" @@ -5754,15 +5764,6 @@ dependencies = [ "syn 2.0.66", ] -[[package]] -name = "primeorder" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" -dependencies = [ - "elliptic-curve", -] - [[package]] name = "primitive-types" version = "0.12.2" @@ -6340,7 +6341,7 @@ dependencies = [ "reth-revm", "reth-tasks", "reth-transaction-pool", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "tokio", "tracing", ] @@ -6961,7 +6962,7 @@ dependencies = [ "reth-primitives", "reth-rpc-types", "reth-rpc-types-compat", - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "serde", "serde_json", "sha2 0.10.8", @@ -6995,7 +6996,7 @@ dependencies = [ "reth-provider", "reth-revm", "reth-transaction-pool", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "tracing", ] @@ -7022,8 +7023,8 @@ dependencies = [ "reth-primitives", "reth-prune-types", "reth-storage-errors", - "revm", - "revm-primitives", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", ] [[package]] @@ -7032,7 +7033,10 @@ version = "1.0.0-rc.2" dependencies = [ "alloy-eips", "alloy-sol-types", + "anyhow", + "lazy_static", "reth-chainspec", + "reth-consensus", "reth-ethereum-consensus", "reth-evm", "reth-execution-types", @@ -7040,7 +7044,7 @@ dependencies = [ "reth-prune-types", "reth-revm", "reth-testing-utils", - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "secp256k1", "serde_json", ] @@ -7058,8 +7062,8 @@ dependencies = [ "reth-provider", "reth-prune-types", "reth-revm", - "revm", - "revm-primitives", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "thiserror", "tracing", ] @@ -7073,7 +7077,7 @@ dependencies = [ "reth-consensus", "reth-prune-types", "reth-storage-errors", - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "thiserror-no-std", ] @@ -7087,7 +7091,7 @@ dependencies = [ "reth-execution-errors", "reth-primitives", "reth-trie", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", ] [[package]] @@ -7592,7 +7596,7 @@ dependencies = [ "reth-rpc-types-compat", "reth-tracing", "reth-transaction-pool", - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "serde", "serde_json", "thiserror", @@ -7628,7 +7632,7 @@ dependencies = [ "reth-rpc-types", "reth-rpc-types-compat", "reth-transaction-pool", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "sha2 0.10.8", "thiserror", "tracing", @@ -7652,7 +7656,7 @@ dependencies = [ "reth-provider", "reth-rpc-types", "reth-transaction-pool", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "serde_json", "thiserror", "tokio", @@ -7699,7 +7703,7 @@ dependencies = [ "assert_matches", "byteorder", "bytes", - "c-kzg", + "c-kzg 1.0.2", "criterion", "derive_more", "modular-bitfield", @@ -7716,8 +7720,9 @@ dependencies = [ "reth-primitives-traits", "reth-static-file-types", "reth-trie-common", - "revm", - "revm-primitives", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", + "revm-precompile 7.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "roaring", "secp256k1", "serde", @@ -7749,7 +7754,7 @@ dependencies = [ "proptest-derive", "rand 0.8.5", "reth-codecs", - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "serde", "test-fuzz", ] @@ -7788,7 +7793,7 @@ dependencies = [ "reth-storage-errors", "reth-testing-utils", "reth-trie", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "strum", "tempfile", "tokio", @@ -7858,7 +7863,7 @@ dependencies = [ "reth-storage-api", "reth-storage-errors", "reth-trie", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "tracing", ] @@ -7904,9 +7909,9 @@ dependencies = [ "reth-tasks", "reth-testing-utils", "reth-transaction-pool", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "revm-inspectors", - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "schnellru", "secp256k1", "serde", @@ -8221,7 +8226,7 @@ dependencies = [ "reth-stages-types", "reth-storage-errors", "reth-trie", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", ] [[package]] @@ -8342,7 +8347,7 @@ dependencies = [ "reth-stages-types", "reth-storage-errors", "reth-trie-common", - "revm", + "revm 9.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "serde_json", "similar-asserts", "tokio", @@ -8372,7 +8377,7 @@ dependencies = [ "proptest-derive", "reth-codecs", "reth-primitives-traits", - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", "serde", "serde_json", "test-fuzz", @@ -8404,6 +8409,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "revm" +version = "9.0.0" +source = "git+https://github.com/taikoxyz/revm.git?branch=v36-taiko#337a98f982e165c5a84cfc25d965344bfd4081bc" +dependencies = [ + "auto_impl", + "cfg-if", + "dyn-clone", + "revm-interpreter 5.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", + "revm-precompile 7.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", + "serde", + "serde_json", +] + [[package]] name = "revm" version = "9.0.0" @@ -8412,8 +8431,8 @@ dependencies = [ "auto_impl", "cfg-if", "dyn-clone", - "revm-interpreter", - "revm-precompile", + "revm-interpreter 5.0.0 (git+https://github.com/bluealloy/revm.git?rev=41e2f7f)", + "revm-precompile 7.0.0 (git+https://github.com/bluealloy/revm.git?rev=41e2f7f)", "serde", "serde_json", ] @@ -8430,32 +8449,56 @@ dependencies = [ "boa_engine", "boa_gc", "colorchoice", - "revm", + "revm 9.0.0 (git+https://github.com/bluealloy/revm.git?rev=41e2f7f)", "serde_json", "thiserror", ] +[[package]] +name = "revm-interpreter" +version = "5.0.0" +source = "git+https://github.com/taikoxyz/revm.git?branch=v36-taiko#337a98f982e165c5a84cfc25d965344bfd4081bc" +dependencies = [ + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", + "serde", +] + [[package]] name = "revm-interpreter" version = "5.0.0" source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" dependencies = [ - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/bluealloy/revm.git?rev=41e2f7f)", "serde", ] [[package]] name = "revm-precompile" version = "7.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" +source = "git+https://github.com/taikoxyz/revm.git?branch=v36-taiko#337a98f982e165c5a84cfc25d965344bfd4081bc" dependencies = [ "aurora-engine-modexp", "blst", - "c-kzg", + "c-kzg 1.0.0", + "k256", + "once_cell", + "revm-primitives 4.0.0 (git+https://github.com/taikoxyz/revm.git?branch=v36-taiko)", + "ripemd", + "secp256k1", + "sha2 0.10.8", + "substrate-bn", +] + +[[package]] +name = "revm-precompile" +version = "7.0.0" +source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" +dependencies = [ + "aurora-engine-modexp", + "c-kzg 1.0.2", "k256", "once_cell", - "p256", - "revm-primitives", + "revm-primitives 4.0.0 (git+https://github.com/bluealloy/revm.git?rev=41e2f7f)", "ripemd", "secp256k1", "sha2 0.10.8", @@ -8465,13 +8508,13 @@ dependencies = [ [[package]] name = "revm-primitives" version = "4.0.0" -source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" +source = "git+https://github.com/taikoxyz/revm.git?branch=v36-taiko#337a98f982e165c5a84cfc25d965344bfd4081bc" dependencies = [ "alloy-primitives", "auto_impl", "bitflags 2.5.0", "bitvec", - "c-kzg", + "c-kzg 1.0.0", "cfg-if", "derive_more", "dyn-clone", @@ -8482,6 +8525,23 @@ dependencies = [ "serde", ] +[[package]] +name = "revm-primitives" +version = "4.0.0" +source = "git+https://github.com/bluealloy/revm.git?rev=41e2f7f#41e2f7f9740c0fb70c5ba888a36453712b6de39c" +dependencies = [ + "alloy-primitives", + "auto_impl", + "bitflags 2.5.0", + "bitvec", + "cfg-if", + "dyn-clone", + "enumn", + "hashbrown 0.14.5", + "hex", + "serde", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -8888,8 +8948,7 @@ dependencies = [ [[package]] name = "secp256k1" version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +source = "git+https://github.com/CeciliaZ030/rust-secp256k1?branch=sp1-patch#26d5313e6fb992a0f393ffcbf9be3c03b23295f1" dependencies = [ "rand 0.8.5", "secp256k1-sys", @@ -8899,8 +8958,7 @@ dependencies = [ [[package]] name = "secp256k1-sys" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +source = "git+https://github.com/CeciliaZ030/rust-secp256k1?branch=sp1-patch#26d5313e6fb992a0f393ffcbf9be3c03b23295f1" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index cef90dbb9607..edae771ca099 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -504,8 +504,6 @@ similar-asserts = "1.5.0" test-fuzz = "5" # raiko -raiko-core = { git = "https://github.com/taikoxyz/raiko.git", branch = "reth-wip" } -raiko-lib = { git = "https://github.com/taikoxyz/raiko.git", branch = "reth-wip" } anyhow = "1.0" [patch.crates-io] diff --git a/crates/chainspec/Cargo.toml b/crates/chainspec/Cargo.toml index 6bd5bb26a5b0..8702d6851af0 100644 --- a/crates/chainspec/Cargo.toml +++ b/crates/chainspec/Cargo.toml @@ -50,3 +50,4 @@ arbitrary = [ "alloy-chains/arbitrary" ] network = ["reth-network-peers"] +taiko = ["reth-ethereum-forks/taiko"] diff --git a/crates/chainspec/src/spec.rs b/crates/chainspec/src/spec.rs index 18eb95b6e14c..2e6c35a099c4 100644 --- a/crates/chainspec/src/spec.rs +++ b/crates/chainspec/src/spec.rs @@ -118,6 +118,8 @@ pub static TAIKO_A7: Lazy> = Lazy::new(|| { ForkCondition::TTD { fork_block: None, total_difficulty: U256::from(0) }, ), (Hardfork::Shanghai, ForkCondition::Timestamp(0)), + #[cfg(feature = "taiko")] + (Hardfork::Hekla, ForkCondition::Block(0)), ]), deposit_contract: None, ..Default::default() @@ -150,6 +152,10 @@ pub static TAIKO_DEV: Lazy> = Lazy::new(|| { ForkCondition::TTD { fork_block: None, total_difficulty: U256::from(0) }, ), (Hardfork::Shanghai, ForkCondition::Timestamp(0)), + #[cfg(feature = "taiko")] + (Hardfork::Hekla, ForkCondition::Block(0)), + #[cfg(feature = "taiko")] + (Hardfork::Ontake, ForkCondition::Block(20)), //todo ]), deposit_contract: None, ..Default::default() @@ -174,14 +180,16 @@ pub static TAIKO_MAINNET: Lazy> = Lazy::new(|| { (Hardfork::Byzantium, ForkCondition::Block(0)), (Hardfork::Constantinople, ForkCondition::Block(0)), (Hardfork::Petersburg, ForkCondition::Block(0)), - (Hardfork::Istanbul, ForkCondition::Block(1561651)), - (Hardfork::Berlin, ForkCondition::Block(4460644)), - (Hardfork::London, ForkCondition::Block(5062605)), + (Hardfork::Istanbul, ForkCondition::Block(0)), + (Hardfork::Berlin, ForkCondition::Block(0)), + (Hardfork::London, ForkCondition::Block(0)), ( Hardfork::Paris, ForkCondition::TTD { fork_block: None, total_difficulty: U256::from(0) }, ), (Hardfork::Shanghai, ForkCondition::Timestamp(0)), + #[cfg(feature = "taiko")] + (Hardfork::Hekla, ForkCondition::Block(0)), ]), deposit_contract: None, ..Default::default() diff --git a/crates/ethereum-forks/Cargo.toml b/crates/ethereum-forks/Cargo.toml index ac9836c5438a..fc8dab7649ff 100644 --- a/crates/ethereum-forks/Cargo.toml +++ b/crates/ethereum-forks/Cargo.toml @@ -36,6 +36,7 @@ proptest-derive.workspace = true [features] default = ["std", "serde"] +taiko = [] std = ["thiserror-no-std/std"] serde = ["dep:serde"] arbitrary = ["dep:arbitrary", "dep:proptest", "dep:proptest-derive"] diff --git a/crates/ethereum-forks/src/hardfork.rs b/crates/ethereum-forks/src/hardfork.rs index fa095dea5a18..cd10bce4d6bb 100644 --- a/crates/ethereum-forks/src/hardfork.rs +++ b/crates/ethereum-forks/src/hardfork.rs @@ -65,6 +65,12 @@ pub enum Hardfork { Regolith, /// Shanghai: . Shanghai, + /// Hekla: the 1st taiko mainnet version: <> + #[cfg(feature = "taiko")] + Hekla, + /// Ontake: the 2nd taiko mainnet fork: <> + #[cfg(feature = "taiko")] + Ontake, /// Canyon: /// . #[cfg(feature = "optimism")] diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index 449b2ef762b4..c288b071c1a7 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -2,7 +2,8 @@ use crate::{ dao_fork::{DAO_HARDFORK_BENEFICIARY, DAO_HARDKFORK_ACCOUNTS}, - taiko::{check_anchor_tx, TaikoData}, EthEvmConfig, + taiko::{check_anchor_tx, check_anchor_tx_ontake, TaikoData}, + EthEvmConfig, }; use reth_chainspec::{ChainSpec, MAINNET}; pub use reth_consensus::Consensus; @@ -16,7 +17,8 @@ use reth_evm::{ }; use reth_execution_types::ExecutionOutcome; use reth_primitives::{ - BlockNumber, BlockWithSenders, Hardfork, Header, Receipt, Request, Withdrawals, U256, + revm::config::revm_spec, BlockNumber, BlockWithSenders, Hardfork, Head, Header, Receipt, + Request, Withdrawals, U256, }; use reth_prune_types::PruneModes; use reth_revm::{ @@ -31,7 +33,7 @@ use reth_revm::{ }; use revm_primitives::{ db::{Database, DatabaseCommit}, Address, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState, - EVMError, HashSet, + EVMError, HashSet, SpecId, }; use std::sync::Arc; use anyhow::Result; @@ -176,8 +178,28 @@ where // verify the anchor tx if is_anchor { - check_anchor_tx(transaction, sender, &block.block, taiko_data.clone().unwrap()) + let spec_id = revm_spec( + &self.chain_spec, + Head { number: block.number, ..Default::default() }, + ); + if spec_id.is_enabled_in(SpecId::ONTAKE) { + check_anchor_tx_ontake( + transaction, + sender, + &block.block, + taiko_data.clone().unwrap(), + ) .map_err(|e| BlockExecutionError::CanonicalRevert { inner: e.to_string() })?; + } else if spec_id.is_enabled_in(SpecId::HEKLA) { + check_anchor_tx(transaction, sender, &block.block, taiko_data.clone().unwrap()) + .map_err(|e| BlockExecutionError::CanonicalRevert { + inner: e.to_string(), + })?; + } else { + return Err(BlockExecutionError::CanonicalRevert { + inner: "unknown spec id for anchor".to_string(), + }); + } } // If the signature was not valid, the sender address will have been set to zero @@ -211,6 +233,7 @@ where evm.tx_mut().taiko.is_anchor = is_anchor; // set the treasury address evm.tx_mut().taiko.treasury = taiko_data.clone().unwrap().l2_contract; + evm.tx_mut().taiko.basefee_ratio = taiko_data.clone().unwrap().basefee_ratio; // Execute transaction. let res = evm.transact().map_err(move |err| { diff --git a/crates/ethereum/evm/src/taiko.rs b/crates/ethereum/evm/src/taiko.rs index 980cb30f9d60..2060853b4c47 100644 --- a/crates/ethereum/evm/src/taiko.rs +++ b/crates/ethereum/evm/src/taiko.rs @@ -15,6 +15,12 @@ pub struct TaikoData { pub parent_header: Header, /// L2 contract pub l2_contract: Address, + /// base fee sharing ratio + pub basefee_ratio: u8, + /// base fee adjustment quotient + pub basefee_adj_quotient: u8, + /// gas issuance per second + pub gas_issue_per_sec: u32, } /// Anchor tx gas limit @@ -80,8 +86,23 @@ sol! { ) external {} + + function anchorV2( + uint64 _anchorBlockId, + bytes32 _anchorStateRoot, + uint32 _parentGasUsed, + uint32 _gasIssuancePerSecond, + uint8 _basefeeAdjustmentQuotient + ) + external + nonReentrant + {} } +// todo, use compiled abi once test passes +// sol!(TaikoL2, "./res/TaikoL2.json"); +// use TaikoL2::{anchor, anchorV2}; + /// Decode anchor tx data pub fn decode_anchor(bytes: &[u8]) -> Result { anchorCall::abi_decode(bytes, true).map_err(|e| anyhow!(e)) @@ -146,4 +167,73 @@ pub fn check_anchor_tx(tx: &TransactionSigned, from: &Address, block: &Block, ta ); Ok(()) -} \ No newline at end of file +} + +pub fn decode_anchor_ontake(bytes: &[u8]) -> Result { + anchorV2Call::abi_decode(bytes, true).map_err(|e| anyhow!(e)) +} + +/// Verifies the anchor tx correctness in ontake fork +pub fn check_anchor_tx_ontake( + tx: &TransactionSigned, + from: &Address, + block: &Block, + taiko_data: TaikoData, +) -> Result<()> { + let anchor: &reth_primitives::TxEip1559 = + tx.as_eip1559().context(anyhow!("anchor tx is not an EIP1559 tx"))?; + + // Check the signature + check_anchor_signature(tx).context(anyhow!("failed to check anchor signature"))?; + + // Extract the `to` address + let TxKind::Call(to) = anchor.to else { panic!("anchor tx not a smart contract call") }; + // Check that it's from the golden touch address + ensure!(*from == *GOLDEN_TOUCH_ACCOUNT, "anchor transaction from mismatch"); + // Check that the L2 contract is being called + ensure!(to == taiko_data.l2_contract, "anchor transaction to mismatch"); + // Tx can't have any ETH attached + ensure!(anchor.value == U256::from(0), "anchor transaction value mismatch"); + // Tx needs to have the expected gas limit + ensure!(anchor.gas_limit == ANCHOR_GAS_LIMIT, "anchor transaction gas price mismatch"); + // Check needs to have the base fee set to the block base fee + ensure!( + anchor.max_fee_per_gas == block.header.base_fee_per_gas.unwrap().into(), + "anchor transaction gas mismatch" + ); + + /* + uint64 _anchorBlockId, + bytes32 _anchorStateRoot, + uint32 _parentGasUsed, + uint32 _gasIssuancePerSecond, + uint8 _basefeeAdjustmentQuotient + */ + + // Okay now let's decode the anchor tx to verify the inputs + let anchor_call = decode_anchor_ontake(&anchor.input)?; + ensure!( + anchor_call._anchorStateRoot == taiko_data.l1_header.state_root, + "L1 state root mismatch" + ); + ensure!(anchor_call._anchorBlockId == taiko_data.l1_header.number, "L1 block number mismatch"); + ensure!( + anchor_call._anchorStateRoot == taiko_data.l1_header.state_root, + "L1 state root mismatch" + ); + // The parent gas used input needs to match the gas used value of the parent block + ensure!( + anchor_call._parentGasUsed == taiko_data.parent_header.gas_used as u32, + "parentGasUsed mismatch" + ); + ensure!( + anchor_call._gasIssuancePerSecond == taiko_data.gas_issue_per_sec, + "gas issuance per second mismatch" + ); + ensure!( + anchor_call._basefeeAdjustmentQuotient == taiko_data.basefee_adj_quotient, + "basefee adjustment quotient mismatch" + ); + + Ok(()) +} diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 080df0b8e3ab..d1f4cf25207a 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -121,6 +121,7 @@ optimism = [ taiko = [ "revm-primitives/taiko", "revm/taiko", + "reth-ethereum-forks/taiko", ] alloy-compat = [ "reth-primitives-traits/alloy-compat", diff --git a/crates/primitives/src/revm/config.rs b/crates/primitives/src/revm/config.rs index 5914dbf59348..f06814e5feea 100644 --- a/crates/primitives/src/revm/config.rs +++ b/crates/primitives/src/revm/config.rs @@ -52,6 +52,15 @@ pub fn revm_spec(chain_spec: &ChainSpec, block: Head) -> revm_primitives::SpecId } } + #[cfg(feature = "taiko")] + if chain_spec.is_taiko() { + if chain_spec.fork(Hardfork::Ontake).active_at_head(&block) { + return revm_primitives::ONTAKE; + } else if chain_spec.fork(Hardfork::Hekla).active_at_head(&block) { + return revm_primitives::HEKLA; + } + } + if chain_spec.fork(Hardfork::Prague).active_at_head(&block) { revm_primitives::PRAGUE } else if chain_spec.fork(Hardfork::Cancun).active_at_head(&block) { diff --git a/crates/primitives/src/revm/env.rs b/crates/primitives/src/revm/env.rs index 4cf85c273460..5bb81562f710 100644 --- a/crates/primitives/src/revm/env.rs +++ b/crates/primitives/src/revm/env.rs @@ -212,7 +212,7 @@ fn fill_tx_env_with_system_contract_call( enveloped_tx: Some(Bytes::default()), }, #[cfg(feature = "taiko")] - taiko: revm_primitives::TaikoFields { treasury: Address::default(), is_anchor: false }, + taiko: revm_primitives::TaikoFields { treasury: Address::default(), is_anchor: false, basefee_ratio: 0u8 }, }; // ensure the block gas limit is >= the tx diff --git a/testing/ef-tests/Cargo.toml b/testing/ef-tests/Cargo.toml index 0eef88fabf84..6fc08af3276d 100644 --- a/testing/ef-tests/Cargo.toml +++ b/testing/ef-tests/Cargo.toml @@ -41,6 +41,4 @@ thiserror.workspace = true rayon.workspace = true # raiko -raiko-core.workspace = true -raiko-lib.workspace = true anyhow.workspace = true