Commit Graph

13702 Commits

Author SHA1 Message Date
zjubfd
755df16c9a
Merge pull request #1068 from qinglin89/dev-rlp 2022-08-31 13:30:59 +08:00
Leon
64549a75eb
statedb: get rid of activestate, stopPrefetcher manually (#1006) 2022-08-31 13:30:25 +08:00
bittrainee
b485651b86
fix: fix potential goroutine leak (#1067) 2022-08-31 12:38:09 +08:00
dylanhuang
f45759858d
txpool: reheap the priced list if london fork not enabled (#1070) 2022-08-31 12:37:20 +08:00
qinglin89
24da9ec194 fix: gomod add packages 2022-08-26 14:46:17 +08:00
Qian Bin
da57d11ecc rlp trie: faster trie node encoding (#24126)
This change speeds up trie hashing and all other activities that require
RLP encoding of trie nodes by approximately 20%. The speedup is achieved by
avoiding reflection overhead during node encoding.

The interface type trie.node now contains a method 'encode' that works with
rlp.EncoderBuffer. Management of EncoderBuffers is left to calling code.
trie.hasher, which is pooled to avoid allocations, now maintains an
EncoderBuffer. This means memory resources related to trie node encoding
are tied to the hasher pool.

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-08-26 14:46:13 +08:00
Felix Lange
25337f5aba core/types: faster RLP encoding of Header, StateAcccount, Re... (#24420)
This change makes use of the new code generator rlp/rlpgen to improve the
performance of RLP encoding for Header and StateAccount. It also speeds up
encoding of ReceiptForStorage using the new rlp.EncoderBuffer API.

The change is much less transparent than I wanted it to be, because Header and
StateAccount now have an EncodeRLP method defined with pointer receiver. It
used to be possible to encode non-pointer values of these types, but the new
method prevents that and attempting to encode unadressable values (even if
part of another value) will return an error. The error can be surprising and may
pop up in places that previously didn't expect any errors.

To make things work, I also needed to update all code paths (mostly in unit tests)
that lead to encoding of non-pointer values, and pass a pointer instead.

Benchmark results:

    name                             old time/op    new time/op    delta
    EncodeRLP/legacy-header-8           328ns ± 0%     237ns ± 1%   -27.63%  (p=0.000 n=8+8)
    EncodeRLP/london-header-8           353ns ± 0%     247ns ± 1%   -30.06%  (p=0.000 n=8+8)
    EncodeRLP/receipt-for-storage-8     237ns ± 0%     123ns ± 0%   -47.86%  (p=0.000 n=8+7)
    EncodeRLP/receipt-full-8            297ns ± 0%     301ns ± 1%    +1.39%  (p=0.000 n=8+8)

    name                             old speed      new speed      delta
    EncodeRLP/legacy-header-8        1.66GB/s ± 0%  2.29GB/s ± 1%   +38.19%  (p=0.000 n=8+8)
    EncodeRLP/london-header-8        1.55GB/s ± 0%  2.22GB/s ± 1%   +42.99%  (p=0.000 n=8+8)
    EncodeRLP/receipt-for-storage-8  38.0MB/s ± 0%  64.8MB/s ± 0%   +70.48%  (p=0.000 n=8+7)
    EncodeRLP/receipt-full-8          910MB/s ± 0%   897MB/s ± 1%    -1.37%  (p=0.000 n=8+8)

    name                             old alloc/op   new alloc/op   delta
    EncodeRLP/legacy-header-8           0.00B          0.00B           ~     (all equal)
    EncodeRLP/london-header-8           0.00B          0.00B           ~     (all equal)
    EncodeRLP/receipt-for-storage-8     64.0B ± 0%      0.0B       -100.00%  (p=0.000 n=8+8)
    EncodeRLP/receipt-full-8             320B ± 0%      320B ± 0%      ~     (all equal)
2022-08-26 14:44:54 +08:00
Felix Lange
1d6c01ab0b rlp/rlpgen: RLP encoder code generator (#24251)
This change adds a code generator tool for creating EncodeRLP method
implementations. The generated methods will behave identically to the
reflect-based encoder, but run faster because there is no reflection overhead.

Package rlp now provides the EncoderBuffer type for incremental encoding. This
is used by generated code, but the new methods can also be useful for
hand-written encoders.

There is also experimental support for generating DecodeRLP, and some new
methods have been added to the existing Stream type to support this. Creating
decoders with rlpgen is not recommended at this time because the generated
methods create very poor error reporting.

More detail about package rlp changes:

* rlp: externalize struct field processing / validation

This adds a new package, rlp/internal/rlpstruct, in preparation for the
RLP encoder generator.

I think the struct field rules are subtle enough to warrant extracting
this into their own package, even though it means that a bunch of
adapter code is needed for converting to/from rlpstruct.Type.

* rlp: add more decoder methods (for rlpgen)

This adds new methods on rlp.Stream:

- Uint64, Uint32, Uint16, Uint8, BigInt
- ReadBytes for decoding into []byte
- MoreDataInList - useful for optional list elements

* rlp: expose encoder buffer (for rlpgen)

This exposes the internal encoder buffer type for use in EncodeRLP
implementations.

The new EncoderBuffer type is a sort-of 'opaque handle' for a pointer to
encBuffer. It is implemented this way to ensure the global encBuffer pool
is handled correctly.
2022-08-26 14:44:18 +08:00
zjubfd
f2b1f3f128
Merge pull request #1061 from qinglin89/dev-merge
fix: upstream patches
2022-08-23 10:43:14 +08:00
Zhang Zhuo
94885ae9ca core/vm: fix sstore gas comment type (#24583) 2022-08-22 14:43:14 +08:00
rjl493456442
9c72720d9f eth/downloader: ignore zero size header batch for importing (#24569)
* eth/downloader: ignore zero size header batch for importing

* core, light: reject empty header batch for importing
2022-08-22 14:43:14 +08:00
rjl493456442
c1d9690013 les, tests: fix vflux fuzzer by removing unnecessary panic (#24537) 2022-08-22 14:43:14 +08:00
Guifel
3572eb7b20 eth/tracers: use hex encoding for debug_traceBlock argument (#24517) 2022-08-22 14:43:14 +08:00
ligi
f8e2104b52 build: fix linter install on windows (#24523) 2022-08-22 14:43:14 +08:00
rjl493456442
d130c0e423 trie: fix two issues in trie iterator (#24539)
* 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
2022-08-22 14:43:14 +08:00
s7v7nislands
799f041ae1 rpc: fix defer in test (#24490)
Co-authored-by: Felix Lange <fjl@twurst.com>
2022-08-22 14:43:14 +08:00
Martin Holst Swende
0e65495310 eth/protocols/snap: avoid estimating infinite percentage 2022-08-22 14:43:14 +08:00
Zachinquarantine
9843a36bec mobile: remove deprecated Stop function (#24369) 2022-08-22 14:43:14 +08:00
Ceyhun Onur
413a42d9ce core/rawdb: add HasCode, HashTrieNode and use them where possible (#24454) 2022-08-22 14:43:14 +08:00
dylanhuang
2e22fe399c
ci: fix the pattern of commit lint (#1063) 2022-08-22 11:25:31 +08:00
dylanhuang
c3e3b1128d
consensus: fix the GasLimitBoundDivisor (#1060) 2022-08-22 11:24:50 +08:00
dylanhuang
02b31abc5a
test: fix TestOfflineBlockPrune (#1062) 2022-08-22 11:24:18 +08:00
Felföldi Zsolt
e5f4fde8ef les/vflux/client: fix goroutine leak in testIter (#24449) 2022-08-19 07:43:25 +08:00
Guruprasad Kamath
62d66e4656 appveyor.yml: fetch sub-modules recursively (#24451) 2022-08-19 07:41:15 +08:00
Sina Mahmoodi
7bb1463a63 graphql: fix nonce for pending accounts (#24443) 2022-08-19 07:40:41 +08:00
b1ackd0t
c1dd16f4ce internal/ethapi: fix incorrect type on empty slice (#24372)
* Fixes #24368

Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com>

* Update internal/ethapi/api.go

Co-authored-by: Martin Holst Swende <martin@swende.se>
2022-08-19 07:35:43 +08:00
zhiqiangxu
a1db38af74 p2p: reduce the scope of variable dialPubkey (#24385)
dialPubkey isn't used anywhere else after dialDest.Load, so it should be safe to
restrict its scope to the if clause.
2022-08-19 07:33:07 +08:00
Martin Holst Swende
788b77115c core/state: fix read-meters + simplify code (#24304) 2022-08-19 07:31:35 +08:00
setunapo
e64fde1840 ci: allow merge pull request 2022-08-19 06:43:12 +08:00
Roshan
11d2bae157
bep153: Native Staking on BSC (#1051) 2022-08-18 14:36:45 +08:00
setunapo
ddbe6c4f77 ci: no type-case check for scope. 2022-08-17 19:24:48 +08:00
joeycli
dbb047bccc
Merge pull request #1053 from bnb-chain/fix_opendatabase_fail
state: fix offline tool start failed when start with pruneancient
2022-08-17 14:29:11 +08:00
dylanhuang
05d8399cdf
ci: add commit message lint (#1044) 2022-08-16 19:01:24 +08:00
joeycli
895c077f8a fix bug #1034, offline tool start failed when start with pruneancient 2022-08-16 14:02:45 +08:00
Alex Vorona
723863ee56
Dockerfile: update ca-certificates version (#1038) 2022-08-08 18:09:02 +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
kyrie-yl
51bfecacb0 broadcast block before commit block and add metrics (#975)
Signed-off-by: cryyl <yl.on.the.way@gmail.com>
2022-08-01 17:41:50 +08:00
zjubfd
f68965a615
Merge pull request #1025 from bnb-chain/develop
[R4R] Release v1.1.12
v1.1.12
2022-07-28 19:05:28 +08:00
dylanhuang
09dfd2ff7e
prepare for release v1.1.12 (#1023) 2022-07-28 17:25:47 +08:00
zjubfd
6c46c59f27
fix: verify node is not treated as verify node (#1024) 2022-07-28 13:58:33 +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
dylanhuang
dd3b3a69b5
fix: memory leak issue with diff protocol (#1019) 2022-07-26 16:33:59 +08:00
zjubfd
cd46de9e0b
log: disable noisy logs since system transaction will cause gas capping (#1015) 2022-07-25 21:13:49 +08:00
zjubfd
0ed265c5e0
fix: fast node can not recover from force kill or panic (#1014) 2022-07-25 21:12:45 +08:00
joeycli
9d59a140d6
[R4R]fix: tools broken because of writting metadata when open a readyonly db (#1013)
* freezer batch compatible offline prunblock command

adjust pruneblock local var

* not write metadata to db when open db with readyonly
2022-07-25 09:56:17 +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