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

feat(app): return genesis bridge data in InitChainResponse #162

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
keruch marked this conversation as resolved.
Show resolved Hide resolved
)
Loading