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 dfcaad4 commit 3cfd2ba
Show file tree
Hide file tree
Showing 35 changed files with 315 additions and 382 deletions.
276 changes: 178 additions & 98 deletions Cargo.lock

Large diffs are not rendered by default.

56 changes: 27 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,7 @@ 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 = { version = "16.0.0", features = ["std"], default-features = false }
revm-inspectors = "0.8.1"
revm-primitives = { version = "10.0.0", features = [
"std",
Expand Down Expand Up @@ -596,29 +594,29 @@ 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"}
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-admin = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-debug = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-mev = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-txpool = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
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 @@ -4,10 +4,9 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_chains::{Chain, NamedChain};
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 @@ -283,8 +282,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 @@ -300,7 +299,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 @@ -939,6 +938,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
4 changes: 2 additions & 2 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| proofs::calculate_requests_root(&r.0)),
..Default::default()
};

Expand Down Expand Up @@ -682,7 +682,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
3 changes: 2 additions & 1 deletion crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub fn validate_cancun_gas(block: &SealedBlock) -> Result<(), ConsensusError> {
/// [EIP-7685]: https://eips.ethereum.org/EIPS/eip-7685
#[inline]
pub fn validate_prague_request(block: &SealedBlock) -> Result<(), ConsensusError> {
// todo: invalid
let requests_root =
block.body.calculate_requests_root().ok_or(ConsensusError::BodyRequestsMissing)?;
let header_requests_root = block.requests_root.ok_or(ConsensusError::RequestsRootMissing)?;
Expand Down Expand Up @@ -460,7 +461,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
2 changes: 1 addition & 1 deletion 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 Down
4 changes: 2 additions & 2 deletions crates/ethereum/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ 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() {
if header.requests_hash.is_none() {
return Err(ConsensusError::RequestsRootMissing)
}
} else if header.requests_root.is_some() {
} else if header.requests_hash.is_some() {
return Err(ConsensusError::RequestsRootUnexpected)
}

Expand Down
3 changes: 2 additions & 1 deletion crates/ethereum/consensus/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ pub fn validate_block_post_execution<ChainSpec: EthereumHardforks>(

// Validate that the header requests root matches the calculated requests root
if chain_spec.is_prague_active_at_timestamp(block.timestamp) {
let Some(header_requests_root) = block.header.requests_root else {
// todo: update
let Some(header_requests_root) = block.header.requests_hash else {
return Err(ConsensusError::RequestsRootMissing)
};
let requests_root = reth_primitives::proofs::calculate_requests_root(requests);
Expand Down
5 changes: 2 additions & 3 deletions crates/ethereum/engine-primitives/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use reth_chain_state::ExecutedBlock;
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
use reth_primitives::{SealedBlock, Withdrawals};
use reth_rpc_types_compat::engine::payload::{
block_to_payload_v1, block_to_payload_v3, block_to_payload_v4,
convert_block_to_payload_field_v2,
block_to_payload_v1, block_to_payload_v3, convert_block_to_payload_field_v2,
};
use std::convert::Infallible;

Expand Down Expand Up @@ -145,7 +144,7 @@ impl From<EthBuiltPayload> for ExecutionPayloadEnvelopeV4 {
let EthBuiltPayload { block, fees, sidecars, .. } = value;

Self {
execution_payload: block_to_payload_v4(block),
execution_payload: block_to_payload_v3(block),
block_value: fees,
// From the engine API spec:
//
Expand Down
12 changes: 6 additions & 6 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::{TxLegacy, EMPTY_ROOT_HASH};
use alloy_consensus::{constants::KECCAK_EMPTY, TxLegacy, EMPTY_ROOT_HASH};
use alloy_eips::{
eip2935::{HISTORY_STORAGE_ADDRESS, HISTORY_STORAGE_CODE},
eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_CODE, SYSTEM_ADDRESS},
Expand Down Expand Up @@ -1016,7 +1016,7 @@ mod tests {
parent_hash: B256::random(),
timestamp: 1,
number: fork_activation_block,
requests_root: Some(EMPTY_ROOT_HASH),
requests_hash: Some(KECCAK_EMPTY),
..Header::default()
};
let provider = executor_provider(chain_spec);
Expand Down Expand Up @@ -1075,7 +1075,7 @@ mod tests {
parent_hash: B256::random(),
timestamp: 1,
number: fork_activation_block,
requests_root: Some(EMPTY_ROOT_HASH),
requests_hash: Some(KECCAK_EMPTY),
..Header::default()
};

Expand Down Expand Up @@ -1121,7 +1121,7 @@ mod tests {
);

let mut header = chain_spec.genesis_header().clone();
header.requests_root = Some(EMPTY_ROOT_HASH);
header.requests_hash = Some(KECCAK_EMPTY);
let header_hash = header.hash_slow();

let provider = executor_provider(chain_spec);
Expand Down Expand Up @@ -1159,7 +1159,7 @@ mod tests {
parent_hash: header_hash,
timestamp: 1,
number: 1,
requests_root: Some(EMPTY_ROOT_HASH),
requests_hash: Some(KECCAK_EMPTY),
..Header::default()
};
let header_hash = header.hash_slow();
Expand Down Expand Up @@ -1196,7 +1196,7 @@ mod tests {
parent_hash: header_hash,
timestamp: 1,
number: 2,
requests_root: Some(EMPTY_ROOT_HASH),
requests_hash: Some(KECCAK_EMPTY),
..Header::default()
};

Expand Down
12 changes: 6 additions & 6 deletions crates/ethereum/evm/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::{TxLegacy, EMPTY_ROOT_HASH};
use alloy_consensus::{constants::KECCAK_EMPTY, TxLegacy, EMPTY_ROOT_HASH};
use alloy_eips::{
eip2935::{HISTORY_STORAGE_ADDRESS, HISTORY_STORAGE_CODE},
eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_CODE, SYSTEM_ADDRESS},
Expand Down Expand Up @@ -797,7 +797,7 @@ mod tests {
parent_hash: B256::random(),
timestamp: 1,
number: fork_activation_block,
requests_root: Some(EMPTY_ROOT_HASH),
requests_hash: Some(KECCAK_EMPTY),
..Header::default()
};
let provider = executor_provider(chain_spec);
Expand Down Expand Up @@ -855,7 +855,7 @@ mod tests {
parent_hash: B256::random(),
timestamp: 1,
number: fork_activation_block,
requests_root: Some(EMPTY_ROOT_HASH),
requests_hash: Some(KECCAK_EMPTY),
..Header::default()
};

Expand Down Expand Up @@ -901,7 +901,7 @@ mod tests {
);

let mut header = chain_spec.genesis_header().clone();
header.requests_root = Some(EMPTY_ROOT_HASH);
header.requests_hash = Some(KECCAK_EMPTY);
let header_hash = header.hash_slow();

let provider = executor_provider(chain_spec);
Expand Down Expand Up @@ -938,7 +938,7 @@ mod tests {
parent_hash: header_hash,
timestamp: 1,
number: 1,
requests_root: Some(EMPTY_ROOT_HASH),
requests_hash: Some(KECCAK_EMPTY),
..Header::default()
};
let header_hash = header.hash_slow();
Expand Down Expand Up @@ -977,7 +977,7 @@ mod tests {
parent_hash: header_hash,
timestamp: 1,
number: 2,
requests_root: Some(EMPTY_ROOT_HASH),
requests_hash: Some(KECCAK_EMPTY),
..Header::default()
};

Expand Down
3 changes: 2 additions & 1 deletion crates/ethereum/payload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ where
}

// calculate the requests and the requests root
// todo
let (requests, requests_root) = if chain_spec
.is_prague_active_at_timestamp(attributes.timestamp)
{
Expand Down Expand Up @@ -414,7 +415,7 @@ where
parent_beacon_block_root: attributes.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: None, // TODO,
};

// seal the block
Expand Down
8 changes: 4 additions & 4 deletions crates/net/eth-wire-types/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None
requests_hash: None
},
]),
}.encode(&mut data);
Expand Down Expand Up @@ -312,7 +312,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None
requests_hash: None
},
]),
};
Expand Down Expand Up @@ -412,7 +412,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None
requests_hash: None
},
],
withdrawals: None,
Expand Down Expand Up @@ -488,7 +488,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None
requests_hash: None
},
],
withdrawals: None,
Expand Down
6 changes: 3 additions & 3 deletions crates/net/eth-wire-types/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None
requests_hash: None
};
assert_eq!(header.hash_slow(), expected_hash);
}
Expand Down Expand Up @@ -256,7 +256,7 @@ mod tests {
blob_gas_used: Some(0x020000),
excess_blob_gas: Some(0),
parent_beacon_block_root: None,
requests_root: None,
requests_hash: None,
};

let header = Header::decode(&mut data.as_slice()).unwrap();
Expand Down Expand Up @@ -296,7 +296,7 @@ mod tests {
parent_beacon_block_root: None,
blob_gas_used: Some(0),
excess_blob_gas: Some(0x1600000),
requests_root: None,
requests_hash: None,
};

let header = Header::decode(&mut data.as_slice()).unwrap();
Expand Down
Loading

0 comments on commit 3cfd2ba

Please sign in to comment.