execution/state: a Balance or Nonce read at a withdrawn destruct validates on its own

Open
#26,429 3 comments 0 reactions 3 assignees View on GitHub

Maintainers usually reply within 1 day

@mh0lt is already working on this.

Since Nov 17, 2026.

Assessment

This issue has not been assessed yet.

Description

In a block with an access list, a tx can read the balance or nonce of an account while a destruct of a lower tx holds. The read is recorded at the version of the destruct. When the field has no cell at that tx, validateReadImpl checks the read against AddressPath, and the existence marker that the access list seeds has the same version. So the read stays valid after the destruct is withdrawn, although a re-run reads the old value.

This does not change a result today: every path that records such a read also records a SelfDestructPath read at the same version, and that read fails validation, so the full read set is rejected. Only the Balance or Nonce read alone is not checked against the destruct. #26380 added this check for the AddressPath read; it needs the read's value, which validateReadImpl does not get.

Repro

seededRemovalOfPrefundedAccount in execution/state/versionmap_seed_removal_test.go: tx 0 creates and destroys the prefunded x (balance 5), and the access list seeds the removal.

func TestBalanceReadAtAWithdrawnDestruct(t *testing.T) {
	x, reader, vm := seededRemovalOfPrefundedAccount(t)
	ibs := NewWithVersionMap(reader, vm)
	defer ibs.Close()
	ibs.SetTxContext(1, 1)
	balance, err := ibs.GetBalance(x)
	require.NoError(t, err)
	require.True(t, balance.IsZero())
	reads := ibs.VersionedReads()
	balanceOnly := ReadSet{balance: map[accounts.Address]VersionedRead[uint256.Int]{x: reads.balance[x]}}

	for _, path := range []AccountPath{SelfDestructPath, BalancePath} {
		vm.Delete(x, path, accounts.NilKey, 0, false) // the removal of tx 0 is withdrawn
	}
	require.Equal(t, VersionInvalid, vm.ValidateReadSet(1, reads, validateEqualVersion, false, ""))
	require.Equal(t, VersionInvalid, vm.ValidateReadSet(1, balanceOnly, validateEqualVersion, false, "")) // fails: VersionValid
}

A re-run of tx 1 reads balance 5. GetNonce(x) gives the same result for the Nonce read.

From @yperbasis's review of #26380.

Dominant language
Go
Stars
3.6k
Forks
1.6k
Avg merge
1d 17h
Merged PRs (30d)
820

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from erigontech/erigon

All issues in erigontech/erigon

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.