Commit graph

41 commits

Author SHA1 Message Date
Daniel Liu
677f923125
refactor(all): track state changes in state db #27349 (#1947) 2026-02-24 10:27:31 +05:30
Daniel Liu
a51eaa7200
fix(core, trie): revert error removal in (*state.Trie).Commit #27544 (#1168)
* trie, core/state: revert error removal in (*state.Trie).Commit

* Gary's nitpick :)



---------

Co-authored-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2026-02-05 11:43:33 +05:30
Daniel Liu
9cf795c908
perf: improve state reader with error handling and committed flag #27428 (#1166)
- Add error returns to Database.Reader() and NodeIterator() methods
- Introduce committed flag to prevent usage of tries after commit
- Update callers to handle new error signatures
- Add MustNodeIterator() helper for backward compatibility

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2026-02-03 20:55:53 +05:30
Daniel Liu
e40208f3db
trie: new empty trie with types.EmptyRootHash instead of null #27230 (#1160) 2026-01-26 18:04:14 +05:30
Daniel Liu
3d194d4303
all: port boring changes from pbss #27176 (#1158)
* all: port boring changes from pbss

* core, trie: address comments from martin

* trie: minor fixes

* core/rawdb: update comment

* core, eth, tests, trie: address comments

* tests, trie: add extra check when update trie database

* trie/triedb/hashdb: degrade the error to warning

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2026-01-26 11:21:46 +05:30
Daniel Liu
583338686f
all: expose block number information to statedb #27753 (#1936) 2026-01-16 15:55:04 +05:30
Daniel Liu
6d4670a4ec
core, trie: refactor trie API #26995 (#1147)
In this PR, all TryXXX(e.g. TryGet) APIs of trie are renamed to XXX(e.g. Get) with an error returned.

The original XXX(e.g. Get) APIs are renamed to MustXXX(e.g. MustGet) and does not return any error -- they print a log output. A future PR will change the behaviour to panic on errorrs.

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2026-01-16 15:51:13 +05:30
Daniel Liu
47501c8834
core/state, trie: remove unused error-return from trie Commit operation #26641 (#1135)
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-12-08 15:05:11 +05:30
Daniel Liu
8be96e4622
trie: use slices package for sorting #27496 (#1703) 2025-12-07 15:43:53 +05:30
Daniel Liu
940fd2adbd
core, trie: port changes from pbss #26637 (#1127) 2025-12-07 15:38:38 +05:30
Daniel Liu
07328dcec4
core, eth, trie: abstract node scheme #25532 (#1123)
This PR introduces a node scheme abstraction. The interface is only implemented by `hashScheme` at the moment, but will be extended by `pathScheme` very soon.

Apart from that, a few changes are also included which is worth mentioning:

-  port the changes in the stacktrie, tracking the path prefix of nodes during commit
-  use ethdb.Database for constructing trie.Database. This is not necessary right now, but it is required for path-based used to open reverse diff freezer

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2025-11-17 11:25:08 +05:30
Daniel Liu
28a4f25166
cmd, core, eth, trie: track deleted nodes #22225 #25757 (#1120)
Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
2025-11-12 13:32:22 +05:30
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
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
cb888541c5
core, trie: add state metrics #23433 (#1071) 2025-08-04 11:19:42 +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
Daniel Liu
f07824db20
core, ethdb, tests, trie: implement NewBatchWithSize API for batcher #24392 (#1085) 2025-06-17 13:26:50 +08:00
Daniel Liu
7fbf862806
trie: improve the node iterator seek operation #22470 (#1064) 2025-06-03 12:18:46 +08:00
Daniel Liu
5328a637c0 trie: use unified emptyRootHash and emptyCodeHash (#26718) 2025-04-07 16:44:32 +08:00
Daniel Liu
ebb2c3b2ea all: new empty trie with types.EmptyRootHash instead of null (#27230) 2025-02-07 13:04:45 +08:00
olumuyiwadad
b5abbfed79 new EVM Upgrade
- Solidity Upgraded up to v0.8.0
-  Fixed and Added eth_chainId
- Fix error in TransactionRecipet
- Reward halving issue fixed
2021-09-21 16:53:46 +05:30
olumuyiwadad
571c41f891 FIx Bad block error. 2021-09-17 17:59:06 +05:30
Péter Szilágyi
434dd5bc00
cmd, core, eth, light, trie: add trie read caching layer 2018-11-15 12:22:13 +02:00
gary rong
7beccb29be all: get rid of error when creating memory database (#16716)
* all: get rid of error when create mdb

* core: clean up variables definition

* all: inline mdb definition
2018-05-09 15:24:25 +03:00
Péter Szilágyi
55599ee95d core, trie: intermediate mempool between trie and database (#15857)
This commit reduces database I/O by not writing every state trie to disk.
2018-02-05 17:40:32 +01:00
Felix Lange
693d9ccbfb trie: more node iterator improvements (#14615)
* ethdb: remove Set

Set deadlocks immediately and isn't part of the Database interface.

* trie: add Err to Iterator

This is useful for testing because the underlying NodeIterator doesn't
need to be kept in a separate variable just to get the error.

* trie: add LeafKey to iterator, panic when not at leaf

LeafKey is useful for callers that can't interpret Path.

* trie: retry failed seek/peek in iterator Next

Instead of failing iteration irrecoverably, make it so Next retries the
pending seek or peek every time.

Smaller changes in this commit make this easier to test:

* The iterator previously returned from Next on encountering a hash
  node. This caused it to visit the same path twice.
* Path returned nibbles with terminator symbol for valueNode attached
  to fullNode, but removed it for valueNode attached to shortNode. Now
  the terminator is always present. This makes Path unique to each node
  and simplifies Leaf.

* trie: add Path to MissingNodeError

The light client trie iterator needs to know the path of the node that's
missing so it can retrieve a proof for it. NodeIterator.Path is not
sufficient because it is updated when the node is resolved and actually
visited by the iterator.

Also remove unused fields. They were added a long time ago before we
knew which fields would be needed for the light client.
2017-06-20 18:26:09 +02:00
Felix Lange
4047ccad2f trie: add start key to NodeIterator constructors
The 'step' method is split into two parts, 'peek' and 'push'. peek
returns the next state but doesn't make it current.

The end of iteration was previously tracked by setting 'trie' to nil.
End of iteration is now tracked using the 'iteratorEnd' error, which is
slightly cleaner and requires less code.
2017-04-25 02:14:31 +02:00
Felix Lange
a13e920af0 trie: clean up iterator constructors
Make it so each iterator has exactly one public constructor:

- NodeIterators can be created through a method.
- Iterators can be created through NewIterator on any NodeIterator.
2017-04-25 02:14:31 +02:00
Nick Johnson
b35aa21f9f trie: implement unionIterator (#14312) 2017-04-13 11:14:19 +02:00
Nick Johnson
555273495b trie: add difference iterator (#3637)
This PR implements a differenceIterator, which allows iterating over trie nodes
that exist in one trie but not in another. This is a prerequisite for most GC
strategies, in order to find obsolete nodes.
2017-02-22 23:49:34 +01:00
Felix Lange
35a7dcb162 all: gofmt -w -s 2017-01-06 15:52:03 +01:00
Felix Lange
cd791bd855 core, trie: replace state caches with trie journal 2016-09-28 11:27:28 +03:00
Péter Szilágyi
5a057a8ded core/state, trie: surface iterator entry hashes 2016-02-16 12:21:08 +02:00
Felix Lange
565d9f2306 core, trie: new trie 2015-09-22 22:53:49 +02:00
Felix Lange
bfbcfbe4a9 all: fix license headers one more time
I forgot to update one instance of "go-ethereum" in commit 3f047be5a.
2015-07-23 18:35:11 +02:00
Felix Lange
3f047be5aa all: update license headers to distiguish GPL/LGPL
All code outside of cmd/ is licensed as LGPL. The headers
now reflect this by calling the whole work "the go-ethereum library".
2015-07-22 18:51:45 +02:00
Felix Lange
ea54283b30 all: update license information 2015-07-07 14:12:44 +02:00
obscuren
db4aaedcbd Moved ptrie => trie. Removed old trie 2015-01-08 11:47:04 +01:00
Renamed from ptrie/iterator_test.go (Browse further)