Skip to content

Commit

Permalink
Merge branch 'main' into klkvr/engine-validator-in-rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Oct 18, 2024
2 parents 2e30eee + 8d32fd7 commit ea30fd5
Show file tree
Hide file tree
Showing 60 changed files with 372 additions and 222 deletions.
3 changes: 3 additions & 0 deletions .github/assets/check_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ set +e # Disable immediate exit on error

# Array of crates to compile
crates=($(cargo metadata --format-version=1 --no-deps | jq -r '.packages[].name' | grep '^reth' | sort))

# Array of crates to exclude
# Used with the `contains` function.
# shellcheck disable=SC2034
exclude_crates=(
# The following are not working yet, but known to be fixable
reth-exex-types # https://github.com/paradigmxyz/reth/issues/9946
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ 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
auto_impl.workspace = true
Expand Down
6 changes: 4 additions & 2 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ pub use alloy_eips::eip1559::BaseFeeParams;

use alloc::{boxed::Box, sync::Arc, vec::Vec};
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 reth_ethereum_forks::{
ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition,
ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, DEV_HARDFORKS,
Expand All @@ -17,8 +19,8 @@ use reth_network_peers::{
};
use reth_primitives_traits::{
constants::{
DEV_GENESIS_HASH, EIP1559_INITIAL_BASE_FEE, EMPTY_WITHDRAWALS, ETHEREUM_BLOCK_GAS_LIMIT,
HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
EIP1559_INITIAL_BASE_FEE, ETHEREUM_BLOCK_GAS_LIMIT, HOLESKY_GENESIS_HASH,
SEPOLIA_GENESIS_HASH,
},
Header, SealedHeader,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e-test-utils/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<E: EngineTypes> PayloadTestContext<E> {
) -> eyre::Result<E::PayloadBuilderAttributes> {
self.timestamp += 1;
let attributes: E::PayloadBuilderAttributes = attributes_generator(self.timestamp);
self.payload_builder.new_payload(attributes.clone()).await.unwrap();
self.payload_builder.send_new_payload(attributes.clone()).await.unwrap()?;
Ok(attributes)
}

Expand Down
9 changes: 4 additions & 5 deletions crates/engine/local/src/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use reth_chainspec::EthereumHardforks;
use reth_engine_primitives::EngineTypes;
use reth_payload_builder::PayloadBuilderHandle;
use reth_payload_primitives::{
BuiltPayload, PayloadAttributesBuilder, PayloadBuilder, PayloadTypes,
BuiltPayload, PayloadAttributesBuilder, PayloadBuilder, PayloadKind, PayloadTypes,
};
use reth_provider::{BlockReader, ChainSpecProvider};
use reth_rpc_types_compat::engine::payload::block_to_payload;
Expand Down Expand Up @@ -202,10 +202,9 @@ where

let payload_id = res.payload_id.ok_or_eyre("No payload id")?;

// wait for some time to let the payload be built
tokio::time::sleep(Duration::from_millis(200)).await;

let Some(Ok(payload)) = self.payload_builder.best_payload(payload_id).await else {
let Some(Ok(payload)) =
self.payload_builder.resolve_kind(payload_id, PayloadKind::WaitForPending).await
else {
eyre::bail!("No payload")
};

Expand Down
1 change: 1 addition & 0 deletions crates/ethereum-forks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ auto_impl.workspace = true
[dev-dependencies]
arbitrary = { workspace = true, features = ["derive"] }
proptest.workspace = true
alloy-consensus.workspace = true

[features]
default = ["std", "serde", "rustc-hash"]
Expand Down
11 changes: 4 additions & 7 deletions crates/ethereum-forks/src/forkid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,12 @@ impl Cache {
#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::b256;

const GENESIS_HASH: B256 =
b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");
use alloy_consensus::constants::MAINNET_GENESIS_HASH;

// EIP test vectors.
#[test]
fn forkhash() {
let mut fork_hash = ForkHash::from(GENESIS_HASH);
let mut fork_hash = ForkHash::from(MAINNET_GENESIS_HASH);
assert_eq!(fork_hash.0, hex!("fc64ec04"));

fork_hash += 1_150_000u64;
Expand All @@ -468,7 +465,7 @@ mod tests {
fn compatibility_check() {
let mut filter = ForkFilter::new(
Head { number: 0, ..Default::default() },
GENESIS_HASH,
MAINNET_GENESIS_HASH,
0,
vec![
ForkFilterKey::Block(1_150_000),
Expand Down Expand Up @@ -727,7 +724,7 @@ mod tests {

let mut fork_filter = ForkFilter::new(
Head { number: 0, ..Default::default() },
GENESIS_HASH,
MAINNET_GENESIS_HASH,
0,
vec![ForkFilterKey::Block(b1), ForkFilterKey::Block(b2)],
);
Expand Down
3 changes: 2 additions & 1 deletion crates/ethereum/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,14 @@ impl ConfigureEvm for EthEvmConfig {
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::constants::KECCAK_EMPTY;
use alloy_genesis::Genesis;
use alloy_primitives::{B256, U256};
use reth_chainspec::{Chain, ChainSpec, MAINNET};
use reth_evm::execute::ProviderError;
use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId},
Header, KECCAK_EMPTY,
Header,
};
use reth_revm::{
db::{CacheDB, EmptyDBTyped},
Expand Down
1 change: 1 addition & 0 deletions crates/ethereum/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ alloy-genesis.workspace = true
tokio.workspace = true
futures-util.workspace = true
serde_json.workspace = true
alloy-consensus.workspace = true

[features]
default = []
Expand Down
12 changes: 10 additions & 2 deletions crates/ethereum/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use reth_node_builder::{
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadBuilderConfig, PayloadTypes,
};
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::Header;
use reth_primitives::{Block, Header};
use reth_provider::CanonStateSubscriptions;
use reth_rpc::EthApi;
use reth_tracing::tracing::{debug, info};
Expand All @@ -35,6 +35,14 @@ use reth_transaction_pool::{

use crate::{EthEngineTypes, EthEvmConfig};

/// Ethereum primitive types.
#[derive(Debug)]
pub struct EthPrimitives;

impl NodePrimitives for EthPrimitives {
type Block = Block;
}

/// Type configuration for a regular Ethereum node.
#[derive(Debug, Default, Clone, Copy)]
#[non_exhaustive]
Expand Down Expand Up @@ -69,7 +77,7 @@ impl EthereumNode {
}

impl NodeTypes for EthereumNode {
type Primitives = ();
type Primitives = EthPrimitives;
type ChainSpec = ChainSpec;
}

Expand Down
8 changes: 3 additions & 5 deletions crates/ethereum/node/tests/e2e/blobs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use alloy_consensus::constants::MAINNET_GENESIS_HASH;
use alloy_genesis::Genesis;
use alloy_primitives::b256;
use reth::{
args::RpcServerArgs,
builder::{NodeBuilder, NodeConfig, NodeHandle},
Expand Down Expand Up @@ -75,13 +75,11 @@ async fn can_handle_blobs() -> eyre::Result<()> {
.submit_payload(blob_payload, blob_attr, PayloadStatusEnum::Valid, versioned_hashes.clone())
.await?;

let genesis_hash = b256!("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3");

let (_, _) = tokio::join!(
// send fcu with blob hash
node.engine_api.update_forkchoice(genesis_hash, blob_block_hash),
node.engine_api.update_forkchoice(MAINNET_GENESIS_HASH, blob_block_hash),
// send fcu with normal hash
node.engine_api.update_forkchoice(genesis_hash, payload.block().hash())
node.engine_api.update_forkchoice(MAINNET_GENESIS_HASH, payload.block().hash())
);

// submit normal payload
Expand Down
13 changes: 4 additions & 9 deletions crates/net/eth-wire-types/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ impl Default for Status {
///
/// # Example
/// ```
/// use alloy_consensus::constants::MAINNET_GENESIS_HASH;
/// use alloy_primitives::{B256, U256};
/// use reth_chainspec::{Chain, EthereumHardfork, MAINNET};
/// use reth_eth_wire_types::{EthVersion, Status};
/// use reth_primitives::MAINNET_GENESIS_HASH;
///
/// // this is just an example status message!
/// let status = Status::builder()
Expand Down Expand Up @@ -216,6 +216,7 @@ impl StatusBuilder {
#[cfg(test)]
mod tests {
use crate::{EthVersion, Status};
use alloy_consensus::constants::MAINNET_GENESIS_HASH;
use alloy_genesis::Genesis;
use alloy_primitives::{hex, B256, U256};
use alloy_rlp::{Decodable, Encodable};
Expand All @@ -235,10 +236,7 @@ mod tests {
"feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13d",
)
.unwrap(),
genesis: B256::from_str(
"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
)
.unwrap(),
genesis: MAINNET_GENESIS_HASH,
forkid: ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 0 },
};

Expand All @@ -258,10 +256,7 @@ mod tests {
"feb27336ca7923f8fab3bd617fcb6e75841538f71c1bcfc267d7838489d9e13d",
)
.unwrap(),
genesis: B256::from_str(
"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
)
.unwrap(),
genesis: MAINNET_GENESIS_HASH,
forkid: ForkId { hash: ForkHash([0xb7, 0x15, 0x07, 0x7d]), next: 0 },
};
let status = Status::decode(&mut &data[..]).unwrap();
Expand Down
4 changes: 3 additions & 1 deletion crates/node/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ workspace = true
# reth
reth-chainspec.workspace = true
reth-db-api.workspace = true
reth-engine-primitives.workspace = true
reth-engine-primitives.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
13 changes: 9 additions & 4 deletions crates/node/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub use reth_primitives_traits::{Block, BlockBody};

use std::marker::PhantomData;

use reth_chainspec::EthChainSpec;
Expand All @@ -18,11 +20,14 @@ use reth_db_api::{
use reth_engine_primitives::EngineTypes;

/// Configures all the primitive types of the node.
// TODO(mattsse): this is currently a placeholder
pub trait NodePrimitives {}
pub trait NodePrimitives {
/// Block primitive.
type Block;
}

// TODO(mattsse): Placeholder
impl NodePrimitives for () {}
impl NodePrimitives for () {
type Block = reth_primitives::Block;
}

/// The type that configures the essential types of an Ethereum-like node.
///
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ reth-optimism-forks.workspace = true
alloy-chains.workspace = true
alloy-genesis.workspace = true
alloy-primitives.workspace = true
alloy-consensus.workspace = true

# op
op-alloy-rpc-types.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/chainspec/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use alloc::sync::Arc;

use alloy_chains::Chain;
use alloy_consensus::constants::DEV_GENESIS_HASH;
use alloy_primitives::U256;
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_optimism_forks::DEV_HARDFORKS;
use reth_primitives_traits::constants::DEV_GENESIS_HASH;

use crate::{LazyLock, OpChainSpec};

Expand Down
3 changes: 2 additions & 1 deletion crates/optimism/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl ConfigureEvm for OptimismEvmConfig {
#[cfg(test)]
mod tests {
use super::*;
use alloy_consensus::constants::KECCAK_EMPTY;
use alloy_genesis::Genesis;
use alloy_primitives::{B256, U256};
use reth_chainspec::ChainSpec;
Expand All @@ -216,7 +217,7 @@ mod tests {
use reth_optimism_chainspec::BASE_MAINNET;
use reth_primitives::{
revm_primitives::{BlockEnv, CfgEnv, SpecId},
Header, Receipt, Receipts, SealedBlockWithSenders, TxType, KECCAK_EMPTY,
Header, Receipt, Receipts, SealedBlockWithSenders, TxType,
};
use reth_revm::{
db::{CacheDB, EmptyDBTyped},
Expand Down
Loading

0 comments on commit ea30fd5

Please sign in to comment.