Commit Graph

13617 Commits

Author SHA1 Message Date
rjl493456442
da977e9cdc core, ethdb, tests, trie: implement NewBatchWithSize API for batcher (#24392)
This PR adds an addtional API called `NewBatchWithSize` for db
batcher. It turns out that leveldb batch memory allocation is
super inefficient. The main reason is the allocation step of
leveldb Batch is too small when the batch size is large. It can
take a few second to build a leveldb batch with 100MB size.

Luckily, leveldb also offers another API called MakeBatch which can
pre-allocate the memory area. So if the approximate size of batch is
known in advance, this API can be used in this case.

It's needed in new state scheme PR which needs to commit a batch of
trie nodes in a single batch. Implement the feature in a seperate PR.
2022-12-16 17:30:34 +08:00
dylanhuang
cc17abfa17
metrics: add miner info into metrics server (#1212)
* metrics: add unlock address to metrics when miner module is enabled

* metrics: add miner config into metrics server

* metrics: add device-info into metrics server

* metrics: fix the format of device info

* metrics: remove device-info
2022-12-16 07:59:16 +08:00
kyrie-yl
c5b7d747f7
eth, trie: sync with upstream v1.10.26 to solve snap sync issues (#1226)
* eth: fix a rare datarace on CHT challenge reply / shutdown

* trie: check childrens' existence concurrently for snap heal

* eth/protocols/snap: fix problems due to idle-but-busy peers

* eth/filters: change filter block to be by-ref (#26054)

This PR changes the block field in the filter to be a pointer, to disambiguate between empty hash and no hash

* rpc: handle wrong HTTP batch response length (#26064)

* eth/protocols/snap: throttle trie heal requests when peers DoS us (#25666)

* eth/protocols/snap: throttle trie heal requests when peers DoS us

* eth/protocols/snap: lower heal throttle log to debug

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

* eth/protocols/snap: fix comment

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

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Jordan Krage <jmank88@gmail.com>
2022-12-13 17:16:14 +08:00
setunapo
8894b65590
doc: update readme (#1233) 2022-12-07 14:59:37 +08:00
zjubfd
cd0d177f57
Merge pull request #1222 from j75689/fix/build-info
metrics: fix the label format of prometheus server
2022-12-01 17:07:09 +08:00
j75689
ecc12f6493 metrics: fix the label format of prometheus server 2022-12-01 16:54:10 +08:00
nathanhopp
b6b274eba2
metrics fix: edit mutate key to replace - with _ (#1217) 2022-12-01 10:13:50 +08:00
zjubfd
d3873f4ccf
Merge pull request #1210 from guagualvcha/p_1.1.18
release: prepare for v1.1.18 release.
2022-11-29 15:07:01 +08:00
zjubfd
02f7ad74c6 release: prepare for release v1.1.18 2022-11-29 13:39:08 +08:00
dylanhuang
ef16f9efdb
Merge pull request #1209 from j75689/metrics/build-info
metrics: add build info into metrics server
2022-11-29 10:32:21 +08:00
j75689
fe5682c4e0 ci: fix build cmd of arm binary 2022-11-28 22:42:30 +08:00
j75689
d1c9262b12 ci: add git info to cross-compile 2022-11-28 22:42:30 +08:00
j75689
9023e42d0a metrics: add build info into metrics server 2022-11-28 22:42:30 +08:00
j75689
d77ebb8511 metrics: add label type in metrics package 2022-11-28 22:42:30 +08:00
setunapo
807d52e557 worker: some Subscribe NewTxsEvent changes of miner worker
1.remove the unnecessary NewTxsEvent subscriber, which was used for PoW resubmit check.
2.unsubscribe ASAP before another fillTransactions, to avoid block others.
2022-11-28 13:21:14 +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
Larry
d87d697d92
worker: add double sign check for safety. (#1201)
* worker: add double sign check for safety.

And for corner cases, such as reorg after reorg...
use slice to record all broadcast blocks's parents to avoid overwritten.
2022-11-24 15:22:37 +08:00
Roshan
90a414ab7c
Merge pull request #1195 from Pythonberg1997/cross_stake
update Gibbs fork height and system contract code
2022-11-22 16:29:03 +08:00
Roshan
db4cb1df26 upgrade: update Gibbs fork height and system contract code 2022-11-21 19:42:35 +08:00
setunapo
aa986b6d4e worker: return for resubmit signal.
it is not necssary to add more transaction when resubmit is fired.
the resubmit logic was for PoW and can be removed later.
2022-11-21 17:28:23 +08:00
setunapo
21b985c14b worker: always drop on new block imported.
When new block is imported, there is no need to commit the current
work, even the new imported block is offturn and itself is inturn.

That is because when offturn block is received, the inturn block is
already later to broadcast block, deliver the later block will cause
many reorg, which is not reasonable.

And also make sure all useless work can be discarded, to avoid goroutine leak.
2022-11-21 17:28:23 +08:00
setunapo
c33f696811 worker: do not fillTransactions immediately on new transaction.
It may not efficient if schedule fillTransactions when new transactions arrive.
It could make the CPU keep running.
To make is more efficient:
  1.schedule fillTransactions when a certain amount of transaction are arrived.
  2.or there is not much time left.
2022-11-21 17:28:23 +08:00
setunapo
de5dd95ada worker: enhancement of the current block generation logic.
Currently, validator only try once to get transactions from TxPool to produce the block.
However, new transactions could arrive while the validator is committing transaction.
Validator should be allowed to add these new arrived transactions as long as
Header.Timestamp is not reached

This commit will:
** commitTransactions return with error code
** drop current mining block on new block imported
** try fillTransactions several times for the best
   not use append mode to follow the GasPrice rule.
** check if there is enough time for another fillTransactions.
2022-11-21 17:28:23 +08:00
zjubfd
276b69ee8b
Merge pull request #1192 from kyrie-yl/upstream_v1.10.22
all: sync with upstream v1.10.22
2022-11-20 15:20:09 +08:00
Henry
fb2e68b79a common/compiler: json unmarshalling error checks (#25449)
complier/solidity:add json.Unmarshal err check
2022-11-18 11:32:36 +08:00
ycyraum
48b6db9f63 core/genesis: remove calaverasAllocData (#25516)
core/genesis: calaverasAllocData no longer used
2022-11-18 11:16:03 +08:00
rjl493456442
466e9a2a3d trie: improve node rlp decoding performance (#25357)
This avoids copying the input []byte while decoding trie nodes. In most
cases, particularly when the input slice is provided by the underlying
database, this optimization is safe to use.

For cases where the origin of the input slice is unclear, the copying version
is retained. The new code performs better even when the input must be
copied, because it is now only copied once in decodeNode.
2022-11-18 11:16:03 +08:00
Justin Traglia
b8c2d2e8f8 eth, les: unlock downloader peerSet if there's an error (#25546)
Unlock peerSet if there's an error in the downloader
2022-11-18 11:16:03 +08:00
Leon
dbc70ee1e2
core/forkid: refactor nextForkHash (#1177) 2022-11-17 12:12:12 +08:00
setunapo
139eb3f467 worker: fix a bug of the delay timer.
`fillTransactions` will call `commitTransactions` twice, if the delay
timer is expired during the first call, it will make the delay timer
never be triggered in the second commitTransactions call.
Pseudo code:
    x := time.NewTimer(time.Second)
    <-x.C
    fmt.Println("read delay 1")
    <-x.C
    fmt.Println("read delay 2")  // will never hit
2022-11-17 11:42:03 +08:00
setunapo
0789afe6e7 worker: remove pre-seal empty block
pre-seal empty block is for PoW to deliver an empty block ASAP to
gain the block mine reward.

It is useless for PoS consensus and it does not work for BSC either.

Delete the code to make worker simpler.
2022-11-16 17:57:44 +08:00
setunapo
086a99b407 worker: no need to add more transaction if not mining
It could be a very old PoW logic, which try to add more transaction
into the pending block when mining is stopped.
Mining can be stopped when:
  1.download started.
  2.manually stopped by RPC.
It is unnecessary to add more transaction into the pending block if a validator is stopped.
And updateSnapshot() is not needed as well, it is to get the pending mining snapshot.
2022-11-16 10:47:58 +08:00
setunapo
fe1c8622f6 parlia: Delay() with DelayLeftOver
Right now, DelayLeftOver is used to reserve time for block finalize, not block
broadcast. And the code does not work as expected.

The general block generation could be described as:
|- fillTransactions -|- finalize a block -|- wait until the period(3s) reached -|- broadcast -|
2022-11-16 10:47:58 +08:00
setunapo
d1ed977d89 worker: change interrupt type from *int to chan
channel operation is preferred than atomic value check in golang.
And it will help for the further refactor on worker.
2022-11-15 13:26:11 +08:00
setunapo
b4dcff5772 worker: remove the code of resubmit interval adjust
resubmit intervalAdjust is for PoW only, to remove it to make worker simpler.

With PoW, there will be a periodic timer to check if it is the time to stop
packing transaction and start calculating the desired hash value, since other miner
could succeed in hash compute if it spends too much time packing transactions.
It will commit the current fruit to calculate root at a reasonable time.
And it will schedule a new work to get a big block if new transaction was received.

When there are too many transactions in the TxPool, the interval of the resubmit timer would be
increased and vice versa.

But it is not needed with PoS related consensus, since the block interval is determined in PoS,
and there is already a timer to stop too long packing.
2022-11-15 13:26:11 +08:00
Guillaume Ballet
bf1dbd9233 accounts/abi: substitude arg%d to the range keyword (#25307)
* accounts/abi: substitude arg%d to the range keyword

* support more keywords

* review feedback
2022-11-15 11:54:31 +08:00
Brion
d07a706aff rpc: add graceful shutdown timeout for HTTP server (#25258)
This change ensures the HTTP server will always terminate within
at most 5s, even when all connections are busy and do not become
idle.

Co-authored-by: Felix Lange <fjl@twurst.com>
2022-11-15 11:54:31 +08:00
Seungbae.yu
0f96641ae4 core, eth: pre-allocate map in storage copy (#25279) 2022-11-15 11:54:31 +08:00
lightclient
e91c40ddef internal/ethapi: error if tx args includes chain id that doesn't match local (#25157)
* internal/ethapi: error if tx args includes chain id that doesn't match local

* internal/ethapi: simplify code a bit

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2022-11-15 11:54:31 +08:00
henridf
c2c22c5947 core: remove lock in BlockChain.ExportN (#25254)
* Remove locking in (*BlockChain).ExportN

Since ExportN is read-only, it shouldn't need the lock. (?)

* Add hash check to detect reorgs during export.

* fix check order

* Update blockchain.go

* Update blockchain.go

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2022-11-15 11:54:31 +08:00
Leon
01b78d4789
miner: disable enforceTip when get txs from txpool (#1166) 2022-11-07 10:42:05 +08:00
Leon
8b7b87c232
release: update version and changelogs (#1161) 2022-11-02 16:47:14 +08:00
zjubfd
4e2f5c6263 merge with master branch 2022-10-31 15:12:21 +08:00
Kai
72f6acc49f
ci: specify bind-tools version (#1126) 2022-10-31 15:04:13 +08:00
zjubfd
678c133dec
Merge pull request #1114 from LysanderGG/LysanderGG-patch-1
typo: .github fix job name
2022-10-31 15:03:41 +08:00
zjubfd
6b83c41123
Merge pull request #1146 from qinglin89/develop-upstream20
all: sync with upstream
2022-10-31 14:05:09 +08:00
Leon
bed1a57766
core:remove redundant func (#1159) 2022-10-31 14:03:45 +08:00
Jolly Zhao
c46671df97 parlia: the newChainHead mights not be imported to Pralia.Snapshot ASAP 2022-10-28 11:42:06 +08:00
Håvard Anda Estensen
caf9d0a5e6 p2p: use errors.Is for error comparison (#24882)
Co-authored-by: Felix Lange <fjl@twurst.com>
2022-10-28 09:04:57 +08:00
lwh
c93b905633 accounts/abi/bind: fix duplicate field names in the generated go struct (#24924)
* accounts/abi/bind: fix duplicate field names in the generated go struct #24627

* accounts, cmd/abigen: resolve name conflicts

* ci lint, accounts/abi: remove unused function overloadedArgName

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2022-10-28 09:04:37 +08:00