Skip to content
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
38 changes: 21 additions & 17 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ secp256k1 = { version = "0.28", default-features = false, features = [
"recovery",
] }
# TODO: Remove `k256` feature: https://github.com/sigp/enr/pull/74
enr = { version = "0.12.0", default-features = false, features = ["k256", "rust-secp256k1"] }
enr = { version = "0.12.0", default-features = false, features = [
"k256",
"rust-secp256k1",
] }

# for eip-4844
c-kzg = "1.0.0"
Expand Down
5 changes: 4 additions & 1 deletion bin/reth/src/commands/db/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
use clap::Parser;
use reth_db::{
cursor::DbCursorRO, database::Database, open_db_read_only, table::Table, transaction::DbTx,
AccountChangeSets, AccountsHistory, AccountsTrie, BlockBodyIndices, BlockOmmers,
AccountChangeSets, AccountsHistory, AccountsTrie, BlockBodyIndices, BlockOmmers, BlockRequests,
BlockWithdrawals, Bytecodes, CanonicalHeaders, DatabaseEnv, HashedAccounts, HashedStorages,
HeaderNumbers, HeaderTerminalDifficulties, Headers, PlainAccountState, PlainStorageState,
PruneCheckpoints, Receipts, StageCheckpointProgresses, StageCheckpoints, StorageChangeSets,
Expand Down Expand Up @@ -98,6 +98,9 @@ impl Command {
Tables::BlockWithdrawals => {
find_diffs::<BlockWithdrawals>(primary_tx, secondary_tx, output_dir)?
}
Tables::BlockRequests => {
find_diffs::<BlockRequests>(primary_tx, secondary_tx, output_dir)?
}
Tables::TransactionBlocks => {
find_diffs::<TransactionBlocks>(primary_tx, secondary_tx, output_dir)?
}
Expand Down
13 changes: 7 additions & 6 deletions bin/reth/src/commands/db/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use human_bytes::human_bytes;
use itertools::Itertools;
use reth_db::{
database::Database, mdbx, static_file::iter_static_files, AccountChangeSets, AccountsHistory,
AccountsTrie, BlockBodyIndices, BlockOmmers, BlockWithdrawals, Bytecodes, CanonicalHeaders,
DatabaseEnv, HashedAccounts, HashedStorages, HeaderNumbers, HeaderTerminalDifficulties,
Headers, PlainAccountState, PlainStorageState, PruneCheckpoints, Receipts,
StageCheckpointProgresses, StageCheckpoints, StorageChangeSets, StoragesHistory, StoragesTrie,
Tables, TransactionBlocks, TransactionHashNumbers, TransactionSenders, Transactions,
VersionHistory,
AccountsTrie, BlockBodyIndices, BlockOmmers, BlockRequests, BlockWithdrawals, Bytecodes,
CanonicalHeaders, DatabaseEnv, HashedAccounts, HashedStorages, HeaderNumbers,
HeaderTerminalDifficulties, Headers, PlainAccountState, PlainStorageState, PruneCheckpoints,
Receipts, StageCheckpointProgresses, StageCheckpoints, StorageChangeSets, StoragesHistory,
StoragesTrie, Tables, TransactionBlocks, TransactionHashNumbers, TransactionSenders,
Transactions, VersionHistory,
};
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_primitives::static_file::{find_fixed_range, SegmentRangeInclusive};
Expand Down Expand Up @@ -332,6 +332,7 @@ impl Command {
Tables::BlockBodyIndices => viewer.get_checksum::<BlockBodyIndices>().unwrap(),
Tables::BlockOmmers => viewer.get_checksum::<BlockOmmers>().unwrap(),
Tables::BlockWithdrawals => viewer.get_checksum::<BlockWithdrawals>().unwrap(),
Tables::BlockRequests => viewer.get_checksum::<BlockRequests>().unwrap(),
Tables::Bytecodes => viewer.get_checksum::<Bytecodes>().unwrap(),
Tables::CanonicalHeaders => viewer.get_checksum::<CanonicalHeaders>().unwrap(),
Tables::HashedAccounts => viewer.get_checksum::<HashedAccounts>().unwrap(),
Expand Down
1 change: 1 addition & 0 deletions crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,7 @@ mod tests {
body: body.clone().into_iter().map(|tx| tx.into_signed()).collect(),
ommers: Vec::new(),
withdrawals: Some(Withdrawals::default()),
requests: None,
},
body.iter().map(|tx| tx.signer()).collect(),
)
Expand Down
23 changes: 19 additions & 4 deletions crates/consensus/auto-seal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use reth_primitives::{
constants::{EMPTY_TRANSACTIONS, ETHEREUM_BLOCK_GAS_LIMIT},
eip4844::calculate_excess_blob_gas,
proofs, Block, BlockBody, BlockHash, BlockHashOrNumber, BlockNumber, ChainSpec, Header,
Receipts, SealedBlock, SealedHeader, TransactionSigned, Withdrawals, B256, U256,
Receipts, Requests, SealedBlock, SealedHeader, TransactionSigned, Withdrawals, B256, U256,
};
use reth_provider::{
BlockReaderIdExt, BundleStateWithReceipts, CanonStateNotificationSender, StateProviderFactory,
Expand Down Expand Up @@ -268,6 +268,7 @@ impl StorageInner {
transactions: &[TransactionSigned],
ommers: &[Header],
withdrawals: Option<&Withdrawals>,
requests: Option<&Requests>,
chain_spec: Arc<ChainSpec>,
) -> Header {
let timestamp = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_secs();
Expand Down Expand Up @@ -310,6 +311,7 @@ impl StorageInner {
excess_blob_gas: None,
extra_data: Default::default(),
parent_beacon_block_root: None,
requests_root: requests.map(|r| proofs::calculate_requests_root(&r.0)),
};

if chain_spec.is_cancun_active_at_timestamp(timestamp) {
Expand Down Expand Up @@ -345,11 +347,13 @@ impl StorageInner {
/// Builds and executes a new block with the given transactions, on the provided executor.
///
/// This returns the header of the executed block, as well as the poststate from execution.
#[allow(clippy::too_many_arguments)]
pub(crate) fn build_and_execute<Provider, Executor>(
&mut self,
transactions: Vec<TransactionSigned>,
ommers: Vec<Header>,
withdrawals: Option<Withdrawals>,
requests: Option<Requests>,
provider: &Provider,
chain_spec: Arc<ChainSpec>,
executor: &Executor,
Expand All @@ -358,14 +362,21 @@ impl StorageInner {
Executor: BlockExecutorProvider,
Provider: StateProviderFactory,
{
let header =
self.build_header_template(&transactions, &ommers, withdrawals.as_ref(), chain_spec);
let header = self.build_header_template(
&transactions,
&ommers,
withdrawals.as_ref(),
requests.as_ref(),
chain_spec,
);

// todo(onbjerg): when we rewrite this, add support for requests
let mut block = Block {
header,
body: transactions,
ommers: ommers.clone(),
withdrawals: withdrawals.clone(),
requests: requests.clone(),
}
.with_recovered_senders()
.ok_or(BlockExecutionError::Validation(BlockValidationError::SenderRecoveryError))?;
Expand Down Expand Up @@ -405,8 +416,12 @@ impl StorageInner {
block.number,
);

// todo(onbjerg): we should not pass requests around as this is building a block, which
// means we need to extract the requests from the execution output and compute the requests
// root here

let Block { mut header, body, .. } = block.block;
let body = BlockBody { transactions: body, ommers, withdrawals };
let body = BlockBody { transactions: body, ommers, withdrawals, requests };

trace!(target: "consensus::auto", ?bundle_state, ?header, ?body, "executed block, calculating state root and completing header");

Expand Down
6 changes: 5 additions & 1 deletion crates/consensus/auto-seal/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use reth_beacon_consensus::{BeaconEngineMessage, ForkchoiceStatus};
use reth_engine_primitives::EngineTypes;
use reth_evm::execute::BlockExecutorProvider;
use reth_primitives::{
Block, ChainSpec, IntoRecoveredTransaction, SealedBlockWithSenders, Withdrawals,
Block, ChainSpec, IntoRecoveredTransaction, Requests, SealedBlockWithSenders, Withdrawals,
};
use reth_provider::{CanonChainTracker, CanonStateNotificationSender, Chain, StateProviderFactory};
use reth_rpc_types::engine::ForkchoiceState;
Expand Down Expand Up @@ -137,12 +137,15 @@ where
})
.unzip();
let ommers = vec![];
// todo(onbjerg): these two dont respect chainspec
let withdrawals = Some(Withdrawals::default());
let requests = Some(Requests::default());

match storage.build_and_execute(
transactions.clone(),
ommers.clone(),
withdrawals.clone(),
requests.clone(),
&client,
chain_spec,
&executor,
Expand Down Expand Up @@ -201,6 +204,7 @@ where
body: transactions,
ommers,
withdrawals,
requests,
};
let sealed_block = block.seal_slow();

Expand Down
15 changes: 14 additions & 1 deletion crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use reth_primitives::{
};
use reth_provider::{HeaderProvider, WithdrawalsProvider};

// todo: validate requests root

/// Validate header standalone
pub fn validate_header_standalone(
header: &SealedHeader,
Expand Down Expand Up @@ -351,6 +353,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None
};
// size: 0x9b5

Expand All @@ -364,7 +367,16 @@ mod tests {
let ommers = Vec::new();
let body = Vec::new();

(SealedBlock { header: header.seal_slow(), body, ommers, withdrawals: None }, parent)
(
SealedBlock {
header: header.seal_slow(),
body,
ommers,
withdrawals: None,
requests: None,
},
parent,
)
}

#[test]
Expand Down Expand Up @@ -452,6 +464,7 @@ mod tests {
transactions: vec![transaction],
ommers: vec![],
withdrawals: Some(Withdrawals::default()),
requests: None,
};

let block = SealedBlock::new(header, body);
Expand Down
Loading