Skip to content

Commit

Permalink
regular dependency upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
debjit-bw committed Nov 28, 2024
1 parent 9baa4b6 commit 9d4ad0b
Show file tree
Hide file tree
Showing 9 changed files with 888 additions and 841 deletions.
1,506 changes: 751 additions & 755 deletions Cargo.lock

Large diffs are not rendered by default.

76 changes: 36 additions & 40 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,39 @@ name = "reth"
path = "src/main.rs"

[dependencies]
reth = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-ethereum-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-auto-seal-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-ethereum-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-ethereum-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9", features = ["test-utils"] }
reth-errors = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-db-api = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-rpc = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-stages = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-stages-api = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-stages-types = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-trie = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", rev = "bd8c4eceb20c39c6e501d06cf906469329340bb9" }
eyre = "0.6.12"
reth = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-evm = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-evm-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-ethereum-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-chainspec = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-chain-state = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-cli-util = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
# reth-auto-seal-consensus = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-prune-types = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-basic-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-ethereum-payload-builder = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-ethereum-engine-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-provider = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40", features = ["test-utils"] }
reth-errors = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-db = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-db-api = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-rpc = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-stages = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-stages-api = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-stages-types = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-primitives = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-trie = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
reth-trie-db = { git = "https://github.com/paradigmxyz/reth", rev = "496bf0bf715f0a1fafc198f8d72ccd71913d1a40" }
eyre = "0.6"
clap = { version = "4.5.6", features = ["derive"] }

# revm
revm = { version = "17.0.0", features = [
"std",
"secp256k1",
"blst",
], default-features = false }
revm-inspectors = "0.10.0"
revm-primitives = { version = "13.0.0", features = [
revm = { version = "18.0.0", features = ["std"], default-features = false }
revm-inspectors = "0.11.0"
revm-primitives = { version = "14.0.0", features = [
"std",
], default-features = false }

Expand All @@ -62,16 +58,16 @@ 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.9", default-features = false }
alloy-dyn-abi = "0.8.11"
alloy-primitives = { version = "0.8.11", default-features = false }
alloy-rlp = "0.3.4"
alloy-sol-types = "0.8.0"
alloy-sol-types = "0.8.11"
alloy-trie = { version = "0.7", default-features = false }

alloy-consensus = { version = "0.5.4", default-features = false }
alloy-eips = { version = "0.5.4", default-features = false }
alloy-consensus = { version = "0.6.4", default-features = false }
alloy-eips = { version = "0.6.4", default-features = false }
alloy-sol-macro = "0.8.9"
alloy-serde = { version = "0.5.4", default-features = false }
alloy-serde = { version = "0.6.4", default-features = false }
rayon = "1.7"

tracing = "0.1.0"
Expand Down
83 changes: 73 additions & 10 deletions src/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
use reth::primitives::{BlockWithSenders, Header, SealedBlock, SealedHeader};
use reth_chainspec::ChainSpec;
use alloy_consensus::Header;
use reth::{
consensus_common::validation::{
validate_against_parent_4844, validate_against_parent_eip1559_base_fee,
validate_against_parent_hash_number, validate_body_against_header, validate_cancun_gas,
validate_header_base_fee, validate_header_gas, validate_shanghai_withdrawals,
},
primitives::{BlockBody, BlockWithSenders, SealedBlock, SealedHeader},
};
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_primitives::GotExpected;
use revm_primitives::U256;
use std::sync::Arc;

Expand All @@ -18,17 +27,27 @@ impl GnosisBeaconConsensus {

// `validate_header`, `validate_header_against_parent`, `validate_header_with_total_difficulty`, `validate_block_pre_execution`, `validate_block_post_execution`
impl Consensus for GnosisBeaconConsensus {
fn validate_header(&self, _header: &SealedHeader) -> Result<(), ConsensusError> {
// TODO
Ok(())
fn validate_header(&self, header: &SealedHeader) -> Result<(), ConsensusError> {
validate_header_gas(header)?;
validate_header_base_fee(header, &self.chain_spec)
}

fn validate_header_against_parent(
&self,
_header: &SealedHeader,
_parent: &SealedHeader,
header: &SealedHeader,
parent: &SealedHeader,
) -> Result<(), ConsensusError> {
// TODO
validate_against_parent_hash_number(header, parent)?;
validate_against_parent_eip1559_base_fee(header, parent, &self.chain_spec)?;

// ensure that the blob gas fields for this block
if self
.chain_spec
.is_cancun_active_at_timestamp(header.timestamp)
{
validate_against_parent_4844(header, parent)?;
}

Ok(())
}

Expand All @@ -41,8 +60,52 @@ impl Consensus for GnosisBeaconConsensus {
Ok(())
}

fn validate_block_pre_execution(&self, _block: &SealedBlock) -> Result<(), ConsensusError> {
// TODO
fn validate_body_against_header(
&self,
body: &BlockBody,
header: &SealedHeader,
) -> Result<(), ConsensusError> {
validate_body_against_header(body, header)
}

// fn validate_block_pre_execution(&self, _block: &SealedBlock) -> Result<(), ConsensusError> {
// // TODO
// Ok(())
// }

fn validate_block_pre_execution(&self, block: &SealedBlock) -> Result<(), ConsensusError> {
// Check ommers hash
let ommers_hash = reth_primitives::proofs::calculate_ommers_root(&block.body.ommers);
if block.header.ommers_hash != ommers_hash {
return Err(ConsensusError::BodyOmmersHashDiff(
GotExpected {
got: ommers_hash,
expected: block.header.ommers_hash,
}
.into(),
));
}

// Check transaction root
if let Err(error) = block.ensure_transaction_root_valid() {
return Err(ConsensusError::BodyTransactionRootDiff(error.into()));
}

// EIP-4895: Beacon chain push withdrawals as operations
if self
.chain_spec
.is_shanghai_active_at_timestamp(block.timestamp)
{
validate_shanghai_withdrawals(block)?;
}

if self
.chain_spec
.is_cancun_active_at_timestamp(block.timestamp)
{
validate_cancun_gas(block)?;
}

Ok(())
}

Expand Down
11 changes: 4 additions & 7 deletions src/evm_config.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
use alloy_consensus::Header;
use alloy_primitives::{Address, U256};
use reth::revm::{inspector_handle_register, Database, GetInspector};
use reth::revm::{Evm, EvmBuilder};
use reth_chainspec::ChainSpec;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
use reth_evm_ethereum::{revm_spec, revm_spec_by_timestamp_after_merge};
use reth_primitives::{
revm_primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv},
transaction::FillTxEnv,
Head, Header, TransactionSigned,
};
use reth_primitives::{transaction::FillTxEnv, Head, TransactionSigned};
use revm::{
handler::mainnet::reward_beneficiary as reward_beneficiary_mainnet, interpreter::Gas, Context,
};
use revm_primitives::{
spec_to_generic, BlobExcessGasAndPrice, BlockEnv, Bytes, CfgEnv, EVMError, Env, HandlerCfg,
Spec, SpecId, TxKind,
spec_to_generic, AnalysisKind, BlobExcessGasAndPrice, BlockEnv, Bytes, CfgEnv,
CfgEnvWithHandlerCfg, EVMError, Env, HandlerCfg, Spec, SpecId, TxEnv, TxKind,
};
use std::{convert::Infallible, sync::Arc};

Expand Down
6 changes: 3 additions & 3 deletions src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::evm_config::GnosisEvmConfig;

use crate::gnosis::apply_post_block_system_calls;
use alloc::{boxed::Box, sync::Arc};
use alloy_consensus::Transaction as _;
use alloy_consensus::{Header, Transaction as _};
use alloy_eips::eip7685::Requests;
use alloy_primitives::Address;
use core::fmt::Display;
Expand All @@ -19,7 +19,7 @@ use reth_evm::{
};
use reth_evm_ethereum::eip6110::parse_deposits_from_receipts;
use reth_node_ethereum::BasicBlockExecutorProvider;
use reth_primitives::{BlockWithSenders, Header, Receipt};
use reth_primitives::{BlockWithSenders, Receipt};
use revm::State;
use revm_primitives::{
db::{Database, DatabaseCommit},
Expand Down Expand Up @@ -101,7 +101,7 @@ where
EvmConfig: Clone,
{
pub fn new(state: State<DB>, chain_spec: Arc<ChainSpec>, evm_config: EvmConfig) -> Self {
let system_caller = SystemCaller::new(evm_config.clone(), (*chain_spec).clone());
let system_caller = SystemCaller::new(evm_config.clone(), chain_spec.clone());
let block_rewards_contract = chain_spec
.genesis()
.config
Expand Down
13 changes: 5 additions & 8 deletions src/gnosis.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
use std::collections::HashMap;

use crate::errors::GnosisBlockExecutionError;
use alloy_eips::eip4895::{Withdrawal, Withdrawals};
use alloy_primitives::{address, Address, U256};
use alloy_sol_macro::sol;
use alloy_sol_types::SolCall;
use reth::{
primitives::Withdrawal,
revm::{
interpreter::Host,
primitives::{ExecutionResult, Output, ResultAndState},
Database, DatabaseCommit, Evm, State,
},
use reth::revm::{
interpreter::Host,
primitives::{ExecutionResult, Output, ResultAndState},
Database, DatabaseCommit, Evm, State,
};
use reth_chainspec::ChainSpec;
use reth_chainspec::EthereumHardforks;
use reth_errors::BlockValidationError;
use reth_evm::{execute::BlockExecutionError, ConfigureEvm};
use reth_primitives::Withdrawals;
use reth_provider::ProviderError;
use revm_primitives::{
Account, AccountInfo, AccountStatus, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg,
Expand Down
8 changes: 1 addition & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,7 @@ where
type Consensus = Arc<dyn reth_consensus::Consensus>;

async fn build_consensus(self, ctx: &BuilderContext<Node>) -> eyre::Result<Self::Consensus> {
if ctx.is_dev() {
Ok(Arc::new(reth_auto_seal_consensus::AutoSealConsensus::new(
ctx.chain_spec(),
)))
} else {
Ok(Arc::new(GnosisBeaconConsensus::new(ctx.chain_spec())))
}
Ok(Arc::new(GnosisBeaconConsensus::new(ctx.chain_spec())))
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ fn main() {
}
}
}

// ./target/debug/reth --chain ./scripts/chiado_genesis_alloc.json init-state ./state_at_26478650.jsonl --without-evm --header ./alt_header.rlp --total-difficulty 8626000110427540000000000000000000000000000000 --header-hash 3eaf85f384900ee9cf4e23f8e7584ef7f3118bcb960d3f56c62cff5ca95166f3
24 changes: 13 additions & 11 deletions src/payload_builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use alloy_consensus::EMPTY_OMMER_ROOT_HASH;
use alloy_consensus::{Header, EMPTY_OMMER_ROOT_HASH};
use alloy_eips::{eip4844::MAX_DATA_GAS_PER_BLOCK, eip7685::Requests, merge::BEACON_NONCE};
use eyre::eyre;
use reth::{
Expand All @@ -12,7 +12,7 @@ use reth::{
},
primitives::{
proofs::{self},
Block, Header, Receipt,
Block, Receipt,
},
revm::database::StateProviderDatabase,
transaction_pool::{noop::NoopTransactionPool, BestTransactionsAttributes, TransactionPool},
Expand Down Expand Up @@ -508,13 +508,15 @@ where
// only determine cancun fields when active
if chain_spec.is_cancun_active_at_timestamp(attributes.timestamp) {
// grab the blob sidecars from the executed txs
blob_sidecars = pool.get_all_blobs_exact(
executed_txs
.iter()
.filter(|tx| tx.is_eip4844())
.map(|tx| tx.hash)
.collect(),
)?;
blob_sidecars = pool
.get_all_blobs_exact(
executed_txs
.iter()
.filter(|tx| tx.is_eip4844())
.map(|tx| tx.hash)
.collect(),
)
.map_err(PayloadBuilderError::other)?;

excess_blob_gas = if chain_spec.is_cancun_active_at_timestamp(parent_header.timestamp) {
let parent_excess_blob_gas = parent_header.excess_blob_gas.unwrap_or_default();
Expand Down Expand Up @@ -566,12 +568,12 @@ where
},
};

let sealed_block = block.seal_slow();
let sealed_block = Arc::new(block.seal_slow());
debug!(target: "payload_builder", ?sealed_block, "sealed built block");

// create the executed block data
let executed = ExecutedBlock {
block: Arc::new(sealed_block.clone()),
block: sealed_block.clone(),
senders: Arc::new(executed_senders),
execution_output: Arc::new(execution_outcome),
hashed_state: Arc::new(hashed_state),
Expand Down

0 comments on commit 9d4ad0b

Please sign in to comment.