Commit Graph

105 Commits

Author SHA1 Message Date
Hao Duan
b35e4fce99
core: avoid modification of accountSet cache in tx_pool (#21159)
* core: avoid modification of accountSet cache in tx_pool

when runReorg, we may copy the dirtyAccounts' accountSet cache to promoteAddrs
in which accounts will be promoted, however, if we have reset request at the
same time, we may reuse promoteAddrs and modify the cache content which is
against the original intention of accountSet cache. So, we need to make a new
slice here to avoid modify accountSet cache.

* core: fix flatten condition + comment

Co-authored-by: Felix Lange <fjl@twurst.com>
2020-08-04 11:51:53 +02:00
Péter Szilágyi
6793ffa12b
Merge pull request #21300 from rjl493456442/txpool-fix-queued-evictions
core: fix queued transaction eviction
2020-07-24 11:14:42 +03:00
rjl493456442
5413df1dfa
core: fix heartbeat in txpool
core: address comment
2020-07-24 11:12:59 +03:00
villanuevawill
c374447401
core: fix queued transaction eviction
Solves issue#20582. Non-executable transactions should not be evicted on each tick if there are no promote transactions or if a pending/reset empties the pending list. Tests and logging expanded to handle these cases in the future.

core/tx_pool: use a ts for each tx in the queue, but only update the heartbeat on promotion or pending replaced

queuedTs proper naming
2020-07-24 11:11:57 +03:00
Martin Holst Swende
6c9f040ebe
core: transaction pool optimizations (#21328)
* core: added local tx pool test case

* core, crypto: various allocation savings regarding tx handling

* core/txlist, txpool: save a reheap operation, avoid some bigint allocs

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2020-07-14 21:42:32 +02:00
Felix Lange
bcb3087450 Revert "core, txpool: less allocations when handling transactions (#21232)"
Reverting because this change started handling account balances as
uint64 in the transaction pool, which is incorrect.

This reverts commit af5c97aebe.
2020-07-09 14:02:03 +02:00
Marius van der Wijden
af5c97aebe
core, txpool: less allocations when handling transactions (#21232)
* core: use uint64 for total tx costs instead of big.Int

* core: added local tx pool test case

* core, crypto: various allocation savings regarding tx handling

* Update core/tx_list.go

* core: added tx.GasPriceIntCmp for comparison without allocation

adds a method to remove unneeded allocation in comparison to tx.gasPrice

* core: handle pools full of locals better

* core/tests: benchmark for tx_list

* core/txlist, txpool: save a reheap operation, avoid some bigint allocs

Co-authored-by: Martin Holst Swende <martin@swende.se>
2020-07-01 19:35:26 +02:00
Marius van der Wijden
ddeea1e0c6
core: types: less allocations when hashing and tx handling (#21265)
* core, crypto: various allocation savings regarding tx handling

* core: reduce allocs for gas price comparison

This change reduces the allocations needed for comparing different transactions to each other.
A call to `tx.GasPrice()` copies the gas price as it has to be safe against modifications and
also needs to be threadsafe. For comparing and ordering different transactions we don't need
these guarantees

* core: added tx.GasPriceIntCmp for comparison without allocation

adds a method to remove unneeded allocation in comparison to tx.gasPrice

* core/types: pool legacykeccak256 objects in rlpHash

rlpHash is by far the most used function in core that allocates a legacyKeccak256 object on each call.
Since it is so widely used it makes sense to add pooling here so we relieve the GC.
On my machine these changes result in > 100 MILLION less allocations and > 30 GB less allocated memory.

* reverted some changes

* reverted some changes

* trie: use crypto.KeccakState instead of replicating code

Co-authored-by: Martin Holst Swende <martin@swende.se>
2020-06-30 11:59:06 +02:00
Hao Duan
8523ad450d core: filter out txs with invalid signatures as soon as possible
Once we detect an invalid transaction during recovering signatures, we should
directly exclude this transaction to avoid validating the signatures hereafter.

This should optimize the validations times of transactions with invalid signatures
to only one time.
2020-06-04 10:37:21 +08:00
chenglin
3f649d4852
core: collect NewTxsEvent items without holding reorg lock (#21145) 2020-06-02 18:52:20 +02:00
Martin Michlmayr
4f2784b38f
all: fix typos in comments (#21118) 2020-05-25 10:21:28 +02:00
gary rong
b9df7ecdc3
all: seperate consensus error and evm internal error (#20830)
* all: seperate consensus error and evm internal error

There are actually two types of error will be returned when
a tranaction/message call is executed: (a) consensus error
(b) evm internal error. The former should be converted to
a consensus issue, e.g. The sender doesn't enough asset to
purchase the gas it specifies. The latter is allowed since
evm itself is a blackbox and internal error is allowed to happen.

This PR emphasizes the difference by introducing a executionResult
structure. The evm error is embedded inside. So if any error
returned, it indicates consensus issue happens.

And also this PR improve the `EstimateGas` API to return the concrete
revert reason if the transaction always fails

* all: polish

* accounts/abi/bind/backends: add tests

* accounts/abi/bind/backends, internal: cleanup error message

* all: address comments

* core: fix lint

* accounts, core, eth, internal: address comments

* accounts, internal: resolve revert reason if possible

* accounts, internal: address comments
2020-04-22 11:25:36 +03:00
Martin Holst Swende
55a73f556a
core: bump txpool tx max size to 128KB 2020-03-30 10:47:09 +02:00
Péter Szilágyi
9938d954c8
eth: rework tx fetcher to use O(1) ops + manage network requests 2020-02-13 15:27:15 +02:00
rjl493456442
049e17116e
core, eth: implement eth/65 transaction fetcher 2020-02-11 13:56:36 +02:00
Martin Holst Swende
b2de0bd87b
core: set max tx size down to 2 slots (64KB) 2020-01-14 11:49:36 +01:00
MichaelRiabzev-StarkWare
8bd37a1d91 core: count tx size in slots, bump max size ot 4x32KB (#20352)
* tests for tx size

* alow multiple slots transactions

* tests for tx size limit (32 KB)

* change tx size tests to use addRemoteSync instead of validateTx (requested in pool request).

* core: minor tx slotting polishes, add slot tracking metric

Co-authored-by: Michael Riabzev <RiabzevMichael@gmail.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2020-01-10 11:40:03 +02:00
Péter Szilágyi
f40ff23b7b
core: fix tx dedup return error count 2019-09-18 11:42:47 +03:00
Péter Szilágyi
056183c056
core: dedup known transactions without global lock, track metrics 2019-09-17 15:55:06 +03:00
Martin Holst Swende
8d41e885e6 core: smaller txpool status locking (#20080)
* txpool: smaller lock portion

* core/tx_pool: fix data race
2019-09-17 10:34:28 +03:00
Péter Szilágyi
72d5a27a39
core, metrics, p2p: switch some invalid counters to gauges 2019-09-10 14:39:07 +03:00
gary rong
c2c4c9f1e5 core, light, params: implement eip2028 (#19931)
* core, light, params: implement eip2028

* core, light: address comments

* core: address comments

* tests: disable Istanbul tx tests (until updated)

* core: address comment
2019-08-14 15:53:21 +03:00
gary rong
b80c840af3 core, les: fix les unit tests (#19823) 2019-07-22 15:45:40 +03:00
gary rong
8f80cafa10 core: fix write concurrency in txpool (#19835)
* core: fix write coucurrency in txpool

* core: add rlock for pendingState read access

* core: address comments
2019-07-17 13:39:41 +03:00
Péter Szilágyi
a966425a1d
core: kill off managed state, use own tiny noncer for txpool 2019-07-09 10:42:09 +03:00
Felix Lange
60c062e17d core: move TxPool reorg and events to background goroutine (#19705)
* core: move TxPool reorg and events to background goroutine

This change moves internal queue re-shuffling work in TxPool to a
background goroutine, TxPool.runReorg. Requests to execute runReorg are
accumulated by the new scheduleReorgLoop. The new loop also accumulates
transaction events.

The motivation for this change is making sends to txFeed synchronous
instead of sending them in one-off goroutines launched by 'add' and
'promoteExecutables'. If a downstream consumer of txFeed is blocked for
a while, reorg requests and events will queue up.

* core: remove homestead check in TxPool

This change removes tracking of the homestead block number from TxPool.
The homestead field was used to enforce minimum gas of 53000 for
contract creations after the homestead fork, but not before it. Since
nobody would want configure a non-homestead chain nowadays and contract
creations usually take more than 53000 gas, the extra correctness is
redundant and can be removed.

* core: fixes for review comments

* core: remove BenchmarkPoolInsert

This is useless now because there is no separate code path for
individual transactions anymore.

* core: fix pending counter metric

* core: fix pool tests

* core: dedup txpool announced events, discard stales

* core: reorg tx promotion/demotion to avoid weird pending gaps
2019-06-21 11:29:14 +03:00
Péter Szilágyi
b02958b9c5
core, ethdb, metrics, p2p: expose various counter metrics for grafana 2019-06-11 09:49:13 +03:00
贺鹏飞
fbe7caf136
core: cache tx signature before obtaining lock 2019-03-29 12:01:29 +02:00
Martin Holst Swende
650ad19c2d
core: make txpool handle reorg due to setHead 2019-03-21 11:42:56 +01:00
Jordan Krage
27ce4eb78b core: sanitize more TxPoolConfig fields (#17210)
* core: sanitize more TxPoolConfig fields

* core: fix TestTransactionPendingMinimumAllowance
2018-12-20 14:00:58 +01:00
mr_franklin
3fd87f2193 core: fix comment typo (#18144) 2018-11-21 12:52:02 +02:00
Wuxiang
81080bf8cb core: fix a typo (#17733) 2018-09-21 13:45:42 +03:00
Wenbiao Zheng
6a33954731 core, eth, trie: use common/prque (#17508) 2018-09-03 17:33:21 +02:00
Péter Szilágyi
e0d0e64ce2
cmd, core, miner: add --txpool.locals and priority mining 2018-08-22 09:43:57 +03:00
Antoine Rondelet
27a278e6e3 core: fixed typo in addresssByHeartbeat (#17243) 2018-07-25 14:25:14 +03:00
Osuke
10780e8a00 core: fix txpool guarantee comment (#17214)
* fixed-typo

* core: fix txpool guarantee comment
2018-07-24 18:44:41 +03:00
Wenbiao Zheng
52b1d09457 core: reduce nesting in transaction pool code (#16980) 2018-06-14 13:46:43 +03:00
John C. Vernaleo
8c4a7fa8d3 core: change comment to match code more closely (#16963) 2018-06-13 10:14:15 +03:00
Péter Szilágyi
01a7e267dc
Merge pull request #16882 from karalabe/streaming-ecrecover
core: concurrent background transaction sender ecrecover
2018-06-05 17:13:43 +03:00
kiel barry
cbfb40b0aa params: fix golint warnings (#16853)
params: fix golint warnings
2018-06-05 12:31:34 +02:00
Péter Szilágyi
2ab24a2a8f
core: concurrent background transaction sender ecrecover 2018-06-05 11:03:55 +03:00
Péter Szilágyi
342ec83d67
core: fix transaction event asynchronicity 2018-05-30 10:14:00 +03:00
Ryan Schneider
55b579e02c core: use a wrapped map to remove contention in TxPool.Get. (#16670)
* core: use a wrapped `map` and `sync.RWMutex` for `TxPool.all` to remove contention in `TxPool.Get`.

* core: Remove redundant `txLookup.Find` and improve comments on txLookup methods.
2018-05-23 15:55:42 +03:00
Péter Szilágyi
49719e21bc
core, eth: minor txpool event cleanups 2018-05-18 12:08:24 +03:00
rjl493456442
a2e43d28d0
all: collate new transaction events together 2018-05-18 11:46:44 +03:00
Crispin Flowerday
0afd767537
core: ensure local transactions aren't discarded as underpriced
This fixes an issue where local transactions are discarded as
underpriced when the pool and queue are full.
2018-05-02 11:04:40 +03:00
thomasmodeneis
ba1030b6b8 build: enable goimports and varcheck linters (#16446) 2018-04-18 00:53:50 +02:00
Péter Szilágyi
db48d312e4
core: txpool stable underprice drop order, perf fixes 2018-04-12 12:54:22 +03:00
Péter Szilágyi
2b5d1a4a4c
core: update txpool tests for the removal fix 2018-03-07 10:58:11 +02:00
cui
f8601430fd
core: should enqueue the invalids tx anyway
even the pending is empty we shoud enqueue the invalid txs
2018-03-07 10:07:50 +02:00