From 68c538afed46cbde7e5cc10b981298d3c29173d9 Mon Sep 17 00:00:00 2001 From: keruch <53012408+keruch@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:58:39 +0300 Subject: [PATCH] feat(app): return genesis bridge data in InitChainResponse (#162) --- app/app.go | 16 +++++++++++++++- go.mod | 25 +++++++++++++++---------- go.sum | 24 ++++++++++++------------ 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/app/app.go b/app/app.go index 1ca9334..768ce74 100644 --- a/app/app.go +++ b/app/app.go @@ -969,7 +969,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) @@ -980,10 +980,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..2bb43e6 100644 --- a/go.mod +++ b/go.mod @@ -17,8 +17,8 @@ require ( github.com/cosmos/gogoproto v1.5.0 github.com/cosmos/ibc-go/v6 v6.3.0 github.com/dvsekhvalnov/jose2go v1.5.0 - github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241119103059-def6322e4345 - github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241126070643-7ef37e51de91 + github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241202152140-ffec6e81a1ca + github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241202143104-5a4205efeef8 github.com/ethereum/go-ethereum v1.12.0 github.com/evmos/evmos/v12 v12.1.6 github.com/gogo/protobuf v1.3.3 @@ -31,7 +31,7 @@ require ( github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 github.com/tendermint/tendermint v0.34.29 github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 @@ -46,7 +46,7 @@ require ( cloud.google.com/go/storage v1.38.0 // indirect cosmossdk.io/api v0.7.0 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/math v1.3.0 // indirect + cosmossdk.io/math v1.4.0 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -353,14 +353,19 @@ replace ( github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 // use Evmos geth fork github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26 - github.com/evmos/evmos/v12 => github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4 - github.com/gorilla/rpc => github.com/dymensionxyz/rpc v1.3.1 github.com/libp2p/go-libp2p-kad-dht => github.com/libp2p/go-libp2p-kad-dht v0.25.2 - github.com/libp2p/go-libp2p-pubsub => github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20240513081713-3ecd83c19ea2 - github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.3 // 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 + +) + +// Dymension Forks +replace ( + github.com/cosmos/cosmos-sdk => github.com/dymensionxyz/cosmos-sdk v0.46.17-0.20241128210616-e9dfe47b8c73 + github.com/evmos/evmos/v12 => github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2 + github.com/gorilla/rpc => github.com/dymensionxyz/rpc v1.3.1 + github.com/libp2p/go-libp2p-pubsub => github.com/dymensionxyz/go-libp2p-pubsub v0.0.0-20240513081713-3ecd83c19ea2 + github.com/osmosis-labs/osmosis/v15 => github.com/dymensionxyz/osmosis/v15 v15.2.0-dymension-v1.1.3 + github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20241128205759-2a9d5f015da5 ) diff --git a/go.sum b/go.sum index d108728..672bce4 100644 --- a/go.sum +++ b/go.sum @@ -203,8 +203,8 @@ cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98ok cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= -cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= -cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= +cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= +cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= @@ -465,8 +465,6 @@ github.com/cosmos/cosmos-db v1.0.0 h1:EVcQZ+qYag7W6uorBKFPvX6gRjw6Uq2hIh4hCWjuQ0 github.com/cosmos/cosmos-db v1.0.0/go.mod h1:iBvi1TtqaedwLdcrZVYRSSCb6eSy61NLj4UNmdIgs0U= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= -github.com/cosmos/cosmos-sdk v0.46.16 h1:RVGv1+RulLZeNyfCaPZrZtv0kY7ZZNAI6JGpub0Uh6o= -github.com/cosmos/cosmos-sdk v0.46.16/go.mod h1:05U50tAsOzQ8JOAePshJCbJQw5ib1YJR6IXcqyVI1Xg= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -569,14 +567,16 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= -github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89 h1:rGkCcx4dWX9mxAUrq7zrdOc44XddMY/nM6kqYTWjerY= -github.com/dymensionxyz/cometbft v0.34.29-0.20241104165035-feade34f8f89/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw= +github.com/dymensionxyz/cometbft v0.34.29-0.20241128205759-2a9d5f015da5 h1:DIKsa7EWJRt+pIzzFn3MGYajwqaTmQQ/k255xONciRc= +github.com/dymensionxyz/cometbft v0.34.29-0.20241128205759-2a9d5f015da5/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw= +github.com/dymensionxyz/cosmos-sdk v0.46.17-0.20241128210616-e9dfe47b8c73 h1:A0Oqua/AfzhBWvv4jiep48TAaAsh6wSwgCKBAqU/LQ0= +github.com/dymensionxyz/cosmos-sdk v0.46.17-0.20241128210616-e9dfe47b8c73/go.mod h1:VPUuzF+l+ekSGPV7VVB8m0OMQfwp3QdKWNZjvkU3A1U= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20241121093220-e0d7ad456fbd h1:V89QyOFM84o9w0iFdctMU6So8SS/Xt32JWAXGqJduT0= github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20241121093220-e0d7ad456fbd/go.mod h1:3weqpVj/TqTFpC0LjEB3H+HZSpm7BrQ1QkEg1Ahy6KY= -github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241119103059-def6322e4345 h1:FcHidPgGEHh9ELwodNJkGcHqsG+mdPiGdughzG4W+X8= -github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241119103059-def6322e4345/go.mod h1:y89w1OG4C4aF7yyW8bv9PwV3o1KkCx1hyt34ap04Rnk= -github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241126070643-7ef37e51de91 h1:w1aFCVNQm8EUGxJy7bztCI0wTNZ6FphRCLmjtXgodLc= -github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241126070643-7ef37e51de91/go.mod h1:wqEC/5bf0bZwW/1+A+YGGLirDL0r8uj46U0999lPO8Q= +github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241202152140-ffec6e81a1ca h1:jW7rlPl/VdJTnm5Ie9aUsyFG3cwM0KdN+0LTV70/nN4= +github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241202152140-ffec6e81a1ca/go.mod h1:AA0rq+4H+yn/Agnx5L8ermhhny3FYgCv6UW9DzK5vss= +github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241202143104-5a4205efeef8 h1:EDC58P68E6YNgpvP4t4Mm/8St8E5XjgWulkaj9uUKbI= +github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241202143104-5a4205efeef8/go.mod h1:C3VbfePK85aRCdA1iHzB2AYD+n1gKR9Pw+wm3wQUXvE= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2 h1:aVP3off7u2vsvRH7lHAUPTLdf9/AfnzC/rvvi0wC/co= github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2/go.mod h1:CI6D89pkoiIm4BjoMFNnEaCLdKBEobLuwvhS0c1zh7Y= github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc= @@ -1545,8 +1545,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=