Skip to content

Commit

Permalink
feat: update el requests for devnet 4
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg committed Oct 18, 2024
1 parent 9c8f5d8 commit d9f63a5
Show file tree
Hide file tree
Showing 66 changed files with 583 additions and 1,040 deletions.
294 changes: 180 additions & 114 deletions Cargo.lock

Large diffs are not rendered by default.

129 changes: 66 additions & 63 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,9 @@ reth-trie-db = { path = "crates/trie/db" }
reth-trie-parallel = { path = "crates/trie/parallel" }

# revm
revm = { version = "14.0.3", features = [
"std",
], default-features = false }
revm-inspectors = "0.8.1"
revm-primitives = { version = "10.0.0", features = [
revm = { version = "16.0.0", features = ["std"], default-features = false }
revm-inspectors = "0.9.0"
revm-primitives = { version = "12.0.0", features = [
"std",
], default-features = false }

Expand All @@ -426,45 +424,45 @@ alloy-rlp = "0.3.4"
alloy-sol-types = "0.8.0"
alloy-trie = { version = "0.7", default-features = false }

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

# op
op-alloy-rpc-types = "0.4"
op-alloy-rpc-types-engine = "0.4"
op-alloy-network = "0.4"
op-alloy-consensus = "0.4"
op-alloy-rpc-types = "0.5"
op-alloy-rpc-types-engine = "0.5"
op-alloy-network = "0.5"
op-alloy-consensus = "0.5"

# misc
aquamarine = "0.5"
Expand Down Expand Up @@ -595,30 +593,35 @@ tikv-jemalloc-ctl = "0.6"
tikv-jemallocator = "0.6"
tracy-client = "0.17.3"

[patch.crates-io]
#alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-admin = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-debug = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-mev = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-txpool = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#[patch.crates-io]
#alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-admin = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-debug = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-mev = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-rpc-types-txpool = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }
#alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "a971b3a" }

#op-alloy-rpc-types = { git = "https://github.com/alloy-rs/op-alloy", rev = "6a042e7681b1" }
#op-alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/op-alloy", rev = "6a042e7681b1" }
#op-alloy-network = { git = "https://github.com/alloy-rs/op-alloy", rev = "6a042e7681b1" }
#op-alloy-consensus = { git = "https://github.com/alloy-rs/op-alloy", rev = "6a042e7681b1" }
1 change: 0 additions & 1 deletion crates/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ alloy-chains = { workspace = true, features = ["serde", "rlp"] }
alloy-eips = { workspace = true, features = ["serde"] }
alloy-genesis.workspace = true
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
alloy-trie.workspace = true
alloy-consensus.workspace = true

# misc
Expand Down
10 changes: 5 additions & 5 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use alloy_chains::{Chain, NamedChain};
use alloy_consensus::constants::EMPTY_WITHDRAWALS;
use alloy_genesis::Genesis;
use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256};
use alloy_trie::EMPTY_ROOT_HASH;
use derive_more::From;

use alloy_consensus::constants::{DEV_GENESIS_HASH, MAINNET_GENESIS_HASH};
use alloy_consensus::constants::{DEV_GENESIS_HASH, KECCAK_EMPTY, MAINNET_GENESIS_HASH};
use reth_ethereum_forks::{
ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition,
ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, DEV_HARDFORKS,
Expand Down Expand Up @@ -284,8 +283,8 @@ impl ChainSpec {
};

// If Prague is activated at genesis we set requests root to an empty trie root.
let requests_root =
self.is_prague_active_at_timestamp(self.genesis.timestamp).then_some(EMPTY_ROOT_HASH);
let requests_hash =
self.is_prague_active_at_timestamp(self.genesis.timestamp).then_some(KECCAK_EMPTY);

Header {
gas_limit: self.genesis.gas_limit,
Expand All @@ -301,7 +300,7 @@ impl ChainSpec {
parent_beacon_block_root,
blob_gas_used: blob_gas_used.map(Into::into),
excess_blob_gas: excess_blob_gas.map(Into::into),
requests_root,
requests_hash,
..Default::default()
}
}
Expand Down Expand Up @@ -940,6 +939,7 @@ mod tests {
use alloy_chains::Chain;
use alloy_genesis::{ChainConfig, GenesisAccount};
use alloy_primitives::{b256, hex};
use alloy_trie::EMPTY_ROOT_HASH;
use reth_ethereum_forks::{ForkCondition, ForkHash, ForkId, Head};
use reth_trie_common::TrieAccount;

Expand Down
1 change: 0 additions & 1 deletion crates/cli/commands/src/stage/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C>
tx.clear::<tables::TransactionBlocks>()?;
tx.clear::<tables::BlockOmmers>()?;
tx.clear::<tables::BlockWithdrawals>()?;
tx.clear::<tables::BlockRequests>()?;
reset_stage_checkpoint(tx, StageId::Bodies)?;

insert_genesis_header(&provider_rw.0, &static_file_provider, &self.env.chain)?;
Expand Down
7 changes: 3 additions & 4 deletions crates/consensus/auto-seal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl StorageInner {
timestamp,
base_fee_per_gas,
blob_gas_used,
requests_root: requests.map(|r| proofs::calculate_requests_root(&r.0)),
requests_hash: requests.map(|r| r.requests_hash()),
..Default::default()
};

Expand Down Expand Up @@ -366,7 +366,6 @@ impl StorageInner {
transactions,
ommers: ommers.clone(),
withdrawals: withdrawals.clone(),
requests: requests.clone(),
},
}
.with_recovered_senders()
Expand All @@ -390,7 +389,7 @@ impl StorageInner {
// root here

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

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

Expand Down Expand Up @@ -682,7 +681,7 @@ mod tests {
timestamp,
base_fee_per_gas: None,
blob_gas_used: Some(0),
requests_root: None,
requests_hash: None,
excess_blob_gas: Some(0),
..Default::default()
}
Expand Down
24 changes: 1 addition & 23 deletions crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,6 @@ pub fn validate_cancun_gas(block: &SealedBlock) -> Result<(), ConsensusError> {
Ok(())
}

/// Validate that requests root is present if Prague is active.
///
/// See [EIP-7685]: General purpose execution layer requests
///
/// [EIP-7685]: https://eips.ethereum.org/EIPS/eip-7685
#[inline]
pub fn validate_prague_request(block: &SealedBlock) -> Result<(), ConsensusError> {
let requests_root =
block.body.calculate_requests_root().ok_or(ConsensusError::BodyRequestsMissing)?;
let header_requests_root = block.requests_root.ok_or(ConsensusError::RequestsRootMissing)?;
if requests_root != *header_requests_root {
return Err(ConsensusError::BodyRequestsRootDiff(
GotExpected { got: requests_root, expected: header_requests_root }.into(),
));
}
Ok(())
}

/// Validate a block without regard for state:
///
/// - Compares the ommer hash in the block header to the block body
Expand Down Expand Up @@ -127,10 +109,6 @@ pub fn validate_block_pre_execution<ChainSpec: EthereumHardforks>(
validate_cancun_gas(block)?;
}

if chain_spec.is_prague_active_at_timestamp(block.timestamp) {
validate_prague_request(block)?;
}

Ok(())
}

Expand Down Expand Up @@ -460,7 +438,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None
requests_hash: None
};
// size: 0x9b5

Expand Down
26 changes: 13 additions & 13 deletions crates/consensus/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use alloc::{fmt::Debug, vec::Vec};
use alloy_primitives::{BlockHash, BlockNumber, Bloom, B256, U256};
use reth_primitives::{
constants::MINIMUM_GAS_LIMIT, BlockWithSenders, GotExpected, GotExpectedBoxed, Header,
InvalidTransactionError, Receipt, Request, SealedBlock, SealedHeader,
InvalidTransactionError, Receipt, Requests, SealedBlock, SealedHeader,
};

/// A consensus implementation that does nothing.
Expand All @@ -31,12 +31,12 @@ pub struct PostExecutionInput<'a> {
/// Receipts of the block.
pub receipts: &'a [Receipt],
/// EIP-7685 requests of the block.
pub requests: &'a [Request],
pub requests: &'a Requests,
}

impl<'a> PostExecutionInput<'a> {
/// Creates a new instance of `PostExecutionInput`.
pub const fn new(receipts: &'a [Receipt], requests: &'a [Request]) -> Self {
pub const fn new(receipts: &'a [Receipt], requests: &'a Requests) -> Self {
Self { receipts, requests }
}
}
Expand Down Expand Up @@ -170,10 +170,10 @@ pub enum ConsensusError {
#[display("mismatched block withdrawals root: {_0}")]
BodyWithdrawalsRootDiff(GotExpectedBoxed<B256>),

/// Error when the requests root in the block is different from the expected requests
/// root.
#[display("mismatched block requests root: {_0}")]
BodyRequestsRootDiff(GotExpectedBoxed<B256>),
/// Error when the requests hash in the block is different from the expected requests
/// hash.
#[display("mismatched block requests hash: {_0}")]
BodyRequestsHashDiff(GotExpectedBoxed<B256>),

/// Error when a block with a specific hash and number is already known.
#[display("block with [hash={hash}, number={number}] is already known")]
Expand Down Expand Up @@ -248,17 +248,17 @@ pub enum ConsensusError {
#[display("missing withdrawals root")]
WithdrawalsRootMissing,

/// Error when the requests root is missing.
#[display("missing requests root")]
RequestsRootMissing,
/// Error when the requests hash is missing.
#[display("missing requests hash")]
RequestsHashMissing,

/// Error when an unexpected withdrawals root is encountered.
#[display("unexpected withdrawals root")]
WithdrawalsRootUnexpected,

/// Error when an unexpected requests root is encountered.
#[display("unexpected requests root")]
RequestsRootUnexpected,
/// Error when an unexpected requests hash is encountered.
#[display("unexpected requests hash")]
RequestsHashUnexpected,

/// Error when withdrawals are missing.
#[display("missing withdrawals")]
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/invalid-block-hooks/src/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ where
let response = ExecutionWitness {
state: HashMap::from_iter(state),
codes: Default::default(),
keys: Some(state_preimages),
keys: state_preimages,
};
let re_executed_witness_path = self.save_file(
format!("{}_{}.witness.re_executed.json", block.number, block.hash()),
Expand Down
3 changes: 1 addition & 2 deletions crates/engine/util/src/reorg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ where
transactions_root: proofs::calculate_transaction_root(&transactions),
receipts_root: outcome.receipts_root_slow(reorg_target.header.number).unwrap(),
logs_bloom: outcome.block_logs_bloom(reorg_target.header.number).unwrap(),
requests_root: None, // TODO(prague)
requests_hash: None, // TODO(prague)
gas_used: cumulative_gas_used,
blob_gas_used: blob_gas_used.map(Into::into),
excess_blob_gas: excess_blob_gas.map(Into::into),
Expand All @@ -411,7 +411,6 @@ where
transactions,
ommers: reorg_target.body.ommers,
withdrawals: reorg_target.body.withdrawals,
requests: None, // TODO(prague)
},
}
.seal_slow();
Expand Down
8 changes: 4 additions & 4 deletions crates/ethereum/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ impl<ChainSpec: Send + Sync + EthChainSpec + EthereumHardforks + Debug> Consensu
}

if self.chain_spec.is_prague_active_at_timestamp(header.timestamp) {
if header.requests_root.is_none() {
return Err(ConsensusError::RequestsRootMissing)
if header.requests_hash.is_none() {
return Err(ConsensusError::RequestsHashMissing)
}
} else if header.requests_root.is_some() {
return Err(ConsensusError::RequestsRootUnexpected)
} else if header.requests_hash.is_some() {
return Err(ConsensusError::RequestsHashUnexpected)
}

Ok(())
Expand Down
Loading

0 comments on commit d9f63a5

Please sign in to comment.