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
8 changes: 7 additions & 1 deletion cmd/utils/app/import_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ func InsertChain(ethereum *eth.Ethereum, chain *blockgen.ChainPack, setHead bool
}

// UpdateForkChoice has an async commit so we need to wait to make sure
// it is completed before assuming all state changes etc are inserted
// it is completed before assuming all state changes etc are inserted.
// State-change events are dispatched pre-commit, so waiting on the stream
// only ensures the dispatcher fired — not that MDBX is flushed.
var lastSeenBlock uint64
for len(insertedBlocks) > 0 {
req, err := stream.Recv()
Expand Down Expand Up @@ -445,6 +447,10 @@ func InsertChain(ethereum *eth.Ethereum, chain *blockgen.ChainPack, setHead bool
}
}

// Wait for the FCU background commit so HeadBlockHash can't land in MDBX
// ahead of the header it points to.
ethereum.ExecutionModule().WaitIdle(ethereum.SentryCtx())

return ethereum.ChainDB().Update(ethereum.SentryCtx(), func(tx kv.RwTx) error {
rawdb.WriteHeadBlockHash(tx, lvh)
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ var (
}
FcuBackgroundCommitFlag = cli.BoolFlag{
Name: "fcu.background.commit",
Usage: "Enables background flush and commit",
Usage: "Return FCU response before MDBX flush+commit lands (commit runs in background; remote rpcdaemon 'latest' stays consistent but can lag for the commit duration)",
Value: ethconfig.Defaults.FcuBackgroundCommit,
}
MCPDisableFlag = cli.BoolFlag{
Expand Down
2 changes: 1 addition & 1 deletion docs/site/docs/fundamentals/configuring-erigon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ 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.
* `--fcu.background.commit`: Returns the FCU response before MDBX flush+commit lands (commit runs in background; remote `rpcdaemon` `latest` stays consistent but can lag for the commit duration).
* Default: `false`

### Execution
Expand Down
2 changes: 1 addition & 1 deletion docs/site/static/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ 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.
* `--fcu.background.commit`: Returns the FCU response before MDBX flush+commit lands (commit runs in background; remote `rpcdaemon` `latest` stays consistent but can lag for the commit duration).
* Default: `false`

### Execution
Expand Down
29 changes: 27 additions & 2 deletions execution/engineapi/engine_block_downloader/block_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,31 @@ func (e *EngineBlockDownloader) downloadBlocks(ctx context.Context, req Backward
return nil
}

// retryBusy re-invokes call while it reports ExecutionStatusBusy (a background
// FCU commit briefly holds the exec semaphore), polling every 50ms and logging
// periodically so a stuck commit surfaces instead of hanging silently.
func (e *EngineBlockDownloader) retryBusy(ctx context.Context, label string, call func() (execmodule.ExecutionStatus, *string, common.Hash, error)) (execmodule.ExecutionStatus, *string, common.Hash, error) {
status, validationErr, lastValidHash, err := call()
logEvery := time.NewTicker(5 * time.Second)
defer logEvery.Stop()
for err == nil && status == execmodule.ExecutionStatusBusy {
if err := common.Sleep(ctx, 50*time.Millisecond); err != nil {
return status, validationErr, lastValidHash, err
}
select {
case <-logEvery.C:
e.logger.Debug("[EngineBlockDownloader] execution busy - retrying", "label", label)
default:
}
status, validationErr, lastValidHash, err = call()
}
return status, validationErr, lastValidHash, err
}

func (e *EngineBlockDownloader) execDownloadedBatch(ctx context.Context, block *types.Block, requested common.Hash) error {
status, validationErr, lastValidHash, err := e.chainRW.ValidateChain(ctx, block.Hash(), block.NumberU64())
status, validationErr, lastValidHash, err := e.retryBusy(ctx, "ValidateChain", func() (execmodule.ExecutionStatus, *string, common.Hash, error) {
return e.chainRW.ValidateChain(ctx, block.Hash(), block.NumberU64())
})
if err != nil {
return err
}
Expand All @@ -297,7 +320,9 @@ func (e *EngineBlockDownloader) execDownloadedBatch(ctx context.Context, block *
lastValidHash,
)
}
fcuStatus, _, lastValidHash, err := e.chainRW.UpdateForkChoice(ctx, block.Hash(), common.Hash{}, common.Hash{}, 0)
fcuStatus, _, lastValidHash, err := e.retryBusy(ctx, "UpdateForkChoice", func() (execmodule.ExecutionStatus, *string, common.Hash, error) {
return e.chainRW.UpdateForkChoice(ctx, block.Hash(), common.Hash{}, common.Hash{}, 0)
})
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ 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.
* `--fcu.background.commit`: Returns the FCU response before MDBX flush+commit lands (commit runs in background; remote `rpcdaemon` `latest` stays consistent but can lag for the commit duration).
* Default: `false`

### Execution
Expand Down
10 changes: 7 additions & 3 deletions node/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ var Defaults = Config{
ProduceE2: true,
ProduceE3: true,
},
FcuTimeout: 1 * time.Second,
FcuBackgroundPrune: true,
FcuBackgroundCommit: false, // to enable, we need to 1) have rawdb API go via execctx and 2) revive Coherent cache for rpcdaemon
FcuTimeout: 1 * time.Second,
FcuBackgroundPrune: true,
// FcuBackgroundCommit returns the FCU response before the MDBX commit
// lands; the commit runs in a background goroutine and successive FCUs are
// serialized by the ExecModule semaphore. "Latest" state reads can lag the
// announced head by one block for the commit's duration.
FcuBackgroundCommit: false,
ExperimentalBAL: false,
WarmupKzgCtxOnInit: true,
}
Expand Down
Loading