Skip to content

[pallet-revive] only record diff if value changed#8881

Merged
pgherveou merged 2 commits intomasterfrom
pg/fix-tracing
Jun 18, 2025
Merged

[pallet-revive] only record diff if value changed#8881
pgherveou merged 2 commits intomasterfrom
pg/fix-tracing

Conversation

@pgherveou
Copy link
Copy Markdown
Contributor

@pgherveou pgherveou commented Jun 17, 2025

Only record storage change in diff mode if the value differ from the initial one.
Previous implementation would report a diff for example when the old value was written again.

Updated tests in paritytech/evm-test-suite#96

@pgherveou
Copy link
Copy Markdown
Contributor Author

/cmd prdoc --audience runtime_dev --bump patch

@pgherveou pgherveou added the T7-smart_contracts This PR/Issue is related to smart contracts. label Jun 17, 2025
@pgherveou pgherveou enabled auto-merge June 17, 2025 13:03
.storage
.insert(key, new_value.map(|v| v.to_vec().into()));
} else {
self.trace.1.entry(self.current_addr).or_default().storage.remove(&key);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is old_value the storage slot value before this write or before the transaction?

In the former case we should not remove it if there was a write before in this transaction that changed the value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

old_value is the value that will go in the pre of the diff trace, that 's the value before the transaction.
We only set it the first time by using .or_insert_with(|| old_value.map(Into::into)); map API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah okay. Then all good!

@pgherveou pgherveou added this pull request to the merge queue Jun 18, 2025
Merged via the queue into master with commit f10da53 Jun 18, 2025
249 checks passed
@pgherveou pgherveou deleted the pg/fix-tracing branch June 18, 2025 16:10
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
Only record storage change in diff mode if the value differ from the
initial one.
Previous implementation would report a diff for example when the old
value was written again.

Updated tests in paritytech/evm-test-suite#96

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T7-smart_contracts This PR/Issue is related to smart contracts.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants