Commit Graph

14713 Commits

Author SHA1 Message Date
Péter Szilágyi
d98d70f670
cmd/utils, eth: disallow invalid snap sync / snapshot flag combos (#28657)
* eth: prevent startup in snap mode without snapshots

* cmd/utils: try to fix bad flag combos wrt snap sync and snapshot generation
2023-12-08 15:16:04 +02:00
Felföldi Zsolt
fff843cfaf
beacon/light: add CommitteeChain (#27766)
This change implements CommitteeChain which is a key component of the beacon light client. It is a passive data structure that can validate, hold and update a chain of beacon light sync committees and updates, starting from a checkpoint that proves the starting committee through a beacon block hash, header and corresponding state. Once synced to the current sync period, CommitteeChain can also validate signed beacon headers.
2023-12-08 13:38:00 +01:00
Martin HS
1048e2d6a3
cmd/evm: fix dump after state-test exec (#28650)
The dump after state-test didn't work, the problem was an error, "Already committed", which was silently ignored. 

This change re-initialises the state, so the dumping works again.
2023-12-08 11:06:01 +01:00
Martin HS
5a45e7a631
rpc: fix ns/µs mismatch in metrics (#28649)
The rpc/duration/all meter was in nanoseconds, the individual meter in microseconds.
This PR changes it so both of them use nanoseconds.
2023-12-08 09:40:50 +01:00
Marius Kjærstad
77c4bbcaa5
build: upgrade -dlgo version to Go 1.21.5 (#28648) 2023-12-07 12:45:09 +02:00
Guillaume Ballet
a113497dd7
tests/fuzzers/bls12381: deactivate BLS fuzzer when CGO_ENABLED=0 (#28653)
tests/fuzzers/bls12381: deactivate fuzzer when CGO_ENABLED=0
2023-12-07 10:07:20 +01:00
Marius van der Wijden
55b483d82a
ethdb/pebble: remove a dependency (#28627)
The dependency was not really used anyway, so we can get rid of it.

Co-authored-by: Felix Lange <fjl@twurst.com>
2023-12-06 11:41:04 +01:00
Guillaume Ballet
69576df254
.github: use github actions to run 32-bit linux tests (#28549)
use github actions to run 32-bit linux tests
2023-12-05 14:45:40 +01:00
Martin Holst Swende
b8d44ed98b
log: remove lazy, remove unused interfaces, unexport methods (#28622)
This change 

- Removes interface `log.Format`, 
- Removes method `log.FormatFunc`, 
- unexports `TerminalHandler.TerminalFormat` formatting methods (renamed to `TerminalHandler.format`)
- removes the notion of `log.Lazy` values


The lazy handler was useful in the old log package, since it
could defer the evaluation of costly attributes until later in the
log pipeline: thus, if the logging was done at 'Trace', we could
skip evaluation if logging only was set to 'Info'.

With the move to slog, this way of deferring evaluation is no longer
needed, since slog introduced 'Enabled': the caller can thus do
the evaluate-or-not decision at the callsite, which is much more
straight-forward than dealing with lazy reflect-based evaluation.

Also, lazy evaluation would not work with 'native' slog, as in, these
two statements would be evaluated differently:

```golang
  log.Info("foo", "my lazy", lazyObj)
  slog.Info("foo", "my lazy", lazyObj)
```
2023-12-05 11:54:44 +01:00
Martin Holst Swende
3dc071e036
eth/tracers/logger: make structlog/json-log stack hex again (#28628)
* common/hexutil: define hex wrappers for uint256.Int

* eth/tracers/logger: make structlog/json-log stack hex again

* common/hexutil: goimports
2023-12-05 09:37:48 +01:00
Håvard Anda Estensen
2e13b01046
accounts: run tests in parallel (#28544) 2023-12-04 14:55:06 +01:00
Manav Darji
70fd0b635e
eth/fetcher: fix invalid tracking of received at time for block (#28637)
eth/fetcher: fix invalid tracking of received at time
2023-12-04 14:25:17 +02:00
BorkBorked
f04e5bde74
accounts/abi/bind: fixed typos (#28634)
* Update auth.go

* Update backend.go

* Update bind.go

* Update bind_test.go
2023-12-04 11:53:42 +02:00
ddl
6e488c2449
cmd/evm: fix Env struct json tag (#28635) 2023-12-04 11:52:55 +02:00
Delweng
5fb8ebc9ec
eth/tracers: tx-level state in debug_traceCall (#28460) 2023-12-01 16:38:52 +03:30
Martin Holst Swende
dd0d0a2522
slog: faster and less memory-consumption (#28621)
These changes improves the performance of the non-coloured terminal formatting, _quite a lot_. 

```
name               old time/op    new time/op    delta
TerminalHandler-8    10.2µs ±15%     5.4µs ± 9%  -47.02%  (p=0.008 n=5+5)

name               old alloc/op   new alloc/op   delta
TerminalHandler-8    2.17kB ± 0%    0.40kB ± 0%  -81.46%  (p=0.008 n=5+5)

name               old allocs/op  new allocs/op  delta
TerminalHandler-8      33.0 ± 0%       5.0 ± 0%  -84.85%  (p=0.008 n=5+5)
```

I tried to _somewhat_ organize the commits, but the it might still be a bit chaotic. Some core insights: 

- The function `terminalHandler.Handl` uses a mutex, and writes all output immediately to 'upstream'. Thus, it can reuse a scratch-buffer every time. 
- This buffer can be propagated internally, making all the internal formatters either write directly to it,
- OR, make  use of the `tmp := buf.AvailableBuffer()` in some cases, where a byte buffer "extra capacity" can be temporarily used. 
- The `slog` package  uses `Attr` by value. It makes sense to minimize operating on them, since iterating / collecting into a new slice, iterating again etc causes copy-on-heap. Better to operate on them only once. 
- If we want to do padding, it's better to copy from a constant `space`-buffer than to invoke `bytes.Repeat` every single time.
2023-12-01 13:28:20 +01:00
BorkBorked
f2b509d8a1
accounts/abi/bind: fix typo (#28630) 2023-12-01 09:51:50 +01:00
Maciej Kulawik
fa0df76f3c
trie/triedb/hashdb: take lock around access to dirties cache (#28542)
Add read locking of db lock around access to dirties cache in hashdb.Database to prevent
data race versus hashdb.Database.dereference which can modify the dirities map by deleting
an item.

Fixes #28541

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2023-11-30 10:50:48 +01:00
rjl493456442
ab0eb46a84
core/state: make stateobject.create selfcontain (#28459) 2023-11-29 16:07:51 +08:00
jwasinger
28e7371701
all: replace log15 with slog (#28187)
This PR replaces Geth's logger package (a fork of [log15](https://github.com/inconshreveable/log15)) with an implementation using slog, a logging library included as part of the Go standard library as of Go1.21.

Main changes are as follows:
* removes any log handlers that were unused in the Geth codebase.
* Json, logfmt, and terminal formatters are now slog handlers.
* Verbosity level constants are changed to match slog constant values.  Internal translation is done to make this opaque to the user and backwards compatible with existing `--verbosity` and `--vmodule` options.
* `--log.backtraceat` and `--log.debug` are removed.

The external-facing API is largely the same as the existing Geth logger.  Logger method signatures remain unchanged.

A small semantic difference is that a `Handler` can only be set once per `Logger` and not changed dynamically.  This just means that a new logger must be instantiated every time the handler of the root logger is changed.

----
For users of the `go-ethereum/log` module. If you were using this module for your own project, you will need to change the initialization. If you previously did 
```golang
log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
```
You now instead need to do 
```golang
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true)))
```
See more about reasoning here: https://github.com/ethereum/go-ethereum/issues/28558#issuecomment-1820606613
2023-11-29 08:33:50 +01:00
Péter Szilágyi
61b844f2b2
eth/gasestimator: allow slight estimation error in favor of less iterations (#28618)
* eth/gasestimator: early exit for plain transfer and error allowance

* core, eth/gasestimator: hard guess at a possible required gas

* internal/ethapi: update estimation tests with the error ratio

* eth/gasestimator: I hate you linter

* graphql: fix gas estimation test

---------

Co-authored-by: Oren <orenyomtov@users.noreply.github.com>
2023-11-28 22:31:47 +02:00
Jakub Freebit
e0c7ad01ab
consensus: verify the nonexistence of shanghai- and cancun-specific header fields (#28605) 2023-11-28 21:29:00 +01:00
Guillaume Ballet
34dcd74935
crypto/secp256k1: fix 32-bit tests when CGO_ENABLED=0 (#28602) 2023-11-28 19:16:50 +01:00
Sina Mahmoodi
bbc5db8405
eth/tracers/js: fix type inconsistencies (#28488)
This change fixes two type-inconsistencies in the JS tracer:

- In most places we return byte arrays as a `Uint8Array` to the tracer. However it seems we missed doing the conversion for `ctx` fields which are passed to the tracer during `result`. They are passed as simple arrays. I think Uint8Arrays are more suitable and we should change this inconsistency. Note: this will be a breaking-change. But I believe the effect is small. If we look at our tracers we see that these fields (`ctx.from`, `ctx.to`, etc.) are used in 2 ways. Passed to `toHex` which takes both array or buffer. Or the length was measured which is the same for both types.
- The `slice` taking in `int, int` params versus `memory.slice` taking `int64, int64` params. I suggest changing `slice` types to `int64`. This should have no effect almost in any case.
2023-11-28 15:00:35 +01:00
Shivam Sandbhor
248dc50ee8
ethereum: remove TODO comment about subscription (#28609) 2023-11-28 14:49:08 +01:00
Martin Holst Swende
63979bc9cc
cmd/evm, core/state: fix post-exec dump of state (statetests, blockchaintests) (#28504)
There were several problems related to dumping state. 

- If a preimage was missing, even if we had set the `OnlyWithAddresses` to `false`, to export them anyway, the way the mapping was constructed (using `common.Address` as key) made the entries get lost anyway. Concerns both state- and blockchain tests. 
- Blockchain test execution was not configured to store preimages.

This changes makes it so that the block test executor takes a callback, just like the state test executor already does. This callback can be used to examine the post-execution state, e.g. to aid debugging of test failures.
2023-11-28 13:54:17 +01:00
lightclient
58297e339b
light: remove package light(#28614)
This changes removes the package 'light', which is currently unused.
2023-11-28 09:01:23 +01:00
rjl493456442
71817f318e
eth/catalyst, eth/downloader: expose more sync information (#28584)
This change exposes more information from sync module internally
2023-11-28 08:38:30 +01:00
Martin Holst Swende
5b57727d6d
go.mod: update uint256 to v1.2.4 (#28612) 2023-11-27 16:39:28 +02:00
Péter Szilágyi
1e28e0bb03
eth/gasestimator, internal/ethapi: move gas estimator out of rpc (#28600) 2023-11-27 16:20:09 +02:00
Ng Wei Han
333dd956bf
trie: fix random test generator early terminate (#28590)
This change fixes a minor bug in the `randTest.Generate` function, which caused the `quick.Check` to be a no-op.
2023-11-25 14:56:22 +01:00
Péter Szilágyi
2a2013014c
eth, internal/ethapi: drop some weird indirection (#28597) 2023-11-24 13:26:42 +02:00
Marius van der Wijden
bdf5e388ca
cmd, les, tests: remove light client code (#28586)
* cmd, les, tests: remove light client code

This commit removes the light client (LES) code.
Since the merge the light client has been broken and
it is hard to maintain it alongside the normal client.
We decided it would be best to remove it for now and
maybe rework and reintroduce it in the future.

* cmd, eth: remove some more mentions of light mode

* cmd: re-add flags and mark as deprecated

* cmd: warn the user about deprecated flags

* eth: better error message
2023-11-23 16:28:26 +02:00
Mikel Cortes
d76efbb9be
params: update discV5 bootnodes (#28562)
update discV5 bootnodes from https://github.com/eth-clients/eth2-networks/blob/master/shared/mainnet/bootstrap_nodes.txt
2023-11-23 11:14:10 +01:00
Martin Holst Swende
eec37e3b71
cmd/devp2p/internal/ethtest: undo debug-hack (#28588)
cmd/devp2p/internal/ethtest: remove a debug-hack flaw which prevented certain tests from running
2023-11-23 09:22:09 +01:00
Felix Lange
63127f5443
cmd/geth: fix build error (#28585) 2023-11-22 16:32:43 +01:00
Guillaume Ballet
d468c333a7
cmd/{geth,utils}: add cmd to export preimages in snap enumeration order (#28256)
Adds a subcommand: `geth snapshot export-preimages`, to export preimages of every hash found during a snapshot enumeration: that is, it exports _only the active state_, and not _all_ preimages that have been used but are no longer part of the state. 

This tool is needed for the verkle transition, in order to distribute the preimages needed for the conversion. Since only the 'active' preimages are exported, the output is shrunk from ~70GB to ~4GB.

The order of the output is the order used by the snapshot enumeration, which avoids database thrashing. However, it also means that storage-slot preimages are not deduplicated.
2023-11-22 14:48:25 +01:00
Håvard Anda Estensen
5ff929c22f
les/vflux: run tests in parallel (#28524) 2023-11-22 14:00:30 +01:00
jwasinger
3cfcd252db
cmd/geth: add support for --dev flag in dumpgenesis (#28463)
Co-authored-by: Felix Lange <fjl@twurst.com>
Co-authored-by: lightclient <lightclient@protonmail.com>
2023-11-22 12:08:39 +01:00
jwasinger
104dbf7821
cmd/utils: validate pre-existing genesis in --dev mode (#28468)
geth --dev can be used with an existing data directory and genesis block. Since
dev mode only works with PoS, we need to verify that the merge has happened.

Co-authored-by: Felix Lange <fjl@twurst.com>
2023-11-22 12:01:38 +01:00
Delweng
d6cea4832a
rpc: improve performance of subscription notification encoding (#28328)
It turns out that encoding json.RawMessage is slow because
package json basically parses the message again to ensure it is valid.
We can avoid the slowdown by encoding the entire RPC notification once,
which yields a 30% speedup.
2023-11-22 11:24:54 +01:00
Mario Vega
347fecd881
core/types: make 'v' optional for DynamicFeeTx and BlobTx (#28564)
This fixes an issue where transactions would not be accepted when they have only
'yParity' and not 'v'.
2023-11-22 11:00:44 +01:00
ucwong
e9f59b5d5e
eth/filters: reuse error msg for invalid block range (#28479) 2023-11-21 15:28:44 +01:00
Maciej Kulawik
6489a0dd1f
ethdb/pebble: don't double-close iterator inside pebbleIterator (#28566)
Adds 'released' flag to pebbleIterator to avoid double closing cockroachdb/pebble.Iterator as it is an invalid operation.

Fixes #28565
2023-11-21 15:22:22 +01:00
Marius van der Wijden
146e8d999c
core, trie, rpc: speed up tests (#28461)
* rpc: make subscription test faster

reduces time for TestClientSubscriptionChannelClose
from 25 sec to < 1 sec.

* trie: cache trie nodes for faster sanity check

This reduces the time spent on TestIncompleteSyncHash
from ~25s to ~16s.

* core/forkid: speed up validation test

This takes the validation test from > 5s to sub 1 sec

* core/state: improve snapshot test run
brings the time for TestSnapshotRandom from 13s down to 6s

* accounts/keystore: improve keyfile test

This removes some unnecessary waits and reduces the
runtime of TestUpdatedKeyfileContents from 5 to 3 seconds

* trie: remove resolver
* trie: only check ~5% of all trie nodes
2023-11-21 12:19:28 +01:00
levisyin
525db7b2c5
accounts/abi: context info on unpack-errors (#28529)
adds contextual information to errors returned by unpack
2023-11-21 09:16:57 +01:00
Haotian
ad16f11f84
cmd/evm: capitalize evm commands (#28569)
* standard:fix for a unified standard

* standard:fix more as a complements

---------

Co-authored-by: haotian <haotian@haotiandeMacBook-Air.local>
2023-11-21 09:56:23 +02:00
rjl493456442
661bd45188
core/state/snapshot: print correct error from trie iterator (#28560) 2023-11-21 10:47:37 +08:00
Håvard Anda Estensen
460cc1673e
cmd: run tests in parallel (#28546) 2023-11-20 10:52:14 +01:00
jp-imx
14a1e96b68
core/txpool/legacypool: respect nolocals-setting (#28435)
This change adds a check to ensure that transactions added to the legacy pool are not treated as 'locals' if the global locals-management has been disabled. 

This change makes the pool enforce the --txpool.pricelimit setting.
2023-11-20 09:05:20 +01:00