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

core/state: set-based journalling #30660

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Oct 23, 2024

This is a second attempt at #30500 .

This PR introduces set-based journalling, where the journalling-events are basically stored in per-scoped maps.

Whenever we enter a new call scope, we create a new scoped journal. Changes within the same scoped journal overwrite eachother. For example: if a scope updates a balance to from 6 to 5 then 4, then 3, there will only be one preimage in the journal. As opposed to the old journal (linear_journal), which would have multiple entries: [ prev: 6, prev: 5, prev:4].

The linear / appending journal is wasteful on memory, and also slow on rollbacks, since each change is rolled back individually.


@karalabe reminded me of the burntpix benchmark, on which this PR excels, so I thought it was worth another chance.

master:

[user@work go-ethereum]$ ./evm_master run --prestate ./burntpix.json --receiver 0x49206861766520746F6F206D7563682074696D65  --input 0xa4de9ab4000000000000000000000000000000000000000000000000000000000F1FD58E000000000000000000000000000000000000000000000000000000000007A120 --bench | tail -c +131 | sed 's/[0]*$//' | xxd -r -p > output.svg
EVM gas used:    5642735088
execution time:  49.349209526s
allocations:     915684
allocated bytes: 175333368

This PR:

[user@work go-ethereum]$ ./evm_setjournal run --prestate ./burntpix.json --receiver 0x49206861766520746F6F206D7563682074696D65  --input 0xa4de9ab4000000000000000000000000000000000000000000000000000000000F1FD58E000000000000000000000000000000000000000000000000000000000007A120 --bench | tail -c +131 | sed 's/[0]*$//' | xxd -r -p > output.svg
EVM gas used:    5642735088
execution time:  48.740463584s
allocations:     30198
allocated bytes: 30308272

Allocations, 915K -> 30K,
Allocated bytes: 175M -> 30M

core/state: add handling for DiscardSnapshot
core/state: use new journal
core/state, genesis: fix flaw re discard/commit.
	In case the state is committed, the journal is reset, thus it is not correct to Discard/Revert snapshots at that point.
core/state: fix nil defer in merge
core/state: fix bugs in setjournal
core/state: journal api changes
core/state: bugfixes in sparse journal
core/state: journal tests
core/state: improve post-state check in journal-fuzzing test
core/state: post-rebase fixups
miner: remove discard-snapshot call, it's not needed since journal will be reset in Finalize
core/state: fix tests
core/state: lint
core/state: supply origin-value when reverting storage change
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.

1 participant