Skip to content

types, rawdb, p2p, stagedsync: distinguish empty BALs - #22914

Merged
taratorio merged 5 commits into
mainfrom
agent/avoid-pre-bal-db-read
Jul 31, 2026
Merged

types, rawdb, p2p, stagedsync: distinguish empty BALs#22914
taratorio merged 5 commits into
mainfrom
agent/avoid-pre-bal-db-read

Conversation

@taratorio

@taratorio taratorio commented Jul 31, 2026

Copy link
Copy Markdown
Member

Follow-up to #22894 addressing the staged-sync review comment and the rawdb review comment.

The original Header.HasBAL() predicate conflated two states: whether the BAL commitment field is present and whether it commits to a non-empty BAL. Those meanings need different behavior for a canonical empty BAL encoded as 0xc0.

This change:

  • defines Header.HasBAL() as presence of the BAL commitment field;
  • adds Header.HasNonEmptyBAL() for a commitment other than the canonical empty-list hash;
  • uses HasNonEmptyBAL() in staged sync and backward BAL fetching to avoid unnecessary database and network work;
  • keeps rawdb.ReadBlock on HasBAL() so a stored empty 0xc0 sidecar is preserved;
  • covers missing, empty, and non-empty commitments, including the required single DB lookup for a missing non-empty sidecar;
  • makes TestAssembleBlockWithFreshlyAddedTxns wait for observed txpool polls instead of a fixed delay.

This keeps block reconstruction faithful while retaining the intended optimization for BAL consumers that do not need an empty sidecar. The builder-test change removes timing dependence and does not change production block-building behavior.

TDD note: the CI stabilization is a test-only synchronization refactor, so no production behavior was changed. The failed race-test job is the original red signal.

Validation:

  • go test ./execution/types ./db/rawdb ./execution/stagedsync ./execution/p2p -count=1
  • go test ./execution/stagedsync ./execution/execmodule -run '^(TestBlockAccessListBytes|TestAssembleBlockWithFreshlyAddedTxns)$' -count=20
  • ERIGON_EXEC3_PARALLEL=true GOMAXPROCS=4 go test -race -timeout=10m ./execution/stagedsync ./execution/execmodule -run '^(TestBlockAccessListBytes|TestAssembleBlockWithFreshlyAddedTxns)$' -count=50
  • ERIGON_EXEC3_PARALLEL=true GOMAXPROCS=4 go test -race -timeout=60m ./execution/execmodule -count=3
  • go test ./execution/stagedsync ./execution/execmodule -count=1
  • make lint (four consecutive clean runs)
  • make erigon integration

@taratorio taratorio changed the title rawdb, stagedsync: skip unnecessary BAL reads types, rawdb, p2p, stagedsync: distinguish empty BALs Jul 31, 2026
@taratorio
taratorio marked this pull request as ready for review July 31, 2026 12:04
@yperbasis yperbasis added the Glamsterdam https://eips.ethereum.org/EIPS/eip-7773 label Jul 31, 2026
@yperbasis
yperbasis requested a review from Copilot July 31, 2026 13:23
@yperbasis yperbasis added this to the 3.7.0 milestone Jul 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines Erigon’s EIP-7928 Block Access List (BAL) handling by separating “commitment field is present” from “commitment is non-empty”, allowing empty BAL commitments (canonical 0xc0) to be treated as present while still avoiding unnecessary DB/network work for consumers that only benefit from non-empty BALs.

Changes:

  • Redefines Header.HasBAL() to mean “BAL commitment field present” and introduces Header.HasNonEmptyBAL() to mean “commitment is not the canonical empty-list hash”.
  • Updates staged sync execution (exec3) and backward downloader BAL request selection to use HasNonEmptyBAL() to skip work for empty commitments.
  • Preserves faithful block reconstruction in rawdb.ReadBlock (including stored empty BAL sidecars) and adds regression tests covering missing/empty/non-empty commitment states and call sites.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
execution/types/block.go Redefines HasBAL() semantics (presence) and adds HasNonEmptyBAL() (non-empty commitment).
execution/types/block_access_list_test.go Adds tests validating HasBAL() vs HasNonEmptyBAL() behavior for missing/empty/non-empty commitments.
execution/stagedsync/exec3.go Adds blockAccessListBytes helper and switches exec path to avoid DB reads for empty commitments.
execution/stagedsync/exec3_bal_test.go Adds tests ensuring stagedsync skips DB reads when BAL field is missing or commitment is empty.
execution/p2p/bbd.go Skips backward BAL requests for empty commitments by switching to HasNonEmptyBAL().
db/rawdb/accessors_chain.go Uses header.HasBAL() to ensure empty BAL sidecars are preserved on block reconstruction.
db/rawdb/accessors_chain_test.go Adds regression test ensuring ReadBlock loads stored empty BAL bytes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread execution/stagedsync/exec3_bal_test.go Outdated
@taratorio
taratorio enabled auto-merge July 31, 2026 15:02
@taratorio
taratorio added this pull request to the merge queue Jul 31, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 31, 2026
@taratorio
taratorio added this pull request to the merge queue Jul 31, 2026
Merged via the queue into main with commit 527e210 Jul 31, 2026
114 checks passed
@taratorio
taratorio deleted the agent/avoid-pre-bal-db-read branch July 31, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Glamsterdam https://eips.ethereum.org/EIPS/eip-7773

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants