Commit Graph

131 Commits

Author SHA1 Message Date
Seungbae Yu
ada603fab5
core: don't cache zero nonce in txNoncer (#25603)
This changes the nonce cache used by TxPool to not store cached
nonces for non-existing accounts.
2022-09-16 18:23:13 +02:00
Seungbae Yu
3a4cef5402
core: preallocate maps in TxPool helper methods (#25737) 2022-09-12 15:02:41 +02:00
aaronbuchwald
68420e1aa5
core: fix typo in txpool (#25149)
Fix typo in txPool truncateQueue comment
2022-06-22 22:51:45 +02:00
Martin Holst Swende
a907d7e81a
all: more linters (#24783)
This enables the following linters

- typecheck
- unused
- staticcheck
- bidichk
- durationcheck
- exportloopref
- gosec

WIth a few exceptions.

- We use a deprecated protobuf in trezor. I didn't want to mess with that, since I cannot meaningfully test any changes there.
- The deprecated TypeMux is used in a few places still, so the warning for it is silenced for now.
- Using string type in context.WithValue is apparently wrong, one should use a custom type, to prevent collisions between different places in the hierarchy of callers. That should be fixed at some point, but may require some attention.
- The warnings for using weak random generator are squashed, since we use a lot of random without need for cryptographic guarantees.
2022-06-13 16:24:45 +02:00
zhaochonghe
2bfd9a28d1
core: fix the order of address in queue (#24907)
reverse the order of address in queue
2022-05-19 15:25:22 +08:00
xwjack
8bbf83e7a4
core: ignore basefee when comparing with pool gasprice in txpool (#24080)
This reverts commit 9489853321.
2021-12-17 15:44:57 +01:00
Felix Lange
9489853321
core: check effective tip in txpool pricelimit validation (#23855)
The price limit is supposed to exclude transactions with too low fee
amount. Before EIP-1559, it was sufficient to check the limit against
the gas price of the transaction. After 1559, it is more complicated
because the concept of 'transaction gas price' does not really exist.

When mining, the price limit is used to exclude transactions below a
certain effective fee amount. This change makes it apply the same check
earlier, in tx validation. Transactions below the specified fee amount
cannot enter the pool.

Fixes #23837
2021-11-08 16:25:35 +02:00
Martin Holst Swende
03bc8b7858
core: more efficient nonce-update in txpool (#22231)
* Adjust pending nonce update operation

Benchmark the speed of transaction insertion under multiple accounts

core: fix rebase issues + docstring

core: make benchmark test use sync:ed method

* core: address review comments

* core: add memreport to benchmark

Co-authored-by: WeiLoy <wei_loy@163.com>
2021-11-02 18:32:23 +01:00
jwasinger
011fe3eb5e
core: remove unused error from TxPool.Pending (#23720) 2021-10-13 23:00:45 +02:00
Marius van der Wijden
067084feda
core: fix race conditions in txpool (#23474)
* core: fix race conditions in txpool

* core: fixed races in the txpool

* core: rebased on master

* core: move reheap mutex

* core: renamed mutex

* core: revert Reheap changes
2021-08-31 10:33:39 +02:00
Martin Holst Swende
d705f5a554
core: make txpool reject too sudden changes (#23095)
* core: make txpool reject too sudden changes

* core: add some metrics to txpool
2021-08-24 21:48:36 +03:00
baptiste-b-pegasys
3526f69047
all: remove term "whitelist" in comments and log messages (#23294) 2021-07-29 17:36:15 +02:00
Mark
c49e065fea
internal: get pending and queued transaction by address (#22992)
* core, eth, internal, les, light: get pending and queued transaction by address

* core: tiny nitpick fixes

* light: tiny nitpick

Co-authored-by: mark <mark@amis.com>
Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2021-07-13 13:40:58 +03:00
Péter Szilágyi
aa69d36152
core, graphql, internal: expose effectiveGasPrice in receipts 2021-06-16 09:52:06 +03:00
Péter Szilágyi
c503f98f6d
all: rename internal 1559 gas fields, add support for graphql (#23010)
* all: rename internal 1559 gas fields, add support for graphql

* cmd/evm/testdata, core: use public 1559 gas names on API surfaces
2021-06-08 12:05:41 +02:00
Péter Szilágyi
7e915ee379
core, eth, miner: enforce configured mining reward post 1559 too 2021-06-04 10:18:37 +03:00
Felföldi Zsolt
2d716c4b01
core: add new eip-1559 tx constraints (#22970)
This PR adds the new consensus constraints of EIP-1559 transactions as specified in https://github.com/ethereum/EIPs#3594
2021-05-30 19:37:52 +02:00
Felföldi Zsolt
966ee3ae6d
all: EIP-1559 tx pool support (#22898)
This pull request implements EIP-1559 compatible transaction pool with dual heap eviction ordering.
It is based on #22791
The eviction ordering scheme and the reasoning behind it is described here: https://gist.github.com/zsfelfoldi/9607ad248707a925b701f49787904fd6
2021-05-28 10:28:07 +02:00
Fire Man
93407b14a6
core: make txpool free space calculation more accurate (#22933) 2021-05-24 14:34:38 +02:00
Derek Chiang
eaccdba4ab
core: fix method comment for txpool.requestReset (#22543) 2021-03-22 09:10:51 +02:00
Péter Szilágyi
0928562670
all: define Berlin hard fork spec 2021-02-26 14:24:07 +02:00
lightclient
bbfb1e4008
all: add support for EIP-2718, EIP-2930 transactions (#21502)
This adds support for EIP-2718 typed transactions as well as EIP-2930
access list transactions (tx type 1). These EIPs are scheduled for the
Berlin fork.

There very few changes to existing APIs in core/types, and several new APIs
to deal with access list transactions. In particular, there are two new
constructor functions for transactions: types.NewTx and types.SignNewTx.
Since the canonical encoding of typed transactions is not RLP-compatible,
Transaction now has new methods for encoding and decoding: MarshalBinary
and UnmarshalBinary.

The existing EIP-155 signer does not support the new transaction types.
All code dealing with transaction signatures should be updated to use the
newer EIP-2930 signer. To make this easier for future updates, we have
added new constructor functions for types.Signer: types.LatestSigner and
types.LatestSignerForChainID. 

This change also adds support for the YoloV3 testnet.

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: Ryan Schneider <ryanleeschneider@gmail.com>
2021-02-25 15:26:57 +01:00
Marius van der Wijden
3512b41c5c
core: reset txpool state on sethead (#22247)
fixes an issue where local transactions that were included in the chain before a SetHead were rejected if resubmitted, since the txpool had not reset the state to the current (older) state.
2021-02-03 11:02:35 +01:00
gary rong
88c696240d
core/txpool: remove "local" notion from the txpool price heap (#21478)
* core: separate the local notion from the pricedHeap

* core: add benchmarks

* core: improve tests

* core: address comments

* core: degrade the panic to error message

* core: fix typo

* core: address comments

* core: address comment

* core: use PEAK instead of POP

* core: address comments
2020-12-11 10:44:57 +01:00
Martin Holst Swende
706f5e3b98
core: fix txpool off-by-one error (#21683) 2020-10-09 12:23:46 +03:00
Marius van der Wijden
0bdd295cc0
core: more detailed metering for reorgs (#21420) 2020-08-20 09:49:35 +02:00
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