Skip to content

Commit

Permalink
Merge branch 'main' into error
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jan 4, 2025
2 parents 597d4ec + 8befda5 commit 9f4ea76
Show file tree
Hide file tree
Showing 102 changed files with 681 additions and 1,849 deletions.
153 changes: 81 additions & 72 deletions Cargo.lock

Large diffs are not rendered by default.

57 changes: 29 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -434,47 +434,48 @@ revm-inspectors = "0.14.1"
# eth
alloy-chains = { version = "0.1.32", default-features = false }
alloy-dyn-abi = "0.8.15"
alloy-eip2124 = { version = "0.1.0", default-features = false }
alloy-primitives = { version = "0.8.15", default-features = false, features = [
"map-foldhash",
] }
alloy-rlp = { version = "0.3.10", default-features = false }
alloy-sol-types = "0.8.15"
alloy-trie = { version = "0.7", default-features = false }

alloy-consensus = { version = "0.9.1", default-features = false }
alloy-contract = { version = "0.9.1", default-features = false }
alloy-eips = { version = "0.9.1", default-features = false }
alloy-genesis = { version = "0.9.1", default-features = false }
alloy-json-rpc = { version = "0.9.1", default-features = false }
alloy-network = { version = "0.9.1", default-features = false }
alloy-network-primitives = { version = "0.9.1", default-features = false }
alloy-node-bindings = { version = "0.9.1", default-features = false }
alloy-provider = { version = "0.9.1", features = [
alloy-consensus = { version = "0.9.2", default-features = false }
alloy-contract = { version = "0.9.2", default-features = false }
alloy-eips = { version = "0.9.2", default-features = false }
alloy-genesis = { version = "0.9.2", default-features = false }
alloy-json-rpc = { version = "0.9.2", default-features = false }
alloy-network = { version = "0.9.2", default-features = false }
alloy-network-primitives = { version = "0.9.2", default-features = false }
alloy-node-bindings = { version = "0.9.2", default-features = false }
alloy-provider = { version = "0.9.2", features = [
"reqwest",
], default-features = false }
alloy-pubsub = { version = "0.9.1", default-features = false }
alloy-rpc-client = { version = "0.9.1", default-features = false }
alloy-rpc-types = { version = "0.9.1", features = [
alloy-pubsub = { version = "0.9.2", default-features = false }
alloy-rpc-client = { version = "0.9.2", default-features = false }
alloy-rpc-types = { version = "0.9.2", features = [
"eth",
], default-features = false }
alloy-rpc-types-admin = { version = "0.9.1", default-features = false }
alloy-rpc-types-anvil = { version = "0.9.1", default-features = false }
alloy-rpc-types-beacon = { version = "0.9.1", default-features = false }
alloy-rpc-types-debug = { version = "0.9.1", default-features = false }
alloy-rpc-types-engine = { version = "0.9.1", default-features = false }
alloy-rpc-types-eth = { version = "0.9.1", default-features = false }
alloy-rpc-types-mev = { version = "0.9.1", default-features = false }
alloy-rpc-types-trace = { version = "0.9.1", default-features = false }
alloy-rpc-types-txpool = { version = "0.9.1", default-features = false }
alloy-serde = { version = "0.9.1", default-features = false }
alloy-signer = { version = "0.9.1", default-features = false }
alloy-signer-local = { version = "0.9.1", default-features = false }
alloy-transport = { version = "0.9.1" }
alloy-transport-http = { version = "0.9.1", features = [
alloy-rpc-types-admin = { version = "0.9.2", default-features = false }
alloy-rpc-types-anvil = { version = "0.9.2", default-features = false }
alloy-rpc-types-beacon = { version = "0.9.2", default-features = false }
alloy-rpc-types-debug = { version = "0.9.2", default-features = false }
alloy-rpc-types-engine = { version = "0.9.2", default-features = false }
alloy-rpc-types-eth = { version = "0.9.2", default-features = false }
alloy-rpc-types-mev = { version = "0.9.2", default-features = false }
alloy-rpc-types-trace = { version = "0.9.2", default-features = false }
alloy-rpc-types-txpool = { version = "0.9.2", default-features = false }
alloy-serde = { version = "0.9.2", default-features = false }
alloy-signer = { version = "0.9.2", default-features = false }
alloy-signer-local = { version = "0.9.2", default-features = false }
alloy-transport = { version = "0.9.2" }
alloy-transport-http = { version = "0.9.2", features = [
"reqwest-rustls-tls",
], default-features = false }
alloy-transport-ipc = { version = "0.9.1", default-features = false }
alloy-transport-ws = { version = "0.9.1", default-features = false }
alloy-transport-ipc = { version = "0.9.2", default-features = false }
alloy-transport-ws = { version = "0.9.2", default-features = false }

# op
op-alloy-rpc-types = { version = "0.9.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2022-2024 Reth Contributors
Copyright (c) 2022-2025 Reth Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion bin/reth-bench/src/bench/new_payload_fcu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Command {
let block_number = block.header.number;

let versioned_hashes: Vec<B256> =
block.body.blob_versioned_hashes_iter().copied().collect();
block.body().blob_versioned_hashes_iter().copied().collect();
let parent_beacon_block_root = block.parent_beacon_block_root;
let payload = block_to_payload(block).0;

Expand Down
2 changes: 1 addition & 1 deletion bin/reth-bench/src/bench/new_payload_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Command {
let gas_used = block.gas_used;

let versioned_hashes: Vec<B256> =
block.body.blob_versioned_hashes_iter().copied().collect();
block.body().blob_versioned_hashes_iter().copied().collect();
let parent_beacon_block_root = block.parent_beacon_block_root;
let payload = block_to_payload(block).0;

Expand Down
4 changes: 2 additions & 2 deletions book/sources/exex/tracking-state/src/bin/2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>> Fut
while let Some(notification) = ready!(this.ctx.notifications.try_next().poll_unpin(cx))? {
if let Some(reverted_chain) = notification.reverted_chain() {
this.transactions = this.transactions.saturating_sub(
reverted_chain.blocks_iter().map(|b| b.body.transactions.len() as u64).sum(),
reverted_chain.blocks_iter().map(|b| b.body().transactions.len() as u64).sum(),
);
}

Expand All @@ -45,7 +45,7 @@ impl<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>> Fut

this.transactions += committed_chain
.blocks_iter()
.map(|b| b.body.transactions.len() as u64)
.map(|b| b.body().transactions.len() as u64)
.sum::<u64>();

this.ctx
Expand Down
2 changes: 1 addition & 1 deletion crates/blockchain-tree-api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl<B: Block> std::fmt::Debug for InsertBlockErrorDataTwo<B> {
.field("hash", &self.block.hash())
.field("number", &self.block.number())
.field("parent_hash", &self.block.parent_hash())
.field("num_txs", &self.block.body.transactions().len())
.field("num_txs", &self.block.body().transactions().len())
.finish_non_exhaustive()
}
}
Expand Down
16 changes: 8 additions & 8 deletions crates/blockchain-tree/src/block_indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,23 +572,23 @@ mod tests {

// Define blocks with their numbers and parent hashes.
let block_1 = SealedBlockWithSenders {
block: SealedBlock {
header: SealedHeader::new(
block: SealedBlock::new(
SealedHeader::new(
Header { parent_hash, number: 1, ..Default::default() },
block_hash_1,
),
..Default::default()
},
Default::default(),
),
..Default::default()
};
let block_2 = SealedBlockWithSenders {
block: SealedBlock {
header: SealedHeader::new(
block: SealedBlock::new(
SealedHeader::new(
Header { parent_hash: block_hash_1, number: 2, ..Default::default() },
block_hash_2,
),
..Default::default()
},
Default::default(),
),
..Default::default()
};

Expand Down
8 changes: 4 additions & 4 deletions crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1635,14 +1635,14 @@ mod tests {
};

SealedBlockWithSenders::new(
SealedBlock {
header: SealedHeader::seal(header),
body: BlockBody {
SealedBlock::new(
SealedHeader::seal(header),
BlockBody {
transactions: signed_body,
ommers: Vec::new(),
withdrawals: Some(Withdrawals::default()),
},
},
),
body.iter().map(|tx| tx.signer()).collect(),
)
.unwrap()
Expand Down
26 changes: 13 additions & 13 deletions crates/chain-state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
CanonStateNotification, CanonStateNotificationSender, CanonStateNotifications,
ChainInfoTracker, MemoryOverlayStateProvider,
};
use alloy_consensus::BlockHeader;
use alloy_consensus::{transaction::TransactionMeta, BlockHeader};
use alloy_eips::{eip2718::Encodable2718, BlockHashOrNumber, BlockNumHash};
use alloy_primitives::{map::HashMap, Address, TxHash, B256};
use parking_lot::RwLock;
Expand All @@ -13,12 +13,12 @@ use reth_execution_types::{Chain, ExecutionOutcome};
use reth_metrics::{metrics::Gauge, Metrics};
use reth_primitives::{
BlockWithSenders, EthPrimitives, NodePrimitives, Receipts, SealedBlock, SealedBlockFor,
SealedBlockWithSenders, SealedHeader, TransactionMeta,
SealedBlockWithSenders, SealedHeader,
};
use reth_primitives_traits::{Block, BlockBody as _, SignedTransaction};
use reth_storage_api::StateProviderBox;
use reth_trie::{updates::TrieUpdates, HashedPostState};
use std::{collections::BTreeMap, sync::Arc, time::Instant};
use std::{collections::BTreeMap, ops::Deref, sync::Arc, time::Instant};
use tokio::sync::{broadcast, watch};

/// Size of the broadcast channel used to notify canonical state events.
Expand Down Expand Up @@ -183,7 +183,7 @@ impl<N: NodePrimitives> CanonicalInMemoryState<N> {
let in_memory_state = InMemoryState::new(blocks, numbers, pending);
let header = in_memory_state
.head_state()
.map_or_else(SealedHeader::default, |state| state.block_ref().block().header.clone());
.map_or_else(SealedHeader::default, |state| state.block_ref().block().deref().clone());
let chain_info_tracker = ChainInfoTracker::new(header, finalized, safe);
let (canon_state_notification_sender, _) =
broadcast::channel(CANON_STATE_NOTIFICATION_CHANNEL_SIZE);
Expand Down Expand Up @@ -462,7 +462,7 @@ impl<N: NodePrimitives> CanonicalInMemoryState<N> {

/// Returns the `SealedHeader` corresponding to the pending state.
pub fn pending_sealed_header(&self) -> Option<SealedHeader<N::BlockHeader>> {
self.pending_state().map(|h| h.block_ref().block().header.clone())
self.pending_state().map(|h| h.block_ref().block().deref().clone())
}

/// Returns the `Header` corresponding to the pending state.
Expand Down Expand Up @@ -549,7 +549,7 @@ impl<N: NodePrimitives> CanonicalInMemoryState<N> {
if let Some(tx) = block_state
.block_ref()
.block()
.body
.body()
.transactions()
.iter()
.find(|tx| tx.trie_hash() == hash)
Expand All @@ -573,7 +573,7 @@ impl<N: NodePrimitives> CanonicalInMemoryState<N> {
if let Some((index, tx)) = block_state
.block_ref()
.block()
.body
.body()
.transactions()
.iter()
.enumerate()
Expand All @@ -584,7 +584,7 @@ impl<N: NodePrimitives> CanonicalInMemoryState<N> {
index: index as u64,
block_hash: block_state.hash(),
block_number: block_state.block_ref().block.number(),
base_fee: block_state.block_ref().block.header.base_fee_per_gas(),
base_fee: block_state.block_ref().block.base_fee_per_gas(),
timestamp: block_state.block_ref().block.timestamp(),
excess_blob_gas: block_state.block_ref().block.excess_blob_gas(),
};
Expand Down Expand Up @@ -664,7 +664,7 @@ impl<N: NodePrimitives> BlockState<N> {
/// Returns the state root after applying the executed block that determines
/// the state.
pub fn state_root(&self) -> B256 {
self.block.block().header.state_root()
self.block.block().state_root()
}

/// Returns the `Receipts` of executed block that determines the state.
Expand Down Expand Up @@ -758,7 +758,7 @@ impl<N: NodePrimitives> BlockState<N> {
block_state
.block_ref()
.block()
.body
.body()
.transactions()
.iter()
.find(|tx| tx.trie_hash() == hash)
Expand All @@ -778,7 +778,7 @@ impl<N: NodePrimitives> BlockState<N> {
block_state
.block_ref()
.block()
.body
.body()
.transactions()
.iter()
.enumerate()
Expand All @@ -789,7 +789,7 @@ impl<N: NodePrimitives> BlockState<N> {
index: index as u64,
block_hash: block_state.hash(),
block_number: block_state.block_ref().block.number(),
base_fee: block_state.block_ref().block.header.base_fee_per_gas(),
base_fee: block_state.block_ref().block.base_fee_per_gas(),
timestamp: block_state.block_ref().block.timestamp(),
excess_blob_gas: block_state.block_ref().block.excess_blob_gas(),
};
Expand Down Expand Up @@ -1318,7 +1318,7 @@ mod tests {
);

// Check the pending header
assert_eq!(state.pending_header().unwrap(), block2.block().header.header().clone());
assert_eq!(state.pending_header().unwrap(), block2.block().header().clone());

// Check the pending sealed header
assert_eq!(state.pending_sealed_header().unwrap(), block2.block().header.clone());
Expand Down
29 changes: 21 additions & 8 deletions crates/chain-state/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ impl<T: Clone + Sync + Send + 'static> Stream for ForkChoiceStream<T> {
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::BlockBody;
use alloy_primitives::{b256, B256};
use reth_execution_types::ExecutionOutcome;
use reth_primitives::{Receipt, Receipts, TransactionSigned, TxType};
use reth_primitives::{Receipt, Receipts, SealedBlock, TransactionSigned, TxType};

#[test]
fn test_commit_notification() {
Expand Down Expand Up @@ -295,21 +296,25 @@ mod tests {
#[test]
fn test_block_receipts_commit() {
// Create a default block instance for use in block definitions.
let block: SealedBlockWithSenders = Default::default();
let mut body = BlockBody::<TransactionSigned>::default();

// Define unique hashes for two blocks to differentiate them in the chain.
let block1_hash = B256::new([0x01; 32]);
let block2_hash = B256::new([0x02; 32]);

// Create a default transaction to include in block1's transactions.
let tx = TransactionSigned::default();
body.transactions.push(tx);

let block: SealedBlockWithSenders =
SealedBlock::new(SealedHeader::seal(alloy_consensus::Header::default()), body)
.seal_with_senders()
.unwrap();

// Create a clone of the default block and customize it to act as block1.
let mut block1 = block.clone();
block1.set_block_number(1);
block1.set_hash(block1_hash);
// Add the transaction to block1's transactions.
block1.block.body.transactions.push(tx);

// Clone the default block and customize it to act as block2.
let mut block2 = block;
Expand Down Expand Up @@ -365,10 +370,14 @@ mod tests {
#[test]
fn test_block_receipts_reorg() {
// Define block1 for the old chain segment, which will be reverted.
let mut old_block1: SealedBlockWithSenders = Default::default();
let mut body = BlockBody::<TransactionSigned>::default();
body.transactions.push(TransactionSigned::default());
let mut old_block1: SealedBlockWithSenders =
SealedBlock::new(SealedHeader::seal(alloy_consensus::Header::default()), body)
.seal_with_senders()
.unwrap();
old_block1.set_block_number(1);
old_block1.set_hash(B256::new([0x01; 32]));
old_block1.block.body.transactions.push(TransactionSigned::default());

// Create a receipt for a transaction in the reverted block.
#[allow(clippy::needless_update)]
Expand All @@ -389,10 +398,14 @@ mod tests {
Arc::new(Chain::new(vec![old_block1.clone()], old_execution_outcome, None));

// Define block2 for the new chain segment, which will be committed.
let mut new_block1: SealedBlockWithSenders = Default::default();
let mut body = BlockBody::<TransactionSigned>::default();
body.transactions.push(TransactionSigned::default());
let mut new_block1: SealedBlockWithSenders =
SealedBlock::new(SealedHeader::seal(alloy_consensus::Header::default()), body)
.seal_with_senders()
.unwrap();
new_block1.set_block_number(2);
new_block1.set_hash(B256::new([0x02; 32]));
new_block1.block.body.transactions.push(TransactionSigned::default());

// Create a receipt for a transaction in the new committed block.
#[allow(clippy::needless_update)]
Expand Down
Loading

0 comments on commit 9f4ea76

Please sign in to comment.