Commit graph

360 commits

Author SHA1 Message Date
devopsbo3
562be5a6f8 Revert "core, trie: track state change set with account address (#27815)"
This reverts commit 426aec583b.
2023-11-10 12:27:53 -06:00
devopsbo3
563c377115 Revert "all: implement path-based state scheme (#25963)"
This reverts commit b7ea2f2445.
2023-11-10 12:27:53 -06:00
devopsbo3
d586a671a3 Revert "all: activate pbss as experimental feature (#26274)"
This reverts commit 1053526246.
2023-11-10 12:27:53 -06:00
devopsbo3
414953c066 Revert "trie/triedb/pathdb: make shutdown journal log friendlier (#27905)"
This reverts commit e7bebb9200.
2023-11-10 12:27:53 -06:00
devopsbo3
b3a35f84e7 Revert "all: update golang/x/ext and fix slice sorting fallout (#27909)"
This reverts commit 1c411fcea2.
2023-11-10 12:27:53 -06:00
devopsbo3
35ca9d3291 Revert "trie: add tests for "short" nodes in StackTrie (#27932)"
This reverts commit 6189a353d7.
2023-11-10 12:27:53 -06:00
devopsbo3
2aa49b926b Revert "trie: reduce allocs in recHash (#27770)"
This reverts commit 06434771a1.
2023-11-10 12:27:53 -06:00
devopsbo3
92666a4189 Revert "core, eth, trie: expose more detailed dirty ram tracking for diff layers (#27971)"
This reverts commit 2aa9c9c87b.
2023-11-10 12:27:53 -06:00
devopsbo3
00c76bbe2b Revert "core, trie: cleanup trie database (#28062)"
This reverts commit ef485b7254.
2023-11-10 12:27:53 -06:00
devopsbo3
acb7eea122 Revert "trie: add getter for preimage store in trie.Database (#28155)"
This reverts commit 9a178056b8.
2023-11-10 12:27:53 -06:00
devopsbo3
c43ff32158 Revert "trie: remove internal nodes between shortNode and child in path mode (#28163)"
This reverts commit f881c71814.
2023-11-10 12:27:53 -06:00
devopsbo3
d110fa3a73 Revert "trie/triedb/pathdb: improve error log (#28177)"
This reverts commit cdfae85ae2.
2023-11-10 12:27:53 -06:00
devopsbo3
0cea8194ff Revert "core, accounts, eth, trie: handle genesis state missing (#28171)"
This reverts commit bcc2e34f7e.
2023-11-10 12:27:53 -06:00
devopsbo3
0a1873ca1b Revert "trie: fix benchmark by ensuring key immutability (#28221)"
This reverts commit ce2182937b.
2023-11-10 12:27:53 -06:00
devopsbo3
5e5610a08a Revert "trie: refactor stacktrie (#28233)"
This reverts commit b5cf9ab566.
2023-11-10 12:27:53 -06:00
devopsbo3
057d5137bd Revert "all: move light.NodeSet to trienode.ProofSet (#28287)"
This reverts commit 6ffa8094b3.
2023-11-10 12:27:53 -06:00
devopsbo3
dd9cfb3354 Revert "trie: fix a typo, use correct docstrings (#28302)"
This reverts commit e5992d458d.
2023-11-10 12:27:53 -06:00
devopsbo3
9eb510dfba Revert "trie: remove owner and binary marshaling from stacktrie (#28291)"
This reverts commit bc238e6ddb.
2023-11-10 12:27:53 -06:00
devopsbo3
a91c62e79a Revert "eth/protocols/snap: fix snap sync failure on empty storage range (#28306)"
This reverts commit 631db5c5ae.
2023-11-10 12:27:53 -06:00
devopsbo3
d60605e9bb Revert "trie: make rhs-proof align with last key in range proofs (#28311)"
This reverts commit 51d0547794.
2023-11-10 12:27:53 -06:00
devopsbo3
b1a0cd4d6f Revert "core, trie, eth: refactor stacktrie constructor (#28350)"
This reverts commit eed2347f95.
2023-11-10 12:27:53 -06:00
devopsbo3
15581049b1 Revert "trie/triedb/pathdb, core/rawdb: enhance error message in freezer (#28198)"
This reverts commit e90266a302.
2023-11-10 12:27:53 -06:00
devopsbo3
26cd4e60f8 Revert "core, eth, trie: filter out boundary nodes and remove dangling nodes in stacktrie (#28327)"
This reverts commit 6fe5774fb2.
2023-11-10 12:27:53 -06:00
devopsbo3
4250c2cb1a Revert "trie: use explicit errors in stacktrie (instead of panic) (#28361)"
This reverts commit 5cbd9502ca.
2023-11-10 12:27:53 -06:00
devopsbo3
0a25fa026e Revert "trie/triedb/pathdb: improve dirty node flushing trigger (#28426)"
This reverts commit e47ad2f169.
2023-11-10 12:27:53 -06:00
rjl493456442
e47ad2f169 trie/triedb/pathdb: improve dirty node flushing trigger (#28426)
* trie/triedb/pathdb: improve dirty node flushing trigger

* trie/triedb/pathdb: add tests

* trie/triedb/pathdb: address comment
2023-11-10 11:09:46 -06:00
Martin Holst Swende
5cbd9502ca trie: use explicit errors in stacktrie (instead of panic) (#28361)
This PR removes panics from stacktrie (mostly), and makes the Update return errors instead. While adding tests for this, I also found that one case of possible corruption was not caught, which is now fixed.
2023-11-10 11:09:46 -06:00
rjl493456442
6fe5774fb2 core, eth, trie: filter out boundary nodes and remove dangling nodes in stacktrie (#28327)
* core, eth, trie: filter out boundary nodes in stacktrie

* eth/protocol/snap: add comments

* Update trie/stacktrie.go

Co-authored-by: Martin Holst Swende <martin@swende.se>

* eth, trie: remove onBoundary callback

* eth/protocols/snap: keep complete boundary nodes

* eth/protocols/snap: skip healing if the storage trie is already complete

* eth, trie: add more metrics

* eth, trie: address comment

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-11-10 11:09:46 -06:00
rjl493456442
e90266a302 trie/triedb/pathdb, core/rawdb: enhance error message in freezer (#28198)
This PR adds more error message for debugging purpose.
2023-11-10 11:09:46 -06:00
rjl493456442
eed2347f95 core, trie, eth: refactor stacktrie constructor (#28350)
This change enhances the stacktrie constructor by introducing an option struct. It also simplifies the `Hash` and `Commit` operations, getting rid of the special handling round root node.
2023-11-10 11:09:46 -06:00
Martin Holst Swende
51d0547794 trie: make rhs-proof align with last key in range proofs (#28311)
During snap-sync, we request ranges of values: either a range of accounts or a range of storage values. For any large trie, e.g. the main account trie or a large storage trie, we cannot fetch everything at once.

Short version; we split it up and request in multiple stages. To do so, we use an origin field, to say "Give me all storage key/values where key > 0x20000000000000000". When the server fulfils this, the server provides the first key after origin, let's say 0x2e030000000000000 -- never providing the exact origin. However, the client-side needs to be able to verify that the 0x2e03.. indeed is the first one after 0x2000.., and therefore the attached proof concerns the origin, not the first key.

So, short-short version: the left-hand side of the proof relates to the origin, and is free-standing from the first leaf.

On the other hand, (pun intended), the right-hand side, there's no such 'gap' between "along what path does the proof walk" and the last provided leaf. The proof must prove the last element (unless there are no elements).

Therefore, we can simplify the semantics for trie.VerifyRangeProof by removing an argument. This doesn't make much difference in practice, but makes it so that we can remove some tests. The reason I am raising this is that the upcoming stacktrie-based verifier does not support such fancy features as standalone right-hand borders.
2023-11-10 11:09:46 -06:00
rjl493456442
631db5c5ae eth/protocols/snap: fix snap sync failure on empty storage range (#28306)
This change addresses an issue in snap sync, specifically when the entire sync process can be halted due to an encountered empty storage range.

Currently, on the snap sync client side, the response to an empty (partial) storage range is discarded as a non-delivery. However, this response can be a valid response, when the particular range requested does not contain any slots.

For instance, consider a large contract where the entire key space is divided into 16 chunks, and there are no available slots in the last chunk [0xf] -> [end]. When the node receives a request for this particular range, the response includes:

    The proof with origin [0xf]
    A nil storage slot set

If we simply discard this response, the finalization of the last range will be skipped, halting the entire sync process indefinitely. The test case TestSyncWithUnevenStorage can reproduce the scenario described above.

In addition, this change also defines the common variables MaxAddress and MaxHash.
2023-11-10 11:09:46 -06:00
Martin Holst Swende
bc238e6ddb trie: remove owner and binary marshaling from stacktrie (#28291)
This change
  - Removes the owner-notion from a stacktrie; the owner is only ever needed for comitting to the database, but the commit-function, the `writeFn` is provided by the caller, so the caller can just set the owner into the `writeFn` instead of having it passed through the stacktrie.
  - Removes the `encoding.BinaryMarshaler`/`encoding.BinaryUnmarshaler` interface from stacktrie. We're not using it, and it is doubtful whether anyone downstream is either.
2023-11-10 11:09:46 -06:00
Brandon Liu
e5992d458d trie: fix a typo, use correct docstrings (#28302)
* fix a typo

* trie: additional fixes to docstrings

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-11-10 11:09:46 -06:00
Martin Holst Swende
6ffa8094b3 all: move light.NodeSet to trienode.ProofSet (#28287)
This is a minor refactor in preparation of changes to range verifier. This PR contains no intentional functional changes but moves (and renames) the light.NodeSet
2023-11-10 11:09:46 -06:00
Martin Holst Swende
b5cf9ab566 trie: refactor stacktrie (#28233)
This change refactors stacktrie to separate the stacktrie itself from the
internal representation of nodes: a stacktrie is not a recursive structure
of stacktries, rather, a framework for representing and operating upon a set of nodes.

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2023-11-10 11:09:46 -06:00
Chirag Garg
ce2182937b trie: fix benchmark by ensuring key immutability (#28221)
This change fixes the bug in a benchmark, where the input to the trie is reused in a way which is not correct. 

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-11-10 11:09:46 -06:00
rjl493456442
bcc2e34f7e core, accounts, eth, trie: handle genesis state missing (#28171)
* core, accounts, eth, trie: handle genesis state missing

* core, eth, trie: polish

* core: manage txpool subscription in mainpool

* eth/backend: fix test

* cmd, eth: fix test

* core/rawdb, trie/triedb/pathdb: address comments

* eth, trie: address comments

* eth: inline the function

* eth: use synced flag

* core/txpool: revert changes in txpool

* core, eth, trie: rename functions
2023-11-10 11:09:46 -06:00
rjl493456442
cdfae85ae2 trie/triedb/pathdb: improve error log (#28177) 2023-11-10 11:09:46 -06:00
rjl493456442
f881c71814 trie: remove internal nodes between shortNode and child in path mode (#28163)
* trie: remove internal nodes between shortNode and child in path mode

* trie: address comments

* core/rawdb, trie: address comments

* core/rawdb: delete unused func

* trie: change comments

* trie: add missing tests

* trie: fix lint
2023-11-10 11:09:46 -06:00
Guillaume Ballet
9a178056b8 trie: add getter for preimage store in trie.Database (#28155) 2023-11-10 11:09:46 -06:00
rjl493456442
ef485b7254 core, trie: cleanup trie database (#28062) 2023-11-10 11:09:46 -06:00
Péter Szilágyi
2aa9c9c87b core, eth, trie: expose more detailed dirty ram tracking for diff layers (#27971) 2023-11-10 11:09:46 -06:00
Marius van der Wijden
06434771a1 trie: reduce allocs in recHash (#27770) 2023-11-10 11:09:46 -06:00
Paweł Bylica
6189a353d7 trie: add tests for "short" nodes in StackTrie (#27932) 2023-11-10 11:09:46 -06:00
Péter Szilágyi
1c411fcea2 all: update golang/x/ext and fix slice sorting fallout (#27909)
The Go authors updated golang/x/ext to change the function signature of the slices sort method. 
It's an entire shitshow now because x/ext is not tagged, so everyone's codebase just 
picked a new version that some other dep depends on, causing our code to fail building.

This PR updates the dep on our code too and does all the refactorings to follow upstream...
2023-11-10 11:09:46 -06:00
Péter Szilágyi
e7bebb9200 trie/triedb/pathdb: make shutdown journal log friendlier (#27905) 2023-11-10 11:09:46 -06:00
rjl493456442
1053526246 all: activate pbss as experimental feature (#26274)
* all: activate pbss

* core/rawdb: fix compilation error

* cma, core, eth, les, trie: address comments

* cmd, core, eth, trie: polish code

* core, cmd, eth: address comments

* cmd, core, eth, les, light, tests: address comment

* cmd/utils: shorten log message

* trie/triedb/pathdb: limit node buffer size to 1gb

* cmd/utils: fix opening non-existing db

* cmd/utils: rename flag name

* cmd, core: group chain history flags and fix tests

* core, eth, trie: fix memory leak in snapshot generation

* cmd, eth, internal: deprecate flags

* all: enable state tests for pathdb, fixes

* cmd, core: polish code

* trie/triedb/pathdb: limit the node buffer size to 256mb

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2023-11-10 11:09:46 -06:00
rjl493456442
b7ea2f2445 all: implement path-based state scheme (#25963)
* all: implement path-based state scheme

* all: edits from review

* core/rawdb, trie/triedb/pathdb: review changes

* core, light, trie, eth, tests: reimplement pbss history

* core, trie/triedb/pathdb: track block number in state history

* trie/triedb/pathdb: add history documentation

* core, trie/triedb/pathdb: address comments from Peter's review

Important changes to list:

- Cache trie nodes by path in clean cache
- Remove root->id mappings when history is truncated

* trie/triedb/pathdb: fallback to disk if unexpect node in clean cache

* core/rawdb: fix tests

* trie/triedb/pathdb: rename metrics, change clean cache key

* trie/triedb: manage the clean cache inside of disk layer

* trie/triedb/pathdb: move journal function

* trie/triedb/path: fix tests

* trie/triedb/pathdb: fix journal

* trie/triedb/pathdb: fix history

* trie/triedb/pathdb: try to fix tests on windows

* core, trie: address comments

* trie/triedb/pathdb: fix test issues

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-11-10 11:09:46 -06:00
rjl493456442
426aec583b core, trie: track state change set with account address (#27815) 2023-11-10 11:09:46 -06:00