Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5824a53
execution, db: state-cache review follow-ups; wire frozen-block catch…
yperbasis Aug 5, 2026
b05da15
execution/cache: name the nil-aggregator case in BindAggregator's assert
yperbasis Aug 5, 2026
5fa7d08
execution/cache, execution/execmodule: absorb snapshot publication in…
yperbasis Aug 5, 2026
75728a2
execution/execmodule: evict the code store on the catch-up prune path
yperbasis Aug 5, 2026
72bbd6b
execution/cache: count addr-codehash seed admission outcomes
yperbasis Aug 5, 2026
67177e0
execution/cache: keep the fill counters off the hot read line
yperbasis Aug 5, 2026
91ccda8
db/state/execctx: assert the apply-only miss path as a difference
yperbasis Aug 5, 2026
1890f34
execution/cache: assert only eviction-safe indices in the chunk-bound…
yperbasis Aug 5, 2026
9a48884
execution/cache: ApplyAll no longer rewrites the caller's slice
yperbasis Aug 5, 2026
8a48529
db/state/execctx: Flush on a cache-attached SD panics like the neighb…
yperbasis Aug 5, 2026
c1dd19e
execution/cache: count fill attempts dying on an inexact frontier
yperbasis Aug 5, 2026
00cec03
execution/cache: make AggregatorBound as nil-safe as BindAggregator
yperbasis Aug 5, 2026
5991d05
execution/commitment: add the missed BranchCache absorb unit test
yperbasis Aug 5, 2026
eb6a44f
Revert "execution/commitment: add the missed BranchCache absorb unit …
yperbasis Aug 5, 2026
9ca2938
execution/cache: cover the third counter in the layout test; cache-dr…
yperbasis Aug 5, 2026
f730805
execution/cache, execution/execmodule: three review nits
yperbasis Aug 5, 2026
fa71731
Merge remote-tracking branch 'origin/main' into yperbasis/statecache-…
yperbasis Aug 15, 2026
86c076d
db/seg: remove unrelated lint suppression
yperbasis Aug 16, 2026
20633ed
db/state/execctx, execution/cache, execution/execmodule: clarify cach…
yperbasis Aug 17, 2026
5dad6aa
Merge remote-tracking branch 'origin/main' into yperbasis/statecache-…
yperbasis Aug 17, 2026
b7525d9
execution/cache: remove fill admission counters
yperbasis Aug 17, 2026
a53738f
execution, db: narrow frozen-block StateCache fix
yperbasis Aug 17, 2026
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
2 changes: 1 addition & 1 deletion execution/execmodule/exec_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ func (e *ExecModule) Start(ctx context.Context, hook *stageloop.Hook) {
}
defer e.semaphore.Release(1)

if err := e.pipelineExecutor.ProcessFrozenBlocks(ctx, hook, e.onlySnapDownloadOnStart); err != nil {
if err := e.pipelineExecutor.ProcessFrozenBlocks(ctx, hook, e.onlySnapDownloadOnStart, e.stateCache); err != nil {
if !errors.Is(err, context.Canceled) {
e.logger.Error("Could not start execution service", "err", err)
}
Expand Down
46 changes: 46 additions & 0 deletions execution/execmodule/exec_module_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ import (
"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/dbg"
"github.com/erigontech/erigon/common/log/v3"
"github.com/erigontech/erigon/db/datadir"
"github.com/erigontech/erigon/db/dbservices"
"github.com/erigontech/erigon/db/kv"
"github.com/erigontech/erigon/db/kv/temporal/temporaltest"
"github.com/erigontech/erigon/execution/cache"
"github.com/erigontech/erigon/execution/types"
)

Expand Down Expand Up @@ -95,6 +98,49 @@ func TestNewDomainStateCacheRespectsUseStateCache(t *testing.T) {
scDefault.Close()
}

// Every SharedDomains used for frozen-block processing must publish catch-up
// writes and revoke older views' fill authority through the normal commit path.
func TestNewFrozenBlocksSDWiresStateCache(t *testing.T) {
t.Parallel()

ctx := t.Context()
db := temporaltest.NewTestDB(t, datadir.New(t.TempDir()))
sc := cache.NewStateCache(1<<20, 1<<20, 1<<20, 1<<20)
t.Cleanup(sc.Close)
sc.Applier().Initialize(0)

addr := make([]byte, 20)
addr[0] = 1
stale := []byte{1}
frontier := cache.FrontierWithStateVersion(cache.FrontierFunc(func(kv.Domain) (uint64, bool) {
return 10, true
}), 0)
preCatchup := sc.View(frontier)
preCatchup.Fill(kv.AccountsDomain, addr, stale, 5)

tx, err := db.BeginTemporalRw(ctx)
require.NoError(t, err)
defer tx.Rollback()
pe := &PipelineExecutor{logger: log.New()}
sd, err := pe.newFrozenBlocksSD(ctx, tx, sc)
require.NoError(t, err)
defer sd.Close()

fresh := []byte{2}
sd.SetTxNum(20)
require.NoError(t, sd.DomainPut(kv.AccountsDomain, tx, addr, fresh, 20, nil))
require.NoError(t, sd.Commit(ctx, tx))

got, ok := sc.View(nil).Get(kv.AccountsDomain, addr)
require.True(t, ok)
require.Equal(t, fresh, got, "catch-up commits must reach the cache")

preCatchup.Fill(kv.AccountsDomain, addr, stale, 5)
got, ok = sc.View(nil).Get(kv.AccountsDomain, addr)
require.True(t, ok)
require.Equal(t, fresh, got, "a pre-catch-up read view must not refill stale state")
}

func TestUnwindToCommonCanonicalReturnsCanonicalityError(t *testing.T) {
expectedErr := errors.New("canonicality read failed")
e := &ExecModule{
Expand Down
19 changes: 14 additions & 5 deletions execution/execmodule/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/erigontech/erigon/db/kv"
dbstate "github.com/erigontech/erigon/db/state"
"github.com/erigontech/erigon/db/state/execctx"
"github.com/erigontech/erigon/execution/cache"
"github.com/erigontech/erigon/execution/chain"
"github.com/erigontech/erigon/execution/protocol/rules"
"github.com/erigontech/erigon/execution/stagedsync"
Expand Down Expand Up @@ -177,10 +178,20 @@ func (pe *PipelineExecutor) RunLoop(ctx context.Context, sd *execctx.SharedDomai
return tx, sd, nil
}

func (pe *PipelineExecutor) newFrozenBlocksSD(ctx context.Context, tx kv.TemporalRwTx, stateCache *cache.StateCache) (*execctx.SharedDomains, error) {
sd, err := execctx.NewSharedDomains(ctx, tx, pe.logger)
if err != nil {
return nil, err
}
sd.SetInMemHistoryReads(inMemHistoryReads)
sd.SetStateCache(stateCache)
return sd, nil
}

// ProcessFrozenBlocks runs the pipeline over snapshot blocks at startup.
// It downloads block files, then executes them in a hasMore loop until
// all frozen blocks are processed.
func (pe *PipelineExecutor) ProcessFrozenBlocks(ctx context.Context, hook *stageloop.Hook, onlySnapDownload bool) error {
func (pe *PipelineExecutor) ProcessFrozenBlocks(ctx context.Context, hook *stageloop.Hook, onlySnapDownload bool, stateCache *cache.StateCache) error {
sawZeroBlocksTimes := 0
tx, err := pe.db.BeginTemporalRw(ctx)
if err != nil {
Expand All @@ -203,12 +214,11 @@ func (pe *PipelineExecutor) ProcessFrozenBlocks(ctx context.Context, hook *stage
return tx.Commit()
}

doms, err := execctx.NewSharedDomains(ctx, tx, pe.logger)
doms, err := pe.newFrozenBlocksSD(ctx, tx, stateCache)
if err != nil {
return err
}
defer func() { doms.Close() }() // RunLoop rotates doms; close whichever is current at exit
doms.SetInMemHistoryReads(inMemHistoryReads)

var finishStageBeforeSync uint64
if hook != nil {
Expand Down Expand Up @@ -247,11 +257,10 @@ func (pe *PipelineExecutor) ProcessFrozenBlocks(ctx context.Context, hook *stage
return nil, nil, err
}
tx = newTx
newSD, err := execctx.NewSharedDomains(ctx, newTx, pe.logger)
newSD, err := pe.newFrozenBlocksSD(ctx, newTx, stateCache)
if err != nil {
return nil, nil, err
}
newSD.SetInMemHistoryReads(inMemHistoryReads)
hook.NotifySyncState(newTx)
return newTx, newSD, nil
},
Expand Down
Loading