Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d7bbe14
rpc/jsonrpc, node/ethconfig: enable FcuBackgroundCommit by default
yperbasis May 19, 2026
58f5877
execution/execmodule: unskip TestNotificationDispatchBackgroundCommit
yperbasis May 19, 2026
9e61f87
cmd/utils/app: wait for FCU bg-commit in import path before WriteHead…
yperbasis May 19, 2026
d0a8e31
rpc/jsonrpc: fix head-vs-data inconsistency in bg-commit-aware reads
yperbasis May 20, 2026
79ce7d9
rpc/jsonrpc: revert head-overlay wrap where dependent reads are plain-tx
yperbasis May 20, 2026
b487340
rpc/jsonrpc: guard nil ReadCurrentBlockNumber in parity_listStorageKeys
yperbasis May 20, 2026
85d168b
rpc/jsonrpc: resolve latest tag on plain tx in log-range scans
yperbasis May 20, 2026
7c7ac1f
rpc/jsonrpc: route block-table head reads through overlay in GetBlock…
yperbasis May 20, 2026
1688f79
node/ethconfig, rpc/jsonrpc, cmd/utils, docs: clarify FcuBackgroundCo…
yperbasis May 20, 2026
ab060ab
db/kv/membatchwithdb, db/state/execctx, rpc/rpchelper: document overl…
yperbasis May 20, 2026
51a2426
rpc/rpchelper: tolerate nil filters in _GetBlockNumber pending branch
yperbasis May 20, 2026
cbc2a70
rpc/jsonrpc: drop eth_system overlay wrap superseded by #22006
yperbasis Jul 6, 2026
6b4b6a6
cmd/rpcdaemon, docs: default to the version-keyed Coherent state cache
yperbasis Jul 6, 2026
0672f47
engineapi: tolerate Busy when executing downloaded batches
yperbasis Jul 6, 2026
9eb4bc4
rpc/jsonrpc: reuse BaseAPI header helpers in bor GetAuthor
yperbasis Jul 6, 2026
92aa2a4
db, rpc, node, cmd, execution: condense FcuBackgroundCommit comments
yperbasis Jul 6, 2026
da6aada
Merge branch 'main' into alex/fcu_bg_commit_35
yperbasis Jul 6, 2026
798d1a9
docs: regenerate llms-full.txt for state.cache flag change
yperbasis Jul 6, 2026
9ba4e1e
node/ethconfig, docs: keep FcuBackgroundCommit off by default
yperbasis Jul 6, 2026
ee6c097
execution, db, rpc: state-version parity, kvcache hardening, committe…
yperbasis Jul 6, 2026
3f13294
db/kv/kvcache: key batch feeds for readers, stop cross-block root car…
yperbasis Jul 6, 2026
f85cc6c
cmd/rpcdaemon, docs: keep --state.cache default at 0MB
yperbasis Jul 6, 2026
a458dd9
db/kv/kvcache: refresh codeEvict, not stateEvict, on code-domain cach…
yperbasis Jul 6, 2026
3feb08a
Merge remote-tracking branch 'origin/main' into alex/fcu_bg_commit_35
yperbasis Jul 7, 2026
0c94527
rpc/jsonrpc, execution/execmodule: committed-view debug_accountAt, ov…
yperbasis Jul 7, 2026
5b052eb
rpc/jsonrpc: return nil result on error in debug_accountAt
yperbasis Jul 7, 2026
d9ea9d3
Merge branch 'main' into alex/fcu_bg_commit_35
yperbasis Jul 7, 2026
7f8a297
Merge branch 'main' into alex/fcu_bg_commit_35
yperbasis Jul 10, 2026
d463e77
rpc: pin overlay view across block reads
yperbasis Jul 15, 2026
d3f9e9a
rpc: keep eth_getProof on one read snapshot
yperbasis Jul 15, 2026
dd23ad5
Merge branch 'main' into alex/fcu_bg_commit_35
yperbasis Jul 15, 2026
a5900d8
db/kv/kvcache, rpc/rpchelper: require GetAsOf on cache views
yperbasis Jul 15, 2026
27eb22f
db/kv/kvcache: remove obsolete canonical root state
yperbasis Jul 15, 2026
4f628ec
db/kv/kvcache: centralize coherent root initialization
yperbasis Jul 15, 2026
a7082f4
rpc/jsonrpc: reuse resolved block in eth_getProof
yperbasis Jul 15, 2026
8f04ba0
rpc, cmd, docs: clarify block lookup and commit wording
yperbasis Jul 15, 2026
3c142a7
db/kv/kvcache: drop dead evict-list re-feed in advanceRoot
yperbasis Jul 15, 2026
03df20f
engineapi: make retryBusy backoff unconditional
yperbasis Jul 15, 2026
9a761c2
db/kv/membatchwithdb: enforce memStore backing via memTx's type
yperbasis Jul 15, 2026
7b2eff4
rpc: pin eth_getProof reads to DB snapshot
yperbasis Jul 15, 2026
20cac1a
db/kv/kvcache: bound retained root memory
yperbasis Jul 15, 2026
fb1c204
cmd/rpcdaemon: keep zero-budget state reads coherent
yperbasis Jul 15, 2026
571f398
rpc: resolve log block hashes on committed view
yperbasis Jul 15, 2026
a202073
rpc: allow genesis state proofs
yperbasis Jul 15, 2026
b014604
rpc: restore genesis proof rejection
yperbasis Jul 15, 2026
d59b0f7
rpc: handle missing eth_getProof header
yperbasis Jul 15, 2026
952e7bd
docs: align --state.cache zero-value text with the flag help
yperbasis Jul 16, 2026
1207459
db/kv/kvcache: skip cache machinery at zero budget
yperbasis Jul 16, 2026
2b9f03c
rpc/jsonrpc: resolve getLogs block-hash filter via HeaderNumber
yperbasis Jul 16, 2026
30a01bc
Merge remote-tracking branch 'origin/main' into alex/fcu_bg_commit_35
yperbasis Jul 16, 2026
0fb6db2
rpc/rpchelper: clarify the GetBlockNumber filters contract
yperbasis Jul 16, 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
22 changes: 11 additions & 11 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func RootCommand() (*cobra.Command, *httpcfg.HttpCfg) {
rootCmd.PersistentFlags().BoolVar(&cfg.GethCompatibility, "rpc.gethcompat", false, "Enables Geth-compatible storage iteration order for debug_storageRangeAt (sorted by keccak256 hash). Disabled by default for performance.")
rootCmd.PersistentFlags().StringVar(&cfg.TxPoolApiAddr, "txpool.api.addr", "", "txpool api network address, for example: 127.0.0.1:9090 (default: use value of --private.api.addr)")

rootCmd.PersistentFlags().StringVar(&stateCacheStr, "state.cache", "0MB", "Amount of data to store in StateCache (enabled if no --datadir set). Set 0 to disable StateCache. Defaults to 0MB RAM")
rootCmd.PersistentFlags().StringVar(&stateCacheStr, "state.cache", "0MB", "Amount of data to store in the version-keyed StateCache (an equally-sized code cache is budgeted on top). Set 0 to disable entry retention while preserving snapshot-consistent reads")
rootCmd.PersistentFlags().BoolVar(&cfg.GRPCServerEnabled, "grpc", false, "Enable GRPC server")
rootCmd.PersistentFlags().StringVar(&cfg.GRPCListenAddress, "grpc.addr", nodecfg.DefaultGRPCHost, "GRPC server listening interface")
rootCmd.PersistentFlags().IntVar(&cfg.GRPCPort, "grpc.port", nodecfg.DefaultGRPCPort, "GRPC server listening port")
Expand Down Expand Up @@ -242,6 +242,13 @@ type StateChangesClient interface {
StateChanges(ctx context.Context, in *remoteproto.StateChangeRequest, opts ...grpc.CallOption) (remoteproto.KV_StateChangesClient, error)
}

func newRemoteStateCache(cfg kvcache.CoherentConfig) kvcache.Cache {
if cfg.CacheSize == 0 && cfg.CodeCacheSize == 0 {
cfg.WaitForNewBlock = false
}
return kvcache.New(cfg)
}

func subscribeToStateChangesLoop(ctx context.Context, client StateChangesClient, cache kvcache.Cache) {
go func() {
for {
Expand Down Expand Up @@ -334,11 +341,8 @@ func EmbeddedServices(ctx context.Context,
// the overlay is always current, has zero memory overhead, and
// doesn't need the StateChanges gRPC stream to stay coherent.
stateCache = stateCacheCfg.LocalCache
} else if stateCacheCfg.CacheSize > 0 {
// Remote RPCDaemon: use coherent cache fed by StateChanges stream.
stateCache = kvcache.New(stateCacheCfg)
} else {
stateCache = kvcache.NewSimple()
stateCache = newRemoteStateCache(stateCacheCfg)
}

subscribeToStateChangesLoop(ctx, stateDiffClient, stateCache)
Expand Down Expand Up @@ -530,22 +534,18 @@ func RemoteServices(ctx context.Context, cfg *httpcfg.HttpCfg, logger log.Logger
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, err
}
stateCache = kvcache.NewSimple()
}
// If DB can't be configured - used PrivateApiAddr as remote DB
if db == nil {
db = remoteKv
}

if !cfg.WithDatadir {
if cfg.StateCache.CacheSize > 0 {
stateCache = kvcache.New(cfg.StateCache)
} else {
stateCache = kvcache.NewSimple()
}
logger.Info("if you run RPCDaemon on same machine with Erigon add --datadir option")
}

stateCache = newRemoteStateCache(cfg.StateCache)

subscribeToStateChangesLoop(ctx, remoteKvClient, stateCache)

txpoolConn := conn
Expand Down
61 changes: 61 additions & 0 deletions cmd/rpcdaemon/cli/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@ import (
"github.com/holiman/uint256"
"github.com/stretchr/testify/require"

"github.com/erigontech/erigon/common"
"github.com/erigontech/erigon/common/log/v3"
"github.com/erigontech/erigon/db/datadir"
"github.com/erigontech/erigon/db/kv"
"github.com/erigontech/erigon/db/kv/kvcache"
"github.com/erigontech/erigon/db/kv/temporal/temporaltest"
"github.com/erigontech/erigon/db/state/execctx"
"github.com/erigontech/erigon/execution/chain"
"github.com/erigontech/erigon/execution/protocol/rules/ethash"
"github.com/erigontech/erigon/execution/protocol/rules/merge"
"github.com/erigontech/erigon/execution/types"
"github.com/erigontech/erigon/execution/types/accounts"
"github.com/erigontech/erigon/node/gointerfaces"
"github.com/erigontech/erigon/node/gointerfaces/remoteproto"
)

// TestIsWebsocket tests if an incoming websocket upgrade request is detected properly.
Expand Down Expand Up @@ -70,3 +79,55 @@ func TestRemoteRulesEngineFinalizeDelegates(t *testing.T) {
require.NoError(t, err)
})
}

func TestZeroBudgetRemoteCachePinsCommittedState(t *testing.T) {
cfg := kvcache.DefaultCoherentConfig
cfg.CacheSize = 0
cfg.CodeCacheSize = 0
cache := newRemoteStateCache(cfg)

db := temporaltest.NewTestDB(t, datadir.New(t.TempDir()))
addr := common.Address{1}
committedAccount := accounts.Account{Nonce: 1, Balance: *uint256.NewInt(1), CodeHash: accounts.EmptyCodeHash}
announcedAccount := committedAccount
announcedAccount.Nonce = 2
committedData := accounts.SerialiseV3(&committedAccount)
announcedData := accounts.SerialiseV3(&announcedAccount)

require.NoError(t, db.UpdateTemporal(t.Context(), func(tx kv.TemporalRwTx) error {
domains, err := execctx.NewSharedDomains(t.Context(), tx, log.New())
if err != nil {
return err
}
defer domains.Close()
if err := domains.DomainPut(kv.AccountsDomain, tx, addr[:], committedData, 0, nil); err != nil {
return err
}
return domains.Flush(t.Context(), tx)
}))

tx, err := db.BeginTemporalRo(t.Context())
require.NoError(t, err)
defer tx.Rollback()
stateVersion, err := tx.ReadSequence(string(kv.PlainStateVersion))
require.NoError(t, err)

cache.OnNewBlock(&remoteproto.StateChangeBatch{
StateVersionId: stateVersion + 1,
ChangeBatch: []*remoteproto.StateChange{{
Direction: remoteproto.Direction_FORWARD,
Changes: []*remoteproto.AccountChange{{
Action: remoteproto.Action_UPSERT,
Address: gointerfaces.ConvertAddressToH160(addr),
Data: announcedData,
}},
}},
})
require.Zero(t, cache.Len())

view, err := cache.View(t.Context(), tx)
require.NoError(t, err)
data, err := view.Get(addr[:])
require.NoError(t, err)
require.Equal(t, committedData, data)
}
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
Loading
Loading