Skip to content

Commit 4f1f09d

Browse files
committed
fix --payloadless mode for execution builder in remote ledger model
1 parent aa5d662 commit 4f1f09d

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

cmd/execution_builder.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -941,16 +941,16 @@ func (exeNode *ExecutionNode) LoadExecutionStateLedger(
941941
module.ReadyDoneAware,
942942
error,
943943
) {
944+
// Ledger selection is two independent choices passed to the factory:
945+
// - --payloadless picks the payloadless vs. full ledger (this branch).
946+
// - --ledger-service-addr (Config.LedgerServiceAddr), when set, means this
947+
// node connects to a remote ledger service rather than running a local
948+
// ledger; the factory then returns a gRPC client instead of a local one.
949+
// Combined: payloadless + remote address -> remote payloadless client;
950+
// payloadless + no address -> local payloadless ledger; likewise for full mode.
944951
if exeNode.exeConf.payloadless {
945952
// Payloadless mode. ValidateFlags enforces --enable-storehouse,
946953
// so the storehouse is the value source for reads.
947-
//
948-
// The factory call mirrors the full-mode call below: same Config,
949-
// same triggerCheckpoint. Today the factory body is a placeholder
950-
// (no WAL, no checkpoint load) — see TODOs at
951-
// ledgerfactory.NewPayloadlessLedger. When the WAL/checkpoint
952-
// pieces land, only the factory body changes; this call site stays
953-
// the same.
954954
pl, err := ledgerfactory.NewPayloadlessLedger(ledgerfactory.Config{
955955
LedgerServiceAddr: exeNode.exeConf.ledgerServiceAddr,
956956
LedgerMaxRequestSize: exeNode.exeConf.ledgerMaxRequestSize,
@@ -1501,11 +1501,16 @@ func (exeNode *ExecutionNode) LoadBootstrapper(node *NodeConfig) error {
15011501
// HasRootCheckpointV7 guard keeps a re-entry after an interrupted
15021502
// bootstrap from hitting ConvertCheckpointV6ToV7's "output exists" check.
15031503
//
1504+
// Only nodes running a local payloadless ledger need this: a node using a
1505+
// remote ledger service (ledgerServiceAddr set) never reads its local trie
1506+
// dir, and the remote ledger service performs its own V7 bootstrap. Skipping
1507+
// the conversion avoids a needless full-forest load on remote-ledger nodes.
1508+
//
15041509
// TODO: ConvertCheckpointV6ToV7 reads the entire V6 forest into memory
15051510
// before emitting V7, a memory/time spike at first boot for mainnet-scale
15061511
// root checkpoints. A future optimization is to convert subtrie-by-subtrie
15071512
// without loading the whole forest.
1508-
if exeNode.exeConf.payloadless {
1513+
if exeNode.exeConf.payloadless && exeNode.exeConf.ledgerServiceAddr == "" {
15091514
triedir := exeNode.exeConf.triedir
15101515
hasV7Root, err := wal.HasRootCheckpointV7(triedir)
15111516
if err != nil {

integration/localnet/builder/bootstrap.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,15 @@ func prepareExecutionService(container testnet.ContainerConfig, i int, n int) Se
483483
service.Volumes = append(service.Volumes,
484484
fmt.Sprintf("%s:/trie:z", trieDir),
485485
)
486-
if payloadless {
487-
service.Command = append(service.Command, "--payloadless")
488-
}
486+
}
487+
488+
// In payloadless mode, both remote-ledger and local-ledger execution nodes
489+
// must run payloadless. The flag selects the payloadless committer, state
490+
// checker, and ledger client. A remote-ledger node missing this flag would
491+
// build a full ledger.LedgerService client and fail against a payloadless
492+
// ledger service with "unknown service ledger.LedgerService".
493+
if payloadless {
494+
service.Command = append(service.Command, "--payloadless")
489495
}
490496

491497
// Payloadless mode requires storehouse to store the actual payloads

0 commit comments

Comments
 (0)