Skip to content

Commit

Permalink
fix(agd): run the bootstrap block during agoric-upgrade-10
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed May 11, 2023
1 parent 7c06082 commit 3bb75e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
10 changes: 9 additions & 1 deletion golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,15 @@ func upgrade10Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgr
app.VstorageKeeper.MigrateNoDataPlaceholders(ctx) // upgrade-10 only
normalizeProvisionAccount(ctx, app.AccountKeeper)

return app.mm.RunMigrations(ctx, app.configurator, fromVm)
mvm, err := app.mm.RunMigrations(ctx, app.configurator, fromVm)
if err != nil {
return mvm, err
}

// Just run the SwingSet kernel to finish bootstrap and get ready to open for
// business.
stdlog.Println("Rebooting SwingSet")
return mvm, swingset.BootSwingset(ctx, app.SwingSetKeeper)
}
}

Expand Down
17 changes: 11 additions & 6 deletions golang/cosmos/x/swingset/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,26 @@ type bootstrapBlockAction struct {
StoragePort int `json:"storagePort"`
}

func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abci.ValidatorUpdate {
keeper.SetParams(ctx, data.GetParams())
keeper.SetState(ctx, data.GetState())

// Just run the SwingSet kernel to finish bootstrap and get ready to open for
func BootSwingset(ctx sdk.Context, keeper Keeper) error {
// Just run the SwingSet kernel to finish bootstrap and get ready to open for
// business.
stdlog.Println("Running SwingSet until bootstrap is ready")
action := &bootstrapBlockAction{
Type: "BOOTSTRAP_BLOCK",
BlockTime: ctx.BlockTime().Unix(),
StoragePort: vm.GetPort("vstorage"),
}

_, err := keeper.BlockingSend(ctx, action)
return err
}

func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abci.ValidatorUpdate {
keeper.SetParams(ctx, data.GetParams())
keeper.SetState(ctx, data.GetState())

stdlog.Println("Running SwingSet until bootstrap is ready")
err := BootSwingset(ctx, keeper)

// fmt.Fprintf(os.Stderr, "BOOTSTRAP_BLOCK Returned from swingset: %s, %v\n", out, err)
if err != nil {
// NOTE: A failed BOOTSTRAP_BLOCK means that the SwingSet state is inconsistent.
Expand Down

0 comments on commit 3bb75e3

Please sign in to comment.