Skip to content

Commit aa5d662

Browse files
committed
auto convert v7 root checkpoint in payloadless mode for localnet
1 parent a562fe7 commit aa5d662

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

integration/localnet/builder/bootstrap.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"time"
1616

1717
"github.com/go-yaml/yaml"
18+
"github.com/rs/zerolog"
1819

1920
"github.com/onflow/flow-go/cmd/build"
2021
"github.com/onflow/flow-go/ledger/complete/wal"
@@ -862,6 +863,32 @@ func prepareLedgerService(dockerServices Services, flowNodeContainerConfigs []te
862863
// Create symlinks for V7 checkpoint (payloadless)
863864
v7Filename := bootstrapFilenames.FilenameWALRootCheckpoint + wal.V7FileSuffix
864865
checkpointSourceV7 := filepath.Join(bootstrapExecutionStateDir, v7Filename)
866+
867+
// In payloadless mode a spork only produces a V6 root.checkpoint, and the
868+
// ledger service has no bootstrapper of its own to convert it. Convert the V6
869+
// root checkpoint into a V7 root checkpoint here (once, at bootstrap time);
870+
// the symlink block below then seeds the ledger service's trie directory from
871+
// it. On restart the ledger factory finds an existing V7 checkpoint (this root
872+
// or a newer numbered one written by the compactor), so no conversion is
873+
// needed at runtime. The os.Stat guard makes a re-run of `make bootstrap`
874+
// idempotent and avoids ConvertCheckpointV6ToV7's "output exists" rejection.
875+
if payloadless {
876+
if _, err := os.Stat(checkpointSourceV7); errors.Is(err, fs.ErrNotExist) {
877+
logger := zerolog.New(os.Stderr).With().Timestamp().Logger()
878+
if convertErr := wal.ConvertCheckpointV6ToV7(
879+
bootstrapExecutionStateDir,
880+
bootstrapFilenames.FilenameWALRootCheckpoint,
881+
bootstrapExecutionStateDir,
882+
v7Filename,
883+
logger,
884+
16,
885+
); convertErr != nil {
886+
panic(fmt.Errorf("failed to convert V6 root checkpoint to V7 for payloadless ledger service: %w", convertErr))
887+
}
888+
fmt.Printf("converted V6 root checkpoint to V7 in %s\n", bootstrapExecutionStateDir)
889+
}
890+
}
891+
865892
if _, err := os.Stat(checkpointSourceV7); err == nil {
866893
// V7 checkpoint exists, create symlinks on host
867894
_, err = wal.SoftlinkCheckpointFile(v7Filename, bootstrapExecutionStateDir, trieDir)

0 commit comments

Comments
 (0)