Skip to content

Commit

Permalink
modify app genesis, store, then continue prev logic
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Feb 9, 2024
1 parent 66355b3 commit 25bee82
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,21 @@ func testnetify(ctx *Context, home string, testnetAppCreator types.AppCreator, d
return nil, fmt.Errorf("expected string for key %s", KeyNewChainID)
}

// Modify app genesis chain ID and save to genesis file.
genFilePath := config.GenesisFile()
appGen, err := genutiltypes.AppGenesisFromFile(genFilePath)
if err != nil {
return nil, err
}
appGen.ChainID = newChainID
if err := appGen.ValidateAndComplete(); err != nil {
return nil, err
}
if err := appGen.SaveAs(genFilePath); err != nil {
return nil, err
}

// Load the comet genesis doc provider.
genDocProvider := node.DefaultGenesisDocProviderFunc(config)

// Initialize blockStore and stateDB.
Expand Down Expand Up @@ -755,16 +770,6 @@ func testnetify(ctx *Context, home string, testnetAppCreator types.AppCreator, d
return nil, err
}

// Modify genesis chain ID and save to genesis file.
genDoc.ChainID = newChainID
genFilePath := config.GenesisFile()
if err := genDoc.ValidateAndComplete(); err != nil {
return nil, err
}
if err := genDoc.SaveAs(genFilePath); err != nil {
return nil, err
}

ctx.Viper.Set(KeyNewValAddr, validatorAddress)
ctx.Viper.Set(KeyUserPubKey, userPubKey)
testnetApp := testnetAppCreator(ctx.Logger, db, traceWriter, ctx.Viper)
Expand Down Expand Up @@ -911,6 +916,7 @@ func testnetify(ctx *Context, home string, testnetAppCreator types.AppCreator, d
return nil, err
}

// Since we modified the chainID, we set the new genesisDoc in the stateDB.
b, err := cmtjson.Marshal(genDoc)
if err != nil {
return nil, err
Expand Down

0 comments on commit 25bee82

Please sign in to comment.