diff --git a/lib/src/builder/execute.rs b/lib/src/builder/execute.rs index 438141de..4272f6ee 100644 --- a/lib/src/builder/execute.rs +++ b/lib/src/builder/execute.rs @@ -24,7 +24,7 @@ use revm::{ taiko, Database, DatabaseCommit, Evm, }; use ruint::aliases::U256; -use zeth_primitives::{mpt::MptNode, receipt::Receipt, Bloom, RlpBytes}; +use zeth_primitives::{mpt::MptNode, receipt::Receipt, Bloom, Rlp2718Bytes, RlpBytes}; use super::TxExecStrategy; use crate::{ @@ -215,11 +215,8 @@ impl TxExecStrategy for TkoTxExecStrategy { // Add receipt and tx to tries let trie_key = actual_tx_no.to_rlp(); - // This will encode the tx inside an rlp value wrapper - let tx_rlp = tx.to_rlp(); - // Extract the actual tx rlp encoding - let tx_rlp = tx_rlp[tx_rlp.len() - tx.inner_length() - 1..].to_vec(); - tx_trie.insert_rlp_encoded(&trie_key, tx_rlp)?; + // Add to tx trie + tx_trie.insert_rlp_encoded(&trie_key, tx.to_rlp_2718())?; // Add to receipt trie receipt_trie.insert_rlp(&trie_key, receipt)?; diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index bb5d9b3b..b201aedc 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -13,6 +13,7 @@ alloy-dyn-abi = { version = "0.6",default-features = false, optional = true } alloy-rlp = { version = "0.3", default-features = false } alloy-rlp-derive = { version = "0.3", default-features = false } alloy-rpc-types = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } +alloy-eips = { git = "https://github.com/brechtpd/alloy", branch = "header-serialize" } anyhow = { version = "1.0", default-features = false } bytes = { version = "1.5", default-features = false } k256 = { version = "^0.13.3", features = ["ecdsa"], default_features = false } diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index c280f0c5..ffb20cdc 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -26,6 +26,7 @@ pub mod signature; #[cfg(feature = "revm")] pub mod revm; +pub use alloy_eips; pub use alloy_primitives::*; pub use alloy_rlp as rlp; @@ -47,3 +48,20 @@ where out } } + +pub trait Rlp2718Bytes { + /// Returns the RLP-encoding. + fn to_rlp_2718(&self) -> Vec; +} + +impl Rlp2718Bytes for T +where + T: alloy_eips::eip2718::Encodable2718, +{ + #[inline] + fn to_rlp_2718(&self) -> Vec { + let mut out = Vec::new(); + self.encode_2718(&mut out); + out + } +} diff --git a/raiko-guests/risc0/guest/Cargo.lock b/raiko-guests/risc0/guest/Cargo.lock index 373a65ef..34552f38 100644 --- a/raiko-guests/risc0/guest/Cargo.lock +++ b/raiko-guests/risc0/guest/Cargo.lock @@ -2677,6 +2677,7 @@ dependencies = [ name = "zeth-primitives" version = "0.1.0" dependencies = [ + "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-rlp-derive", diff --git a/raiko-guests/succinct/Cargo.lock b/raiko-guests/succinct/Cargo.lock index 57b39e1f..9a9d5240 100644 --- a/raiko-guests/succinct/Cargo.lock +++ b/raiko-guests/succinct/Cargo.lock @@ -2361,6 +2361,7 @@ dependencies = [ name = "zeth-primitives" version = "0.1.0" dependencies = [ + "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-rlp-derive",