Skip to content

Commit

Permalink
fix: BootstrapState use custom genesis doc provider (backport: cometb…
Browse files Browse the repository at this point in the history
…ft#2791)

The cosmos-sdk 0.50 genesis doc marshalling not being compatible with the
cometbft default one (see cosmos/cosmos-sdk#18477),
so we need to support custom genesis doc provider in this public API as well,
it's called by the `bootstrap-state` command in cosmos-sdk.
  • Loading branch information
yihuang committed Apr 12, 2024
1 parent 575b889 commit a1e0d12
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,16 @@ func StateProvider(stateProvider statesync.StateProvider) Option {
// store are empty at the time the function is called.
//
// If the block store is not empty, the function returns an error.
func BootstrapState(ctx context.Context, config *cfg.Config, dbProvider cfg.DBProvider, height uint64, appHash []byte) (err error) {
func BootstrapState(ctx context.Context, config *cfg.Config, dbProvider cfg.DBProvider, height uint64, appHash []byte) error {
return BootstrapStateWithGenProvider(ctx, config, dbProvider, DefaultGenesisDocProviderFunc(config), height, appHash)
}

// BootstrapStateWithGenProvider synchronizes the stores with the application after state sync
// has been performed offline. It is expected that the block store and state
// store are empty at the time the function is called.
//
// If the block store is not empty, the function returns an error.
func BootstrapStateWithGenProvider(ctx context.Context, config *cfg.Config, dbProvider cfg.DBProvider, genProvider GenesisDocProvider, height uint64, appHash []byte) (err error) {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
if ctx == nil {
ctx = context.Background()
Expand Down Expand Up @@ -193,7 +202,7 @@ func BootstrapState(ctx context.Context, config *cfg.Config, dbProvider cfg.DBPr
return fmt.Errorf("state not empty, trying to initialize non empty state")
}

genState, _, err := LoadStateFromDBOrGenesisDocProvider(stateDB, DefaultGenesisDocProviderFunc(config))
genState, _, err := LoadStateFromDBOrGenesisDocProvider(stateDB, genProvider)
if err != nil {
return err
}
Expand Down

0 comments on commit a1e0d12

Please sign in to comment.