Commit Graph

330 Commits

Author SHA1 Message Date
NathanBSC
486e019880
core/statedb: always clear out access list when setting a new one (#1702)
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2023-06-15 17:09:27 +08:00
Matus Kysel
994daa1447
statedb: add function to get state trie root 2023-04-14 15:23:07 +02:00
realuncle
f7d15e34df
BEP-126: Introduce Fast Finality Mechanism (#936) 2023-04-10 18:36:45 +08:00
Nicolas Gotchac
221ef7d80d
UT: fix some flaky tests (#1379)
* core/state: Remove prefetcher on stop
* core/blockchain: Wait for `triedb.Dereference` in `writeBlockWithState`
* eth/protocols/diff: Fix index mismatch in `TestGetDiffLayers`
2023-04-03 22:11:09 +08:00
dylanhuang
bf68be2bd9
dep: bump the version of several important library (#1274)
* dep: upgrade secp256k1 to use btcec/v2 v2.3.2 and update insecurity pkg

* build ci: upgrade go to 1.19 and golangci-lint to 1.50.1

* docs: fix format that does not follow the goimports

* dep: redirect github.com/bnb-chain/tendermint to v0.31.13

* ci: disable GOPROXY
2023-02-02 19:36:37 +08:00
setunapo
58644491ad worker: reused triePrefetch when multi-fillTransactions to mine a block.
avoid too much trie prefetch routines when several fillTransactions are called.
2022-11-28 13:21:14 +08:00
Seungbae.yu
0f96641ae4 core, eth: pre-allocate map in storage copy (#25279) 2022-11-15 11:54:31 +08:00
aaronbuchwald
8c90dc946a core/rawdb: simplify TestDiskSeek to use memorydb (#25182) 2022-10-21 14:23:12 +08:00
Marius van der Wijden
e8b93382da core/state/snapshot: fix race condition (#24685)
Fixes three race conditions found through fuzzing by David Theodore
2022-09-21 17:02:02 +08:00
Péter Szilágyi
f310921b41 core/state/snapshot: remove noop map item assignment 2022-09-21 17:02:02 +08:00
Leon
64549a75eb
statedb: get rid of activestate, stopPrefetcher manually (#1006) 2022-08-31 13:30:25 +08:00
Ceyhun Onur
413a42d9ce core/rawdb: add HasCode, HashTrieNode and use them where possible (#24454) 2022-08-22 14:43:14 +08:00
Martin Holst Swende
788b77115c core/state: fix read-meters + simplify code (#24304) 2022-08-19 07:31:35 +08:00
joeycli
895c077f8a fix bug #1034, offline tool start failed when start with pruneancient 2022-08-16 14:02:45 +08:00
Leon
76e3c9071a [R4R] Pipecommit enable trie prefetcher (#992) 2022-08-01 17:41:50 +08:00
setunapo
77c8372cc4 Trie prefetch on state pretch (#996)
* feature: do trie prefetch on state prefetch

Currently, state prefetch just pre execute the transactions and discard the results.
It is helpful to increase the snapshot cache hit rate.
It would be more helpful, if it can do trie prefetch at the same time, since the it will
preload the trie node and build the trie tree in advance.
This patch is to implement it, by reusing the main trie prefetch and doing finalize after
transaction is executed.

* some code improvements for trie prefetch

** increase pendingSize before dispatch tasks
** use throwaway StateDB for TriePrefetchInAdvance and remove the prefetcherLock
** remove the necessary drain operation in trie prefetch mainloop,
   trie prefetcher won't be used after close.
2022-08-01 17:41:50 +08:00
setunapo
df3e1be9d3 [Feature]: Improve trie prefetch (#952)
* trie prefetcher for From/To address in advance

We found that trie prefetch could be not fast enough, especially trie prefetch of
the outer big state trie tree.
Instead of do trie prefetch until a transaction is finalized, we could do trie prefetch
in advance. Try to prefetch the trie node of the From/To accounts, since their root hash
are most likely to be changed.

* Parallel TriePrefetch for large trie update.

Currently, we create a subfetch for each account address to do trie prefetch. If the address
has very large state change, trie prefetch could be not fast enough, e.g. a contract modified
lots of KV pair or a large number of account's root hash is changed in a block.

With this commit, there will be children subfetcher created to do trie prefetch in parallell if
the parent subfetch's workload exceed the threshold.

* some improvemnts of parallel trie prefetch implementation

1.childrenLock is removed, since it is not necessary
  APIs of triePrefetcher is not thread safe, they should be used sequentially.
  A prefetch will be interrupted by trie() or clos(), so we only need mark it as
  interrupted and check before call scheduleParallel to avoid the concurrent access to paraChildren
2.rename subfetcher.children to subfetcher.paraChildren
3.use subfetcher.pendingSize to replace totalSize & processedIndex
4.randomly select the start child to avoid always feed the first one
5.increase threshold and capacity to avoid create too many child routine

* fix review comments

** nil check refine
** create a separate routine for From/To prefetch, avoid blocking the cirtical path

* remove the interrupt member

* not create a signer for each transaction

* some changes to triePrefetcher

** remove the abortLoop, move the subfetcher abort operation into mainLoop
   since we want to make subfetcher's create & schedule & abort within a loop to
   avoid concurrent access locks.

** no wait subfetcher's term signal in abort()
   it could speed up the close by closing subfetcher concurrently.
   we send stop signnal to all subfetchers in burst and wait their term signal later.

* some coding improve for subfetcher.scheduleParallel

* fix a UT crash of s.prefetcher == nil

* update parallel trie prefetcher configuration

tested with different combination of parallelTriePrefetchThreshold & parallelTriePrefetchCapacity,
found the most efficient configure could be:
  parallelTriePrefetchThreshold = 10
  parallelTriePrefetchCapacity  = 20

* fix review comments: code refine
2022-08-01 17:41:50 +08:00
dylanhuang
06bc2a0681
fix: remove diffhash patch introduced fro (#1020) 2022-07-27 13:58:49 +08:00
Leon
a2a90d3212
Fix pipecommit about activeState (#1002)
* get copy of prefetcher before use to avoid been modified between access and not-nil condition
2022-07-27 01:24:28 +08:00
Leon
71f0caa6cf
Remove duplicate update/delete on tire (#1001)
* rm duplicate update/delete on tire
* rm useless code
2022-07-27 01:23:19 +08:00
joeycli
d93211b310
[R4R]db: freezer batch compatible offline prunblock command (#1005)
[R4R]db: freezer batch compatible offline prunblock command (#1005)
2022-07-22 16:11:34 +08:00
dylanhuang
403b19c629
[R4R] fix: Incorrect merkle root issue when enabling pipecommit with miner (#1011)
[R4R] fix: Incorrect merkle root issue when enabling pipecommit with miner (#1011)
2022-07-22 15:58:06 +08:00
setunapo
8e74562179
[R4R]: Redesign triePrefetcher to make it thread safe (#972)
* Redesign triePrefetcher to make it thread safe

There are 2 types of triePrefetcher instances:
1.New created triePrefetcher: it is key to do trie prefetch to speed up validation phase.
2.Copied triePrefetcher: it only copy the prefetched trie information, actually it won't do
  prefetch at all, the copied tries are all kept in p.fetches.

Here we try to improve the new created one, to make it concurrent safe, while the copied one's
behavior stay unchanged(its logic is very simple).
As commented in triePrefetcher struct, its APIs are not thread safe. So callers should make sure
the created triePrefetcher should be used within a single routine.
As we are trying to improve triePrefetcher, we would use it concurrently, so it is necessary to
redesign it for concurrent access.

The design is simple:
** start a mainLoop to do all the work, APIs just send channel message.

Others:
** remove the metrics copy, since it is useless for copied triePrefetcher
** for trie(), only get subfetcher through channel to reduce the workload of mainloop

* some code enhancement for triePrefetcher redesign

* some fixup: rename, temporary trie chan for concurrent safe.

* fix review comments

* add some protection in case the trie prefetcher is already stopped

* fix review comments

** make close concurrent safe
** fix potential deadlock

* replace channel by RWMutex for a few triePrefetcher APIs

For APIs like: trie(), copy(), used(), it is simpler and more efficient to
use a RWMutex instead of channel communicaton.
Since the mainLoop would be busy handling trie request, while these trie request
can be processed in parallism.

We would only keep prefetch and close within the mainLoop, since they could update
the fetchers

* add lock for subfecter.used access to make it concurrent safe

* no need to create channel for copied triePrefetcher

* fix trie_prefetcher_test.go

trie prefetcher’s behavior has changed, prefetch() won't create subfetcher immediately.
it is reasonable, but break the UT, to fix the failed UT
2022-07-07 10:00:09 +08:00
j75689
79bd42836c fix: code compatibility fixes 2022-07-05 11:14:21 +08:00
zjubfd
a50a05d624 merge with go-ethereum 1.1.5 2022-02-10 18:48:16 +08:00
Martin Holst Swende
51eb5f8ca8
cmd/geth: add db cmd to show metadata (#23900)
* cmd/geth: add db cmd to show metadata

* cmd/geth: better output generator status

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>

* cmd: minor

Co-authored-by: Sina Mahmoodi <1591639+s1na@users.noreply.github.com>
Co-authored-by: Sina Mahmoodi <itz.s1na@gmail.com>
2022-01-18 12:30:41 +02:00
Péter Szilágyi
58d1988349
core, eth, les, trie: remove the sync bloom, used by fast sync 2021-12-03 12:32:41 +02:00
Taeik Lim
85064ed09b
all: fix 'the the' in comments (#24036) 2021-12-02 15:42:09 +01:00
Martin Holst Swende
9055cc14ec
core/vm, core/state/snapshot: remove unused code (#23956)
* core/state/snapshot: remove wiper functionality

* core/vm: remove unused 'unofficial' opcodes
2021-11-25 10:37:47 +02:00
Martin Holst Swende
526c3f6b9e
core/state/snapshot: fix benchmarks (#23804) 2021-10-26 11:01:01 +02:00
Ziyuan Zhong
312e02bca9
core/state/snapshot: fix BAD BLOCK error when snapshot is generating (#23635)
* core/state/snapshot: fix BAD BLOCK error when snapshot is generating

* core/state/snapshot: alternative fix for the snapshot generator

* add comments and minor update

Co-authored-by: Martin Holst Swende <martin@swende.se>
2021-10-20 10:05:27 +02:00
rjl493456442
f915f6873f
core/state/snapshot: fix data race in layer flattening (#23628)
* core/state/snapshot: fix data race in layer flattening

* core/state/snapshot: fix typo
2021-10-15 10:52:40 +03:00
hsyodyssey
84bccd0900
core/state: fix typos in comments (#23702) 2021-10-10 15:00:00 +02:00
hsyodyssey
12f971fb2d
core/state: fix typo in comment (#23665) 2021-10-04 12:16:50 +02:00
Guillaume Ballet
443afc975c
core/state: move state account to core/types + abstracted "write account to trie" (#23567)
* core/state: abstracted "write account to trie" method

* fix appveyor build

* Apply suggestions from code review

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

* review feedback

* core/state/accounts: move Account to core/types

* core/types: rename Account -> StateAccount

* core/state: restore EncodeRLP for stateObject

* core/types: add the missing file

* more review feedback

* more review feedback

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
2021-09-28 10:48:07 +02:00
Ikko Ashimine
31be5d41d9
core: fix typo in iterator.go (#23502)
strorage -> storage
2021-08-31 10:21:42 +02:00
gary rong
a5a5237178
core, light, tests, trie: add state metrics (#23433) 2021-08-24 22:00:42 +03:00
Péter Szilágyi
9d6480c3cd
core/state/snapshot: gofmt 2021-08-10 16:58:38 +03:00
Tyler Chambers
66948316f7
core/state/snapshot: clarify comment about snapshot repair (#23305)
Co-authored-by: Tyler Chambers <me@tylerchambers.net>
Co-authored-by: Felix Lange <fjl@twurst.com>
2021-08-10 11:16:53 +02:00
Ziyuan Zhong
57d9e0ac75
core/state/snapshot: fix typo in comment (#23219) 2021-08-10 11:04:29 +02:00
Péter Szilágyi
3b38a83274
core/state/pruner: fix state bloom sync permission in Windows 2021-08-10 10:40:10 +03:00
Marius van der Wijden
28ba686cbf
core/state: add trie prefetcher tests (#23216)
* core/state: add trie prefetcher tests

* core/state: add missing license
2021-08-03 17:35:25 +02:00
aaronbuchwald
82c5085399
cre/state: fix outdated statedb Prepare comment (#23320) 2021-08-03 09:06:58 +03:00
Marius van der Wijden
8fe47b0a0d
core/state: avoid unnecessary alloc in trie prefetcher (#23198) 2021-07-12 21:34:20 +02:00
Marius van der Wijden
686b2884ee
all: removed blockhash from statedb (#23126)
This PR removes the blockhash from the statedb
2021-06-30 15:17:01 +02:00
Li Dongwei
bca8c03e57
core/state: remove unused methods ReturnGas, GetStorageProofByHash (#23092)
Co-authored-by: lidongwei <lidongwei@huobi.com>
2021-06-25 14:34:09 +02:00
Guillaume Ballet
2cde472650
core/state: fix typos in test error message (#22962) 2021-05-31 12:43:18 +02:00
gary rong
c73652da0b
core/state/snapshot: fix flaky tests (#22944)
* core/state/snapshot: fix flaky tests

* core/state/snapshot: fix tests
2021-05-26 10:58:09 +03:00
Martin Holst Swende
addd8824cf
cmd/geth, eth, core: snapshot dump + unify with trie dump (#22795)
* cmd/geth, eth, core: snapshot dump + unify with trie dump

* cmd/evm: dump API fixes

* cmd/geth, core, eth: fix some remaining errors

* cmd/evm: dump - add limit, support address startkey, address review concerns

* cmd, core/state, eth: minor polishes, fix snap dump crash, unify format

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2021-05-12 11:05:39 +03:00
fudongbai
3ab97c2a83 disable log of snap update 2021-05-10 17:10:11 +08:00