Commit Graph

12621 Commits

Author SHA1 Message Date
Marius van der Wijden
0703ef62d3
crypto/secp256k1: fix undefined behavior in BitCurve.Add (#22621)
This commit changes the behavior of BitCurve.Add to be more inline
with btcd. It fixes two different bugs:

1) When adding a point at infinity to another point, the other point
   should be returned. While this is undefined behavior, it is better
   to be more inline with the go standard library.
   Thus (0,0) + (a, b) = (a,b)

2) Adding the same point to itself produced the point at infinity.
   This is incorrect, now doubleJacobian is used to correctly calculate it.
   Thus (a,b) + (a,b) == 2* (a,b) and not (0,0) anymore.

The change also adds a differential fuzzer for Add, testing it against btcd.

Co-authored-by: Felix Lange <fjl@twurst.com>
2021-05-27 13:30:25 +02:00
rene
d836ad141e
cmd/devp2p/internal/ethtest: add block hash announcement test (#22535) 2021-05-27 11:57:49 +02:00
Felix Lange
7194c847b6
p2p/rlpx: reduce allocation and syscalls (#22899)
This change significantly improves the performance of RLPx message reads
and writes. In the previous implementation, reading and writing of
message frames performed multiple reads and writes on the underlying
network connection, and allocated a new []byte buffer for every read.

In the new implementation, reads and writes re-use buffers, and perform
much fewer system calls on the underlying connection. This doubles the
theoretically achievable throughput on a single connection, as shown by
the benchmark result:

    name             old speed      new speed       delta
    Throughput-8     70.3MB/s ± 0%  155.4MB/s ± 0%  +121.11%  (p=0.000 n=9+8)

The change also removes support for the legacy, pre-EIP-8 handshake encoding.
As of May 2021, no actively maintained client sends this format.
2021-05-27 10:19:13 +02:00
Martin Holst Swende
2e7714f864
cmd/utils: avoid large alloc in --dev mode (#22949)
* cmd/utils: avoid 1Gb alloc in --dev mode

* cmd/geth: avoid 512Mb alloc in genesis query tests
2021-05-27 10:13:35 +02:00
Mike Burr
5869789d75
ethstats: fix typo in comment (#22952)
Trivial but helpful to understanding.
2021-05-26 22:33:00 +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
aaronbuchwald
05dab7f6bd
internal/ethapi: remove unused vm.Config parameter of DoCall (#22942) 2021-05-26 08:39:41 +02:00
meowsbits
10962b685e
ethstats: fix URL parser for '@' or ':' in node name/password (#21640)
Fixes the case (example below) where the value passed
to --ethstats flag would be parsed wrongly because the
node name and/or password value contained the special
characters '@' or ':'

    --ethstats "ETC Labs Metrics @meowsbits":mypass@ws://mordor.dash.fault.dev:3000
2021-05-25 23:22:46 +02:00
rene
49bde05a55
cmd/devp2p: refactor eth test suite (#22843)
This PR refactors the eth test suite to make it more readable and
easier to use. Some notable differences:

- A new file helpers.go stores all of the methods used between
  both eth66 and eth65 and below tests, as well as methods shared
  among many test functions.
- suite.go now contains all of the test functions for both eth65
  tests and eth66 tests.
- The utesting.T object doesn't get passed through to other helper methods,
  but is instead only used within the scope of the test function,
  whereas helper methods return errors, so only the test function
  itself can fatal out in the case of an error.
- The full test suite now only takes 13.5 seconds to run.
2021-05-25 23:09:11 +02:00
Eugene Lepeico
6c7d6cf886
tests: get test name from testing.T (#22941)
There were 2 TODOs about that fix after Golang 1.8 release.
It's here for 3 years already, so now should be the right time.
2021-05-25 22:47:14 +02:00
meowsbits
750115ff39
p2p/nat: skip TestUPNP in non-CI environments if discover fails (#22877)
Fixes #21476
2021-05-25 22:37:30 +02:00
gary rong
51b32cc7e4
internal/ethapi: merge CallArgs and SendTxArgs (#22718)
There are two transaction parameter structures defined in
the codebase, although for different purposes. But most of
the parameters are shared. So it's nice to reduce the code
duplication by merging them together.

Co-authored-by: Martin Holst Swende <martin@swende.se>
2021-05-25 22:30:21 +02:00
Felix Lange
836c647bdd
eth: unregister peer only when handler exits (#22908)
This removes the error log message that says 

    Ethereum peer removal failed ... err="peer not registered"

The error happened because removePeer was called multiple
times: once to disconnect the peer, and another time when the
handler exited. With this change, removePeer now has the sole
purpose of disconnecting the peer. Unregistering happens exactly
once, when the handler exits.
2021-05-25 22:20:36 +02:00
Felix Lange
4d33de9b49
rlp: optimize big.Int decoding for size <= 32 bytes (#22927)
This change grows the static integer buffer in Stream to 32 bytes,
making it possible to decode 256bit integers without allocating a
temporary buffer.

In the recent commit 088da24, Stream struct size decreased from 120
bytes down to 88 bytes. This commit grows the struct to 112 bytes again,
but the size change will not degrade performance because Stream
instances are internally cached in sync.Pool.

    name             old time/op    new time/op    delta
    DecodeBigInts-8    12.2µs ± 0%     8.6µs ± 4%  -29.58%  (p=0.000 n=9+10)

    name             old speed      new speed      delta
    DecodeBigInts-8   230MB/s ± 0%   326MB/s ± 4%  +42.04%  (p=0.000 n=9+10)
2021-05-25 21:56:25 +02:00
ucwong
017cf71fbd
rlp, tests/fuzzers/bls12381: gofmt (#22937) 2021-05-25 10:14:39 +02:00
Fire Man
93407b14a6
core: make txpool free space calculation more accurate (#22933) 2021-05-24 14:34:38 +02:00
Felix Lange
154ca32a8a
rlp: optimize byte array handling (#22924)
This change improves the performance of encoding/decoding [N]byte.

    name                     old time/op    new time/op    delta
    DecodeByteArrayStruct-8     336ns ± 0%     246ns ± 0%  -26.98%  (p=0.000 n=9+10)
    EncodeByteArrayStruct-8     225ns ± 1%     148ns ± 1%  -34.12%  (p=0.000 n=10+10)

    name                     old alloc/op   new alloc/op   delta
    DecodeByteArrayStruct-8      120B ± 0%       48B ± 0%  -60.00%  (p=0.000 n=10+10)
    EncodeByteArrayStruct-8     0.00B          0.00B          ~     (all equal)
2021-05-22 15:10:16 +02:00
Felix Lange
0d076d92db
rlp: use atomic.Value for type cache (#22902)
All encoding/decoding operations read the type cache to find the
writer/decoder function responsible for a type. When analyzing CPU
profiles of geth during sync, I found that the use of sync.RWMutex in
cache lookups appears in the profiles. It seems we are running into
CPU cache contention problems when package rlp is heavily used
on all CPU cores during sync.

This change makes it use atomic.Value + a writer lock instead of
sync.RWMutex. In the common case where the typeinfo entry is present in
the cache, we simply fetch the map and lookup the type.
2021-05-22 13:34:29 +02:00
gary rong
59f259b058
miner/stress: update stress tests (#22919)
This PR updates the miner stress tests and moves them to standalone
packages, so that they can be run directly.
2021-05-21 20:52:51 +02:00
Péter Szilágyi
6bc72783f6
Merge pull request #22921 from karalabe/les-simplify-reqids
les: generate random nums directly, not via strange conversions
2021-05-21 12:51:56 +03:00
Péter Szilágyi
835fe06f1d
les: generate random nums directly, not via strange conversions 2021-05-21 12:36:04 +03:00
Evolution404
81662fe827
core/rawdb: handle prefix in table.compact method (#22911) 2021-05-21 10:33:59 +02:00
Martin Holst Swende
a6c462781f
EIP-1559: miner changes (#22896)
* core/types, miner: create TxWithMinerFee wrapper, add EIP-1559 support to TransactionsByMinerFeeAndNonce

miner: set base fee when creating a new header, handle gas limit, log miner fees

* all: rename to NewTransactionsByPriceAndNonce

* core/types, miner: rename to NewTransactionsByPriceAndNonce + EffectiveTip

miner: activate 1559 for testGenerateBlockAndImport tests

* core,miner: revert naming to TransactionsByPriceAndTime

* core/types/transaction: update effective tip calculation logic

* miner: update aleut to london

* core/types/transaction_test: use correct signer for 1559 txs + add back sender check

* miner/worker: calculate gas target from gas limit

* core, miner: fix block  gas limits for 1559

Co-authored-by: Ansgar Dietrichs <adietrichs@gmail.com>
Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com>
2021-05-21 09:59:26 +02:00
Felix Lange
16bc57438b
p2p/dnsdisc: fix crash when iterator closed before first call to Next (#22906) 2021-05-20 09:24:41 +02:00
Péter Szilágyi
3e795881ea
eth, p2p/msgrate: move peer QoS tracking to its own package and use it for snap (#22876)
This change extracts the peer QoS tracking logic from eth/downloader, moving
it into the new package p2p/msgrate. The job of msgrate.Tracker is determining
suitable timeout values and request sizes per peer.

The snap sync scheduler now uses msgrate.Tracker instead of the hard-coded 15s
timeout. This should make the sync work better on network links with high latency.
2021-05-19 14:09:03 +02:00
lightclient
b3a1fda650
cmd/utils: expand tilde in --jspath (#22900) 2021-05-18 19:54:10 +02:00
Felix Lange
088da24ebf
rlp: improve decoder stream implementation (#22858)
This commit makes various cleanup changes to rlp.Stream.

* rlp: shrink Stream struct

This removes a lot of unused padding space in Stream by reordering the
fields. The size of Stream changes from 120 bytes to 88 bytes. Stream
instances are internally cached and reused using sync.Pool, so this does
not improve performance.

* rlp: simplify list stack

The list stack kept track of the size of the current list context as
well as the current offset into it. The size had to be stored in the
stack in order to subtract it from the remaining bytes of any enclosing
list in ListEnd. It seems that this can be implemented in a simpler
way: just subtract the size from the enclosing list context in List instead.
2021-05-18 12:10:27 +02:00
Felix Lange
3e6f46caec
p2p/discover/v4wire: use optional RLP field for EIP-868 seq (#22842)
This changes the definitions of Ping and Pong, adding an optional field
for the sequence number. This field was previously encoded/decoded using
the "tail" struct tag, but using "optional" is much nicer.
2021-05-18 11:48:41 +02:00
Shane Bammel
32c1ed8a9c
core/forkid: fix off-by-one bug (#22879)
* forkid: added failing test

* forkid: fixed off-by-one bug
2021-05-18 11:37:18 +03:00
Evolution404
b7a91663ab
core/asm: fix the bug of "00" prefix number (#22883) 2021-05-18 10:22:58 +02:00
Martin Holst Swende
bb9f9ccf4f
core/rawdb: wait for background freezing to exit when closing freezer (#22878) 2021-05-18 01:30:01 +02:00
Martin Holst Swende
67e7f61af7
core: fix failing tests (#22888)
This PR fixes two errors that regressed when EIP-1559 was merged.
2021-05-18 01:10:28 +02:00
Martin Holst Swende
94451c2788
all: implement EIP-1559 (#22837)
This is the initial implementation of EIP-1559 in packages core/types and core.
Mining, RPC, etc. will be added in subsequent commits.

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
Co-authored-by: lightclient@protonmail.com <lightclient@protonmail.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
2021-05-17 15:13:22 +02:00
Martin Holst Swende
14bc6e5130
consensus/ethash: change eip3554 from 9.5M to 9.7M (#22870) 2021-05-17 10:49:23 +02:00
lightclient
597ecb39cc
cmd/evm: return json error if unmarshalling from stdin fails (#22871)
* cmd/evm: return json error if unmarshalling from stdin fails

* cmd/evm: make error capitalizations uniform (all lowercase starts)

* cmd/evm: capitalize error sent directly to stderror
2021-05-17 08:52:32 +02: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
Péter Szilágyi
1cca781a02
Merge pull request #22840 from holiman/eip_3554
consensus/ethash: implement EIP-3554 (bomb delay)
2021-05-12 10:19:08 +03:00
Guillaume Ballet
a2c456a526
core: ensure a broken trie invariant crashes genesis creation (#22780)
* Ensure state could be created in ToBlock

* Fix rebase errors

* use a panic instead
2021-05-11 18:12:10 +03:00
Péter Szilágyi
f34f749e81
Merge pull request #22857 from karalabe/tracer-stack-fix-2
eth/tracers: do the JSON serialization via .js to capture C faults
2021-05-11 17:21:04 +03:00
Péter Szilágyi
0524cede37
eth/tracers: do the JSON serialization via .js to capture C faults 2021-05-11 16:23:54 +03:00
Ryan Schneider
ca98080798
cmd/geth, eth/gasprice: add configurable threshold to gas price oracle (#22752)
This adds a cmd line parameter `--gpo.ignoreprice`, to make the gas price oracle ignore transactions below the given threshold.
2021-05-11 11:25:51 +02:00
Felix Lange
643fd0efc6
core/types: remove support for legacy receipt/log storage encoding (#22852)
* core/types: remove support for legacy receipt storage encoding

* core/types: remove support for legacy log storage encoding
2021-05-11 11:43:35 +03:00
Felix Lange
e536bb52ff
eth/protocols/snap: adapt to uint256 API changes (#22851) 2021-05-10 13:35:07 +02:00
Felix Lange
c0e201b690
eth/protocols/eth, les: avoid Raw() when decoding HashOrNumber (#22841)
Getting the raw value is not necessary to decode this type, and
decoding it directly from the stream is faster.
2021-05-10 12:38:54 +02:00
Martin Holst Swende
ae5fcdc67f
go.mod: upgrade to github.com/holiman/uint256 v1.2.0 (#22745) 2021-05-10 12:29:33 +02:00
Ceelog
f19a679b09
cmd/geth: remove reference to monitor command (#22844)
'geth monitor' subcommand is no longer supported.
2021-05-10 12:19:32 +02:00
Marius Kjærstad
7ab7acfded
build: upgrade -dlgo version to Go 1.16.4 (#22848) 2021-05-10 12:18:42 +02:00
Felix Lange
700df1442d
rlp: add support for optional struct fields (#22832)
This adds support for a new struct tag "optional". Using this tag, structs used
for RLP encoding/decoding can be extended in a backwards-compatible way,
by adding new fields at the end.
2021-05-07 14:37:13 +02:00
Martin Holst Swende
17b1be2661
consensus/ethash: implement EIP-3554 (bomb delay) 2021-05-07 14:04:54 +02:00
Martin Holst Swende
8a070e8f7d
consensus/clique: add some missing checks (#22836) 2021-05-07 10:31:01 +02:00