Skip to content
Merged
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
6 changes: 0 additions & 6 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1162,11 +1162,6 @@ var (
Usage: "Enables background pruning post fcu",
Value: ethconfig.Defaults.FcuBackgroundPrune,
}
FcuBackgroundCommitFlag = cli.BoolFlag{
Name: "fcu.background.commit",
Usage: "Enables background flush and commit",
Value: ethconfig.Defaults.FcuBackgroundCommit,
}
MCPDisableFlag = cli.BoolFlag{
Name: "mcp.disable",
Usage: "Disables the embedded MCP server",
Expand Down Expand Up @@ -2026,7 +2021,6 @@ func SetEthConfig(nodeCtx context.Context, ctx *cli.Command, nodeConfig *nodecfg

cfg.FcuTimeout = ctx.Duration(FcuTimeoutFlag.Name)
cfg.FcuBackgroundPrune = ctx.Bool(FcuBackgroundPruneFlag.Name)
cfg.FcuBackgroundCommit = ctx.Bool(FcuBackgroundCommitFlag.Name)

// Executor performance toggles. When the user explicitly sets the CLI
// flag, it overrides the env-var default that dbg read at package init.
Expand Down
2 changes: 0 additions & 2 deletions docs/site/docs/fundamentals/configuring-erigon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,6 @@ Flags for configuring Fork Choice Update behavior.
* Default: `1s`
* `--fcu.background.prune`: Enables background pruning after FCU.
* Default: `true`
* `--fcu.background.commit`: Enables background flush and commit after FCU.
* Default: `false`

### Execution

Expand Down
2 changes: 0 additions & 2 deletions docs/site/static/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2298,8 +2298,6 @@ Flags for configuring Fork Choice Update behavior.
* Default: `1s`
* `--fcu.background.prune`: Enables background pruning after FCU.
* Default: `true`
* `--fcu.background.commit`: Enables background flush and commit after FCU.
* Default: `false`

### Execution

Expand Down
13 changes: 5 additions & 8 deletions execution/execmodule/exec_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ func GetBlockHashFromMissingSegmentError(err error) (common.Hash, bool) {
// machinery is unnecessary.
type Cache struct {
execModule *ExecModule
publishedSD func() *execctx.SharedDomains // returns the latest published SD from Events (for background commit)
publishedSD func() *execctx.SharedDomains // returns the latest published SD from Events
}

// SetPublishedSD wires the Cache to fall back to the published SD from Events
// when the exec module's currentContext is nil (e.g. during background commit).
// when the exec module's currentContext is nil (e.g. while an FCU commits).
func (c *Cache) SetPublishedSD(provider func() *execctx.SharedDomains) {
c.publishedSD = provider
}
Expand All @@ -123,7 +123,7 @@ func (c *Cache) View(_ context.Context, tx kv.TemporalTx) (kvcache.CacheView, er
context = c.execModule.currentContext
c.execModule.lock.RUnlock()
}
// Fall back to the published SD from Events during background commits
// Fall back to the published SD from Events while an FCU commits
// (currentContext is nil but the SD is still valid in memory).
if context == nil && c.publishedSD != nil {
context = c.publishedSD()
Expand Down Expand Up @@ -211,7 +211,6 @@ type ExecModule struct {
balRegenerator *bal.Regenerator

fcuBackgroundPrune bool
fcuBackgroundCommit bool
onlySnapDownloadOnStart bool
nextForkActivated bool
// gas-weighted EWMA: accumulate gas and time separately so near-empty blocks don't skew the average
Expand All @@ -220,7 +219,7 @@ type ExecModule struct {

lock sync.RWMutex
currentContext *execctx.SharedDomains
publishedSD func() *execctx.SharedDomains // fallback for background commit
publishedSD func() *execctx.SharedDomains // fallback while an FCU commits

// stateCache is a cache for state data (accounts, storage, code)
stateCache *cache.StateCache
Expand Down Expand Up @@ -249,7 +248,6 @@ func NewExecModule(
engine rules.Engine,
syncCfg ethconfig.Sync,
fcuBackgroundPrune bool,
fcuBackgroundCommit bool,
onlySnapDownloadOnStart bool,
readAheader *exec.BlockReadAheader,
stopNode func() error,
Expand Down Expand Up @@ -279,7 +277,6 @@ func NewExecModule(
syncCfg: syncCfg,
bacgroundCtx: ctx,
fcuBackgroundPrune: fcuBackgroundPrune,
fcuBackgroundCommit: fcuBackgroundCommit,
onlySnapDownloadOnStart: onlySnapDownloadOnStart,
stateCache: domainCache,
codeStore: codeStore,
Expand Down Expand Up @@ -349,7 +346,7 @@ func (e *ExecModule) closeModuleContext() {
func (e *ExecModule) ForkValidator() *ForkValidator { return e.forkValidator }

// SetPublishedSD wires the ExecModule to fall back to the published SD from Events
// when currentContext is nil (e.g. during background commit).
// when currentContext is nil (e.g. while an FCU commits).
func (e *ExecModule) SetPublishedSD(provider func() *execctx.SharedDomains) {
e.publishedSD = provider
}
Expand Down
81 changes: 12 additions & 69 deletions execution/execmodule/exec_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,9 @@ func TestReorgBackAndForwardIntoCanonicalChain(t *testing.T) {
}{
{name: "fg-prune"},
// bg-prune matches the hive erigon default (FcuBackgroundPrune=true): the
// background prune shares the pipeline sync with the next FCU's RunLoop.
// bg-commit hands the semaphore to its goroutine the same way; in both
// modes the handoff must not overlap the FCU goroutine's cleanup.
// background prune shares the pipeline sync with the next FCU's RunLoop,
// and its semaphore handoff must not overlap the FCU goroutine's cleanup.
{name: "bg-prune", opt: execmoduletester.WithFcuBackgroundPrune()},
{name: "bg-commit", opt: execmoduletester.WithFcuBackgroundCommit()},
}
for _, mode := range modes {
opts := []execmoduletester.Option{execmoduletester.WithGenesisSpec(&types.Genesis{Config: chain.AllProtocolChanges})}
Expand Down Expand Up @@ -1675,35 +1673,6 @@ func TestNotificationDispatchForegroundCommit(t *testing.T) {
require.NoError(t, err)
}

// TestNotificationDispatchBackgroundCommit verifies that with background
// commit enabled, notifications are still dispatched before FCU returns,
// even though the DB commit happens asynchronously.
//
// Note: with background commit, subsequent blocks may fail validation
// because the DB state hasn't caught up yet (the commit is async). This
// test only processes the genesis → block 1 transition to verify that
// notification dispatch works correctly in the background commit path.
func TestNotificationDispatchBackgroundCommit(t *testing.T) {
// Background commit creates a race: FCU N returns before commit finishes,
// so FCU N+1 reads stale state from DB. This is the known limitation that
// the API-layer "latest head pointer" coordination is designed to solve.
// Once that's implemented, remove this skip and verify the full flow.
t.Skip("background commit requires API-layer coordination (latest head pointer) to work correctly")

m := execmoduletester.New(t, execmoduletester.WithFcuBackgroundCommit())

headerCh, unsub := m.Notifications.Events.AddHeaderSubscription()
defer unsub()

chainPack, err := m.GenerateChain(1, nil)
require.NoError(t, err)

err = m.InsertChain(chainPack)
require.NoError(t, err)

drainHeaders(t, headerCh, 2*time.Second)
}

// TestNotificationDispatchBackgroundPrune verifies that with the default
// production configuration (foreground commit + background prune), notifications
// are dispatched and data is committed before FCU returns. This was a real bug:
Expand Down Expand Up @@ -2346,12 +2315,11 @@ func TestInsertBlocksWithBatchedFCU(t *testing.T) {
}
}

// runBatchedFCUBadBlockRecovery is the shared body for the foreground- and
// background-commit variants of the bad-block recovery test. Both FCU
// cleanup branches — local SD close (foreground) and the additional
// currentContext reset (background) — must leave the next InsertBlocks+FCU
// cycle able to recover.
func runBatchedFCUBadBlockRecovery(t *testing.T, bgCommit bool) {
// TestInsertBlocksWithBatchedFCU_BadBlockRecovery covers the FCU cleanup path:
// a bad-block FCU closes the local SharedDomains while the persistent
// currentContext remains, and the next InsertBlocks+FCU cycle must
// re-initialize the overlay on top of it and recover.
func TestInsertBlocksWithBatchedFCU_BadBlockRecovery(t *testing.T) {
ctx := t.Context()
privKey, err := crypto.GenerateKey()
require.NoError(t, err)
Expand All @@ -2362,19 +2330,12 @@ func runBatchedFCUBadBlockRecovery(t *testing.T, bgCommit bool) {
senderAddr: {Balance: new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)},
},
}
opts := []execmoduletester.Option{
m := execmoduletester.New(t,
execmoduletester.WithGenesisSpec(genesis),
execmoduletester.WithKey(privKey),
}
if bgCommit {
opts = append(opts, execmoduletester.WithFcuBackgroundCommit())
}
m := execmoduletester.New(t, opts...)
)

// Under background commit, a commit (including the genesis InsertBlocks inside
// New) lands asynchronously after the call returns. These polls let DB reads
// wait for the commit goroutine; both return immediately under foreground
// commit. Transient read errors are treated as "not ready yet" and retried.
// Transient read errors are treated as "not ready yet" and retried.
waitForGenesis := func() {
require.Eventually(t, func() bool {
var funded bool
Expand Down Expand Up @@ -2453,10 +2414,8 @@ func runBatchedFCUBadBlockRecovery(t *testing.T, bgCommit bool) {

// Phase 3: recovery — insert the real block 6 and FCU on it. This must
// succeed even though the bad-block FCU just closed the local
// SharedDomains. The persistent e.currentContext is either still
// pointing to the prior SD (foreground) or has been nil'd (background);
// both paths must let the next InsertBlocks re-initialize the overlay
// cleanly.
// SharedDomains: the persistent e.currentContext still points at the prior
// SD, and the next InsertBlocks must re-initialize the overlay cleanly.
recoverIns, err := m.InsertBlocks(ctx, []*types.Block{chainPack.Blocks[5]})
require.NoError(t, err, "InsertBlocks of the good block after a bad-block FCU must not error")
require.Equal(t, execmodule.ExecutionStatusSuccess, recoverIns)
Expand Down Expand Up @@ -2485,22 +2444,6 @@ func runBatchedFCUBadBlockRecovery(t *testing.T, bgCommit bool) {
}))
}

// TestInsertBlocksWithBatchedFCU_BadBlockRecovery_Foreground covers the
// foreground-commit cleanup path: a bad-block FCU closes the local
// SharedDomains while the persistent currentContext remains, and the next
// InsertBlocks must re-initialize the overlay on top of it.
func TestInsertBlocksWithBatchedFCU_BadBlockRecovery_Foreground(t *testing.T) {
runBatchedFCUBadBlockRecovery(t, false)
}

// TestInsertBlocksWithBatchedFCU_BadBlockRecovery_Background covers the
// background-commit cleanup path, where the bad-block FCU additionally resets
// currentContext. Commits land asynchronously, so the shared body polls
// committed state before asserting (see waitForGenesis/waitForBlock).
func TestInsertBlocksWithBatchedFCU_BadBlockRecovery_Background(t *testing.T) {
runBatchedFCUBadBlockRecovery(t, true)
}

// transferGen returns a deterministic per-block tx generator: identical
// inputs produce identical blocks, which lets tests build forks that share
// a prefix with the canonical chain (requires a pre-Cancun config — Cancun+
Expand Down
9 changes: 0 additions & 9 deletions execution/execmodule/execmoduletester/exec_module_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,6 @@ func WithoutAmsterdamBuilderContracts() Option {
}
}

func WithFcuBackgroundCommit() Option {
return func(opts *options) {
opts.fcuBackgroundCommit = true
}
}

// WithAlwaysGenerateChangesets pins --experimental.always-generate-changesets
// regardless of the tester default: true for tests that reorg deeper than
// MaxReorgDepth, false for tests that rely on the windowed-changesets
Expand Down Expand Up @@ -404,7 +398,6 @@ type options struct {
pruneMode *prune.Mode
withTxPool bool
enableDomains []kv.Domain
fcuBackgroundCommit bool
fcuBackgroundPrune bool
alwaysGenerateChangesets *bool
maxReorgDepth *uint64
Expand Down Expand Up @@ -521,7 +514,6 @@ func New(tb testing.TB, opts ...Option) *ExecModuleTester {
cfg.Prune = pruneMode
cfg.ExperimentalBAL = opt.experimentalBAL
cfg.FcuBackgroundPrune = opt.fcuBackgroundPrune
cfg.FcuBackgroundCommit = opt.fcuBackgroundCommit

logLvl := log.LvlError
if lvl, ok := os.LookupEnv("EXEC_MODULE_TESTER_LOG_LEVEL"); ok {
Expand Down Expand Up @@ -803,7 +795,6 @@ func New(tb testing.TB, opts ...Option) *ExecModuleTester {
engine,
cfg.Sync,
cfg.FcuBackgroundPrune,
cfg.FcuBackgroundCommit,
onlySnapDownloadOnStart,
readAheader,
func() error { return nil },
Expand Down
Loading
Loading