From 3bb75e398b3827c9608137f8ccb5d31c468a3684 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Wed, 10 May 2023 16:32:29 -0600 Subject: [PATCH] fix(agd): run the bootstrap block during `agoric-upgrade-10` --- golang/cosmos/app/app.go | 10 +++++++++- golang/cosmos/x/swingset/genesis.go | 17 +++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/golang/cosmos/app/app.go b/golang/cosmos/app/app.go index 8d2ff7725f4..56c265f62d6 100644 --- a/golang/cosmos/app/app.go +++ b/golang/cosmos/app/app.go @@ -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) } } diff --git a/golang/cosmos/x/swingset/genesis.go b/golang/cosmos/x/swingset/genesis.go index 49bf3c4632b..8205d4836ba 100644 --- a/golang/cosmos/x/swingset/genesis.go +++ b/golang/cosmos/x/swingset/genesis.go @@ -37,13 +37,9 @@ 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(), @@ -51,7 +47,16 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abc } _, 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.