Skip to content

Commit

Permalink
Merge pull request risc0#77 from taikoxyz/fix-tx-trie-rlp-encoding
Browse files Browse the repository at this point in the history
fix tx trie rlp encoding for legacy transactions
  • Loading branch information
CeciliaZ030 authored Mar 29, 2024
2 parents 6eb3d2d + 2a82556 commit 5e4aab9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/src/builder/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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)?;

Expand Down
1 change: 1 addition & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
18 changes: 18 additions & 0 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -47,3 +48,20 @@ where
out
}
}

pub trait Rlp2718Bytes {
/// Returns the RLP-encoding.
fn to_rlp_2718(&self) -> Vec<u8>;
}

impl<T> Rlp2718Bytes for T
where
T: alloy_eips::eip2718::Encodable2718,
{
#[inline]
fn to_rlp_2718(&self) -> Vec<u8> {
let mut out = Vec::new();
self.encode_2718(&mut out);
out
}
}
1 change: 1 addition & 0 deletions raiko-guests/risc0/guest/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions raiko-guests/succinct/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5e4aab9

Please sign in to comment.