Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore - Upgrade reth dependencies #15

Merged
merged 10 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
3,850 changes: 2,178 additions & 1,672 deletions Cargo.lock

Large diffs are not rendered by default.

75 changes: 56 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,68 @@ name = "reth"
path = "src/main.rs"

[dependencies]
reth = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-ethereum-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-auto-seal-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-ethereum-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth-errors = { git = "https://github.com/paradigmxyz/reth", rev = "d599393771f9d7d137ea4abf271e1bd118184c73" }
reth = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-ethereum-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-auto-seal-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-ethereum-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-ethereum-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70", features = ["test-utils"] }
reth-errors = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-db-api = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-stages = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-stages-api = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-stages-types = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
reth-trie = { git = "https://github.com/paradigmxyz/reth", rev = "9a732f6b7813f9ecb5f28b379d3062c287a78e70" }
eyre = "0.6.12"
clap = { version = "4.5.6", features = ["derive"] }
alloy-sol-macro = "0.7.6"
alloy-sol-types = "0.7.6"
revm = "11.0.0"
revm-primitives = "6.0.0"
alloy-sol-macro = "0.8.5"
alloy-sol-types = "0.8.5"

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

serde_json = "1.0.117"
serde = { version = "1.0", default-features = false }
serde_with = "3.3.0"
hex = "0.4.3"
walkdir = "2.3.3"
thiserror = "1.0"
thiserror-no-std = { version = "2.0.2", default-features = false }

# eth
alloy-chains = "0.1.32"
alloy-dyn-abi = "0.8.0"
alloy-primitives = { version = "0.8.4", default-features = false }
alloy-serde = { version = "0.4.0", default-features = false }
alloy-rlp = "0.3.4"
alloy-trie = { version = "0.6", default-features = false }
rayon = "1.7"

tracing = "0.1.0"

[target.'cfg(unix)'.dependencies]
tikv-jemallocator = { version = "0.5.0", optional = true }
tikv-jemallocator = { version = "0.6", optional = true }
tikv-jemalloc-ctl = "0.6"
libc = "0.2"

[features]
Expand Down
13 changes: 13 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use reth_evm::execute::BlockExecutionError;

#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
pub enum GnosisBlockExecutionError {
#[error("Error: {message:?}")]
CustomErrorMessage { message: String },
}

impl From<GnosisBlockExecutionError> for BlockExecutionError {
fn from(err: GnosisBlockExecutionError) -> Self {
Self::other(err)
}
}
74 changes: 22 additions & 52 deletions src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@
use reth::{
primitives::{BlockWithSenders, Receipt, Request},
providers::ProviderError,
revm::{
primitives::ResultAndState, state_change::apply_blockhashes_update, Database,
DatabaseCommit, Evm, State,
},
revm::{primitives::ResultAndState, Database, DatabaseCommit, Evm, State},
};
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_evm::{
execute::{BlockExecutionError, BlockValidationError},
system_calls::{
apply_beacon_root_contract_call, apply_consolidation_requests_contract_call,
apply_withdrawal_requests_contract_call,
},
system_calls::{OnStateHook, SystemCaller},
ConfigureEvm,
};
use reth_evm_ethereum::eip6110::parse_deposits_from_receipts;
use revm_primitives::EVMError;
use reth_primitives::Header;
use std::{fmt::Display, sync::Arc};

/// Helper type for the output of executing a block.
Expand All @@ -40,44 +34,35 @@ pub struct EthEvmExecutor<EvmConfig> {

impl<EvmConfig> EthEvmExecutor<EvmConfig>
where
EvmConfig: ConfigureEvm,
EvmConfig: ConfigureEvm<Header = Header>,
{
/// Executes the transactions in the block and returns the receipts of the transactions in the
/// block, the total gas used and the list of EIP-7685 [requests](Request).
///
/// This applies the pre-execution and post-execution changes that require an [EVM](Evm), and
/// executes the transactions.
pub fn execute_state_transitions<Ext, DB>(
pub fn execute_state_transitions<Ext, DB, F>(
&self,
block: &BlockWithSenders,
mut evm: Evm<'_, Ext, &mut State<DB>>,
state_hook: Option<F>,
) -> Result<EthExecuteOutput, BlockExecutionError>
where
DB: Database<Error: Into<ProviderError> + Display>,
DB: Database,
DB::Error: Into<ProviderError> + Display,
F: OnStateHook,
{
// apply pre execution changes
apply_beacon_root_contract_call(
&self.evm_config,
&self.chain_spec,
block.timestamp,
block.number,
block.parent_beacon_block_root,
&mut evm,
)?;
apply_blockhashes_update(
evm.db_mut(),
&self.chain_spec,
block.timestamp,
block.number,
block.parent_hash,
)?;
let mut system_caller =
SystemCaller::new(&self.evm_config, &self.chain_spec).with_state_hook(state_hook);

system_caller.apply_pre_execution_changes(block, &mut evm)?;

// execute transactions
let mut cumulative_gas_used = 0;
let mut receipts = Vec::with_capacity(block.body.len());
let mut receipts = Vec::with_capacity(block.body.transactions.len());
for (sender, transaction) in block.transactions_with_sender() {
// The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior,
// must be no greater than the block’s gasLimit.
// The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior,
// must be no greater than the block’s gasLimit.
let block_available_gas = block.header.gas_limit - cumulative_gas_used;
if transaction.gas_limit() > block_available_gas {
return Err(
Expand All @@ -93,20 +78,16 @@ where
.fill_tx_env(evm.tx_mut(), transaction, *sender);

// Execute transaction.
let ResultAndState { result, state } = evm.transact().map_err(move |err| {
let new_err = match err {
EVMError::Transaction(e) => EVMError::Transaction(e),
EVMError::Header(e) => EVMError::Header(e),
EVMError::Database(e) => EVMError::Database(e.into()),
EVMError::Custom(e) => EVMError::Custom(e),
EVMError::Precompile(e) => EVMError::Precompile(e),
};
let result_and_state = evm.transact().map_err(move |err| {
let new_err = err.map_db_err(|e| e.into());
// Ensure hash is calculated for error log, if not already done
BlockValidationError::EVM {
hash: transaction.recalculate_hash(),
error: Box::new(new_err),
}
})?;
system_caller.on_state(&result_and_state);
let ResultAndState { result, state } = result_and_state;
evm.db_mut().commit(state);

// append gas used
Expand Down Expand Up @@ -135,20 +116,9 @@ where
// Collect all EIP-6110 deposits
let deposit_requests = parse_deposits_from_receipts(&self.chain_spec, &receipts)?;

// Collect all EIP-7685 requests
let withdrawal_requests =
apply_withdrawal_requests_contract_call(&self.evm_config, &mut evm)?;

// Collect all EIP-7251 requests
let consolidation_requests =
apply_consolidation_requests_contract_call(&self.evm_config, &mut evm)?;
let post_execution_requests = system_caller.apply_post_execution_changes(&mut evm)?;

[
deposit_requests,
withdrawal_requests,
consolidation_requests,
]
.concat()
[deposit_requests, post_execution_requests].concat()
} else {
vec![]
};
Expand Down
Loading
Loading