Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/daily_hive_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
run: |
FLAGS='--sim.parallelism 4 --sim.loglevel 1'
if [[ "$SIMULATION" == "ethereum/eels/consume-engine" || "$SIMULATION" == "ethereum/eels/consume-rlp" ]]; then
FLAGS+=" --sim.buildarg fixtures=https://github.com/ethereum/execution-spec-tests/releases/download/v5.3.0/fixtures_develop.tar.gz"
FLAGS+=" --sim.buildarg fixtures=https://github.com/ethereum/execution-spec-tests/releases/download/v5.4.0/fixtures_develop.tar.gz"
FLAGS+=" --sim.buildarg branch=forks/osaka"
FLAGS+=" --client.checktimelimit=180s"
fi
Expand Down
14 changes: 9 additions & 5 deletions crates/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl Blockchain {
let chain_config = self.storage.get_chain_config();

// Validate the block pre-execution
validate_block(block, &parent_header, &chain_config, ELASTICITY_MULTIPLIER)?;
validate_block_pre_execution(block, &parent_header, &chain_config, ELASTICITY_MULTIPLIER)?;

let vm_db = StoreVmDatabase::new(self.storage.clone(), parent_header)?;
let mut vm = self.new_evm(vm_db)?;
Expand Down Expand Up @@ -215,7 +215,7 @@ impl Blockchain {
let chain_config = self.storage.get_chain_config();

// Validate the block pre-execution
validate_block(block, parent_header, &chain_config, ELASTICITY_MULTIPLIER)?;
validate_block_pre_execution(block, parent_header, &chain_config, ELASTICITY_MULTIPLIER)?;
let block_validated_instant = Instant::now();

let exec_merkle_start = Instant::now();
Expand Down Expand Up @@ -666,7 +666,7 @@ impl Blockchain {
vm: &mut Evm,
) -> Result<BlockExecutionResult, ChainError> {
// Validate the block pre-execution
validate_block(block, parent_header, chain_config, ELASTICITY_MULTIPLIER)?;
validate_block_pre_execution(block, parent_header, chain_config, ELASTICITY_MULTIPLIER)?;
let execution_result = vm.execute_block(block)?;
// Validate execution went alright
validate_gas_used(&execution_result.receipts, &block.header)?;
Expand Down Expand Up @@ -1764,9 +1764,13 @@ pub fn find_parent_header(
/// Verifies that blob gas fields in the header are correct in reference to the block's body.
/// If a block passes this check, execution will still fail with execute_block when a transaction runs out of gas
///
/// Note that this doesn't validate that the transactions or withdrawals root of the header matches the body
/// # WARNING
///
/// This doesn't validate that the transactions or withdrawals root of the header matches the body
/// contents, since we assume the caller already did it. And, in any case, that wouldn't invalidate the block header.
pub fn validate_block(
///
/// To validate it, use [`ethrex_common::types::block::validate_block_body`]
pub fn validate_block_pre_execution(
block: &Block,
parent_header: &BlockHeader,
chain_config: &ChainConfig,
Expand Down
24 changes: 18 additions & 6 deletions crates/l2/prover/src/guest_program/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use crate::report_cycles;

use ethrex_blockchain::error::ChainError;
use ethrex_blockchain::{
validate_block, validate_gas_used, validate_receipts_root, validate_requests_hash,
validate_state_root,
validate_block_pre_execution, validate_gas_used, validate_receipts_root,
validate_requests_hash, validate_state_root,
};
use ethrex_common::types::AccountUpdate;
use ethrex_common::types::block_execution_witness::ExecutionWitness;
use ethrex_common::types::fee_config::FeeConfig;
use ethrex_common::types::{AccountUpdate, InvalidBlockBodyError, validate_block_body};
use ethrex_common::types::{
block_execution_witness::GuestProgramState, block_execution_witness::GuestProgramStateError,
};
Expand All @@ -35,6 +35,8 @@ use ethrex_l2_common::{

#[derive(Debug, thiserror::Error)]
pub enum StatelessExecutionError {
#[error("Block body and header don't match: {0}")]
BlockBodyValidationError(InvalidBlockBodyError),
#[error("Block validation error: {0}")]
BlockValidationError(ChainError),
#[error("Gas validation error: {0}")]
Expand Down Expand Up @@ -182,9 +184,15 @@ pub fn stateless_validation_l1(
let mut non_privileged_count = 0;

for block in blocks.iter() {
// Validate header and body match
report_cycles("validate_block_body", || {
validate_block_body(&block.header, &block.body)
.map_err(StatelessExecutionError::BlockBodyValidationError)
})?;

// Validate the block
report_cycles("validate_block", || {
validate_block(
report_cycles("validate_block_pre_execution", || {
validate_block_pre_execution(
block,
parent_block_header,
&chain_config,
Expand Down Expand Up @@ -402,8 +410,12 @@ fn execute_stateless(
let mut non_privileged_count = 0;

for (i, block) in blocks.iter().enumerate() {
// Validate header and body match
validate_block_body(&block.header, &block.body)
.map_err(StatelessExecutionError::BlockBodyValidationError)?;

// Validate the block
validate_block(
validate_block_pre_execution(
block,
parent_block_header,
&chain_config,
Expand Down
4 changes: 2 additions & 2 deletions crates/l2/sequencer/block_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ethrex_blockchain::{
error::ChainError,
fork_choice::apply_fork_choice,
payload::{BuildPayloadArgs, create_payload},
validate_block,
validate_block_pre_execution,
};
use ethrex_common::H256;
use ethrex_common::{Address, U256};
Expand Down Expand Up @@ -209,7 +209,7 @@ impl BlockProducer {
// Blockchain stores block
let block = payload_build_result.payload;
let chain_config = self.store.get_chain_config();
validate_block(
validate_block_pre_execution(
&block,
&head_header,
&chain_config,
Expand Down
2 changes: 1 addition & 1 deletion tooling/ef_tests/blockchain/.fixtures_url
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/ethereum/execution-spec-tests/releases/download/v5.3.0/fixtures_develop.tar.gz
https://github.com/ethereum/execution-spec-tests/releases/download/v5.4.0/fixtures_develop.tar.gz
2 changes: 1 addition & 1 deletion tooling/ef_tests/state/.fixtures_url
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/ethereum/execution-spec-tests/releases/download/v5.3.0/fixtures_develop.tar.gz
https://github.com/ethereum/execution-spec-tests/releases/download/v5.4.0/fixtures_develop.tar.gz
Loading