Skip to content

Commit

Permalink
fix: do not exit when end height does not exist yet (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
troykessler authored Apr 4, 2024
1 parent 68c7d3b commit 6697be9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions blocksync/blocksync.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func StartBlockSync(engine types.Engine, chainRest, storageRest string, poolId,
return StartDBExecutor(engine, chainRest, storageRest, poolId, targetHeight, metrics, port, 0, 0, utils.DefaultSnapshotServerPort, false, false, backupCfg)
}

func PerformBlockSyncValidationChecks(engine types.Engine, chainRest string, blockPoolId, targetHeight int64, userInput bool) error {
func PerformBlockSyncValidationChecks(engine types.Engine, chainRest string, blockPoolId, targetHeight int64, checkEndHeight, userInput bool) error {
continuationHeight, err := engine.GetContinuationHeight()
if err != nil {
return fmt.Errorf("failed to get continuation height from engine: %w", err)
Expand Down Expand Up @@ -48,7 +48,7 @@ func PerformBlockSyncValidationChecks(engine types.Engine, chainRest string, blo
return fmt.Errorf("requested target height is %d but app is already at block height %d", targetHeight, continuationHeight)
}

if targetHeight > 0 && targetHeight > endHeight {
if checkEndHeight && targetHeight > 0 && targetHeight > endHeight {
return fmt.Errorf("requested target height is %d but last available block on pool is %d", targetHeight, endHeight)
}

Expand Down Expand Up @@ -83,7 +83,7 @@ func StartBlockSyncWithBinary(engine types.Engine, binaryPath, homePath, chainId
utils.TrackSyncStartEvent(engine, utils.BLOCK_SYNC, chainId, chainRest, storageRest, targetHeight, optOut)

// perform validation checks before booting state-sync process
if err := PerformBlockSyncValidationChecks(engine, chainRest, blockPoolId, targetHeight, userInput); err != nil {
if err := PerformBlockSyncValidationChecks(engine, chainRest, blockPoolId, targetHeight, true, userInput); err != nil {
logger.Error().Msg(fmt.Sprintf("block-sync validation checks failed: %s", err))
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion heightsync/heightsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func StartHeightSyncWithBinary(engine types.Engine, binaryPath, homePath, chainI
logger.Info().Msg(fmt.Sprintf("target height not specified, searching for latest available block height"))
}

if err := blocksync.PerformBlockSyncValidationChecks(engine, chainRest, blockPoolId, targetHeight, false); err != nil {
if err := blocksync.PerformBlockSyncValidationChecks(engine, chainRest, blockPoolId, targetHeight, true, false); err != nil {
logger.Error().Msg(fmt.Sprintf("block-sync validation checks failed: %s", err))
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion servesnapshots/servesnapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func StartServeSnapshotsWithBinary(engine types.Engine, binaryPath, homePath, ch
}
}

if err := blocksync.PerformBlockSyncValidationChecks(engine, chainRest, blockPoolId, targetHeight, false); err != nil {
if err := blocksync.PerformBlockSyncValidationChecks(engine, chainRest, blockPoolId, targetHeight, false, false); err != nil {
logger.Error().Msg(fmt.Sprintf("block-sync validation checks failed: %s", err))
os.Exit(1)
}
Expand Down

0 comments on commit 6697be9

Please sign in to comment.