Skip to content

feat(repo): migrate to latest reth/alloy/trevm #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,35 @@ signet-zenith = { path = "crates/zenith" }
ajj = { version = "0.3.1" }

# trevm
trevm = { version = "0.20.10", features = ["full_env_cfg"] }
trevm = { version = "0.23.4", features = ["full_env_cfg"] }

# Alloy periphery crates
alloy = { version = "=0.12.6", features = [
alloy = { version = "=1.0.5", features = [
"full",
"rpc-types-mev",
"genesis",
"arbitrary",
] }
alloy-contract = { version = "=0.12.6", features = ["pubsub"] }
alloy-contract = { version = "=1.0.5", features = ["pubsub"] }

# Reth
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-db-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-eth-wire-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-exex-test-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-network-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-db-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-eth-wire-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-exex-test-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-network-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }

# Foundry periphery
foundry-blob-explorers = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion crates/bundle/src/call/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ where

// Taking these clears the order detector
let (orders, fills) =
trevm.inner_mut_unchecked().data.inspector.as_mut_detector().take_aggregates();
trevm.inner_mut_unchecked().inspector.as_mut_detector().take_aggregates();
self.response.orders = orders;
self.response.fills = fills;

Expand Down
2 changes: 1 addition & 1 deletion crates/bundle/src/call/ty.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Signet bundle types.
use alloy::{
consensus::{Transaction, TxEnvelope},
consensus::{transaction::SignerRecoverable, Transaction, TxEnvelope},
eips::{eip2718::Encodable2718, BlockNumberOrTag, Decodable2718},
primitives::{keccak256, Bytes, B256, U256},
rlp::Buf,
Expand Down
2 changes: 1 addition & 1 deletion crates/bundle/src/send/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl SignetEthBundle {
/// checks that the tokens can actually be transferred.
pub async fn alloy_validate_fills_onchain<Db, P, N>(
&self,
orders: HostOrdersInstance<(), P, N>,
orders: HostOrdersInstance<P, N>,
) -> Result<(), SignetEthBundleError<Db>>
where
Db: Database,
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use alloy::{
consensus::{ReceiptEnvelope, TxEip1559},
primitives::{Address, PrimitiveSignature as Signature, U256},
primitives::{Address, Signature, U256},
sol_types::SolCall,
};
use reth::{
Expand Down
47 changes: 31 additions & 16 deletions crates/evm/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ use alloy::{
primitives::{Address, Bloom, U256},
};
use reth::{
core::primitives::SignedTransaction,
primitives::{
Block, BlockBody, Receipt, RecoveredBlock, SealedHeader, Transaction, TransactionSigned,
},
core::primitives::SignerRecoverable,
primitives::{Block, BlockBody, Receipt, RecoveredBlock, SealedHeader, TransactionSigned},
providers::ExecutionOutcome,
};
use signet_extract::{ExtractedEvent, Extracts};
Expand Down Expand Up @@ -136,8 +134,9 @@ impl Tx for FillShim<'_> {

*caller = self.1;

match self.0.as_ref() {
Transaction::Legacy(tx) => {
match self.0 {
TransactionSigned::Legacy(tx) => {
let tx = tx.tx();
*tx_type = TxType::Legacy as u8;
*gas_limit = tx.gas_limit;
*gas_price = tx.gas_price;
Expand All @@ -152,7 +151,8 @@ impl Tx for FillShim<'_> {
*max_fee_per_blob_gas = 0;
authorization_list.clear();
}
Transaction::Eip2930(tx) => {
TransactionSigned::Eip2930(tx) => {
let tx = tx.tx();
*tx_type = TxType::Eip2930 as u8;
*gas_limit = tx.gas_limit;
*gas_price = tx.gas_price;
Expand All @@ -167,7 +167,8 @@ impl Tx for FillShim<'_> {
*max_fee_per_blob_gas = 0;
authorization_list.clear();
}
Transaction::Eip1559(tx) => {
TransactionSigned::Eip1559(tx) => {
let tx = tx.tx();
*tx_type = TxType::Eip1559 as u8;
*gas_limit = tx.gas_limit;
*gas_price = tx.max_fee_per_gas;
Expand All @@ -182,7 +183,8 @@ impl Tx for FillShim<'_> {
*max_fee_per_blob_gas = 0;
authorization_list.clear();
}
Transaction::Eip4844(tx) => {
TransactionSigned::Eip4844(tx) => {
let tx = tx.tx();
*tx_type = TxType::Eip4844 as u8;
*gas_limit = tx.gas_limit;
*gas_price = tx.max_fee_per_gas;
Expand All @@ -197,7 +199,8 @@ impl Tx for FillShim<'_> {
*max_fee_per_blob_gas = tx.max_fee_per_blob_gas;
authorization_list.clear();
}
Transaction::Eip7702(tx) => {
TransactionSigned::Eip7702(tx) => {
let tx = tx.tx();
*tx_type = TxType::Eip7702 as u8;
*gas_limit = tx.gas_limit;
*gas_price = tx.max_fee_per_gas;
Expand All @@ -210,7 +213,13 @@ impl Tx for FillShim<'_> {
access_list.clone_from(&tx.access_list);
blob_hashes.clear();
*max_fee_per_blob_gas = 0;
authorization_list.clone_from(&tx.authorization_list);
authorization_list.clone_from(
&tx.authorization_list
.iter()
.cloned()
.map(alloy::signers::Either::Left)
.collect(),
);
}
}
}
Expand Down Expand Up @@ -438,7 +447,7 @@ impl<'a, 'b> SignetDriver<'a, 'b> {
{
// Taking these clears the context for reuse.
let (agg_orders, agg_fills) =
trevm.inner_mut_unchecked().data.inspector.as_mut_detector().take_aggregates();
trevm.inner_mut_unchecked().inspector.as_mut_detector().take_aggregates();

// We check the AggregateFills here, and if it fails, we discard the
// transaction outcome and push a failure receipt.
Expand Down Expand Up @@ -486,7 +495,7 @@ impl<'a, 'b> SignetDriver<'a, 'b> {
let (result, trevm) = trevm.accept();

// Create a receipt for the transaction.
let tx_env = trevm.inner().data.ctx.tx();
let tx_env = trevm.inner().ctx.tx();
let sender = tx_env.caller;
// 4844 transactions are not allowed
let receipt = self.make_receipt(result).into();
Expand Down Expand Up @@ -936,7 +945,7 @@ mod test {
SignableTransaction, TxEip1559,
},
primitives::{Sealable, B256, B64},
signers::{local::PrivateKeySigner, SignerSync},
signers::{local::PrivateKeySigner, Signature, SignerSync},
};
use reth::primitives::{Block, RecoveredBlock, Transaction};
use signet_extract::ExtractedEvent;
Expand Down Expand Up @@ -1158,7 +1167,7 @@ mod test {
let user = Address::repeat_byte(2);

// Set up a fake event
let fake_tx = TransactionSigned::default();
let fake_tx = fake_tx();
let fake_receipt: reth::primitives::Receipt = Default::default();

let enter = signet_zenith::Passage::Enter {
Expand Down Expand Up @@ -1199,7 +1208,7 @@ mod test {
let recipient = Address::repeat_byte(2);

// Set up a couple fake events
let fake_tx = TransactionSigned::default();
let fake_tx = fake_tx();
let fake_receipt: reth::primitives::Receipt = Default::default();

let enter = signet_zenith::Passage::Enter {
Expand Down Expand Up @@ -1251,4 +1260,10 @@ mod test {
assert_eq!(receipts.len(), 2);
assert_eq!(trevm.read_balance(recipient), U256::from(100));
}

fn fake_tx() -> TransactionSigned {
let tx = TxEip1559::default();
let signature = Signature::test_signature();
TransactionSigned::new_unhashed(tx.into(), signature)
}
}
4 changes: 2 additions & 2 deletions crates/evm/src/orders/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ where
return;
}

if let Ok(Log { data, .. }) = RollupOrders::Order::decode_log(&log, true) {
if let Ok(Log { data, .. }) = RollupOrders::Order::decode_log(&log) {
self.orders.add(data);
} else if let Ok(Log { data, .. }) = RollupOrders::Filled::decode_log(&log, true) {
} else if let Ok(Log { data, .. }) = RollupOrders::Filled::decode_log(&log) {
self.filleds.add(data);
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/extract/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl From<Transactor::Transact> for Events {
impl Events {
/// Decode a [`Passage`] event from a log.
pub fn decode_passage(log: &Log<LogData>, filter_chain_id: u64) -> Option<Self> {
let event = PassageEvents::decode_log(log, true).ok().map(|log| log.data)?;
let event = PassageEvents::decode_log(log).ok().map(|log| log.data)?;

match event {
PassageEvents::Enter(e) if e.rollup_chain_id() == filter_chain_id => {
Expand All @@ -76,7 +76,7 @@ impl Events {

/// Decode a [`Zenith`] event from a log.
pub fn decode_zenith(log: &Log<LogData>, filter_chain_id: u64) -> Option<Self> {
let event = ZenithEvents::decode_log(log, true).ok().map(|log| log.data)?;
let event = ZenithEvents::decode_log(log).ok().map(|log| log.data)?;

match event {
ZenithEvents::BlockSubmitted(e) if e.rollup_chain_id() == filter_chain_id => {
Expand All @@ -88,7 +88,7 @@ impl Events {

/// Decode a [`Transactor`] event from a log.
pub fn decode_transactor(log: &Log<LogData>, filter_chain_id: u64) -> Option<Self> {
let event = TransactorEvents::decode_log(log, true).ok().map(|log| log.data)?;
let event = TransactorEvents::decode_log(log).ok().map(|log| log.data)?;

match event {
TransactorEvents::Transact(e) if e.rollup_chain_id() == filter_chain_id => {
Expand All @@ -100,7 +100,7 @@ impl Events {

/// Decode an [`RollupOrders`] event from a log.
pub fn decode_orders(log: &Log<LogData>, filter_chain_id: u64) -> Option<Self> {
let event = RollupOrdersEvents::decode_log(log, true).ok().map(|log| log.data)?;
let event = RollupOrdersEvents::decode_log(log).ok().map(|log| log.data)?;

match event {
RollupOrdersEvents::Filled(mut e) => {
Expand Down
7 changes: 2 additions & 5 deletions crates/extract/src/extracted.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use alloy::{
eips::Typed2718,
primitives::{Log, TxHash, U256},
};
use alloy::primitives::{Log, TxHash, U256};
use reth::primitives::{Receipt, TransactionSigned};
use signet_zenith::{Passage, RollupOrders, Transactor, Zenith};

Expand Down Expand Up @@ -191,7 +188,7 @@ impl ExtractedEvent<'_, Zenith::BlockSubmitted> {
}

/// True if the transaction is an EIP-4844 transaction.
pub fn is_eip4844(&self) -> bool {
pub const fn is_eip4844(&self) -> bool {
self.tx.is_eip4844()
}
}
17 changes: 15 additions & 2 deletions crates/extract/src/test_utils/host_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
Events, Extracts,
};
use alloy::{
consensus::{constants::GWEI_TO_WEI, BlobTransactionSidecar, TxEip4844},
consensus::{constants::GWEI_TO_WEI, BlobTransactionSidecar, TxEip1559, TxEip4844},
primitives::{Address, Bytes, FixedBytes, Log, LogData, Sealable, B256, U256},
signers::Signature,
};
Expand Down Expand Up @@ -277,7 +277,20 @@ impl HostBlockSpec {

/// Make dummy txns. The blob txn will always be at the end of the block
fn make_txns(&self) -> Vec<TransactionSigned> {
self.receipts.iter().map(|_| Default::default()).chain(self.blob_txn()).collect()
self.receipts
.iter()
.map(|_| {
Some(
alloy::consensus::Signed::new_unhashed(
TxEip1559::default(),
Signature::test_signature(),
)
.into(),
)
})
.chain(std::iter::once(self.blob_txn()))
.flatten()
.collect()
}

/// Get the block number
Expand Down
11 changes: 6 additions & 5 deletions crates/rpc/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use alloy::{
rpc::types::{FeeHistory, Filter, Log},
};
use reth::{
core::primitives::SignedTransaction,
core::primitives::SignerRecoverable,
primitives::{Block, EthPrimitives, Receipt, Recovered, RecoveredBlock, TransactionSigned},
providers::{
providers::{BlockchainProvider, ProviderNodeTypes},
Expand Down Expand Up @@ -403,7 +403,7 @@ where
let hash = *tx.hash();
let signature = *tx.signature();

let inner: TxEnvelope = match tx.into_inner().into_transaction() {
let inner: TxEnvelope = match tx.into_inner().into_typed_transaction() {
reth::primitives::Transaction::Legacy(tx) => {
Signed::new_unchecked(tx, signature, hash).into()
}
Expand Down Expand Up @@ -727,7 +727,7 @@ where
append_matching_block_logs(
&mut all_logs,
ProviderOrBlock::<BlockchainProvider<Inner>>::Block(block),
&FilteredParams::new(Some(filter.clone())),
filter,
block_num_hash,
&receipts,
false,
Expand All @@ -742,6 +742,8 @@ where
/// Returns an error if:
/// - underlying database error
/// - amount of matches exceeds configured limit
///
/// https://github.com/paradigmxyz/reth/blob/d01658e516abbf2a1a76855a26d7123286865f22/crates/rpc/rpc/src/eth/filter.rs#L506
async fn get_logs_in_block_range(
&self,
filter: &Filter,
Expand All @@ -760,7 +762,6 @@ where
}

let mut all_logs = Vec::new();
let filter_params = FilteredParams::new(Some(filter.clone()));

// derive bloom filters from filter input, so we can check headers for matching logs
let address_filter = FilteredParams::address_filter(&filter.address);
Expand Down Expand Up @@ -800,7 +801,7 @@ where
append_matching_block_logs(
&mut all_logs,
ProviderOrBlock::<BlockchainProvider<Inner>>::Block(block),
&filter_params,
filter,
block_num_hash,
&receipts,
false,
Expand Down
Loading