Commit graph

16974 commits

Author SHA1 Message Date
MariusVanDerWijden
05b7239548 core: misc fixes (claude) 2026-04-29 23:10:30 +02:00
MariusVanDerWijden
9d545adcb3 core: txpool fix 2026-04-29 16:32:30 +02:00
Stefan
e079c9353a
core/state: avoid polluting EIP-7928 read list in SelfDestructRefundB… (#34848)
…ytes

SelfDestructRefundBytes iterates s.stateObjects and previously called
IsNewContract / HasSelfDestructed on each entry to filter for accounts
that were both created and selfdestructed in the current transaction.
Both helpers go through StateDB.getStateObject, which unconditionally
records an EIP-7928 account read via s.stateReadList.AddAccount(addr).

The effect is that *every* live entry in the stateObjects cache gets
added to the per-tx read list whenever a tx triggers the EIP-8037
selfdestruct refund check (i.e. on every successful tx post-Amsterdam).
This pollutes the BAL with addresses the tx never actually touched.

In the miner, the cache may contain accounts loaded by earlier failed-tx
attempts (preCheck via getStateObject loaded them; RevertToSnapshot does
not evict the cache because reads aren't journaled). Validators
re-executing the sealed block don't have those cached entries, so they
don't reproduce the reads. Result: BAL hash mismatch on otherwise
deterministic execution.

Use direct field access on the already-iterated *stateObject so the
filter doesn't go through getStateObject. Functionally equivalent --
newContract and selfDestructed are the same fields the helpers consult
-- but with no read-list side effect.
2026-04-29 14:03:16 +02:00
MariusVanDerWijden
f59ec20794 core: misc fixes (claude) 2026-04-29 12:41:52 +02:00
MariusVanDerWijden
42a87ae77a core: misc fixes (claude) 2026-04-29 10:35:01 +02:00
MariusVanDerWijden
87a4f9c674 core: misc fixes (claude) 2026-04-29 01:50:27 +02:00
MariusVanDerWijden
95574903c0 core: fix 2026-04-28 23:31:43 +02:00
MariusVanDerWijden
891ec8d128 eth/catalyst: allow reorging the head block to a parent 2026-04-28 23:09:07 +02:00
MariusVanDerWijden
589c24bbfc core: merge bal 2026-04-28 23:05:48 +02:00
MariusVanDerWijden
869aad082a Merge branch 'eip-8037-rewrite' into bal-devnet-5 2026-04-28 23:00:11 +02:00
Stefan
8e8a64fcad params: mark amsterdam blob-schedule entry as optional (#34833)
## Summary

Marks `amsterdam` as `optional` in the blob-schedule fork-validation
table in `params/config.go::CheckConfigForkOrder`, so that a chain
config setting `amsterdamTime` no longer requires a corresponding
`blobSchedule.amsterdam` entry to be present.

## Why

Hive's `clients/<el>/mapper.jq` removed the `amsterdam` block from the
generated `blobSchedule` in
[ethereum/hive#1387](https://github.com/ethereum/hive/pull/1387)
("Remove Amsterdam blob param defaults — values are wrong; we agreed to
remove named forks from blob config").

With strict validation in place, every hive simulator that activates
Amsterdam — including `ethereum/eels/consume-engine` against
`bal-devnet-4` — now fails immediately at `geth init`:

```
Fatal: Failed to write genesis block: invalid chain configuration:
missing entry for fork "amsterdam" in blobSchedule
```

This shows up in the latest scheduled CI runs of
[ethpandaops/hive-tests](https://github.com/ethpandaops/hive-tests) as a
flood of `"could not start client … terminated unexpectedly"` errors on
Amsterdam tests (the simulator job is marked "success" only because the
simulator process itself completes — `tests=46285 failed=24369`).

The `bal-devnet-3` branch already carried a relaxation for the same
reason (commit
[`265d74b75`](https://github.com/ethereum/go-ethereum/commit/265d74b75)
commented the entire check out). This change is narrower:
- only `amsterdam` is marked optional,
- every other fork (`cancun`, `prague`, `osaka`, `bpo1..bpo5`) keeps its
strict check,
- `cur.config.validate()` still runs whenever a caller *does* supply a
blob entry, so misconfigured Amsterdam blob params remain rejected.

It also matches the pattern already used in the fork-ordering table just
above, where `amsterdam` and the BPO timestamps are likewise marked
`optional: true`.

## Test plan

- `go build ./...` and `go test ./params/...` pass locally.
- Reproduced the original failure: a freshly-built
`ethpandaops/geth:bal-devnet-4` errors at `geth init` on a genesis with
`amsterdamTime` set but no `blobSchedule.amsterdam`. With this patch
applied, the same `geth init` succeeds and writes the genesis state.
- Suggest re-running `ethpandaops/hive-tests` workflow
`hive-devnet-4.yaml` against this branch (`common_client_tag:
qu0b/relax-amsterdam-blobschedule-validation`, `client_source: git`) to
confirm Amsterdam tests start the client cleanly.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 22:43:27 +02:00
MariusVanDerWijden
856fd974f6 core: fixed costPerStateByte 2026-04-28 22:43:26 +02:00
MariusVanDerWijden
e5064680b3 core/types/bal: make txIndex uint32 2026-04-28 22:42:53 +02:00
MariusVanDerWijden
da34c4e267 core: dump BAL on mismatch 2026-04-28 22:42:53 +02:00
MariusVanDerWijden
384518cf86 cmd/evm: fix compile 2026-04-28 22:42:53 +02:00
MariusVanDerWijden
8fdccca0b7 core: fix genesis BAL hash 2026-04-28 22:42:53 +02:00
Jared Wasinger
991887c6ee tests: add back devnet spec test runner 2026-04-28 22:42:53 +02:00
MariusVanDerWijden
85f5c21f87 internal/ethapi: add BAL to rpc 2026-04-28 22:42:53 +02:00
Barnabas Busa
73b84bb822 miner: supply a slot number when synthesising pending block post-Amsterdam
getPending builds the pending block on demand via generateWork, but after
EIP-7843 (#33589) prepareWork rejects the call unless generateParams.slotNum
is non-nil once Amsterdam is active:

    if miner.chainConfig.IsAmsterdam(header.Number, header.Time) {
        if genParams.slotNum == nil {
            return nil, errors.New("no slot number set post-amsterdam")
        }
        header.SlotNumber = genParams.slotNum
    }

getPending never populated slotNum, so on any Amsterdam-activated chain
eth_getBalance(addr, "pending") (and every other RPC that resolves through
the pending state) fails with "pending state is not available", breaking
faucets and nonce trackers that poll pending.

Fix by synthesising a slot number from the parent header when available,
mirroring how the Shanghai branch above already conditionally populates
withdrawals. The pending block is empty post-merge so the exact slot value
is not user-visible; SlotNumber+1 (or zero) is sufficient to satisfy the
prepareWork invariant.

Observed on a bal-devnet-3 Geth build: every eth_getBalance(...,"pending")
returned -32000 "pending state is not available" until the faucet was
repointed at a non-Geth EL. Other clients (Nethermind, Besu, Reth, Erigon,
Ethrex) serve pending on the same chain without issue.
2026-04-28 22:42:53 +02:00
Barnabas Busa
4e6c9ec825 beacon/engine: regenerate gen_ed.go to include BlockAccessList
ExecutableData.BlockAccessList was added to the struct in types.go but
gen_ed.go was never regenerated, so MarshalJSON/UnmarshalJSON silently
dropped the field. engine_getPayloadV6 responses were emitted without
blockAccessList, which Prysm rejected with "missing required field
'blockAccessList' for ExecutionPayload", preventing any block
production post-genesis.

Regenerated via `go generate ./beacon/engine/`.
2026-04-28 22:42:37 +02:00
Barnabas Busa
46dcfe06c7 core: set empty BlockAccessListHash on Amsterdam genesis 2026-04-28 22:42:37 +02:00
Marius van der Wijden
fcdadea22c core: apply fixes for BAL (claude) 2026-04-28 22:42:37 +02:00
MariusVanDerWijden
0858bf7154 core: implement eip-7981: Increase Access List Cost 2026-04-28 22:42:36 +02:00
Jared Wasinger
01f79c0927 all: implement BAL single-threaded execution and validation 2026-04-28 22:37:01 +02:00
rayoo
decfab7f6f core/state,core/types/bal: copy stateReadList in StateDB.Copy
The stateReadList field introduced by #34776 to track the state access
footprint for EIP-7928 was not propagated by StateDB.Copy. Every other
per-transaction field that lives alongside it (accessList,
transientStorage, journal, witness, accessEvents) is copied explicitly,
so this field was simply missed.

After Copy the copy's stateReadList is nil while the original keeps its
entries, so the nil-safe guards on StateAccessList.AddAccount / AddState
silently drop every access recorded on the copy. For any post-Amsterdam
code path that copies a prepared state and keeps reading from the copy,
the BAL footprint becomes incomplete.

Add a Copy method on bal.StateAccessList and invoke it from
StateDB.Copy, matching the pattern used for accessList and accessEvents.

---------

Co-authored-by: jwasinger <j-wasinger@hotmail.com>
2026-04-28 22:35:53 +02:00
rayoo
a262af0430 eth/protocols/snap: fix data race on testPeer counters (#34802)
The testPeer request counters (nAccountRequests, nStorageRequests,
nBytecodeRequests, nTrienodeRequests) were plain int fields incremented
with ++. These increments happen in Request* methods that are invoked
concurrently by the Syncer from multiple goroutines
(assignBytecodeTasks, assignStorageTasks, etc.), causing a data race
reliably detected by go test -race.

Change the counters to atomic.Int64 so increments and reads are
synchronized without introducing a mutex.

Fixes races detected in TestMultiSyncManyUseless,
TestMultiSyncManyUselessWithLowTimeout,
TestMultiSyncManyUnresponsive, TestSyncWithStorageAndOneCappedPeer,
TestSyncWithStorageAndCorruptPeer, and
TestSyncWithStorageAndNonProvingPeer.
2026-04-28 22:35:53 +02:00
Sina M
a86eaceda0 Update eth/fetcher/tx_fetcher.go
Co-authored-by: jwasinger <j-wasinger@hotmail.com>
2026-04-28 22:35:53 +02:00
Sina Mahmoodi
a835267289 eth/fetcher: lazy-allocate hashes slice in scheduleFetches
scheduleFetches.func1 is the single biggest allocator in the Pyroscope
profile of a busy node (~13.5 GB/hr, 8% of total alloc_space). Each
peer-iteration pre-allocated 'make([]common.Hash, 0, maxTxRetrievals)'
= 8 KB, even for peers that end up collecting no new hashes (all their
announces were already being fetched by someone else).

Defer the slice allocation to the first append. Peers that collect zero
hashes now pay zero allocation, which is the common case on the
timeoutTrigger path where all peers with any announces are iterated.

New benchmarks BenchmarkScheduleFetches_{100peers_10new,
100peers_allFetching, 500peers_3new} (benchstat, 6 samples):

  scenario            ns/op       B/op        allocs/op
  100p/10new          unchanged   unchanged   unchanged   (fast path)
  100p/allFetching   -62%        -92%        -20%
  500p/3new          -22%        -44%         -7%
  geomean            -33%        -65%         -9%
2026-04-28 22:35:53 +02:00
MariusVanDerWijden
f71f4da77a core: last fixes 2026-04-28 22:33:01 +02:00
MariusVanDerWijden
48d7bf08d7 core: do selfdestructs 2026-04-28 22:26:39 +02:00
MariusVanDerWijden
87641c7265 core/state: charge account creation to parent 2026-04-28 21:06:05 +02:00
MariusVanDerWijden
c1b1faed8b core/state: use journaling approach 2026-04-28 19:29:17 +02:00
Gary Rong
46be549b00 core: extend the journal and introduce the ability for traversal 2026-04-28 18:07:12 +02:00
MariusVanDerWijden
c3d51efe2d core: more fixes 2026-04-28 16:49:02 +02:00
MariusVanDerWijden
b1daa4432c core: implement EIP-8037: state creation gas cost increase (new spec) 2026-04-28 13:53:15 +02:00
Rahman
a065580422
triedb/pathdb: compute size in StateSetWithOrigin.decode (#34828)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
`StateSetWithOrigin.decode()` was missing size computation after
deserializing origin data, causing `size` to remain zero after journal
reload. Added the same calculation logic used in
`NewStateSetWithOrigin()`.
2026-04-27 15:25:57 +08:00
rjl493456442
2d5da60371
core/types/bal: update the BAL definition to the latest spec (#34799)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
This PR updates the BAL structure definition to the latest the spec,

- Balance has been changed from [16]byte to uint256
- Storage key and value has been changed from [32]byte to uint256 
- BlockAccessList has been changed from a struct to a slice of
AccountChanges
- TxIndex has been changed from uint16 to uint32
2026-04-26 23:32:39 +08:00
cui
b26391773d
core/state: and instead of or (#34819)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2026-04-26 11:54:07 +02:00
rayoo
b70d9a4b8e
core/state,core/types/bal: copy stateReadList in StateDB.Copy
Some checks failed
/ Linux Build (push) Has been cancelled
/ Linux Build (arm) (push) Has been cancelled
/ Keeper Build (push) Has been cancelled
/ Windows Build (push) Has been cancelled
/ Docker Image (push) Has been cancelled
The stateReadList field introduced by #34776 to track the state access
footprint for EIP-7928 was not propagated by StateDB.Copy. Every other
per-transaction field that lives alongside it (accessList,
transientStorage, journal, witness, accessEvents) is copied explicitly,
so this field was simply missed.

After Copy the copy's stateReadList is nil while the original keeps its
entries, so the nil-safe guards on StateAccessList.AddAccount / AddState
silently drop every access recorded on the copy. For any post-Amsterdam
code path that copies a prepared state and keeps reading from the copy,
the BAL footprint becomes incomplete.

Add a Copy method on bal.StateAccessList and invoke it from
StateDB.Copy, matching the pattern used for accessList and accessEvents.

---------

Co-authored-by: jwasinger <j-wasinger@hotmail.com>
2026-04-24 17:30:03 +02:00
rayoo
8091994e7b
eth/protocols/snap: fix data race on testPeer counters (#34802)
The testPeer request counters (nAccountRequests, nStorageRequests,
nBytecodeRequests, nTrienodeRequests) were plain int fields incremented
with ++. These increments happen in Request* methods that are invoked
concurrently by the Syncer from multiple goroutines
(assignBytecodeTasks, assignStorageTasks, etc.), causing a data race
reliably detected by go test -race.

Change the counters to atomic.Int64 so increments and reads are
synchronized without introducing a mutex.

Fixes races detected in TestMultiSyncManyUseless,
TestMultiSyncManyUselessWithLowTimeout,
TestMultiSyncManyUnresponsive, TestSyncWithStorageAndOneCappedPeer,
TestSyncWithStorageAndCorruptPeer, and
TestSyncWithStorageAndNonProvingPeer.
2026-04-24 13:37:34 +02:00
Bosul Mun
0da22dee45
eth/fetcher: lazy-allocate hashes slice in scheduleFetches
scheduleFetches.func1 is the biggest allocator in the long-duration
profile of node (11% of total alloc_space).
Each peer-iteration pre-allocated make([]common.Hash, 0, maxTxRetrievals),
even for peers that end up collecting no new hashes (all their announces
were already being fetched by someone else).

Defer the slice allocation to the first append. Peers that collect zero hashes
now pay zero allocation, which is the common case on the timeoutTrigger
path where all peers with any announces are iterated.
2026-04-24 13:24:52 +02:00
Sina M
c876755839
Update eth/fetcher/tx_fetcher.go
Co-authored-by: jwasinger <j-wasinger@hotmail.com>
2026-04-24 12:12:26 +02:00
YQ
33c1bd59ff
rpc: send WebSocket close frame on client disconnect (#33909)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
When `rpc.Client.Close()` is called, the TCP connection is torn down
without sending a WebSocket Close frame. The server sees `websocket:
close 1006 (abnormal closure): unexpected EOF` instead of a clean 1000
(normal closure).

### Root cause

`websocketCodec.close()` delegates to `jsonCodec.close()` which calls
`c.conn.Close()` — gorilla/websocket's `Conn.Close` explicitly "[closes
the underlying network connection without sending or waiting for a close
message](https://pkg.go.dev/github.com/gorilla/websocket#Conn.Close)"
(per RFC 6455).

### Fix

Send a WebSocket Close control frame (opcode 0x8, status 1000) before
closing the underlying connection. Uses `WriteControl` with the same
`encMu` mutex pattern already used by `pingLoop` for write
serialization, and reuses the existing `wsPingWriteTimeout` (5s)
constant.

`WriteControl` errors are safe to ignore — the connection may already be
broken by the time we attempt the close frame.

Fixes #30482
2026-04-24 11:27:39 +02:00
cui
6ece4cd143
crypto: fix unit test (#34811)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
2026-04-24 10:02:34 +08:00
Bosul Mun
526ad4f6f1
crypto/kzg4844: add cell-related functions (#34766)
Some checks are pending
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
This PR adds three cell-level kzg functions required for the sparse
blobpool (eth/72).

- VerifyCells: Verifies cells corresponding to proofs. This is used to
verify cells received from eth/72 peers.
- ComputeCells: Computes cells from blobs. This is needed because user
submissions and eth/71 transaction deliveries contain blobs, while
eth/72 peers expect cells.
- RecoverBlobs: Recovers blobs from partial cells. This is needed to
support both eth/71 and eth/72

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2026-04-23 15:39:07 +02:00
Sina Mahmoodi
2ca74d2ef9 eth/fetcher: lazy-allocate hashes slice in scheduleFetches
scheduleFetches.func1 is the single biggest allocator in the Pyroscope
profile of a busy node (~13.5 GB/hr, 8% of total alloc_space). Each
peer-iteration pre-allocated 'make([]common.Hash, 0, maxTxRetrievals)'
= 8 KB, even for peers that end up collecting no new hashes (all their
announces were already being fetched by someone else).

Defer the slice allocation to the first append. Peers that collect zero
hashes now pay zero allocation, which is the common case on the
timeoutTrigger path where all peers with any announces are iterated.

New benchmarks BenchmarkScheduleFetches_{100peers_10new,
100peers_allFetching, 500peers_3new} (benchstat, 6 samples):

  scenario            ns/op       B/op        allocs/op
  100p/10new          unchanged   unchanged   unchanged   (fast path)
  100p/allFetching   -62%        -92%        -20%
  500p/3new          -22%        -44%         -7%
  geomean            -33%        -65%         -9%
2026-04-23 08:38:40 +00:00
Matus Kysel
8e2107dc39
cmd/devp2p: fix disconnect decoding in rlpx ping (#34781)
Some checks are pending
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Linux Build (push) Waiting to run
/ Docker Image (push) Waiting to run
The rlpx ping command mishandled disconnect responses on two counts:
the error return from rlp.DecodeBytes was ignored, so decode failures
silently produced an "invalid disconnect message" error with no context;
and the decoder assumed the spec-compliant list form exclusively, while
older geth and some other implementations send the reason as a bare
byte.
                                                                  
Accept both wire forms (matching the legacy-tolerant behavior already
  in p2p.decodeDisconnectMessage), and on decode failure include the raw
payload so operators can see exactly what the peer sent. Add a unit
  test for the decoder covering both forms plus the empty-payload error
  path.
2026-04-22 16:48:38 +02:00
Sina M
b0ead5e17b
.gitea: add installer and archive steps for windows (#34793)
Adds the installer + archive steps that were done on appveyor to gitea
builder.
2026-04-22 16:18:29 +02:00
Guillaume Ballet
eb3283fb2e
accounts/usbwallet: revert github.com/karalabe/hid to fix freebsd build (#34784)
This PR reverts the last change to the freebsd build, and it fixes the
_direct_ FreeBSD build.

Here, we change the upstream of github.com/karalabe/hid to its new home,
github.com/ethereum/hid. The new dependency includes a dummy.go file
that makes `go mod vendor` work.

##### Origin of the problem

Enrique is maintaining the FreeBSD ports, and FreeBSD ports only support
vendored go modules. It turns out that `go mod vendor` will not include
C files if there is no `.go` file in the directory. Since the C files
were missing for `karalabe/hid`, the ports maintainer tried to use the
version of `hidapi` that is provided by the ports. To do so, he had to
modify the way things are included. This broke the _out of ports_
FreeBSD build.
2026-04-22 12:32:19 +02:00
Sina M
87b030780e
.github: add windows runner (#34742)
Difference to Appveyor:

- Missing 386 build. Hit some issue because user-space memory there is
around 2Gbs. Also seems generally extremely niche.
- Not doing the archive step and NSIS installer and uploads (those are
done on the builder).
2026-04-22 12:18:56 +02:00