Commit graph

246 commits

Author SHA1 Message Date
Daniel Liu
58c066f053
all: handle err from func rlp.Encode, close XFN-127 (#1692) 2025-11-03 12:45:19 +05:30
Daniel Liu
22edaacf0d
trie: update comments + err check for preimages #25672 (#1117)
This PR includes minor updates to comments in trie/committer that reference insertion to the db, and adds an err != nil check for the return value of preimages.commit.

Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
2025-10-24 16:57:19 +08:00
Daniel Liu
3f0f3af776
trie: check childrens' existence concurrently for snap heal #25694 (#1573)
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2025-10-08 12:24:04 +08:00
Daniel Liu
271687e463
core, trie: remove DiskDB function from trie database #25690 (#1116) 2025-10-08 12:21:56 +08:00
Daniel Liu
0bd353373e
trie: fix unhandled error in test #25628 (#1115)
Co-authored-by: Amir Hossein <77993374+Kamandlou@users.noreply.github.com>
2025-10-08 12:20:53 +08:00
Daniel Liu
1c7e92b56e
trie: better error reporting #25645 (#1114)
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-10-08 12:18:14 +08:00
Daniel Liu
2563cd13ed
trie: cleanup stateTrie #25640 (#1113)
It's a trivial PR to hide the error log when the trie node is not found in the database. The idea for this change is for all TryXXX functions, the error is already returned and we don't need to fire a log explicitly.

Recently there are a few tickets #25613 #25589 reporting that the trie nodes are missing because of debug.SetHead. The root cause is after resetting, the chain rewinds to a historical point and re-imports the blocks on top.

Since the node is already synced and started to accept transactions previously, these transactions are still kept in the txpool and verified by txpool with a live state. This live state is constructed based on the live trie database, which is changed fast by node referencing and de-referencing.

Unfortunately, when we construct a live state(like the state in txpool), we don't reference the state we have. The blockchain will garbage collect the intermediate version nodes in another thread which leads the broken live state.

The best solution for this is to forcibly obtain a reference for all live states we create and call release function once it's used up. But it might end up with more junks persisted into disk. Will try to find an elegant solution later in the following PR.

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-09-24 07:45:06 +08:00
Daniel Liu
862f18ec58
core/state, trie: fix trie flush order for proper pruning #25581 (#1112)
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2025-09-24 07:44:22 +08:00
wit liu
1a2c8ee180
all: fix govet (#1517)
Co-authored-by: wit <wit765765346@gmail>
2025-09-21 18:55:13 +08:00
Daniel Liu
0b13b19b55
trie: fix some typos #25551 #25648 (#1111) 2025-09-21 18:51:15 +08:00
Daniel Liu
637e732aff
trie: improve node rlp-decoding #25357 (#1109) 2025-09-17 08:42:42 +08:00
Daniel Liu
80159e5854
core/state, trie: add DeleteAccount method #25531 (#1108) 2025-09-13 09:29:51 +08:00
Daniel Liu
4e234f231a
core, trie: flush preimages to db on database close #25533 (#1107) 2025-09-09 17:32:22 +08:00
Daniel Liu
aca2149f12
core, eth, trie: use TryGetAccount to read what TryUpdateAccount has written #25458 (#1106)
* core: use TryGetAccount to read where TryUpdateAccount has been used to write

* Gary's review feedback

* implement Gary's suggestion

* fix bug + rename NewSecure into NewStateTrie

* trie: add backwards-compatibility aliases for SecureTrie

* Update database.go

* make the linter happy

Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-09-03 15:34:11 +08:00
Daniel Liu
6c5c8c13de
core, trie: rework trie committer #25320 (#1103)
* all: rework trie and trie committer

* all: get rid of internal cache in trie

* all: fixes

* trie: polish

* core, trie: address comments

* trie: fix imports

* core/state: address comments

* core/state/snapshot: polish

* trie: remove unused code

* trie: update tests

* trie: don't set db as nil

* trie: address comments

* trie: unskip test

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-08-31 15:58:48 +08:00
Daniel Liu
3fed9ebeb8
core, eth, trie: rework preimage store #25287 (#1099)
* core, trie, eth, cmd: rework preimage store

* trie: address comment

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-08-29 05:22:44 +08:00
Daniel Liu
0b7b02b8e0
trie: lint whitespace #25312 (#1098) 2025-08-28 18:49:37 +08:00
Daniel Liu
67106daaa8
trie: fix gosimple lint issue #25309 (#1097)
Co-authored-by: Felix Lange <fjl@twurst.com>
2025-08-26 15:44:53 +08:00
Daniel Liu
18d2dbad89
core, trie: port snap sync changes #24898 (#1096)
core, eth, les, trie: rework snap sync

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-08-26 15:20:39 +08:00
Daniel Liu
3d69b27ae4
trie: more linters #24783 (#1092) 2025-08-26 15:19:07 +08:00
Daniel Liu
793293f041
trie: move locking into trieDB insert method #25030 (#1091)
Move locking into trieDB insert function

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>
2025-08-22 16:38:30 +08:00
Daniel Liu
d52bfaa5ca
all: introduce trie owner notion #24750 (#1090)
* cmd, core/state, light, trie, eth: add trie owner notion

* all: refactor

* tests: fix goimports

* core/state/snapshot: fix ineffasigns

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-08-22 16:37:39 +08:00
Daniel Liu
ee81b721fc
core, trie: implement trie tracer #24403 (#1088)
Trie tracer is an auxiliary tool to capture all deleted nodes
which can't be captured by trie.Committer. The deleted nodes
can be removed from the disk later.

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-08-21 13:38:56 +08:00
Daniel Liu
a8b841c0a0
trie: implement NodeBlob API for trie iterator #24391 (#1084)
This functionality is needed in new path-based storage scheme, but
can be implemented in a seperate PR though.

When an account is deleted, then all the storage slots should be
nuked out from the disk as well. In hash-based storage scheme they
are still left in the disk but in new scheme, they will be iterated
and marked as deleted.

But why the NodeBlob API is needed in this scenario? Because when
the node is marked deleted, the previous value is also required to
be recorded to construct the reverse diff.

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-08-20 16:28:58 +08:00
Daniel Liu
9cad0a0cc0
all: create global hasher pool #31769 (#1233)
This PR creates a global hasher pool that can be used by all packages.
It also removes a bunch of the package local pools.

It also updates a few locations to use available hashers or the global
hashing pool to reduce allocations all over the codebase.
This change should reduce global allocation count by ~1%

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2025-08-20 15:11:09 +08:00
Daniel Liu
13fe871c25
trie: test for edgecase in VerifyRangeProof #24257 (#1083) 2025-08-20 15:04:35 +08:00
Daniel Liu
b196b7231c
trie: fix range prover #24266 (#1082)
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-08-20 14:54:24 +08:00
Daniel Liu
5702df86ee
trie: readonly interface for trie iterator resolver #24221 (#1081) 2025-08-20 14:52:56 +08:00
Daniel Liu
a75fa97f56
core, trie: use db.has over db.get where possible #24117 (#1078) 2025-08-20 14:51:32 +08:00
Daniel Liu
8750881da2
trie: remove the sync bloom, used by fast sync #24047 (#1077) 2025-08-08 09:31:26 +08:00
Daniel Liu
f0ee1211cc
trie: reject deletions when verifying range proofs #23960 (#1076)
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2025-08-08 09:23:50 +08:00
Daniel Liu
3da4549e07
core/state: move state account to core/types + abstracted write account to trie #23567 (#1072) 2025-08-08 09:13:34 +08:00
Daniel Liu
7464f0a7f3
trie: better error-handling #23657 (#1073) 2025-08-04 14:38:48 +08:00
Daniel Liu
655f975bbb
trie: simplify range proofs #22762 (#1067) 2025-08-04 14:36:02 +08:00
Daniel Liu
cb888541c5
core, trie: add state metrics #23433 (#1071) 2025-08-04 11:19:42 +08:00
Daniel Liu
77522e51ec
core, trie: decode the value for storage dump #19943 (#1189)
* core, trie: decode the value for storage dump

* core/state: address comment

Co-authored-by: gary rong <garyrong0905@gmail.com>
2025-07-28 16:52:06 +08:00
Daniel Liu
cf5766177a
trie: remove the duplicate write for preimage #23001 (#1068) 2025-07-28 16:50:39 +08:00
Daniel Liu
f552cebfcd
trie: remove redundant returns + use stacktrie where applicable #22760 (#1066)
* trie: add benchmark for proofless range

* trie: remove unused returns + use stacktrie

Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-07-28 16:49:31 +08:00
Daniel Liu
a9d4fffc97
trie: move fuzzers into native packages #28467 (#1239) 2025-07-17 17:55:19 +08:00
Daniel Liu
8f90413200
trie: fix range prover #22210 (#1061)
Fixes a special case when the trie only has a single trie node and the range proof only contains a single element.

Co-authored-by: gary rong <garyrong0905@gmail.com>
2025-07-11 09:20:18 +08:00
Daniel Liu
8ba50ab2aa
trie: remove deprecated uses of math.rand (#1136) 2025-06-25 16:57:23 +08:00
Daniel Liu
416c5cb7dd
trie: upgarde for snap protocol #21482 (#1058) 2025-06-25 16:55:07 +08:00
Daniel Liu
dbe173e794
core, trie: speed up some tests with quadratic processing flaw #21987 (#1057) 2025-06-25 16:17:05 +08:00
Daniel Liu
937b3d75e0
core, eth, trie: prepare trie sync for path based operation #21504 (#1046) 2025-06-21 08:30:25 +08:00
Daniel Liu
ea459d68a3
trie: fix spelling mistakes (#1122) 2025-06-20 16:29:57 +08:00
Daniel Liu
3a6beedb8c
trie: fix parallel typo in trie/hasher.go #25241 (#1095) 2025-06-17 13:32:04 +08:00
Daniel Liu
6200e8d7de
core, trie: change format 0x%x to %#x #25221 (#1094) 2025-06-17 13:31:20 +08:00
Daniel Liu
dabaf392a7
trie: fix size accounting in cleaner #25007 (#1093)
Decrease children size instead of dirties size when marking dirties as cleaned up in trie cleaner

Co-authored-by: aaronbuchwald <aaron.buchwald56@gmail.com>
2025-06-17 13:29:57 +08:00
Daniel Liu
e4de0e82a2
trie: remove unused makeHashNode #24702 (#1089)
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
2025-06-17 13:28:59 +08:00
Daniel Liu
205a94ea4f
trie: fix two issues in trie iterator #24539 (#1086)
* trie: fix memory leak in trie iterator

In the trie iterator, live nodes are tracked in a stack while iterating.
Popped node states should be explictly set to nil in order to get
garbage-collected.

* trie: fix empty trie iterator
2025-06-17 13:27:57 +08:00