Skip to content

Commit

Permalink
Update reth to v1.1.5 (#645)
Browse files Browse the repository at this point in the history
* wip: upgrade to reth 1.1.5

* rm EvmEnvProvider trait

* fixes to rpc

* fix engine.rs and node.rs

* fix payload

* fix env

* fix payloads

* refactor: fix exex

* fixes to evmexec

* chore: update Cargo.lock

* remove unused conversion

* remove obsolete comment
  • Loading branch information
prajwolrg authored Feb 1, 2025
1 parent dcc3f77 commit 69ab2da
Show file tree
Hide file tree
Showing 24 changed files with 1,742 additions and 1,152 deletions.
1,357 changes: 702 additions & 655 deletions Cargo.lock

Large diffs are not rendered by default.

103 changes: 51 additions & 52 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,70 +125,69 @@ zkaleido-sp1-adapter = { git = "https://github.com/alpenlabs/zkaleido", tag = "v

# IMPORTANT: ensure alloy-* and revm packages are of the same version as inside reth dependency
# reth dependencies:
alloy-consensus = { version = "0.7.3", default-features = false }
alloy-eips = { version = "0.7.3", default-features = false }
alloy-genesis = { version = "0.7.3", default-features = false }
alloy-network = { version = "0.7.3", default-features = false }
alloy-primitives = { version = "0.8.11", default-features = false }
alloy-rlp = { version = "0.3.10", default-features = false }
alloy-rlp-derive = "0.3.10"
alloy-rpc-types = { version = "0.7.3", features = [
alloy-consensus = { 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-network = { version = "0.9.2", default-features = false }
alloy-primitives = { version = "0.8.19", default-features = false }
alloy-rlp = { version = "0.3.11", default-features = false }
alloy-rlp-derive = "0.3.11"
alloy-rpc-types = { version = "0.9.2", features = [
"eth",
], default-features = false }
alloy-rpc-types-eth = { version = "0.7.3", default-features = false, features = [
alloy-rpc-types-eth = { version = "0.9.2", default-features = false, features = [
"serde",
] }
alloy-serde = { version = "0.7.3", default-features = false }
alloy-sol-types = "0.8.11"
# TODO: fix exact version during the next reth bump.
alloy-trie = { version = "=0.7.6", default-features = false }
revm = { version = "18.0.0", features = ["std"], default-features = false }
revm-primitives = { version = "14.0.0", features = [
alloy-serde = { version = "0.9.2", default-features = false }
alloy-sol-types = "0.8.19"
alloy-trie = { version = "0.7", default-features = false }
revm = { version = "19.2.0", features = ["std"], default-features = false }
revm-primitives = { version = "15.1.0", features = [
"std",
"serde",
], default-features = false }

# reth itself:
reth = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-cli = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-cli-commands = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-db = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-errors = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-ethereum-forks = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-ethereum-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-evm = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-exex = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-ipc = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-network-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-payload-validator = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3", default-features = false, features = [
reth = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-cli = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-cli-commands = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-db = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-errors = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-ethereum-forks = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-ethereum-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-evm = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-exex = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-ipc = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-network-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-node-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-node-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-payload-builder = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-payload-validator = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5", default-features = false, features = [
"std",
"serde-bincode-compat",
] }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3", default-features = false }
reth-provider = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-revm = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-rpc = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-rpc-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3", default-features = false }
reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-rpc-server-types = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-rpc-types-compat = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-tasks = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-trie = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-trie-common = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.3" }
reth-primitives-traits = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5", default-features = false }
reth-provider = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-revm = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-rpc = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-rpc-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-rpc-eth-api = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-rpc-eth-types = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5", default-features = false }
reth-rpc-layer = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-rpc-server-types = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-rpc-types-compat = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-tasks = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-trie = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-trie-common = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth.git", rev = "v1.1.5" }

anyhow = "1.0.86"
arbitrary = { version = "1.3.2", features = ["derive"] }
Expand Down
7 changes: 4 additions & 3 deletions crates/evmexec/src/el_payload.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_rpc_types::engine::ExecutionPayloadV1;
use arbitrary::Arbitrary;
use borsh::{BorshDeserialize, BorshSerialize};
use reth_rpc_types_compat::engine::try_payload_v1_to_block;
use reth_primitives::{Block, TransactionSigned};
use revm_primitives::{FixedBytes, B256};
use strata_primitives::{
buf::{Buf20, Buf32},
Expand Down Expand Up @@ -54,8 +54,9 @@ pub fn make_update_input_from_payload_and_ops(
) -> Result<UpdateInput, ElPayloadError> {
let extra_payload = create_evm_extra_payload(el_payload.block_hash);
let v1_payload = ExecutionPayloadV1::from(el_payload);
let evm_block = try_payload_v1_to_block(v1_payload)
.map_err(|err| ElPayloadError::BlockConversionError(err.to_string()))?;
let evm_block: Block<TransactionSigned> = v1_payload
.try_into_block()
.map_err(|e| ElPayloadError::BlockConversionError(e.to_string()))?;

Ok(UpdateInput::new(
evm_block.number,
Expand Down
2 changes: 0 additions & 2 deletions crates/evmexec/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ impl<T: EngineRpc> RpcExecEngineInner<T> {
withdrawals: Some(withdrawals),
parent_beacon_block_root: None,
suggested_fee_recipient: COINBASE_ADDRESS,
max_blobs_per_block: None,
target_blobs_per_block: None,
});

let mut fcs = *self.fork_choice_state.lock().await;
Expand Down
7 changes: 5 additions & 2 deletions crates/evmexec/src/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloy_rpc_types::engine::{
use jsonrpsee::http_client::{transport::HttpBackend, HttpClient, HttpClientBuilder};
#[cfg(test)]
use mockall::automock;
use reth_primitives::Block;
use reth_primitives::{Block, SealedBlock, TransactionSigned};
use reth_rpc_api::{EngineApiClient, EthApiClient};
use reth_rpc_layer::{AuthClientLayer, AuthClientService};
use revm_primitives::alloy_primitives::BlockHash;
Expand Down Expand Up @@ -109,6 +109,9 @@ impl EngineRpc for EngineRpcClient {
>>::block_by_hash(&self.client, block_hash, true)
.await?;

Ok(block.map(|b| b.try_into().unwrap()))
Ok(block.map(|b| {
let sealed_block: SealedBlock = b.try_into().unwrap();
Block::<TransactionSigned>::from(sealed_block)
}))
}
}
4 changes: 2 additions & 2 deletions crates/reth/exex/src/cache_db_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl DatabaseRef for CacheDBProvider {
fn basic_ref(&self, address: Address) -> Result<Option<AccountInfo>, Self::Error> {
let account_info = self
.provider
.basic_account(address)?
.basic_account(&address)?
.map(|account| account.into());

// Record the account value to the state.
Expand All @@ -94,7 +94,7 @@ impl DatabaseRef for CacheDBProvider {
fn code_by_hash_ref(&self, code_hash: B256) -> Result<Bytecode, Self::Error> {
let bytecode = self
.provider
.bytecode_by_hash(code_hash)?
.bytecode_by_hash(&code_hash)?
.map(|code| Bytecode::new_raw(code.bytes()))
.ok_or_else(|| {
ProviderError::Database(DatabaseError::Other(format!(
Expand Down
14 changes: 4 additions & 10 deletions crates/reth/exex/src/prover_exex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashMap, sync::Arc};
use alloy_rpc_types::{serde_helpers::JsonStorageKey, BlockNumHash, EIP1186AccountProofResponse};
use eyre::eyre;
use futures_util::TryStreamExt;
use reth_evm::execute::{BlockExecutionInput, BlockExecutorProvider, Executor};
use reth_evm::execute::{BlockExecutorProvider, Executor};
use reth_exex::{ExExContext, ExExEvent};
use reth_node_api::{FullNodeComponents, NodeTypes};
use reth_primitives::{BlockExt, BlockWithSenders, EthPrimitives};
Expand Down Expand Up @@ -83,12 +83,9 @@ impl<
}
}

fn get_accessed_states<
'a,
Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>,
>(
fn get_accessed_states<Node: FullNodeComponents<Types: NodeTypes<Primitives = EthPrimitives>>>(
ctx: &ExExContext<Node>,
block: &'a BlockWithSenders,
block: &BlockWithSenders,
block_idx: u64,
) -> eyre::Result<AccessedState> {
let executor: <Node as FullNodeComponents>::Executor = ctx.block_executor().clone();
Expand All @@ -97,10 +94,7 @@ fn get_accessed_states<
let cache_db_provider = CacheDBProvider::new(provider);
let cache_db = CacheDB::new(&cache_db_provider);

let block_exec_input: BlockExecutionInput<'a, BlockWithSenders> =
BlockExecutionInput::new(block, block.difficulty);

executor.executor(cache_db).execute(block_exec_input)?;
executor.executor(cache_db).execute(block)?;

let acessed_state = cache_db_provider.get_accessed_state();
Ok(acessed_state)
Expand Down
40 changes: 24 additions & 16 deletions crates/reth/node/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ use alloy_rpc_types::engine::{
ExecutionPayload, ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4,
ExecutionPayloadSidecar, ExecutionPayloadV1, PayloadError,
};
use reth::rpc::compat::engine::payload::block_to_payload;
use reth_chainspec::ChainSpec;
use reth_node_api::{
payload::PayloadTypes, validate_version_specific_fields, AddOnsContext,
payload::PayloadTypes, validate_version_specific_fields, AddOnsContext, BuiltPayload,
EngineApiMessageVersion, EngineObjectValidationError, EngineTypes, EngineValidator,
PayloadOrAttributes, PayloadValidator,
NodePrimitives, PayloadOrAttributes, PayloadValidator,
};
use reth_node_builder::{rpc::EngineValidatorBuilder, FullNodeComponents, NodeTypesWithEngine};
use reth_payload_validator::ExecutionPayloadValidator;
use reth_primitives::{Block, SealedBlockFor};
use serde::{Deserialize, Serialize};

use super::payload::{
StrataBuiltPayload, StrataExecutionPayloadEnvelopeV2, StrataPayloadBuilderAttributes,
};
use crate::{node::StrataPrimitives, StrataPayloadAttributes};
use super::payload::{StrataBuiltPayload, StrataPayloadBuilderAttributes};
use crate::{node::StrataPrimitives, StrataExecutionPayloadEnvelopeV2, StrataPayloadAttributes};

/// Custom engine types for strata to use custom payload attributes and payload
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
Expand All @@ -33,18 +32,10 @@ impl<T: PayloadTypes> PayloadTypes for StrataEngineTypes<T> {
type PayloadBuilderAttributes = T::PayloadBuilderAttributes;
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct StrataPayloadTypes;

impl PayloadTypes for StrataPayloadTypes {
type BuiltPayload = StrataBuiltPayload;
type PayloadAttributes = StrataPayloadAttributes;
type PayloadBuilderAttributes = StrataPayloadBuilderAttributes;
}

impl<T: PayloadTypes> EngineTypes for StrataEngineTypes<T>
where
T::BuiltPayload: TryInto<ExecutionPayloadV1>
T::BuiltPayload: BuiltPayload<Primitives: NodePrimitives<Block = reth_primitives::Block>>
+ TryInto<ExecutionPayloadV1>
+ TryInto<StrataExecutionPayloadEnvelopeV2>
+ TryInto<ExecutionPayloadEnvelopeV3>
+ TryInto<ExecutionPayloadEnvelopeV4>,
Expand All @@ -53,6 +44,23 @@ where
type ExecutionPayloadEnvelopeV2 = StrataExecutionPayloadEnvelopeV2;
type ExecutionPayloadEnvelopeV3 = ExecutionPayloadEnvelopeV3;
type ExecutionPayloadEnvelopeV4 = ExecutionPayloadEnvelopeV4;

fn block_to_payload(
block: SealedBlockFor<
<<Self::BuiltPayload as BuiltPayload>::Primitives as NodePrimitives>::Block,
>,
) -> (ExecutionPayload, ExecutionPayloadSidecar) {
block_to_payload(block)
}
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct StrataPayloadTypes;

impl PayloadTypes for StrataPayloadTypes {
type BuiltPayload = StrataBuiltPayload;
type PayloadAttributes = StrataPayloadAttributes;
type PayloadBuilderAttributes = StrataPayloadBuilderAttributes;
}

/// Strata engine validator
Expand Down
23 changes: 9 additions & 14 deletions crates/reth/node/src/evm.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use std::sync::Arc;

use reth_chainspec::ChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};
use reth_evm::{env::EvmEnv, ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};
use reth_node_ethereum::EthEvmConfig;
use reth_primitives::{Header, TransactionSigned};
use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
use revm_primitives::{
Address, AnalysisKind, BlockEnv, Bytes, CfgEnvWithHandlerCfg, Env, TxEnv, U256,
};
use revm_primitives::{Address, Bytes, CfgEnvWithHandlerCfg, Env, TxEnv};
use strata_reth_evm::set_evm_handles;

/// Custom EVM configuration
Expand All @@ -23,22 +21,19 @@ impl StrataEvmConfig {
inner: EthEvmConfig::new(chain_spec),
}
}

pub fn inner(&self) -> &EthEvmConfig {
&self.inner
}
}

impl ConfigureEvmEnv for StrataEvmConfig {
type Header = Header;
type Transaction = TransactionSigned;
type Error = core::convert::Infallible;

fn fill_cfg_env(
&self,
cfg_env: &mut CfgEnvWithHandlerCfg,
header: &Self::Header,
total_difficulty: U256,
) {
self.inner.fill_cfg_env(cfg_env, header, total_difficulty);
// TODO: check if it's still needed.
cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse;
fn fill_cfg_env(&self, cfg_env: &mut CfgEnvWithHandlerCfg, header: &Self::Header) {
self.inner.fill_cfg_env(cfg_env, header);
}

fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) {
Expand All @@ -60,7 +55,7 @@ impl ConfigureEvmEnv for StrataEvmConfig {
&self,
parent: &Self::Header,
attributes: NextBlockEnvAttributes,
) -> Result<(CfgEnvWithHandlerCfg, BlockEnv), Self::Error> {
) -> Result<EvmEnv, Self::Error> {
self.inner.next_cfg_and_block_env(parent, attributes)
}
}
Expand Down
Loading

0 comments on commit 69ab2da

Please sign in to comment.