Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkpointing V6 - support concurrent checkpoint encoding/decoding #3273

Merged
merged 204 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
05b467d
small refactor node iterator, adding comments to checkpointer
zhangchiqing Aug 31, 2022
0ea8397
add StoreCheckpointConcurrently
zhangchiqing Sep 13, 2022
feeb9c4
add writer and reader
zhangchiqing Sep 15, 2022
487bd8f
add test cases
zhangchiqing Sep 16, 2022
a47b76b
add test cases
zhangchiqing Sep 19, 2022
fba0fa6
fix reader
zhangchiqing Sep 20, 2022
d89f768
fix GetNodeByIndex
zhangchiqing Sep 20, 2022
c209720
fix writer
zhangchiqing Sep 20, 2022
3e68cd5
fix tests
zhangchiqing Sep 20, 2022
9b57ae3
read checkpoint v6
zhangchiqing Sep 21, 2022
655968a
checkpoint header
zhangchiqing Sep 23, 2022
4de349c
read checksum
zhangchiqing Sep 23, 2022
7e40b8d
validating checksum
zhangchiqing Sep 24, 2022
1647022
save to v5
zhangchiqing Sep 26, 2022
8277cdb
add compare v5
zhangchiqing Sep 27, 2022
d0b10f0
support version
zhangchiqing Sep 27, 2022
cb4c40a
add more header
zhangchiqing Sep 27, 2022
76c35e1
log version
zhangchiqing Sep 28, 2022
ed9d3ec
revert payload conversion
zhangchiqing Sep 28, 2022
92f31b2
small refactor node iterator, adding comments to checkpointer
zhangchiqing Aug 31, 2022
cb588f3
add StoreCheckpointConcurrently
zhangchiqing Sep 13, 2022
db31973
add writer and reader
zhangchiqing Sep 15, 2022
a0e6e69
add test cases
zhangchiqing Sep 16, 2022
769078d
add test cases
zhangchiqing Sep 19, 2022
5c47a06
fix reader
zhangchiqing Sep 20, 2022
492cf79
fix GetNodeByIndex
zhangchiqing Sep 20, 2022
92d0abe
fix writer
zhangchiqing Sep 20, 2022
947bdb8
fix tests
zhangchiqing Sep 20, 2022
22bbef6
read checkpoint v6
zhangchiqing Sep 21, 2022
1a8e17d
update estimate size
zhangchiqing Sep 28, 2022
14f242d
Delete concurrent_checkpointer_test.go
zhangchiqing Sep 29, 2022
fa78215
remove debugging function
zhangchiqing Sep 29, 2022
04d0b0d
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-check-header
zhangchiqing Oct 3, 2022
b74ee03
Delete concurrent_checkpointer_test.go
zhangchiqing Oct 3, 2022
8805165
Apply suggestions from code review
zhangchiqing Oct 3, 2022
905e656
Merge branch 'master' into feature-checkpoint-v6
zhangchiqing Oct 3, 2022
db755de
fix linter
zhangchiqing Oct 3, 2022
30dc86c
compare checksum from checkpoint header and part files
zhangchiqing Oct 3, 2022
bdb24ac
check file all part file exist
zhangchiqing Oct 3, 2022
5d14ae2
add test case
zhangchiqing Oct 3, 2022
9a408bf
apply suggestion
zhangchiqing Oct 3, 2022
6bf7041
Apply suggestions from code review
zhangchiqing Oct 3, 2022
0776388
fix preallocation
zhangchiqing Oct 3, 2022
a85cee7
refactor estimateSubtrieNodeCount
zhangchiqing Oct 4, 2022
4a76c15
update error message
zhangchiqing Oct 4, 2022
0ac43f0
apply suggestion
zhangchiqing Oct 3, 2022
a421984
Apply suggestions from code review
zhangchiqing Oct 3, 2022
8dac3fc
fix preallocation
zhangchiqing Oct 3, 2022
c22bfe6
refactor estimateSubtrieNodeCount
zhangchiqing Oct 4, 2022
b9e451e
update error message
zhangchiqing Oct 4, 2022
99e69b2
check whether file exist already
zhangchiqing Oct 4, 2022
ee5f8e8
fix checking file exist
zhangchiqing Oct 4, 2022
ff685f3
add todo
zhangchiqing Oct 4, 2022
738a1bf
Merge branch 'feature-checkpoint-v6' of github.com:onflow/flow-go int…
zhangchiqing Oct 4, 2022
01343c3
delay the memory allocation
zhangchiqing Oct 4, 2022
b3028aa
refactor storeTries
zhangchiqing Oct 4, 2022
96b406b
fix test
zhangchiqing Oct 4, 2022
7b118aa
Merge branch 'leo/checkpoint-v6-check-header' into leo/checkpoint-v6-…
zhangchiqing Oct 4, 2022
7e29a0d
add EOF read check
zhangchiqing Sep 28, 2022
00b89cb
add test to check if checkpointing is determinstic
zhangchiqing Sep 28, 2022
2d044e8
add test case: TestWriteAndReadCheckpointV6ThenBackToV5
zhangchiqing Sep 28, 2022
8d3341f
add TestWriteAndReadCheckpointV6MultipleTries
zhangchiqing Sep 29, 2022
82ffc3b
add logger
zhangchiqing Sep 28, 2022
5066514
implement nWorker
zhangchiqing Sep 29, 2022
6b66f0c
log read progress
zhangchiqing Sep 29, 2022
7b73375
evict file after read
zhangchiqing Oct 4, 2022
693fce2
add version to part files
zhangchiqing Oct 4, 2022
4d0dd17
clean up temp files on error
zhangchiqing Oct 4, 2022
474d161
remove unnecessary checks
zhangchiqing Oct 4, 2022
14d6ec0
remove check
zhangchiqing Oct 4, 2022
814ca9e
evict header file
zhangchiqing Oct 4, 2022
17fbab8
Update ledger/complete/wal/checkpoint_v6_writer.go
zhangchiqing Oct 5, 2022
54278f3
refactor store footer
zhangchiqing Oct 5, 2022
f4c7ef5
refactor readVersion to readFielHeader and validateFileHeader
zhangchiqing Oct 5, 2022
6a3217a
refactor to encodeSubtrieCount
zhangchiqing Oct 5, 2022
124e786
add open and read checkpoint v6
zhangchiqing Oct 5, 2022
a4583f4
update comments
zhangchiqing Oct 5, 2022
5fe9138
clean up on error
zhangchiqing Oct 5, 2022
821bffa
refactor getNodeByIndex
zhangchiqing Oct 5, 2022
84d271f
Merge branch 'master' into feature-checkpoint-v6
zhangchiqing Oct 6, 2022
5dc8565
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-check-header
zhangchiqing Oct 6, 2022
d110787
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-check-par…
zhangchiqing Oct 6, 2022
c4a2eab
update error message
zhangchiqing Oct 6, 2022
7c8a8af
Merge branch 'leo/checkpoint-v6-check-header' into leo/checkpoint-v6-…
zhangchiqing Oct 6, 2022
a4e91e1
encode subtrie node count
zhangchiqing Oct 6, 2022
76a6be2
Merge branch 'master' into feature-checkpoint-v6
zhangchiqing Oct 6, 2022
c30d510
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-check-header
zhangchiqing Oct 6, 2022
b63e5d7
remove dir and filename from readCheckpoint
zhangchiqing Oct 6, 2022
e490de5
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-check-header
zhangchiqing Oct 6, 2022
0dff500
Merge branch 'leo/checkpoint-v6-check-header' into leo/checkpoint-v6-…
zhangchiqing Oct 6, 2022
f799ce7
revert changes to ReadNode
zhangchiqing Oct 6, 2022
7110a6f
Merge branch 'leo/checkpoint-v6-support-v5' into leo/checkpoint-v6-ad…
zhangchiqing Oct 6, 2022
fc3af6b
Merge branch 'leo/checkpoint-v6-add-eof-check' into leo/checkpoint-v6…
zhangchiqing Oct 6, 2022
07a388f
fix tests
zhangchiqing Oct 6, 2022
516da41
Merge branch 'leo/checkpoint-v6-add-more-tests' into leo/checkpoint-v…
zhangchiqing Oct 6, 2022
025b949
Merge branch 'leo/checkpoint-v6-control-concurrency' into leo/checkpo…
zhangchiqing Oct 6, 2022
b2012e8
fix linter
zhangchiqing Oct 6, 2022
128c883
remove sanity check
zhangchiqing Oct 6, 2022
9e10743
Merge branch 'leo/checkpoint-v6-check-header' into leo/checkpoint-v6-…
zhangchiqing Oct 6, 2022
09fd05f
refactor StoreCheckpoint inputs
zhangchiqing Oct 7, 2022
240d6a1
use multierror
zhangchiqing Oct 7, 2022
f90c195
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-check-header
zhangchiqing Oct 7, 2022
3cbdd05
Merge pull request #3319 from onflow/leo/checkpoint-v6-check-header
zhangchiqing Oct 7, 2022
376ca0e
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-check-par…
zhangchiqing Oct 7, 2022
35483a4
use findCheckpointPartFiles
zhangchiqing Oct 7, 2022
aebdb78
Merge pull request #3321 from onflow/leo/checkpoint-v6-check-part-fil…
zhangchiqing Oct 7, 2022
19f57b9
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-support-v5
zhangchiqing Oct 7, 2022
069a9d3
Merge pull request #3326 from onflow/leo/checkpoint-v6-support-v5
zhangchiqing Oct 7, 2022
78b80bd
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-add-eof-c…
zhangchiqing Oct 7, 2022
eff11cf
rename function
zhangchiqing Oct 7, 2022
378dd76
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-add-eof-c…
zhangchiqing Oct 7, 2022
fbe0c3b
Merge pull request #3327 from onflow/leo/checkpoint-v6-add-eof-check
zhangchiqing Oct 7, 2022
cad7197
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-add-more-…
zhangchiqing Oct 7, 2022
01993d9
update error message
zhangchiqing Oct 7, 2022
5ce31c2
Merge pull request #3328 from onflow/leo/checkpoint-v6-add-more-tests
zhangchiqing Oct 7, 2022
2860b4b
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-control-c…
zhangchiqing Oct 7, 2022
a80e348
fix conflict
zhangchiqing Oct 7, 2022
04326ff
Merge pull request #3329 from onflow/leo/checkpoint-v6-control-concur…
zhangchiqing Oct 7, 2022
d2c0963
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-evict-file
zhangchiqing Oct 7, 2022
f2d7f77
Merge pull request #3330 from onflow/leo/checkpoint-v6-evict-file
zhangchiqing Oct 7, 2022
1e56f88
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-add-versi…
zhangchiqing Oct 7, 2022
13c9b15
Merge pull request #3335 from onflow/leo/checkpoint-v6-add-version-to…
zhangchiqing Oct 7, 2022
bd9a6ca
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-refactor-…
zhangchiqing Oct 7, 2022
50817f6
Merge pull request #3336 from onflow/leo/checkpoint-v6-refactor-reade…
zhangchiqing Oct 7, 2022
5d5983e
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-cleanup-o…
zhangchiqing Oct 7, 2022
f1eff73
Merge pull request #3337 from onflow/leo/checkpoint-v6-cleanup-on-error
zhangchiqing Oct 7, 2022
d2a8e28
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-refactor-…
zhangchiqing Oct 7, 2022
5f8b45c
Merge pull request #3347 from onflow/leo/checkpoint-v6-refactor-get-n…
zhangchiqing Oct 7, 2022
bd2834d
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-encode-su…
zhangchiqing Oct 7, 2022
845e3a6
Merge pull request #3350 from onflow/leo/checkpoint-v6-encode-subtrie…
zhangchiqing Oct 7, 2022
5ac82ac
fix returning error
zhangchiqing Oct 11, 2022
146b635
fix test case
zhangchiqing Oct 11, 2022
4f52ca9
improve logging
zhangchiqing Oct 11, 2022
24a90f7
Merge branch 'master' into leo/refactor-store-checkpoint
zhangchiqing Oct 11, 2022
4b04eb8
remove writer
zhangchiqing Oct 11, 2022
c9cb8fd
Merge branch 'leo/refactor-store-checkpoint' into feature-checkpoint-v6
zhangchiqing Oct 11, 2022
f04252e
refactor file close error
zhangchiqing Oct 11, 2022
29643e3
flakey test
zhangchiqing Oct 11, 2022
33b21f6
use v6 fore regular checkpointing
zhangchiqing Oct 11, 2022
ad00691
fix lint
zhangchiqing Oct 11, 2022
2075fdd
support V6
zhangchiqing Oct 12, 2022
5a6e6ad
Merge branch 'feature-checkpoint-v6' into leo/checkpoint-v6-refactor-…
zhangchiqing Oct 12, 2022
141c9a5
log state extraction
zhangchiqing Oct 12, 2022
e5ee278
update log
zhangchiqing Oct 12, 2022
c9b8a43
use single thread during normal operation
zhangchiqing Oct 12, 2022
dcc130a
apply suggestion
zhangchiqing Oct 12, 2022
4b3daa3
Update ledger/complete/wal/checkpoint_v6_writer.go
zhangchiqing Oct 12, 2022
95c74cd
Apply suggestions from code review
zhangchiqing Oct 12, 2022
85bc2e0
address review comments
zhangchiqing Oct 12, 2022
483c086
Merge branch 'feature-checkpoint-v6' of github.com:onflow/flow-go int…
zhangchiqing Oct 12, 2022
c032f3a
fix encode decode func
zhangchiqing Oct 12, 2022
7ce9de2
Merge pull request #3368 from onflow/leo/checkpoint-v6-refactor-file-…
zhangchiqing Oct 12, 2022
976d36a
Merge branch 'feature-checkpoint-v6' of github.com:onflow/flow-go int…
zhangchiqing Oct 12, 2022
f486f82
lint
zhangchiqing Oct 12, 2022
769d4a0
Apply suggestions from code review
zhangchiqing Oct 12, 2022
67e0beb
update todo
zhangchiqing Oct 12, 2022
6ee9ad5
fix bug
zhangchiqing Oct 12, 2022
b7447ce
fix log
zhangchiqing Oct 12, 2022
e08e697
revert checkpointLoaded check
zhangchiqing Oct 12, 2022
d56e1ed
fix check and update comment
zhangchiqing Oct 12, 2022
d688ab6
slow down compactor
zhangchiqing Oct 12, 2022
3dec16e
log checkpoint file path
zhangchiqing Oct 13, 2022
29d4399
Rewrite benchmarks for storing/loading checkpoint
fxamacker Oct 13, 2022
b17d8ae
Remove temp benchmark output files
fxamacker Oct 13, 2022
4fa0517
Improve logs in checkpoint benchmarks
fxamacker Oct 13, 2022
bcb1989
revert closeAndMerge
zhangchiqing Oct 13, 2022
83eefa3
fix for empty trie
zhangchiqing Oct 13, 2022
71685b4
fix tests
zhangchiqing Oct 13, 2022
31d63ea
fix tests
zhangchiqing Oct 13, 2022
5350e8d
fix TestEncodeSubTrie tests
zhangchiqing Oct 13, 2022
bb166f7
Merge pull request #3377 from onflow/fxamacker/checkpoint-benchmarks
zhangchiqing Oct 13, 2022
3e52c31
Merge branch 'feature-checkpoint-v6' of github.com:onflow/flow-go int…
zhangchiqing Oct 13, 2022
3b1edd3
update ledger update delay
zhangchiqing Oct 13, 2022
5d732a0
Merge branch 'master' into feature-checkpoint-v6
zhangchiqing Oct 13, 2022
4c399f5
fix lint
zhangchiqing Oct 13, 2022
4890a4e
remove noneCheckpointFileExist
zhangchiqing Oct 13, 2022
44e630a
fix lint
zhangchiqing Oct 13, 2022
285927f
update state extraction log
zhangchiqing Oct 13, 2022
499619c
add outputVersion flag
zhangchiqing Oct 13, 2022
77be018
fix linter
zhangchiqing Oct 13, 2022
af61164
use checkpoint v5
zhangchiqing Oct 13, 2022
124f1c5
fix reading v6
zhangchiqing Oct 13, 2022
f8c81fe
use max version
zhangchiqing Oct 13, 2022
d87fcc9
fix remove checkpoint
zhangchiqing Oct 13, 2022
e1b7ef6
refactor concurrency
zhangchiqing Oct 13, 2022
f57527d
Merge branch 'master' into feature-checkpoint-v6
zhangchiqing Oct 13, 2022
abbfcf1
Apply suggestions from code review
zhangchiqing Oct 13, 2022
70108c4
remove compare checkpoint cmd
zhangchiqing Oct 13, 2022
9f2e00f
revert flatten encoding changes
zhangchiqing Oct 13, 2022
add5df7
remove compare checkpoint cmd
zhangchiqing Oct 13, 2022
982134a
refactor reader concurrency
zhangchiqing Oct 13, 2022
4c42f19
remove decoded
zhangchiqing Oct 13, 2022
5c23d4a
add instruction for benchmark
zhangchiqing Oct 14, 2022
6d1c77d
Merge branch 'master' into feature-checkpoint-v6
zhangchiqing Oct 14, 2022
af168ce
enable logging in reading checkpoint file in state extraction
zhangchiqing Oct 14, 2022
66e4036
rename benchmark
zhangchiqing Oct 14, 2022
d204903
logging the progress of reading checkpoint v5
zhangchiqing Oct 14, 2022
ad5fb5f
ensure checkpoint file exist
zhangchiqing Oct 14, 2022
d8c4e02
refactor part file name func
zhangchiqing Oct 15, 2022
9aabe4b
remove filePaths
zhangchiqing Oct 15, 2022
2fd443c
addressing review comments
zhangchiqing Oct 15, 2022
88636e3
remove check
zhangchiqing Oct 15, 2022
e1ab73b
test export checkpoint at for both version 5 and 6
zhangchiqing Oct 15, 2022
40e1658
Merge branch 'master' into feature-checkpoint-v6
zhangchiqing Oct 15, 2022
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
4 changes: 4 additions & 0 deletions cmd/execution_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,10 @@ func (exeNode *ExecutionNode) LoadExecutionStateLedger(
return nil, fmt.Errorf("failed to initialize wal: %w", err)
}

if exeNode.exeConf.outputCheckpointV5 {
exeNode.diskWAL.UseCheckpointVersion5()
}

exeNode.ledgerStorage, err = ledger.NewLedger(exeNode.diskWAL, int(exeNode.exeConf.mTrieCacheSize), exeNode.collector, node.Logger.With().Str("subcomponent",
"ledger").Logger(), ledger.DefaultPathFinderVersion)
return exeNode.ledgerStorage, err
Expand Down
2 changes: 2 additions & 0 deletions cmd/execution_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type ExecutionConfig struct {
transactionResultsCacheSize uint
checkpointDistance uint
checkpointsToKeep uint
outputCheckpointV5 bool
stateDeltasLimit uint
chunkDataPackCacheSize uint
chunkDataPackRequestsCacheSize uint32
Expand Down Expand Up @@ -63,6 +64,7 @@ func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet) {
flags.Uint32Var(&exeConf.mTrieCacheSize, "mtrie-cache-size", 500, "cache size for MTrie")
flags.UintVar(&exeConf.checkpointDistance, "checkpoint-distance", 20, "number of WAL segments between checkpoints")
flags.UintVar(&exeConf.checkpointsToKeep, "checkpoints-to-keep", 5, "number of recent checkpoints to keep (0 to keep all)")
flags.BoolVar(&exeConf.outputCheckpointV5, "outputCheckpointV5", false, "output checkpoint file in v5")
fxamacker marked this conversation as resolved.
Show resolved Hide resolved
flags.UintVar(&exeConf.stateDeltasLimit, "state-deltas-limit", 100, "maximum number of state deltas in the memory pool")
flags.UintVar(&exeConf.computationConfig.ProgramsCacheSize, "cadence-execution-cache", programs.DefaultProgramsCacheSize,
"cache size for Cadence execution")
Expand Down
49 changes: 47 additions & 2 deletions cmd/util/cmd/execution-state-extract/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
flagChain string
flagNoMigration bool
flagNoReport bool
flagVersion int
fxamacker marked this conversation as resolved.
Show resolved Hide resolved
)

func getChain(chainName string) (chain flow.Chain, err error) {
Expand Down Expand Up @@ -70,6 +71,8 @@ func init() {

Cmd.Flags().BoolVar(&flagNoReport, "no-report", false,
"don't report the state")

Cmd.Flags().IntVar(&flagVersion, "version", 6, "checkpoint version")
}

func run(*cobra.Command, []string) {
Expand All @@ -86,6 +89,8 @@ func run(*cobra.Command, []string) {
log.Fatal().Err(err).Msg("malformed block hash")
}

log.Info().Msgf("extracting state by block ID: %v", blockID)

db := common.InitStorage(flagDatadir)
defer db.Close()

Expand All @@ -94,7 +99,7 @@ func run(*cobra.Command, []string) {

stateCommitment, err = getStateCommitment(commits, blockID)
if err != nil {
log.Fatal().Err(err).Msg("cannot get state commitment for block")
log.Fatal().Err(err).Msgf("cannot get state commitment for block %v", blockID)
}
}

Expand All @@ -108,6 +113,8 @@ func run(*cobra.Command, []string) {
if err != nil {
log.Fatal().Err(err).Msg("invalid state commitment length")
}

log.Info().Msgf("extracting state by state commitment: %x", stateCommitment)
}

if len(flagBlockHash) == 0 && len(flagStateCommitment) == 0 {
Expand All @@ -130,7 +137,20 @@ func run(*cobra.Command, []string) {
}
}

log.Info().Msgf("Block state commitment: %s", hex.EncodeToString(stateCommitment[:]))
log.Info().Msgf("Extracting state from %s, exporting root checkpoint to %s, version: %v",
flagExecutionStateDir,
path.Join(flagOutputDir, bootstrap.FilenameWALRootCheckpoint),
flagVersion)

log.Info().Msgf("Block state commitment: %s from %v, output dir: %s",
hex.EncodeToString(stateCommitment[:]),
flagExecutionStateDir,
flagOutputDir)

// err := ensureCheckpointFileExist(flagExecutionStateDir)
// if err != nil {
// log.Fatal().Err(err).Msgf("cannot ensure checkpoint file exist in folder %v", flagExecutionStateDir)
// }

chain, err := getChain(flagChain)
if err != nil {
Expand All @@ -143,6 +163,7 @@ func run(*cobra.Command, []string) {
flagOutputDir,
log.Logger,
chain,
flagVersion,
!flagNoMigration,
!flagNoReport,
)
Expand All @@ -151,3 +172,27 @@ func run(*cobra.Command, []string) {
log.Fatal().Err(err).Msgf("error extracting the execution state: %s", err.Error())
}
}

// func ensureCheckpointFileExist(dir string) error {
// checkpoints, err := wal.Checkpoints(dir)
// if err != nil {
// return fmt.Errorf("could not find checkpoint files: %v", err)
// }
//
// if len(checkpoints) != 0 {
// log.Info().Msgf("found checkpoint %v files: %v", len(checkpoints), checkpoints)
// return nil
// }
//
// has, err := wal.HasRootCheckpoint(dir)
// if err != nil {
// return fmt.Errorf("could not check has root checkpoint: %w", err)
// }
//
// if has {
// log.Info().Msg("found root checkpoint file")
// return nil
// }
//
// return fmt.Errorf("no checkpoint file was found, no root checkpoint file was found")
// }
14 changes: 12 additions & 2 deletions cmd/util/cmd/execution-state-extract/execution_state_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ func extractExecutionState(
outputDir string,
log zerolog.Logger,
chain flow.Chain,
version int, // to be removed after next spork
migrate bool,
report bool,
) error {

log.Info().Msg("init WAL")

diskWal, err := wal.NewDiskWAL(
zerolog.Nop(),
log,
nil,
metrics.NewNoopCollector(),
dir,
Expand All @@ -45,6 +48,8 @@ func extractExecutionState(
return fmt.Errorf("cannot create disk WAL: %w", err)
}

log.Info().Msg("init ledger")

led, err := complete.NewLedger(
diskWal,
complete.DefaultCacheSize,
Expand All @@ -60,11 +65,15 @@ func extractExecutionState(
checkpointsToKeep = 1
)

compactor, err := complete.NewCompactor(led, diskWal, zerolog.Nop(), complete.DefaultCacheSize, checkpointDistance, checkpointsToKeep, atomic.NewBool(false))
log.Info().Msg("init compactor")

compactor, err := complete.NewCompactor(led, diskWal, log, complete.DefaultCacheSize, checkpointDistance, checkpointsToKeep, atomic.NewBool(false))
if err != nil {
return fmt.Errorf("cannot create compactor: %w", err)
}

log.Info().Msgf("waiting for compactor to load checkpoint and WAL")

<-compactor.Ready()

defer func() {
Expand Down Expand Up @@ -116,6 +125,7 @@ func extractExecutionState(
complete.DefaultPathFinderVersion,
outputDir,
bootstrap.FilenameWALRootCheckpoint,
version,
)
if err != nil {
return fmt.Errorf("cannot generate the output checkpoint: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestExtractExecutionState(t *testing.T) {
outdir,
zerolog.Nop(),
flow.Emulator.Chain(),
6,
false,
false,
)
Expand Down
Loading