Commit Graph

14851 Commits

Author SHA1 Message Date
Martin Holst Swende
2391fbc676
tests/fuzzers: move fuzzers into native packages (#28467)
This PR moves our fuzzers from tests/fuzzers into whatever their respective 'native' package is.

The historical reason why they were placed in an external location, is that when they were based on go-fuzz, they could not be "hidden" via the _test.go prefix. So in order to shove them away from the go-ethereum "production code", they were put aside.

But now we've rewritten them to be based on golang testing, and thus can be brought back. I've left (in tests/) the ones that are not production (bls128381), require non-standard imports (secp requires btcec, bn256 requires gnark/google/cloudflare deps).

This PR also adds a fuzzer for precompiled contracts, because why not.

This PR utilizes a newly rewritten replacement for go-118-fuzz-build, namely gofuzz-shim, which utilises the inputs from the fuzzing engine better.
2023-11-14 14:34:29 +01:00
VM
24d46224c1
trie: spelling - fix comments in hasher (#28507)
Co-authored-by: VM <arimas@foxmail.com>
2023-11-14 14:27:07 +01:00
Sina Mahmoodi
e803ef09ad
eth/tracers/js: fix isPush for push0 (#28520)
Fixes so that `push0` opcode is correctly reported as `true` by the `IsPush` function

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-11-14 13:14:38 +01:00
Guillaume Ballet
fa8d39807d
cmd, core, trie: verkle-capable geth init (#28270)
This change allows the creation of a genesis block for verkle testnets. This makes for a chunk of code that is easier to review and still touches many discussion points.
2023-11-14 13:09:40 +01:00
Delweng
f265cc24b4
cmd/geth: remove some whitespace in code and comments (#28148)
This changes just removes some whitespace
2023-11-10 13:26:13 +01:00
Marius Kjærstad
49b2c5f43c
build: upgrade -dlgo version to Go 1.21.4 (#28505) 2023-11-10 13:15:06 +01:00
Delweng
ce5a4809fd
ethclient: add empty/nonexist account testcase for eth_getProof RPC (#28482)
Adds testcases for eth_getProof endpoint for the following cases: 

- the account/contract does not exist
- the account/contract exists but is empty.
2023-11-10 12:23:09 +01:00
Wei Tang
2f4833b828
cmd/evm: allow state dump regardless if test passes in statetest (#28484)
This change makes it so that when executing state tess, state is always dumped out if the corresponding flag is set.
2023-11-10 12:21:51 +01:00
rjl493456442
326fa00759
core/rawdb: fsync the index file after each freezer write (#28483)
* core/rawdb: fsync the index and data file after each freezer write

* core/rawdb: fsync the data file in freezer after write
2023-11-10 12:56:39 +02:00
Delweng
e38b9f1830
eth/filters: exit early if topics-filter has more than 4 topics (#28494)
Currently, geth's will return `[]` for any `len(topics) > 4` log filter. The EVM only supports up to four logs, via LOG4 opcode, so larger criterias fail. This change makes the filter query exit early in those cases.
2023-11-10 08:10:03 +01:00
Jim McDonald
f7dde2a96c
ethdb/pebble: add Errorf function to panicLogger (#28491)
cockroachdb/pebble@422dce9 added Errorf to the Logger interface, this change makes it possible to compile geth with that version of pebble by adding the corresponding method to panicLogger.
2023-11-09 15:15:22 +01:00
Martin Holst Swende
b77a9b127c
cmd/geth: more testcases for logging (#28501)
* cmd/geth: more testcases for logging

This adds more edgecases around logging, particularly around handling of different types of nil-values
as concrete types and within interfaces.

Also adds tests with 'reserved' values which breaks json/logfmt formats. The json output is checked in,
but not actively used by any testcase at the moment.

* cmd/geth/testdata: remove timestamps
2023-11-09 10:46:48 +01:00
Delweng
7ea860d665
graphql: type of yParity from Long to BigInt (#28456)
Signed-off-by: jsvisa <delweng@gmail.com>
2023-11-09 11:36:27 +03:00
Péter Szilágyi
470dba8fc1
core/vm: set basefee to 0 internally on eth_call (#28470)
* core/vm: set basefee to 0 internally on eth_call

* core: nicer 0-basefee, make it work for blob fees too

* internal/ethapi: make tests a bit more complex

* core: fix blob fee checker

* core: make code a bit more readable

* core: fix some test error strings

* core/vm: Get rid of weird comment

* core: dict wrong typo
2023-11-08 11:22:08 +02:00
Marius van der Wijden
4d9f3cd5d7
eth: set networkID to chainID by default (#28250)
Co-authored-by: Felix Lange <fjl@twurst.com>
2023-11-07 14:21:46 +01:00
Delweng
f20b334f21
eth/filters: eth_getLogs fast exit for invalid block range (#28386) 2023-11-07 12:41:19 +01:00
Péter Szilágyi
97ae32441e
travis: use newer builder image (#28475) 2023-11-07 13:00:31 +02:00
Péter Szilágyi
51b5ad3da3
.travis: enable cross building to macos arm64 (#28474)
Co-authored-by: Felix Lange <fjl@twurst.com>
2023-11-07 11:35:03 +01:00
Péter Szilágyi
e91cdb49be
ethclient: fix forwarding 1559 gas fields (#28462) 2023-11-03 19:40:37 +02:00
Alvaro Sevilla
b1cec853be
eth/tracers: add position field for callTracer logs (#28389)
Currently, one can use the "withLogs" parameter to include logs in the
callTracer results, which allows the user to see at which trace level
was each log emitted.
This commit adds a position field to the logs which determine
the exact ordering of a call's logs and its subcalls. This would
be useful e.g. for explorers wishing to display the flow of execution.

Co-authored-by: jsvisa <delweng@gmail.com>
2023-11-03 10:28:27 +01:00
lmittmann
a3be38127c
core/vm: performance tweak of OpCode.String() (#28453)
make `opCodeToString` a `[256]string` array

Co-authored-by: lmittmann <lmittmann@users.noreply.github.com>
2023-11-02 08:54:28 +02:00
rjl493456442
f4ac548619
ethdb/pebble: cap memory table size as maxMemTableSize-1 (#28444) 2023-10-31 18:19:31 +02:00
Mario Vega
285202aae2
cmd/evm: add --run option to blocktest command (#28421)
Co-authored-by: lightclient <lightclient@protonmail.com>
2023-10-31 15:23:51 +01:00
Felix Lange
bc42e88415
core: add basic chain history support in GenerateChain (#28428)
This change improves GenerateChain to support internal chain history access (ChainReader)
for the consensus engine and EVM.

GenerateChain takes a `parent` block and the number of blocks to create. With my changes,
the consensus engine and EVM can now access blocks from `parent` up to the block currently
being generated. This is required to make the BLOCKHASH instruction work, and also needed
to create real clique chains.  Clique uses chain history to figure out if the current signer is in-turn,
for example.

I've also added some more accessors to BlockGen. These are helpful when creating transactions:

- g.Signer returns a signer instance for the current block
- g.Difficulty returns the current block difficulty
- g.Gas returns the remaining gas amount

Another fix in this commit concerns the receipts returned by GenerateChain. The receipts now
have properly derived fields (BlockHash, etc.) and should generally match what would be
returned by the RPC API.
2023-10-31 12:39:25 +01:00
Jakub Freebit
447945e438
core/rawdb: add logging and fix comments around AncientRange function. (#28379)
This adds warning logs when the read does not match the expected count.
We can also remove the size limit since the function documentation explicitly states
that callers should limit the count.
2023-10-31 12:04:45 +01:00
rjl493456442
ea2e66a58e
trie/triedb/pathdb: improve dirty node flushing trigger (#28426)
* trie/triedb/pathdb: improve dirty node flushing trigger

* trie/triedb/pathdb: add tests

* trie/triedb/pathdb: address comment
2023-10-31 11:39:55 +02:00
Martin Holst Swende
233db64cc1
all: make vendored copy of reexec (#28382)
a little copying is better than a little dependency

-- go proverb

We have this dependency on docker, a.k.a moby: a gigantic library, and we only need ~70 LOC,
so here I tried moving it inline instead.

Co-authored-by: Felix Lange <fjl@twurst.com>
2023-10-28 00:14:43 +02:00
Delweng
2d7dba024d
graphql: always set content-type to application/json (#28417)
---------

Signed-off-by: jsvisa <delweng@gmail.com>
2023-10-27 16:50:59 +02:00
Guillaume Ballet
4cbca5178a
core, cmd/geth: add --override.* flags to geth init (#28407)
* core, cmd/geth: add --override.* flags to geth init

* also apply overrides before genesis commit with new block

* review feedback
2023-10-27 10:15:14 +08:00
Delweng
abe3fca1de
graphql: fix an issue of nil pointer panic (#28416)
Signed-off-by: jsvisa <delweng@gmail.com>
2023-10-26 13:48:51 +02:00
Martin Holst Swende
58ae1df684
cmd/geth: test for logging-output (#28373)
This PR is a bit in preparation for the slog work in #28187 .

Our current test re logging mostly test the internals, but we have no real end-to-end test of the logging output. This PR introduces a simple reexec-based log tester. This also relies upon a special mode in geth, which can be made to eject a set of predefined log messages (only available if the build-tag `integrationtests` is used

e.g. go run --tags=integrationtests ./cmd/geth --log.format terminal logtest

While working on this, I also noticed a quirk in the setup: when geth was configured to use a file output, then two separate handlers were used (one handler for the file, one handler for the console). Using two separate handlers means that two formatters are used, thus the formatting of any/all records happened twice. This PR changes the mechanism to use two separate io.Writers instead, which is both more optimal and fixes a bug which occurs due to a global statefulness in the formatter.
2023-10-25 17:57:12 +02:00
Adrian Sutton
d8c6ae054c
rpc: use correct stringer-method for serializing BlockNumberOrHash (#28358)
The String() version of BlockNumberOrHash uses decimal for all block numbers, including negative ones used to indicate labels. Switch to using BlockNumber.String() which encodes it correctly for use in the JSON-RPC API.
2023-10-25 15:52:42 +02:00
Delweng
f7b62e5506
graphql: logs return error if from block > to (#28412)
As per discussion in ethereum/execution-apis#475

Signed-off-by: jsvisa <delweng@gmail.com>
2023-10-25 15:20:23 +02:00
Martin Holst Swende
96b75033c0
trie: use explicit errors in stacktrie (instead of panic) (#28361)
This PR removes panics from stacktrie (mostly), and makes the Update return errors instead. While adding tests for this, I also found that one case of possible corruption was not caught, which is now fixed.
2023-10-25 14:53:50 +02:00
Martin Holst Swende
300df874d7
cmd/evm: make t8ntool handle transaction decoding errors better (#28397)
This change closes https://github.com/ethereum/go-ethereum/issues/27730 . By using an iterator instead of a slice of transactions, we can better handle the case when an individual transaction (within an otherwise well-formed RLP-list) cannot be decoded.
2023-10-25 14:08:52 +02:00
moomin
a8617c6d4d
txpool/legacypool: remove already known error in legacypool (#28400) 2023-10-23 18:36:11 +03:00
rjl493456442
ab04aeb855
core, eth, trie: filter out boundary nodes and remove dangling nodes in stacktrie (#28327)
* core, eth, trie: filter out boundary nodes in stacktrie

* eth/protocol/snap: add comments

* Update trie/stacktrie.go

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

* eth, trie: remove onBoundary callback

* eth/protocols/snap: keep complete boundary nodes

* eth/protocols/snap: skip healing if the storage trie is already complete

* eth, trie: add more metrics

* eth, trie: address comment

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-10-23 18:31:56 +03:00
Delweng
43e6a3c196
graphql: return error if block from>to (#28393)
As per discussion in ethereum/execution-apis#475
2023-10-23 17:25:26 +02:00
rjl493456442
3853f50082
trie/triedb/pathdb, core/rawdb: enhance error message in freezer (#28198)
This PR adds more error message for debugging purpose.
2023-10-23 15:46:39 +02:00
hyunchel
062598bb40
core/blockchain: fix typos and grammar (#28295) 2023-10-23 15:23:41 +02:00
kaliubuntu0206
54f35c68be
ethstats: fix bug in block reporting (#28398)
Fixes a bug where the ethstats omits to report full block contents. This bug was a side-effect of https://github.com/ethereum/go-ethereum/pull/26777,  where `CurrentBlock` was changed to return a header instead of a block, leading to a failed type assertion.
2023-10-23 15:06:05 +02:00
aaronbuchwald
6c6982163b
core/state/pruner: track number of skipped items during state pruning (#28368) 2023-10-23 13:24:32 +08:00
Inphi
ffc6a0f36e
event: fix Resubscribe deadlock when unsubscribing after inner sub ends (#28359)
A goroutine is used to manage the lifetime of subscriptions managed by
resubscriptions. When the subscription ends with no error, the resub
goroutine ends as well. However, the resub goroutine needs to live
long enough to read from the unsub channel. Otheriwse, an Unsubscribe
call deadlocks when writing to the unsub channel.

This is fixed by adding a buffer to the unsub channel.
2023-10-22 17:37:56 +02:00
kevaundray
a6a0ae45b6
crypto/kzg4844: use the new trusted setup file and format (#28383)
Changes the trusted_setup to the one created during the kzg-ceremony. The trusted setup file can be found in the consensus specs: https://github.com/ethereum/consensus-specs/blob/dev/presets/mainnet/trusted_setups/trusted_setup_4096.json
---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2023-10-22 16:05:04 +02:00
Martin Holst Swende
c1d5a012ea
core/state, tests: fix memory leak via fastcache (#28387)
This change fixes a memory leak, when running either state-tests or blockchain-tests, we allocate a `1MB` fastcache during snapshot generation. `fastcache` is a bit special, and requires a `Reset()` (it has it's own memory allocator). 

The `1MB` was hidden [here](https://github.com/ethereum/go-ethereum/blob/master/tests/state_test_util.go#L333) and [here](https://github.com/ethereum/go-ethereum/blob/master/tests/block_test_util.go#L146) respectively.
2023-10-20 13:35:49 +02:00
Marius van der Wijden
cd29535672
crypto/blake2b: put architecture-dependent features behind build-tag (#28381)
This change to fixes a compilation-flaw on master, by putting architecture-specific functions behind corresponding build tags.
2023-10-19 14:04:26 +02:00
Sina Mahmoodi
4d3c0d41f4
eth/filters: fix flaky test TestPendingTxFilterDeadlock (#28376) 2023-10-19 10:30:55 +02:00
Brandon Liu
ec1a0502bf
rpc: increase timeout in TestClientWebsocketPing (#28371) 2023-10-19 10:08:36 +02:00
Marius van der Wijden
d10a2f6ab7
tests/fuzzers: update fuzzers to be based on go-native fuzzing (#28352)
This change modifies the fuzzers to use the native golang fuzzing framework instead of go-fuzz
2023-10-18 15:01:16 +02:00
lightclient
da55b23d21
eth/fetcher: downgrade stale txs log from warn to debug (#28364) 2023-10-17 19:52:53 +03:00