Skip to content

Commit bd183b6

Browse files
Evalirprestwich
andauthored
feat(repo): migrate to latest reth/alloy/trevm (#57)
* feat(repo): migrate to latest reth/alloy/trevm wip * fix: filters * fix: doc * chore: some clippy * chore: stuff * chore: signature changes --------- Co-authored-by: James <[email protected]>
1 parent b8251ff commit bd183b6

File tree

18 files changed

+96
-76
lines changed

18 files changed

+96
-76
lines changed

Cargo.toml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,35 @@ signet-zenith = { path = "crates/zenith" }
4949
ajj = { version = "0.3.1" }
5050

5151
# trevm
52-
trevm = { version = "0.20.10", features = ["full_env_cfg"] }
52+
trevm = { version = "0.23.4", features = ["full_env_cfg"] }
5353

5454
# Alloy periphery crates
55-
alloy = { version = "=0.12.6", features = [
55+
alloy = { version = "=1.0.5", features = [
5656
"full",
5757
"rpc-types-mev",
5858
"genesis",
5959
"arbitrary",
6060
] }
61-
alloy-contract = { version = "=0.12.6", features = ["pubsub"] }
61+
alloy-contract = { version = "=1.0.5", features = ["pubsub"] }
6262

6363
# Reth
64-
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
65-
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
66-
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
67-
reth-db-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
68-
reth-eth-wire-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
69-
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
70-
reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
71-
reth-exex-test-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
72-
reth-network-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
73-
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
74-
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
75-
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
76-
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
77-
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
78-
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
79-
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.4" }
64+
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
65+
reth-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
66+
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
67+
reth-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
68+
reth-db-common = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
69+
reth-eth-wire-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
70+
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
71+
reth-exex = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
72+
reth-exex-test-utils = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
73+
reth-network-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
74+
reth-network-peers = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
75+
reth-node-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
76+
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
77+
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
78+
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
79+
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
80+
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", tag = "v1.4.3" }
8081

8182
# Foundry periphery
8283
foundry-blob-explorers = "0.10"

crates/bundle/src/call/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ where
185185

186186
// Taking these clears the order detector
187187
let (orders, fills) =
188-
trevm.inner_mut_unchecked().data.inspector.as_mut_detector().take_aggregates();
188+
trevm.inner_mut_unchecked().inspector.as_mut_detector().take_aggregates();
189189
self.response.orders = orders;
190190
self.response.fills = fills;
191191

crates/bundle/src/call/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Signet bundle types.
22
use alloy::{
3-
consensus::{Transaction, TxEnvelope},
3+
consensus::{transaction::SignerRecoverable, Transaction, TxEnvelope},
44
eips::{eip2718::Encodable2718, BlockNumberOrTag, Decodable2718},
55
primitives::{keccak256, Bytes, B256, U256},
66
rlp::Buf,

crates/bundle/src/send/bundle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl SignetEthBundle {
100100
/// checks that the tokens can actually be transferred.
101101
pub async fn alloy_validate_fills_onchain<Db, P, N>(
102102
&self,
103-
orders: HostOrdersInstance<(), P, N>,
103+
orders: HostOrdersInstance<P, N>,
104104
) -> Result<(), SignetEthBundleError<Db>>
105105
where
106106
Db: Database,

crates/evm/src/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use alloy::{
44
consensus::{ReceiptEnvelope, TxEip1559},
5-
primitives::{Address, PrimitiveSignature as Signature, U256},
5+
primitives::{Address, Signature, U256},
66
sol_types::SolCall,
77
};
88
use reth::{

crates/evm/src/driver.rs

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ use alloy::{
99
primitives::{Address, Bloom, U256},
1010
};
1111
use reth::{
12-
core::primitives::SignedTransaction,
13-
primitives::{
14-
Block, BlockBody, Receipt, RecoveredBlock, SealedHeader, Transaction, TransactionSigned,
15-
},
12+
core::primitives::SignerRecoverable,
13+
primitives::{Block, BlockBody, Receipt, RecoveredBlock, SealedHeader, TransactionSigned},
1614
providers::ExecutionOutcome,
1715
};
1816
use signet_extract::{ExtractedEvent, Extracts};
@@ -136,8 +134,9 @@ impl Tx for FillShim<'_> {
136134

137135
*caller = self.1;
138136

139-
match self.0.as_ref() {
140-
Transaction::Legacy(tx) => {
137+
match self.0 {
138+
TransactionSigned::Legacy(tx) => {
139+
let tx = tx.tx();
141140
*tx_type = TxType::Legacy as u8;
142141
*gas_limit = tx.gas_limit;
143142
*gas_price = tx.gas_price;
@@ -152,7 +151,8 @@ impl Tx for FillShim<'_> {
152151
*max_fee_per_blob_gas = 0;
153152
authorization_list.clear();
154153
}
155-
Transaction::Eip2930(tx) => {
154+
TransactionSigned::Eip2930(tx) => {
155+
let tx = tx.tx();
156156
*tx_type = TxType::Eip2930 as u8;
157157
*gas_limit = tx.gas_limit;
158158
*gas_price = tx.gas_price;
@@ -167,7 +167,8 @@ impl Tx for FillShim<'_> {
167167
*max_fee_per_blob_gas = 0;
168168
authorization_list.clear();
169169
}
170-
Transaction::Eip1559(tx) => {
170+
TransactionSigned::Eip1559(tx) => {
171+
let tx = tx.tx();
171172
*tx_type = TxType::Eip1559 as u8;
172173
*gas_limit = tx.gas_limit;
173174
*gas_price = tx.max_fee_per_gas;
@@ -182,7 +183,8 @@ impl Tx for FillShim<'_> {
182183
*max_fee_per_blob_gas = 0;
183184
authorization_list.clear();
184185
}
185-
Transaction::Eip4844(tx) => {
186+
TransactionSigned::Eip4844(tx) => {
187+
let tx = tx.tx();
186188
*tx_type = TxType::Eip4844 as u8;
187189
*gas_limit = tx.gas_limit;
188190
*gas_price = tx.max_fee_per_gas;
@@ -197,7 +199,8 @@ impl Tx for FillShim<'_> {
197199
*max_fee_per_blob_gas = tx.max_fee_per_blob_gas;
198200
authorization_list.clear();
199201
}
200-
Transaction::Eip7702(tx) => {
202+
TransactionSigned::Eip7702(tx) => {
203+
let tx = tx.tx();
201204
*tx_type = TxType::Eip7702 as u8;
202205
*gas_limit = tx.gas_limit;
203206
*gas_price = tx.max_fee_per_gas;
@@ -210,7 +213,13 @@ impl Tx for FillShim<'_> {
210213
access_list.clone_from(&tx.access_list);
211214
blob_hashes.clear();
212215
*max_fee_per_blob_gas = 0;
213-
authorization_list.clone_from(&tx.authorization_list);
216+
authorization_list.clone_from(
217+
&tx.authorization_list
218+
.iter()
219+
.cloned()
220+
.map(alloy::signers::Either::Left)
221+
.collect(),
222+
);
214223
}
215224
}
216225
}
@@ -438,7 +447,7 @@ impl<'a, 'b> SignetDriver<'a, 'b> {
438447
{
439448
// Taking these clears the context for reuse.
440449
let (agg_orders, agg_fills) =
441-
trevm.inner_mut_unchecked().data.inspector.as_mut_detector().take_aggregates();
450+
trevm.inner_mut_unchecked().inspector.as_mut_detector().take_aggregates();
442451

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

488497
// Create a receipt for the transaction.
489-
let tx_env = trevm.inner().data.ctx.tx();
498+
let tx_env = trevm.inner().ctx.tx();
490499
let sender = tx_env.caller;
491500
// 4844 transactions are not allowed
492501
let receipt = self.make_receipt(result).into();
@@ -936,7 +945,7 @@ mod test {
936945
SignableTransaction, TxEip1559,
937946
},
938947
primitives::{Sealable, B256, B64},
939-
signers::{local::PrivateKeySigner, SignerSync},
948+
signers::{local::PrivateKeySigner, Signature, SignerSync},
940949
};
941950
use reth::primitives::{Block, RecoveredBlock, Transaction};
942951
use signet_extract::ExtractedEvent;
@@ -1158,7 +1167,7 @@ mod test {
11581167
let user = Address::repeat_byte(2);
11591168

11601169
// Set up a fake event
1161-
let fake_tx = TransactionSigned::default();
1170+
let fake_tx = fake_tx();
11621171
let fake_receipt: reth::primitives::Receipt = Default::default();
11631172

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

12011210
// Set up a couple fake events
1202-
let fake_tx = TransactionSigned::default();
1211+
let fake_tx = fake_tx();
12031212
let fake_receipt: reth::primitives::Receipt = Default::default();
12041213

12051214
let enter = signet_zenith::Passage::Enter {
@@ -1251,4 +1260,10 @@ mod test {
12511260
assert_eq!(receipts.len(), 2);
12521261
assert_eq!(trevm.read_balance(recipient), U256::from(100));
12531262
}
1263+
1264+
fn fake_tx() -> TransactionSigned {
1265+
let tx = TxEip1559::default();
1266+
let signature = Signature::test_signature();
1267+
TransactionSigned::new_unhashed(tx.into(), signature)
1268+
}
12541269
}

crates/evm/src/orders/inspector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ where
100100
return;
101101
}
102102

103-
if let Ok(Log { data, .. }) = RollupOrders::Order::decode_log(&log, true) {
103+
if let Ok(Log { data, .. }) = RollupOrders::Order::decode_log(&log) {
104104
self.orders.add(data);
105-
} else if let Ok(Log { data, .. }) = RollupOrders::Filled::decode_log(&log, true) {
105+
} else if let Ok(Log { data, .. }) = RollupOrders::Filled::decode_log(&log) {
106106
self.filleds.add(data);
107107
}
108108
}

crates/extract/src/events.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl From<Transactor::Transact> for Events {
6161
impl Events {
6262
/// Decode a [`Passage`] event from a log.
6363
pub fn decode_passage(log: &Log<LogData>, filter_chain_id: u64) -> Option<Self> {
64-
let event = PassageEvents::decode_log(log, true).ok().map(|log| log.data)?;
64+
let event = PassageEvents::decode_log(log).ok().map(|log| log.data)?;
6565

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

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

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

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

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

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

105105
match event {
106106
RollupOrdersEvents::Filled(mut e) => {

crates/extract/src/extracted.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use alloy::{
2-
eips::Typed2718,
3-
primitives::{Log, TxHash, U256},
4-
};
1+
use alloy::primitives::{Log, TxHash, U256};
52
use reth::primitives::{Receipt, TransactionSigned};
63
use signet_zenith::{Passage, RollupOrders, Transactor, Zenith};
74

@@ -191,7 +188,7 @@ impl ExtractedEvent<'_, Zenith::BlockSubmitted> {
191188
}
192189

193190
/// True if the transaction is an EIP-4844 transaction.
194-
pub fn is_eip4844(&self) -> bool {
191+
pub const fn is_eip4844(&self) -> bool {
195192
self.tx.is_eip4844()
196193
}
197194
}

crates/extract/src/test_utils/host_spec.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
Events, Extracts,
44
};
55
use alloy::{
6-
consensus::{constants::GWEI_TO_WEI, BlobTransactionSidecar, TxEip4844},
6+
consensus::{constants::GWEI_TO_WEI, BlobTransactionSidecar, TxEip1559, TxEip4844},
77
primitives::{Address, Bytes, FixedBytes, Log, LogData, Sealable, B256, U256},
88
signers::Signature,
99
};
@@ -277,7 +277,20 @@ impl HostBlockSpec {
277277

278278
/// Make dummy txns. The blob txn will always be at the end of the block
279279
fn make_txns(&self) -> Vec<TransactionSigned> {
280-
self.receipts.iter().map(|_| Default::default()).chain(self.blob_txn()).collect()
280+
self.receipts
281+
.iter()
282+
.map(|_| {
283+
Some(
284+
alloy::consensus::Signed::new_unhashed(
285+
TxEip1559::default(),
286+
Signature::test_signature(),
287+
)
288+
.into(),
289+
)
290+
})
291+
.chain(std::iter::once(self.blob_txn()))
292+
.flatten()
293+
.collect()
281294
}
282295

283296
/// Get the block number

crates/rpc/src/ctx.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use alloy::{
1313
rpc::types::{FeeHistory, Filter, Log},
1414
};
1515
use reth::{
16-
core::primitives::SignedTransaction,
16+
core::primitives::SignerRecoverable,
1717
primitives::{Block, EthPrimitives, Receipt, Recovered, RecoveredBlock, TransactionSigned},
1818
providers::{
1919
providers::{BlockchainProvider, ProviderNodeTypes},
@@ -403,7 +403,7 @@ where
403403
let hash = *tx.hash();
404404
let signature = *tx.signature();
405405

406-
let inner: TxEnvelope = match tx.into_inner().into_transaction() {
406+
let inner: TxEnvelope = match tx.into_inner().into_typed_transaction() {
407407
reth::primitives::Transaction::Legacy(tx) => {
408408
Signed::new_unchecked(tx, signature, hash).into()
409409
}
@@ -727,7 +727,7 @@ where
727727
append_matching_block_logs(
728728
&mut all_logs,
729729
ProviderOrBlock::<BlockchainProvider<Inner>>::Block(block),
730-
&FilteredParams::new(Some(filter.clone())),
730+
filter,
731731
block_num_hash,
732732
&receipts,
733733
false,
@@ -742,6 +742,8 @@ where
742742
/// Returns an error if:
743743
/// - underlying database error
744744
/// - amount of matches exceeds configured limit
745+
///
746+
/// https://github.com/paradigmxyz/reth/blob/d01658e516abbf2a1a76855a26d7123286865f22/crates/rpc/rpc/src/eth/filter.rs#L506
745747
async fn get_logs_in_block_range(
746748
&self,
747749
filter: &Filter,
@@ -760,7 +762,6 @@ where
760762
}
761763

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

765766
// derive bloom filters from filter input, so we can check headers for matching logs
766767
let address_filter = FilteredParams::address_filter(&filter.address);
@@ -800,7 +801,7 @@ where
800801
append_matching_block_logs(
801802
&mut all_logs,
802803
ProviderOrBlock::<BlockchainProvider<Inner>>::Block(block),
803-
&filter_params,
804+
filter,
804805
block_num_hash,
805806
&receipts,
806807
false,

0 commit comments

Comments
 (0)