Skip to content

Commit

Permalink
Fix trace decoder padding with dummy payloads (0xPolygonZero#63)
Browse files Browse the repository at this point in the history
* Fix trace decoder padding with dummy payloads

* Add CHANGELOG entry
  • Loading branch information
Nashtare committed Feb 26, 2024
1 parent c9f9b98 commit 90fa386
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add verification for invalid jumps. [#36](https://github.com/0xPolygonZero/zk_evm/pull/36)
- Refactor accessed lists as sorted linked lists ([#30](https://github.com/0xPolygonZero/zk_evm/pull/30))
- Change visibility of `compact` mod ([#57](https://github.com/0xPolygonZero/zk_evm/pull/57))
- Fix block padding without withdrawals ([#63](https://github.com/0xPolygonZero/zk_evm/pull/63))

## [0.1.0] - 2024-02-21
* Initial release.
15 changes: 11 additions & 4 deletions trace_decoder/src/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ impl ProcessedBlockTrace {
gas_used_after: U256::zero(),
};

// A copy of the initial extra_data possibly needed during padding.
let extra_data_for_dummies = extra_data.clone();

let mut txn_gen_inputs = self
.txn_info
.into_iter()
Expand Down Expand Up @@ -156,6 +159,7 @@ impl ProcessedBlockTrace {
&mut txn_gen_inputs,
&other_data,
&extra_data,
&extra_data_for_dummies,
&initial_tries_for_dummies,
&curr_block_tries,
!self.withdrawals.is_empty(),
Expand Down Expand Up @@ -303,18 +307,20 @@ impl ProcessedBlockTrace {
fn pad_gen_inputs_with_dummy_inputs_if_needed(
gen_inputs: &mut Vec<TxnProofGenIR>,
other_data: &OtherBlockData,
extra_data: &ExtraBlockData,
final_extra_data: &ExtraBlockData,
initial_extra_data: &ExtraBlockData,
initial_tries: &PartialTrieState,
final_tries: &PartialTrieState,
has_withdrawals: bool,
) -> bool {
match gen_inputs.len() {
0 => {
debug_assert!(initial_tries.state == final_tries.state);
debug_assert!(initial_extra_data == final_extra_data);
// We need to pad with two dummy entries.
gen_inputs.extend(create_dummy_txn_pair_for_empty_block(
other_data,
extra_data,
final_extra_data,
initial_tries,
));

Expand All @@ -330,11 +336,12 @@ impl ProcessedBlockTrace {
match has_withdrawals {
false => {
let dummy_txn =
create_dummy_gen_input(other_data, extra_data, initial_tries);
create_dummy_gen_input(other_data, initial_extra_data, initial_tries);
gen_inputs.insert(0, dummy_txn)
}
true => {
let dummy_txn = create_dummy_gen_input(other_data, extra_data, final_tries);
let dummy_txn =
create_dummy_gen_input(other_data, final_extra_data, final_tries);
gen_inputs.push(dummy_txn)
}
};
Expand Down

0 comments on commit 90fa386

Please sign in to comment.