Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reboot SwingSet on bulldozer upgrade #7684

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if err is non-nil here, and if so return. We don't want to proceed with swingset initialization in this case.

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