Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trace decoder padding with dummy payloads #63

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Changes from 1 commit
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
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Do you think it's worth adding a error string for these? Might be overkill idk.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the assertions are actually not needed here, as it's solely based on gen_inputs len, meaning the loop wouldn't have been entered before

// 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
Loading