core/state: fix test

This commit is contained in:
Gary Rong 2026-03-16 15:35:37 +08:00
parent 3b1338e980
commit 91b3543b61
2 changed files with 16 additions and 10 deletions

View file

@ -32,21 +32,21 @@ package state
// with mutated states from preceding transactions in the block. // with mutated states from preceding transactions in the block.
// //
// - Tracking Layer: Finally, the readerTracker wraps the execution reader to // - Tracking Layer: Finally, the readerTracker wraps the execution reader to
// capture all state accesses made during a specific transaction. These individual // capture all state reads made during a specific transaction. These individual
// access are subsequently merged to construct a comprehensive access list // reads are subsequently merged to construct a comprehensive access list
// for the entire block. // for the entire block.
// //
// The architecture can be illustrated by the diagram below: // The architecture can be illustrated by the diagram below:
// [ Block Level Access List ] <────────────────┐ // [ Block Level Read List ] <────────────────┐
// ▲ │ (Merge) // ▲ │ ( Aggregate )
// │ │ // │ │
// ┌───────┴───────┐ ┌───────┴───────┐ // ┌───────┴───────┐ ┌───────┴───────┐
// │ readerTracker │ │ readerTracker │ (Access Tracking) // │ readerTracker │ │ readerTracker │ (State read tracking)
// └───────┬───────┘ └───────┬───────┘ // └───────┬───────┘ └───────┬───────┘
// │ │ // │ │
// ┌──────────────┴──────────────┐ ┌──────────────┴──────────────┐ // ┌──────────────┴──────────────┐ ┌──────────────┴──────────────┐
// │ ReaderWithBlockLevelAL │ │ ReaderWithBlockLevelAL │ (Unified View) // │ ReaderWithBlockLevelAL │ │ ReaderWithBlockLevelAL │
// │ (Pre-state + Mutations) │ │ (Pre-state + Mutations) │ // │ (Pre-state + Mutations) │ │ (Pre-state + Mutations) │
// └──────────────┬──────────────┘ └──────────────┬──────────────┘ // └──────────────┬──────────────┘ └──────────────┬──────────────┘
// │ │ // │ │
@ -62,6 +62,12 @@ package state
// │ (State & Contract Code) │ // │ (State & Contract Code) │
// └─────────────────────────────┘ // └─────────────────────────────┘
// Note: The block producer, which is responsible for generating the block
// along with the block-level access list, does not maintain the internal
// hierarchy (e.g., PrefetchStateReader or ReaderWithBlockLevelAL).
// Instead, it directly utilizes the readerTracker, wrapped around the
// base reader, to construct the access list.
import ( import (
"maps" "maps"
"sync" "sync"

View file

@ -164,12 +164,12 @@ type noopCodeReader struct{}
func (r *noopCodeReader) Has(addr common.Address, codeHash common.Hash) bool { return false } func (r *noopCodeReader) Has(addr common.Address, codeHash common.Hash) bool { return false }
func (r *noopCodeReader) Code(addr common.Address, codeHash common.Hash) ([]byte, error) { func (r *noopCodeReader) Code(addr common.Address, codeHash common.Hash) []byte {
return nil, nil return nil
} }
func (r *noopCodeReader) CodeSize(addr common.Address, codeHash common.Hash) (int, error) { func (r *noopCodeReader) CodeSize(addr common.Address, codeHash common.Hash) int {
return 0, nil return 0
} }
func TestReaderWithTracker(t *testing.T) { func TestReaderWithTracker(t *testing.T) {