Commit Graph

15580 Commits

Author SHA1 Message Date
Felix Lange c7a8bcecbe
core/types: add length check in CalcRequestsHash (#30829)
The existing implementation is correct when building and verifying
blocks, since we will only collect non-empty requests into the block
requests list.

But it isn't correct for cases where a requests list containing empty
items is sent by the consensus layer on the engine API. We want to
ensure that empty requests do not cause a difference in validation
there, so the commitment computation should explicitly skip them.
2024-11-28 18:43:39 +01:00
Marius van der Wijden 53f66c1b03
cmd/bootnode: remove bootnode utility (#30813)
Since we don't really support custom networks anymore, we don't need the
bootnode utility. In case a discovery-only node is wanted, it can still be run using cmd/devp2p.
2024-11-28 14:37:36 +01:00
Felix Lange db8eed860d
all: exclude empty outputs in requests commitment (#30670)
Implements changes from these spec PRs:

- https://github.com/ethereum/EIPs/pull/8989
- https://github.com/ethereum/execution-apis/pull/599
2024-11-28 11:48:50 +01:00
Ng Wei Han 2406305175
trie: combine validation loops in VerifyRangeProof (#30823)
Small optimization. It's guaranteed that `len(keys)` == `len(values)`,
so we can combine the checks in a single loop rather than 2 separate
loops.
2024-11-28 17:17:58 +08:00
rjl493456442 8c1a36dad3
core/state/snapshot: handle legacy journal (#30802)
This workaround is meant to minimize the possibility for snapshot generation
once the geth node upgrades to new version (specifically #30752 )

In #30752, the journal format in state snapshot is modified by removing
the destruct set. Therefore, the existing old format (version = 0) will be
discarded and all in-memory layers will be lost. Unfortunately, the lost 
in-memory layers can't be recovered by some other approaches, and the 
entire state snapshot will be regenerated (it will last about 2.5 hours).

This pull request introduces a workaround to adopt the legacy journal if
the destruct set contained is empty. Since self-destruction has been
deprecated following the cancun fork, the destruct set is expected to be nil for
layers above the fork block. However, an exception occurs during contract 
deployment: pre-funded accounts may self-destruct, causing accounts with 
non-zero balances to be removed from the state. For example,
https://etherscan.io/tx/0xa087333d83f0cd63b96bdafb686462e1622ce25f40bd499e03efb1051f31fe49).


For nodes with a fully synced state, the legacy journal is likely compatible with
the updated definition, eliminating the need for regeneration. Unfortunately,
nodes performing a full sync of historical chain segments or encountering 
pre-funded account deletions may face incompatibilities, leading to automatic 
snapshot regeneration.
2024-11-28 11:21:31 +08:00
wangjingcun e0deac7f6f
core: better document reason for dropping error on return (#30811)
Add a comment for error return of nil

Signed-off-by: wangjingcun <wangjingcun@aliyun.com>
2024-11-27 07:17:03 +01:00
jwasinger 915248cd6b
cmd/evm: don't reuse state between iterations, show errors (#30780)
Reusing state between benchmark iterations resulted in inconsistent
results across runs, which surfaced in https://github.com/ethereum/go-ethereum/issues/30778 .

If these errors are triggered again, they will now trigger panic. 

---------

Co-authored-by: Martin HS <martin@swende.se>
2024-11-26 16:12:38 +01:00
rjl493456442 a11b4bebcb
Revert "core/state/snapshot: simplify snapshot rebuild (#30772)" (#30810)
This reverts commit 23800122b3.

The original pull request introduces a bug and some flaky tests are
detected because of this flaw.

```
--- FAIL: TestRecoverSnapshotFromWipingCrash (0.27s)
    blockchain_snapshot_test.go:158: The disk layer is not integrated snapshot is not constructed
{"pc":0,"op":88,"gas":"0x7148","gasCost":"0x2","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PC"}
{"pc":1,"op":255,"gas":"0x7146","gasCost":"0x1db0","memSize":0,"stack":["0x0"],"depth":1,"refund":0,"opName":"SELFDESTRUCT"}
{"output":"","gasUsed":"0x0"}
{"output":"","gasUsed":"0x1db2"}
{"pc":0,"op":116,"gas":"0x13498","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH21"}
```

Before the original PR, the snapshot would block the function until the
disk layer
was fully generated under the following conditions:

(a) explicitly required by users with `AsyncBuild = false`.
(b) the snapshot was being fully rebuilt or *the disk layer generation
had resumed*.

Unfortunately, with the changes introduced in that PR, the snapshot no
longer waits
for disk layer generation to complete if the generation is resumed. It
brings lots of
uncertainty and breaks this tiny debug feature.
2024-11-26 11:33:59 +01:00
Nebojsa Urosevic d7e7b54190
core/tracing: add GetCodeHash to StateDB (#30784)
This PR extends the tracing.StateDB interface by adding a GetCodeHash function.
2024-11-26 08:16:00 +01:00
Felix Lange b4d99e3917
eth/ethconfig: improve error message if TTD missing (#30807)
This updates the message you get when trying to initialize Geth with
genesis.json that doesn't have `terminalTotalDifficulty`. The previous
message was a bit obscure, I had to check the code to find out what the
problem was.
2024-11-26 09:49:12 +08:00
Arran Schlosberg 23800122b3
core/state/snapshot: simplify snapshot rebuild (#30772)
This PR is purely for improved readability; I was doing work involving
the file and think this may help others who are trying to understand
what's going on.

1. `snapshot.Tree.Rebuild()` now returns a function that blocks until
regeneration is complete, allowing `Tree.waitBuild()` to be removed
entirely as all it did was search for the `done` channel behind this new
function.
2. Its usage inside `New()` is also simplified by (a) only waiting if
`!AsyncBuild`; and (b) avoiding the double negative of `if !NoBuild`.

---------

Co-authored-by: Martin HS <martin@swende.se>
2024-11-25 13:43:23 +01:00
Jordan Krage 3c754e2a09
accounts/abi: fix MakeTopics mutation of big.Int inputs (#30785)
#28764 updated `func MakeTopics` to support negative `*big.Int`s.
However, it also changed the behavior of the function from just
_reading_ the input `*big.Int` via `Bytes()`, to leveraging
`big.U256Bytes` which is documented as being _destructive_:

This change updates `MakeTopics` to not mutate the original, and 
also applies the same change in signer/core/apitypes.
2024-11-25 13:34:50 +01:00
Hyunsoo Shin (Lake) 19fa71b917
internal/ethapi: remove double map-clone (#30803)
Similar to https://github.com/ethereum/go-ethereum/pull/30788
2024-11-25 13:33:28 +01:00
Martin HS 02159d553f
eth/tracers/logger: improve markdown logger (#30805)
This PR improves the output of the markdown logger a bit.

- Remove `RStack` field, 
- Move `Stack` last, since it may have very large vertical expansion
- Make the pre- and post-exec  metadata structured into a bullet-list
2024-11-25 13:29:27 +01:00
Martin HS ab4a1cc01f
eth/tracers/logger: fix json-logger output missing (#30804)
Fixes a flaw introduced in
https://github.com/ethereum/go-ethereum/pull/29795 , discovered while
reviewing https://github.com/ethereum/go-ethereum/pull/30633 .
2024-11-25 10:07:50 +01:00
Daniel Liu 5e1a39d67f
internal/flags: fix "flag redefined" bug for alias on custom flags (#30796)
This change fixes a bug on the `DirectoryFlag` and the `BigFlag`, which would trigger a `panic` with the message "flag redefined" in case an alias was added to such a flag.
2024-11-24 20:09:38 +01:00
rjl493456442 6485d5e3ff
core, triedb: remove destruct flag in state snapshot (#30752)
This pull request removes the destruct flag from the state snapshot to
simplify the code.

Previously, this flag indicated that an account was removed during a
state transition, making all associated storage slots inaccessible.
Because storage deletion can involve a large number of slots, the actual
deletion is deferred until the end of the process, where it is handled
in batches.

With the deprecation of self-destruct in the Cancun fork, storage
deletions are no longer expected. Historically, the largest storage
deletion event in Ethereum was around 15 megabytes—manageable in memory.

In this pull request, the single destruct flag is replaced by a set of
deletion markers for individual storage slots. Each deleted storage slot
will now appear in the Storage set with a nil value.

This change will simplify a lot logics, such as storage accessing,
storage flushing, storage iteration and so on.
2024-11-22 16:55:43 +08:00
j2gg0s 6eeff3ee7d
trie: replace custom logic with bytes.HasPrefix (#30771)
in `trie`
- Replace custom logic with `bytes.HasPrefix`
- Remove unnecessary code in `GetNode`
2024-11-22 09:16:42 +01:00
wangjingcun 16f2f7155f
all: typos in comments (#30779)
fixes some typos
2024-11-22 09:02:45 +01:00
Hyunsoo Shin (Lake) 2cd25fdd23
internal/ethapi: remove double map-clone (#30788)
`ActivePrecompiledContracts()` clones the precompiled contract map, thus
its callsite does not need to clone it
2024-11-22 08:21:20 +01:00
rjl493456442 a25be32fa9
core, eth, internal, miner: remove unnecessary parameters (#30776)
Follow-up to #30745 , this change removes some unnecessary parameters.
2024-11-22 08:17:32 +01:00
rjl493456442 e3d61e6db0
core, eth, internal, cmd: rework EVM constructor (#30745)
This pull request refactors the EVM constructor by removing the
TxContext parameter.

The EVM object is frequently overused. Ideally, only a single EVM
instance should be created and reused throughout the entire state
transition of a block, with the transaction context switched as needed
by calling evm.SetTxContext.

Unfortunately, in some parts of the code, the EVM object is repeatedly
created, resulting in unnecessary complexity. This pull request is the
first step towards gradually improving and simplifying this setup.

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2024-11-20 12:35:52 +01:00
Martin HS 6d3d252a5e
core/vm/program: evm bytecode-building utility (#30725)
In many cases, there is a need to create somewhat nontrivial bytecode. A
recent example is the verkle statetests, where we want a `CREATE2`- op
to create a contract, which can then be invoked, and when invoked does a
selfdestruct-to-self.

It is overkill to go full solidity, but it is also a bit tricky do
assemble this by concatenating bytes. This PR takes an approach that
has been used in in goevmlab for several years.

Using this utility, the case can be expressed as: 
```golang
	// Some runtime code
	runtime := program.New().Ops(vm.ADDRESS, vm.SELFDESTRUCT).Bytecode()
	// A constructor returning the runtime code
	initcode := program.New().ReturnData(runtime).Bytecode()
	// A factory invoking the constructor
	outer := program.New().Create2AndCall(initcode, nil).Bytecode()
```

We have a lot of places in the codebase where we concatenate bytes, cast
from `vm.OpCode` . By taking tihs approach instead, thos places can be made a
bit more maintainable/robust.
2024-11-20 08:40:21 +01:00
Martin Holst Swende aa63692129
version: fix typo in v1.14.13 release cycle name 2024-11-19 16:58:52 +01:00
Martin Holst Swende 66d8185aad
version: begin v1.14.13 release cycle 2024-11-19 14:51:54 +01:00
Martin Holst Swende c64cf28f9c
version: go-ethereum v1.14.12 stable 2024-11-19 14:46:38 +01:00
Håvard Anda Estensen e20150f888
rpc: run tests in parallel (#30384)
Continuation of https://github.com/ethereum/go-ethereum/pull/30381
2024-11-19 13:43:33 +01:00
jwasinger 581e2140f2
core/txpool, eth/catalyst: clear transaction pool in Rollback (#30534)
This adds an API method `DropTransactions` to legacy pool, blob pool and
txpool interface. This method removes all txs currently tracked in the
pools.

It modifies the simulated beacon to use the new method in `Rollback`
which removes previous hacky implementation that also erroneously reset
the gas tip to 1 gwei.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-11-19 13:35:52 +01:00
jwasinger 61ff3a1186
all: remove kilic dependency from bls12381 fuzzers (#30296)
The [kilic](https://github.com/kilic/bls12-381) bls12381 implementation
has been archived. It shouldn't be necessary to include it as a fuzzing
target any longer.

This also adds fuzzers for G1/G2 mul that use inputs that are guaranteed
to be valid. Previously, we just did random input fuzzing for these
precompiles.
2024-11-19 13:29:23 +01:00
bitcoin-lightning 83790b0729
core: fix typos (#30767) 2024-11-19 14:26:39 +08:00
Marius Kjærstad 7c0ff05685
build: upgrade -dlgo version to Go 1.23.3 (#30742)
New release: https://groups.google.com/g/golang-announce/c/X5KodEJYuqI
2024-11-15 14:05:23 +01:00
Martin HS a5f0001845
cmd/geth: remove unlock commandline flag (#30737)
This is one further step towards removing account management from
`geth`. This PR deprecates the flag `unlock`, and makes the flag moot:
unlock via geth is no longer possible.
2024-11-15 10:15:15 +01:00
Martin HS ec280e030f
core/state: tests on the binary iterator (#30754)
Fixes an error in the binary iterator, adds additional testcases

---------

Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2024-11-15 07:59:06 +01:00
witty df182a742c
docs: fix typo (#30740)
fixes a typo on one of the postmortems
2024-11-11 12:14:18 +01:00
tianyeyouyou ae83912841
p2p/netutil: unittests for addrutil (#30439)
add unit tests for `p2p/addrutil`

---------

Co-authored-by: Martin HS <martin@swende.se>
2024-11-11 11:43:22 +01:00
rjl493456442 77f3ef3714
tests: fix test panic (#30741)
Fix panic in tests
2024-11-10 10:57:05 +01:00
Marius van der Wijden 3f5f2efccb
eth/protocols/eth: add ETH68 protocol handler fuzzers (#30417)
Adds a protocol handler fuzzer to fuzz the ETH68 protocol handlers
2024-11-09 16:07:17 +01:00
rjl493456442 74ef47462f
core/state, triedb/database: refactor state reader (#30712)
Co-authored-by: Martin HS <martin@swende.se>
2024-11-09 08:08:06 +08:00
Péter Szilágyi 55fdbb7e7b
travis: build and upload RISC-V docker images too (#30739)
Requested by @barnabasbusa
2024-11-08 18:20:48 +02:00
zhiqiangxu 896fc51379
trie/utils: remove unneeded initialization (#30472) 2024-11-08 15:28:42 +01:00
Karol Chojnowski 3c7336b0e9
core/state: invoke OnCodeChange-hook on selfdestruct (#30686)
This change invokes the OnCodeChange hook when selfdestruct operation is performed, and a contract is removed. This is an event which can be consumed by tracers.
2024-11-08 15:25:30 +01:00
Felföldi Zsolt 7cbce8ed58
beacon/blsync: remove cli dependencies (#30720)
This PR moves chain config related code (config file processing, fork
logic, network defaults) from `beacon/types` and `beacon/blsync` into
`beacon/params` while the command line flag logic of the chain config is
moved into `cmd/utils`, thereby removing the cli dependencies from
package `beacon` and its sub-packages.
2024-11-08 15:21:00 +01:00
jwasinger d42d45046c
cmd/evm: benchmarking via `statetest` command + filter by name, index and fork (#30442)
When `evm statetest --bench` is specified, benchmark the execution
similarly to `evm run`.

Also adds the ability to filter tests by name, index and fork. 

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2024-11-08 15:18:42 +01:00
Naveen 5b78aef009
signer/core: extended support for EIP-712 array types (#30620)
This change updates the EIP-712 implementation to resolve [#30619](https://github.com/ethereum/go-ethereum/issues/30619).

The test cases have been repurposed from the ethers.js [repository](https://github.com/ethers-io/ethers.js/blob/main/testcases/typed-data.json.gz), but have been updated to remove tests that don't have a valid domain separator; EIP-712 messages without a domain separator are not supported by geth.

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2024-11-08 15:04:17 +01:00
Madhur Shrimal a6037d027f
accounts/usbwallet: support dynamic tx (#30180)
Adds support non-legacy transaction-signing using ledger

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2024-11-08 14:57:29 +01:00
jwasinger 0fc9cca994
internal/ethapi: Set basefee for `AccessList` based on given block, not chain tip (#30538) 2024-11-08 13:33:43 +01:00
SangIlMo 8e00f95056
ethclient/gethclient: testcase for createAccessList, make tabledriven (#30194)
Adds testcase for createAccessList when user requested gasPrice is less than baseFee, also makes the tests tabledriven
---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2024-11-08 13:28:16 +01:00
Felix Lange e92e22a7cf
ethclient: add RevertErrorData function and example (#30669)
Here I'm adding a new helper function that extracts the revert reason of
a contract call. Unfortunately, this aspect of the API is underspecified.
See these spec issues for more detail:

- https://github.com/ethereum/execution-apis/issues/232
- https://github.com/ethereum/execution-apis/issues/463
- https://github.com/ethereum/execution-apis/issues/523

The function added here only works with Geth-like servers that return
error code `3`. We will not be able to support all possible servers.
However, if there is a specific server implementation that makes it
possible to extract the same info, we could add it in the same function
as well.

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
2024-11-07 20:26:02 +01:00
dependabot[bot] 4bac6e669e
build(deps): bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1 (#30728)
Bumps [github.com/golang-jwt/jwt/v4](https://github.com/golang-jwt/jwt) from 4.5.0 to 4.5.1.


Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-07 14:48:51 +01:00
Marius van der Wijden 9c08631bb0
cmd/utils: change blssync.JWTSecretFlag to DirectoryFlag (#30729)
closes https://github.com/ethereum/go-ethereum/issues/30304

We already use `DirectoryFlag` for `authrpc.jwtsecret` which expands the
tilde, so this should work out of the box
2024-11-06 18:24:55 +01:00