Skip to content

Commit

Permalink
fix(cancun): dummy payloads and public input retrieval (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare authored May 27, 2024
1 parent 9af4bf7 commit aea633c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions evm_arithmetization/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ impl BlockMetadata {
(pis[18].to_canonical_u64() + (pis[19].to_canonical_u64() << 32)).into();
let block_gas_used = pis[20].to_canonical_u64().into();
let block_blob_gas_used =
(pis[23].to_canonical_u64() + (pis[24].to_canonical_u64() << 32)).into();
(pis[21].to_canonical_u64() + (pis[22].to_canonical_u64() << 32)).into();
let block_excess_blob_gas =
(pis[25].to_canonical_u64() + (pis[26].to_canonical_u64() << 32)).into();
let parent_beacon_block_root = get_h256(&pis[27..35]);
(pis[23].to_canonical_u64() + (pis[24].to_canonical_u64() << 32)).into();
let parent_beacon_block_root = get_h256(&pis[25..33]);
let block_bloom =
core::array::from_fn(|i| h2u(get_h256(&pis[35 + 8 * i..35 + 8 * (i + 1)])));
core::array::from_fn(|i| h2u(get_h256(&pis[33 + 8 * i..33 + 8 * (i + 1)])));

Self {
block_beneficiary,
Expand Down
25 changes: 18 additions & 7 deletions trace_decoder/src/decoding.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{
collections::HashMap,
fmt::{self, Display, Formatter},
iter::{self, once},
iter::once,
};

use ethereum_types::{Address, BigEndianHash, H256, U256, U512};
Expand Down Expand Up @@ -256,13 +256,13 @@ impl ProcessedBlockTrace {
let mut txn_gen_inputs = self
.txn_info
.into_iter()
.enumerate()
.map(|(idx, txn_info)| {
.map(|txn_info| {
let is_initial_payload = txn_idx == 0;

let current_idx = txn_idx;
if !txn_info.meta.is_dummy() {
txn_idx += 1;
}
let is_initial_payload = idx == 0;

Self::process_txn_info(
current_idx,
Expand Down Expand Up @@ -645,10 +645,21 @@ impl ProcessedBlockTrace {
// state accesses to the withdrawal addresses.
let withdrawal_addrs =
withdrawals_with_hashed_addrs_iter().map(|(_, h_addr, _)| h_addr);

let additional_paths = if last_inputs.txn_number_before == 0.into() {
// We need to include the beacon roots contract as this payload is at the
// start of the block execution.
vec![Nibbles::from_h256_be(H256(
BEACON_ROOTS_CONTRACT_ADDRESS_HASHED,
))]
} else {
vec![]
};

last_inputs.tries.state_trie = create_minimal_state_partial_trie(
&final_trie_state.state,
withdrawal_addrs,
iter::empty(),
additional_paths.into_iter(),
)?;
}

Expand Down Expand Up @@ -716,7 +727,7 @@ impl ProcessedBlockTrace {
);
// For each non-dummy txn, we increment `txn_number_after` by 1, and
// update `gas_used_after` accordingly.
extra_data.txn_number_after += U256::one();
extra_data.txn_number_after += U256::from(!txn_info.meta.is_dummy() as u8);
extra_data.gas_used_after += txn_info.meta.gas_used.into();

// Because we need to run delta application before creating the minimal
Expand Down Expand Up @@ -772,7 +783,7 @@ impl ProcessedBlockTrace {

// After processing a transaction, we update the remaining accumulators
// for the next transaction.
extra_data.txn_number_before += U256::one();
extra_data.txn_number_before = extra_data.txn_number_after;
extra_data.gas_used_before = extra_data.gas_used_after;

Ok(gen_inputs)
Expand Down

0 comments on commit aea633c

Please sign in to comment.