diff --git a/app/app.go b/app/app.go index 211c98e2..78531f40 100644 --- a/app/app.go +++ b/app/app.go @@ -138,6 +138,7 @@ import ( // Used in cosmos-sdk when registering the route for swagger docs. _ "github.com/sedaprotocol/seda-chain/client/docs/statik" + "github.com/sedaprotocol/seda-chain/cmd/sedad/gentx" "github.com/sedaprotocol/seda-chain/x/batching" batchingkeeper "github.com/sedaprotocol/seda-chain/x/batching/keeper" batchingtypes "github.com/sedaprotocol/seda-chain/x/batching/types" @@ -171,7 +172,7 @@ var ( // non-dependant module elements, such as codec registration // and genesis verification. ModuleBasics = module.NewBasicManager( - genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + genutil.NewAppModuleBasic(gentx.GenTxValidator), auth.AppModuleBasic{}, authzmodule.AppModuleBasic{}, vesting.AppModuleBasic{}, @@ -780,7 +781,7 @@ func NewApp( mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, nil), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil, app.interfaceRegistry), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, nil), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.PubKeyKeeper), upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), evidence.NewAppModule(app.EvidenceKeeper), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), @@ -808,7 +809,7 @@ func NewApp( app.bmm = module.NewBasicManagerFromManager( app.mm, map[string]module.AppModuleBasic{ - genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), + genutiltypes.ModuleName: genutil.NewAppModuleBasic(gentx.GenTxValidator), govtypes.ModuleName: gov.NewAppModuleBasic( []govclient.ProposalHandler{ // paramsclient.ProposalHandler, diff --git a/cmd/sedad/cmd/root.go b/cmd/sedad/cmd/root.go index 112f032c..0e094cf1 100644 --- a/cmd/sedad/cmd/root.go +++ b/cmd/sedad/cmd/root.go @@ -54,6 +54,7 @@ import ( "github.com/sedaprotocol/seda-chain/app" appparams "github.com/sedaprotocol/seda-chain/app/params" _ "github.com/sedaprotocol/seda-chain/client/docs/statik" // for swagger docs + "github.com/sedaprotocol/seda-chain/cmd/sedad/gentx" ) // NewRootCmd creates a new root command for a Cosmos SDK application @@ -187,13 +188,13 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig, basi rootCmd.AddCommand( genutilcli.InitCmd(basicManager, app.DefaultNodeHome), JoinNetworkCommand(basicManager, app.DefaultNodeHome), - genutilcli.CollectGenTxsCmd( + gentx.CollectGenTxsCmd( banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, gentxModule.GenTxValidator, encodingConfig.InterfaceRegistry.SigningContext().ValidatorAddressCodec(), ), - genutilcli.GenTxCmd( + gentx.GenTxCmd( basicManager, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, diff --git a/cmd/sedad/gentx/collect_gentxs.go b/cmd/sedad/gentx/collect_gentxs.go index 2579b5fa..e7ae4bdc 100644 --- a/cmd/sedad/gentx/collect_gentxs.go +++ b/cmd/sedad/gentx/collect_gentxs.go @@ -122,7 +122,7 @@ func GenAppStateFromConfig(cdc codec.JSONCodec, txEncodingConfig client.TxEncodi } // CollectTxs processes and validates application's genesis Txs of type -// MsgCreateValidatorWithVRF and returns the list of appGenTxs and +// MsgCreateSEDAValidator and returns the list of appGenTxs and // persistent peers required to generate genesis.json. func CollectTxs(cdc codec.JSONCodec, txJSONDecoder sdk.TxDecoder, moniker, genTxsDir string, genesis *types.AppGenesis, genBalIterator types.GenesisBalancesIterator, @@ -188,7 +188,7 @@ func CollectTxs(cdc codec.JSONCodec, txJSONDecoder sdk.TxDecoder, moniker, genTx // genesis transactions must be single-message msgs := genTx.GetMsgs() - msg := msgs[0].(*stakingtypes.MsgCreateValidatorWithVRF) + msg := msgs[0].(*stakingtypes.MsgCreateSEDAValidator) // validate validator addresses and funds against the accounts in the state valAddr, err := valAddrCodec.StringToBytes(msg.ValidatorAddress) diff --git a/cmd/sedad/gentx/gentx.go b/cmd/sedad/gentx/gentx.go new file mode 100644 index 00000000..4985d30b --- /dev/null +++ b/cmd/sedad/gentx/gentx.go @@ -0,0 +1,305 @@ +package gentx + +import ( + "bufio" + "bytes" + "encoding/json" + "fmt" + "io" + "os" + "path/filepath" + + "github.com/spf13/cobra" + + address "cosmossdk.io/core/address" + "cosmossdk.io/errors" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/server" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/version" + authclient "github.com/cosmos/cosmos-sdk/x/auth/client" + "github.com/cosmos/cosmos-sdk/x/genutil" + "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/staking/client/cli" + + "github.com/sedaprotocol/seda-chain/app/utils" + customcli "github.com/sedaprotocol/seda-chain/x/staking/client/cli" + stakingtypes "github.com/sedaprotocol/seda-chain/x/staking/types" +) + +//nolint:revive +func GenTxValidator(msgs []sdk.Msg) error { + if len(msgs) != 1 { + return fmt.Errorf("unexpected number of GenTx messages; got: %d, expected: 1", len(msgs)) + } + if _, ok := msgs[0].(*stakingtypes.MsgCreateSEDAValidator); !ok { + return fmt.Errorf("unexpected GenTx message type; expected: MsgCreateSEDAValidator, got: %T", msgs[0]) + } + + if m, ok := msgs[0].(sdk.HasValidateBasic); ok { + if err := m.ValidateBasic(); err != nil { + return fmt.Errorf("invalid GenTx '%s': %w", msgs[0], err) + } + } + + return nil +} + +// GenTxCmd builds the application's gentx command. +// +//nolint:revive +func GenTxCmd(mbm module.BasicManager, txEncCfg client.TxEncodingConfig, genBalIterator types.GenesisBalancesIterator, defaultNodeHome string, valAdddressCodec address.Codec) *cobra.Command { + ipDefault, _ := server.ExternalIP() + fsCreateValidator, defaultsDesc := cli.CreateValidatorMsgFlagSet(ipDefault) + + cmd := &cobra.Command{ + Use: "gentx [key_name] [amount]", + Short: "Generate a genesis tx carrying a self delegation and VRF public key", + Args: cobra.ExactArgs(2), + Long: fmt.Sprintf(`Generate a genesis transaction that creates a validator with a self-delegation and +VRF public key. The transaction is signed by the key in the Keyring referenced by a given name. A VRF key pair +is generated and stored in the configuration directory during the process. A node ID and consensus pubkey may +optionally be provided. If they are omitted, they will be retrieved from the priv_validator.json file. +The following default parameters are included: + %s + +Example: +$ %s gentx my-key-name 1000000seda --home=/path/to/home/dir --keyring-backend=os --chain-id=sedachain \ + --moniker="myvalidator" \ + --commission-max-change-rate=0.01 \ + --commission-max-rate=1.0 \ + --commission-rate=0.07 \ + --details="..." \ + --security-contact="..." \ + --website="..." +`, defaultsDesc, version.AppName, + ), + RunE: func(cmd *cobra.Command, args []string) error { + serverCtx := server.GetServerContextFromCmd(cmd) + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + cdc := clientCtx.Codec + + config := serverCtx.Config + config.SetRoot(clientCtx.HomeDir) + + nodeID, valPubKey, err := genutil.InitializeNodeValidatorFiles(serverCtx.Config) + if err != nil { + return errors.Wrap(err, "failed to initialize node validator files") + } + // vrfPubKey, err := utils.LoadOrGenVRFKey(serverCtx.Config, "") // TODO (#314) + // if err != nil { + // return errors.Wrap(err, "failed to initialize VRF key") + // } + + // read --nodeID, if empty take it from priv_validator.json + if nodeIDString, _ := cmd.Flags().GetString(cli.FlagNodeID); nodeIDString != "" { + nodeID = nodeIDString + } + + // read --pubkey, if empty take it from priv_validator.json + if pkStr, _ := cmd.Flags().GetString(cli.FlagPubKey); pkStr != "" { + if err := clientCtx.Codec.UnmarshalInterfaceJSON([]byte(pkStr), &valPubKey); err != nil { + return errors.Wrap(err, "failed to unmarshal validator public key") + } + } + + appGenesis, err := types.AppGenesisFromFile(config.GenesisFile()) + if err != nil { + return errors.Wrapf(err, "failed to read genesis doc file %s", config.GenesisFile()) + } + + var genesisState map[string]json.RawMessage + if err = json.Unmarshal(appGenesis.AppState, &genesisState); err != nil { + return errors.Wrap(err, "failed to unmarshal genesis state") + } + + if err = mbm.ValidateGenesis(cdc, txEncCfg, genesisState); err != nil { + return errors.Wrap(err, "failed to validate genesis state") + } + + inBuf := bufio.NewReader(cmd.InOrStdin()) + + name := args[0] + key, err := clientCtx.Keyring.Key(name) + if err != nil { + return errors.Wrapf(err, "failed to fetch '%s' from the keyring", name) + } + + moniker := config.Moniker + if m, _ := cmd.Flags().GetString(cli.FlagMoniker); m != "" { + moniker = m + } + + // Generate SEDA keys. + pub, err := key.GetAddress() + if err != nil { + return err + } + clientCtx = clientCtx.WithInput(inBuf).WithFromAddress(pub) + + valAddr := sdk.ValAddress(clientCtx.GetFromAddress()) + if valAddr.Empty() { + return fmt.Errorf("set the from address using --from flag") + } + pks, err := utils.GenerateSEDAKeys(valAddr, filepath.Dir(config.PrivValidatorKeyFile())) + if err != nil { + return err + } + + // set flags for creating a gentx + sdkCfg, err := cli.PrepareConfigForTxCreateValidator(cmd.Flags(), moniker, nodeID, appGenesis.ChainID, valPubKey) + if err != nil { + return errors.Wrap(err, "error creating configuration to create validator msg") + } + createValCfg := customcli.TxCreateValidatorConfig{ + TxCreateValidatorConfig: sdkCfg, + SEDAPubKeys: pks, + } + + amount := args[1] + coins, err := sdk.ParseCoinsNormalized(amount) + if err != nil { + return errors.Wrap(err, "failed to parse coins") + } + addr, err := key.GetAddress() + if err != nil { + return err + } + err = genutil.ValidateAccountInGenesis(genesisState, genBalIterator, addr, coins, cdc) + if err != nil { + return errors.Wrap(err, "failed to validate account in genesis") + } + + txFactory, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + // The following line comes from a discrepancy between the `gentx` + // and `create-validator` commands: + // - `gentx` expects amount as an arg, + // - `create-validator` expects amount as a required flag. + // ref: https://github.com/cosmos/cosmos-sdk/issues/8251 + // Since gentx doesn't set the amount flag (which `create-validator` + // reads from), we copy the amount arg into the valCfg directly. + // + // Ideally, the `create-validator` command should take a validator + // config file instead of so many flags. + // ref: https://github.com/cosmos/cosmos-sdk/issues/8177 + createValCfg.Amount = amount + + // create a 'create-validator' message + txf, msg, err := customcli.BuildCreateSEDAValidatorMsg(clientCtx, createValCfg, txFactory, true, valAdddressCodec) + if err != nil { + return errors.Wrap(err, "failed to build create-validator-with-vrf message") + } + + if key.GetType() == keyring.TypeOffline || key.GetType() == keyring.TypeMulti { + cmd.PrintErrln("Offline key passed in. Use `tx sign` command to sign.") + return txf.PrintUnsignedTx(clientCtx, msg) + } + + // write the unsigned transaction to the buffer + w := bytes.NewBuffer([]byte{}) + clientCtx = clientCtx.WithOutput(w) + + if m, ok := msg.(sdk.HasValidateBasic); ok { + if err := m.ValidateBasic(); err != nil { + return err + } + } + + if err = txf.PrintUnsignedTx(clientCtx, msg); err != nil { + return errors.Wrap(err, "failed to print unsigned std tx") + } + + // read the transaction + stdTx, err := readUnsignedGenTxFile(clientCtx, w) + if err != nil { + return errors.Wrap(err, "failed to read unsigned gen tx file") + } + + // sign the transaction and write it to the output file + txBuilder, err := clientCtx.TxConfig.WrapTxBuilder(stdTx) + if err != nil { + return fmt.Errorf("error creating tx builder: %w", err) + } + + err = authclient.SignTx(txFactory, clientCtx, name, txBuilder, true, true) + if err != nil { + return errors.Wrap(err, "failed to sign std tx") + } + + outputDocument, _ := cmd.Flags().GetString(flags.FlagOutputDocument) + if outputDocument == "" { + outputDocument, err = makeOutputFilepath(config.RootDir, nodeID) + if err != nil { + return errors.Wrap(err, "failed to create output file path") + } + } + + if err := writeSignedGenTx(clientCtx, outputDocument, stdTx); err != nil { + return errors.Wrap(err, "failed to write signed gen tx") + } + + cmd.PrintErrf("Genesis transaction written to %q\n", outputDocument) + return nil + }, + } + + cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory") + cmd.Flags().String(flags.FlagOutputDocument, "", "Write the genesis transaction JSON document to the given file instead of the default location") + cmd.Flags().AddFlagSet(fsCreateValidator) + flags.AddTxFlagsToCmd(cmd) + _ = cmd.Flags().MarkHidden(flags.FlagOutput) // signing makes sense to output only json + + return cmd +} + +func makeOutputFilepath(rootDir, nodeID string) (string, error) { + writePath := filepath.Join(rootDir, "config", "gentx") + if err := os.MkdirAll(writePath, 0o700); err != nil { + return "", fmt.Errorf("could not create directory %q: %w", writePath, err) + } + + return filepath.Join(writePath, fmt.Sprintf("gentx-%v.json", nodeID)), nil +} + +func readUnsignedGenTxFile(clientCtx client.Context, r io.Reader) (sdk.Tx, error) { + bz, err := io.ReadAll(r) + if err != nil { + return nil, err + } + + aTx, err := clientCtx.TxConfig.TxJSONDecoder()(bz) + if err != nil { + return nil, err + } + + return aTx, err +} + +func writeSignedGenTx(clientCtx client.Context, outputDocument string, tx sdk.Tx) error { + outputFile, err := os.OpenFile(outputDocument, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644) + if err != nil { + return err + } + defer outputFile.Close() + + json, err := clientCtx.TxConfig.TxJSONEncoder()(tx) + if err != nil { + return err + } + + _, err = fmt.Fprintf(outputFile, "%s\n", json) + + return err +} diff --git a/proto/sedachain/staking/v1/tx.proto b/proto/sedachain/staking/v1/tx.proto index ec361f46..2bc318cc 100644 --- a/proto/sedachain/staking/v1/tx.proto +++ b/proto/sedachain/staking/v1/tx.proto @@ -9,23 +9,21 @@ import "cosmos/base/v1beta1/coin.proto"; import "cosmos/staking/v1beta1/staking.proto"; import "cosmos/msg/v1/msg.proto"; import "amino/amino.proto"; +import "sedachain/pubkey/v1/pubkey.proto"; option go_package = "github.com/sedaprotocol/seda-chain/x/staking/types"; // Msg defines the staking Msg service. service Msg { - // option (cosmos.msg.v1.service) = true; - - // CreateValidatorWithVRF defines a method for creating a new validator. - rpc CreateValidatorWithVRF(MsgCreateValidatorWithVRF) - returns (MsgCreateValidatorWithVRFResponse); + // CreateSEDAValidator defines a method for creating a new validator. + rpc CreateSEDAValidator(MsgCreateSEDAValidator) + returns (MsgCreateSEDAValidatorResponse); } -// MsgCreateValidator defines a SDK message for creating a new validator. -message MsgCreateValidatorWithVRF { +// MsgCreateSEDAValidator defines a message for creating a new SEDA +// validator. +message MsgCreateSEDAValidator { option (cosmos.msg.v1.signer) = "validator_address"; - // option (amino.name) = "cosmos-sdk/MsgCreateValidator"; - option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -50,9 +48,9 @@ message MsgCreateValidatorWithVRF { [ (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey" ]; cosmos.base.v1beta1.Coin value = 7 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; - google.protobuf.Any vrf_pubkey = 8 - [ (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey" ]; + repeated sedachain.pubkey.v1.IndexedPubKey indexed_pub_keys = 8 [ (gogoproto.nullable) = false ]; } -// MsgCreateValidatorResponse defines the Msg/CreateValidator response type. -message MsgCreateValidatorWithVRFResponse {} +// MsgCreateSEDAValidatorResponse defines the Msg/MsgCreateSEDAValidator +// response type. +message MsgCreateSEDAValidatorResponse {} diff --git a/proto/sedachain/wasm_storage/v1/tx.proto b/proto/sedachain/wasm_storage/v1/tx.proto index 6493aa3d..22e14056 100644 --- a/proto/sedachain/wasm_storage/v1/tx.proto +++ b/proto/sedachain/wasm_storage/v1/tx.proto @@ -83,4 +83,4 @@ message MsgUpdateParams { } // no data needs to be returned -message MsgUpdateParamsResponse {} \ No newline at end of file +message MsgUpdateParamsResponse {} diff --git a/x/batching/keeper/integration_test.go b/x/batching/keeper/integration_test.go index 1c7fd862..875be85d 100644 --- a/x/batching/keeper/integration_test.go +++ b/x/batching/keeper/integration_test.go @@ -216,6 +216,7 @@ func initFixture(tb testing.TB) *fixture { viewKeeper, addresscodec.NewBech32Codec(params.Bech32PrefixValAddr), ) + tallyKeeper := tallykeeper.NewKeeper( wasmStorageKeeper, batchingKeeper, @@ -225,7 +226,7 @@ func initFixture(tb testing.TB) *fixture { authModule := auth.NewAppModule(cdc, accountKeeper, app.RandomGenesisAccounts, nil) bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil) - stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, nil) + stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, pubKeyKeeper) wasmStorageModule := wasmstorage.NewAppModule(cdc, *wasmStorageKeeper) tallyModule := tally.NewAppModule(tallyKeeper) pubKeyModule := pubkey.NewAppModule(cdc, *pubKeyKeeper) diff --git a/x/pubkey/keeper/endblock_test.go b/x/pubkey/keeper/endblock_test.go index f022a07a..4c1f51d4 100644 --- a/x/pubkey/keeper/endblock_test.go +++ b/x/pubkey/keeper/endblock_test.go @@ -152,7 +152,7 @@ func initFixture(tb testing.TB) *fixture { authModule := auth.NewAppModule(cdc, accountKeeper, app.RandomGenesisAccounts, nil) bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil) - stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, nil) + stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, pubkeyKeeper) pubkeyModule := pubkey.NewAppModule(cdc, *pubkeyKeeper) integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{ diff --git a/x/pubkey/keeper/keeper.go b/x/pubkey/keeper/keeper.go index bfdeb46e..4dfff23d 100644 --- a/x/pubkey/keeper/keeper.go +++ b/x/pubkey/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "bytes" "context" + "encoding/hex" "fmt" "cosmossdk.io/collections" @@ -59,6 +60,27 @@ func (k Keeper) GetAuthority() string { return k.authority } +// StoreIndexedPubKeys stores the given list of indexed public keys +// for a validator. +func (k Keeper) StoreIndexedPubKeys(ctx sdk.Context, valAddr sdk.ValAddress, pubKeys []types.IndexedPubKey) error { + for _, pk := range pubKeys { + err := k.SetValidatorKeyAtIndex(ctx, valAddr, utils.SEDAKeyIndex(pk.Index), pk.PubKey) + if err != nil { + return err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeAddKey, + sdk.NewAttribute(types.AttributeValidatorAddr, valAddr.String()), + sdk.NewAttribute(types.AttributePubKeyIndex, fmt.Sprintf("%d", pk.Index)), + sdk.NewAttribute(types.AttributePublicKey, hex.EncodeToString(pk.PubKey)), + ), + ) + } + return nil +} + func (k Keeper) SetValidatorKeyAtIndex(ctx context.Context, validatorAddr sdk.ValAddress, index utils.SEDAKeyIndex, pubKey []byte) error { err := k.pubKeys.Set(ctx, collections.Join(validatorAddr.Bytes(), uint32(index)), pubKey) if err != nil { diff --git a/x/pubkey/keeper/msg_server.go b/x/pubkey/keeper/msg_server.go index 42e1e596..d60a19d8 100644 --- a/x/pubkey/keeper/msg_server.go +++ b/x/pubkey/keeper/msg_server.go @@ -2,8 +2,6 @@ package keeper import ( "context" - "encoding/hex" - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -27,6 +25,7 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer { func (m msgServer) AddKey(goCtx context.Context, msg *types.MsgAddKey) (*types.MsgAddKeyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + // Validate the message. err := msg.Validate() if err != nil { return nil, err @@ -36,6 +35,7 @@ func (m msgServer) AddKey(goCtx context.Context, msg *types.MsgAddKey) (*types.M return nil, sdkerrors.ErrInvalidRequest.Wrapf("invalid SEDA keys: %s", err) } + // Verify that the validator exists. valAddr, err := m.validatorAddressCodec.StringToBytes(msg.ValidatorAddr) if err != nil { return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err) @@ -45,20 +45,10 @@ func (m msgServer) AddKey(goCtx context.Context, msg *types.MsgAddKey) (*types.M return nil, sdkerrors.ErrNotFound.Wrapf("validator not found %s", msg.ValidatorAddr) } - for _, indPubKey := range msg.IndexedPubKeys { - err := m.SetValidatorKeyAtIndex(ctx, valAddr, utils.SEDAKeyIndex(indPubKey.Index), indPubKey.PubKey) - if err != nil { - return nil, err - } - - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeAddKey, - sdk.NewAttribute(types.AttributeValidatorAddr, msg.ValidatorAddr), - sdk.NewAttribute(types.AttributePubKeyIndex, fmt.Sprintf("%d", indPubKey.Index)), - sdk.NewAttribute(types.AttributePublicKey, hex.EncodeToString(indPubKey.PubKey)), - ), - ) + // Store the public keys. + err = m.StoreIndexedPubKeys(ctx, valAddr, msg.IndexedPubKeys) + if err != nil { + return nil, err } return &types.MsgAddKeyResponse{}, nil } diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go new file mode 100644 index 00000000..6ee6f53a --- /dev/null +++ b/x/staking/client/cli/tx.go @@ -0,0 +1,255 @@ +package cli + +import ( + "fmt" + "path/filepath" + "strings" + + "github.com/spf13/cobra" + flag "github.com/spf13/pflag" + + "cosmossdk.io/core/address" + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/server" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/version" + stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli" + sdktypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + "github.com/sedaprotocol/seda-chain/app/utils" + pubkeycli "github.com/sedaprotocol/seda-chain/x/pubkey/client/cli" + pubkeytypes "github.com/sedaprotocol/seda-chain/x/pubkey/types" + "github.com/sedaprotocol/seda-chain/x/staking/types" +) + +// default values +var ( + DefaultTokens = sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction) + defaultAmount = DefaultTokens.String() + sdk.DefaultBondDenom + defaultCommissionRate = "0.1" + defaultCommissionMaxRate = "0.2" + defaultCommissionMaxChangeRate = "0.01" + defaultMinSelfDelegation = "1" +) + +// NewTxCmd returns a root CLI command handler for all x/staking transaction commands. +func NewTxCmd(valAddrCodec, ac address.Codec) *cobra.Command { + stakingTxCmd := &cobra.Command{ + Use: sdktypes.ModuleName, + Short: "Staking transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + stakingTxCmd.AddCommand( + NewCreateValidatorCmd(valAddrCodec), + stakingcli.NewEditValidatorCmd(valAddrCodec), + stakingcli.NewDelegateCmd(valAddrCodec, ac), + stakingcli.NewRedelegateCmd(valAddrCodec, ac), + stakingcli.NewUnbondCmd(valAddrCodec, ac), + stakingcli.NewCancelUnbondingDelegation(valAddrCodec, ac), + ) + + return stakingTxCmd +} + +func NewCreateValidatorCmd(ac address.Codec) *cobra.Command { + cmd := &cobra.Command{ + Use: "create-validator [path/to/validator.json]", + Short: "create new validator initialized with a self-delegation to it", + Args: cobra.ExactArgs(1), + Long: `Create a new validator initialized with a self-delegation by submitting a JSON file with the new validator details.`, + Example: strings.TrimSpace( + fmt.Sprintf(` +$ %s tx staking create-validator path/to/validator.json --from keyname + +Where validator.json contains: + +{ + "pubkey": { + "@type":"/cosmos.crypto.ed25519.PubKey", + "key":"oWg2ISpLF405Jcm2vXV+2v4fnjodh6aafuIdeoW+rUw=" + }, + "amount": "1000000stake", + "moniker": "myvalidator", + "identity": "optional identity signature (ex. UPort or Keybase)", + "website": "validator's (optional) website", + "security": "validator's (optional) security contact email", + "details": "validator's (optional) details", + "commission-rate": "0.1", + "commission-max-rate": "0.2", + "commission-max-change-rate": "0.01", + "min-self-delegation": "1" +} + +where we can get the pubkey using "%s tendermint show-validator" +`, version.AppName, version.AppName)), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + serverCfg := server.GetServerContextFromCmd(cmd).Config + + txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + + valAddr := sdk.ValAddress(clientCtx.GetFromAddress()) + if valAddr.Empty() { + return fmt.Errorf("set the from address using --from flag") + } + + var pks []pubkeytypes.IndexedPubKey + keyFile, _ := cmd.Flags().GetString(pubkeycli.FlagKeyFile) + if keyFile != "" { + pks, err = utils.LoadSEDAPubKeys(keyFile) + if err != nil { + return err + } + } else { + pks, err = utils.GenerateSEDAKeys(valAddr, filepath.Dir(serverCfg.PrivValidatorKeyFile())) + if err != nil { + return err + } + } + + validator, err := parseAndValidateValidatorJSON(clientCtx.Codec, args[0]) + if err != nil { + return err + } + + txf, msg, err := newBuildCreateSEDAValidatorMsg(clientCtx, txf, cmd.Flags(), validator, ac, pks) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + cmd.Flags().String(pubkeycli.FlagKeyFile, "", "path to an existing SEDA key file") + cmd.Flags().String(stakingcli.FlagIP, "", fmt.Sprintf("The node's public IP. It takes effect only when used in combination with --%s", flags.FlagGenerateOnly)) + cmd.Flags().String(stakingcli.FlagNodeID, "", "The node's ID") + flags.AddTxFlagsToCmd(cmd) + + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} + +func newBuildCreateSEDAValidatorMsg(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet, val validator, valAc address.Codec, pks []pubkeytypes.IndexedPubKey) (tx.Factory, *types.MsgCreateSEDAValidator, error) { + valAddr := clientCtx.GetFromAddress() + + description := sdktypes.NewDescription( + val.Moniker, + val.Identity, + val.Website, + val.Security, + val.Details, + ) + + valStr, err := valAc.BytesToString(sdk.ValAddress(valAddr)) + if err != nil { + return txf, nil, err + } + msg, err := types.NewMsgCreateSEDAValidator( + valStr, val.PubKey, pks, val.Amount, description, val.CommissionRates, val.MinSelfDelegation, + ) + if err != nil { + return txf, nil, err + } + if err := msg.Validate(valAc); err != nil { + return txf, nil, err + } + + genOnly, _ := fs.GetBool(flags.FlagGenerateOnly) + if genOnly { + ip, _ := fs.GetString(stakingcli.FlagIP) + p2pPort, _ := fs.GetUint(stakingcli.FlagP2PPort) + nodeID, _ := fs.GetString(stakingcli.FlagNodeID) + + if nodeID != "" && ip != "" && p2pPort > 0 { + txf = txf.WithMemo(fmt.Sprintf("%s@%s:%d", nodeID, ip, p2pPort)) + } + } + + return txf, msg, nil +} + +type TxCreateValidatorConfig struct { + stakingcli.TxCreateValidatorConfig + SEDAPubKeys []pubkeytypes.IndexedPubKey +} + +func BuildCreateSEDAValidatorMsg(clientCtx client.Context, config TxCreateValidatorConfig, txBldr tx.Factory, generateOnly bool, valCodec address.Codec) (tx.Factory, sdk.Msg, error) { + amounstStr := config.Amount + amount, err := sdk.ParseCoinNormalized(amounstStr) + if err != nil { + return txBldr, nil, err + } + + valAddr := clientCtx.GetFromAddress() + description := sdktypes.NewDescription( + config.Moniker, + config.Identity, + config.Website, + config.SecurityContact, + config.Details, + ) + + // get the initial validator commission parameters + rateStr := config.CommissionRate + maxRateStr := config.CommissionMaxRate + maxChangeRateStr := config.CommissionMaxChangeRate + commissionRates, err := buildCommissionRates(rateStr, maxRateStr, maxChangeRateStr) + if err != nil { + return txBldr, nil, err + } + + // get the initial validator min self delegation + msbStr := config.MinSelfDelegation + minSelfDelegation, ok := math.NewIntFromString(msbStr) + + if !ok { + return txBldr, nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "minimum self delegation must be a positive integer") + } + + valStr, err := valCodec.BytesToString(sdk.ValAddress(valAddr)) + if err != nil { + return txBldr, nil, err + } + + msg, err := types.NewMsgCreateSEDAValidator( + valStr, + config.PubKey, + config.SEDAPubKeys, + amount, + description, + commissionRates, + minSelfDelegation, + ) + if err != nil { + return txBldr, msg, err + } + + if generateOnly { + ip := config.IP + p2pPort := config.P2PPort + nodeID := config.NodeID + + if nodeID != "" && ip != "" && p2pPort > 0 { + txBldr = txBldr.WithMemo(fmt.Sprintf("%s@%s:%d", nodeID, ip, p2pPort)) + } + } + + return txBldr, msg, nil +} diff --git a/x/staking/client/cli/utils.go b/x/staking/client/cli/utils.go new file mode 100644 index 00000000..bd9ba90d --- /dev/null +++ b/x/staking/client/cli/utils.go @@ -0,0 +1,127 @@ +package cli + +import ( + "encoding/json" + "errors" + "fmt" + "os" + + errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/codec" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +// validator struct to define the fields of the validator +type validator struct { + Amount sdk.Coin + PubKey cryptotypes.PubKey + Moniker string + Identity string + Website string + Security string + Details string + CommissionRates types.CommissionRates + MinSelfDelegation math.Int +} + +func parseAndValidateValidatorJSON(cdc codec.Codec, path string) (validator, error) { + type internalVal struct { + Amount string `json:"amount"` + PubKey json.RawMessage `json:"pubkey"` + Moniker string `json:"moniker"` + Identity string `json:"identity,omitempty"` + Website string `json:"website,omitempty"` + Security string `json:"security,omitempty"` + Details string `json:"details,omitempty"` + CommissionRate string `json:"commission-rate"` + CommissionMaxRate string `json:"commission-max-rate"` + CommissionMaxChange string `json:"commission-max-change-rate"` + MinSelfDelegation string `json:"min-self-delegation"` + } + + contents, err := os.ReadFile(path) + if err != nil { + return validator{}, err + } + + var v internalVal + err = json.Unmarshal(contents, &v) + if err != nil { + return validator{}, err + } + + if v.Amount == "" { + return validator{}, fmt.Errorf("must specify amount of coins to bond") + } + amount, err := sdk.ParseCoinNormalized(v.Amount) + if err != nil { + return validator{}, err + } + + if v.PubKey == nil { + return validator{}, fmt.Errorf("must specify the JSON encoded pubkey") + } + var pk cryptotypes.PubKey + if err := cdc.UnmarshalInterfaceJSON(v.PubKey, &pk); err != nil { + return validator{}, err + } + + if v.Moniker == "" { + return validator{}, fmt.Errorf("must specify the moniker name") + } + + commissionRates, err := buildCommissionRates(v.CommissionRate, v.CommissionMaxRate, v.CommissionMaxChange) + if err != nil { + return validator{}, err + } + + if v.MinSelfDelegation == "" { + return validator{}, fmt.Errorf("must specify minimum self delegation") + } + minSelfDelegation, ok := math.NewIntFromString(v.MinSelfDelegation) + if !ok { + return validator{}, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "minimum self delegation must be a positive integer") + } + + return validator{ + Amount: amount, + PubKey: pk, + Moniker: v.Moniker, + Identity: v.Identity, + Website: v.Website, + Security: v.Security, + Details: v.Details, + CommissionRates: commissionRates, + MinSelfDelegation: minSelfDelegation, + }, nil +} + +func buildCommissionRates(rateStr, maxRateStr, maxChangeRateStr string) (commission types.CommissionRates, err error) { + if rateStr == "" || maxRateStr == "" || maxChangeRateStr == "" { + return commission, errors.New("must specify all validator commission parameters") + } + + rate, err := math.LegacyNewDecFromStr(rateStr) + if err != nil { + return commission, err + } + + maxRate, err := math.LegacyNewDecFromStr(maxRateStr) + if err != nil { + return commission, err + } + + maxChangeRate, err := math.LegacyNewDecFromStr(maxChangeRateStr) + if err != nil { + return commission, err + } + + commission = types.NewCommissionRates(rate, maxRate, maxChangeRate) + + return commission, nil +} diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 7ff0c344..f049fa07 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -2,14 +2,15 @@ package keeper import ( "context" + "fmt" addresscodec "cosmossdk.io/core/address" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/sedaprotocol/seda-chain/app/utils" "github.com/sedaprotocol/seda-chain/x/staking/types" ) @@ -17,48 +18,46 @@ var _ types.MsgServer = msgServer{} type msgServer struct { stakingtypes.MsgServer - keeper *Keeper - accountKeeper types.AccountKeeper - randomnessKeeper types.RandomnessKeeper + pubkeyKeeper types.PubkeyKeeper validatorAddressCodec addresscodec.Codec } -func NewMsgServerImpl(sdkMsgServer stakingtypes.MsgServer, keeper *Keeper, accKeeper types.AccountKeeper, randKeeper types.RandomnessKeeper) types.MsgServer { +func NewMsgServerImpl(sdkMsgServer stakingtypes.MsgServer, pubKeyKeeper types.PubkeyKeeper, valAddrCdc addresscodec.Codec) types.MsgServer { ms := &msgServer{ MsgServer: sdkMsgServer, - keeper: keeper, - accountKeeper: accKeeper, - randomnessKeeper: randKeeper, - validatorAddressCodec: keeper.ValidatorAddressCodec(), + pubkeyKeeper: pubKeyKeeper, + validatorAddressCodec: valAddrCdc, } return ms } -func (k msgServer) CreateValidatorWithVRF(ctx context.Context, msg *types.MsgCreateValidatorWithVRF) (*types.MsgCreateValidatorWithVRFResponse, error) { - if err := msg.Validate(k.validatorAddressCodec); err != nil { +func (m msgServer) CreateValidator(ctx context.Context, msg *stakingtypes.MsgCreateValidator) (*stakingtypes.MsgCreateValidatorResponse, error) { + return nil, fmt.Errorf("not implemented") +} + +func (m msgServer) CreateSEDAValidator(ctx context.Context, msg *types.MsgCreateSEDAValidator) (*types.MsgCreateSEDAValidatorResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + + err := msg.Validate(m.validatorAddressCodec) + if err != nil { return nil, err } - - // create an account based on VRF public key to send NewSeed txs when proposing blocks - vrfPubKey, ok := msg.VrfPubkey.GetCachedValue().(cryptotypes.PubKey) - if !ok { - return nil, sdkerrors.ErrInvalidType.Wrapf("expected cryptotypes.PubKey, got %T", vrfPubKey) + valAddr, err := m.validatorAddressCodec.StringToBytes(msg.ValidatorAddress) + if err != nil { + return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err) } - addr := sdk.AccAddress(vrfPubKey.Address().Bytes()) - acc := k.accountKeeper.NewAccountWithAddress(ctx, addr) - k.accountKeeper.SetAccount(ctx, acc) - - // register VRF public key to validator consensus address - consPubKey, ok := msg.Pubkey.GetCachedValue().(cryptotypes.PubKey) - if !ok { - return nil, sdkerrors.ErrInvalidType.Wrapf("expected cryptotypes.PubKey, got %T", consPubKey) + // Validate and store the public keys. + err = utils.ValidateSEDAPubKeys(msg.IndexedPubKeys) + if err != nil { + return nil, sdkerrors.ErrInvalidRequest.Wrapf("invalid SEDA keys: %s", err) } - err := k.randomnessKeeper.SetValidatorVRFPubKey(ctx, sdk.GetConsAddress(consPubKey).String(), vrfPubKey) + err = m.pubkeyKeeper.StoreIndexedPubKeys(sdkCtx, valAddr, msg.IndexedPubKeys) if err != nil { return nil, err } + // Call the wrapped CreateValidator method. sdkMsg := new(stakingtypes.MsgCreateValidator) sdkMsg.Description = msg.Description sdkMsg.Commission = msg.Commission @@ -67,10 +66,9 @@ func (k msgServer) CreateValidatorWithVRF(ctx context.Context, msg *types.MsgCre sdkMsg.Pubkey = msg.Pubkey sdkMsg.Value = msg.Value - _, err = k.MsgServer.CreateValidator(ctx, sdkMsg) + _, err = m.MsgServer.CreateValidator(ctx, sdkMsg) if err != nil { return nil, err } - - return &types.MsgCreateValidatorWithVRFResponse{}, nil + return &types.MsgCreateSEDAValidatorResponse{}, nil } diff --git a/x/staking/module.go b/x/staking/module.go index 11340e56..7965f903 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -18,11 +18,11 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/staking" - sdkcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli" sdkkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/simulation" sdktypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/sedaprotocol/seda-chain/x/staking/client/cli" "github.com/sedaprotocol/seda-chain/x/staking/keeper" "github.com/sedaprotocol/seda-chain/x/staking/types" ) @@ -43,7 +43,6 @@ var ( // AppModuleBasic defines the basic application module used by the staking module. type AppModuleBasic struct { cdc codec.Codec - ak types.AccountKeeper } // Name returns the staking module's name. @@ -58,13 +57,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // RegisterInterfaces registers the module's interface types func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { - // TODO(#208) to be activated later - // types.RegisterInterfaces(registry) - // err := registry.EnsureRegistered(&types.MsgCreateValidatorWithVRF{}) - // if err != nil { - // fmt.Println("error") - // } - + types.RegisterInterfaces(registry) sdktypes.RegisterInterfaces(registry) } @@ -93,10 +86,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *g // GetTxCmd returns the root tx command for the staking module. func (amb AppModuleBasic) GetTxCmd() *cobra.Command { - // TODO(#208) to be activated later - // return cli.NewTxCmd(amb.cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(), amb.cdc.InterfaceRegistry().SigningContext().AddressCodec()) - - return sdkcli.NewTxCmd(amb.cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(), amb.cdc.InterfaceRegistry().SigningContext().AddressCodec()) + return cli.NewTxCmd(amb.cdc.InterfaceRegistry().SigningContext().ValidatorAddressCodec(), amb.cdc.InterfaceRegistry().SigningContext().AddressCodec()) } // ---------------------------------------------------------------------------- @@ -107,36 +97,34 @@ func (amb AppModuleBasic) GetTxCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper *keeper.Keeper - accountKeeper types.AccountKeeper - bankKeeper sdktypes.BankKeeper - randomnessKeeper types.RandomnessKeeper + keeper *keeper.Keeper + accountKeeper sdktypes.AccountKeeper + bankKeeper sdktypes.BankKeeper + pubKeyKeeper types.PubkeyKeeper } // NewAppModule creates a new AppModule object func NewAppModule( cdc codec.Codec, keeper *keeper.Keeper, - ak types.AccountKeeper, + ak sdktypes.AccountKeeper, bk sdktypes.BankKeeper, - rk types.RandomnessKeeper, + pk types.PubkeyKeeper, ) AppModule { return AppModule{ - AppModuleBasic: AppModuleBasic{cdc: cdc, ak: ak}, - keeper: keeper, - accountKeeper: ak, - bankKeeper: bk, - randomnessKeeper: rk, + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + accountKeeper: ak, + bankKeeper: bk, + pubKeyKeeper: pk, } } // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { - sdkMsgServer := NewMsgServerImpl(am.keeper.Keeper, am.accountKeeper) - sdktypes.RegisterMsgServer(cfg.MsgServer(), sdkMsgServer) - - // TODO(#208) to be activated later - // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(sdkMsgServer, am.keeper, am.accountKeeper, am.randomnessKeeper)) + sdkMsgServer := sdkkeeper.NewMsgServerImpl(am.keeper.Keeper) + msgServer := keeper.NewMsgServerImpl(sdkMsgServer, am.pubKeyKeeper, am.keeper.ValidatorAddressCodec()) + types.RegisterMsgServer(cfg.MsgServer(), msgServer) querier := sdkkeeper.Querier{Keeper: am.keeper.Keeper} sdktypes.RegisterQueryServer(cfg.QueryServer(), querier) diff --git a/x/staking/msg_server.go b/x/staking/msg_server.go deleted file mode 100644 index 1ff360c9..00000000 --- a/x/staking/msg_server.go +++ /dev/null @@ -1,53 +0,0 @@ -package staking - -import ( - "context" - - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - "github.com/sedaprotocol/seda-chain/x/staking/types" -) - -var _ stakingtypes.MsgServer = msgServer{} - -type msgServer struct { - stakingtypes.MsgServer - accountKeeper types.AccountKeeper -} - -func NewMsgServerImpl(keeper *stakingkeeper.Keeper, accKeeper types.AccountKeeper) stakingtypes.MsgServer { - ms := &msgServer{ - MsgServer: stakingkeeper.NewMsgServerImpl(keeper), - accountKeeper: accKeeper, - } - return ms -} - -func (k msgServer) CreateValidator(ctx context.Context, msg *stakingtypes.MsgCreateValidator) (*stakingtypes.MsgCreateValidatorResponse, error) { - return k.MsgServer.CreateValidator(ctx, msg) -} - -func (k msgServer) EditValidator(ctx context.Context, msg *stakingtypes.MsgEditValidator) (*stakingtypes.MsgEditValidatorResponse, error) { - return k.MsgServer.EditValidator(ctx, msg) -} - -func (k msgServer) Delegate(ctx context.Context, msg *stakingtypes.MsgDelegate) (*stakingtypes.MsgDelegateResponse, error) { - return k.MsgServer.Delegate(ctx, msg) -} - -func (k msgServer) BeginRedelegate(ctx context.Context, msg *stakingtypes.MsgBeginRedelegate) (*stakingtypes.MsgBeginRedelegateResponse, error) { - return k.MsgServer.BeginRedelegate(ctx, msg) -} - -func (k msgServer) Undelegate(ctx context.Context, msg *stakingtypes.MsgUndelegate) (*stakingtypes.MsgUndelegateResponse, error) { - return k.MsgServer.Undelegate(ctx, msg) -} - -func (k msgServer) CancelUnbondingDelegation(ctx context.Context, msg *stakingtypes.MsgCancelUnbondingDelegation) (*stakingtypes.MsgCancelUnbondingDelegationResponse, error) { - return k.MsgServer.CancelUnbondingDelegation(ctx, msg) -} - -func (k msgServer) UpdateParams(ctx context.Context, msg *stakingtypes.MsgUpdateParams) (*stakingtypes.MsgUpdateParamsResponse, error) { - return k.MsgServer.UpdateParams(ctx, msg) -} diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 6ce04411..d4eaab20 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -9,7 +9,7 @@ import ( // RegisterInterfaces registers the x/staking interfaces types with the interface registry func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), - &MsgCreateValidatorWithVRF{}, + &MsgCreateSEDAValidator{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index 05731de8..8ccfd984 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -1,20 +1,10 @@ package types import ( - "context" - - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/sedaprotocol/seda-chain/x/pubkey/types" ) -type AccountKeeper interface { - stakingtypes.AccountKeeper - - NewAccountWithAddress(ctx context.Context, addr sdk.AccAddress) sdk.AccountI - SetAccount(ctx context.Context, acc sdk.AccountI) -} - -type RandomnessKeeper interface { - SetValidatorVRFPubKey(ctx context.Context, consensusAddr string, vrfPubKey cryptotypes.PubKey) error +type PubkeyKeeper interface { + StoreIndexedPubKeys(ctx sdk.Context, valAddr sdk.ValAddress, pubKeys []types.IndexedPubKey) error } diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index ded13745..dff80b5c 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -9,18 +9,21 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/staking/types" + + pubkeytypes "github.com/sedaprotocol/seda-chain/x/pubkey/types" ) var ( - _ sdk.Msg = &MsgCreateValidatorWithVRF{} - _ codectypes.UnpackInterfacesMessage = (*MsgCreateValidatorWithVRF)(nil) + _ sdk.Msg = &MsgCreateSEDAValidator{} + _ codectypes.UnpackInterfacesMessage = (*MsgCreateSEDAValidator)(nil) ) -// NewMsgCreateValidatorWithVRF creates a MsgCreateValidatorWithVRF instance. -func NewMsgCreateValidatorWithVRF( - valAddr string, pubKey, vrfPubKey cryptotypes.PubKey, - selfDelegation sdk.Coin, description types.Description, commission types.CommissionRates, minSelfDelegation math.Int, -) (*MsgCreateValidatorWithVRF, error) { +// NewMsgCreateSEDAValidator creates a MsgCreateSEDAValidator instance. +func NewMsgCreateSEDAValidator( + valAddr string, pubKey cryptotypes.PubKey, sedaPubKeys []pubkeytypes.IndexedPubKey, + selfDelegation sdk.Coin, description types.Description, commission types.CommissionRates, + minSelfDelegation math.Int, +) (*MsgCreateSEDAValidator, error) { var pkAny *codectypes.Any if pubKey != nil { var err error @@ -29,29 +32,21 @@ func NewMsgCreateValidatorWithVRF( } } - var vrfPkAny *codectypes.Any - if vrfPubKey != nil { - var err error - if vrfPkAny, err = codectypes.NewAnyWithValue(vrfPubKey); err != nil { - return nil, err - } - } - - return &MsgCreateValidatorWithVRF{ + return &MsgCreateSEDAValidator{ Description: description, ValidatorAddress: valAddr, Pubkey: pkAny, - VrfPubkey: vrfPkAny, + IndexedPubKeys: sedaPubKeys, Value: selfDelegation, Commission: commission, MinSelfDelegation: minSelfDelegation, }, nil } -// Validate validates the MsgCreateValidatorWithVRF sdk msg. -func (msg MsgCreateValidatorWithVRF) Validate(ac address.Codec) error { - if msg.Pubkey == nil || msg.VrfPubkey == nil { - return sdkerrors.ErrInvalidRequest.Wrap("empty validator public key or VRF public key") +// Validate validates the MsgCreateSEDAValidator sdk msg. +func (msg MsgCreateSEDAValidator) Validate(ac address.Codec) error { + if msg.Pubkey == nil { + return sdkerrors.ErrInvalidRequest.Wrap("empty validator public key") } msgCreateVal := &types.MsgCreateValidator{ @@ -66,11 +61,7 @@ func (msg MsgCreateValidatorWithVRF) Validate(ac address.Codec) error { } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces -func (msg MsgCreateValidatorWithVRF) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { - var pubKey, vrfPubKey cryptotypes.PubKey - err := unpacker.UnpackAny(msg.Pubkey, &pubKey) - if err != nil { - return err - } - return unpacker.UnpackAny(msg.VrfPubkey, &vrfPubKey) +func (msg MsgCreateSEDAValidator) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { + var pubKey cryptotypes.PubKey + return unpacker.UnpackAny(msg.Pubkey, &pubKey) } diff --git a/x/staking/types/tx.pb.go b/x/staking/types/tx.pb.go index 6c5bcfd5..38a9f2cb 100644 --- a/x/staking/types/tx.pb.go +++ b/x/staking/types/tx.pb.go @@ -16,6 +16,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + types3 "github.com/sedaprotocol/seda-chain/x/pubkey/types" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -35,33 +36,34 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgCreateValidator defines a SDK message for creating a new validator. -type MsgCreateValidatorWithVRF struct { +// MsgCreateSEDAValidator defines a message for creating a new SEDA +// validator. +type MsgCreateSEDAValidator struct { Description types.Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description"` Commission types.CommissionRates `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission"` MinSelfDelegation cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=cosmossdk.io/math.Int" json:"min_self_delegation"` // Deprecated: Use of Delegator Address in MsgCreateValidator is deprecated. // The validator address bytes and delegator address bytes refer to the same // account while creating validator (defer only in bech32 notation). - DelegatorAddress string `protobuf:"bytes,4,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` // Deprecated: Do not use. - ValidatorAddress string `protobuf:"bytes,5,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` - Pubkey *types1.Any `protobuf:"bytes,6,opt,name=pubkey,proto3" json:"pubkey,omitempty"` - Value types2.Coin `protobuf:"bytes,7,opt,name=value,proto3" json:"value"` - VrfPubkey *types1.Any `protobuf:"bytes,8,opt,name=vrf_pubkey,json=vrfPubkey,proto3" json:"vrf_pubkey,omitempty"` + DelegatorAddress string `protobuf:"bytes,4,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` // Deprecated: Do not use. + ValidatorAddress string `protobuf:"bytes,5,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Pubkey *types1.Any `protobuf:"bytes,6,opt,name=pubkey,proto3" json:"pubkey,omitempty"` + Value types2.Coin `protobuf:"bytes,7,opt,name=value,proto3" json:"value"` + IndexedPubKeys []types3.IndexedPubKey `protobuf:"bytes,8,rep,name=indexed_pub_keys,json=indexedPubKeys,proto3" json:"indexed_pub_keys"` } -func (m *MsgCreateValidatorWithVRF) Reset() { *m = MsgCreateValidatorWithVRF{} } -func (m *MsgCreateValidatorWithVRF) String() string { return proto.CompactTextString(m) } -func (*MsgCreateValidatorWithVRF) ProtoMessage() {} -func (*MsgCreateValidatorWithVRF) Descriptor() ([]byte, []int) { +func (m *MsgCreateSEDAValidator) Reset() { *m = MsgCreateSEDAValidator{} } +func (m *MsgCreateSEDAValidator) String() string { return proto.CompactTextString(m) } +func (*MsgCreateSEDAValidator) ProtoMessage() {} +func (*MsgCreateSEDAValidator) Descriptor() ([]byte, []int) { return fileDescriptor_670d278351a2d088, []int{0} } -func (m *MsgCreateValidatorWithVRF) XXX_Unmarshal(b []byte) error { +func (m *MsgCreateSEDAValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCreateValidatorWithVRF) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCreateSEDAValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCreateValidatorWithVRF.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCreateSEDAValidator.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -71,34 +73,35 @@ func (m *MsgCreateValidatorWithVRF) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *MsgCreateValidatorWithVRF) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateValidatorWithVRF.Merge(m, src) +func (m *MsgCreateSEDAValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateSEDAValidator.Merge(m, src) } -func (m *MsgCreateValidatorWithVRF) XXX_Size() int { +func (m *MsgCreateSEDAValidator) XXX_Size() int { return m.Size() } -func (m *MsgCreateValidatorWithVRF) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateValidatorWithVRF.DiscardUnknown(m) +func (m *MsgCreateSEDAValidator) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateSEDAValidator.DiscardUnknown(m) } -var xxx_messageInfo_MsgCreateValidatorWithVRF proto.InternalMessageInfo +var xxx_messageInfo_MsgCreateSEDAValidator proto.InternalMessageInfo -// MsgCreateValidatorResponse defines the Msg/CreateValidator response type. -type MsgCreateValidatorWithVRFResponse struct { +// MsgCreateSEDAValidatorResponse defines the Msg/MsgCreateSEDAValidator +// response type. +type MsgCreateSEDAValidatorResponse struct { } -func (m *MsgCreateValidatorWithVRFResponse) Reset() { *m = MsgCreateValidatorWithVRFResponse{} } -func (m *MsgCreateValidatorWithVRFResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateValidatorWithVRFResponse) ProtoMessage() {} -func (*MsgCreateValidatorWithVRFResponse) Descriptor() ([]byte, []int) { +func (m *MsgCreateSEDAValidatorResponse) Reset() { *m = MsgCreateSEDAValidatorResponse{} } +func (m *MsgCreateSEDAValidatorResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateSEDAValidatorResponse) ProtoMessage() {} +func (*MsgCreateSEDAValidatorResponse) Descriptor() ([]byte, []int) { return fileDescriptor_670d278351a2d088, []int{1} } -func (m *MsgCreateValidatorWithVRFResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgCreateSEDAValidatorResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgCreateValidatorWithVRFResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgCreateSEDAValidatorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgCreateValidatorWithVRFResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgCreateSEDAValidatorResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -108,66 +111,68 @@ func (m *MsgCreateValidatorWithVRFResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *MsgCreateValidatorWithVRFResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateValidatorWithVRFResponse.Merge(m, src) +func (m *MsgCreateSEDAValidatorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateSEDAValidatorResponse.Merge(m, src) } -func (m *MsgCreateValidatorWithVRFResponse) XXX_Size() int { +func (m *MsgCreateSEDAValidatorResponse) XXX_Size() int { return m.Size() } -func (m *MsgCreateValidatorWithVRFResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateValidatorWithVRFResponse.DiscardUnknown(m) +func (m *MsgCreateSEDAValidatorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateSEDAValidatorResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgCreateValidatorWithVRFResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgCreateSEDAValidatorResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgCreateValidatorWithVRF)(nil), "sedachain.staking.v1.MsgCreateValidatorWithVRF") - proto.RegisterType((*MsgCreateValidatorWithVRFResponse)(nil), "sedachain.staking.v1.MsgCreateValidatorWithVRFResponse") + proto.RegisterType((*MsgCreateSEDAValidator)(nil), "sedachain.staking.v1.MsgCreateSEDAValidator") + proto.RegisterType((*MsgCreateSEDAValidatorResponse)(nil), "sedachain.staking.v1.MsgCreateSEDAValidatorResponse") } func init() { proto.RegisterFile("sedachain/staking/v1/tx.proto", fileDescriptor_670d278351a2d088) } var fileDescriptor_670d278351a2d088 = []byte{ - // 618 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x4f, 0x13, 0x41, - 0x14, 0xc7, 0xbb, 0x22, 0x28, 0xc3, 0x85, 0xae, 0x55, 0xdb, 0x26, 0x6c, 0xf9, 0x61, 0x22, 0x21, - 0xe9, 0x8c, 0xc5, 0x83, 0x09, 0x37, 0x0a, 0xc1, 0x10, 0xc5, 0x90, 0x25, 0xc1, 0xc4, 0x4b, 0x9d, - 0xdd, 0x9d, 0x6e, 0x27, 0xec, 0xce, 0x34, 0x3b, 0xd3, 0x0d, 0xbd, 0x72, 0x32, 0x9e, 0xfc, 0x13, - 0x38, 0x7a, 0x93, 0x03, 0x7f, 0x04, 0xf1, 0x44, 0x38, 0x19, 0x0f, 0xc4, 0xc0, 0x01, 0xff, 0x0c, - 0xd3, 0x99, 0xd9, 0x6d, 0x51, 0x7b, 0xd0, 0xcb, 0x66, 0x66, 0xbe, 0xef, 0x7d, 0xe6, 0x9b, 0xf7, - 0xde, 0x2c, 0x98, 0x13, 0x24, 0xc0, 0x7e, 0x07, 0x53, 0x86, 0x84, 0xc4, 0x07, 0x94, 0x85, 0x28, - 0x6d, 0x20, 0x79, 0x08, 0xbb, 0x09, 0x97, 0xdc, 0x2e, 0xe5, 0x32, 0x34, 0x32, 0x4c, 0x1b, 0xd5, - 0x4a, 0xc8, 0x79, 0x18, 0x11, 0xa4, 0x62, 0xbc, 0x5e, 0x1b, 0x61, 0xd6, 0xd7, 0x09, 0xd5, 0x52, - 0xc8, 0x43, 0xae, 0x96, 0x68, 0xb0, 0x32, 0xa7, 0x15, 0x9f, 0x8b, 0x98, 0x8b, 0x96, 0x16, 0xf4, - 0xc6, 0x48, 0x8e, 0xde, 0x21, 0x0f, 0x0b, 0x82, 0xd2, 0x86, 0x47, 0x24, 0x6e, 0x20, 0x9f, 0x53, - 0x66, 0xf4, 0x27, 0x46, 0x1f, 0xba, 0xd3, 0x21, 0x99, 0x1d, 0x1d, 0xf5, 0xd8, 0x44, 0xc5, 0x42, - 0xf9, 0x8f, 0x45, 0x26, 0x14, 0x71, 0x4c, 0x19, 0x47, 0xea, 0xab, 0x8f, 0x16, 0xbf, 0x4c, 0x82, - 0xca, 0x8e, 0x08, 0x37, 0x12, 0x82, 0x25, 0xd9, 0xc7, 0x11, 0x0d, 0xb0, 0xe4, 0xc9, 0x5b, 0x2a, - 0x3b, 0xfb, 0xee, 0x96, 0xbd, 0x0b, 0x66, 0x02, 0x22, 0xfc, 0x84, 0x76, 0x25, 0xe5, 0xac, 0x6c, - 0xcd, 0x5b, 0xcb, 0x33, 0xab, 0x4b, 0xd0, 0x78, 0x1e, 0x16, 0x41, 0xb9, 0x80, 0x9b, 0xc3, 0xd0, - 0xe6, 0xf4, 0xd9, 0x65, 0xad, 0xf0, 0xf9, 0xe6, 0x64, 0xc5, 0x72, 0x47, 0x11, 0xb6, 0x0b, 0x80, - 0xcf, 0xe3, 0x98, 0x0a, 0x31, 0x00, 0xde, 0x51, 0xc0, 0xa7, 0xe3, 0x80, 0x1b, 0x79, 0xa4, 0x8b, - 0x25, 0x11, 0xa3, 0xd0, 0x11, 0x8a, 0xfd, 0x1e, 0x3c, 0x88, 0x29, 0x6b, 0x09, 0x12, 0xb5, 0x5b, - 0x01, 0x89, 0x48, 0x88, 0x95, 0xdb, 0x89, 0x79, 0x6b, 0x79, 0xba, 0xf9, 0x6c, 0x90, 0xf3, 0xfd, - 0xb2, 0xf6, 0x50, 0xdf, 0x21, 0x82, 0x03, 0x48, 0x39, 0x8a, 0xb1, 0xec, 0xc0, 0x6d, 0x26, 0x2f, - 0x4e, 0xeb, 0xc0, 0x5c, 0xbe, 0xcd, 0xa4, 0x46, 0x17, 0x63, 0xca, 0xf6, 0x48, 0xd4, 0xde, 0xcc, - 0x51, 0xf6, 0x4b, 0x50, 0x34, 0x60, 0x9e, 0xb4, 0x70, 0x10, 0x24, 0x44, 0x88, 0xf2, 0x5d, 0xc5, - 0xaf, 0x5e, 0x9c, 0xd6, 0x4b, 0x06, 0xb1, 0xae, 0x95, 0x3d, 0x99, 0x50, 0x16, 0x96, 0x2d, 0x77, - 0x36, 0x4f, 0x32, 0x8a, 0xfd, 0x06, 0x14, 0xd3, 0xac, 0xc8, 0x39, 0x68, 0x52, 0x81, 0x16, 0x2e, - 0x4e, 0xeb, 0x73, 0x06, 0x94, 0x37, 0xe2, 0x16, 0xd1, 0x9d, 0x4d, 0x7f, 0x3b, 0xb7, 0xb7, 0xc0, - 0x54, 0xb7, 0xe7, 0x1d, 0x90, 0x7e, 0x79, 0x4a, 0x95, 0xb2, 0x04, 0xf5, 0x34, 0xc2, 0x6c, 0x1a, - 0xe1, 0x3a, 0xeb, 0x37, 0xcb, 0x5f, 0x87, 0x1e, 0xfd, 0xa4, 0xdf, 0x95, 0x1c, 0xee, 0xf6, 0xbc, - 0x57, 0xa4, 0xef, 0x9a, 0x6c, 0x7b, 0x0d, 0x4c, 0xa6, 0x38, 0xea, 0x91, 0xf2, 0x3d, 0x85, 0xa9, - 0x64, 0x1d, 0x19, 0x0c, 0xe2, 0x48, 0x3b, 0xe8, 0xad, 0xc6, 0xea, 0x14, 0x7b, 0x07, 0x80, 0x34, - 0x69, 0xb7, 0x8c, 0x8f, 0xfb, 0xff, 0xe5, 0x63, 0x3a, 0x4d, 0xda, 0xbb, 0x0a, 0xb0, 0xe6, 0x7c, - 0x38, 0xae, 0x15, 0x7e, 0x1e, 0xd7, 0x0a, 0x47, 0x37, 0x27, 0x2b, 0x7f, 0x56, 0x6b, 0x71, 0x09, - 0x2c, 0x8c, 0x1d, 0x58, 0x97, 0x88, 0x2e, 0x67, 0x82, 0xac, 0x7e, 0xb4, 0xc0, 0xc4, 0x8e, 0x08, - 0xed, 0x23, 0x0b, 0x3c, 0x1a, 0x33, 0xdb, 0x08, 0xfe, 0xed, 0x39, 0xc3, 0xb1, 0xec, 0xea, 0x8b, - 0x7f, 0x4c, 0xc8, 0xcc, 0x34, 0x5f, 0x9f, 0x5d, 0x39, 0xd6, 0xf9, 0x95, 0x63, 0xfd, 0xb8, 0x72, - 0xac, 0x4f, 0xd7, 0x4e, 0xe1, 0xfc, 0xda, 0x29, 0x7c, 0xbb, 0x76, 0x0a, 0xef, 0x56, 0x43, 0x2a, - 0x3b, 0x3d, 0x0f, 0xfa, 0x3c, 0x46, 0x03, 0xb8, 0xaa, 0x96, 0xcf, 0x23, 0xb5, 0xa9, 0xeb, 0x3f, - 0xd1, 0x61, 0xfe, 0xda, 0x65, 0xbf, 0x4b, 0x84, 0x37, 0xa5, 0x82, 0x9e, 0xff, 0x0a, 0x00, 0x00, - 0xff, 0xff, 0xd0, 0xfe, 0xfa, 0x43, 0xad, 0x04, 0x00, 0x00, + // 653 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x6f, 0xd3, 0x3c, + 0x18, 0xc7, 0x9b, 0x77, 0x3f, 0xde, 0x77, 0x9e, 0xf4, 0x6a, 0xcd, 0x0a, 0x64, 0x95, 0x96, 0x96, + 0x81, 0xc4, 0x34, 0x51, 0x87, 0x16, 0x4e, 0xbb, 0xad, 0x1b, 0xa0, 0x09, 0x86, 0xa6, 0x4c, 0xe2, + 0xc0, 0xa5, 0x38, 0x89, 0x97, 0x59, 0x4d, 0xec, 0x28, 0x76, 0xa3, 0xe5, 0x86, 0x38, 0x71, 0xe4, + 0x4f, 0xd8, 0x91, 0xe3, 0x90, 0xf6, 0x47, 0x4c, 0x9c, 0xa6, 0x9d, 0x10, 0x87, 0x09, 0x6d, 0x87, + 0xf1, 0x67, 0xa0, 0xd8, 0x6e, 0xda, 0x41, 0x39, 0x70, 0xa9, 0x6c, 0x7f, 0xbf, 0xcf, 0x27, 0x8f, + 0x9f, 0xe7, 0x71, 0xc1, 0x32, 0xc7, 0x01, 0xf2, 0x0f, 0x10, 0xa1, 0x0e, 0x17, 0xa8, 0x4f, 0x68, + 0xe8, 0x64, 0x6d, 0x47, 0x1c, 0xc2, 0x24, 0x65, 0x82, 0x99, 0xb5, 0x52, 0x86, 0x5a, 0x86, 0x59, + 0xbb, 0xbe, 0x14, 0x32, 0x16, 0x46, 0xd8, 0x91, 0x1e, 0x6f, 0xb0, 0xef, 0x20, 0x9a, 0xab, 0x80, + 0x7a, 0x2d, 0x64, 0x21, 0x93, 0x4b, 0xa7, 0x58, 0xe9, 0xd3, 0x25, 0x9f, 0xf1, 0x98, 0xf1, 0x9e, + 0x12, 0xd4, 0x46, 0x4b, 0xb6, 0xda, 0x39, 0x1e, 0xe2, 0xd8, 0xc9, 0xda, 0x1e, 0x16, 0xa8, 0xed, + 0xf8, 0x8c, 0x50, 0xad, 0xdf, 0xd7, 0xfa, 0x28, 0x3b, 0x65, 0x19, 0xa6, 0xa3, 0x5c, 0x77, 0xb4, + 0x2b, 0xe6, 0x32, 0xff, 0x98, 0x0f, 0x85, 0x2a, 0x8a, 0x09, 0x65, 0x8e, 0xfc, 0xd5, 0x47, 0xcd, + 0xd1, 0x95, 0x93, 0x81, 0xd7, 0xc7, 0x79, 0x11, 0xa1, 0x56, 0xca, 0xb1, 0xf2, 0x79, 0x06, 0xdc, + 0xde, 0xe1, 0xe1, 0x66, 0x8a, 0x91, 0xc0, 0x7b, 0x4f, 0xb7, 0x36, 0x5e, 0xa3, 0x88, 0x04, 0x48, + 0xb0, 0xd4, 0xdc, 0x05, 0xf3, 0x01, 0xe6, 0x7e, 0x4a, 0x12, 0x41, 0x18, 0xb5, 0x8c, 0xa6, 0xb1, + 0x3a, 0xdf, 0xb9, 0x07, 0xf5, 0x95, 0x46, 0x35, 0x92, 0x49, 0xc2, 0xad, 0x91, 0xb5, 0x3b, 0x77, + 0x7a, 0xd1, 0xa8, 0x7c, 0xba, 0x3e, 0x5e, 0x33, 0xdc, 0x71, 0x84, 0xe9, 0x02, 0xe0, 0xb3, 0x38, + 0x26, 0x9c, 0x17, 0xc0, 0x7f, 0x24, 0xf0, 0xc1, 0x9f, 0x80, 0x9b, 0xa5, 0xd3, 0x45, 0x02, 0xf3, + 0x71, 0xe8, 0x18, 0xc5, 0x7c, 0x0b, 0x16, 0x63, 0x42, 0x7b, 0x1c, 0x47, 0xfb, 0xbd, 0x00, 0x47, + 0x38, 0x44, 0x32, 0xdb, 0xa9, 0xa6, 0xb1, 0x3a, 0xd7, 0x7d, 0x54, 0xc4, 0x7c, 0xbb, 0x68, 0xdc, + 0x52, 0xdf, 0xe0, 0x41, 0x1f, 0x12, 0xe6, 0xc4, 0x48, 0x1c, 0xc0, 0x6d, 0x2a, 0xce, 0x4f, 0x5a, + 0x40, 0x7f, 0x7c, 0x9b, 0x0a, 0x85, 0xae, 0xc6, 0x84, 0xee, 0xe1, 0x68, 0x7f, 0xab, 0x44, 0x99, + 0xcf, 0x41, 0x55, 0x83, 0x59, 0xda, 0x43, 0x41, 0x90, 0x62, 0xce, 0xad, 0x69, 0xc9, 0xaf, 0x9f, + 0x9f, 0xb4, 0x6a, 0x1a, 0xb1, 0xa1, 0x94, 0x3d, 0x91, 0x12, 0x1a, 0x5a, 0x86, 0xbb, 0x50, 0x06, + 0x69, 0xc5, 0x7c, 0x05, 0xaa, 0xd9, 0xb0, 0xba, 0x25, 0x68, 0x46, 0x82, 0xee, 0x9e, 0x9f, 0xb4, + 0x96, 0x35, 0xa8, 0xec, 0xc0, 0x0d, 0xa2, 0xbb, 0x90, 0xfd, 0x72, 0x6e, 0x3e, 0x03, 0xb3, 0xaa, + 0x97, 0xd6, 0xac, 0x2c, 0x65, 0x0d, 0xaa, 0x61, 0x85, 0xc3, 0x61, 0x85, 0x1b, 0x34, 0xef, 0x5a, + 0x5f, 0x46, 0x39, 0xfa, 0x69, 0x9e, 0x08, 0x06, 0x77, 0x07, 0xde, 0x0b, 0x9c, 0xbb, 0x3a, 0xda, + 0x5c, 0x07, 0x33, 0x19, 0x8a, 0x06, 0xd8, 0xfa, 0x57, 0x62, 0x96, 0x86, 0x1d, 0x29, 0xe6, 0x74, + 0xac, 0x1d, 0xe4, 0x46, 0x63, 0x55, 0x88, 0xe9, 0x82, 0x05, 0x42, 0x03, 0x7c, 0x88, 0x83, 0x5e, + 0x32, 0xf0, 0x7a, 0x7d, 0x9c, 0x73, 0xeb, 0xbf, 0xe6, 0xd4, 0xea, 0x7c, 0x67, 0x05, 0x8e, 0x1e, + 0x94, 0x1e, 0xb9, 0xac, 0x0d, 0xb7, 0x95, 0x59, 0x65, 0xd0, 0x9d, 0x2e, 0x78, 0xee, 0xff, 0x64, + 0xfc, 0x90, 0xaf, 0xdb, 0x1f, 0x8e, 0x1a, 0x95, 0x1f, 0x47, 0x8d, 0xca, 0xfb, 0xeb, 0xe3, 0xb5, + 0xdf, 0x4b, 0xb6, 0xd2, 0x04, 0xf6, 0xe4, 0x91, 0x75, 0x31, 0x4f, 0x18, 0xe5, 0xb8, 0xf3, 0xce, + 0x00, 0x53, 0x3b, 0x3c, 0x34, 0x73, 0xb0, 0x38, 0x69, 0xb2, 0x1f, 0xc2, 0x49, 0x6f, 0x1d, 0x4e, + 0x86, 0xd6, 0x9f, 0xfc, 0x8d, 0x7b, 0x98, 0x42, 0xf7, 0xe5, 0xe9, 0xa5, 0x6d, 0x9c, 0x5d, 0xda, + 0xc6, 0xf7, 0x4b, 0xdb, 0xf8, 0x78, 0x65, 0x57, 0xce, 0xae, 0xec, 0xca, 0xd7, 0x2b, 0xbb, 0xf2, + 0xa6, 0x13, 0x12, 0x71, 0x30, 0xf0, 0xa0, 0xcf, 0x62, 0xa7, 0x20, 0xcb, 0x6e, 0xf9, 0x2c, 0x92, + 0x9b, 0x96, 0x7a, 0xad, 0x87, 0xe5, 0x9f, 0x80, 0xc8, 0x13, 0xcc, 0xbd, 0x59, 0x69, 0x7a, 0xfc, + 0x33, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x66, 0x03, 0xab, 0xc4, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -182,8 +187,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // CreateValidatorWithVRF defines a method for creating a new validator. - CreateValidatorWithVRF(ctx context.Context, in *MsgCreateValidatorWithVRF, opts ...grpc.CallOption) (*MsgCreateValidatorWithVRFResponse, error) + // CreateSEDAValidator defines a method for creating a new validator. + CreateSEDAValidator(ctx context.Context, in *MsgCreateSEDAValidator, opts ...grpc.CallOption) (*MsgCreateSEDAValidatorResponse, error) } type msgClient struct { @@ -194,9 +199,9 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) CreateValidatorWithVRF(ctx context.Context, in *MsgCreateValidatorWithVRF, opts ...grpc.CallOption) (*MsgCreateValidatorWithVRFResponse, error) { - out := new(MsgCreateValidatorWithVRFResponse) - err := c.cc.Invoke(ctx, "/sedachain.staking.v1.Msg/CreateValidatorWithVRF", in, out, opts...) +func (c *msgClient) CreateSEDAValidator(ctx context.Context, in *MsgCreateSEDAValidator, opts ...grpc.CallOption) (*MsgCreateSEDAValidatorResponse, error) { + out := new(MsgCreateSEDAValidatorResponse) + err := c.cc.Invoke(ctx, "/sedachain.staking.v1.Msg/CreateSEDAValidator", in, out, opts...) if err != nil { return nil, err } @@ -205,36 +210,36 @@ func (c *msgClient) CreateValidatorWithVRF(ctx context.Context, in *MsgCreateVal // MsgServer is the server API for Msg service. type MsgServer interface { - // CreateValidatorWithVRF defines a method for creating a new validator. - CreateValidatorWithVRF(context.Context, *MsgCreateValidatorWithVRF) (*MsgCreateValidatorWithVRFResponse, error) + // CreateSEDAValidator defines a method for creating a new validator. + CreateSEDAValidator(context.Context, *MsgCreateSEDAValidator) (*MsgCreateSEDAValidatorResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) CreateValidatorWithVRF(ctx context.Context, req *MsgCreateValidatorWithVRF) (*MsgCreateValidatorWithVRFResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateValidatorWithVRF not implemented") +func (*UnimplementedMsgServer) CreateSEDAValidator(ctx context.Context, req *MsgCreateSEDAValidator) (*MsgCreateSEDAValidatorResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateSEDAValidator not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_CreateValidatorWithVRF_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateValidatorWithVRF) +func _Msg_CreateSEDAValidator_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateSEDAValidator) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).CreateValidatorWithVRF(ctx, in) + return srv.(MsgServer).CreateSEDAValidator(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/sedachain.staking.v1.Msg/CreateValidatorWithVRF", + FullMethod: "/sedachain.staking.v1.Msg/CreateSEDAValidator", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateValidatorWithVRF(ctx, req.(*MsgCreateValidatorWithVRF)) + return srv.(MsgServer).CreateSEDAValidator(ctx, req.(*MsgCreateSEDAValidator)) } return interceptor(ctx, in, info, handler) } @@ -245,15 +250,15 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "CreateValidatorWithVRF", - Handler: _Msg_CreateValidatorWithVRF_Handler, + MethodName: "CreateSEDAValidator", + Handler: _Msg_CreateSEDAValidator_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "sedachain/staking/v1/tx.proto", } -func (m *MsgCreateValidatorWithVRF) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateSEDAValidator) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -263,27 +268,29 @@ func (m *MsgCreateValidatorWithVRF) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateValidatorWithVRF) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateSEDAValidator) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateValidatorWithVRF) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateSEDAValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.VrfPubkey != nil { - { - size, err := m.VrfPubkey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.IndexedPubKeys) > 0 { + for iNdEx := len(m.IndexedPubKeys) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IndexedPubKeys[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x42 } - i-- - dAtA[i] = 0x42 } { size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) @@ -354,7 +361,7 @@ func (m *MsgCreateValidatorWithVRF) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *MsgCreateValidatorWithVRFResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateSEDAValidatorResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -364,12 +371,12 @@ func (m *MsgCreateValidatorWithVRFResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgCreateValidatorWithVRFResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateSEDAValidatorResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgCreateValidatorWithVRFResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateSEDAValidatorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -388,7 +395,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgCreateValidatorWithVRF) Size() (n int) { +func (m *MsgCreateSEDAValidator) Size() (n int) { if m == nil { return 0 } @@ -414,14 +421,16 @@ func (m *MsgCreateValidatorWithVRF) Size() (n int) { } l = m.Value.Size() n += 1 + l + sovTx(uint64(l)) - if m.VrfPubkey != nil { - l = m.VrfPubkey.Size() - n += 1 + l + sovTx(uint64(l)) + if len(m.IndexedPubKeys) > 0 { + for _, e := range m.IndexedPubKeys { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } } return n } -func (m *MsgCreateValidatorWithVRFResponse) Size() (n int) { +func (m *MsgCreateSEDAValidatorResponse) Size() (n int) { if m == nil { return 0 } @@ -436,7 +445,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgCreateValidatorWithVRF) Unmarshal(dAtA []byte) error { +func (m *MsgCreateSEDAValidator) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -459,10 +468,10 @@ func (m *MsgCreateValidatorWithVRF) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateValidatorWithVRF: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateSEDAValidator: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateValidatorWithVRF: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateSEDAValidator: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -700,7 +709,7 @@ func (m *MsgCreateValidatorWithVRF) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VrfPubkey", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IndexedPubKeys", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -727,10 +736,8 @@ func (m *MsgCreateValidatorWithVRF) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.VrfPubkey == nil { - m.VrfPubkey = &types1.Any{} - } - if err := m.VrfPubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.IndexedPubKeys = append(m.IndexedPubKeys, types3.IndexedPubKey{}) + if err := m.IndexedPubKeys[len(m.IndexedPubKeys)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -755,7 +762,7 @@ func (m *MsgCreateValidatorWithVRF) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateValidatorWithVRFResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCreateSEDAValidatorResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -778,10 +785,10 @@ func (m *MsgCreateValidatorWithVRFResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateValidatorWithVRFResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateSEDAValidatorResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateValidatorWithVRFResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateSEDAValidatorResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/x/tally/keeper/integration_test.go b/x/tally/keeper/integration_test.go index 4dc480e8..98da3e51 100644 --- a/x/tally/keeper/integration_test.go +++ b/x/tally/keeper/integration_test.go @@ -219,7 +219,7 @@ func initFixture(tb testing.TB) *fixture { authModule := auth.NewAppModule(cdc, accountKeeper, app.RandomGenesisAccounts, nil) bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil) - stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, nil) + stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, pubKeyKeeper) wasmStorageModule := wasmstorage.NewAppModule(cdc, *wasmStorageKeeper) tallyModule := tally.NewAppModule(tallyKeeper) diff --git a/x/vesting/keeper/integration_test.go b/x/vesting/keeper/integration_test.go index eba86832..08bc23ca 100644 --- a/x/vesting/keeper/integration_test.go +++ b/x/vesting/keeper/integration_test.go @@ -29,12 +29,16 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" sdkstakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" sdkstakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/sedaprotocol/seda-chain/app" "github.com/sedaprotocol/seda-chain/app/params" "github.com/sedaprotocol/seda-chain/integration" + pubkeykeeper "github.com/sedaprotocol/seda-chain/x/pubkey/keeper" + pubkeytypes "github.com/sedaprotocol/seda-chain/x/pubkey/types" "github.com/sedaprotocol/seda-chain/x/staking" stakingkeeper "github.com/sedaprotocol/seda-chain/x/staking/keeper" "github.com/sedaprotocol/seda-chain/x/vesting" @@ -123,9 +127,26 @@ func initFixture(tb testing.TB) *fixture { err := stakingKeeper.SetParams(newCtx, stakingParams) require.NoError(tb, err) + slashingKeeper := slashingkeeper.NewKeeper( + cdc, + nil, + runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), + stakingKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + pubKeyKeeper := pubkeykeeper.NewKeeper( + cdc, + runtime.NewKVStoreService(keys[pubkeytypes.StoreKey]), + stakingKeeper, + slashingKeeper, + addresscodec.NewBech32Codec(params.Bech32PrefixValAddr), + authtypes.NewModuleAddress("gov").String(), + ) + authModule := auth.NewAppModule(cdc, accountKeeper, app.RandomGenesisAccounts, nil) bankModule := bank.NewAppModule(cdc, bankKeeper, accountKeeper, nil) - stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, nil) + stakingModule := staking.NewAppModule(cdc, stakingKeeper, accountKeeper, bankKeeper, pubKeyKeeper) vestingModule := vesting.NewAppModule(accountKeeper, bankKeeper, stakingKeeper) integrationApp := integration.NewIntegrationApp(newCtx, logger, keys, cdc, map[string]appmodule.AppModule{