Commit graph

3158 commits

Author SHA1 Message Date
CPerezz
1afcea992c
core/state: change StateCounts.Add to value receiver
The struct is 80 bytes (10 ints) — value semantics matches the type's
"snapshot, safe to pass by value" thesis stated in its doc comment, and
removes three unnecessary &-takings at call sites. No behavior change.
2026-04-30 14:03:23 +02:00
CPerezz
cdfad0d343
core/state: comment len(code) > 0 gate, drop dead OriginStorageLoadTime
- Add a comment at the code-mutation gate explaining the deliberate
  len(code) > 0 (vs code != nil) match against non-BAL semantics; in
  devnet-3 BAL access lists, an empty []byte is non-nil but encodes
  "no code install".
- Remove BALStateTransitionMetrics.OriginStorageLoadTime: declared but
  never assigned anywhere in the tree. The actual state-transition
  read time is captured by AccountReadTime/StorageReadTime added in
  the prior commit.
2026-04-30 14:03:23 +02:00
CPerezz
6951ad7c50
core: nil-guard balTransitionStats in reportBALMetrics
Mirrors the nil-check already used in buildSlowBlockLog. The previous
unguarded access was safe today only because parallel_state_processor
short-circuits on error before the metrics path is reached, but the API
contract was fragile — a future caller could reach reportBALMetrics
without an established balTransitionStats and panic.
2026-04-30 14:03:23 +02:00
CPerezz
6b1ea9a498
core/state: forward prefetcher read times through the reader aggregator
Without this, the inline interface assertion in processBlockWithAccessList
silently fell through (the prefetchReader returned by ReaderEIP7928 is a
*reader wrapper, not the inner *prefetchStateReader), causing the
prefetcher contribution to state_read_ms to drop to zero in production.

Mirrors the existing GetStateStats forwarding pattern. Adds a regression
test that asserts *reader exposes PrefetchReadTimes via the BAL chain,
plus a fallback test for non-prefetch readers.
2026-04-30 14:03:23 +02:00
CPerezz
812fa198c3
core/state, core: introduce state.StateCounts snapshot type
Adds the StateCounts type that the BAL slow-block work depends on:
- core/state/state_counts.go: 10-field plain-int snapshot type with
  Add merge primitive; isolates the live atomic mutation surface from
  the value-typed aggregation pipeline.
- core/state/statedb.go: SnapshotCounts() method that converts the
  StateDB's atomic counters to a plain StateCounts at the boundary.
- core/blockchain_stats.go: ExecuteStats embeds state.StateCounts;
  adds ExecWall/PostProcess/Prefetch BAL extension fields, the
  slowBlockBAL JSON struct + BAL field on slowBlockLog, and extracts
  buildSlowBlockLog as a pure helper for direct testing.

Without this commit the bal-devnet-3 branch as committed in subsequent
commits would not build for a fresh clone (state.StateCounts undefined).
2026-04-30 14:03:23 +02:00
CPerezz
ae69e96efd
core: extend slow-block JSON shape test with state_writes, cache, state_read_ms 2026-04-30 14:03:23 +02:00
CPerezz
d611185f09
core: sum prefetcher + per-tx + BAL state-transition reads into state_read_ms 2026-04-30 14:03:23 +02:00
CPerezz
cd93a42b5b
core/state: instrument prefetcher read times 2026-04-30 14:03:23 +02:00
CPerezz
bcdc309f0b
core/state: instrument BAL state-transition read times 2026-04-30 14:03:22 +02:00
CPerezz
6730ab31e5
core: aggregate per-tx state-read durations through parallel pipeline 2026-04-30 14:03:22 +02:00
CPerezz
d419d91c44
core/state: surface BAL write counters via WriteCounts 2026-04-30 14:03:22 +02:00
CPerezz
78cb5b98df
core/state: increment write counters in BAL state transition 2026-04-30 14:03:22 +02:00
CPerezz
3dc4dcaff8
core/state: add code-write counter fields to BALStateTransition 2026-04-30 14:03:22 +02:00
CPerezz
f089266126
core/state: forward cache stats from prefetchStateReader 2026-04-30 14:03:22 +02:00
Marius van der Wijden
189bbd91b4 core: fix 8037 transaction inclusion 2026-04-09 15:19:26 +02:00
Marius van der Wijden
cd2095fb4a core/vm: fix two bugs
Fixes the collision bugs and create gas ordering
2026-04-09 15:05:13 +02:00
Sina M
407cf11930
core/state: touch BAL on statedb cache (#34684)
The BAL reader tracker captures access list reads at the reader level.
When statedb has an account cached the BAL tracker is not informed of
the access. This is ok during the lifetime of a transaction because you
only need to record the access the first time. It is also ok during the
lifetime of a block because BAL reads are block-level (same as statedb
caches).

Where I think the issue can rise is in the miner. Namely when building a
block, if the miner picks up a tx which fails, it drops it and picks up
another tx to include. There might be some edge case here where the
failed tx which is not included poisons the cache and a future block
which is included omits an account because it wasn't aware of the
access.
2026-04-08 13:20:58 -04:00
Marius van der Wijden
fa79954576 core: fix rebasing issue 2026-04-08 16:19:24 +02:00
Marius van der Wijden
ce91d227c2 core/vm: fix gas usage 2026-04-08 16:18:54 +02:00
Marius van der Wijden
778326725b core: introduce vm.GasBudget 2026-04-08 15:35:49 +02:00
Marius van der Wijden
0578ebbe1a core/vm: easier logic 2026-04-08 15:34:58 +02:00
Marius van der Wijden
3e37ed1b82 core: fix tx-inclusion tests 2026-04-08 12:44:39 +02:00
Sina M
60096253be
core/types: fix merging state mutations (EIP-7928) (#34640) 2026-04-07 08:57:43 -04:00
Jared Wasinger
6a79e3693b core: preface invalid bal errors so they are caught by the exception mapper 2026-04-05 18:14:18 -04:00
jwasinger
985cdac8a7
core: fix 8037 gas accounting (#34631)
To check whether a transaction can be applied, we validate that
`blockGasLimit > txGasLimit + (cumulativeRegularGasUsed +
cumulativeStateGasUsed)`. However, the check should only be applied to
the bottleneck resource, i.e. `blockGasLimit >
max(txRegularGasUsed+cumulativeRegularGasUsed, txStateGasUsed+
cumulativeStateGasUsed)`.

The changes here break multiple tests.  I am trying to determine why.

---------

Co-authored-by: qu0b <stefan@starflinger.eu>
2026-04-05 18:12:48 -04:00
Jared Wasinger
710ffb03ad core: perform BAL validation against gas limit for blocks which come with access lists
Co-authored-by: spencer <spencer.tb@ethereum.org>
2026-04-05 15:33:42 -04:00
Sina M
c3ad7547ce
core/state: various fixes in EIP-7928 (#34641)
Co-authored-by: jwasinger <j-wasinger@hotmail.com>
2026-04-03 12:41:45 -04:00
Josh Klopfenstein
53719add20 Some fixes for bal-devnet-3 (#34090)
Rename `balHash` to `blockAccessListHash` in json encoding of block header.  Fix miner panic when attempting to create pre-amsterdam blocks.
2026-03-31 17:59:45 -04:00
Jared Wasinger
e4f847871b core/types: don't include BAL in rlp encoding of full block. Set access list hash on block header when calling 'Block.WithAccessList' 2026-03-31 17:59:43 -04:00
Jared Wasinger
2ff40c7484 core/types/bal: ensure that a written storage slot which was previously read doesn't appear in both the read/write set in the BAL
Co-authored-by: MariusVanDerWijden <m.vanderwijden@live.de>
2026-03-31 17:56:43 -04:00
Marius van der Wijden
8327e870e6 all: fix rebasing issues 2026-03-31 17:56:43 -04:00
Marius van der Wijden
18848bca26 all: fix rebasing issues 2026-03-31 17:56:41 -04:00
Marius van der Wijden
98f757bcc2 core: fix deadlock in parallel state processor 2026-03-31 17:53:30 -04:00
Jared Wasinger
c7ab99831a core: fix storage deletion 2026-03-31 17:53:30 -04:00
Jared Wasinger
71ad98ba90 cmd,core,eth,miner:
* add method on StateReaderTracker to clear the accumulated reads
* don't factor the BAL size into the payload size during construction in the miner
* simplify miner code for constructing payloads-with-BALs via the use of aformentioned StateReaderTracker clear method
* clean up the configuration of the BAL execution mode based on the preset flag specified
2026-03-31 17:53:28 -04:00
CPerezz
5f47ac4811 core/types: fix CopyHeader missing BlockAccessListHash deep copy
CopyHeader copies all pointer-typed header fields (WithdrawalsHash,
RequestsHash, SlotNumber, etc.) but was missing the deep copy for
BlockAccessListHash added by EIP-7928. This caused the BAL hash
to be silently shared between the original and the copy, leading
to potential data races and incorrect nil-checks on copied headers.
2026-03-31 17:52:49 -04:00
Jared Wasinger
787464adfc address more lint errors 2026-03-31 17:52:47 -04:00
Jared Wasinger
6d1df21ef9 fix some lint errors (TODO: merge this commit into the 7928 changes 2026-03-31 17:49:53 -04:00
Jared Wasinger
265d74b75e all: implement eip 7928 block access lists 2026-03-31 17:49:49 -04:00
MariusVanDerWijden
40f34eeb08 core: implement EIP-8037: state creation gas cost increase 2026-03-31 16:59:35 -04:00
CPerezz
3da517e239
core/state: fix storage counters in binary trie IntermediateRoot (#34110)
Add missing `StorageUpdated` and `StorageDeleted` counter increments
in the binary trie fast path of `IntermediateRoot()`.
2026-03-31 15:47:07 +02:00
Jonny Rhea
dc3794e3dc
core/rawdb: BAL storage layer (#34064)
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
Add persistent storage for Block Access Lists (BALs) in `core/rawdb/`.
This provides read/write/delete accessors for BALs in the active
key-value store.

---------

Co-authored-by: Jared Wasinger <j-wasinger@hotmail.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2026-03-31 15:05:31 +08:00
Charles Dusek
e585ad3b42
core/rawdb: fix freezer dir.Sync() failure on Windows (#34115) 2026-03-30 15:34:23 +08:00
Daniel Liu
d1369b69f5
core/txpool/legacypool: use types.Sender instead of signer.Sender (#34059)
Some checks failed
/ Linux Build (arm) (push) Has been cancelled
/ Keeper Build (push) Has been cancelled
/ Windows Build (push) Has been cancelled
/ Linux Build (push) Has been cancelled
/ Docker Image (push) Has been cancelled
`pool.signer.Sender(tx)` bypasses the sender cache used by types.Sender,
which can force an extra signature recovery for every promotable tx
(promotion runs frequently). Use `types.Sender(pool.signer, tx)` here to
keep sender derivation cached and consistent.
2026-03-28 11:46:09 +01:00
rjl493456442
c3467dd8b5
core, miner, trie: relocate witness stats (#34106)
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 relocates the witness statistics into the witness itself, making
it more self-contained.
2026-03-27 17:06:46 +01:00
Lessa
8a3a309fa9
core/txpool/legacypool: remove redundant nil check in Get (#34092)
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
Leftover from d40a255 when return type changed from *txpool.Transaction
to *types.Transaction.
2026-03-26 14:02:31 +01:00
bigbear
5d0e18f775
core/tracing: fix NonceChangeAuthorization comment (#34085)
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
Comment referenced NonceChangeTransaction which doesn't exist, should be
NonceChangeAuthorization.
2026-03-25 09:16:09 +01:00
Felföldi Zsolt
b87340a856
core, core/vm: implement EIP-7708 (#33645)
This PR implements EIP-7708 according to the latest "rough consensus":

https://github.com/ethereum/EIPs/pull/9003
https://github.com/etan-status/EIPs/blob/fl-ethlogs/EIPS/eip-7708.md

---------

Co-authored-by: Jared Wasinger <j-wasinger@hotmail.com>
Co-authored-by: raxhvl <raxhvl@users.noreply.github.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
2026-03-23 22:29:53 +08:00
Daniel Liu
a61e5ccb1e
core, internal/ethapi: fix incorrect max-initcode RPC error mapping (#34067)
Problem:

The max-initcode sentinel moved from core to vm, but RPC pre-check
mapping still depended on core.ErrMaxInitCodeSizeExceeded. This mismatch
could surface inconsistent error mapping when oversized initcode is
submitted through JSON-RPC.

Solution:

- Remove core.ErrMaxInitCodeSizeExceeded from the core pre-check error
set.
- Map max-initcode validation errors in RPC from
vm.ErrMaxInitCodeSizeExceeded.
- Keep the RPC error code mapping unchanged (-38025).

Impact:

- Restores consistent max-initcode error mapping after the sentinel
move.
- Preserves existing JSON-RPC client expectations for error code -38025.
- No consensus, state, or protocol behavior changes.
2026-03-23 22:10:32 +08:00
Lessa
e23b0cbc22
core/rawdb: fix key length check for num -- hash in db inspect (#34074)
Fix incorrect key length calculation for `numHashPairings` in
`InspectDatabase`, introduced in #34000.

The `headerHashKey` format is `headerPrefix + num + headerHashSuffix`
(10 bytes), but the check incorrectly included `common.HashLength`,
expecting 42 bytes.

This caused all number -- hash entries to be misclassified as
unaccounted data.
2026-03-23 21:54:30 +08:00