Skip to content

Commit

Permalink
feat(app): return genesis bridge data in InitChainResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
keruch committed Nov 27, 2024
1 parent b9ad42b commit 589ac65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 15 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
var genesisState GenesisState
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
panic(fmt.Errorf("failed to unmarshal genesis state on InitChain: %w", err))
}

genesisInfo := app.HubGenesisKeeper.GetGenesisInfo(ctx)
Expand All @@ -957,10 +957,24 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
if len(req.Validators) == 0 {
panic(fmt.Sprint("Dymint have no sequencers defined on InitChain, req:", req))
}

// Passing the dymint sequencers to the sequencer module from RequestInitChain
app.SequencersKeeper.MustSetDymintValidatorUpdates(ctx, req.Validators)
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
res := app.mm.InitGenesis(ctx, app.appCodec, genesisState)

// Everything needed for the genesis bridge data should be set during the InitGenesis call,
// so we query it after and return it in InitChainResponse.
genesisBridgeData, _, err := app.HubGenesisKeeper.PrepareGenesisBridgeData(ctx)
if err != nil {
panic(fmt.Errorf("failed to prepare genesis bridge data on InitChain: %w", err))
}
bz, err := tmjson.Marshal(genesisBridgeData)
if err != nil {
panic(fmt.Errorf("failed to marshal genesis bridge data on InitChain: %w", err))
}
res.GenesisBridgeDataBytes = bz

return res
}

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,6 @@ replace (
// replace broken goleveldb
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
// use cometbft
github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89
github.com/tendermint/tendermint => ../dymension-cometbft
github.com/dymensionxyz/dymension-rdk => ../dymension-rdk
)

0 comments on commit 589ac65

Please sign in to comment.