From bb62bc1be29c6a5fe8d06cc3c7d30a5d6e33c148 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 20 Sep 2024 21:34:24 +0530 Subject: [PATCH] refactor(authority): message update chain info to update single chains (#2890) * refactor update info message * add new message to remove chain info * generate files * update comments * Update docs/releases/v21_breaking_changes.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * resolver comments --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Dmitry S <11892559+swift1337@users.noreply.github.com> --- changelog.md | 1 + docs/cli/zetacored/cli.md | 54 +++ docs/openapi/openapi.swagger.yaml | 3 + docs/releases/v21_breaking_changes.md | 11 + docs/spec/authority/messages.md | 18 +- proto/zetachain/zetacore/authority/tx.proto | 18 +- testutil/testdata/types/chain.json | 9 + .../zetachain/zetacore/authority/tx_pb.d.ts | 58 ++- x/authority/client/cli/tx.go | 1 + .../client/cli/tx_remove_chain_info.go | 39 ++ .../client/cli/tx_update_chain_info.go | 18 +- .../client/cli/tx_update_chain_info_test.go | 47 +- .../keeper/msg_server_remove_chain_info.go | 45 ++ .../msg_server_remove_chain_info_test.go | 184 +++++++ .../keeper/msg_server_update_chain_info.go | 28 +- .../msg_server_update_chain_info_test.go | 46 +- x/authority/types/authorization_list.go | 1 + x/authority/types/authorization_list_test.go | 1 + x/authority/types/codec.go | 2 + x/authority/types/errors.go | 2 + .../types/message_remove_chain_info.go | 46 ++ .../types/message_remove_chain_info_test.go | 90 ++++ .../types/message_update_chain_info.go | 15 +- .../types/message_update_chain_info_test.go | 32 +- x/authority/types/tx.pb.go | 453 ++++++++++++++++-- 25 files changed, 1087 insertions(+), 135 deletions(-) create mode 100644 docs/releases/v21_breaking_changes.md create mode 100644 testutil/testdata/types/chain.json create mode 100644 x/authority/client/cli/tx_remove_chain_info.go create mode 100644 x/authority/keeper/msg_server_remove_chain_info.go create mode 100644 x/authority/keeper/msg_server_remove_chain_info_test.go create mode 100644 x/authority/types/message_remove_chain_info.go create mode 100644 x/authority/types/message_remove_chain_info_test.go diff --git a/changelog.md b/changelog.md index 9d68531972..207dcc1311 100644 --- a/changelog.md +++ b/changelog.md @@ -18,6 +18,7 @@ * [2725](https://github.com/zeta-chain/node/pull/2725) - refactor SetCctxAndNonceToCctxAndInboundHashToCctx to receive tsspubkey as an argument * [2802](https://github.com/zeta-chain/node/pull/2802) - set default liquidity cap for new ZRC20s * [2826](https://github.com/zeta-chain/node/pull/2826) - remove unused code from emissions module and add new parameter for fixed block reward amount +* [2890](https://github.com/zeta-chain/node/pull/2890) - refactor `MsgUpdateChainInfo` to accept a single chain, and add `MsgRemoveChainInfo` to remove a chain ### Tests diff --git a/docs/cli/zetacored/cli.md b/docs/cli/zetacored/cli.md index 99fad7198c..a8719cf83f 100644 --- a/docs/cli/zetacored/cli.md +++ b/docs/cli/zetacored/cli.md @@ -8174,6 +8174,7 @@ zetacored tx authority [flags] * [zetacored tx](#zetacored-tx) - Transactions subcommands * [zetacored tx authority add-authorization](#zetacored-tx-authority-add-authorization) - Add a new authorization or update the policy of an existing authorization. Policy type can be 0 for groupEmergency, 1 for groupOperational, 2 for groupAdmin. * [zetacored tx authority remove-authorization](#zetacored-tx-authority-remove-authorization) - removes an existing authorization +* [zetacored tx authority remove-chain-info](#zetacored-tx-authority-remove-chain-info) - Remove the chain info for the specified chain id * [zetacored tx authority update-chain-info](#zetacored-tx-authority-update-chain-info) - Update the chain info * [zetacored tx authority update-policies](#zetacored-tx-authority-update-policies) - Update policies to values provided in the JSON file. @@ -8283,6 +8284,59 @@ zetacored tx authority remove-authorization [msg-url] [flags] * [zetacored tx authority](#zetacored-tx-authority) - authority transactions subcommands +## zetacored tx authority remove-chain-info + +Remove the chain info for the specified chain id + +``` +zetacored tx authority remove-chain-info [chain-id] [flags] +``` + +### Options + +``` + -a, --account-number uint The account number of the signing account (offline mode only) + --aux Generate aux signer data instead of sending a tx + -b, --broadcast-mode string Transaction broadcasting mode (sync|async) + --chain-id string The network chain ID + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) + -h, --help help for remove-chain-info + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string [host]:[port] to tendermint rpc interface for this chain + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) + -s, --sequence uint The sequence number of the signing account (offline mode only) + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator + -y, --yes Skip tx broadcasting prompt confirmation +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --log_no_color Disable colored logs + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx authority](#zetacored-tx-authority) - authority transactions subcommands + ## zetacored tx authority update-chain-info Update the chain info diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 5c791c13a7..43ec9bc0e1 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -56838,6 +56838,9 @@ definitions: description: |- MsgRemoveAuthorizationResponse defines the MsgRemoveAuthorizationResponse service. + authorityMsgRemoveChainInfoResponse: + type: object + description: MsgRemoveChainInfoResponse defines the MsgRemoveChainInfoResponse service. authorityMsgUpdateChainInfoResponse: type: object description: MsgUpdateChainInfoResponse defines the MsgUpdateChainInfoResponse service. diff --git a/docs/releases/v21_breaking_changes.md b/docs/releases/v21_breaking_changes.md new file mode 100644 index 0000000000..df82831bad --- /dev/null +++ b/docs/releases/v21_breaking_changes.md @@ -0,0 +1,11 @@ + +# V21 Breaking Changes + +### Update chain info refactored + +* The `update_chain_info` message has been refactored to update/add a single chain ,instead of providing the entire list as `ChainInfo` + * The user is now required to provide a json file with the details of the chain to be updated/added. + * If the chain already exists, the details will be updated. + * If the chain does not exist, it will be added to the list of chains and saved to the store. + * A new transaction type `RemoveChainInfo` has also been added to remove a chain from the list of chains. + * It accepts the chain-id of the chain to be removed as a parameter. \ No newline at end of file diff --git a/docs/spec/authority/messages.md b/docs/spec/authority/messages.md index 8ee4264bab..222e45d7e1 100644 --- a/docs/spec/authority/messages.md +++ b/docs/spec/authority/messages.md @@ -13,13 +13,25 @@ message MsgUpdatePolicies { ## MsgUpdateChainInfo -UpdateChainInfo updates the chain info structure that adds new static chain info or overwrite existing chain info -on the hard-coded chain info +UpdateChainInfo updates the chain info object +If the provided chain does not exist in the chain info object, it is added +If the chain already exists in the chain info object, it is updated ```proto message MsgUpdateChainInfo { string creator = 1; - ChainInfo chain_info = 2; + pkg.chains.Chain chain = 3; +} +``` + +## MsgRemoveChainInfo + +RemoveChainInfo removes the chain info for the specified chain id + +```proto +message MsgRemoveChainInfo { + string creator = 1; + int64 chain_id = 2; } ``` diff --git a/proto/zetachain/zetacore/authority/tx.proto b/proto/zetachain/zetacore/authority/tx.proto index 23d041198b..1fd610fb89 100644 --- a/proto/zetachain/zetacore/authority/tx.proto +++ b/proto/zetachain/zetacore/authority/tx.proto @@ -4,6 +4,7 @@ package zetachain.zetacore.authority; import "zetachain/zetacore/authority/policies.proto"; import "zetachain/zetacore/authority/chain_info.proto"; import "zetachain/zetacore/authority/authorization.proto"; +import "zetachain/zetacore/pkg/chains/chains.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/node/x/authority/types"; @@ -12,6 +13,7 @@ option go_package = "github.com/zeta-chain/node/x/authority/types"; service Msg { rpc UpdatePolicies(MsgUpdatePolicies) returns (MsgUpdatePoliciesResponse); rpc UpdateChainInfo(MsgUpdateChainInfo) returns (MsgUpdateChainInfoResponse); + rpc RemoveChainInfo(MsgRemoveChainInfo) returns (MsgRemoveChainInfoResponse); rpc AddAuthorization(MsgAddAuthorization) returns (MsgAddAuthorizationResponse); rpc RemoveAuthorization(MsgRemoveAuthorization) @@ -53,8 +55,20 @@ message MsgUpdatePoliciesResponse {} // MsgUpdateChainInfo defines the MsgUpdateChainInfo service. message MsgUpdateChainInfo { string creator = 1; - ChainInfo chain_info = 2 [ (gogoproto.nullable) = false ]; + pkg.chains.Chain chain = 3 [ (gogoproto.nullable) = false ]; + + // Do not edit + reserved 2; } // MsgUpdateChainInfoResponse defines the MsgUpdateChainInfoResponse service. -message MsgUpdateChainInfoResponse {} \ No newline at end of file +message MsgUpdateChainInfoResponse {} + +// MsgRemoveChainInfo defines the MsgRemoveChainInfo service. +message MsgRemoveChainInfo { + string creator = 1; + int64 chain_id = 2; +} + +// MsgRemoveChainInfoResponse defines the MsgRemoveChainInfoResponse service. +message MsgRemoveChainInfoResponse {} \ No newline at end of file diff --git a/testutil/testdata/types/chain.json b/testutil/testdata/types/chain.json new file mode 100644 index 0000000000..90614862cd --- /dev/null +++ b/testutil/testdata/types/chain.json @@ -0,0 +1,9 @@ +{ + "chain_id": 1, + "network": 1, + "network_type": 3, + "vm": 2, + "consensus": 4, + "is_external": true, + "name": "testchain" +} \ No newline at end of file diff --git a/typescript/zetachain/zetacore/authority/tx_pb.d.ts b/typescript/zetachain/zetacore/authority/tx_pb.d.ts index 827b942c9b..c48580369c 100644 --- a/typescript/zetachain/zetacore/authority/tx_pb.d.ts +++ b/typescript/zetachain/zetacore/authority/tx_pb.d.ts @@ -6,7 +6,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; import type { Policies, PolicyType } from "./policies_pb.js"; -import type { ChainInfo } from "./chain_info_pb.js"; +import type { Chain } from "../pkg/chains/chains_pb.js"; /** * MsgAddAuthorization defines the MsgAddAuthorization service. @@ -185,9 +185,9 @@ export declare class MsgUpdateChainInfo extends Message { creator: string; /** - * @generated from field: zetachain.zetacore.authority.ChainInfo chain_info = 2; + * @generated from field: zetachain.zetacore.pkg.chains.Chain chain = 3; */ - chainInfo?: ChainInfo; + chain?: Chain; constructor(data?: PartialMessage); @@ -225,3 +225,55 @@ export declare class MsgUpdateChainInfoResponse extends Message | undefined, b: MsgUpdateChainInfoResponse | PlainMessage | undefined): boolean; } +/** + * MsgRemoveChainInfo defines the MsgRemoveChainInfo service. + * + * @generated from message zetachain.zetacore.authority.MsgRemoveChainInfo + */ +export declare class MsgRemoveChainInfo extends Message { + /** + * @generated from field: string creator = 1; + */ + creator: string; + + /** + * @generated from field: int64 chain_id = 2; + */ + chainId: bigint; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.authority.MsgRemoveChainInfo"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgRemoveChainInfo; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgRemoveChainInfo; + + static fromJsonString(jsonString: string, options?: Partial): MsgRemoveChainInfo; + + static equals(a: MsgRemoveChainInfo | PlainMessage | undefined, b: MsgRemoveChainInfo | PlainMessage | undefined): boolean; +} + +/** + * MsgRemoveChainInfoResponse defines the MsgRemoveChainInfoResponse service. + * + * @generated from message zetachain.zetacore.authority.MsgRemoveChainInfoResponse + */ +export declare class MsgRemoveChainInfoResponse extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.authority.MsgRemoveChainInfoResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgRemoveChainInfoResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgRemoveChainInfoResponse; + + static fromJsonString(jsonString: string, options?: Partial): MsgRemoveChainInfoResponse; + + static equals(a: MsgRemoveChainInfoResponse | PlainMessage | undefined, b: MsgRemoveChainInfoResponse | PlainMessage | undefined): boolean; +} + diff --git a/x/authority/client/cli/tx.go b/x/authority/client/cli/tx.go index 6a0cfb803e..68c4e66a72 100644 --- a/x/authority/client/cli/tx.go +++ b/x/authority/client/cli/tx.go @@ -22,6 +22,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand( CmdUpdatePolicies(), CmdUpdateChainInfo(), + CmdRemoveChainInfo(), CmdAddAuthorization(), CmdRemoveAuthorization(), ) diff --git a/x/authority/client/cli/tx_remove_chain_info.go b/x/authority/client/cli/tx_remove_chain_info.go new file mode 100644 index 0000000000..13e94e4aeb --- /dev/null +++ b/x/authority/client/cli/tx_remove_chain_info.go @@ -0,0 +1,39 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + + "github.com/zeta-chain/node/x/authority/types" +) + +func CmdRemoveChainInfo() *cobra.Command { + cmd := &cobra.Command{ + Use: "remove-chain-info [chain-id]", + Short: "Remove the chain info for the specified chain id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + chainID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return err + } + + msg := types.NewMsgRemoveChainInfo( + clientCtx.GetFromAddress().String(), + chainID) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/authority/client/cli/tx_update_chain_info.go b/x/authority/client/cli/tx_update_chain_info.go index ff133577a1..9f19ce4064 100644 --- a/x/authority/client/cli/tx_update_chain_info.go +++ b/x/authority/client/cli/tx_update_chain_info.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" + "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/x/authority/types" ) @@ -20,7 +21,7 @@ func CmdUpdateChainInfo() *cobra.Command { Short: "Update the chain info", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { - chainInfo, err := ReadChainInfoFromFile(os.DirFS("."), args[0]) + chainInfo, err := ReadChainFromFile(os.DirFS("."), args[0]) if err != nil { return err } @@ -42,14 +43,13 @@ func CmdUpdateChainInfo() *cobra.Command { return cmd } -// ReadChainInfoFromFile read the chain info from the file using os package and unmarshal it into the chain info variable -func ReadChainInfoFromFile(fsys fs.FS, filePath string) (types.ChainInfo, error) { - var chainInfo types.ChainInfo - chainInfoBytes, err := fs.ReadFile(fsys, filePath) +// ReadChainFromFile reads a chain from a file and returns the chain object. +func ReadChainFromFile(fsys fs.FS, filePath string) (chains.Chain, error) { + var c chains.Chain + chainBytes, err := fs.ReadFile(fsys, filePath) if err != nil { - return chainInfo, fmt.Errorf("failed to read file: %w", err) + return c, fmt.Errorf("failed to read file: %w", err) } - - err = json.Unmarshal(chainInfoBytes, &chainInfo) - return chainInfo, err + err = json.Unmarshal(chainBytes, &c) + return c, err } diff --git a/x/authority/client/cli/tx_update_chain_info_test.go b/x/authority/client/cli/tx_update_chain_info_test.go index 10581a8c5e..219f827711 100644 --- a/x/authority/client/cli/tx_update_chain_info_test.go +++ b/x/authority/client/cli/tx_update_chain_info_test.go @@ -4,37 +4,34 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/testutil/testdata" "github.com/zeta-chain/node/x/authority/client/cli" ) func TestReadChainInfoFromFile(t *testing.T) { - fs := testdata.TypesFiles + t.Run("successfully read file", func(t *testing.T) { + fs := testdata.TypesFiles + + chain, err := cli.ReadChainFromFile(fs, "types/chain.json") + require.NoError(t, err) + + require.EqualValues(t, chains.Chain{ + ChainId: 1, + Network: chains.Network_zeta, + NetworkType: chains.NetworkType_devnet, + Vm: chains.Vm_svm, + Consensus: chains.Consensus_solana_consensus, + IsExternal: true, + CctxGateway: chains.CCTXGateway_zevm, + Name: "testchain", + }, chain) + }) - chainInfo, err := cli.ReadChainInfoFromFile(fs, "types/chain_info.json") - require.NoError(t, err) + t.Run("file not found", func(t *testing.T) { + fs := testdata.TypesFiles - require.Len(t, chainInfo.Chains, 2) - require.EqualValues(t, chains.Chain{ - ChainId: 42, - Network: chains.Network_eth, - NetworkType: chains.NetworkType_mainnet, - Vm: chains.Vm_no_vm, - Consensus: chains.Consensus_ethereum, - IsExternal: false, - CctxGateway: chains.CCTXGateway_zevm, - Name: "foo", - }, chainInfo.Chains[0]) - require.EqualValues(t, chains.Chain{ - ChainId: 84, - Network: chains.Network_zeta, - NetworkType: chains.NetworkType_testnet, - Vm: chains.Vm_evm, - Consensus: chains.Consensus_tendermint, - IsExternal: true, - CctxGateway: chains.CCTXGateway_observers, - Name: "bar", - }, chainInfo.Chains[1]) + _, err := cli.ReadChainFromFile(fs, "types/chain_not_found.json") + require.Error(t, err) + }) } diff --git a/x/authority/keeper/msg_server_remove_chain_info.go b/x/authority/keeper/msg_server_remove_chain_info.go new file mode 100644 index 0000000000..b559f5d2ae --- /dev/null +++ b/x/authority/keeper/msg_server_remove_chain_info.go @@ -0,0 +1,45 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/zeta-chain/node/x/authority/types" +) + +// RemoveChainInfo removes the chain info for the specified chain id +func (k msgServer) RemoveChainInfo( + goCtx context.Context, + msg *types.MsgRemoveChainInfo, +) (*types.MsgRemoveChainInfoResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // Check the authorization for this message against the authorization list + err := k.CheckAuthorization(ctx, msg) + if err != nil { + return nil, errors.Wrap(types.ErrUnauthorized, err.Error()) + } + + chainInfo, found := k.GetChainInfo(ctx) + if !found { + return nil, types.ErrChainInfoNotFound + } + + updatedChainInfo := RemoveChain(chainInfo, msg.ChainId) + k.SetChainInfo(ctx, updatedChainInfo) + return &types.MsgRemoveChainInfoResponse{}, nil +} + +// RemoveChain removes the chain with the given chainID from the chainInfo +// If the chain does not exist, the chainInfo is returned as is +func RemoveChain(chainInfo types.ChainInfo, chainID int64) types.ChainInfo { + updatedChainInfo := types.ChainInfo{} + for _, chain := range chainInfo.Chains { + if chain.ChainId != chainID { + updatedChainInfo.Chains = append(updatedChainInfo.Chains, chain) + } + } + return updatedChainInfo +} diff --git a/x/authority/keeper/msg_server_remove_chain_info_test.go b/x/authority/keeper/msg_server_remove_chain_info_test.go new file mode 100644 index 0000000000..91a697999b --- /dev/null +++ b/x/authority/keeper/msg_server_remove_chain_info_test.go @@ -0,0 +1,184 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/pkg/chains" + keepertest "github.com/zeta-chain/node/testutil/keeper" + "github.com/zeta-chain/node/testutil/sample" + "github.com/zeta-chain/node/x/authority/keeper" + "github.com/zeta-chain/node/x/authority/types" +) + +func TestMsgServer_RemoveChainInfo(t *testing.T) { + t.Run("can't remove chain info if not authorized", func(t *testing.T) { + k, ctx := keepertest.AuthorityKeeper(t) + msgServer := keeper.NewMsgServerImpl(*k) + msg := types.MsgRemoveChainInfo{ + Creator: sample.AccAddress(), + } + k.SetAuthorizationList(ctx, types.AuthorizationList{Authorizations: []types.Authorization{ + { + MsgUrl: sdk.MsgTypeURL(&msg), + AuthorizedPolicy: types.PolicyType_groupAdmin, + }, + }}) + + _, err := msgServer.RemoveChainInfo(sdk.WrapSDKContext(ctx), &msg) + require.ErrorIs(t, err, types.ErrUnauthorized) + }) + + t.Run("can remove chain from chain info", func(t *testing.T) { + // Arrange + k, ctx := keepertest.AuthorityKeeper(t) + msgServer := keeper.NewMsgServerImpl(*k) + k.SetAuthorizationList(ctx, types.DefaultAuthorizationsList()) + + admin := sample.AccAddress() + k.SetPolicies(ctx, types.Policies{ + Items: []*types.Policy{ + { + PolicyType: types.PolicyType_groupAdmin, + Address: admin, + }, + }, + }) + chainID := int64(42) + chainInfo := sample.ChainInfo(chainID) + k.SetChainInfo(ctx, chainInfo) + + // Act + _, err := msgServer.RemoveChainInfo(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainInfo{ + Creator: admin, + ChainId: chainID, + }) + + // Assert + require.NoError(t, err) + storedChains, found := k.GetChainInfo(ctx) + require.True(t, found) + require.Len(t, storedChains.Chains, 2) + require.NotContains(t, storedChains.Chains, chainInfo.Chains[0]) + }) + + t.Run("can remove chain from chain info containing only 1 chain", func(t *testing.T) { + // Arrange + k, ctx := keepertest.AuthorityKeeper(t) + msgServer := keeper.NewMsgServerImpl(*k) + k.SetAuthorizationList(ctx, types.DefaultAuthorizationsList()) + + admin := sample.AccAddress() + k.SetPolicies(ctx, types.Policies{ + Items: []*types.Policy{ + { + PolicyType: types.PolicyType_groupAdmin, + Address: admin, + }, + }, + }) + chainID := int64(42) + chainInfo := types.ChainInfo{Chains: []chains.Chain{{ChainId: chainID}}} + k.SetChainInfo(ctx, chainInfo) + + // Act + _, err := msgServer.RemoveChainInfo(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainInfo{ + Creator: admin, + ChainId: chainID, + }) + + // Assert + require.NoError(t, err) + storedChains, found := k.GetChainInfo(ctx) + require.True(t, found) + require.Len(t, storedChains.Chains, 0) + require.NotContains(t, storedChains.Chains, chainInfo.Chains[0]) + }) + + t.Run("can't remove chain from chain info if chain info not found", func(t *testing.T) { + // Arrange + k, ctx := keepertest.AuthorityKeeper(t) + msgServer := keeper.NewMsgServerImpl(*k) + k.SetAuthorizationList(ctx, types.DefaultAuthorizationsList()) + + admin := sample.AccAddress() + k.SetPolicies(ctx, types.Policies{ + Items: []*types.Policy{ + { + PolicyType: types.PolicyType_groupAdmin, + Address: admin, + }, + }, + }) + + // Act + _, err := msgServer.RemoveChainInfo(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainInfo{ + Creator: admin, + ChainId: 42, + }) + + // Assert + require.ErrorIs(t, err, types.ErrChainInfoNotFound) + }) + + t.Run("can't remove chain from chain info if chain not found", func(t *testing.T) { + // Arrange + k, ctx := keepertest.AuthorityKeeper(t) + msgServer := keeper.NewMsgServerImpl(*k) + k.SetAuthorizationList(ctx, types.DefaultAuthorizationsList()) + + admin := sample.AccAddress() + k.SetPolicies(ctx, types.Policies{ + Items: []*types.Policy{ + { + PolicyType: types.PolicyType_groupAdmin, + Address: admin, + }, + }, + }) + chainInfo := sample.ChainInfo(42) + k.SetChainInfo(ctx, chainInfo) + + // Act + _, err := msgServer.RemoveChainInfo(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainInfo{ + Creator: admin, + ChainId: 103, + }) + + // Assert + require.NoError(t, err) + storedChains, found := k.GetChainInfo(ctx) + require.True(t, found) + require.Len(t, storedChains.Chains, 3) + }) +} + +func TestMsgServer_RemoveChain(t *testing.T) { + tt := []struct { + name string + chainInfo types.ChainInfo + removeChainID int64 + expected types.ChainInfo + }{ + { + name: "can remove chain from chain info", + chainInfo: types.ChainInfo{Chains: []chains.Chain{{ChainId: 42}, {ChainId: 43}}}, + removeChainID: 42, + expected: types.ChainInfo{Chains: []chains.Chain{{ChainId: 43}}}, + }, + { + name: "can't remove chain from chain info if chain not found", + chainInfo: types.ChainInfo{Chains: []chains.Chain{{ChainId: 42}, {ChainId: 43}}}, + removeChainID: 103, + expected: types.ChainInfo{Chains: []chains.Chain{{ChainId: 42}, {ChainId: 43}}}, + }, + } + + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + require.Equal(t, tc.expected, keeper.RemoveChain(tc.chainInfo, tc.removeChainID)) + }) + } + +} diff --git a/x/authority/keeper/msg_server_update_chain_info.go b/x/authority/keeper/msg_server_update_chain_info.go index 64d773e25f..c4f3b02018 100644 --- a/x/authority/keeper/msg_server_update_chain_info.go +++ b/x/authority/keeper/msg_server_update_chain_info.go @@ -9,8 +9,9 @@ import ( "github.com/zeta-chain/node/x/authority/types" ) -// UpdateChainInfo updates the chain info structure that adds new static chain info or overwrite existing chain info -// on the hard-coded chain info +// UpdateChainInfo updates the chain info object +// If the provided chain does not exist in the chain info object, it is added +// If the chain already exists in the chain info object, it is updated func (k msgServer) UpdateChainInfo( goCtx context.Context, msg *types.MsgUpdateChainInfo, @@ -24,8 +25,27 @@ func (k msgServer) UpdateChainInfo( if err != nil { return nil, errors.Wrap(types.ErrUnauthorized, err.Error()) } - // set chain info - k.SetChainInfo(ctx, msg.ChainInfo) + chainInfo := types.ChainInfo{} + chainInfoExist := false + + existingChainInfo, found := k.GetChainInfo(ctx) + if found { + chainInfo = existingChainInfo + } + // try to update a chain if the chain info already exists + for i, chain := range chainInfo.Chains { + if chain.ChainId == msg.Chain.ChainId { + chainInfo.Chains[i] = msg.Chain + chainInfoExist = true + } + } + + // if the chain info does not exist, add the chain to the chain info object + if !chainInfoExist { + chainInfo.Chains = append(chainInfo.Chains, msg.Chain) + } + + k.SetChainInfo(ctx, chainInfo) return &types.MsgUpdateChainInfoResponse{}, nil } diff --git a/x/authority/keeper/msg_server_update_chain_info_test.go b/x/authority/keeper/msg_server_update_chain_info_test.go index 1964688a3a..1d29e18c9f 100644 --- a/x/authority/keeper/msg_server_update_chain_info_test.go +++ b/x/authority/keeper/msg_server_update_chain_info_test.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - keepertest "github.com/zeta-chain/node/testutil/keeper" "github.com/zeta-chain/node/testutil/sample" "github.com/zeta-chain/node/x/authority/keeper" @@ -30,7 +29,7 @@ func TestMsgServer_UpdateChainInfo(t *testing.T) { require.ErrorIs(t, err, types.ErrUnauthorized) }) - t.Run("can set chain info when it doesn't exist", func(t *testing.T) { + t.Run("can set new chain info if it doesnt exist", func(t *testing.T) { k, ctx := keepertest.AuthorityKeeper(t) msgServer := keeper.NewMsgServerImpl(*k) @@ -47,20 +46,20 @@ func TestMsgServer_UpdateChainInfo(t *testing.T) { }, }, }) - chainInfo := sample.ChainInfo(42) + chain := sample.Chain(42) k.SetAuthorizationList(ctx, types.DefaultAuthorizationsList()) _, err := msgServer.UpdateChainInfo(sdk.WrapSDKContext(ctx), &types.MsgUpdateChainInfo{ - Creator: admin, - ChainInfo: chainInfo, + Creator: admin, + Chain: chain, }) require.NoError(t, err) // Check if the chain info is set storedChainInfo, found := k.GetChainInfo(ctx) require.True(t, found) - require.Equal(t, chainInfo, storedChainInfo) + require.Contains(t, storedChainInfo.Chains, chain) }) t.Run("can update existing chain info", func(t *testing.T) { @@ -79,22 +78,32 @@ func TestMsgServer_UpdateChainInfo(t *testing.T) { }, }, }) - chainInfo := sample.ChainInfo(84) + chainID := int64(42) + chainInfo := sample.ChainInfo(1) + chainInfo.Chains[0].ChainId = chainID + + chainInfo.Chains[0].Name = "name" + k.SetChainInfo(ctx, chainInfo) + chainInfo.Chains[0].Name = "updated name" k.SetAuthorizationList(ctx, types.DefaultAuthorizationsList()) _, err := msgServer.UpdateChainInfo(sdk.WrapSDKContext(ctx), &types.MsgUpdateChainInfo{ - Creator: admin, - ChainInfo: chainInfo, + Creator: admin, + Chain: chainInfo.Chains[0], }) require.NoError(t, err) - // Check if the chain info is set + // Check if the chain info is set and updated storedChainInfo, found := k.GetChainInfo(ctx) require.True(t, found) - require.Equal(t, chainInfo, storedChainInfo) + for _, chain := range storedChainInfo.Chains { + if chain.ChainId == chainID { + require.Equal(t, "updated name", chain.Name) + } + } }) - t.Run("can remove chain info", func(t *testing.T) { + t.Run("add chain to chain info if chain dos not exist", func(t *testing.T) { k, ctx := keepertest.AuthorityKeeper(t) msgServer := keeper.NewMsgServerImpl(*k) @@ -110,19 +119,20 @@ func TestMsgServer_UpdateChainInfo(t *testing.T) { }, }, }) - chainInfo := types.ChainInfo{} + chainID := int64(103) + newChain := sample.Chain(chainID) k.SetAuthorizationList(ctx, types.DefaultAuthorizationsList()) _, err := msgServer.UpdateChainInfo(sdk.WrapSDKContext(ctx), &types.MsgUpdateChainInfo{ - Creator: admin, - ChainInfo: chainInfo, + Creator: admin, + Chain: newChain, }) require.NoError(t, err) - // The structure should still exist but be empty + // Check if the chain info is set and updated storedChainInfo, found := k.GetChainInfo(ctx) require.True(t, found) - require.Equal(t, chainInfo, storedChainInfo) + require.Equal(t, 4, len(storedChainInfo.Chains)) + require.Contains(t, storedChainInfo.Chains, newChain) }) - } diff --git a/x/authority/types/authorization_list.go b/x/authority/types/authorization_list.go index 1437ed030c..9e0da9b18f 100644 --- a/x/authority/types/authorization_list.go +++ b/x/authority/types/authorization_list.go @@ -39,6 +39,7 @@ var ( "/zetachain.zetacore.authority.MsgAddAuthorization", "/zetachain.zetacore.authority.MsgRemoveAuthorization", "/zetachain.zetacore.authority.MsgUpdateChainInfo", + "/zetachain.zetacore.authority.MsgRemoveChainInfo", "/zetachain.zetacore.lightclient.MsgEnableHeaderVerification", } // EmergencyPolicyMessages keeps track of the message URLs that can, by default, only be executed by emergency policy address diff --git a/x/authority/types/authorization_list_test.go b/x/authority/types/authorization_list_test.go index 1585e079ca..37bac846f7 100644 --- a/x/authority/types/authorization_list_test.go +++ b/x/authority/types/authorization_list_test.go @@ -430,6 +430,7 @@ func TestDefaultAuthorizationsList(t *testing.T) { sdk.MsgTypeURL(&types.MsgAddAuthorization{}), sdk.MsgTypeURL(&types.MsgRemoveAuthorization{}), sdk.MsgTypeURL(&types.MsgUpdateChainInfo{}), + sdk.MsgTypeURL(&types.MsgRemoveChainInfo{}), sdk.MsgTypeURL(&lightclienttypes.MsgEnableHeaderVerification{}), } defaultList := types.DefaultAuthorizationsList() diff --git a/x/authority/types/codec.go b/x/authority/types/codec.go index 0eddb04819..eb2dfe0eb2 100644 --- a/x/authority/types/codec.go +++ b/x/authority/types/codec.go @@ -10,12 +10,14 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdatePolicies{}, "authority/UpdatePolicies", nil) cdc.RegisterConcrete(&MsgUpdateChainInfo{}, "authority/UpdateChainInfo", nil) + cdc.RegisterConcrete(&MsgRemoveChainInfo{}, "authority/RemoveChainInfo", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdatePolicies{}, &MsgUpdateChainInfo{}, + &MsgRemoveChainInfo{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/authority/types/errors.go b/x/authority/types/errors.go index 776132d525..81edcbf387 100644 --- a/x/authority/types/errors.go +++ b/x/authority/types/errors.go @@ -12,4 +12,6 @@ var ( ErrPoliciesNotFound = errorsmod.Register(ModuleName, 1108, "policies not found") ErrSignerDoesntMatch = errorsmod.Register(ModuleName, 1109, "signer doesn't match required policy") ErrInvalidPolicyType = errorsmod.Register(ModuleName, 1110, "invalid policy type") + + ErrChainInfoNotFound = errorsmod.Register(ModuleName, 1111, "chain info not found") ) diff --git a/x/authority/types/message_remove_chain_info.go b/x/authority/types/message_remove_chain_info.go new file mode 100644 index 0000000000..9f06d2a298 --- /dev/null +++ b/x/authority/types/message_remove_chain_info.go @@ -0,0 +1,46 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgRemoveChainInfo = "RemoveChainInfo" + +var _ sdk.Msg = &MsgRemoveChainInfo{} + +func NewMsgRemoveChainInfo(creator string, chainID int64) *MsgRemoveChainInfo { + return &MsgRemoveChainInfo{ + Creator: creator, + ChainId: chainID, + } +} + +func (msg *MsgRemoveChainInfo) Route() string { + return RouterKey +} + +func (msg *MsgRemoveChainInfo) Type() string { + return TypeMsgRemoveChainInfo +} + +func (msg *MsgRemoveChainInfo) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} + +func (msg *MsgRemoveChainInfo) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgRemoveChainInfo) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/authority/types/message_remove_chain_info_test.go b/x/authority/types/message_remove_chain_info_test.go new file mode 100644 index 0000000000..46bb882613 --- /dev/null +++ b/x/authority/types/message_remove_chain_info_test.go @@ -0,0 +1,90 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/zeta-chain/node/testutil/sample" + "github.com/zeta-chain/node/x/authority/types" +) + +func TestMsgRemoveChainInfo_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg *types.MsgRemoveChainInfo + errContains string + }{ + { + name: "valid message", + msg: types.NewMsgRemoveChainInfo(sample.AccAddress(), 42), + }, + { + name: "invalid creator address", + msg: types.NewMsgRemoveChainInfo("invalid", 42), + errContains: "invalid creator address", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.errContains != "" { + require.ErrorContains(t, err, tt.errContains) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgRemoveChainInfo_GetSigners(t *testing.T) { + signer := sample.AccAddress() + tests := []struct { + name string + msg *types.MsgRemoveChainInfo + panics bool + }{ + { + name: "valid signer", + msg: types.NewMsgRemoveChainInfo(signer, 42), + panics: false, + }, + { + name: "invalid signer", + msg: types.NewMsgRemoveChainInfo("invalid", 42), + panics: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if !tt.panics { + signers := tt.msg.GetSigners() + require.Equal(t, []sdk.AccAddress{sdk.MustAccAddressFromBech32(signer)}, signers) + } else { + require.Panics(t, func() { + tt.msg.GetSigners() + }) + } + }) + } +} + +func TestMsgRemoveChainInfo_Type(t *testing.T) { + msg := types.NewMsgRemoveChainInfo(sample.AccAddress(), 42) + require.Equal(t, types.TypeMsgRemoveChainInfo, msg.Type()) +} + +func TestMsgRemoveChainInfo_Route(t *testing.T) { + msg := types.NewMsgRemoveChainInfo(sample.AccAddress(), 42) + require.Equal(t, types.RouterKey, msg.Route()) +} + +func TestMsgRemoveChainInfo_GetSignBytes(t *testing.T) { + msg := types.NewMsgRemoveChainInfo(sample.AccAddress(), 42) + require.NotPanics(t, func() { + msg.GetSignBytes() + }) +} diff --git a/x/authority/types/message_update_chain_info.go b/x/authority/types/message_update_chain_info.go index faea9dcacb..65b83545e4 100644 --- a/x/authority/types/message_update_chain_info.go +++ b/x/authority/types/message_update_chain_info.go @@ -4,16 +4,18 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/zeta-chain/node/pkg/chains" ) const TypeMsgUpdateChainInfo = "UpdateChainInfo" var _ sdk.Msg = &MsgUpdateChainInfo{} -func NewMsgUpdateChainInfo(creator string, chainInfo ChainInfo) *MsgUpdateChainInfo { +func NewMsgUpdateChainInfo(creator string, chain chains.Chain) *MsgUpdateChainInfo { return &MsgUpdateChainInfo{ - Creator: creator, - ChainInfo: chainInfo, + Creator: creator, + Chain: chain, } } @@ -43,9 +45,10 @@ func (msg *MsgUpdateChainInfo) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - // the chain information must be valid - if err := msg.ChainInfo.Validate(); err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain info: %s", err.Error()) + // the chain must be valid + if err := msg.Chain.Validate(); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain"+ + ": %s", err.Error()) } return nil diff --git a/x/authority/types/message_update_chain_info_test.go b/x/authority/types/message_update_chain_info_test.go index 0e77533d16..dc54098b7c 100644 --- a/x/authority/types/message_update_chain_info_test.go +++ b/x/authority/types/message_update_chain_info_test.go @@ -19,29 +19,17 @@ func TestMsgUpdateChainInfo_ValidateBasic(t *testing.T) { }{ { name: "valid message", - msg: types.NewMsgUpdateChainInfo(sample.AccAddress(), sample.ChainInfo(42)), + msg: types.NewMsgUpdateChainInfo(sample.AccAddress(), sample.Chain(42)), }, { name: "invalid creator address", - msg: types.NewMsgUpdateChainInfo("invalid", sample.ChainInfo(42)), + msg: types.NewMsgUpdateChainInfo("invalid", sample.Chain(42)), errContains: "invalid creator address", }, { - name: "invalid chain info", - msg: types.NewMsgUpdateChainInfo(sample.AccAddress(), types.ChainInfo{ - Chains: []chains.Chain{ - { - ChainId: 0, - Network: chains.Network_optimism, - NetworkType: chains.NetworkType_testnet, - Vm: chains.Vm_evm, - Consensus: chains.Consensus_op_stack, - IsExternal: true, - Name: "foo", - }, - }, - }), - errContains: "invalid chain info", + name: "invalid chain", + msg: types.NewMsgUpdateChainInfo(sample.AccAddress(), chains.Chain{ChainId: -1}), + errContains: "invalid chain", }, } @@ -66,12 +54,12 @@ func TestMsgUpdateChainInfo_GetSigners(t *testing.T) { }{ { name: "valid signer", - msg: types.NewMsgUpdateChainInfo(signer, sample.ChainInfo(42)), + msg: types.NewMsgUpdateChainInfo(signer, sample.Chain(42)), panics: false, }, { name: "invalid signer", - msg: types.NewMsgUpdateChainInfo("invalid", sample.ChainInfo(42)), + msg: types.NewMsgUpdateChainInfo("invalid", sample.Chain(42)), panics: true, }, } @@ -91,17 +79,17 @@ func TestMsgUpdateChainInfo_GetSigners(t *testing.T) { } func TestMsgUpdateChainInfo_Type(t *testing.T) { - msg := types.NewMsgUpdateChainInfo(sample.AccAddress(), sample.ChainInfo(42)) + msg := types.NewMsgUpdateChainInfo(sample.AccAddress(), sample.Chain(42)) require.Equal(t, types.TypeMsgUpdateChainInfo, msg.Type()) } func TestMsgUpdateChainInfo_Route(t *testing.T) { - msg := types.NewMsgUpdateChainInfo(sample.AccAddress(), sample.ChainInfo(42)) + msg := types.NewMsgUpdateChainInfo(sample.AccAddress(), sample.Chain(42)) require.Equal(t, types.RouterKey, msg.Route()) } func TestMsgUpdateChainInfo_GetSignBytes(t *testing.T) { - msg := types.NewMsgUpdateChainInfo(sample.AccAddress(), sample.ChainInfo(42)) + msg := types.NewMsgUpdateChainInfo(sample.AccAddress(), sample.Chain(42)) require.NotPanics(t, func() { msg.GetSignBytes() }) diff --git a/x/authority/types/tx.pb.go b/x/authority/types/tx.pb.go index 1a021c4311..ea316d33a2 100644 --- a/x/authority/types/tx.pb.go +++ b/x/authority/types/tx.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + chains "github.com/zeta-chain/node/pkg/chains" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -312,8 +313,8 @@ var xxx_messageInfo_MsgUpdatePoliciesResponse proto.InternalMessageInfo // MsgUpdateChainInfo defines the MsgUpdateChainInfo service. type MsgUpdateChainInfo struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - ChainInfo ChainInfo `protobuf:"bytes,2,opt,name=chain_info,json=chainInfo,proto3" json:"chain_info"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Chain chains.Chain `protobuf:"bytes,3,opt,name=chain,proto3" json:"chain"` } func (m *MsgUpdateChainInfo) Reset() { *m = MsgUpdateChainInfo{} } @@ -356,11 +357,11 @@ func (m *MsgUpdateChainInfo) GetCreator() string { return "" } -func (m *MsgUpdateChainInfo) GetChainInfo() ChainInfo { +func (m *MsgUpdateChainInfo) GetChain() chains.Chain { if m != nil { - return m.ChainInfo + return m.Chain } - return ChainInfo{} + return chains.Chain{} } // MsgUpdateChainInfoResponse defines the MsgUpdateChainInfoResponse service. @@ -400,6 +401,96 @@ func (m *MsgUpdateChainInfoResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateChainInfoResponse proto.InternalMessageInfo +// MsgRemoveChainInfo defines the MsgRemoveChainInfo service. +type MsgRemoveChainInfo struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *MsgRemoveChainInfo) Reset() { *m = MsgRemoveChainInfo{} } +func (m *MsgRemoveChainInfo) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveChainInfo) ProtoMessage() {} +func (*MsgRemoveChainInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_42e081863c477116, []int{8} +} +func (m *MsgRemoveChainInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveChainInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveChainInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRemoveChainInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveChainInfo.Merge(m, src) +} +func (m *MsgRemoveChainInfo) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveChainInfo) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveChainInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveChainInfo proto.InternalMessageInfo + +func (m *MsgRemoveChainInfo) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgRemoveChainInfo) GetChainId() int64 { + if m != nil { + return m.ChainId + } + return 0 +} + +// MsgRemoveChainInfoResponse defines the MsgRemoveChainInfoResponse service. +type MsgRemoveChainInfoResponse struct { +} + +func (m *MsgRemoveChainInfoResponse) Reset() { *m = MsgRemoveChainInfoResponse{} } +func (m *MsgRemoveChainInfoResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveChainInfoResponse) ProtoMessage() {} +func (*MsgRemoveChainInfoResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_42e081863c477116, []int{9} +} +func (m *MsgRemoveChainInfoResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveChainInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveChainInfoResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRemoveChainInfoResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveChainInfoResponse.Merge(m, src) +} +func (m *MsgRemoveChainInfoResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveChainInfoResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveChainInfoResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveChainInfoResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgAddAuthorization)(nil), "zetachain.zetacore.authority.MsgAddAuthorization") proto.RegisterType((*MsgAddAuthorizationResponse)(nil), "zetachain.zetacore.authority.MsgAddAuthorizationResponse") @@ -409,6 +500,8 @@ func init() { proto.RegisterType((*MsgUpdatePoliciesResponse)(nil), "zetachain.zetacore.authority.MsgUpdatePoliciesResponse") proto.RegisterType((*MsgUpdateChainInfo)(nil), "zetachain.zetacore.authority.MsgUpdateChainInfo") proto.RegisterType((*MsgUpdateChainInfoResponse)(nil), "zetachain.zetacore.authority.MsgUpdateChainInfoResponse") + proto.RegisterType((*MsgRemoveChainInfo)(nil), "zetachain.zetacore.authority.MsgRemoveChainInfo") + proto.RegisterType((*MsgRemoveChainInfoResponse)(nil), "zetachain.zetacore.authority.MsgRemoveChainInfoResponse") } func init() { @@ -416,38 +509,42 @@ func init() { } var fileDescriptor_42e081863c477116 = []byte{ - // 491 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0xaf, 0xd9, 0xb4, 0xb1, 0x87, 0x34, 0xb6, 0x0c, 0x41, 0xc9, 0x46, 0xa8, 0x22, 0x01, 0x95, - 0x60, 0xc9, 0x28, 0x48, 0x80, 0xc4, 0x65, 0x43, 0x42, 0x20, 0xa8, 0x34, 0x45, 0xf4, 0xc2, 0xa5, - 0xca, 0x12, 0xcf, 0xb5, 0xd4, 0xc6, 0x51, 0xec, 0xc2, 0x5a, 0x81, 0xc4, 0x95, 0x13, 0x7c, 0x03, - 0xbe, 0xce, 0x8e, 0x3b, 0x72, 0x42, 0xa8, 0xfd, 0x22, 0x68, 0x6e, 0xec, 0x4d, 0x4d, 0xe4, 0xb5, - 0xec, 0xf6, 0x62, 0xff, 0xfe, 0xf9, 0x39, 0x7e, 0x70, 0x6f, 0x88, 0x45, 0x18, 0x75, 0x42, 0x9a, - 0xf8, 0xb2, 0x62, 0x19, 0xf6, 0xc3, 0xbe, 0xe8, 0xb0, 0x8c, 0x8a, 0x81, 0x2f, 0x8e, 0xbc, 0x34, - 0x63, 0x82, 0x59, 0x5b, 0x1a, 0xe6, 0x29, 0x98, 0xa7, 0x61, 0xf6, 0x43, 0xa3, 0x48, 0xca, 0xba, - 0x34, 0xa2, 0x98, 0x4f, 0xa4, 0xec, 0x6d, 0x23, 0x58, 0x6e, 0xb4, 0x69, 0x72, 0xc8, 0x72, 0xf8, - 0x8e, 0x11, 0x9e, 0x57, 0xc3, 0x50, 0x50, 0x96, 0xe4, 0x8c, 0x1b, 0x84, 0x11, 0x26, 0x4b, 0xff, - 0xb4, 0x9a, 0xac, 0xba, 0xbf, 0x10, 0x6c, 0x34, 0x39, 0xd9, 0x8d, 0xe3, 0xdd, 0xf3, 0x1c, 0xab, - 0x0a, 0xcb, 0x51, 0x86, 0x43, 0xc1, 0xb2, 0x2a, 0xaa, 0xa1, 0xfa, 0x4a, 0xa0, 0x3e, 0xad, 0x5b, - 0xb0, 0xdc, 0xe3, 0xa4, 0xdd, 0xcf, 0xba, 0xd5, 0x2b, 0x72, 0x67, 0xa9, 0xc7, 0x49, 0x2b, 0xeb, - 0x5a, 0x2d, 0x58, 0x57, 0xbe, 0x38, 0x6e, 0xcb, 0xe3, 0x0d, 0xaa, 0x0b, 0x35, 0x54, 0x5f, 0x6d, - 0xd4, 0x3d, 0x53, 0xa3, 0xbc, 0x7d, 0x89, 0xfd, 0x30, 0x48, 0x71, 0xb0, 0x76, 0x26, 0x31, 0x59, - 0x75, 0xef, 0xc0, 0x66, 0x49, 0xc0, 0x00, 0xf3, 0x94, 0x25, 0x1c, 0xbb, 0xef, 0xe0, 0x66, 0x93, - 0x93, 0x00, 0xf7, 0xd8, 0x27, 0x7c, 0xd9, 0x23, 0xb8, 0x35, 0x70, 0xca, 0xc5, 0xb4, 0xdd, 0x67, - 0x58, 0x6f, 0x72, 0xd2, 0x4a, 0xe3, 0x50, 0xe0, 0xfd, 0xfc, 0x06, 0x0d, 0x4e, 0x6f, 0xe0, 0xaa, - 0xba, 0x67, 0x69, 0x75, 0xad, 0x71, 0x7f, 0x86, 0x56, 0x50, 0xcc, 0xf7, 0x16, 0x8f, 0xff, 0xdc, - 0xad, 0x04, 0x9a, 0xed, 0x6e, 0xc2, 0xed, 0x82, 0xb1, 0x4e, 0xf5, 0x05, 0x2c, 0xbd, 0xf9, 0xea, - 0x54, 0xfa, 0x6d, 0x72, 0xc8, 0x0c, 0xb1, 0xde, 0x03, 0x9c, 0xfd, 0x51, 0x79, 0xb0, 0x07, 0xe6, - 0x60, 0x5a, 0x36, 0x4f, 0xb6, 0x12, 0xa9, 0x05, 0x77, 0x0b, 0xec, 0xa2, 0xbb, 0xca, 0xd6, 0xf8, - 0xb1, 0x08, 0x0b, 0x4d, 0x4e, 0xac, 0x21, 0xac, 0x4e, 0xb5, 0xcd, 0x37, 0x3b, 0x16, 0x8e, 0x6b, - 0x3f, 0x9b, 0x93, 0xa0, 0x32, 0x58, 0x5f, 0xe1, 0xfa, 0x74, 0x73, 0x76, 0x66, 0xd4, 0xd2, 0x0c, - 0xfb, 0xf9, 0xbc, 0x0c, 0x6d, 0xff, 0x0d, 0xc1, 0x5a, 0xe1, 0x85, 0x3d, 0xbe, 0x50, 0x6e, 0x9a, - 0x62, 0xbf, 0x98, 0x9b, 0xa2, 0x23, 0x7c, 0x47, 0xb0, 0x51, 0xf6, 0x48, 0x9e, 0x5e, 0x28, 0x59, - 0xc2, 0xb2, 0x5f, 0xfe, 0x0f, 0x4b, 0x65, 0xd9, 0x7b, 0x7d, 0x3c, 0x72, 0xd0, 0xc9, 0xc8, 0x41, - 0x7f, 0x47, 0x0e, 0xfa, 0x39, 0x76, 0x2a, 0x27, 0x63, 0xa7, 0xf2, 0x7b, 0xec, 0x54, 0x3e, 0x3e, - 0x22, 0x54, 0x74, 0xfa, 0x07, 0x5e, 0xc4, 0x7a, 0x72, 0xac, 0x6d, 0x4f, 0x26, 0x5c, 0xc2, 0x62, - 0xec, 0x1f, 0x9d, 0x1f, 0xc0, 0x83, 0x14, 0xf3, 0x83, 0x25, 0x39, 0xc2, 0x9e, 0xfc, 0x0b, 0x00, - 0x00, 0xff, 0xff, 0x74, 0x55, 0xd6, 0x33, 0xad, 0x05, 0x00, 0x00, + // 555 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xdf, 0x6b, 0xd3, 0x40, + 0x1c, 0x6f, 0xd6, 0xfd, 0xa8, 0xdf, 0xc1, 0xec, 0x32, 0xd1, 0x2e, 0x9b, 0xb1, 0x04, 0x95, 0xa2, + 0x2e, 0x99, 0x55, 0x50, 0xc1, 0x07, 0x37, 0x41, 0xac, 0x52, 0x18, 0xc1, 0xbe, 0xf8, 0x52, 0xb2, + 0xe6, 0x76, 0x0d, 0x6b, 0x73, 0x21, 0x77, 0x9d, 0x6b, 0x41, 0xf0, 0xd5, 0x17, 0xf1, 0x3f, 0xf0, + 0xdf, 0xd9, 0xe3, 0x1e, 0x7d, 0x12, 0x69, 0xff, 0x11, 0xd9, 0xe5, 0x72, 0xd6, 0x34, 0x66, 0xa9, + 0x3e, 0xf5, 0x92, 0xfb, 0xfc, 0xca, 0xe7, 0xd2, 0x6f, 0xe0, 0xce, 0x08, 0x31, 0xa7, 0xd3, 0x75, + 0x3c, 0xdf, 0xe2, 0x2b, 0x12, 0x22, 0xcb, 0x19, 0xb0, 0x2e, 0x09, 0x3d, 0x36, 0xb4, 0xd8, 0xa9, + 0x19, 0x84, 0x84, 0x11, 0x75, 0x5b, 0xc2, 0xcc, 0x18, 0x66, 0x4a, 0x98, 0x76, 0x3f, 0x53, 0x24, + 0x20, 0x3d, 0xaf, 0xe3, 0x21, 0x1a, 0x49, 0x69, 0x3b, 0x99, 0x60, 0xbe, 0xd1, 0xf6, 0xfc, 0x23, + 0x22, 0xe0, 0xbb, 0x99, 0x70, 0xb1, 0x1a, 0x39, 0xcc, 0x23, 0xbe, 0x60, 0xdc, 0x4b, 0x61, 0x04, + 0xc7, 0x38, 0x92, 0xa6, 0xe2, 0x47, 0x60, 0xaf, 0x61, 0x82, 0x09, 0x5f, 0x5a, 0x17, 0xab, 0xe8, + 0xae, 0xf1, 0x4d, 0x81, 0x8d, 0x26, 0xc5, 0x7b, 0xae, 0xbb, 0x37, 0xad, 0xaf, 0x56, 0x60, 0xa5, + 0x13, 0x22, 0x87, 0x91, 0xb0, 0xa2, 0x54, 0x95, 0xda, 0x15, 0x3b, 0xbe, 0x54, 0x6f, 0xc0, 0x4a, + 0x9f, 0xe2, 0xf6, 0x20, 0xec, 0x55, 0x16, 0xf8, 0xce, 0x72, 0x9f, 0xe2, 0x56, 0xd8, 0x53, 0x5b, + 0xb0, 0x1e, 0x67, 0x44, 0x6e, 0x9b, 0x57, 0x31, 0xac, 0x14, 0xab, 0x4a, 0x6d, 0xad, 0x5e, 0x33, + 0xb3, 0x4a, 0x35, 0x0f, 0x38, 0xf6, 0xdd, 0x30, 0x40, 0x76, 0xf9, 0xb7, 0x44, 0x74, 0xd7, 0xb8, + 0x09, 0x5b, 0x29, 0x01, 0x6d, 0x44, 0x03, 0xe2, 0x53, 0x64, 0xbc, 0x85, 0xeb, 0x4d, 0x8a, 0x6d, + 0xd4, 0x27, 0x27, 0xe8, 0x7f, 0x1f, 0xc1, 0xa8, 0x82, 0x9e, 0x2e, 0x26, 0xed, 0x3e, 0xc0, 0x7a, + 0x93, 0xe2, 0x56, 0xe0, 0x3a, 0x0c, 0x1d, 0x88, 0xd3, 0xce, 0x70, 0x7a, 0x0d, 0xa5, 0xf8, 0x9d, + 0xe0, 0x56, 0xab, 0xf5, 0xbb, 0x39, 0xaa, 0xf0, 0x10, 0xdd, 0x5f, 0x3c, 0xfb, 0x71, 0xab, 0x60, + 0x4b, 0xb6, 0xb1, 0x05, 0x9b, 0x33, 0xc6, 0x32, 0xd5, 0x09, 0xa8, 0x72, 0xf3, 0xe5, 0x85, 0x74, + 0xc3, 0x3f, 0x22, 0x19, 0xb1, 0x5e, 0xc0, 0x12, 0x4f, 0xc0, 0x8f, 0x67, 0xb5, 0x7e, 0x3b, 0x2d, + 0x53, 0x70, 0x8c, 0x4d, 0xf1, 0x02, 0x71, 0x49, 0x91, 0x28, 0x22, 0xbe, 0x59, 0x2c, 0x2d, 0x94, + 0x8b, 0xc6, 0x36, 0x68, 0xb3, 0xbe, 0x32, 0x55, 0x83, 0xa7, 0x8a, 0xda, 0xcc, 0x93, 0x6a, 0x13, + 0x4a, 0xe2, 0x3f, 0xe1, 0xf2, 0xb2, 0x8a, 0xf6, 0x0a, 0xbf, 0x6e, 0xb8, 0xc2, 0x28, 0x21, 0x15, + 0x1b, 0xd5, 0xbf, 0x2c, 0x41, 0xb1, 0x49, 0xb1, 0x3a, 0x82, 0xb5, 0xc4, 0xc9, 0x58, 0xd9, 0x6d, + 0xcf, 0x34, 0xaa, 0x3d, 0x99, 0x93, 0x10, 0x67, 0x50, 0x3f, 0xc2, 0xd5, 0x64, 0xff, 0xbb, 0x39, + 0xb5, 0x24, 0x43, 0x7b, 0x3a, 0x2f, 0x63, 0xda, 0x3e, 0x59, 0xf4, 0xe5, 0xf6, 0x09, 0x46, 0x0e, + 0xfb, 0xbf, 0x9c, 0x80, 0xfa, 0x49, 0x81, 0xf2, 0xcc, 0x0c, 0x79, 0x78, 0xa9, 0x5c, 0x92, 0xa2, + 0x3d, 0x9b, 0x9b, 0x22, 0x23, 0x7c, 0x56, 0x60, 0x23, 0x6d, 0x0c, 0x3c, 0xce, 0xf9, 0x50, 0x7f, + 0x06, 0x79, 0xfe, 0x2f, 0xac, 0x38, 0xcb, 0xfe, 0xab, 0xb3, 0xb1, 0xae, 0x9c, 0x8f, 0x75, 0xe5, + 0xe7, 0x58, 0x57, 0xbe, 0x4e, 0xf4, 0xc2, 0xf9, 0x44, 0x2f, 0x7c, 0x9f, 0xe8, 0x85, 0xf7, 0x0f, + 0xb0, 0xc7, 0xba, 0x83, 0x43, 0xb3, 0x43, 0xfa, 0x7c, 0x64, 0xef, 0x44, 0xd3, 0xdb, 0x27, 0x2e, + 0xb2, 0x4e, 0xa7, 0x3f, 0x47, 0xc3, 0x00, 0xd1, 0xc3, 0x65, 0x3e, 0xa4, 0x1f, 0xfd, 0x0a, 0x00, + 0x00, 0xff, 0xff, 0x96, 0x32, 0xd6, 0x22, 0xbb, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -464,6 +561,7 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { UpdatePolicies(ctx context.Context, in *MsgUpdatePolicies, opts ...grpc.CallOption) (*MsgUpdatePoliciesResponse, error) UpdateChainInfo(ctx context.Context, in *MsgUpdateChainInfo, opts ...grpc.CallOption) (*MsgUpdateChainInfoResponse, error) + RemoveChainInfo(ctx context.Context, in *MsgRemoveChainInfo, opts ...grpc.CallOption) (*MsgRemoveChainInfoResponse, error) AddAuthorization(ctx context.Context, in *MsgAddAuthorization, opts ...grpc.CallOption) (*MsgAddAuthorizationResponse, error) RemoveAuthorization(ctx context.Context, in *MsgRemoveAuthorization, opts ...grpc.CallOption) (*MsgRemoveAuthorizationResponse, error) } @@ -494,6 +592,15 @@ func (c *msgClient) UpdateChainInfo(ctx context.Context, in *MsgUpdateChainInfo, return out, nil } +func (c *msgClient) RemoveChainInfo(ctx context.Context, in *MsgRemoveChainInfo, opts ...grpc.CallOption) (*MsgRemoveChainInfoResponse, error) { + out := new(MsgRemoveChainInfoResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.authority.Msg/RemoveChainInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) AddAuthorization(ctx context.Context, in *MsgAddAuthorization, opts ...grpc.CallOption) (*MsgAddAuthorizationResponse, error) { out := new(MsgAddAuthorizationResponse) err := c.cc.Invoke(ctx, "/zetachain.zetacore.authority.Msg/AddAuthorization", in, out, opts...) @@ -516,6 +623,7 @@ func (c *msgClient) RemoveAuthorization(ctx context.Context, in *MsgRemoveAuthor type MsgServer interface { UpdatePolicies(context.Context, *MsgUpdatePolicies) (*MsgUpdatePoliciesResponse, error) UpdateChainInfo(context.Context, *MsgUpdateChainInfo) (*MsgUpdateChainInfoResponse, error) + RemoveChainInfo(context.Context, *MsgRemoveChainInfo) (*MsgRemoveChainInfoResponse, error) AddAuthorization(context.Context, *MsgAddAuthorization) (*MsgAddAuthorizationResponse, error) RemoveAuthorization(context.Context, *MsgRemoveAuthorization) (*MsgRemoveAuthorizationResponse, error) } @@ -530,6 +638,9 @@ func (*UnimplementedMsgServer) UpdatePolicies(ctx context.Context, req *MsgUpdat func (*UnimplementedMsgServer) UpdateChainInfo(ctx context.Context, req *MsgUpdateChainInfo) (*MsgUpdateChainInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateChainInfo not implemented") } +func (*UnimplementedMsgServer) RemoveChainInfo(ctx context.Context, req *MsgRemoveChainInfo) (*MsgRemoveChainInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveChainInfo not implemented") +} func (*UnimplementedMsgServer) AddAuthorization(ctx context.Context, req *MsgAddAuthorization) (*MsgAddAuthorizationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddAuthorization not implemented") } @@ -577,6 +688,24 @@ func _Msg_UpdateChainInfo_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Msg_RemoveChainInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveChainInfo) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveChainInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.authority.Msg/RemoveChainInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveChainInfo(ctx, req.(*MsgRemoveChainInfo)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_AddAuthorization_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgAddAuthorization) if err := dec(in); err != nil { @@ -625,6 +754,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateChainInfo", Handler: _Msg_UpdateChainInfo_Handler, }, + { + MethodName: "RemoveChainInfo", + Handler: _Msg_RemoveChainInfo_Handler, + }, { MethodName: "AddAuthorization", Handler: _Msg_AddAuthorization_Handler, @@ -847,7 +980,7 @@ func (m *MsgUpdateChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size, err := m.ChainInfo.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Chain.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -855,7 +988,7 @@ func (m *MsgUpdateChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a if len(m.Creator) > 0 { i -= len(m.Creator) copy(dAtA[i:], m.Creator) @@ -889,6 +1022,64 @@ func (m *MsgUpdateChainInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *MsgRemoveChainInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRemoveChainInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChainId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRemoveChainInfoResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRemoveChainInfoResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveChainInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -989,7 +1180,7 @@ func (m *MsgUpdateChainInfo) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.ChainInfo.Size() + l = m.Chain.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1003,6 +1194,31 @@ func (m *MsgUpdateChainInfoResponse) Size() (n int) { return n } +func (m *MsgRemoveChainInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ChainId != 0 { + n += 1 + sovTx(uint64(m.ChainId)) + } + return n +} + +func (m *MsgRemoveChainInfoResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1582,9 +1798,9 @@ func (m *MsgUpdateChainInfo) Unmarshal(dAtA []byte) error { } m.Creator = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainInfo", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Chain", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1611,7 +1827,7 @@ func (m *MsgUpdateChainInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ChainInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Chain.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1686,6 +1902,157 @@ func (m *MsgUpdateChainInfoResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRemoveChainInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRemoveChainInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveChainInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + m.ChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveChainInfoResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRemoveChainInfoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveChainInfoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0