Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 0 additions & 147 deletions execution/state/block_cache_committed_storage_test.go

This file was deleted.

20 changes: 4 additions & 16 deletions execution/state/block_cache_multiblock_flush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,9 @@ func TestBlockStateCacheFlushClearsAcrossBlocks(t *testing.T) {
// in exec3_parallel.go (one BlockStateCache per blockExecutor/batch).
cache := NewBlockStateCache()

// Block 1: syscall reads slot first (populating committedStorage with
// the pre-batch value, empty here), then writes 0x01, then Flush.
// The read is what CachedReaderV3.ReadAccountStorage does on first
// access — that's the production path that seeds committedStorage.
// Block 1: syscall writes 0x01, then Flush.
const block1TxNum uint64 = 100
domains.SetTxNum(block1TxNum)
// Simulate the first read — value is empty (pre-batch slot is zero).
// CachedReaderV3 caches this as committed[slot] = nil/empty.
cache.PutCommittedStorage(addr, slot, nil)
cache.WriteStorage(addr, slot, []byte{0x01}, block1TxNum)
require.NoError(t, cache.Flush(domains, tx))

Expand All @@ -85,11 +79,8 @@ func TestBlockStateCacheFlushClearsAcrossBlocks(t *testing.T) {
require.True(t, bytes.Equal(enc1, []byte{0x01}),
"after block 1 flush, domain should hold value 0x01, got %x", enc1)

// Block 2: syscall clears the slot back to 0x00. Prior to the fix the
// Flush dedup compared the (nil) cleared value against the stale
// `committedStorage[slot]` (still nil from a never-populated entry)
// and skipped the delete. After the fix the delete propagates and the
// domain no longer returns 0x01.
// Block 2: syscall clears the slot back to 0x00; the delete must
// propagate through Flush so the domain no longer returns 0x01.
const block2TxNum uint64 = 200
domains.SetTxNum(block2TxNum)
cache.WriteStorage(addr, slot, nil, block2TxNum)
Expand All @@ -98,9 +89,7 @@ func TestBlockStateCacheFlushClearsAcrossBlocks(t *testing.T) {
enc2, _, err := domains.GetLatest(kv.StorageDomain, tx, composite)
require.NoError(t, err)
require.Empty(t, enc2,
"after block 2 flush, domain should be cleared (value=empty); "+
"got %x — this is the 24839762 trie-root race: Flush skipped "+
"the delete because committedStorage was never refreshed",
"after block 2 flush, domain should be cleared (value=empty); got %x",
)
}

Expand Down Expand Up @@ -157,7 +146,6 @@ func TestBlockStateCacheFlushPreservesPerTxHistory(t *testing.T) {
require.NoError(t, domains.DomainPut(kv.AccountsDomain, tx, addrVal[:], preEnc, preTxNum, nil))

cache := NewBlockStateCache()
cache.PutCommittedAccount(addr, &preAcc)

// Tx 3 increments balance to 1100.
tx3Acc := accounts.NewAccount()
Expand Down
6 changes: 2 additions & 4 deletions execution/state/finalize_reader_blockcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ func TestFinalizeReaderSeesBlockCacheWrite(t *testing.T) {
domains.DomainPut(kv.AccountsDomain, tx, addrValue[:], preEnc, preBlockTxNum, nil),
)

// Simulate tx 28's SubBalance landing in the BlockStateCache (and only
// the BlockStateCache — applyVersionedWrites never touches sd.mem in the
// parallel path).
// Simulate tx 28's SubBalance landing in the BlockStateCache current tier
// (applyVersionedWrites buffers writes there until the block-end Flush).
postTx28Balance := uint256.NewInt(6707)
postAcc := &accounts.Account{
Nonce: 1,
Expand All @@ -97,7 +96,6 @@ func TestFinalizeReaderSeesBlockCacheWrite(t *testing.T) {
postEnc := accounts.SerialiseV3(postAcc)

blockCache := NewBlockStateCache()
blockCache.PutCommittedAccount(addr, preAcc)
blockCache.WriteAccount(addr, postEnc, 100)

// Sanity: CurrentCachedReaderV3 (the reader used for non-historic
Expand Down
30 changes: 0 additions & 30 deletions execution/state/parallel_fixes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,33 +323,6 @@ func TestTouchUpdates_MixedBatch(t *testing.T) {
assert.Equal(t, uint64(2), updates.Size(), "2 unique keys (addr1 merged, addr2 storage)")
}

// TestBlockStateCacheWriteAccount_NilCommitted verifies that WriteAccount
// doesn't panic when the committed cache has a nil account entry.
// This can happen when PutCommittedAccount stores nil (account doesn't exist).
func TestBlockStateCacheWriteAccount_NilCommitted(t *testing.T) {
cache := NewBlockStateCache()

addr := accounts.InternAddress([20]byte{0x42})

// Put a nil committed account (account doesn't exist in pre-block state)
cache.PutCommittedAccount(addr, nil)

// Write a new account — should not panic
acc := accounts.NewAccount()
acc.Balance = *uint256.NewInt(1000)
acc.Nonce = 1
enc := accounts.SerialiseV3(&acc)

assert.NotPanics(t, func() {
cache.WriteAccount(addr, enc, 1)
}, "WriteAccount should not panic with nil committed account")

// Verify the write is recorded.
current, ok := cache.GetCurrentAccount(addr)
assert.True(t, ok, "Should have current account")
assert.Equal(t, enc, current, "Current account should match written value")
}

// TestBlockStateCacheWriteAccountUpdatesCurrent verifies that successive
// writes update the current view to the latest value (last write wins
// for read access via GetCurrentAccount). The full per-tx history is
Expand All @@ -359,12 +332,9 @@ func TestBlockStateCacheWriteAccountUpdatesCurrent(t *testing.T) {

addr := accounts.InternAddress([20]byte{0x55})

// Set up committed account
acc := accounts.NewAccount()
acc.Balance = *uint256.NewInt(500)
acc.Nonce = 3
cache.PutCommittedAccount(addr, &acc)

enc := accounts.SerialiseV3(&acc)
cache.WriteAccount(addr, enc, 3)

Expand Down
Loading
Loading