Skip to content

Commit

Permalink
fix: special case empty txn_info
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaatif committed Sep 4, 2024
1 parent ece25d3 commit 13304bb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
39 changes: 28 additions & 11 deletions trace_decoder/src/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,32 @@ pub fn entrypoint(
*amt = eth_to_gwei(*amt)
}

let batches = middle(
state,
storage,
batch(txn_info, batch_size),
&mut code,
b_meta.block_timestamp,
b_meta.parent_beacon_block_root,
withdrawals,
)?;
// TODO(0xaatif): I hate this
let batches = match txn_info.is_empty() {
true => {
let mut batches = middle(
state,
storage,
vec![vec![TxnInfo::default()]],
&mut code,
b_meta.block_timestamp,
b_meta.parent_beacon_block_root,
withdrawals,
)?;
assert_eq!(batches.len(), 1);
batches.push(batches[0].clone());
batches
}
false => middle(
state,
storage,
batch(txn_info, batch_size),
&mut code,
b_meta.block_timestamp,
b_meta.parent_beacon_block_root,
withdrawals,
)?,
};

let mut running_gas_used = 0;
Ok(batches
Expand Down Expand Up @@ -231,7 +248,7 @@ fn test_batch() {
do_test(3, 3, [1, 2]); // big hint
}

#[derive(Debug)]
#[derive(Debug, Clone)]
struct Batch<StateTrieT> {
pub first_txn_ix: usize,
pub gas_used: u64,
Expand All @@ -249,7 +266,7 @@ struct Batch<StateTrieT> {

/// [`evm_arithmetization::generation::TrieInputs`],
/// generic over state trie representation.
#[derive(Debug)]
#[derive(Debug, Clone)]
struct IntraBlockTries<StateTrieT> {
pub state: StateTrieT,
pub storage: BTreeMap<H256, StorageTrie>,
Expand Down
1 change: 0 additions & 1 deletion trace_decoder/tests/ab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ fn pad1() {
}

#[test]
#[should_panic] // TODO(0xaatif): fix
fn pad2() {
do_test([(BEACON, acct())], [], [(BEACON, hpt())], [], [], obd());
}
Expand Down

0 comments on commit 13304bb

Please sign in to comment.