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: use both indexed and unindexed params when decoding logs #6174

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

Evalir
Copy link
Member

@Evalir Evalir commented Oct 30, 2023

Fixes #6121.

This bug happened because we were only adding labels for unindexed params. We now need to restore the order of the indexed and unindexed params as alloy returns them separately, to be able to assign the labels properly.

@Evalir Evalir requested a review from mattsse October 30, 2023 19:29
crates/evm/traces/src/decoder.rs Outdated Show resolved Hide resolved
Comment on lines +362 to +379
/// Restore the order of the params of a decoded event,
/// as Alloy returns the indexed and unindexed params separately.
fn reconstruct_params(event: &Event, decoded: &DecodedEvent) -> Vec<DynSolValue> {
let mut indexed = 0;
let mut unindexed = 0;
let mut inputs = vec![];
for input in event.inputs.iter() {
if input.indexed {
inputs.push(decoded.indexed[indexed].clone());
indexed += 1;
} else {
inputs.push(decoded.body[unindexed].clone());
unindexed += 1;
}
}

inputs
}
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this should be supported by DecodedEvent perhaps

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep definitely, we should be able to do this through a method rather than manually

Co-authored-by: Matthias Seitz <[email protected]>
@mattsse
Copy link
Member

mattsse commented Oct 30, 2023

error unrelated?

@Evalir
Copy link
Member Author

Evalir commented Oct 30, 2023

Yeah? Seems unrelated, from an external integration test that probably changed

@Evalir Evalir merged commit e03110a into master Oct 30, 2023
15 of 16 checks passed
@Evalir Evalir deleted the evalir/print-event-names branch October 30, 2023 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contract events logs are empty
2 participants