-
Notifications
You must be signed in to change notification settings - Fork 21.6k
core/state: set-based journalling #30660
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
base: master
Are you sure you want to change the base?
Conversation
dcbf781 to
696edfa
Compare
karalabe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random nits for now
6ca0931 to
32cd8a4
Compare
936622f to
e896dac
Compare
|
Lifting this to top level
So, now I have made (actually, still working on it) the api cleaner, journal: StateDB This had quite a large fallout, and also made for some large changes (simplifications) inside the existing linear journal. The result is that after these changes, I am not 100% confident that it won't blow up in some corner-case where the journal is empty / reset, and something calls revert or discard. I intentionally did not check for out of bounds, because I want to locate the source of such flaws. One such source is when the state processor applies a tx: it either becomes finalized, in which case the journal will be reset, since cross-tx reverting is not allowed. However, if it fails, then the caller (outside) needs to revert it. So that's one point where, although the API is symmetric, the call pattern is not. So, my plan now: let the tests run, then put it on benchmarkers for a spin. |
e896dac to
e6f3517
Compare
|
I tried to depoy this on |
|
Deploying now, so
|
|
I was running Gary’s pr
…On Thu, 7 Nov 2024 at 13:31, Martin HS ***@***.***> wrote:
Deploying now, so
- bench05: this PR, but using linear_journal
- bench06: this PR, but using setjournal
—
Reply to this email directly, view it on GitHub
<#30660 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA7UGN6TTGHA7JCOLAD2IDZ7NMRRAVCNFSM6AAAAABQOC4ON6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRSGEYTSMRTGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Has been running fine for ~5 days. Nothing noteworthy with regards to differences in charts on the two machines. |
Yes, the db version is 9, so it's confirmed! |
f5d8372 to
79b00d1
Compare
|
I built a little fuzzer for differential fuzzing the two journals against each other here: https://github.com/MariusVanDerWijden/go-ethereum/tree/journal_on_heapfix_fuzz, its in the first commit, I also added some things on top, so that the fuzzer doesn't panic |
Nice! We could add it to this PR, but please make it so that it's deterministic from the fuzzer input. So don't use |
79b00d1 to
d4072de
Compare
I've done this now |
fa13bd6 to
2dee224
Compare
2dee224 to
e303ae9
Compare
|
Deploying this again now, so
|
e303ae9 to
1960545
Compare
1960545 to
e7ba44b
Compare
|
Rebased on master, which changed with eip-7702 so the journal-api now does not implicitly require the pre-code to be nil. This has not yet been implemented in the set-based journal, but I have added it to the fuzzer, so the failure is detected. It was harder than I thought to detect, because it's a bit sneaky: if a journal sets back the codehash but not the code, then the changes pass fine: because Hence, a broken journal would subtly corrupt the in-memory stateobject. This can be detected by checking the codehash against the code. This is not yet fixed in set-journal, because I want to think a bit on how to best handle that. |
Actually, there may be nothing wrong with this. It should be fine to set the
The latter assumption is interesting. Is there any case where we can undo a setCode, and revert to an older code, and the older code is not stored in the db? |
9d9265e to
69b6195
Compare
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:This PR:
Allocations,
915K->30K,Allocated bytes:
175M->30M