Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
test: fix incorrect withdrawal_hash assigned
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiWu123 committed Oct 4, 2023
1 parent 953da96 commit 97193e8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bus-mapping/src/circuit_input_builder/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl Block {

/// Return root of withdrawals of this block
pub fn withdrawals_root(&self) -> H256 {
self.eth_block.withdrawals_root.unwrap()
self.eth_block.withdrawals_root.unwrap_or_default()
}

/// Push a copy event to the block.
Expand Down
2 changes: 1 addition & 1 deletion mock/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Default for MockBlock {
mix_hash: Hash::zero(),
nonce: H64::zero(),
base_fee_per_gas: Some(*MOCK_BASEFEE),
withdrawal_hash: Some(Hash::zero()),
withdrawal_hash: None,
// Other information
total_difficulty: Word::zero(),
seal_fields: Vec::new(),
Expand Down
16 changes: 15 additions & 1 deletion testool/src/statetest/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bus_mapping::{
use eth_types::{geth_types, Address, Bytes, Error, GethExecTrace, U256, U64};
use ethers_core::{
k256::ecdsa::SigningKey,
types::{transaction::eip2718::TypedTransaction, TransactionRequest},
types::{transaction::eip2718::TypedTransaction, TransactionRequest, Withdrawal},
};
use ethers_signers::{LocalWallet, Signer};
use external_tracer::TraceConfig;
Expand Down Expand Up @@ -279,13 +279,27 @@ pub fn run_test(
})
.collect();

let withdrawals = trace_config
.withdrawals
.into_iter()
.map(|wd| {
Some(Withdrawal {
index: wd.id.into(),
validator_index: wd.validator_id.into(),
address: wd.address,
amount: wd.amount.into(),
})
})
.collect();

let eth_block = eth_types::Block {
author: Some(trace_config.block_constants.coinbase),
timestamp: trace_config.block_constants.timestamp,
number: Some(U64::from(trace_config.block_constants.number.as_u64())),
difficulty: trace_config.block_constants.difficulty,
gas_limit: trace_config.block_constants.gas_limit,
base_fee_per_gas: Some(trace_config.block_constants.base_fee),
withdrawals,
transactions,
..eth_types::Block::default()
};
Expand Down
2 changes: 1 addition & 1 deletion zkevm-circuits/src/witness/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<F: Field> Block<F> {

/// Return the root of withdrawals in this block
pub fn withdrawals_root(&self) -> H256 {
self.eth_block.withdrawals_root.unwrap()
self.eth_block.withdrawals_root.unwrap_or_default()
}

/// Obtains the expected Circuit degree needed in order to be able to test
Expand Down

0 comments on commit 97193e8

Please sign in to comment.