Skip to content

Commit

Permalink
catch some errors for height differences
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters committed Sep 23, 2024
1 parent c02da35 commit cf534ba
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tools/chainbuilder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ func Run(ctx context.Context, cfg BuilderConfig, dir string) error {
baseapp.SetMinGasPrices(fmt.Sprintf("%f%s", appconsts.DefaultMinGasPrice, appconsts.BondDenom)),
)

_ = simApp.Info(abci.RequestInfo{})
infoResp := simApp.Info(abci.RequestInfo{})

lastHeight := blockStore.Height()
if infoResp.LastBlockHeight != lastHeight {
return fmt.Errorf("last application height is %d, but the block store height is %d", infoResp.LastBlockHeight, lastHeight)
}

if lastHeight == 0 {
if gen == nil {
Expand Down Expand Up @@ -257,6 +260,14 @@ func Run(ctx context.Context, cfg BuilderConfig, dir string) error {
currentTime = state.LastBlockTime.Add(cfg.BlockInterval)
}

if state.ConsensusParams.Version.AppVersion != cfg.AppVersion {
return fmt.Errorf("app version mismatch: state has %d, but cfg has %d", state.ConsensusParams.Version.AppVersion, cfg.AppVersion)
}

if state.LastBlockHeight != lastHeight {
return fmt.Errorf("last block height mismatch: state has %d, but block store has %d", state.LastBlockHeight, lastHeight)
}

validatorPower := state.Validators.Validators[0].VotingPower

signer, err := user.NewSigner(
Expand Down

0 comments on commit cf534ba

Please sign in to comment.