From 589ac654a43a6012c0c2eaea4cdf3fc1c28fec0b Mon Sep 17 00:00:00 2001 From: keruch Date: Wed, 27 Nov 2024 15:42:47 +0100 Subject: [PATCH] feat(app): return genesis bridge data in InitChainResponse --- app/app.go | 16 +++++++++++++++- go.mod | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index da0bcb3..64e75fd 100644 --- a/app/app.go +++ b/app/app.go @@ -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) @@ -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 } diff --git a/go.mod b/go.mod index fb073bc..972fff4 100644 --- a/go.mod +++ b/go.mod @@ -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 )