Skip to content

Commit

Permalink
Merge pull request #17 from dymensionxyz/mtsitrin/16-remove-initchain…
Browse files Browse the repository at this point in the history
…-hack

fix: removed the InitChainer hack
  • Loading branch information
mtsitrin authored Jul 24, 2023
2 parents 5994ce8 + 711d2a1 commit f9219f1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
28 changes: 2 additions & 26 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
abci "github.com/tendermint/tendermint/abci/types"
tmcrypto "github.com/tendermint/tendermint/crypto/encoding"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
Expand All @@ -21,7 +20,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -624,36 +622,14 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
panic(err)
}

//Passing the dymint sequencers to the sequencer module from RequestInitChain
if len(req.Validators) == 0 {
panic("Dymint have no sequencers defined on InitChain")
}

//Passing the dymint sequencers to the sequencer module from RequestInitChain
for _, val := range req.Validators {
tmkey, err := tmcrypto.PubKeyFromProto(val.PubKey)
if err != nil {
panic(err)
}
pubKey, err := cryptocodec.FromTmPubKeyInterface(tmkey)
if err != nil {
panic(err)
}
seq, err := seqtypes.NewSequencer(sdk.ValAddress{}, pubKey, uint64(val.Power))
if err != nil {
panic(err)
}

var genState seqtypes.GenesisState
app.appCodec.MustUnmarshalJSON(genesisState[seqtypes.ModuleName], &genState)
genState.Sequencers = append([]stakingtypes.Validator{seq}, genState.Sequencers...)
genesisState[seqtypes.ModuleName] = app.appCodec.MustMarshalJSON(&genState)
}
app.SequencersKeeper.SetDymintSequencers(ctx, req.Validators)

app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
res := app.mm.InitGenesis(ctx, app.appCodec, genesisState)

//Hack to avoid the baseApp validation
res.Validators = req.Validators
return res
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/cosmos/cosmos-sdk v0.46.13
github.com/cosmos/ibc-go/v6 v6.1.1
github.com/dymensionxyz/dymension-rdk v0.4.0-rc1.0.20230711084242-4d0e9cb2f122
github.com/dymensionxyz/dymension-rdk v0.4.0-rc1.0.20230718060209-76c5329f3b38
github.com/dymensionxyz/dymint v0.5.0-rc2
github.com/gorilla/mux v1.8.0
github.com/rakyll/statik v0.1.7
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ github.com/dymensionxyz/cosmosclient v0.3.0-beta.0.20230621132116-77eb2ae5ab92 h
github.com/dymensionxyz/cosmosclient v0.3.0-beta.0.20230621132116-77eb2ae5ab92/go.mod h1:3y64ecWDzhnd0sSYZfaL4QpwgK0b0j6LFLVRGdygg+o=
github.com/dymensionxyz/dymension v0.2.0-beta.0.20230607115558-745644a96ea6 h1:dnriGXmMdYEiF/8lMrj+PDlN1vyQc6zgs/ZHL67eoyI=
github.com/dymensionxyz/dymension v0.2.0-beta.0.20230607115558-745644a96ea6/go.mod h1:rDkVuF+DxBDi5tTgVHFk1D2xpqf8bOccs6aB1wTOvP0=
github.com/dymensionxyz/dymension-rdk v0.4.0-rc1.0.20230711084242-4d0e9cb2f122 h1:y3fbZUNhh293mLSRwBwWpYfYMx4v5S3DkxOfGFlgAqQ=
github.com/dymensionxyz/dymension-rdk v0.4.0-rc1.0.20230711084242-4d0e9cb2f122/go.mod h1:CR5qsMa0rx373U7xUAYqF5GaqoL7pqTZq4mnp6kSyj4=
github.com/dymensionxyz/dymension-rdk v0.4.0-rc1.0.20230718060209-76c5329f3b38 h1:KJkFlp8PGAwGgLIMaRH6A3y0u0zh9/PfS7tFVzwmdnE=
github.com/dymensionxyz/dymension-rdk v0.4.0-rc1.0.20230718060209-76c5329f3b38/go.mod h1:CR5qsMa0rx373U7xUAYqF5GaqoL7pqTZq4mnp6kSyj4=
github.com/dymensionxyz/dymint v0.5.0-rc2 h1:6egATw8RqJ9B925DhiBCRtlvkl9JKlLn3nU8UCBuzzQ=
github.com/dymensionxyz/dymint v0.5.0-rc2/go.mod h1:kge5k3m3fI66tw+1U9I0QK/8joFBs6KVRqBVnvGS0BA=
github.com/dymensionxyz/go-cnc v0.2.2 h1:C7WUFJ+PkkB62HPegBJJL+YlQExqvYudTTRdNiCNIDk=
Expand Down

0 comments on commit f9219f1

Please sign in to comment.