@@ -12,6 +12,7 @@ import (
1212
1313 cmtCfg "github.com/cometbft/cometbft/config"
1414 cmtProtoState "github.com/cometbft/cometbft/proto/tendermint/state"
15+ cmtstore "github.com/cometbft/cometbft/proto/tendermint/store"
1516 cmtProto "github.com/cometbft/cometbft/proto/tendermint/types"
1617 cmtState "github.com/cometbft/cometbft/state"
1718 "github.com/cometbft/cometbft/store"
@@ -420,11 +421,12 @@ func bootstrapTrustedState(dataDir string, meta bootstrapMeta) error {
420421 }
421422 defer stateDB .Close ()
422423
423- blockStore , err := openConsensusBlockstore (dataDir )
424+ blockStoreDB , err := openConsensusBlockstoreDB (dataDir )
424425 if err != nil {
425426 return fmt .Errorf ("failed to open consensus blockstore: %w" , err )
426427 }
427- defer blockStore .Close ()
428+ defer blockStoreDB .Close ()
429+ blockStore := store .NewBlockStore (blockStoreDB )
428430
429431 if ! blockStore .IsEmpty () {
430432 return fmt .Errorf ("blockstore not empty, trying to initialize non empty state" )
@@ -471,6 +473,19 @@ func bootstrapTrustedState(dataDir string, meta bootstrapMeta) error {
471473 return err
472474 }
473475
476+ // SaveSeenCommit (as used by the upstream) does not persist the BlockStoreState (height/base),
477+ // so we save it explicitly here. This ways the blockstore reports the correct height after bootstrap,
478+ // so that status works as expected. If this is not done, this blockstore base is kept as unitialized,
479+ // and is initialized as soon as the first block is fetche. However we would cut last retained height by 1,
480+ // which is the current case for consensus checkpoint sync.
481+ store .SaveBlockStoreState (
482+ & cmtstore.BlockStoreState {
483+ Base : metaState .LastBlockHeight ,
484+ Height : metaState .LastBlockHeight ,
485+ },
486+ blockStoreDB ,
487+ )
488+
474489 // Once the stores are bootstrapped, we need to set the height at which the node has finished
475490 // statesyncing. This will allow the blocksync reactor to fetch blocks at a proper height.
476491 // In case this operation fails, it is equivalent to a failure in online state sync where the operator
0 commit comments