From f574d9c6cddcc200bfb460f4189d469046b3d437 Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 18 Apr 2024 08:32:48 +0100 Subject: [PATCH 01/11] refactor: replace broadcast mode block with sync and remove fungible params (#2001) * Remove broadcast mode block wip * Fixes * Changelog * PR comments * Lint fix * refactor: remove fungible params (#2004) * Remove unused params from fungible module * Make generate * Changelog * Lint fix * Lint fix * Fix changelog * Revert proto indexes * make generate --- app/app.go | 2 - changelog.md | 1 + cmd/zetacored/root.go | 2 +- .../cli/zetacored/zetacored_query_fungible.md | 1 - .../zetacored_query_fungible_params.md | 33 -- docs/openapi/openapi.swagger.yaml | 25 - e2e/txserver/zeta_tx_server.go | 85 +++- proto/crosschain/genesis.proto | 16 +- proto/fungible/genesis.proto | 2 - proto/fungible/params.proto | 11 - proto/fungible/query.proto | 15 - testutil/keeper/crosschain.go | 2 - testutil/keeper/fungible.go | 4 - typescript/crosschain/genesis_pb.d.ts | 16 +- typescript/fungible/genesis_pb.d.ts | 6 - typescript/fungible/index.d.ts | 1 - typescript/fungible/params_pb.d.ts | 29 -- typescript/fungible/query_pb.d.ts | 50 -- x/crosschain/keeper/keeper.go | 4 - x/crosschain/types/genesis.pb.go | 108 ++-- x/fungible/client/cli/query.go | 1 - x/fungible/client/cli/query_params.go | 34 -- x/fungible/genesis.go | 2 - x/fungible/genesis_test.go | 1 - x/fungible/keeper/grpc_query_params.go | 19 - x/fungible/keeper/grpc_query_params_test.go | 21 - x/fungible/keeper/keeper.go | 9 - x/fungible/keeper/params.go | 16 - x/fungible/keeper/params_test.go | 18 - x/fungible/module_simulation.go | 4 +- x/fungible/types/genesis.go | 3 +- x/fungible/types/genesis.pb.go | 83 +-- x/fungible/types/params.go | 42 -- x/fungible/types/params.pb.go | 265 ---------- x/fungible/types/query.pb.go | 476 +++--------------- x/fungible/types/query.pb.gw.go | 65 --- 36 files changed, 231 insertions(+), 1241 deletions(-) delete mode 100644 docs/cli/zetacored/zetacored_query_fungible_params.md delete mode 100644 proto/fungible/params.proto delete mode 100644 typescript/fungible/params_pb.d.ts delete mode 100644 x/fungible/client/cli/query_params.go delete mode 100644 x/fungible/keeper/grpc_query_params.go delete mode 100644 x/fungible/keeper/grpc_query_params_test.go delete mode 100644 x/fungible/keeper/params.go delete mode 100644 x/fungible/keeper/params_test.go delete mode 100644 x/fungible/types/params.go delete mode 100644 x/fungible/types/params.pb.go diff --git a/app/app.go b/app/app.go index 0625df5f08..bbb50a7802 100644 --- a/app/app.go +++ b/app/app.go @@ -419,7 +419,6 @@ func New( appCodec, keys[fungibletypes.StoreKey], keys[fungibletypes.MemStoreKey], - app.GetSubspace(fungibletypes.ModuleName), app.AccountKeeper, app.EvmKeeper, app.BankKeeper, @@ -432,7 +431,6 @@ func New( keys[crosschaintypes.StoreKey], keys[crosschaintypes.MemStoreKey], &stakingKeeper, - app.GetSubspace(crosschaintypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.ObserverKeeper, diff --git a/changelog.md b/changelog.md index f875ab400f..55b56416dd 100644 --- a/changelog.md +++ b/changelog.md @@ -29,6 +29,7 @@ * [1936](https://github.com/zeta-chain/node/pull/1936) - refactor common package into subpackages and rename to pkg * [1966](https://github.com/zeta-chain/node/pull/1966) - move TSS vote message from crosschain to observer * [1853](https://github.com/zeta-chain/node/pull/1853) - refactor vote inbound tx and vote outbound tx +* [2001](https://github.com/zeta-chain/node/pull/2001) - replace broadcast mode block with sync and remove fungible params * [1989](https://github.com/zeta-chain/node/pull/1989) - simplify `IsSendOutTxProcessed` method and add unit tests * [2013](https://github.com/zeta-chain/node/pull/2013) - rename `GasPriceVoter` message to `VoteGasPrice` diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 9f1835c9bb..0254602289 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -64,7 +64,7 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) { WithLegacyAmino(encodingConfig.Amino). WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). - WithBroadcastMode(flags.BroadcastBlock). + WithBroadcastMode(flags.BroadcastSync). WithHomeDir(app.DefaultNodeHome). WithKeyringOptions(hd.EthSecp256k1Option()). WithViper(EnvPrefix) diff --git a/docs/cli/zetacored/zetacored_query_fungible.md b/docs/cli/zetacored/zetacored_query_fungible.md index 52d7ccc81e..9ac579947a 100644 --- a/docs/cli/zetacored/zetacored_query_fungible.md +++ b/docs/cli/zetacored/zetacored_query_fungible.md @@ -30,7 +30,6 @@ zetacored query fungible [flags] * [zetacored query fungible gas-stability-pool-balance](zetacored_query_fungible_gas-stability-pool-balance.md) - query the balance of a gas stability pool for a chain * [zetacored query fungible gas-stability-pool-balances](zetacored_query_fungible_gas-stability-pool-balances.md) - query all gas stability pool balances * [zetacored query fungible list-foreign-coins](zetacored_query_fungible_list-foreign-coins.md) - list all ForeignCoins -* [zetacored query fungible params](zetacored_query_fungible_params.md) - shows the parameters of the module * [zetacored query fungible show-foreign-coins](zetacored_query_fungible_show-foreign-coins.md) - shows a ForeignCoins * [zetacored query fungible system-contract](zetacored_query_fungible_system-contract.md) - query system contract diff --git a/docs/cli/zetacored/zetacored_query_fungible_params.md b/docs/cli/zetacored/zetacored_query_fungible_params.md deleted file mode 100644 index 9845c39cf3..0000000000 --- a/docs/cli/zetacored/zetacored_query_fungible_params.md +++ /dev/null @@ -1,33 +0,0 @@ -# query fungible params - -shows the parameters of the module - -``` -zetacored query fungible params [flags] -``` - -### Options - -``` - --grpc-addr string the gRPC endpoint to use for this chain - --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS - --height int Use a specific height to query state at (this can error if the node is pruning state) - -h, --help help for params - --node string [host]:[port] to Tendermint RPC interface for this chain - -o, --output string Output format (text|json) -``` - -### Options inherited from parent commands - -``` - --chain-id string The network chain ID - --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) - --trace print out full stack trace on errors -``` - -### SEE ALSO - -* [zetacored query fungible](zetacored_query_fungible.md) - Querying commands for the fungible module - diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 1d1042551f..c250c89f37 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -27401,21 +27401,6 @@ paths: format: int64 tags: - Query - /zeta-chain/fungible/params: - get: - summary: Parameters queries the parameters of the module. - operationId: Query_Params - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/zetacorefungibleQueryParamsResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - tags: - - Query /zeta-chain/fungible/system_contract: get: summary: Queries SystemContract @@ -54759,16 +54744,6 @@ definitions: $ref: '#/definitions/zetacoreemissionsParams' description: params holds all the parameters of this module. description: QueryParamsResponse is response type for the Query/Params RPC method. - zetacorefungibleParams: - type: object - description: Params defines the parameters for the module. - zetacorefungibleQueryParamsResponse: - type: object - properties: - params: - $ref: '#/definitions/zetacorefungibleParams' - description: params holds all the parameters of this module. - description: QueryParamsResponse is response type for the Query/Params RPC method. zetacoreobserverParams: type: object properties: diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index f3d946ff5c..7c8b53038b 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -2,12 +2,14 @@ package txserver import ( "context" + "encoding/hex" "encoding/json" "errors" "fmt" "math/big" "os" "strings" + "time" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -33,6 +35,7 @@ import ( etherminttypes "github.com/evmos/ethermint/types" evmtypes "github.com/evmos/ethermint/x/evm/types" rpchttp "github.com/tendermint/tendermint/rpc/client/http" + coretypes "github.com/tendermint/tendermint/rpc/core/types" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" @@ -48,11 +51,12 @@ const EmissionsPoolAddress = "zeta1w43fn2ze2wyhu5hfmegr6vp52c3dgn0srdgymy" // ZetaTxServer is a ZetaChain tx server for E2E test type ZetaTxServer struct { - clientCtx client.Context - txFactory tx.Factory - name []string - mnemonic []string - address []string + clientCtx client.Context + txFactory tx.Factory + name []string + mnemonic []string + address []string + blockTimeout time.Duration } // NewZetaTxServer returns a new TxServer with provided account @@ -102,11 +106,12 @@ func NewZetaTxServer(rpcAddr string, names []string, mnemonics []string, chainID txf := newFactory(clientCtx) return ZetaTxServer{ - clientCtx: clientCtx, - txFactory: txf, - name: names, - mnemonic: mnemonics, - address: addresses, + clientCtx: clientCtx, + txFactory: txf, + name: names, + mnemonic: mnemonics, + address: addresses, + blockTimeout: 1 * time.Minute, }, nil } @@ -157,6 +162,7 @@ func (zts ZetaTxServer) GetAccountMnemonic(index int) string { } // BroadcastTx broadcasts a tx to ZetaChain with the provided msg from the account +// and waiting for blockTime for tx to be included in the block func (zts ZetaTxServer) BroadcastTx(account string, msg sdktypes.Msg) (*sdktypes.TxResponse, error) { // Find number and sequence and set it acc, err := zts.clientCtx.Keyring.Key(account) @@ -188,8 +194,61 @@ func (zts ZetaTxServer) BroadcastTx(account string, msg sdktypes.Msg) (*sdktypes return nil, err } - // Broadcast tx - return zts.clientCtx.BroadcastTx(txBytes) + return broadcastWithBlockTimeout(zts, txBytes) +} + +func broadcastWithBlockTimeout(zts ZetaTxServer, txBytes []byte) (*sdktypes.TxResponse, error) { + res, err := zts.clientCtx.BroadcastTx(txBytes) + if err != nil { + if res == nil { + return nil, err + } + return &sdktypes.TxResponse{ + Code: res.Code, + Codespace: res.Codespace, + TxHash: res.TxHash, + }, err + } + + exitAfter := time.After(zts.blockTimeout) + hash, err := hex.DecodeString(res.TxHash) + if err != nil { + return nil, err + } + for { + select { + case <-exitAfter: + return nil, fmt.Errorf("timed out after waiting for tx to get included in the block: %d", zts.blockTimeout) + case <-time.After(time.Millisecond * 100): + resTx, err := zts.clientCtx.Client.Tx(context.TODO(), hash, false) + if err == nil { + txRes, err := mkTxResult(zts.clientCtx, resTx) + if err == nil { + return txRes, nil + } + } + } + } +} + +func mkTxResult(clientCtx client.Context, resTx *coretypes.ResultTx) (*sdktypes.TxResponse, error) { + txb, err := clientCtx.TxConfig.TxDecoder()(resTx.Tx) + if err != nil { + return nil, err + } + p, ok := txb.(intoAny) + if !ok { + return nil, fmt.Errorf("expecting a type implementing intoAny, got: %T", txb) + } + resBlock, err := clientCtx.Client.Block(context.TODO(), &resTx.Height) + if err != nil { + return nil, err + } + return sdktypes.NewResponseResultTx(resTx, p.AsAny(), resBlock.Block.Time.Format(time.RFC3339)), nil +} + +type intoAny interface { + AsAny() *codectypes.Any } // DeploySystemContractsAndZRC20 deploys the system contracts and ZRC20 contracts @@ -373,7 +432,7 @@ func newContext( WithLegacyAmino(codec.NewLegacyAmino()). WithInput(os.Stdin). WithOutput(os.Stdout). - WithBroadcastMode(flags.BroadcastBlock). + WithBroadcastMode(flags.BroadcastSync). WithClient(rpc). WithSkipConfirmation(true). WithFromName("creator"). diff --git a/proto/crosschain/genesis.proto b/proto/crosschain/genesis.proto index 87c3875b14..2d5d96c3a9 100644 --- a/proto/crosschain/genesis.proto +++ b/proto/crosschain/genesis.proto @@ -13,12 +13,12 @@ option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types"; // GenesisState defines the metacore module's genesis state. message GenesisState { - repeated OutTxTracker outTxTrackerList = 1 [(gogoproto.nullable) = false]; - repeated GasPrice gasPriceList = 2; - repeated CrossChainTx CrossChainTxs = 3; - repeated LastBlockHeight lastBlockHeightList = 4; - repeated InTxHashToCctx inTxHashToCctxList = 5 [(gogoproto.nullable) = false]; - repeated InTxTracker in_tx_tracker_list = 6 [(gogoproto.nullable) = false]; - ZetaAccounting zeta_accounting = 7 [(gogoproto.nullable) = false]; - repeated string FinalizedInbounds = 8; + repeated OutTxTracker outTxTrackerList = 2 [(gogoproto.nullable) = false]; + repeated GasPrice gasPriceList = 5; + repeated CrossChainTx CrossChainTxs = 7; + repeated LastBlockHeight lastBlockHeightList = 8; + repeated InTxHashToCctx inTxHashToCctxList = 9 [(gogoproto.nullable) = false]; + repeated InTxTracker in_tx_tracker_list = 11 [(gogoproto.nullable) = false]; + ZetaAccounting zeta_accounting = 12 [(gogoproto.nullable) = false]; + repeated string FinalizedInbounds = 16; } diff --git a/proto/fungible/genesis.proto b/proto/fungible/genesis.proto index bc6f804145..d630ff482f 100644 --- a/proto/fungible/genesis.proto +++ b/proto/fungible/genesis.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package zetachain.zetacore.fungible; import "fungible/foreign_coins.proto"; -import "fungible/params.proto"; import "fungible/system_contract.proto"; import "gogoproto/gogo.proto"; @@ -10,7 +9,6 @@ option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; // GenesisState defines the fungible module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; repeated ForeignCoins foreignCoinsList = 2 [(gogoproto.nullable) = false]; SystemContract systemContract = 3; } diff --git a/proto/fungible/params.proto b/proto/fungible/params.proto deleted file mode 100644 index 2615f0b14f..0000000000 --- a/proto/fungible/params.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; -package zetachain.zetacore.fungible; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; - -// Params defines the parameters for the module. -message Params { - option (gogoproto.goproto_stringer) = false; -} diff --git a/proto/fungible/query.proto b/proto/fungible/query.proto index 94e4165cdd..17c3779512 100644 --- a/proto/fungible/query.proto +++ b/proto/fungible/query.proto @@ -3,7 +3,6 @@ package zetachain.zetacore.fungible; import "cosmos/base/query/v1beta1/pagination.proto"; import "fungible/foreign_coins.proto"; -import "fungible/params.proto"; import "fungible/system_contract.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; @@ -12,11 +11,6 @@ option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/zeta-chain/fungible/params"; - } - // Queries a ForeignCoins by index. rpc ForeignCoins(QueryGetForeignCoinsRequest) returns (QueryGetForeignCoinsResponse) { option (google.api.http).get = "/zeta-chain/fungible/foreign_coins/{index}"; @@ -53,15 +47,6 @@ service Query { } } -// QueryParamsRequest is request type for the Query/Params RPC method. -message QueryParamsRequest {} - -// QueryParamsResponse is response type for the Query/Params RPC method. -message QueryParamsResponse { - // params holds all the parameters of this module. - Params params = 1 [(gogoproto.nullable) = false]; -} - message QueryGetForeignCoinsRequest { string index = 1; } diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index 3fb8f81823..3f52ed1e4d 100644 --- a/testutil/keeper/crosschain.go +++ b/testutil/keeper/crosschain.go @@ -75,7 +75,6 @@ func CrosschainKeeperWithMocks( cdc, db, stateStore, - sdkKeepers.ParamsKeeper, sdkKeepers.AuthKeeper, sdkKeepers.BankKeeper, sdkKeepers.EvmKeeper, @@ -134,7 +133,6 @@ func CrosschainKeeperWithMocks( storeKey, memStoreKey, stakingKeeper, - sdkKeepers.ParamsKeeper.Subspace(types.ModuleName), authKeeper, bankKeeper, observerKeeper, diff --git a/testutil/keeper/fungible.go b/testutil/keeper/fungible.go index 5097a208d2..ae61439c1a 100644 --- a/testutil/keeper/fungible.go +++ b/testutil/keeper/fungible.go @@ -8,7 +8,6 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/mock" @@ -44,7 +43,6 @@ func initFungibleKeeper( cdc codec.Codec, db *tmdb.MemDB, ss store.CommitMultiStore, - paramKeeper paramskeeper.Keeper, authKeeper types.AccountKeeper, bankKeepr types.BankKeeper, evmKeeper types.EVMKeeper, @@ -60,7 +58,6 @@ func initFungibleKeeper( cdc, storeKey, memKey, - paramKeeper.Subspace(types.ModuleName), authKeeper, evmKeeper, bankKeepr, @@ -145,7 +142,6 @@ func FungibleKeeperWithMocks(t testing.TB, mockOptions FungibleMockOptions) (*ke cdc, storeKey, memStoreKey, - sdkKeepers.ParamsKeeper.Subspace(types.ModuleName), authKeeper, evmKeeper, bankKeeper, diff --git a/typescript/crosschain/genesis_pb.d.ts b/typescript/crosschain/genesis_pb.d.ts index bec622e2af..08d35e3746 100644 --- a/typescript/crosschain/genesis_pb.d.ts +++ b/typescript/crosschain/genesis_pb.d.ts @@ -19,42 +19,42 @@ import type { InTxTracker } from "./in_tx_tracker_pb.js"; */ export declare class GenesisState extends Message { /** - * @generated from field: repeated zetachain.zetacore.crosschain.OutTxTracker outTxTrackerList = 1; + * @generated from field: repeated zetachain.zetacore.crosschain.OutTxTracker outTxTrackerList = 2; */ outTxTrackerList: OutTxTracker[]; /** - * @generated from field: repeated zetachain.zetacore.crosschain.GasPrice gasPriceList = 2; + * @generated from field: repeated zetachain.zetacore.crosschain.GasPrice gasPriceList = 5; */ gasPriceList: GasPrice[]; /** - * @generated from field: repeated zetachain.zetacore.crosschain.CrossChainTx CrossChainTxs = 3; + * @generated from field: repeated zetachain.zetacore.crosschain.CrossChainTx CrossChainTxs = 7; */ CrossChainTxs: CrossChainTx[]; /** - * @generated from field: repeated zetachain.zetacore.crosschain.LastBlockHeight lastBlockHeightList = 4; + * @generated from field: repeated zetachain.zetacore.crosschain.LastBlockHeight lastBlockHeightList = 8; */ lastBlockHeightList: LastBlockHeight[]; /** - * @generated from field: repeated zetachain.zetacore.crosschain.InTxHashToCctx inTxHashToCctxList = 5; + * @generated from field: repeated zetachain.zetacore.crosschain.InTxHashToCctx inTxHashToCctxList = 9; */ inTxHashToCctxList: InTxHashToCctx[]; /** - * @generated from field: repeated zetachain.zetacore.crosschain.InTxTracker in_tx_tracker_list = 6; + * @generated from field: repeated zetachain.zetacore.crosschain.InTxTracker in_tx_tracker_list = 11; */ inTxTrackerList: InTxTracker[]; /** - * @generated from field: zetachain.zetacore.crosschain.ZetaAccounting zeta_accounting = 7; + * @generated from field: zetachain.zetacore.crosschain.ZetaAccounting zeta_accounting = 12; */ zetaAccounting?: ZetaAccounting; /** - * @generated from field: repeated string FinalizedInbounds = 8; + * @generated from field: repeated string FinalizedInbounds = 16; */ FinalizedInbounds: string[]; diff --git a/typescript/fungible/genesis_pb.d.ts b/typescript/fungible/genesis_pb.d.ts index 1a338d01c8..da2d610c10 100644 --- a/typescript/fungible/genesis_pb.d.ts +++ b/typescript/fungible/genesis_pb.d.ts @@ -5,7 +5,6 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; -import type { Params } from "./params_pb.js"; import type { ForeignCoins } from "./foreign_coins_pb.js"; import type { SystemContract } from "./system_contract_pb.js"; @@ -15,11 +14,6 @@ import type { SystemContract } from "./system_contract_pb.js"; * @generated from message zetachain.zetacore.fungible.GenesisState */ export declare class GenesisState extends Message { - /** - * @generated from field: zetachain.zetacore.fungible.Params params = 1; - */ - params?: Params; - /** * @generated from field: repeated zetachain.zetacore.fungible.ForeignCoins foreignCoinsList = 2; */ diff --git a/typescript/fungible/index.d.ts b/typescript/fungible/index.d.ts index ca17377759..1c8f51dade 100644 --- a/typescript/fungible/index.d.ts +++ b/typescript/fungible/index.d.ts @@ -1,7 +1,6 @@ export * from "./events_pb"; export * from "./foreign_coins_pb"; export * from "./genesis_pb"; -export * from "./params_pb"; export * from "./query_pb"; export * from "./system_contract_pb"; export * from "./tx_pb"; diff --git a/typescript/fungible/params_pb.d.ts b/typescript/fungible/params_pb.d.ts deleted file mode 100644 index a9f83a1d01..0000000000 --- a/typescript/fungible/params_pb.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" -// @generated from file fungible/params.proto (package zetachain.zetacore.fungible, syntax proto3) -/* eslint-disable */ -// @ts-nocheck - -import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; -import { Message, proto3 } from "@bufbuild/protobuf"; - -/** - * Params defines the parameters for the module. - * - * @generated from message zetachain.zetacore.fungible.Params - */ -export declare class Params extends Message { - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.fungible.Params"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): Params; - - static fromJson(jsonValue: JsonValue, options?: Partial): Params; - - static fromJsonString(jsonString: string, options?: Partial): Params; - - static equals(a: Params | PlainMessage | undefined, b: Params | PlainMessage | undefined): boolean; -} - diff --git a/typescript/fungible/query_pb.d.ts b/typescript/fungible/query_pb.d.ts index 57b15066b9..df76823dc6 100644 --- a/typescript/fungible/query_pb.d.ts +++ b/typescript/fungible/query_pb.d.ts @@ -5,60 +5,10 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; -import type { Params } from "./params_pb.js"; import type { ForeignCoins } from "./foreign_coins_pb.js"; import type { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination_pb.js"; import type { SystemContract } from "./system_contract_pb.js"; -/** - * QueryParamsRequest is request type for the Query/Params RPC method. - * - * @generated from message zetachain.zetacore.fungible.QueryParamsRequest - */ -export declare class QueryParamsRequest extends Message { - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.fungible.QueryParamsRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryParamsRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryParamsRequest; - - static fromJsonString(jsonString: string, options?: Partial): QueryParamsRequest; - - static equals(a: QueryParamsRequest | PlainMessage | undefined, b: QueryParamsRequest | PlainMessage | undefined): boolean; -} - -/** - * QueryParamsResponse is response type for the Query/Params RPC method. - * - * @generated from message zetachain.zetacore.fungible.QueryParamsResponse - */ -export declare class QueryParamsResponse extends Message { - /** - * params holds all the parameters of this module. - * - * @generated from field: zetachain.zetacore.fungible.Params params = 1; - */ - params?: Params; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.fungible.QueryParamsResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryParamsResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryParamsResponse; - - static fromJsonString(jsonString: string, options?: Partial): QueryParamsResponse; - - static equals(a: QueryParamsResponse | PlainMessage | undefined, b: QueryParamsResponse | PlainMessage | undefined): boolean; -} - /** * @generated from message zetachain.zetacore.fungible.QueryGetForeignCoinsRequest */ diff --git a/x/crosschain/keeper/keeper.go b/x/crosschain/keeper/keeper.go index 5ed6084983..0962323ca5 100644 --- a/x/crosschain/keeper/keeper.go +++ b/x/crosschain/keeper/keeper.go @@ -6,7 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -18,7 +17,6 @@ type ( memKey storetypes.StoreKey stakingKeeper types.StakingKeeper - paramstore paramtypes.Subspace authKeeper types.AccountKeeper bankKeeper types.BankKeeper zetaObserverKeeper types.ObserverKeeper @@ -32,7 +30,6 @@ func NewKeeper( storeKey, memKey storetypes.StoreKey, stakingKeeper types.StakingKeeper, // custom - paramstore paramtypes.Subspace, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, zetaObserverKeeper types.ObserverKeeper, @@ -50,7 +47,6 @@ func NewKeeper( storeKey: storeKey, memKey: memKey, stakingKeeper: stakingKeeper, - paramstore: paramstore, authKeeper: authKeeper, bankKeeper: bankKeeper, zetaObserverKeeper: zetaObserverKeeper, diff --git a/x/crosschain/types/genesis.pb.go b/x/crosschain/types/genesis.pb.go index c6358ad693..d7511b155d 100644 --- a/x/crosschain/types/genesis.pb.go +++ b/x/crosschain/types/genesis.pb.go @@ -26,14 +26,14 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the metacore module's genesis state. type GenesisState struct { - OutTxTrackerList []OutTxTracker `protobuf:"bytes,1,rep,name=outTxTrackerList,proto3" json:"outTxTrackerList"` - GasPriceList []*GasPrice `protobuf:"bytes,2,rep,name=gasPriceList,proto3" json:"gasPriceList,omitempty"` - CrossChainTxs []*CrossChainTx `protobuf:"bytes,3,rep,name=CrossChainTxs,proto3" json:"CrossChainTxs,omitempty"` - LastBlockHeightList []*LastBlockHeight `protobuf:"bytes,4,rep,name=lastBlockHeightList,proto3" json:"lastBlockHeightList,omitempty"` - InTxHashToCctxList []InTxHashToCctx `protobuf:"bytes,5,rep,name=inTxHashToCctxList,proto3" json:"inTxHashToCctxList"` - InTxTrackerList []InTxTracker `protobuf:"bytes,6,rep,name=in_tx_tracker_list,json=inTxTrackerList,proto3" json:"in_tx_tracker_list"` - ZetaAccounting ZetaAccounting `protobuf:"bytes,7,opt,name=zeta_accounting,json=zetaAccounting,proto3" json:"zeta_accounting"` - FinalizedInbounds []string `protobuf:"bytes,8,rep,name=FinalizedInbounds,proto3" json:"FinalizedInbounds,omitempty"` + OutTxTrackerList []OutTxTracker `protobuf:"bytes,2,rep,name=outTxTrackerList,proto3" json:"outTxTrackerList"` + GasPriceList []*GasPrice `protobuf:"bytes,5,rep,name=gasPriceList,proto3" json:"gasPriceList,omitempty"` + CrossChainTxs []*CrossChainTx `protobuf:"bytes,7,rep,name=CrossChainTxs,proto3" json:"CrossChainTxs,omitempty"` + LastBlockHeightList []*LastBlockHeight `protobuf:"bytes,8,rep,name=lastBlockHeightList,proto3" json:"lastBlockHeightList,omitempty"` + InTxHashToCctxList []InTxHashToCctx `protobuf:"bytes,9,rep,name=inTxHashToCctxList,proto3" json:"inTxHashToCctxList"` + InTxTrackerList []InTxTracker `protobuf:"bytes,11,rep,name=in_tx_tracker_list,json=inTxTrackerList,proto3" json:"in_tx_tracker_list"` + ZetaAccounting ZetaAccounting `protobuf:"bytes,12,opt,name=zeta_accounting,json=zetaAccounting,proto3" json:"zeta_accounting"` + FinalizedInbounds []string `protobuf:"bytes,16,rep,name=FinalizedInbounds,proto3" json:"FinalizedInbounds,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -134,34 +134,34 @@ func init() { proto.RegisterFile("crosschain/genesis.proto", fileDescriptor_dd51 var fileDescriptor_dd51403692d571f4 = []byte{ // 465 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x1b, 0xba, 0x0d, 0x30, 0x83, 0x81, 0xe1, 0x10, 0x55, 0x22, 0xab, 0xc6, 0x81, 0x09, - 0x58, 0x22, 0xe0, 0x13, 0xd0, 0x4a, 0x6c, 0xd3, 0x26, 0x01, 0xa1, 0xa7, 0x89, 0xc9, 0x38, 0x9e, - 0x95, 0x58, 0x0b, 0x76, 0x15, 0xbf, 0x48, 0xa1, 0x9f, 0x82, 0x6f, 0xc4, 0x75, 0xc7, 0x1d, 0x39, - 0x21, 0xd4, 0x7e, 0x11, 0x64, 0x27, 0x0c, 0x47, 0x99, 0xd6, 0xde, 0x9e, 0xfc, 0xde, 0xff, 0xf7, - 0x7f, 0xf9, 0x3b, 0x46, 0x3e, 0x2b, 0x94, 0xd6, 0x2c, 0xa3, 0x42, 0x46, 0x29, 0x97, 0x5c, 0x0b, - 0x1d, 0x4e, 0x0b, 0x05, 0x0a, 0x3f, 0x9d, 0x71, 0xa0, 0xb6, 0x11, 0xda, 0x4a, 0x15, 0x3c, 0xfc, - 0x3f, 0x3c, 0xd8, 0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, 0x1b, 0xe3, 0xe3, 0xcb, + 0xb9, 0xdf, 0xbf, 0x9a, 0xfb, 0xfd, 0xdf, 0x73, 0xbf, 0xff, 0x7d, 0xe1, 0xf7, 0xae, 0x16, 0x7e, + 0xef, 0xe7, 0xc2, 0xef, 0x9d, 0xbe, 0x4a, 0x05, 0x64, 0x65, 0x12, 0x30, 0xf5, 0x35, 0x34, 0x16, + 0xfb, 0xf5, 0xeb, 0xf8, 0xbb, 0x57, 0x58, 0x85, 0xce, 0x9b, 0x81, 0x6f, 0x53, 0xae, 0x93, 0x3b, + 0xf6, 0x55, 0xbc, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff, 0x28, 0xc8, 0xb0, 0x72, 0x2d, 0x04, 0x00, 0x00, } @@ -191,7 +191,9 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.FinalizedInbounds[iNdEx]) i = encodeVarintGenesis(dAtA, i, uint64(len(m.FinalizedInbounds[iNdEx]))) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 } } { @@ -203,7 +205,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x62 if len(m.InTxTrackerList) > 0 { for iNdEx := len(m.InTxTrackerList) - 1; iNdEx >= 0; iNdEx-- { { @@ -215,7 +217,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x5a } } if len(m.InTxHashToCctxList) > 0 { @@ -229,7 +231,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x4a } } if len(m.LastBlockHeightList) > 0 { @@ -243,7 +245,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x42 } } if len(m.CrossChainTxs) > 0 { @@ -257,7 +259,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x3a } } if len(m.GasPriceList) > 0 { @@ -271,7 +273,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x2a } } if len(m.OutTxTrackerList) > 0 { @@ -285,7 +287,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 } } return len(dAtA) - i, nil @@ -349,7 +351,7 @@ func (m *GenesisState) Size() (n int) { if len(m.FinalizedInbounds) > 0 { for _, s := range m.FinalizedInbounds { l = len(s) - n += 1 + l + sovGenesis(uint64(l)) + n += 2 + l + sovGenesis(uint64(l)) } } return n @@ -390,7 +392,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OutTxTrackerList", wireType) } @@ -424,7 +426,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field GasPriceList", wireType) } @@ -458,7 +460,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CrossChainTxs", wireType) } @@ -492,7 +494,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastBlockHeightList", wireType) } @@ -526,7 +528,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field InTxHashToCctxList", wireType) } @@ -560,7 +562,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field InTxTrackerList", wireType) } @@ -594,7 +596,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ZetaAccounting", wireType) } @@ -627,7 +629,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 16: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field FinalizedInbounds", wireType) } diff --git a/x/fungible/client/cli/query.go b/x/fungible/client/cli/query.go index 2fcda320d5..e5f0033532 100644 --- a/x/fungible/client/cli/query.go +++ b/x/fungible/client/cli/query.go @@ -20,7 +20,6 @@ func GetQueryCmd(_ string) *cobra.Command { } cmd.AddCommand( - CmdQueryParams(), CmdListForeignCoins(), CmdShowForeignCoins(), CmdGasStabilityPoolAddress(), diff --git a/x/fungible/client/cli/query_params.go b/x/fungible/client/cli/query_params.go deleted file mode 100644 index fad97be7dd..0000000000 --- a/x/fungible/client/cli/query_params.go +++ /dev/null @@ -1,34 +0,0 @@ -package cli - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/spf13/cobra" - "github.com/zeta-chain/zetacore/x/fungible/types" -) - -func CmdQueryParams() *cobra.Command { - cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) - - queryClient := types.NewQueryClient(clientCtx) - - res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/fungible/genesis.go b/x/fungible/genesis.go index 59b54fe6da..4f19c7cebd 100644 --- a/x/fungible/genesis.go +++ b/x/fungible/genesis.go @@ -18,14 +18,12 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetSystemContract(ctx, *genState.SystemContract) } - k.SetParams(ctx, genState.Params) } // ExportGenesis returns the fungible module's exported genesis. func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { var genesis types.GenesisState - genesis.Params = k.GetParams(ctx) genesis.ForeignCoinsList = k.GetAllForeignCoins(ctx) // Get all zetaDepositAndCallContract diff --git a/x/fungible/genesis_test.go b/x/fungible/genesis_test.go index 119e862a18..ba57014f6b 100644 --- a/x/fungible/genesis_test.go +++ b/x/fungible/genesis_test.go @@ -13,7 +13,6 @@ import ( func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ - Params: types.DefaultParams(), ForeignCoinsList: []types.ForeignCoins{ sample.ForeignCoins(t, sample.EthAddress().String()), sample.ForeignCoins(t, sample.EthAddress().String()), diff --git a/x/fungible/keeper/grpc_query_params.go b/x/fungible/keeper/grpc_query_params.go deleted file mode 100644 index e6bebfb779..0000000000 --- a/x/fungible/keeper/grpc_query_params.go +++ /dev/null @@ -1,19 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/x/fungible/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - ctx := sdk.UnwrapSDKContext(c) - - return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil -} diff --git a/x/fungible/keeper/grpc_query_params_test.go b/x/fungible/keeper/grpc_query_params_test.go deleted file mode 100644 index 634c6a38f6..0000000000 --- a/x/fungible/keeper/grpc_query_params_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/x/fungible/types" -) - -func TestParamsQuery(t *testing.T) { - keeper, ctx, _, _ := testkeeper.FungibleKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - params := types.DefaultParams() - keeper.SetParams(ctx, params) - - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) -} diff --git a/x/fungible/keeper/keeper.go b/x/fungible/keeper/keeper.go index b25e466099..74b5f37730 100644 --- a/x/fungible/keeper/keeper.go +++ b/x/fungible/keeper/keeper.go @@ -6,7 +6,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -16,7 +15,6 @@ type ( cdc codec.BinaryCodec storeKey storetypes.StoreKey memKey storetypes.StoreKey - paramstore paramtypes.Subspace authKeeper types.AccountKeeper evmKeeper types.EVMKeeper bankKeeper types.BankKeeper @@ -29,23 +27,16 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, - ps paramtypes.Subspace, authKeeper types.AccountKeeper, evmKeeper types.EVMKeeper, bankKeeper types.BankKeeper, observerKeeper types.ObserverKeeper, authorityKeeper types.AuthorityKeeper, ) *Keeper { - // set KeyTable if it has not already been set - if !ps.HasKeyTable() { - ps = ps.WithKeyTable(types.ParamKeyTable()) - } - return &Keeper{ cdc: cdc, storeKey: storeKey, memKey: memKey, - paramstore: ps, authKeeper: authKeeper, evmKeeper: evmKeeper, bankKeeper: bankKeeper, diff --git a/x/fungible/keeper/params.go b/x/fungible/keeper/params.go deleted file mode 100644 index 18b311c264..0000000000 --- a/x/fungible/keeper/params.go +++ /dev/null @@ -1,16 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/x/fungible/types" -) - -// GetParams get all parameters as types.Params -func (k Keeper) GetParams(_ sdk.Context) types.Params { - return types.NewParams() -} - -// SetParams set the params -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { - k.paramstore.SetParamSet(ctx, ¶ms) -} diff --git a/x/fungible/keeper/params_test.go b/x/fungible/keeper/params_test.go deleted file mode 100644 index b3b9497a74..0000000000 --- a/x/fungible/keeper/params_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/x/fungible/types" -) - -func TestGetParams(t *testing.T) { - k, ctx, _, _ := testkeeper.FungibleKeeper(t) - params := types.DefaultParams() - - k.SetParams(ctx, params) - - require.EqualValues(t, params, k.GetParams(ctx)) -} diff --git a/x/fungible/module_simulation.go b/x/fungible/module_simulation.go index 0754216df7..5280860006 100644 --- a/x/fungible/module_simulation.go +++ b/x/fungible/module_simulation.go @@ -15,9 +15,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { for i, acc := range simState.Accounts { accs[i] = acc.Address.String() } - fungibleGenesis := types.GenesisState{ - Params: types.DefaultParams(), - } + fungibleGenesis := types.GenesisState{} simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&fungibleGenesis) } diff --git a/x/fungible/types/genesis.go b/x/fungible/types/genesis.go index ccec34a914..859a19b3de 100644 --- a/x/fungible/types/genesis.go +++ b/x/fungible/types/genesis.go @@ -9,7 +9,6 @@ func DefaultGenesis() *GenesisState { return &GenesisState{ ForeignCoinsList: []ForeignCoins{}, SystemContract: nil, - Params: DefaultParams(), } } @@ -27,5 +26,5 @@ func (gs GenesisState) Validate() error { foreignCoinsIndexMap[index] = struct{}{} } - return gs.Params.Validate() + return nil } diff --git a/x/fungible/types/genesis.pb.go b/x/fungible/types/genesis.pb.go index 01a6e80047..56634c414b 100644 --- a/x/fungible/types/genesis.pb.go +++ b/x/fungible/types/genesis.pb.go @@ -26,7 +26,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fungible module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` ForeignCoinsList []ForeignCoins `protobuf:"bytes,2,rep,name=foreignCoinsList,proto3" json:"foreignCoinsList"` SystemContract *SystemContract `protobuf:"bytes,3,opt,name=systemContract,proto3" json:"systemContract,omitempty"` } @@ -64,13 +63,6 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - func (m *GenesisState) GetForeignCoinsList() []ForeignCoins { if m != nil { return m.ForeignCoinsList @@ -92,26 +84,24 @@ func init() { func init() { proto.RegisterFile("fungible/genesis.proto", fileDescriptor_11e46382f3a6d0c2) } var fileDescriptor_11e46382f3a6d0c2 = []byte{ - // 291 bytes of a gzipped FileDescriptorProto + // 261 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4b, 0x2b, 0xcd, 0x4b, 0xcf, 0x4c, 0xca, 0x49, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xae, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x60, 0x4a, 0xa5, 0x64, 0xe0, 0x9a, 0xd2, 0xf2, 0x8b, 0x52, 0x33, 0xd3, - 0xf3, 0xe2, 0x93, 0xf3, 0x33, 0xf3, 0xa0, 0x5a, 0xa5, 0x44, 0xe1, 0xb2, 0x05, 0x89, 0x45, 0x89, - 0xb9, 0x30, 0x61, 0x39, 0xb8, 0x70, 0x71, 0x65, 0x71, 0x49, 0x6a, 0x6e, 0x7c, 0x72, 0x7e, 0x5e, - 0x49, 0x51, 0x62, 0x72, 0x09, 0x54, 0x5e, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, - 0x20, 0xa2, 0x4a, 0xcd, 0x4c, 0x5c, 0x3c, 0xee, 0x10, 0x97, 0x05, 0x97, 0x24, 0x96, 0xa4, 0x0a, - 0x39, 0x72, 0xb1, 0x41, 0x8c, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x52, 0xd6, 0xc3, 0xe3, - 0x52, 0xbd, 0x00, 0xb0, 0x52, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x85, 0xa2, - 0xb9, 0x04, 0xa0, 0xee, 0x76, 0x06, 0x39, 0xdb, 0x27, 0xb3, 0xb8, 0x44, 0x82, 0x49, 0x81, 0x59, - 0x83, 0xdb, 0x48, 0x13, 0xaf, 0x61, 0x6e, 0x48, 0x9a, 0xa0, 0x46, 0x62, 0x18, 0x24, 0x14, 0xcc, - 0xc5, 0x07, 0xf1, 0x9f, 0x33, 0xd4, 0x7b, 0x12, 0xcc, 0x60, 0x77, 0x6a, 0xe3, 0x35, 0x3a, 0x18, - 0x45, 0x4b, 0x10, 0x9a, 0x11, 0x4e, 0x9e, 0x27, 0x1e, 0xc9, 0x31, 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7, 0xe8, + 0x60, 0x14, 0x2d, 0x41, 0x68, 0x46, 0x38, 0x79, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, + 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, + 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, + 0x58, 0x5d, 0xb0, 0x0d, 0xfa, 0x30, 0x1b, 0xf4, 0x2b, 0xf4, 0xe1, 0x61, 0x56, 0x52, 0x59, 0x90, + 0x5a, 0x9c, 0xc4, 0x06, 0x0e, 0x14, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x94, 0x92, 0xf7, + 0x47, 0x9f, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -160,16 +150,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -190,8 +170,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) if len(m.ForeignCoinsList) > 0 { for _, e := range m.ForeignCoinsList { l = e.Size() @@ -240,39 +218,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ForeignCoinsList", wireType) diff --git a/x/fungible/types/params.go b/x/fungible/types/params.go deleted file mode 100644 index 4b348397da..0000000000 --- a/x/fungible/types/params.go +++ /dev/null @@ -1,42 +0,0 @@ -package types - -import ( - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "gopkg.in/yaml.v2" -) - -var _ paramtypes.ParamSet = (*Params)(nil) - -// ParamKeyTable the param key table for launch module -func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) -} - -// NewParams creates a new Params instance -func NewParams() Params { - return Params{} -} - -// DefaultParams returns a default set of parameters -func DefaultParams() Params { - return NewParams() -} - -// ParamSetPairs get the params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} -} - -// Validate validates the set of params -func (p Params) Validate() error { - return nil -} - -// String implements the Stringer interface. -func (p Params) String() string { - out, err := yaml.Marshal(p) - if err != nil { - return "" - } - return string(out) -} diff --git a/x/fungible/types/params.pb.go b/x/fungible/types/params.pb.go deleted file mode 100644 index 7d485a75b0..0000000000 --- a/x/fungible/types/params.pb.go +++ /dev/null @@ -1,265 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: fungible/params.proto - -package types - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params defines the parameters for the module. -type Params struct { -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_8285013990d8e1cf, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Params)(nil), "zetachain.zetacore.fungible.Params") -} - -func init() { proto.RegisterFile("fungible/params.proto", fileDescriptor_8285013990d8e1cf) } - -var fileDescriptor_8285013990d8e1cf = []byte{ - // 157 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x2b, 0xcd, 0x4b, - 0xcf, 0x4c, 0xca, 0x49, 0xd5, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x92, 0xae, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, - 0x8b, 0x52, 0xf5, 0x60, 0x2a, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xea, 0xf4, 0x41, 0x2c, - 0x88, 0x16, 0x25, 0x3e, 0x2e, 0xb6, 0x00, 0xb0, 0x11, 0x56, 0x2c, 0x33, 0x16, 0xc8, 0x33, 0x38, - 0x79, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, - 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, - 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x74, 0x5d, 0xb0, 0x45, 0xfa, 0x30, 0x8b, - 0xf4, 0x2b, 0xf4, 0xe1, 0x8e, 0x2a, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xdb, 0x60, 0x0c, - 0x08, 0x00, 0x00, 0xff, 0xff, 0x61, 0x4b, 0x42, 0x58, 0xad, 0x00, 0x00, 0x00, -} - -func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) 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 ErrIntOverflowParams - } - 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: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/fungible/types/query.pb.go b/x/fungible/types/query.pb.go index 89ad3937b2..f30691101c 100644 --- a/x/fungible/types/query.pb.go +++ b/x/fungible/types/query.pb.go @@ -31,89 +31,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryParamsRequest is request type for the Query/Params RPC method. -type QueryParamsRequest struct { -} - -func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } -func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryParamsRequest) ProtoMessage() {} -func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{0} -} -func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsRequest.Merge(m, src) -} -func (m *QueryParamsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo - -// QueryParamsResponse is response type for the Query/Params RPC method. -type QueryParamsResponse struct { - // params holds all the parameters of this module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` -} - -func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } -func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryParamsResponse) ProtoMessage() {} -func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{1} -} -func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryParamsResponse.Merge(m, src) -} -func (m *QueryParamsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryParamsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo - -func (m *QueryParamsResponse) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - type QueryGetForeignCoinsRequest struct { Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` } @@ -122,7 +39,7 @@ func (m *QueryGetForeignCoinsRequest) Reset() { *m = QueryGetForeignCoin func (m *QueryGetForeignCoinsRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetForeignCoinsRequest) ProtoMessage() {} func (*QueryGetForeignCoinsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{2} + return fileDescriptor_d671b6e9298b37cd, []int{0} } func (m *QueryGetForeignCoinsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -166,7 +83,7 @@ func (m *QueryGetForeignCoinsResponse) Reset() { *m = QueryGetForeignCoi func (m *QueryGetForeignCoinsResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetForeignCoinsResponse) ProtoMessage() {} func (*QueryGetForeignCoinsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{3} + return fileDescriptor_d671b6e9298b37cd, []int{1} } func (m *QueryGetForeignCoinsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -210,7 +127,7 @@ func (m *QueryAllForeignCoinsRequest) Reset() { *m = QueryAllForeignCoin func (m *QueryAllForeignCoinsRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllForeignCoinsRequest) ProtoMessage() {} func (*QueryAllForeignCoinsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{4} + return fileDescriptor_d671b6e9298b37cd, []int{2} } func (m *QueryAllForeignCoinsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -255,7 +172,7 @@ func (m *QueryAllForeignCoinsResponse) Reset() { *m = QueryAllForeignCoi func (m *QueryAllForeignCoinsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllForeignCoinsResponse) ProtoMessage() {} func (*QueryAllForeignCoinsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{5} + return fileDescriptor_d671b6e9298b37cd, []int{3} } func (m *QueryAllForeignCoinsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -305,7 +222,7 @@ func (m *QueryGetSystemContractRequest) Reset() { *m = QueryGetSystemCon func (m *QueryGetSystemContractRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetSystemContractRequest) ProtoMessage() {} func (*QueryGetSystemContractRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{6} + return fileDescriptor_d671b6e9298b37cd, []int{4} } func (m *QueryGetSystemContractRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -342,7 +259,7 @@ func (m *QueryGetSystemContractResponse) Reset() { *m = QueryGetSystemCo func (m *QueryGetSystemContractResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetSystemContractResponse) ProtoMessage() {} func (*QueryGetSystemContractResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{7} + return fileDescriptor_d671b6e9298b37cd, []int{5} } func (m *QueryGetSystemContractResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -385,7 +302,7 @@ func (m *QueryGetGasStabilityPoolAddress) Reset() { *m = QueryGetGasStab func (m *QueryGetGasStabilityPoolAddress) String() string { return proto.CompactTextString(m) } func (*QueryGetGasStabilityPoolAddress) ProtoMessage() {} func (*QueryGetGasStabilityPoolAddress) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{8} + return fileDescriptor_d671b6e9298b37cd, []int{6} } func (m *QueryGetGasStabilityPoolAddress) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -425,7 +342,7 @@ func (m *QueryGetGasStabilityPoolAddressResponse) Reset() { func (m *QueryGetGasStabilityPoolAddressResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetGasStabilityPoolAddressResponse) ProtoMessage() {} func (*QueryGetGasStabilityPoolAddressResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{9} + return fileDescriptor_d671b6e9298b37cd, []int{7} } func (m *QueryGetGasStabilityPoolAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -476,7 +393,7 @@ func (m *QueryGetGasStabilityPoolBalance) Reset() { *m = QueryGetGasStab func (m *QueryGetGasStabilityPoolBalance) String() string { return proto.CompactTextString(m) } func (*QueryGetGasStabilityPoolBalance) ProtoMessage() {} func (*QueryGetGasStabilityPoolBalance) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{10} + return fileDescriptor_d671b6e9298b37cd, []int{8} } func (m *QueryGetGasStabilityPoolBalance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -522,7 +439,7 @@ func (m *QueryGetGasStabilityPoolBalanceResponse) Reset() { func (m *QueryGetGasStabilityPoolBalanceResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetGasStabilityPoolBalanceResponse) ProtoMessage() {} func (*QueryGetGasStabilityPoolBalanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{11} + return fileDescriptor_d671b6e9298b37cd, []int{9} } func (m *QueryGetGasStabilityPoolBalanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -565,7 +482,7 @@ func (m *QueryAllGasStabilityPoolBalance) Reset() { *m = QueryAllGasStab func (m *QueryAllGasStabilityPoolBalance) String() string { return proto.CompactTextString(m) } func (*QueryAllGasStabilityPoolBalance) ProtoMessage() {} func (*QueryAllGasStabilityPoolBalance) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{12} + return fileDescriptor_d671b6e9298b37cd, []int{10} } func (m *QueryAllGasStabilityPoolBalance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -604,7 +521,7 @@ func (m *QueryAllGasStabilityPoolBalanceResponse) Reset() { func (m *QueryAllGasStabilityPoolBalanceResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllGasStabilityPoolBalanceResponse) ProtoMessage() {} func (*QueryAllGasStabilityPoolBalanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{13} + return fileDescriptor_d671b6e9298b37cd, []int{11} } func (m *QueryAllGasStabilityPoolBalanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -653,7 +570,7 @@ func (m *QueryAllGasStabilityPoolBalanceResponse_Balance) String() string { } func (*QueryAllGasStabilityPoolBalanceResponse_Balance) ProtoMessage() {} func (*QueryAllGasStabilityPoolBalanceResponse_Balance) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{13, 0} + return fileDescriptor_d671b6e9298b37cd, []int{11, 0} } func (m *QueryAllGasStabilityPoolBalanceResponse_Balance) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -704,7 +621,7 @@ func (m *QueryCodeHashRequest) Reset() { *m = QueryCodeHashRequest{} } func (m *QueryCodeHashRequest) String() string { return proto.CompactTextString(m) } func (*QueryCodeHashRequest) ProtoMessage() {} func (*QueryCodeHashRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{14} + return fileDescriptor_d671b6e9298b37cd, []int{12} } func (m *QueryCodeHashRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -748,7 +665,7 @@ func (m *QueryCodeHashResponse) Reset() { *m = QueryCodeHashResponse{} } func (m *QueryCodeHashResponse) String() string { return proto.CompactTextString(m) } func (*QueryCodeHashResponse) ProtoMessage() {} func (*QueryCodeHashResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d671b6e9298b37cd, []int{15} + return fileDescriptor_d671b6e9298b37cd, []int{13} } func (m *QueryCodeHashResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -785,8 +702,6 @@ func (m *QueryCodeHashResponse) GetCodeHash() string { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "zetachain.zetacore.fungible.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "zetachain.zetacore.fungible.QueryParamsResponse") proto.RegisterType((*QueryGetForeignCoinsRequest)(nil), "zetachain.zetacore.fungible.QueryGetForeignCoinsRequest") proto.RegisterType((*QueryGetForeignCoinsResponse)(nil), "zetachain.zetacore.fungible.QueryGetForeignCoinsResponse") proto.RegisterType((*QueryAllForeignCoinsRequest)(nil), "zetachain.zetacore.fungible.QueryAllForeignCoinsRequest") @@ -807,65 +722,61 @@ func init() { func init() { proto.RegisterFile("fungible/query.proto", fileDescriptor_d671b6e9298b37cd) } var fileDescriptor_d671b6e9298b37cd = []byte{ - // 927 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x41, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0xa6, 0x34, 0x49, 0x5f, 0x43, 0x91, 0x06, 0x57, 0x84, 0x4d, 0xbb, 0x81, 0x69, 0x69, - 0x4b, 0x28, 0xbb, 0x49, 0x8a, 0x44, 0x09, 0x11, 0xc2, 0x31, 0x6a, 0xa8, 0xc4, 0x21, 0x38, 0x17, - 0xe0, 0x62, 0x8d, 0xd7, 0x93, 0xf5, 0x4a, 0xeb, 0x1d, 0xc7, 0xb3, 0x8e, 0x6a, 0xac, 0x5c, 0xb8, - 0x72, 0xa9, 0xc4, 0x4f, 0xe0, 0x1f, 0x70, 0xe1, 0xc2, 0x0f, 0xe8, 0xb1, 0x12, 0x12, 0x82, 0x0b, - 0x02, 0x87, 0x1f, 0x82, 0x3c, 0xfb, 0x66, 0xe3, 0x35, 0xbb, 0xde, 0xc5, 0xb9, 0xed, 0xcc, 0xbc, - 0xef, 0xbd, 0xef, 0x7b, 0xf3, 0xfc, 0x8d, 0xa1, 0x72, 0xdc, 0x0f, 0x3d, 0xbf, 0x19, 0x70, 0xe7, - 0xa4, 0xcf, 0x7b, 0x03, 0xbb, 0xdb, 0x13, 0x91, 0x20, 0xeb, 0xdf, 0xf2, 0x88, 0xb9, 0x6d, 0xe6, - 0x87, 0xb6, 0xfa, 0x12, 0x3d, 0x6e, 0xeb, 0x40, 0x73, 0xd3, 0x15, 0xb2, 0x23, 0xa4, 0xd3, 0x64, - 0x12, 0x51, 0xce, 0xe9, 0x76, 0x93, 0x47, 0x6c, 0xdb, 0xe9, 0x32, 0xcf, 0x0f, 0x59, 0xe4, 0x8b, - 0x30, 0x4e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f0, 0x8d, 0xe3, 0xf9, 0x51, 0xbb, 0xdf, 0xb4, 0x5d, - 0xd1, 0xc9, 0xec, 0xc1, 0xb3, 0x8b, 0xc4, 0xd1, 0xa0, 0xcb, 0x65, 0x73, 0x49, 0xfd, 0x7b, 0x7f, - 0xf4, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x10, 0x51, 0x58, 0xac, 0xa7, 0x0c, 0x00, 0x00, + // 857 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xc1, 0x6e, 0xd3, 0x48, + 0x18, 0x8e, 0xdb, 0xed, 0x26, 0x9d, 0x76, 0xbb, 0xd2, 0x28, 0xab, 0xed, 0xba, 0x5d, 0x67, 0xd7, + 0xea, 0xb6, 0xdd, 0x50, 0xec, 0x26, 0x45, 0xa2, 0x94, 0x08, 0x91, 0x04, 0xb5, 0x54, 0xe2, 0x50, + 0xd2, 0x13, 0x5c, 0xa2, 0x89, 0x33, 0x75, 0x2c, 0x39, 0x9e, 0x34, 0xe3, 0x54, 0x0d, 0x51, 0x2f, + 0x3c, 0x01, 0x12, 0x8f, 0xc0, 0x1b, 0x70, 0xe1, 0xc2, 0x03, 0xf4, 0x58, 0x09, 0x09, 0xc1, 0x05, + 0x41, 0xca, 0x43, 0x70, 0x44, 0x19, 0xcf, 0xb8, 0x49, 0xb0, 0x13, 0x93, 0xde, 0x3c, 0x9e, 0xff, + 0xfb, 0xfe, 0xef, 0xfb, 0x67, 0xfc, 0x25, 0x20, 0x79, 0xd4, 0x72, 0x4c, 0xab, 0x62, 0x63, 0xfd, + 0xb8, 0x85, 0x9b, 0x6d, 0xad, 0xd1, 0x24, 0x2e, 0x81, 0x4b, 0xcf, 0xb0, 0x8b, 0x8c, 0x1a, 0xb2, + 0x1c, 0x8d, 0x3d, 0x91, 0x26, 0xd6, 0x44, 0xa1, 0x9c, 0x36, 0x08, 0xad, 0x13,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0xa0, 0x1b, 0x13, 0xd1, 0x32, 0x15, 0xf0, 0x72, 0x83, 0x10, 0x5b, 0xe4, 0x20, 0xfc, + 0x12, 0x60, 0x4c, 0x7c, 0xc4, 0x93, 0x19, 0xe3, 0xe8, 0x09, 0x8d, 0x0d, 0x65, 0x8d, 0x5a, 0x60, + 0xc6, 0x72, 0x70, 0x27, 0xaa, 0x31, 0x1e, 0x26, 0x7a, 0x47, 0xe4, 0xcf, 0x19, 0xec, 0x4a, 0x40, + 0x0e, 0xe9, 0xd3, 0xfb, 0x6c, 0x72, 0xd7, 0x09, 0xc5, 0x28, 0x36, 0xc7, 0x47, 0xaa, 0x7a, 0x9f, + 0xd9, 0xdc, 0x81, 0xdb, 0xfd, 0x36, 0x05, 0x5d, 0x14, 0xbf, 0xf0, 0x95, 0x04, 0x12, 0x22, 0x06, + 0x61, 0x66, 0xbc, 0xa8, 0xa1, 0x90, 0x95, 0xb3, 0x3f, 0x03, 0xe1, 0xaa, 0x37, 0x99, 0xea, 0x34, + 0x5c, 0x0f, 0x3c, 0x1c, 0x3f, 0x80, 0xf5, 0x0e, 0xbf, 0x6d, 0x67, 0x85, 0xfd, 0xf3, 0xae, 0x22, + 0x5d, 0x74, 0x15, 0xe9, 0x73, 0x57, 0x91, 0x5e, 0x5c, 0x2a, 0xb1, 0x8b, 0x4b, 0x25, 0xf6, 0xe1, + 0x52, 0x89, 0x3d, 0xd5, 0x4d, 0xcb, 0xad, 0xb5, 0x2a, 0x9a, 0x41, 0xea, 0x81, 0x33, 0x38, 0xbd, + 0x22, 0x76, 0xdb, 0x0d, 0x4c, 0x2b, 0xbf, 0xb2, 0xbf, 0xae, 0x5b, 0xdf, 0x03, 0x00, 0x00, 0xff, + 0xff, 0xad, 0xf6, 0x9f, 0xa6, 0x8d, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -880,8 +791,6 @@ 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 QueryClient interface { - // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // Queries a ForeignCoins by index. ForeignCoins(ctx context.Context, in *QueryGetForeignCoinsRequest, opts ...grpc.CallOption) (*QueryGetForeignCoinsResponse, error) // Queries a list of ForeignCoins items. @@ -906,15 +815,6 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { - out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Query/Params", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) ForeignCoins(ctx context.Context, in *QueryGetForeignCoinsRequest, opts ...grpc.CallOption) (*QueryGetForeignCoinsResponse, error) { out := new(QueryGetForeignCoinsResponse) err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Query/ForeignCoins", in, out, opts...) @@ -980,8 +880,6 @@ func (c *queryClient) CodeHash(ctx context.Context, in *QueryCodeHashRequest, op // QueryServer is the server API for Query service. type QueryServer interface { - // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // Queries a ForeignCoins by index. ForeignCoins(context.Context, *QueryGetForeignCoinsRequest) (*QueryGetForeignCoinsResponse, error) // Queries a list of ForeignCoins items. @@ -1002,9 +900,6 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") -} func (*UnimplementedQueryServer) ForeignCoins(ctx context.Context, req *QueryGetForeignCoinsRequest) (*QueryGetForeignCoinsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ForeignCoins not implemented") } @@ -1031,24 +926,6 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryParamsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/zetachain.zetacore.fungible.Query/Params", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_ForeignCoins_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryGetForeignCoinsRequest) if err := dec(in); err != nil { @@ -1179,10 +1056,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.fungible.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "Params", - Handler: _Query_Params_Handler, - }, { MethodName: "ForeignCoins", Handler: _Query_ForeignCoins_Handler, @@ -1216,62 +1089,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "fungible/query.proto", } -func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *QueryGetForeignCoinsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1759,26 +1576,6 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - func (m *QueryGetForeignCoinsRequest) Size() (n int) { if m == nil { return 0 @@ -1978,139 +1775,6 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryParamsRequest) 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 ErrIntOverflowQuery - } - 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: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsResponse) 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 ErrIntOverflowQuery - } - 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: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryGetForeignCoinsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/fungible/types/query.pb.gw.go b/x/fungible/types/query.pb.gw.go index c971723b1b..f007d04b3e 100644 --- a/x/fungible/types/query.pb.gw.go +++ b/x/fungible/types/query.pb.gw.go @@ -33,24 +33,6 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryParamsRequest - var metadata runtime.ServerMetadata - - msg, err := server.Params(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_ForeignCoins_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGetForeignCoinsRequest var metadata runtime.ServerMetadata @@ -309,29 +291,6 @@ func local_request_Query_CodeHash_0(ctx context.Context, marshaler runtime.Marsh // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_ForeignCoins_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -534,26 +493,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_ForeignCoins_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -698,8 +637,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "fungible", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_ForeignCoins_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "fungible", "foreign_coins", "index"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ForeignCoinsAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "fungible", "foreign_coins"}, "", runtime.AssumeColonVerbOpt(false))) @@ -716,8 +653,6 @@ var ( ) var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage - forward_Query_ForeignCoins_0 = runtime.ForwardResponseMessage forward_Query_ForeignCoinsAll_0 = runtime.ForwardResponseMessage From f6f87b88e6fc0ced913668db1b0a0fa6c8421ee1 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Thu, 18 Apr 2024 05:06:54 -0700 Subject: [PATCH 02/11] feat(zetaclient): remove metrics server prefix (#2043) Co-authored-by: Lucas Bertrand --- zetaclient/metrics/metrics.go | 16 ++++++---------- zetaclient/metrics/metrics_test.go | 6 ++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/zetaclient/metrics/metrics.go b/zetaclient/metrics/metrics.go index efb3232590..d6525a70ba 100644 --- a/zetaclient/metrics/metrics.go +++ b/zetaclient/metrics/metrics.go @@ -87,20 +87,16 @@ var ( ) func NewMetrics() (*Metrics, error) { - server := http.NewServeMux() - - server.Handle("/metrics", - promhttp.InstrumentMetricHandler( - prometheus.DefaultRegisterer, - promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{ - Timeout: 30 * time.Second, - }), - ), + handler := promhttp.InstrumentMetricHandler( + prometheus.DefaultRegisterer, + promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{ + Timeout: 30 * time.Second, + }), ) s := &http.Server{ Addr: ":8886", - Handler: server, + Handler: handler, ReadTimeout: 5 * time.Second, ReadHeaderTimeout: 5 * time.Second, } diff --git a/zetaclient/metrics/metrics_test.go b/zetaclient/metrics/metrics_test.go index f40001bbee..b73bf00530 100644 --- a/zetaclient/metrics/metrics_test.go +++ b/zetaclient/metrics/metrics_test.go @@ -30,7 +30,13 @@ func (ms *MetricsSuite) TestMetrics(c *C) { time.Sleep(1 * time.Second) res, err := http.Get("http://127.0.0.1:8886/metrics") c.Assert(err, IsNil) + c.Assert(res.StatusCode, Equals, http.StatusOK) defer res.Body.Close() //out, err := ioutil.ReadAll(res.Body) //fmt.Println(string(out)) + + res, err = http.Get("http://127.0.0.1:8886") + c.Assert(err, IsNil) + c.Assert(res.StatusCode, Equals, http.StatusOK) + defer res.Body.Close() } From 8ffbf76a3aee06131cab19340fda27ca0095b9aa Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Thu, 18 Apr 2024 14:23:50 +0200 Subject: [PATCH 03/11] chore(codecov.yml): add zetaclient testdata and testutils in codecov ignore (#2036) --- codecov.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codecov.yml b/codecov.yml index aab4d9ab68..bbdb628387 100644 --- a/codecov.yml +++ b/codecov.yml @@ -53,6 +53,8 @@ ignore: - "x/**/migrator.go" - "x/**/module_simulation.go" - "x/**/simulation/**/*" + - "zetaclient/testdata/**/*" + - "zetaclient/testutils/**/*" - "**/*.proto" - "**/*.md" - "**/*.yml" From 583bfaf5ab8acdc8221a73bfe91785f79e8b028e Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Thu, 18 Apr 2024 14:47:34 +0200 Subject: [PATCH 04/11] feat: add `lightclient` module and migrate block header state in this module (#1976) * initialize module and proto * init keeper and queries * clean up queries and add genesis * add module in app.go * verification flags * rename addBlockHeader into voteBlockHeader * implement add new block logic * add lightclient dep to observer and refactor vote blockheader * add lightclient module to crosschain deps and simplify body verification logic * comment out some tests * make generate * refactor add tracker messages * add new queries * add authority dependency to lightclient * implement message update verification flags * basic lightclient tests * proof first test * make generate * changelogs * lint errors * test for vote block header * comment some tests * tx body verification tests * fix failing tests * fix type tests * addInTx tests * lint * out tx tracker tests * comment some tests * block header tests * add tests for proof verification * remove queries * remove block header state * fix e2e tests * fix zetaclient * add breaking changes * add more entry in breaking changes * add verification flags in zetaclient * read verification flags in zetaclient * set verification flags in e2e tests * make generate * fix tests * fix bridge test * comments * revert fungible admin * refactor tss error * testutil/keeper/crosschain.go * add comment todo * default verification flags * add pagination tests * update verification flags comment * use sub function for get required group * message docs * proof * use error in lightclient * fix client test * comments * register interface * Improve error handling on broadcastTx in e2e tests --------- Co-authored-by: skosito --- app/ante/ante.go | 2 +- app/ante/ante_test.go | 10 +- app/app.go | 30 +- app/setup_handlers.go | 3 +- changelog.md | 16 +- cmd/zetae2e/balances.go | 5 +- cmd/zetae2e/bitcoin_address.go | 5 +- cmd/zetae2e/config/clients.go | 19 +- cmd/zetae2e/config/config.go | 2 + cmd/zetae2e/local/local.go | 5 + cmd/zetae2e/run.go | 7 +- cmd/zetae2e/setup_bitcoin.go | 5 +- cmd/zetae2e/show_tss.go | 12 +- cmd/zetae2e/stress.go | 3 +- docs/cli/zetacored/zetacored_query.md | 1 + .../zetacored/zetacored_query_lightclient.md | 33 + ...red_query_lightclient_list-block-header.md | 33 + ...ored_query_lightclient_list-chain-state.md | 33 + ...red_query_lightclient_show-block-header.md | 33 + ...ored_query_lightclient_show-chain-state.md | 33 + ...ery_lightclient_show-verification-flags.md | 33 + docs/cli/zetacored/zetacored_tx.md | 1 + .../cli/zetacored/zetacored_tx_lightclient.md | 29 + ...x_lightclient_update-verification-flags.md | 52 + docs/openapi/openapi.swagger.yaml | 514 +-- docs/spec/crosschain/messages.md | 4 - docs/spec/lightclient/messages.md | 15 + docs/spec/observer/messages.md | 6 +- e2e/e2etests/test_migrate_chain_support.go | 1 + e2e/runner/bitcoin.go | 6 +- e2e/runner/evm.go | 9 +- e2e/runner/runner.go | 30 +- e2e/runner/setup_zeta.go | 7 + e2e/txserver/zeta_tx_server.go | 30 +- pkg/testdata/testdata.go | 7 +- proto/lightclient/chain_state.proto | 14 + proto/lightclient/genesis.proto | 16 + proto/lightclient/query.proto | 90 + proto/lightclient/tx.proto | 19 + proto/lightclient/verification_flags.proto | 10 + proto/observer/block_header.proto | 14 - proto/observer/crosschain_flags.proto | 4 + proto/observer/query.proto | 55 - proto/observer/tx.proto | 9 +- testutil/keeper/crosschain.go | 68 +- testutil/keeper/emissions.go | 5 +- testutil/keeper/fungible.go | 14 +- testutil/keeper/keeper.go | 12 +- testutil/keeper/lightclient.go | 94 + testutil/keeper/mocks/crosschain/account.go | 2 +- testutil/keeper/mocks/crosschain/authority.go | 2 +- testutil/keeper/mocks/crosschain/bank.go | 2 +- testutil/keeper/mocks/crosschain/fungible.go | 2 +- .../keeper/mocks/crosschain/lightclient.go | 60 + testutil/keeper/mocks/crosschain/observer.go | 32 +- testutil/keeper/mocks/crosschain/staking.go | 2 +- testutil/keeper/mocks/emissions/account.go | 2 +- testutil/keeper/mocks/emissions/bank.go | 2 +- testutil/keeper/mocks/emissions/observer.go | 2 +- .../keeper/mocks/emissions/param_store.go | 2 +- testutil/keeper/mocks/emissions/staking.go | 2 +- testutil/keeper/mocks/fungible/account.go | 2 +- testutil/keeper/mocks/fungible/authority.go | 2 +- testutil/keeper/mocks/fungible/bank.go | 2 +- testutil/keeper/mocks/fungible/evm.go | 2 +- testutil/keeper/mocks/fungible/observer.go | 2 +- .../keeper/mocks/lightclient/authority.go | 47 + testutil/keeper/mocks/mocks.go | 20 + testutil/keeper/mocks/observer/authority.go | 2 +- testutil/keeper/mocks/observer/lightclient.go | 65 + testutil/keeper/mocks/observer/slashing.go | 2 +- testutil/keeper/mocks/observer/staking.go | 2 +- testutil/keeper/observer.go | 29 +- testutil/sample/common.go | 30 - testutil/sample/crypto.go | 132 + testutil/sample/lightclient.go | 76 + testutil/sample/sample.go | 81 +- .../chain_state_pb.d.ts} | 20 +- typescript/lightclient/genesis_pb.d.ts | 47 + typescript/lightclient/index.d.ts | 5 + typescript/lightclient/query_pb.d.ts | 325 ++ typescript/lightclient/tx_pb.d.ts | 57 + .../lightclient/verification_flags_pb.d.ts | 39 + typescript/observer/crosschain_flags_pb.d.ts | 4 + typescript/observer/index.d.ts | 1 - typescript/observer/query_pb.d.ts | 219 -- typescript/observer/tx_pb.d.ts | 42 +- x/crosschain/keeper/grpc_query_cctx.go | 2 +- x/crosschain/keeper/keeper.go | 7 + .../keeper/msg_server_add_to_intx_tracker.go | 67 +- .../msg_server_add_to_intx_tracker_test.go | 365 ++- .../keeper/msg_server_add_to_outtx_tracker.go | 188 +- .../msg_server_add_to_outtx_tracker_test.go | 695 ++-- x/crosschain/keeper/out_tx_tracker.go | 1 - x/crosschain/keeper/verify_proof.go | 109 - x/crosschain/keeper/verify_proof_test.go | 393 --- x/crosschain/types/authz.go | 2 +- x/crosschain/types/authz_test.go | 2 +- x/crosschain/types/errors.go | 1 + x/crosschain/types/expected_keepers.go | 5 +- x/crosschain/types/genesis_test.go | 10 - x/crosschain/types/tx_body_verification.go | 164 + .../types/tx_body_verification_test.go | 278 ++ x/lightclient/client/cli/query.go | 31 + .../client/cli/query_block_header.go | 77 + x/lightclient/client/cli/query_chain_state.go | 82 + .../client/cli/query_verification_flags.go | 37 + x/lightclient/client/cli/tx.go | 26 + .../cli/tx_update_verification_flags.go | 41 + x/lightclient/genesis.go | 37 + x/lightclient/genesis_test.go | 63 + x/lightclient/keeper/block_header.go | 155 + x/lightclient/keeper/block_header_test.go | 330 ++ x/lightclient/keeper/chain_state.go | 49 + x/lightclient/keeper/chain_state_test.go | 37 + x/lightclient/keeper/grpc_query.go | 7 + .../keeper/grpc_query_block_header.go | 33 +- .../keeper/grpc_query_block_header_test.go | 129 + .../keeper/grpc_query_chain_state.go | 52 + .../keeper/grpc_query_chain_state_test.go | 129 + .../keeper/grpc_query_prove.go | 9 +- x/lightclient/keeper/grpc_query_prove_test.go | 134 + .../keeper/grpc_query_verification_flags.go | 25 + .../grpc_query_verification_flags_test.go | 47 + x/lightclient/keeper/keeper.go | 59 + x/lightclient/keeper/msg_server.go | 15 + .../msg_server_update_verification_flags.go | 28 + ...g_server_update_verification_flags_test.go | 142 + x/lightclient/keeper/proof.go | 35 + x/lightclient/keeper/proof_test.go | 115 + .../testdata/header_sepolia_5000000.json | 0 .../testdata/header_sepolia_5000001.json | 0 .../testdata/header_sepolia_5000002.json | 0 x/lightclient/keeper/verification_flags.go | 65 + .../keeper/verification_flags_test.go | 70 + x/lightclient/module.go | 171 + .../types/chain_state.pb.go} | 160 +- x/lightclient/types/codec.go | 25 + x/lightclient/types/errors.go | 17 + x/lightclient/types/expected_keepers.go | 10 + x/lightclient/types/genesis.go | 41 + x/lightclient/types/genesis.pb.go | 454 +++ x/lightclient/types/genesis_test.go | 79 + x/lightclient/types/keys.go | 28 + .../message_update_verification_flags.go | 62 + .../message_update_verification_flags_test.go | 173 + x/lightclient/types/query.pb.go | 2783 +++++++++++++++++ x/lightclient/types/query.pb.gw.go | 604 ++++ x/lightclient/types/tx.pb.go | 581 ++++ x/lightclient/types/verification_flags.go | 10 + x/lightclient/types/verification_flags.pb.go | 352 +++ .../types/verification_flags_test.go | 15 + x/observer/keeper/block_header.go | 55 - x/observer/keeper/block_header_test.go | 32 - .../keeper/grpc_query_block_header_test.go | 119 - x/observer/keeper/grpc_query_prove_test.go | 72 - x/observer/keeper/grpc_query_tss.go | 2 +- x/observer/keeper/keeper.go | 35 +- .../keeper/msg_server_add_block_header.go | 125 - .../msg_server_add_block_header_test.go | 218 -- .../keeper/msg_server_vote_block_header.go | 57 + .../msg_server_vote_block_header_test.go | 294 ++ x/observer/keeper/utils.go | 5 +- x/observer/types/codec.go | 4 +- x/observer/types/crosschain_flags.go | 10 +- x/observer/types/crosschain_flags.pb.go | 8 +- x/observer/types/errors.go | 22 +- x/observer/types/expected_keepers.go | 19 + ....go => message_update_crosschain_flags.go} | 0 ...> message_update_crosschain_flags_test.go} | 0 ...header.go => message_vote_block_header.go} | 32 +- ...t.go => message_vote_block_header_test.go} | 40 +- x/observer/types/query.pb.go | 2293 ++------------ x/observer/types/query.pb.gw.go | 368 --- x/observer/types/tx.pb.go | 360 ++- zetaclient/bitcoin/bitcoin_client.go | 12 +- zetaclient/core_context/zeta_core_context.go | 14 + .../core_context/zeta_core_context_test.go | 31 +- zetaclient/evm/evm_client.go | 15 +- zetaclient/evm/evm_client_test.go | 5 +- zetaclient/interfaces/interfaces.go | 6 +- zetaclient/testutils/stub/core_bridge.go | 10 +- zetaclient/zetabridge/broadcast_test.go | 4 +- zetaclient/zetabridge/query.go | 34 +- zetaclient/zetabridge/query_test.go | 40 +- zetaclient/zetabridge/tx.go | 6 +- zetaclient/zetabridge/tx_test.go | 15 +- zetaclient/zetabridge/zetacore_bridge.go | 19 +- zetaclient/zetacore_observer_test.go | 2 + 189 files changed, 11837 insertions(+), 5284 deletions(-) create mode 100644 docs/cli/zetacored/zetacored_query_lightclient.md create mode 100644 docs/cli/zetacored/zetacored_query_lightclient_list-block-header.md create mode 100644 docs/cli/zetacored/zetacored_query_lightclient_list-chain-state.md create mode 100644 docs/cli/zetacored/zetacored_query_lightclient_show-block-header.md create mode 100644 docs/cli/zetacored/zetacored_query_lightclient_show-chain-state.md create mode 100644 docs/cli/zetacored/zetacored_query_lightclient_show-verification-flags.md create mode 100644 docs/cli/zetacored/zetacored_tx_lightclient.md create mode 100644 docs/cli/zetacored/zetacored_tx_lightclient_update-verification-flags.md create mode 100644 docs/spec/lightclient/messages.md create mode 100644 proto/lightclient/chain_state.proto create mode 100644 proto/lightclient/genesis.proto create mode 100644 proto/lightclient/query.proto create mode 100644 proto/lightclient/tx.proto create mode 100644 proto/lightclient/verification_flags.proto delete mode 100644 proto/observer/block_header.proto create mode 100644 testutil/keeper/lightclient.go create mode 100644 testutil/keeper/mocks/crosschain/lightclient.go create mode 100644 testutil/keeper/mocks/lightclient/authority.go create mode 100644 testutil/keeper/mocks/observer/lightclient.go delete mode 100644 testutil/sample/common.go create mode 100644 testutil/sample/crypto.go create mode 100644 testutil/sample/lightclient.go rename typescript/{observer/block_header_pb.d.ts => lightclient/chain_state_pb.d.ts} (58%) create mode 100644 typescript/lightclient/genesis_pb.d.ts create mode 100644 typescript/lightclient/index.d.ts create mode 100644 typescript/lightclient/query_pb.d.ts create mode 100644 typescript/lightclient/tx_pb.d.ts create mode 100644 typescript/lightclient/verification_flags_pb.d.ts delete mode 100644 x/crosschain/keeper/verify_proof.go delete mode 100644 x/crosschain/keeper/verify_proof_test.go create mode 100644 x/crosschain/types/tx_body_verification.go create mode 100644 x/crosschain/types/tx_body_verification_test.go create mode 100644 x/lightclient/client/cli/query.go create mode 100644 x/lightclient/client/cli/query_block_header.go create mode 100644 x/lightclient/client/cli/query_chain_state.go create mode 100644 x/lightclient/client/cli/query_verification_flags.go create mode 100644 x/lightclient/client/cli/tx.go create mode 100644 x/lightclient/client/cli/tx_update_verification_flags.go create mode 100644 x/lightclient/genesis.go create mode 100644 x/lightclient/genesis_test.go create mode 100644 x/lightclient/keeper/block_header.go create mode 100644 x/lightclient/keeper/block_header_test.go create mode 100644 x/lightclient/keeper/chain_state.go create mode 100644 x/lightclient/keeper/chain_state_test.go create mode 100644 x/lightclient/keeper/grpc_query.go rename x/{observer => lightclient}/keeper/grpc_query_block_header.go (50%) create mode 100644 x/lightclient/keeper/grpc_query_block_header_test.go create mode 100644 x/lightclient/keeper/grpc_query_chain_state.go create mode 100644 x/lightclient/keeper/grpc_query_chain_state_test.go rename x/{observer => lightclient}/keeper/grpc_query_prove.go (96%) create mode 100644 x/lightclient/keeper/grpc_query_prove_test.go create mode 100644 x/lightclient/keeper/grpc_query_verification_flags.go create mode 100644 x/lightclient/keeper/grpc_query_verification_flags_test.go create mode 100644 x/lightclient/keeper/keeper.go create mode 100644 x/lightclient/keeper/msg_server.go create mode 100644 x/lightclient/keeper/msg_server_update_verification_flags.go create mode 100644 x/lightclient/keeper/msg_server_update_verification_flags_test.go create mode 100644 x/lightclient/keeper/proof.go create mode 100644 x/lightclient/keeper/proof_test.go rename x/{observer => lightclient}/keeper/testdata/header_sepolia_5000000.json (100%) rename x/{observer => lightclient}/keeper/testdata/header_sepolia_5000001.json (100%) rename x/{observer => lightclient}/keeper/testdata/header_sepolia_5000002.json (100%) create mode 100644 x/lightclient/keeper/verification_flags.go create mode 100644 x/lightclient/keeper/verification_flags_test.go create mode 100644 x/lightclient/module.go rename x/{observer/types/block_header.pb.go => lightclient/types/chain_state.pb.go} (55%) create mode 100644 x/lightclient/types/codec.go create mode 100644 x/lightclient/types/errors.go create mode 100644 x/lightclient/types/expected_keepers.go create mode 100644 x/lightclient/types/genesis.go create mode 100644 x/lightclient/types/genesis.pb.go create mode 100644 x/lightclient/types/genesis_test.go create mode 100644 x/lightclient/types/keys.go create mode 100644 x/lightclient/types/message_update_verification_flags.go create mode 100644 x/lightclient/types/message_update_verification_flags_test.go create mode 100644 x/lightclient/types/query.pb.go create mode 100644 x/lightclient/types/query.pb.gw.go create mode 100644 x/lightclient/types/tx.pb.go create mode 100644 x/lightclient/types/verification_flags.go create mode 100644 x/lightclient/types/verification_flags.pb.go create mode 100644 x/lightclient/types/verification_flags_test.go delete mode 100644 x/observer/keeper/block_header.go delete mode 100644 x/observer/keeper/block_header_test.go delete mode 100644 x/observer/keeper/grpc_query_block_header_test.go delete mode 100644 x/observer/keeper/grpc_query_prove_test.go delete mode 100644 x/observer/keeper/msg_server_add_block_header.go delete mode 100644 x/observer/keeper/msg_server_add_block_header_test.go create mode 100644 x/observer/keeper/msg_server_vote_block_header.go create mode 100644 x/observer/keeper/msg_server_vote_block_header_test.go rename x/observer/types/{message_crosschain_flags.go => message_update_crosschain_flags.go} (100%) rename x/observer/types/{message_crosschain_flags_test.go => message_update_crosschain_flags_test.go} (100%) rename x/observer/types/{message_add_block_header.go => message_vote_block_header.go} (61%) rename x/observer/types/{message_add_block_header_test.go => message_vote_block_header_test.go} (77%) diff --git a/app/ante/ante.go b/app/ante/ante.go index 562c6c0de2..18947d01fa 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -172,8 +172,8 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool { *cctxtypes.MsgVoteOnObservedInboundTx, *cctxtypes.MsgVoteOnObservedOutboundTx, *cctxtypes.MsgAddToOutTxTracker, + *observertypes.MsgVoteBlockHeader, *observertypes.MsgVoteTSS, - *observertypes.MsgAddBlockHeader, *observertypes.MsgAddBlameVote: signers := innerMsg.GetSigners() if len(signers) == 1 { diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index d4a28f4466..790930d175 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -36,8 +36,8 @@ func TestIsSystemTx(t *testing.T) { // *cctxtypes.MsgVoteOnObservedInboundTx, // *cctxtypes.MsgVoteOnObservedOutboundTx, // *cctxtypes.MsgAddToOutTxTracker, + // *observertypes.MsgVoteBlockHeader, // *observertypes.MsgVoteTSS, - // *observertypes.MsgAddBlockHeader, // *observertypes.MsgAddBlameVote: buildTxFromMsg := func(msg sdk.Msg) sdk.Tx { txBuilder := app.MakeEncodingConfig().TxConfig.NewTxBuilder() @@ -187,8 +187,8 @@ func TestIsSystemTx(t *testing.T) { true, }, { - "MsgAddBlockHeader", - buildTxFromMsg(&observertypes.MsgAddBlockHeader{ + "MsgVoteBlockHeader", + buildTxFromMsg(&observertypes.MsgVoteBlockHeader{ Creator: sample.AccAddress(), }), isAuthorized, @@ -196,8 +196,8 @@ func TestIsSystemTx(t *testing.T) { true, }, { - "MsgExec{MsgAddBlockHeader}", - buildAuthzTxFromMsg(&observertypes.MsgAddBlockHeader{ + "MsgExec{MsgVoteBlockHeader}", + buildAuthzTxFromMsg(&observertypes.MsgVoteBlockHeader{ Creator: sample.AccAddress(), }), isAuthorized, diff --git a/app/app.go b/app/app.go index bbb50a7802..27300a47d9 100644 --- a/app/app.go +++ b/app/app.go @@ -98,6 +98,10 @@ import ( authoritykeeper "github.com/zeta-chain/zetacore/x/authority/keeper" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + lightclientmodule "github.com/zeta-chain/zetacore/x/lightclient" + lightclientkeeper "github.com/zeta-chain/zetacore/x/lightclient/keeper" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" + crosschainmodule "github.com/zeta-chain/zetacore/x/crosschain" crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -181,6 +185,7 @@ var ( evm.AppModuleBasic{}, feemarket.AppModuleBasic{}, authoritymodule.AppModuleBasic{}, + lightclientmodule.AppModuleBasic{}, crosschainmodule.AppModuleBasic{}, observermodule.AppModuleBasic{}, fungiblemodule.AppModuleBasic{}, @@ -255,11 +260,12 @@ type App struct { FeeMarketKeeper feemarketkeeper.Keeper // zetachain keepers - AuthorityKeeper authoritykeeper.Keeper - CrosschainKeeper crosschainkeeper.Keeper - ObserverKeeper *observerkeeper.Keeper - FungibleKeeper fungiblekeeper.Keeper - EmissionsKeeper emissionskeeper.Keeper + AuthorityKeeper authoritykeeper.Keeper + LightclientKeeper lightclientkeeper.Keeper + CrosschainKeeper crosschainkeeper.Keeper + ObserverKeeper *observerkeeper.Keeper + FungibleKeeper fungiblekeeper.Keeper + EmissionsKeeper emissionskeeper.Keeper } // New returns a reference to an initialized ZetaApp. @@ -295,6 +301,7 @@ func New( evmtypes.StoreKey, feemarkettypes.StoreKey, authoritytypes.StoreKey, + lightclienttypes.StoreKey, crosschaintypes.StoreKey, observertypes.StoreKey, fungibletypes.StoreKey, @@ -364,6 +371,13 @@ func New( authtypes.NewModuleAddress(govtypes.ModuleName), ) + app.LightclientKeeper = lightclientkeeper.NewKeeper( + appCodec, + keys[lightclienttypes.StoreKey], + keys[lightclienttypes.MemStoreKey], + app.AuthorityKeeper, + ) + app.ObserverKeeper = observerkeeper.NewKeeper( appCodec, keys[observertypes.StoreKey], @@ -372,6 +386,7 @@ func New( &stakingKeeper, app.SlashingKeeper, app.AuthorityKeeper, + app.LightclientKeeper, ) // register the staking hooks @@ -436,6 +451,7 @@ func New( app.ObserverKeeper, &app.FungibleKeeper, app.AuthorityKeeper, + app.LightclientKeeper, ) app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper, group.Config{ MaxExecutionPeriod: 2 * time.Hour, // Two hours. @@ -507,6 +523,7 @@ func New( evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs), feemarket.NewAppModule(app.FeeMarketKeeper, feeSs), authoritymodule.NewAppModule(appCodec, app.AuthorityKeeper), + lightclientmodule.NewAppModule(appCodec, app.LightclientKeeper), crosschainmodule.NewAppModule(appCodec, app.CrosschainKeeper), observermodule.NewAppModule(appCodec, *app.ObserverKeeper), fungiblemodule.NewAppModule(appCodec, app.FungibleKeeper), @@ -541,6 +558,7 @@ func New( emissionstypes.ModuleName, authz.ModuleName, authoritytypes.ModuleName, + lightclienttypes.ModuleName, ) app.mm.SetOrderEndBlockers( banktypes.ModuleName, @@ -564,6 +582,7 @@ func New( emissionstypes.ModuleName, authz.ModuleName, authoritytypes.ModuleName, + lightclienttypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -594,6 +613,7 @@ func New( emissionstypes.ModuleName, authz.ModuleName, authoritytypes.ModuleName, + lightclienttypes.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) diff --git a/app/setup_handlers.go b/app/setup_handlers.go index d9119ee8f6..5501a5b6cc 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/upgrade/types" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -29,7 +30,7 @@ func SetupHandlers(app *App) { } if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) { storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{authoritytypes.ModuleName}, + Added: []string{authoritytypes.ModuleName, lightclienttypes.ModuleName}, } // Use upgrade store loader for the initial loading of all stores when app starts, // it checks if version == upgradeHeight and applies store upgrades before loading the stores, diff --git a/changelog.md b/changelog.md index 55b56416dd..3c13ec7bee 100644 --- a/changelog.md +++ b/changelog.md @@ -8,12 +8,21 @@ * The `Policies` query of the `authority` module must be used to get the current admin policies. * `PolicyType_group1` has been renamed into `PolicyType_groupEmergency` and `PolicyType_group2` has been renamed into `PolicyType_groupAdmin`. -* `MsgCreateTSSVoter` message in the `crosschain` module has been moved to the `observer` module and renamed to `MsgVoteTSS`. - * The structure of the message remains the same. +* A new module called `lightclient` has been created for the blocker header and proof functionality to add inbound and outbound trackers in a permissionless manner (currently deactivated on live networks) + * The list of block headers are now stored in the `lightclient` module instead of the `observer` module. + * The message to vote on new block headers is still in the `observer` module but has been renamed to `MsgVoteBlockHeader` instead of `MsgAddBlockHeader`. + * The `GetAllBlockHeaders` query has been moved to the `lightclient` module and renamed to `BlockHeaderAll`. + * The `GetBlockHeaderByHash` query has been moved to the `lightclient` module and renamed to `BlockHeader`. + * The `GetBlockHeaderStateByChain` query has been moved to the `lightclient` module and renamed to `ChainState`. + * The `Prove` query has been moved to the `lightclient` module. + * The `BlockHeaderVerificationFlags` has been deprecated in `CrosschainFlags`, `VerificationFlags` should be used instead. * `MsgGasPriceVoter` message in the `crosschain` module has been renamed to `MsgVoteGasPrice`. * The structure of the message remains the same. +* `MsgCreateTSSVoter` message in the `crosschain` module has been moved to the `observer` module and renamed to `MsgVoteTSS`. + * The structure of the message remains the same. + ### Refactor * [1511](https://github.com/zeta-chain/node/pull/1511) - move ballot voting logic from `crosschain` to `observer` @@ -29,6 +38,8 @@ * [1936](https://github.com/zeta-chain/node/pull/1936) - refactor common package into subpackages and rename to pkg * [1966](https://github.com/zeta-chain/node/pull/1966) - move TSS vote message from crosschain to observer * [1853](https://github.com/zeta-chain/node/pull/1853) - refactor vote inbound tx and vote outbound tx +* [1815](https://github.com/zeta-chain/node/pull/1815) - add authority module for authorized actions +* [1976](https://github.com/zeta-chain/node/pull/1976) - add lightclient module for header and proof functionality * [2001](https://github.com/zeta-chain/node/pull/2001) - replace broadcast mode block with sync and remove fungible params * [1989](https://github.com/zeta-chain/node/pull/1989) - simplify `IsSendOutTxProcessed` method and add unit tests * [2013](https://github.com/zeta-chain/node/pull/2013) - rename `GasPriceVoter` message to `VoteGasPrice` @@ -37,7 +48,6 @@ * [1789](https://github.com/zeta-chain/node/issues/1789) - block cross-chain transactions that involve restricted addresses * [1755](https://github.com/zeta-chain/node/issues/1755) - use evm JSON RPC for inbound tx (including blob tx) observation. -* [1815](https://github.com/zeta-chain/node/pull/1815) - add authority module for authorized actions * [1884](https://github.com/zeta-chain/node/pull/1884) - added zetatool cmd, added subcommand to filter deposits * [1942](https://github.com/zeta-chain/node/pull/1982) - support Bitcoin P2TR, P2WSH, P2SH, P2PKH addresses * [1935](https://github.com/zeta-chain/node/pull/1935) - add an operational authority group diff --git a/cmd/zetae2e/balances.go b/cmd/zetae2e/balances.go index 7924ba88c6..3815613781 100644 --- a/cmd/zetae2e/balances.go +++ b/cmd/zetae2e/balances.go @@ -9,6 +9,7 @@ import ( "github.com/spf13/cobra" "github.com/zeta-chain/zetacore/app" zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" + "github.com/zeta-chain/zetacore/cmd/zetae2e/local" "github.com/zeta-chain/zetacore/e2e/config" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" @@ -69,8 +70,8 @@ func runBalances(cmd *cobra.Command, args []string) error { conf, ethcommon.HexToAddress(evmAddr), conf.Accounts.EVMPrivKey, - utils.FungibleAdminName, // placeholder value, not used - FungibleAdminMnemonic, // placeholder value, not used + utils.FungibleAdminName, // placeholder value, not used + local.FungibleAdminMnemonic, // placeholder value, not used logger, ) if err != nil { diff --git a/cmd/zetae2e/bitcoin_address.go b/cmd/zetae2e/bitcoin_address.go index f4827b850d..77df85d116 100644 --- a/cmd/zetae2e/bitcoin_address.go +++ b/cmd/zetae2e/bitcoin_address.go @@ -9,6 +9,7 @@ import ( "github.com/spf13/cobra" "github.com/zeta-chain/zetacore/app" zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" + "github.com/zeta-chain/zetacore/cmd/zetae2e/local" "github.com/zeta-chain/zetacore/e2e/config" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" @@ -69,8 +70,8 @@ func runBitcoinAddress(cmd *cobra.Command, args []string) error { conf, ethcommon.HexToAddress(evmAddr), conf.Accounts.EVMPrivKey, - utils.FungibleAdminName, // placeholder value, not used - FungibleAdminMnemonic, // placeholder value, not used + utils.FungibleAdminName, // placeholder value, not used + local.FungibleAdminMnemonic, // placeholder value, not used logger, ) if err != nil { diff --git a/cmd/zetae2e/config/clients.go b/cmd/zetae2e/config/clients.go index e5d69ba4fe..bb8bc85dbb 100644 --- a/cmd/zetae2e/config/clients.go +++ b/cmd/zetae2e/config/clients.go @@ -13,6 +13,7 @@ import ( "github.com/zeta-chain/zetacore/e2e/config" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc" ) @@ -27,25 +28,26 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey st authtypes.QueryClient, banktypes.QueryClient, observertypes.QueryClient, + lightclienttypes.QueryClient, *ethclient.Client, *bind.TransactOpts, error, ) { btcRPCClient, err := getBtcClient(conf.RPCs.Bitcoin) if err != nil { - return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get btc client: %w", err) + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get btc client: %w", err) } evmClient, evmAuth, err := getEVMClient(ctx, conf.RPCs.EVM, evmPrivKey) if err != nil { - return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get evm client: %w", err) + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get evm client: %w", err) } - cctxClient, fungibleClient, authClient, bankClient, observerClient, err := getZetaClients(conf.RPCs.ZetaCoreGRPC) + cctxClient, fungibleClient, authClient, bankClient, observerClient, lightclientClient, err := getZetaClients(conf.RPCs.ZetaCoreGRPC) if err != nil { - return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zeta clients: %w", err) + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zeta clients: %w", err) } zevmClient, zevmAuth, err := getEVMClient(ctx, conf.RPCs.Zevm, evmPrivKey) if err != nil { - return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zevm client: %w", err) + return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zevm client: %w", err) } return btcRPCClient, evmClient, @@ -55,6 +57,7 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey st authClient, bankClient, observerClient, + lightclientClient, zevmClient, zevmAuth, nil @@ -114,11 +117,12 @@ func getZetaClients(rpc string) ( authtypes.QueryClient, banktypes.QueryClient, observertypes.QueryClient, + lightclienttypes.QueryClient, error, ) { grpcConn, err := grpc.Dial(rpc, grpc.WithInsecure()) if err != nil { - return nil, nil, nil, nil, nil, err + return nil, nil, nil, nil, nil, nil, err } cctxClient := crosschaintypes.NewQueryClient(grpcConn) @@ -126,6 +130,7 @@ func getZetaClients(rpc string) ( authClient := authtypes.NewQueryClient(grpcConn) bankClient := banktypes.NewQueryClient(grpcConn) observerClient := observertypes.NewQueryClient(grpcConn) + lightclientClient := lightclienttypes.NewQueryClient(grpcConn) - return cctxClient, fungibleClient, authClient, bankClient, observerClient, nil + return cctxClient, fungibleClient, authClient, bankClient, observerClient, lightclientClient, nil } diff --git a/cmd/zetae2e/config/config.go b/cmd/zetae2e/config/config.go index 2b2bdecc38..cc6c64b532 100644 --- a/cmd/zetae2e/config/config.go +++ b/cmd/zetae2e/config/config.go @@ -31,6 +31,7 @@ func RunnerFromConfig( authClient, bankClient, observerClient, + lightClient, zevmClient, zevmAuth, err := getClientsFromConfig(ctx, conf, evmUserPrivKey) @@ -64,6 +65,7 @@ func RunnerFromConfig( authClient, bankClient, observerClient, + lightClient, evmAuth, zevmAuth, btcRPCClient, diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 817c52721c..1d6a664d71 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -188,6 +188,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) { if !skipSetup { logger.Print("⚙️ setting up networks") startTime := time.Now() + + if err := deployerRunner.EnableVerificationFlags(); err != nil { + panic(err) + } + deployerRunner.SetupEVM(contractsDeployed, true) deployerRunner.SetZEVMContracts() diff --git a/cmd/zetae2e/run.go b/cmd/zetae2e/run.go index 77bdf29141..da0494919f 100644 --- a/cmd/zetae2e/run.go +++ b/cmd/zetae2e/run.go @@ -11,6 +11,7 @@ import ( "github.com/spf13/cobra" "github.com/zeta-chain/zetacore/app" zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" + "github.com/zeta-chain/zetacore/cmd/zetae2e/local" "github.com/zeta-chain/zetacore/e2e/config" "github.com/zeta-chain/zetacore/e2e/e2etests" "github.com/zeta-chain/zetacore/e2e/runner" @@ -20,8 +21,6 @@ import ( const flagVerbose = "verbose" const flagConfig = "config" -const FungibleAdminMnemonic = "snow grace federal cupboard arrive fancy gym lady uniform rotate exercise either leave alien grass" // #nosec G101 - used for testing - // NewRunCmd returns the run command // which runs the E2E from a config file describing the tests, networks, and accounts func NewRunCmd() *cobra.Command { @@ -93,8 +92,8 @@ func runE2ETest(cmd *cobra.Command, args []string) error { conf, ethcommon.HexToAddress(evmAddr), conf.Accounts.EVMPrivKey, - utils.FungibleAdminName, // placeholder value, not used - FungibleAdminMnemonic, // placeholder value, not used + utils.FungibleAdminName, // placeholder value, not used + local.FungibleAdminMnemonic, // placeholder value, not used logger, ) if err != nil { diff --git a/cmd/zetae2e/setup_bitcoin.go b/cmd/zetae2e/setup_bitcoin.go index 4de6b0685d..15e9877164 100644 --- a/cmd/zetae2e/setup_bitcoin.go +++ b/cmd/zetae2e/setup_bitcoin.go @@ -9,6 +9,7 @@ import ( "github.com/spf13/cobra" "github.com/zeta-chain/zetacore/app" zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" + "github.com/zeta-chain/zetacore/cmd/zetae2e/local" "github.com/zeta-chain/zetacore/e2e/config" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" @@ -56,8 +57,8 @@ func runSetupBitcoin(_ *cobra.Command, args []string) error { conf, ethcommon.HexToAddress(evmAddr), conf.Accounts.EVMPrivKey, - utils.FungibleAdminName, // placeholder value, not used - FungibleAdminMnemonic, // placeholder value, not used + utils.FungibleAdminName, // placeholder value, not used + local.FungibleAdminMnemonic, // placeholder value, not used logger, ) if err != nil { diff --git a/cmd/zetae2e/show_tss.go b/cmd/zetae2e/show_tss.go index 79facdf4c5..1d610eb150 100644 --- a/cmd/zetae2e/show_tss.go +++ b/cmd/zetae2e/show_tss.go @@ -4,15 +4,15 @@ import ( "context" "errors" - "github.com/zeta-chain/zetacore/e2e/config" - "github.com/zeta-chain/zetacore/e2e/runner" - "github.com/zeta-chain/zetacore/e2e/utils" - ethcommon "github.com/ethereum/go-ethereum/common" "github.com/fatih/color" "github.com/spf13/cobra" "github.com/zeta-chain/zetacore/app" zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config" + "github.com/zeta-chain/zetacore/cmd/zetae2e/local" + "github.com/zeta-chain/zetacore/e2e/config" + "github.com/zeta-chain/zetacore/e2e/runner" + "github.com/zeta-chain/zetacore/e2e/utils" ) // NewShowTSSCmd returns the show TSS command @@ -58,8 +58,8 @@ func runShowTSS(_ *cobra.Command, args []string) error { conf, ethcommon.HexToAddress(evmAddr), conf.Accounts.EVMPrivKey, - utils.FungibleAdminName, // placeholder value, not used - FungibleAdminMnemonic, // placeholder value, not used + utils.FungibleAdminName, // placeholder value, not used + local.FungibleAdminMnemonic, // placeholder value, not used logger, ) if err != nil { diff --git a/cmd/zetae2e/stress.go b/cmd/zetae2e/stress.go index 793b9ec3c4..5228905074 100644 --- a/cmd/zetae2e/stress.go +++ b/cmd/zetae2e/stress.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "math/big" "os" "sort" @@ -143,7 +142,7 @@ func StressTest(cmd *cobra.Command, _ []string) { local.DeployerAddress, local.DeployerPrivateKey, utils.FungibleAdminName, - FungibleAdminMnemonic, + local.FungibleAdminMnemonic, logger, ) if err != nil { diff --git a/docs/cli/zetacored/zetacored_query.md b/docs/cli/zetacored/zetacored_query.md index cb6eb60fde..2e390d1fa0 100644 --- a/docs/cli/zetacored/zetacored_query.md +++ b/docs/cli/zetacored/zetacored_query.md @@ -40,6 +40,7 @@ zetacored query [flags] * [zetacored query fungible](zetacored_query_fungible.md) - Querying commands for the fungible module * [zetacored query gov](zetacored_query_gov.md) - Querying commands for the governance module * [zetacored query group](zetacored_query_group.md) - Querying commands for the group module +* [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module * [zetacored query observer](zetacored_query_observer.md) - Querying commands for the observer module * [zetacored query params](zetacored_query_params.md) - Querying commands for the params module * [zetacored query slashing](zetacored_query_slashing.md) - Querying commands for the slashing module diff --git a/docs/cli/zetacored/zetacored_query_lightclient.md b/docs/cli/zetacored/zetacored_query_lightclient.md new file mode 100644 index 0000000000..a576a4e71b --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_lightclient.md @@ -0,0 +1,33 @@ +# query lightclient + +Querying commands for the lightclient module + +``` +zetacored query lightclient [flags] +``` + +### Options + +``` + -h, --help help for lightclient +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query](zetacored_query.md) - Querying subcommands +* [zetacored query lightclient list-block-header](zetacored_query_lightclient_list-block-header.md) - List all the block headers +* [zetacored query lightclient list-chain-state](zetacored_query_lightclient_list-chain-state.md) - List all the chain states +* [zetacored query lightclient show-block-header](zetacored_query_lightclient_show-block-header.md) - Show a block header from its hash +* [zetacored query lightclient show-chain-state](zetacored_query_lightclient_show-chain-state.md) - Show a chain state from its chain id +* [zetacored query lightclient show-verification-flags](zetacored_query_lightclient_show-verification-flags.md) - Show the verification flags + diff --git a/docs/cli/zetacored/zetacored_query_lightclient_list-block-header.md b/docs/cli/zetacored/zetacored_query_lightclient_list-block-header.md new file mode 100644 index 0000000000..ade0e06c62 --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_lightclient_list-block-header.md @@ -0,0 +1,33 @@ +# query lightclient list-block-header + +List all the block headers + +``` +zetacored query lightclient list-block-header [flags] +``` + +### Options + +``` + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) + -h, --help help for list-block-header + --node string [host]:[port] to Tendermint RPC interface for this chain + -o, --output string Output format (text|json) +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module + diff --git a/docs/cli/zetacored/zetacored_query_lightclient_list-chain-state.md b/docs/cli/zetacored/zetacored_query_lightclient_list-chain-state.md new file mode 100644 index 0000000000..eead2bf7a0 --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_lightclient_list-chain-state.md @@ -0,0 +1,33 @@ +# query lightclient list-chain-state + +List all the chain states + +``` +zetacored query lightclient list-chain-state [flags] +``` + +### Options + +``` + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) + -h, --help help for list-chain-state + --node string [host]:[port] to Tendermint RPC interface for this chain + -o, --output string Output format (text|json) +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module + diff --git a/docs/cli/zetacored/zetacored_query_lightclient_show-block-header.md b/docs/cli/zetacored/zetacored_query_lightclient_show-block-header.md new file mode 100644 index 0000000000..10d89a7794 --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_lightclient_show-block-header.md @@ -0,0 +1,33 @@ +# query lightclient show-block-header + +Show a block header from its hash + +``` +zetacored query lightclient show-block-header [block-hash] [flags] +``` + +### Options + +``` + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) + -h, --help help for show-block-header + --node string [host]:[port] to Tendermint RPC interface for this chain + -o, --output string Output format (text|json) +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module + diff --git a/docs/cli/zetacored/zetacored_query_lightclient_show-chain-state.md b/docs/cli/zetacored/zetacored_query_lightclient_show-chain-state.md new file mode 100644 index 0000000000..7647726bb9 --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_lightclient_show-chain-state.md @@ -0,0 +1,33 @@ +# query lightclient show-chain-state + +Show a chain state from its chain id + +``` +zetacored query lightclient show-chain-state [chain-id] [flags] +``` + +### Options + +``` + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) + -h, --help help for show-chain-state + --node string [host]:[port] to Tendermint RPC interface for this chain + -o, --output string Output format (text|json) +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module + diff --git a/docs/cli/zetacored/zetacored_query_lightclient_show-verification-flags.md b/docs/cli/zetacored/zetacored_query_lightclient_show-verification-flags.md new file mode 100644 index 0000000000..d8e8d97527 --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_lightclient_show-verification-flags.md @@ -0,0 +1,33 @@ +# query lightclient show-verification-flags + +Show the verification flags + +``` +zetacored query lightclient show-verification-flags [flags] +``` + +### Options + +``` + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) + -h, --help help for show-verification-flags + --node string [host]:[port] to Tendermint RPC interface for this chain + -o, --output string Output format (text|json) +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module + diff --git a/docs/cli/zetacored/zetacored_tx.md b/docs/cli/zetacored/zetacored_tx.md index d0c41e4937..dc2801a1f6 100644 --- a/docs/cli/zetacored/zetacored_tx.md +++ b/docs/cli/zetacored/zetacored_tx.md @@ -40,6 +40,7 @@ zetacored tx [flags] * [zetacored tx fungible](zetacored_tx_fungible.md) - fungible transactions subcommands * [zetacored tx gov](zetacored_tx_gov.md) - Governance transactions subcommands * [zetacored tx group](zetacored_tx_group.md) - Group transaction subcommands +* [zetacored tx lightclient](zetacored_tx_lightclient.md) - lightclient transactions subcommands * [zetacored tx multi-sign](zetacored_tx_multi-sign.md) - Generate multisig signatures for transactions generated offline * [zetacored tx multisign-batch](zetacored_tx_multisign-batch.md) - Assemble multisig transactions in batch from batch signatures * [zetacored tx observer](zetacored_tx_observer.md) - observer transactions subcommands diff --git a/docs/cli/zetacored/zetacored_tx_lightclient.md b/docs/cli/zetacored/zetacored_tx_lightclient.md new file mode 100644 index 0000000000..3bdada0122 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_lightclient.md @@ -0,0 +1,29 @@ +# tx lightclient + +lightclient transactions subcommands + +``` +zetacored tx lightclient [flags] +``` + +### Options + +``` + -h, --help help for lightclient +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx](zetacored_tx.md) - Transactions subcommands +* [zetacored tx lightclient update-verification-flags](zetacored_tx_lightclient_update-verification-flags.md) - Update verification flags + diff --git a/docs/cli/zetacored/zetacored_tx_lightclient_update-verification-flags.md b/docs/cli/zetacored/zetacored_tx_lightclient_update-verification-flags.md new file mode 100644 index 0000000000..08222afc69 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_lightclient_update-verification-flags.md @@ -0,0 +1,52 @@ +# tx lightclient update-verification-flags + +Update verification flags + +``` +zetacored tx lightclient update-verification-flags [eth-type-chain-enabled] [btc-type-chain-enabled] [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|block) + --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 update-verification-flags + --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 + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx lightclient](zetacored_tx_lightclient.md) - lightclient transactions subcommands + diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index c250c89f37..a35e40ae93 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -27416,6 +27416,240 @@ paths: $ref: '#/definitions/googlerpcStatus' tags: - Query + /zeta-chain/lightclient/block_headers: + get: + operationId: Query_BlockHeaderAll + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/lightclientQueryAllBlockHeaderResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: |- + offset is a numeric offset that can be used when key is unavailable. + It is less efficient than using key. Only one of offset or key should + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: |- + limit is the total number of results to be returned in the result page. + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: |- + count_total is set to true to indicate that the result set should include + a count of the total number of items available for pagination in UIs. + count_total is only respected when offset is used. It is ignored when key + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: |- + reverse is set to true if results are to be returned in the descending order. + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /zeta-chain/lightclient/block_headers/{block_hash}: + get: + operationId: Query_BlockHeader + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/lightclientQueryGetBlockHeaderResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: block_hash + in: path + required: true + type: string + format: byte + tags: + - Query + /zeta-chain/lightclient/chain_state: + get: + operationId: Query_ChainStateAll + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/lightclientQueryAllChainStateResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: |- + offset is a numeric offset that can be used when key is unavailable. + It is less efficient than using key. Only one of offset or key should + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: |- + limit is the total number of results to be returned in the result page. + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: |- + count_total is set to true to indicate that the result set should include + a count of the total number of items available for pagination in UIs. + count_total is only respected when offset is used. It is ignored when key + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: |- + reverse is set to true if results are to be returned in the descending order. + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /zeta-chain/lightclient/chain_state/{chain_id}: + get: + operationId: Query_ChainState + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/lightclientQueryGetChainStateResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: chain_id + in: path + required: true + type: string + format: int64 + tags: + - Query + /zeta-chain/lightclient/prove: + get: + operationId: Query_Prove + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/lightclientQueryProveResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: chain_id + in: query + required: false + type: string + format: int64 + - name: tx_hash + in: query + required: false + type: string + - name: proof.ethereum_proof.keys + in: query + required: false + type: array + items: + type: string + format: byte + collectionFormat: multi + - name: proof.ethereum_proof.values + in: query + required: false + type: array + items: + type: string + format: byte + collectionFormat: multi + - name: proof.bitcoin_proof.tx_bytes + in: query + required: false + type: string + format: byte + - name: proof.bitcoin_proof.path + in: query + required: false + type: string + format: byte + - name: proof.bitcoin_proof.index + in: query + required: false + type: integer + format: int64 + - name: block_hash + in: query + required: false + type: string + - name: tx_index + in: query + required: false + type: string + format: int64 + tags: + - Query + /zeta-chain/lightclient/verification_flags: + get: + operationId: Query_VerificationFlags + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/lightclientQueryVerificationFlagsResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + tags: + - Query /zeta-chain/observer/TSS: get: summary: Queries a tSS by index. @@ -27649,104 +27883,6 @@ paths: type: boolean tags: - Query - /zeta-chain/observer/get_all_block_headers: - get: - operationId: Query_GetAllBlockHeaders - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/observerQueryAllBlockHeaderResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - parameters: - - name: pagination.key - description: |- - key is a value returned in PageResponse.next_key to begin - querying the next page most efficiently. Only one of offset or key - should be set. - in: query - required: false - type: string - format: byte - - name: pagination.offset - description: |- - offset is a numeric offset that can be used when key is unavailable. - It is less efficient than using key. Only one of offset or key should - be set. - in: query - required: false - type: string - format: uint64 - - name: pagination.limit - description: |- - limit is the total number of results to be returned in the result page. - If left empty it will default to a value to be set by each app. - in: query - required: false - type: string - format: uint64 - - name: pagination.count_total - description: |- - count_total is set to true to indicate that the result set should include - a count of the total number of items available for pagination in UIs. - count_total is only respected when offset is used. It is ignored when key - is set. - in: query - required: false - type: boolean - - name: pagination.reverse - description: |- - reverse is set to true if results are to be returned in the descending order. - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean - tags: - - Query - /zeta-chain/observer/get_block_header_by_hash/{block_hash}: - get: - operationId: Query_GetBlockHeaderByHash - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/observerQueryGetBlockHeaderByHashResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - parameters: - - name: block_hash - in: path - required: true - type: string - format: byte - tags: - - Query - /zeta-chain/observer/get_block_header_state_by_chain_id/{chain_id}: - get: - operationId: Query_GetBlockHeaderStateByChain - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/observerQueryGetBlockHeaderStateResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - parameters: - - name: chain_id - in: path - required: true - type: string - format: int64 - tags: - - Query /zeta-chain/observer/get_chain_params: get: summary: Queries a list of GetChainParams items. @@ -28055,71 +28191,6 @@ paths: format: int64 tags: - Query - /zeta-chain/observer/prove: - get: - summary: merkle proof verification - operationId: Query_Prove - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/observerQueryProveResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - parameters: - - name: chain_id - in: query - required: false - type: string - format: int64 - - name: tx_hash - in: query - required: false - type: string - - name: proof.ethereum_proof.keys - in: query - required: false - type: array - items: - type: string - format: byte - collectionFormat: multi - - name: proof.ethereum_proof.values - in: query - required: false - type: array - items: - type: string - format: byte - collectionFormat: multi - - name: proof.bitcoin_proof.tx_bytes - in: query - required: false - type: string - format: byte - - name: proof.bitcoin_proof.path - in: query - required: false - type: string - format: byte - - name: proof.bitcoin_proof.index - in: query - required: false - type: integer - format: int64 - - name: block_hash - in: query - required: false - type: string - - name: tx_index - in: query - required: false - type: string - format: int64 - tags: - - Query /zeta-chain/observer/supportedChains: get: operationId: Query_SupportedChains @@ -54091,6 +54162,72 @@ definitions: items: type: object $ref: '#/definitions/protobufAny' + lightclientChainState: + type: object + properties: + chain_id: + type: string + format: int64 + latest_height: + type: string + format: int64 + earliest_height: + type: string + format: int64 + latest_block_hash: + type: string + format: byte + title: ChainState defines the overall state of the block headers for a given chain + lightclientMsgUpdateVerificationFlagsResponse: + type: object + lightclientQueryAllBlockHeaderResponse: + type: object + properties: + block_headers: + type: array + items: + type: object + $ref: '#/definitions/proofsBlockHeader' + pagination: + $ref: '#/definitions/v1beta1PageResponse' + lightclientQueryAllChainStateResponse: + type: object + properties: + chain_state: + type: array + items: + type: object + $ref: '#/definitions/lightclientChainState' + pagination: + $ref: '#/definitions/v1beta1PageResponse' + lightclientQueryGetBlockHeaderResponse: + type: object + properties: + block_header: + $ref: '#/definitions/proofsBlockHeader' + lightclientQueryGetChainStateResponse: + type: object + properties: + chain_state: + $ref: '#/definitions/lightclientChainState' + lightclientQueryProveResponse: + type: object + properties: + valid: + type: boolean + lightclientQueryVerificationFlagsResponse: + type: object + properties: + verification_flags: + $ref: '#/definitions/lightclientVerificationFlags' + lightclientVerificationFlags: + type: object + properties: + ethTypeChainEnabled: + type: boolean + btcTypeChainEnabled: + type: boolean + title: VerificationFlags is a structure containing information which chain types are enabled for block header verification observerAdmin_Policy: type: object properties: @@ -54118,21 +54255,6 @@ definitions: items: type: object $ref: '#/definitions/observerNode' - observerBlockHeaderState: - type: object - properties: - chain_id: - type: string - format: int64 - latest_height: - type: string - format: int64 - earliest_height: - type: string - format: int64 - latest_block_hash: - type: string - format: byte observerBlockHeaderVerificationFlags: type: object properties: @@ -54140,6 +54262,7 @@ definitions: type: boolean isBtcTypeChainEnabled: type: boolean + title: 'Deprecated(v16): Use VerificationFlags in the lightclient module instead' observerChainNonces: type: object properties: @@ -54218,6 +54341,7 @@ definitions: $ref: '#/definitions/observerGasPriceIncreaseFlags' blockHeaderVerificationFlags: $ref: '#/definitions/observerBlockHeaderVerificationFlags' + title: 'Deprecated(v16): Use VerificationFlags in the lightclient module instead' observerGasPriceIncreaseFlags: type: object properties: @@ -54271,8 +54395,6 @@ definitions: format: int64 observerMsgAddBlameVoteResponse: type: object - observerMsgAddBlockHeaderResponse: - type: object observerMsgAddObserverResponse: type: object observerMsgRemoveChainParamsResponse: @@ -54287,6 +54409,13 @@ definitions: type: object observerMsgUpdateObserverResponse: type: object + observerMsgVoteBlockHeaderResponse: + type: object + properties: + ballot_created: + type: boolean + vote_finalized: + type: boolean observerMsgVoteTSSResponse: type: object properties: @@ -54388,16 +54517,6 @@ definitions: $ref: '#/definitions/observerBlame' pagination: $ref: '#/definitions/v1beta1PageResponse' - observerQueryAllBlockHeaderResponse: - type: object - properties: - block_headers: - type: array - items: - type: object - $ref: '#/definitions/proofsBlockHeader' - pagination: - $ref: '#/definitions/v1beta1PageResponse' observerQueryAllChainNoncesResponse: type: object properties: @@ -54455,16 +54574,6 @@ definitions: properties: blame_info: $ref: '#/definitions/observerBlame' - observerQueryGetBlockHeaderByHashResponse: - type: object - properties: - block_header: - $ref: '#/definitions/proofsBlockHeader' - observerQueryGetBlockHeaderStateResponse: - type: object - properties: - block_header_state: - $ref: '#/definitions/observerBlockHeaderState' observerQueryGetChainNoncesResponse: type: object properties: @@ -54531,11 +54640,6 @@ definitions: properties: pending_nonces: $ref: '#/definitions/observerPendingNonces' - observerQueryProveResponse: - type: object - properties: - valid: - type: boolean observerQueryShowObserverCountResponse: type: object properties: diff --git a/docs/spec/crosschain/messages.md b/docs/spec/crosschain/messages.md index 0a57b8e883..068c8c8597 100644 --- a/docs/spec/crosschain/messages.md +++ b/docs/spec/crosschain/messages.md @@ -6,8 +6,6 @@ AddToOutTxTracker adds a new record to the outbound transaction tracker. only the admin policy account and the observer validators are authorized to broadcast this message without proof. If no pending cctx is found, the tracker is removed, if there is an existed tracker with the nonce & chainID. -Authorized: admin policy group 1, observer. - ```proto message MsgAddToOutTxTracker { string creator = 1; @@ -24,8 +22,6 @@ message MsgAddToOutTxTracker { AddToInTxTracker adds a new record to the inbound transaction tracker. -Authorized: admin policy group 1, observer. - ```proto message MsgAddToInTxTracker { string creator = 1; diff --git a/docs/spec/lightclient/messages.md b/docs/spec/lightclient/messages.md new file mode 100644 index 0000000000..057d90f3b6 --- /dev/null +++ b/docs/spec/lightclient/messages.md @@ -0,0 +1,15 @@ +# Messages + +## MsgUpdateVerificationFlags + +UpdateVerificationFlags updates the light client verification flags. +This disables/enables blocks verification of the light client for the specified chain. +Emergency group can disable flags, it requires operational group if at least one flag is being enabled + +```proto +message MsgUpdateVerificationFlags { + string creator = 1; + VerificationFlags verification_flags = 2; +} +``` + diff --git a/docs/spec/observer/messages.md b/docs/spec/observer/messages.md index a73d3a6134..3d51929aa2 100644 --- a/docs/spec/observer/messages.md +++ b/docs/spec/observer/messages.md @@ -94,12 +94,12 @@ message MsgUpdateKeygen { } ``` -## MsgAddBlockHeader +## MsgVoteBlockHeader -AddBlockHeader handles adding a block header to the store, through majority voting of observers +VoteBlockHeader vote for a new block header to the storers ```proto -message MsgAddBlockHeader { +message MsgVoteBlockHeader { string creator = 1; int64 chain_id = 2; bytes block_hash = 3; diff --git a/e2e/e2etests/test_migrate_chain_support.go b/e2e/e2etests/test_migrate_chain_support.go index ae1acdde93..75bdb29d0e 100644 --- a/e2e/e2etests/test_migrate_chain_support.go +++ b/e2e/e2etests/test_migrate_chain_support.go @@ -230,6 +230,7 @@ func configureEVM2(r *runner.E2ERunner) (*runner.E2ERunner, error) { r.AuthClient, r.BankClient, r.ObserverClient, + r.LightclientClient, r.EVMAuth, r.ZEVMAuth, r.BtcRPCClient, diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 6462b2f1db..4bb8d5e46c 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -21,7 +21,7 @@ import ( "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/pkg/proofs/bitcoin" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" - observertypes "github.com/zeta-chain/zetacore/x/observer/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" zetabitcoin "github.com/zeta-chain/zetacore/zetaclient/bitcoin" ) @@ -379,7 +379,7 @@ func (runner *E2ERunner) ProveBTCTransaction(txHash *chainhash.Hash) { panic("timed out waiting for block header to show up in observer") } - _, err := runner.ObserverClient.GetBlockHeaderByHash(runner.Ctx, &observertypes.QueryGetBlockHeaderByHashRequest{ + _, err := runner.LightclientClient.BlockHeader(runner.Ctx, &lightclienttypes.QueryGetBlockHeaderRequest{ BlockHash: hash.CloneBytes(), }) if err != nil { @@ -392,7 +392,7 @@ func (runner *E2ERunner) ProveBTCTransaction(txHash *chainhash.Hash) { } // verify merkle proof through RPC - res, err := runner.ObserverClient.Prove(runner.Ctx, &observertypes.QueryProveRequest{ + res, err := runner.LightclientClient.Prove(runner.Ctx, &lightclienttypes.QueryProveRequest{ ChainId: chains.BtcRegtestChain().ChainId, TxHash: txHash.String(), BlockHash: blockHash.String(), diff --git a/e2e/runner/evm.go b/e2e/runner/evm.go index c0253905cc..0bc6d77070 100644 --- a/e2e/runner/evm.go +++ b/e2e/runner/evm.go @@ -5,16 +5,15 @@ import ( "math/big" "time" - "github.com/ethereum/go-ethereum/rpc" - ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/rpc" "github.com/zeta-chain/zetacore/e2e/utils" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/pkg/proofs/ethereum" - observertypes "github.com/zeta-chain/zetacore/x/observer/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" ) var blockHeaderETHTimeout = 5 * time.Minute @@ -214,7 +213,7 @@ func (runner *E2ERunner) ProveEthTransaction(receipt *ethtypes.Receipt) { panic("timeout waiting for block header") } - _, err := runner.ObserverClient.GetBlockHeaderByHash(runner.Ctx, &observertypes.QueryGetBlockHeaderByHashRequest{ + _, err := runner.LightclientClient.BlockHeader(runner.Ctx, &lightclienttypes.QueryGetBlockHeaderRequest{ BlockHash: blockHash.Bytes(), }) if err != nil { @@ -244,7 +243,7 @@ func (runner *E2ERunner) ProveEthTransaction(receipt *ethtypes.Receipt) { if err != nil { panic("error unmarshalling txProof'd tx") } - res, err := runner.ObserverClient.Prove(runner.Ctx, &observertypes.QueryProveRequest{ + res, err := runner.LightclientClient.Prove(runner.Ctx, &lightclienttypes.QueryProveRequest{ BlockHash: blockHash.Hex(), TxIndex: int64(txIndex), TxHash: txHash.Hex(), diff --git a/e2e/runner/runner.go b/e2e/runner/runner.go index f66af62ff0..d45b542c97 100644 --- a/e2e/runner/runner.go +++ b/e2e/runner/runner.go @@ -28,6 +28,7 @@ import ( "github.com/zeta-chain/zetacore/e2e/txserver" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -49,11 +50,12 @@ type E2ERunner struct { BtcRPCClient *rpcclient.Client // grpc clients - CctxClient crosschaintypes.QueryClient - FungibleClient fungibletypes.QueryClient - AuthClient authtypes.QueryClient - BankClient banktypes.QueryClient - ObserverClient observertypes.QueryClient + CctxClient crosschaintypes.QueryClient + FungibleClient fungibletypes.QueryClient + AuthClient authtypes.QueryClient + BankClient banktypes.QueryClient + ObserverClient observertypes.QueryClient + LightclientClient lightclienttypes.QueryClient // zeta client ZetaTxServer txserver.ZetaTxServer @@ -124,6 +126,7 @@ func NewE2ERunner( authClient authtypes.QueryClient, bankClient banktypes.QueryClient, observerClient observertypes.QueryClient, + lightclientClient lightclienttypes.QueryClient, evmAuth *bind.TransactOpts, zevmAuth *bind.TransactOpts, btcRPCClient *rpcclient.Client, @@ -138,14 +141,15 @@ func NewE2ERunner( DeployerPrivateKey: deployerPrivateKey, FungibleAdminMnemonic: fungibleAdminMnemonic, - ZEVMClient: zevmClient, - EVMClient: evmClient, - ZetaTxServer: zetaTxServer, - CctxClient: cctxClient, - FungibleClient: fungibleClient, - AuthClient: authClient, - BankClient: bankClient, - ObserverClient: observerClient, + ZEVMClient: zevmClient, + EVMClient: evmClient, + ZetaTxServer: zetaTxServer, + CctxClient: cctxClient, + FungibleClient: fungibleClient, + AuthClient: authClient, + BankClient: bankClient, + ObserverClient: observerClient, + LightclientClient: lightclientClient, EVMAuth: evmAuth, ZEVMAuth: zevmAuth, diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 3789babf06..0de4693210 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -204,6 +204,13 @@ func (runner *E2ERunner) SetupBTCZRC20() { runner.BTCZRC20 = BTCZRC20 } +// EnableVerificationFlags enables the verification flags on ZetaChain +func (runner *E2ERunner) EnableVerificationFlags() error { + runner.Logger.Print("⚙️ enabling verification flags for block headers") + + return runner.ZetaTxServer.EnableVerificationFlags(e2eutils.FungibleAdminName) +} + // FundEmissionsPool funds the emissions pool on ZetaChain with the same value as used originally on mainnet (20M ZETA) func (runner *E2ERunner) FundEmissionsPool() error { runner.Logger.Print("⚙️ funding the emissions pool on ZetaChain with 20M ZETA (%s)", txserver.EmissionsPoolAddress) diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 7c8b53038b..d6d804c81e 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -39,9 +39,11 @@ import ( "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -222,10 +224,7 @@ func broadcastWithBlockTimeout(zts ZetaTxServer, txBytes []byte) (*sdktypes.TxRe case <-time.After(time.Millisecond * 100): resTx, err := zts.clientCtx.Client.Tx(context.TODO(), hash, false) if err == nil { - txRes, err := mkTxResult(zts.clientCtx, resTx) - if err == nil { - return txRes, nil - } + return mkTxResult(zts.clientCtx, resTx) } } } @@ -251,6 +250,27 @@ type intoAny interface { AsAny() *codectypes.Any } +// EnableVerificationFlags enables the verification flags for the lightclient module +func (zts ZetaTxServer) EnableVerificationFlags(account string) error { + // retrieve account + acc, err := zts.clientCtx.Keyring.Key(account) + if err != nil { + return err + } + addr, err := acc.GetAddress() + if err != nil { + return err + } + + _, err = zts.BroadcastTx(account, lightclienttypes.NewMsgUpdateVerificationFlags( + addr.String(), + true, + true, + )) + + return err +} + // DeploySystemContractsAndZRC20 deploys the system contracts and ZRC20 contracts // returns the addresses of uniswap factory, router and erc20 zrc20 func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string) (string, string, string, string, string, error) { @@ -411,6 +431,8 @@ func newCodec() (*codec.ProtoCodec, codectypes.InterfaceRegistry) { emissionstypes.RegisterInterfaces(interfaceRegistry) fungibletypes.RegisterInterfaces(interfaceRegistry) observertypes.RegisterInterfaces(interfaceRegistry) + lightclienttypes.RegisterInterfaces(interfaceRegistry) + authoritytypes.RegisterInterfaces(interfaceRegistry) return cdc, interfaceRegistry } diff --git a/pkg/testdata/testdata.go b/pkg/testdata/testdata.go index 5fd1a06b21..6b3bcd3235 100644 --- a/pkg/testdata/testdata.go +++ b/pkg/testdata/testdata.go @@ -23,7 +23,7 @@ var ethFiles embed.FS //go:embed * var testDataFiles embed.FS -// readHeader reads a header from a file. +// ReadEthHeader reads a header from a file. // TODO: centralize test data // https://github.com/zeta-chain/node/issues/1874 func ReadEthHeader() (header types.Header, err error) { @@ -38,7 +38,7 @@ func ReadEthHeader() (header types.Header, err error) { return header, err } -// readReceipt reads a receipt from a file. +// ReadEthReceipt reads a receipt from a file. // TODO: centralize test data // https://github.com/zeta-chain/node/issues/1874 func ReadEthReceipt(index int) (receipt types.Receipt, err error) { @@ -55,7 +55,7 @@ func ReadEthReceipt(index int) (receipt types.Receipt, err error) { return receipt, err } -// readTx reads a tx from a file. +// ReadEthTx reads a tx from a file. // TODO: centralize test data // https://github.com/zeta-chain/node/issues/1874 func ReadEthTx(index int) (tx types.Transaction, err error) { @@ -85,6 +85,7 @@ type Blocks struct { Blocks []Block `json:"blocks"` } +// LoadTestBlocks loads test blocks from a file. // TODO: centralize test data // https://github.com/zeta-chain/node/issues/1874 func LoadTestBlocks(t *testing.T) Blocks { diff --git a/proto/lightclient/chain_state.proto b/proto/lightclient/chain_state.proto new file mode 100644 index 0000000000..9d27e399b7 --- /dev/null +++ b/proto/lightclient/chain_state.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package zetachain.zetacore.lightclient; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; + +// ChainState defines the overall state of the block headers for a given chain +message ChainState { + int64 chain_id = 1; + int64 latest_height = 2; + int64 earliest_height = 3; + bytes latest_block_hash = 4; +} diff --git a/proto/lightclient/genesis.proto b/proto/lightclient/genesis.proto new file mode 100644 index 0000000000..3706da09dc --- /dev/null +++ b/proto/lightclient/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package zetachain.zetacore.lightclient; + +import "gogoproto/gogo.proto"; +import "lightclient/chain_state.proto"; +import "lightclient/verification_flags.proto"; +import "pkg/proofs/proofs.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; + +// GenesisState defines the lightclient module's genesis state. +message GenesisState { + repeated proofs.BlockHeader block_headers = 1 [(gogoproto.nullable) = false]; + repeated ChainState chain_states = 2 [(gogoproto.nullable) = false]; + VerificationFlags verification_flags = 3 [(gogoproto.nullable) = false]; +} diff --git a/proto/lightclient/query.proto b/proto/lightclient/query.proto new file mode 100644 index 0000000000..7433093b04 --- /dev/null +++ b/proto/lightclient/query.proto @@ -0,0 +1,90 @@ +syntax = "proto3"; +package zetachain.zetacore.lightclient; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "lightclient/chain_state.proto"; +import "lightclient/verification_flags.proto"; +import "pkg/proofs/proofs.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; + +// Query defines the gRPC querier service. +service Query { + rpc BlockHeaderAll(QueryAllBlockHeaderRequest) returns (QueryAllBlockHeaderResponse) { + option (google.api.http).get = "/zeta-chain/lightclient/block_headers"; + } + + rpc BlockHeader(QueryGetBlockHeaderRequest) returns (QueryGetBlockHeaderResponse) { + option (google.api.http).get = "/zeta-chain/lightclient/block_headers/{block_hash}"; + } + + rpc ChainStateAll(QueryAllChainStateRequest) returns (QueryAllChainStateResponse) { + option (google.api.http).get = "/zeta-chain/lightclient/chain_state"; + } + + rpc ChainState(QueryGetChainStateRequest) returns (QueryGetChainStateResponse) { + option (google.api.http).get = "/zeta-chain/lightclient/chain_state/{chain_id}"; + } + + rpc Prove(QueryProveRequest) returns (QueryProveResponse) { + option (google.api.http).get = "/zeta-chain/lightclient/prove"; + } + + rpc VerificationFlags(QueryVerificationFlagsRequest) returns (QueryVerificationFlagsResponse) { + option (google.api.http).get = "/zeta-chain/lightclient/verification_flags"; + } +} + +message QueryAllBlockHeaderRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllBlockHeaderResponse { + repeated proofs.BlockHeader block_headers = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryGetBlockHeaderRequest { + bytes block_hash = 1; +} + +message QueryGetBlockHeaderResponse { + proofs.BlockHeader block_header = 1; +} + +message QueryAllChainStateRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllChainStateResponse { + repeated ChainState chain_state = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryGetChainStateRequest { + int64 chain_id = 1; +} + +message QueryGetChainStateResponse { + ChainState chain_state = 1; +} + +message QueryProveRequest { + int64 chain_id = 1; + string tx_hash = 2; + proofs.Proof proof = 3; + string block_hash = 4; + int64 tx_index = 5; +} + +message QueryProveResponse { + bool valid = 1; +} + +message QueryVerificationFlagsRequest {} + +message QueryVerificationFlagsResponse { + VerificationFlags verification_flags = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/lightclient/tx.proto b/proto/lightclient/tx.proto new file mode 100644 index 0000000000..fcaad913c6 --- /dev/null +++ b/proto/lightclient/tx.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package zetachain.zetacore.lightclient; + +import "gogoproto/gogo.proto"; +import "lightclient/verification_flags.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; + +// Msg defines the Msg service. +service Msg { + rpc UpdateVerificationFlags(MsgUpdateVerificationFlags) returns (MsgUpdateVerificationFlagsResponse); +} + +message MsgUpdateVerificationFlags { + string creator = 1; + VerificationFlags verification_flags = 2 [(gogoproto.nullable) = false]; +} + +message MsgUpdateVerificationFlagsResponse {} diff --git a/proto/lightclient/verification_flags.proto b/proto/lightclient/verification_flags.proto new file mode 100644 index 0000000000..5d9e85fa2f --- /dev/null +++ b/proto/lightclient/verification_flags.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package zetachain.zetacore.lightclient; + +option go_package = "github.com/zeta-chain/zetacore/x/lightclient/types"; + +// VerificationFlags is a structure containing information which chain types are enabled for block header verification +message VerificationFlags { + bool ethTypeChainEnabled = 1; + bool btcTypeChainEnabled = 2; +} diff --git a/proto/observer/block_header.proto b/proto/observer/block_header.proto deleted file mode 100644 index c4676db72e..0000000000 --- a/proto/observer/block_header.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; -package zetachain.zetacore.observer; - -import "gogoproto/gogo.proto"; -import "observer/observer.proto"; - -option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; - -message BlockHeaderState { - int64 chain_id = 1; - int64 latest_height = 2; - int64 earliest_height = 3; - bytes latest_block_hash = 4; -} diff --git a/proto/observer/crosschain_flags.proto b/proto/observer/crosschain_flags.proto index e5c3dd9caf..1871963c9b 100644 --- a/proto/observer/crosschain_flags.proto +++ b/proto/observer/crosschain_flags.proto @@ -21,6 +21,8 @@ message GasPriceIncreaseFlags { // Maximum number of pending crosschain transactions to check for gas price increase uint32 maxPendingCctxs = 5; } + +// Deprecated(v16): Use VerificationFlags in the lightclient module instead message BlockHeaderVerificationFlags { bool isEthTypeChainEnabled = 1; bool isBtcTypeChainEnabled = 2; @@ -30,6 +32,8 @@ message CrosschainFlags { bool isInboundEnabled = 1; bool isOutboundEnabled = 2; GasPriceIncreaseFlags gasPriceIncreaseFlags = 3; + + // Deprecated(v16): Use VerificationFlags in the lightclient module instead BlockHeaderVerificationFlags blockHeaderVerificationFlags = 4; } diff --git a/proto/observer/query.proto b/proto/observer/query.proto index 0c2cde9644..7aafc2c799 100644 --- a/proto/observer/query.proto +++ b/proto/observer/query.proto @@ -6,7 +6,6 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "observer/ballot.proto"; import "observer/blame.proto"; -import "observer/block_header.proto"; import "observer/chain_nonces.proto"; import "observer/crosschain_flags.proto"; import "observer/keygen.proto"; @@ -93,23 +92,6 @@ service Query { option (google.api.http).get = "/zeta-chain/observer/blame_by_chain_and_nonce/{chain_id}/{nonce}"; } - rpc GetAllBlockHeaders(QueryAllBlockHeaderRequest) returns (QueryAllBlockHeaderResponse) { - option (google.api.http).get = "/zeta-chain/observer/get_all_block_headers"; - } - - rpc GetBlockHeaderByHash(QueryGetBlockHeaderByHashRequest) returns (QueryGetBlockHeaderByHashResponse) { - option (google.api.http).get = "/zeta-chain/observer/get_block_header_by_hash/{block_hash}"; - } - - rpc GetBlockHeaderStateByChain(QueryGetBlockHeaderStateRequest) returns (QueryGetBlockHeaderStateResponse) { - option (google.api.http).get = "/zeta-chain/observer/get_block_header_state_by_chain_id/{chain_id}"; - } - - // merkle proof verification - rpc Prove(QueryProveRequest) returns (QueryProveResponse) { - option (google.api.http).get = "/zeta-chain/observer/prove"; - } - // Queries a list of GetTssAddress items. rpc GetTssAddress(QueryGetTssAddressRequest) returns (QueryGetTssAddressResponse) { option (google.api.http).get = "/zeta-chain/observer/get_tss_address/{bitcoin_chain_id}"; @@ -215,18 +197,6 @@ message QueryTssHistoryResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } -message QueryProveRequest { - int64 chain_id = 1; - string tx_hash = 2; - proofs.Proof proof = 3; - string block_hash = 4; - int64 tx_index = 5; -} - -message QueryProveResponse { - bool valid = 1; -} - message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. @@ -345,28 +315,3 @@ message QueryBlameByChainAndNonceRequest { message QueryBlameByChainAndNonceResponse { repeated Blame blame_info = 1; } - -message QueryAllBlockHeaderRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -message QueryAllBlockHeaderResponse { - repeated proofs.BlockHeader block_headers = 1; - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -message QueryGetBlockHeaderByHashRequest { - bytes block_hash = 1; -} - -message QueryGetBlockHeaderByHashResponse { - proofs.BlockHeader block_header = 1; -} - -message QueryGetBlockHeaderStateRequest { - int64 chain_id = 1; -} - -message QueryGetBlockHeaderStateResponse { - BlockHeaderState block_header_state = 1; -} diff --git a/proto/observer/tx.proto b/proto/observer/tx.proto index f6b9424b97..227f68cd6b 100644 --- a/proto/observer/tx.proto +++ b/proto/observer/tx.proto @@ -22,7 +22,7 @@ service Msg { rpc AddBlameVote(MsgAddBlameVote) returns (MsgAddBlameVoteResponse); rpc UpdateCrosschainFlags(MsgUpdateCrosschainFlags) returns (MsgUpdateCrosschainFlagsResponse); rpc UpdateKeygen(MsgUpdateKeygen) returns (MsgUpdateKeygenResponse); - rpc AddBlockHeader(MsgAddBlockHeader) returns (MsgAddBlockHeaderResponse); + rpc VoteBlockHeader(MsgVoteBlockHeader) returns (MsgVoteBlockHeaderResponse); rpc ResetChainNonces(MsgResetChainNonces) returns (MsgResetChainNoncesResponse); rpc VoteTSS(MsgVoteTSS) returns (MsgVoteTSSResponse); } @@ -35,7 +35,7 @@ message MsgUpdateObserver { } message MsgUpdateObserverResponse {} -message MsgAddBlockHeader { +message MsgVoteBlockHeader { string creator = 1; int64 chain_id = 2; bytes block_hash = 3; @@ -43,7 +43,10 @@ message MsgAddBlockHeader { proofs.HeaderData header = 5 [(gogoproto.nullable) = false]; } -message MsgAddBlockHeaderResponse {} +message MsgVoteBlockHeaderResponse { + bool ballot_created = 1; + bool vote_finalized = 2; +} message MsgUpdateChainParams { string creator = 1; diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index 3f52ed1e4d..531af3c7b1 100644 --- a/testutil/keeper/crosschain.go +++ b/testutil/keeper/crosschain.go @@ -23,22 +23,24 @@ import ( ) type CrosschainMockOptions struct { - UseBankMock bool - UseAccountMock bool - UseStakingMock bool - UseObserverMock bool - UseFungibleMock bool - UseAuthorityMock bool + UseBankMock bool + UseAccountMock bool + UseStakingMock bool + UseObserverMock bool + UseFungibleMock bool + UseAuthorityMock bool + UseLightclientMock bool } var ( CrosschainMocksAll = CrosschainMockOptions{ - UseBankMock: true, - UseAccountMock: true, - UseStakingMock: true, - UseObserverMock: true, - UseFungibleMock: true, - UseAuthorityMock: true, + UseBankMock: true, + UseAccountMock: true, + UseStakingMock: true, + UseObserverMock: true, + UseFungibleMock: true, + UseAuthorityMock: true, + UseLightclientMock: true, } CrosschainNoMocks = CrosschainMockOptions{} ) @@ -62,6 +64,7 @@ func CrosschainKeeperWithMocks( // Create zeta keepers authorityKeeperTmp := initAuthorityKeeper(cdc, db, stateStore) + lightclientKeeperTmp := initLightclientKeeper(cdc, db, stateStore, authorityKeeperTmp) observerKeeperTmp := initObserverKeeper( cdc, db, @@ -70,6 +73,7 @@ func CrosschainKeeperWithMocks( sdkKeepers.SlashingKeeper, sdkKeepers.ParamsKeeper, authorityKeeperTmp, + lightclientKeeperTmp, ) fungibleKeeperTmp := initFungibleKeeper( cdc, @@ -86,6 +90,7 @@ func CrosschainKeeperWithMocks( FungibleKeeper: fungibleKeeperTmp, AuthorityKeeper: &authorityKeeperTmp, } + var lightclientKeeper types.LightclientKeeper = lightclientKeeperTmp var authorityKeeper types.AuthorityKeeper = authorityKeeperTmp var observerKeeper types.ObserverKeeper = observerKeeperTmp var fungibleKeeper types.FungibleKeeper = fungibleKeeperTmp @@ -127,6 +132,9 @@ func CrosschainKeeperWithMocks( if mockOptions.UseFungibleMock { fungibleKeeper = crosschainmocks.NewCrosschainFungibleKeeper(t) } + if mockOptions.UseLightclientMock { + lightclientKeeper = crosschainmocks.NewCrosschainLightclientKeeper(t) + } k := keeper.NewKeeper( cdc, @@ -138,6 +146,7 @@ func CrosschainKeeperWithMocks( observerKeeper, fungibleKeeper, authorityKeeper, + lightclientKeeper, ) return k, ctx, sdkKeepers, zetaKeepers @@ -154,6 +163,13 @@ func CrosschainKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, Ze return CrosschainKeeperWithMocks(t, CrosschainNoMocks) } +// GetCrosschainLightclientMock returns a new crosschain lightclient keeper mock +func GetCrosschainLightclientMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainLightclientKeeper { + lk, ok := keeper.GetLightclientKeeper().(*crosschainmocks.CrosschainLightclientKeeper) + require.True(t, ok) + return lk +} + // GetCrosschainAuthorityMock returns a new crosschain authority keeper mock func GetCrosschainAuthorityMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainAuthorityKeeper { cok, ok := keeper.GetAuthorityKeeper().(*crosschainmocks.CrosschainAuthorityKeeper) @@ -297,3 +313,31 @@ func MockSaveOutBoundNewRevertCreated(m *crosschainmocks.CrosschainObserverKeepe m.On("GetTSS", ctx).Return(observertypes.TSS{}, true) m.On("SetNonceToCctx", mock.Anything, mock.Anything).Return().Once() } + +// MockCctxByNonce is a utility function using observer mock to returns a cctx of the given status from crosschain keeper +// mocks the methods called by CctxByNonce to directly return the given cctx or error +func MockCctxByNonce( + t *testing.T, + ctx sdk.Context, + k keeper.Keeper, + observerKeeper *crosschainmocks.CrosschainObserverKeeper, + cctxStatus types.CctxStatus, + isErr bool, +) { + if isErr { + // return error on GetTSS to make CctxByNonce return error + observerKeeper.On("GetTSS", mock.Anything).Return(observertypes.TSS{}, false).Once() + return + } + + cctx := sample.CrossChainTx(t, sample.StringRandom(sample.Rand(), 10)) + cctx.CctxStatus = &types.Status{ + Status: cctxStatus, + } + k.SetCrossChainTx(ctx, *cctx) + + observerKeeper.On("GetTSS", mock.Anything).Return(observertypes.TSS{}, true).Once() + observerKeeper.On("GetNonceToCctx", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(observertypes.NonceToCctx{ + CctxIndex: cctx.Index, + }, true).Once() +} diff --git a/testutil/keeper/emissions.go b/testutil/keeper/emissions.go index 57c5b64527..a799b94edb 100644 --- a/testutil/keeper/emissions.go +++ b/testutil/keeper/emissions.go @@ -41,6 +41,8 @@ func EmissionKeeperWithMockOptions( // Create regular keepers sdkKeepers := NewSDKKeepers(cdc, db, stateStore) + authorityKeeper := initAuthorityKeeper(cdc, db, stateStore) + // Create zeta keepers observerKeeperTmp := initObserverKeeper( cdc, @@ -49,7 +51,8 @@ func EmissionKeeperWithMockOptions( sdkKeepers.StakingKeeper, sdkKeepers.SlashingKeeper, sdkKeepers.ParamsKeeper, - initAuthorityKeeper(cdc, db, stateStore), + authorityKeeper, + initLightclientKeeper(cdc, db, stateStore, authorityKeeper), ) zetaKeepers := ZetaKeepers{ diff --git a/testutil/keeper/fungible.go b/testutil/keeper/fungible.go index ae61439c1a..ff5f79192a 100644 --- a/testutil/keeper/fungible.go +++ b/testutil/keeper/fungible.go @@ -86,6 +86,14 @@ func FungibleKeeperWithMocks(t testing.TB, mockOptions FungibleMockOptions) (*ke stateStore, ) + // Create lightclient keeper + lightclientKeeperTmp := initLightclientKeeper( + cdc, + db, + stateStore, + authorityKeeperTmp, + ) + // Create observer keeper observerKeeperTmp := initObserverKeeper( cdc, @@ -95,10 +103,12 @@ func FungibleKeeperWithMocks(t testing.TB, mockOptions FungibleMockOptions) (*ke sdkKeepers.SlashingKeeper, sdkKeepers.ParamsKeeper, authorityKeeperTmp, + lightclientKeeperTmp, ) zetaKeepers := ZetaKeepers{ - ObserverKeeper: observerKeeperTmp, - AuthorityKeeper: &authorityKeeperTmp, + ObserverKeeper: observerKeeperTmp, + AuthorityKeeper: &authorityKeeperTmp, + LightclientKeeper: &lightclientKeeperTmp, } var observerKeeper types.ObserverKeeper = observerKeeperTmp var authorityKeeper types.AuthorityKeeper = authorityKeeperTmp diff --git a/testutil/keeper/keeper.go b/testutil/keeper/keeper.go index 3e76a951b5..0eb8286404 100644 --- a/testutil/keeper/keeper.go +++ b/testutil/keeper/keeper.go @@ -49,6 +49,7 @@ import ( fungiblemodule "github.com/zeta-chain/zetacore/x/fungible" fungiblekeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + lightclientkeeper "github.com/zeta-chain/zetacore/x/lightclient/keeper" observermodule "github.com/zeta-chain/zetacore/x/observer" observerkeeper "github.com/zeta-chain/zetacore/x/observer/keeper" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -93,11 +94,12 @@ type SDKKeepers struct { // ZetaKeepers is a struct containing Zeta module keepers for test purposes type ZetaKeepers struct { - AuthorityKeeper *authoritykeeper.Keeper - CrosschainKeeper *crosschainkeeper.Keeper - EmissionsKeeper *emissionskeeper.Keeper - FungibleKeeper *fungiblekeeper.Keeper - ObserverKeeper *observerkeeper.Keeper + AuthorityKeeper *authoritykeeper.Keeper + CrosschainKeeper *crosschainkeeper.Keeper + EmissionsKeeper *emissionskeeper.Keeper + FungibleKeeper *fungiblekeeper.Keeper + ObserverKeeper *observerkeeper.Keeper + LightclientKeeper *lightclientkeeper.Keeper } var moduleAccountPerms = map[string][]string{ diff --git a/testutil/keeper/lightclient.go b/testutil/keeper/lightclient.go new file mode 100644 index 0000000000..df4ff39b16 --- /dev/null +++ b/testutil/keeper/lightclient.go @@ -0,0 +1,94 @@ +package keeper + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + tmdb "github.com/tendermint/tm-db" + lightclientmocks "github.com/zeta-chain/zetacore/testutil/keeper/mocks/lightclient" + "github.com/zeta-chain/zetacore/x/lightclient/keeper" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// LightclientMockOptions represents options for instantiating a lightclient keeper with mocks +type LightclientMockOptions struct { + UseAuthorityMock bool +} + +var ( + LightclientMocksAll = LightclientMockOptions{ + UseAuthorityMock: true, + } + LightclientNoMocks = LightclientMockOptions{} +) + +func initLightclientKeeper( + cdc codec.Codec, + db *tmdb.MemDB, + ss store.CommitMultiStore, + authorityKeeper types.AuthorityKeeper, +) keeper.Keeper { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + ss.MountStoreWithDB(memKey, storetypes.StoreTypeMemory, db) + + return keeper.NewKeeper(cdc, storeKey, memKey, authorityKeeper) +} + +// LightclientKeeperWithMocks instantiates a lightclient keeper for testing purposes with the option to mock specific keepers +func LightclientKeeperWithMocks(t testing.TB, mockOptions LightclientMockOptions) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + // Initialize local store + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + cdc := NewCodec() + + authorityKeeperTmp := initAuthorityKeeper(cdc, db, stateStore) + + // Create regular keepers + sdkKeepers := NewSDKKeepers(cdc, db, stateStore) + + // Create the observer keeper + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + ctx := NewContext(stateStore) + + // Initialize modules genesis + sdkKeepers.InitGenesis(ctx) + + // Add a proposer to the context + ctx = sdkKeepers.InitBlockProposer(t, ctx) + + // Initialize mocks for mocked keepers + var authorityKeeper types.AuthorityKeeper = authorityKeeperTmp + if mockOptions.UseAuthorityMock { + authorityKeeper = lightclientmocks.NewLightclientAuthorityKeeper(t) + } + + k := keeper.NewKeeper(cdc, storeKey, memStoreKey, authorityKeeper) + + return &k, ctx, sdkKeepers, ZetaKeepers{ + AuthorityKeeper: &authorityKeeperTmp, + } +} + +// LightclientKeeper instantiates an lightclient keeper for testing purposes +func LightclientKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers) { + return LightclientKeeperWithMocks(t, LightclientNoMocks) +} + +// GetLightclientAuthorityMock returns a new lightclient authority keeper mock +func GetLightclientAuthorityMock(t testing.TB, keeper *keeper.Keeper) *lightclientmocks.LightclientAuthorityKeeper { + cok, ok := keeper.GetAuthorityKeeper().(*lightclientmocks.LightclientAuthorityKeeper) + require.True(t, ok) + return cok +} diff --git a/testutil/keeper/mocks/crosschain/account.go b/testutil/keeper/mocks/crosschain/account.go index fbd7c0377b..99b7f1cf5b 100644 --- a/testutil/keeper/mocks/crosschain/account.go +++ b/testutil/keeper/mocks/crosschain/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/authority.go b/testutil/keeper/mocks/crosschain/authority.go index 9f08c9d673..fd6ceefa47 100644 --- a/testutil/keeper/mocks/crosschain/authority.go +++ b/testutil/keeper/mocks/crosschain/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/bank.go b/testutil/keeper/mocks/crosschain/bank.go index 90f4e17e29..267f2b45b4 100644 --- a/testutil/keeper/mocks/crosschain/bank.go +++ b/testutil/keeper/mocks/crosschain/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/fungible.go b/testutil/keeper/mocks/crosschain/fungible.go index 54b7e54a03..0b7fc53c89 100644 --- a/testutil/keeper/mocks/crosschain/fungible.go +++ b/testutil/keeper/mocks/crosschain/fungible.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/lightclient.go b/testutil/keeper/mocks/crosschain/lightclient.go new file mode 100644 index 0000000000..53eaf7c398 --- /dev/null +++ b/testutil/keeper/mocks/crosschain/lightclient.go @@ -0,0 +1,60 @@ +// Code generated by mockery v2.39.1. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + + proofs "github.com/zeta-chain/zetacore/pkg/proofs" + + types "github.com/cosmos/cosmos-sdk/types" +) + +// CrosschainLightclientKeeper is an autogenerated mock type for the CrosschainLightclientKeeper type +type CrosschainLightclientKeeper struct { + mock.Mock +} + +// VerifyProof provides a mock function with given fields: ctx, proof, chainID, blockHash, txIndex +func (_m *CrosschainLightclientKeeper) VerifyProof(ctx types.Context, proof *proofs.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) { + ret := _m.Called(ctx, proof, chainID, blockHash, txIndex) + + if len(ret) == 0 { + panic("no return value specified for VerifyProof") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, *proofs.Proof, int64, string, int64) ([]byte, error)); ok { + return rf(ctx, proof, chainID, blockHash, txIndex) + } + if rf, ok := ret.Get(0).(func(types.Context, *proofs.Proof, int64, string, int64) []byte); ok { + r0 = rf(ctx, proof, chainID, blockHash, txIndex) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func(types.Context, *proofs.Proof, int64, string, int64) error); ok { + r1 = rf(ctx, proof, chainID, blockHash, txIndex) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewCrosschainLightclientKeeper creates a new instance of CrosschainLightclientKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCrosschainLightclientKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *CrosschainLightclientKeeper { + mock := &CrosschainLightclientKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/testutil/keeper/mocks/crosschain/observer.go b/testutil/keeper/mocks/crosschain/observer.go index fd1003c3b7..aa05e13226 100644 --- a/testutil/keeper/mocks/crosschain/observer.go +++ b/testutil/keeper/mocks/crosschain/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks @@ -12,8 +12,6 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" - proofs "github.com/zeta-chain/zetacore/pkg/proofs" - types "github.com/cosmos/cosmos-sdk/types" ) @@ -304,34 +302,6 @@ func (_m *CrosschainObserverKeeper) GetBallot(ctx types.Context, index string) ( return r0, r1 } -// GetBlockHeader provides a mock function with given fields: ctx, hash -func (_m *CrosschainObserverKeeper) GetBlockHeader(ctx types.Context, hash []byte) (proofs.BlockHeader, bool) { - ret := _m.Called(ctx, hash) - - if len(ret) == 0 { - panic("no return value specified for GetBlockHeader") - } - - var r0 proofs.BlockHeader - var r1 bool - if rf, ok := ret.Get(0).(func(types.Context, []byte) (proofs.BlockHeader, bool)); ok { - return rf(ctx, hash) - } - if rf, ok := ret.Get(0).(func(types.Context, []byte) proofs.BlockHeader); ok { - r0 = rf(ctx, hash) - } else { - r0 = ret.Get(0).(proofs.BlockHeader) - } - - if rf, ok := ret.Get(1).(func(types.Context, []byte) bool); ok { - r1 = rf(ctx, hash) - } else { - r1 = ret.Get(1).(bool) - } - - return r0, r1 -} - // GetChainNonces provides a mock function with given fields: ctx, index func (_m *CrosschainObserverKeeper) GetChainNonces(ctx types.Context, index string) (observertypes.ChainNonces, bool) { ret := _m.Called(ctx, index) diff --git a/testutil/keeper/mocks/crosschain/staking.go b/testutil/keeper/mocks/crosschain/staking.go index 5b7d3c501f..64bbe0fed6 100644 --- a/testutil/keeper/mocks/crosschain/staking.go +++ b/testutil/keeper/mocks/crosschain/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/account.go b/testutil/keeper/mocks/emissions/account.go index a660d40e72..265c291e1b 100644 --- a/testutil/keeper/mocks/emissions/account.go +++ b/testutil/keeper/mocks/emissions/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/bank.go b/testutil/keeper/mocks/emissions/bank.go index 8149b5e6af..10bc77649b 100644 --- a/testutil/keeper/mocks/emissions/bank.go +++ b/testutil/keeper/mocks/emissions/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/observer.go b/testutil/keeper/mocks/emissions/observer.go index 7c2cfb3c48..ce36c71f69 100644 --- a/testutil/keeper/mocks/emissions/observer.go +++ b/testutil/keeper/mocks/emissions/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/param_store.go b/testutil/keeper/mocks/emissions/param_store.go index f9923f3d94..4b5a1751cd 100644 --- a/testutil/keeper/mocks/emissions/param_store.go +++ b/testutil/keeper/mocks/emissions/param_store.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/staking.go b/testutil/keeper/mocks/emissions/staking.go index 7c58333bb5..bcfff21c40 100644 --- a/testutil/keeper/mocks/emissions/staking.go +++ b/testutil/keeper/mocks/emissions/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/account.go b/testutil/keeper/mocks/fungible/account.go index 0522e833b4..94b7a84d75 100644 --- a/testutil/keeper/mocks/fungible/account.go +++ b/testutil/keeper/mocks/fungible/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/authority.go b/testutil/keeper/mocks/fungible/authority.go index 929a99021c..b87791c784 100644 --- a/testutil/keeper/mocks/fungible/authority.go +++ b/testutil/keeper/mocks/fungible/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/bank.go b/testutil/keeper/mocks/fungible/bank.go index db14226310..20a2590911 100644 --- a/testutil/keeper/mocks/fungible/bank.go +++ b/testutil/keeper/mocks/fungible/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/evm.go b/testutil/keeper/mocks/fungible/evm.go index 28fd46e25c..f0dcd01094 100644 --- a/testutil/keeper/mocks/fungible/evm.go +++ b/testutil/keeper/mocks/fungible/evm.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/observer.go b/testutil/keeper/mocks/fungible/observer.go index bbe76b1afa..5e0aca6a0f 100644 --- a/testutil/keeper/mocks/fungible/observer.go +++ b/testutil/keeper/mocks/fungible/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/lightclient/authority.go b/testutil/keeper/mocks/lightclient/authority.go new file mode 100644 index 0000000000..f86b893f9c --- /dev/null +++ b/testutil/keeper/mocks/lightclient/authority.go @@ -0,0 +1,47 @@ +// Code generated by mockery v2.39.1. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + + types "github.com/cosmos/cosmos-sdk/types" +) + +// LightclientAuthorityKeeper is an autogenerated mock type for the LightclientAuthorityKeeper type +type LightclientAuthorityKeeper struct { + mock.Mock +} + +// IsAuthorized provides a mock function with given fields: ctx, address, policyType +func (_m *LightclientAuthorityKeeper) IsAuthorized(ctx types.Context, address string, policyType authoritytypes.PolicyType) bool { + ret := _m.Called(ctx, address, policyType) + + if len(ret) == 0 { + panic("no return value specified for IsAuthorized") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(types.Context, string, authoritytypes.PolicyType) bool); ok { + r0 = rf(ctx, address, policyType) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// NewLightclientAuthorityKeeper creates a new instance of LightclientAuthorityKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLightclientAuthorityKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *LightclientAuthorityKeeper { + mock := &LightclientAuthorityKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/testutil/keeper/mocks/mocks.go b/testutil/keeper/mocks/mocks.go index 1180fca27a..e8001ab81d 100644 --- a/testutil/keeper/mocks/mocks.go +++ b/testutil/keeper/mocks/mocks.go @@ -4,6 +4,7 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -41,6 +42,11 @@ type CrosschainAuthorityKeeper interface { crosschaintypes.AuthorityKeeper } +//go:generate mockery --name CrosschainLightclientKeeper --filename lightclient.go --case underscore --output ./crosschain +type CrosschainLightclientKeeper interface { + crosschaintypes.LightclientKeeper +} + /** * Fungible Mocks */ @@ -117,3 +123,17 @@ type ObserverSlashingKeeper interface { type ObserverAuthorityKeeper interface { observertypes.AuthorityKeeper } + +//go:generate mockery --name ObserverLightclientKeeper --filename lightclient.go --case underscore --output ./observer +type ObserverLightclientKeeper interface { + observertypes.LightclientKeeper +} + +/** + * Lightclient Mocks + */ + +//go:generate mockery --name LightclientAuthorityKeeper --filename authority.go --case underscore --output ./lightclient +type LightclientAuthorityKeeper interface { + lightclienttypes.AuthorityKeeper +} diff --git a/testutil/keeper/mocks/observer/authority.go b/testutil/keeper/mocks/observer/authority.go index 76e5e0566c..4787b99b8a 100644 --- a/testutil/keeper/mocks/observer/authority.go +++ b/testutil/keeper/mocks/observer/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/observer/lightclient.go b/testutil/keeper/mocks/observer/lightclient.go new file mode 100644 index 0000000000..b25f440330 --- /dev/null +++ b/testutil/keeper/mocks/observer/lightclient.go @@ -0,0 +1,65 @@ +// Code generated by mockery v2.39.1. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + + proofs "github.com/zeta-chain/zetacore/pkg/proofs" + + types "github.com/cosmos/cosmos-sdk/types" +) + +// ObserverLightclientKeeper is an autogenerated mock type for the ObserverLightclientKeeper type +type ObserverLightclientKeeper struct { + mock.Mock +} + +// AddBlockHeader provides a mock function with given fields: ctx, chainID, height, blockHash, header, parentHash +func (_m *ObserverLightclientKeeper) AddBlockHeader(ctx types.Context, chainID int64, height int64, blockHash []byte, header proofs.HeaderData, parentHash []byte) { + _m.Called(ctx, chainID, height, blockHash, header, parentHash) +} + +// CheckNewBlockHeader provides a mock function with given fields: ctx, chainID, blockHash, height, header +func (_m *ObserverLightclientKeeper) CheckNewBlockHeader(ctx types.Context, chainID int64, blockHash []byte, height int64, header proofs.HeaderData) ([]byte, error) { + ret := _m.Called(ctx, chainID, blockHash, height, header) + + if len(ret) == 0 { + panic("no return value specified for CheckNewBlockHeader") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, int64, []byte, int64, proofs.HeaderData) ([]byte, error)); ok { + return rf(ctx, chainID, blockHash, height, header) + } + if rf, ok := ret.Get(0).(func(types.Context, int64, []byte, int64, proofs.HeaderData) []byte); ok { + r0 = rf(ctx, chainID, blockHash, height, header) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func(types.Context, int64, []byte, int64, proofs.HeaderData) error); ok { + r1 = rf(ctx, chainID, blockHash, height, header) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewObserverLightclientKeeper creates a new instance of ObserverLightclientKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewObserverLightclientKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *ObserverLightclientKeeper { + mock := &ObserverLightclientKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/testutil/keeper/mocks/observer/slashing.go b/testutil/keeper/mocks/observer/slashing.go index a7793ef8dc..d3f64ff726 100644 --- a/testutil/keeper/mocks/observer/slashing.go +++ b/testutil/keeper/mocks/observer/slashing.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/observer/staking.go b/testutil/keeper/mocks/observer/staking.go index 90007b6c35..72fe2be116 100644 --- a/testutil/keeper/mocks/observer/staking.go +++ b/testutil/keeper/mocks/observer/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/observer.go b/testutil/keeper/observer.go index c747df0218..423341a883 100644 --- a/testutil/keeper/observer.go +++ b/testutil/keeper/observer.go @@ -21,16 +21,18 @@ import ( // ObserverMockOptions represents options for instantiating an observer keeper with mocks type ObserverMockOptions struct { - UseStakingMock bool - UseSlashingMock bool - UseAuthorityMock bool + UseStakingMock bool + UseSlashingMock bool + UseAuthorityMock bool + UseLightclientMock bool } var ( ObserverMocksAll = ObserverMockOptions{ - UseStakingMock: true, - UseSlashingMock: true, - UseAuthorityMock: true, + UseStakingMock: true, + UseSlashingMock: true, + UseAuthorityMock: true, + UseLightclientMock: true, } ObserverNoMocks = ObserverMockOptions{} ) @@ -43,6 +45,7 @@ func initObserverKeeper( slashingKeeper slashingkeeper.Keeper, paramKeeper paramskeeper.Keeper, authorityKeeper types.AuthorityKeeper, + lightclientKeeper types.LightclientKeeper, ) *keeper.Keeper { storeKey := sdk.NewKVStoreKey(types.StoreKey) memKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) @@ -57,6 +60,7 @@ func initObserverKeeper( stakingKeeper, slashingKeeper, authorityKeeper, + lightclientKeeper, ) } @@ -71,6 +75,7 @@ func ObserverKeeperWithMocks(t testing.TB, mockOptions ObserverMockOptions) (*ke cdc := NewCodec() authorityKeeperTmp := initAuthorityKeeper(cdc, db, stateStore) + lightclientKeeperTmp := initLightclientKeeper(cdc, db, stateStore, authorityKeeperTmp) // Create regular keepers sdkKeepers := NewSDKKeepers(cdc, db, stateStore) @@ -92,6 +97,7 @@ func ObserverKeeperWithMocks(t testing.TB, mockOptions ObserverMockOptions) (*ke var stakingKeeper types.StakingKeeper = sdkKeepers.StakingKeeper var slashingKeeper types.SlashingKeeper = sdkKeepers.SlashingKeeper var authorityKeeper types.AuthorityKeeper = authorityKeeperTmp + var lightclientKeeper types.LightclientKeeper = lightclientKeeperTmp if mockOptions.UseStakingMock { stakingKeeper = observermocks.NewObserverStakingKeeper(t) } @@ -101,6 +107,9 @@ func ObserverKeeperWithMocks(t testing.TB, mockOptions ObserverMockOptions) (*ke if mockOptions.UseAuthorityMock { authorityKeeper = observermocks.NewObserverAuthorityKeeper(t) } + if mockOptions.UseLightclientMock { + lightclientKeeper = observermocks.NewObserverLightclientKeeper(t) + } k := keeper.NewKeeper( cdc, @@ -110,6 +119,7 @@ func ObserverKeeperWithMocks(t testing.TB, mockOptions ObserverMockOptions) (*ke stakingKeeper, slashingKeeper, authorityKeeper, + lightclientKeeper, ) k.SetParams(ctx, types.DefaultParams()) @@ -124,6 +134,13 @@ func ObserverKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, Zeta return ObserverKeeperWithMocks(t, ObserverNoMocks) } +// GetObserverLightclientMock returns a new observer lightclient keeper mock +func GetObserverLightclientMock(t testing.TB, keeper *keeper.Keeper) *observermocks.ObserverLightclientKeeper { + cok, ok := keeper.GetLightclientKeeper().(*observermocks.ObserverLightclientKeeper) + require.True(t, ok) + return cok +} + // GetObserverAuthorityMock returns a new observer authority keeper mock func GetObserverAuthorityMock(t testing.TB, keeper *keeper.Keeper) *observermocks.ObserverAuthorityKeeper { cok, ok := keeper.GetAuthorityKeeper().(*observermocks.ObserverAuthorityKeeper) diff --git a/testutil/sample/common.go b/testutil/sample/common.go deleted file mode 100644 index 7549d80ce0..0000000000 --- a/testutil/sample/common.go +++ /dev/null @@ -1,30 +0,0 @@ -package sample - -import ( - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/zeta-chain/zetacore/pkg/chains" - "github.com/zeta-chain/zetacore/pkg/crypto" -) - -func Chain(chainID int64) *chains.Chain { - r := newRandFromSeed(chainID) - - return &chains.Chain{ - ChainName: chains.ChainName(r.Intn(4)), - ChainId: chainID, - } -} - -func PubKeySet() *crypto.PubKeySet { - pubKeySet := crypto.PubKeySet{ - Secp256k1: crypto.PubKey(secp256k1.GenPrivKey().PubKey().Bytes()), - Ed25519: crypto.PubKey(ed25519.GenPrivKey().PubKey().String()), - } - return &pubKeySet -} - -func EventIndex() uint64 { - r := newRandFromSeed(1) - return r.Uint64() -} diff --git a/testutil/sample/crypto.go b/testutil/sample/crypto.go new file mode 100644 index 0000000000..77254bb8e0 --- /dev/null +++ b/testutil/sample/crypto.go @@ -0,0 +1,132 @@ +package sample + +import ( + "crypto/ecdsa" + "math/big" + "math/rand" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + ethcrypto "github.com/ethereum/go-ethereum/crypto" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/zeta-chain/zetacore/pkg/cosmos" + "github.com/zeta-chain/zetacore/pkg/crypto" +) + +func PubKeySet() *crypto.PubKeySet { + pubKeySet := crypto.PubKeySet{ + Secp256k1: crypto.PubKey(secp256k1.GenPrivKey().PubKey().Bytes()), + Ed25519: crypto.PubKey(ed25519.GenPrivKey().PubKey().String()), + } + return &pubKeySet +} + +// PubKeyString returns a sample public key string +func PubKeyString() string { + priKey := ed25519.GenPrivKey() + s, err := cosmos.Bech32ifyPubKey(cosmos.Bech32PubKeyTypeAccPub, priKey.PubKey()) + if err != nil { + panic(err) + } + pubkey, err := crypto.NewPubKey(s) + if err != nil { + panic(err) + } + return pubkey.String() +} + +// PrivKeyAddressPair returns a private key, address pair +func PrivKeyAddressPair() (*ed25519.PrivKey, sdk.AccAddress) { + privKey := ed25519.GenPrivKey() + addr := privKey.PubKey().Address() + + return privKey, sdk.AccAddress(addr) +} + +// EthAddress returns a sample ethereum address +func EthAddress() ethcommon.Address { + return ethcommon.BytesToAddress(sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()).Bytes()) +} + +// Hash returns a sample hash +func Hash() ethcommon.Hash { + return EthAddress().Hash() +} + +// PubKey returns a sample account PubKey +func PubKey(r *rand.Rand) cryptotypes.PubKey { + seed := []byte(strconv.Itoa(r.Int())) + return ed25519.GenPrivKeyFromSecret(seed).PubKey() +} + +// Bech32AccAddress returns a sample account address +func Bech32AccAddress() sdk.AccAddress { + pk := ed25519.GenPrivKey().PubKey() + addr := pk.Address() + return sdk.AccAddress(addr) +} + +// AccAddress returns a sample account address in string +func AccAddress() string { + pk := ed25519.GenPrivKey().PubKey() + addr := pk.Address() + return sdk.AccAddress(addr).String() +} + +// ValAddress returns a sample validator operator address +func ValAddress(r *rand.Rand) sdk.ValAddress { + return sdk.ValAddress(PubKey(r).Address()) +} + +// EthTx returns a sample ethereum transaction with the associated tx data bytes +func EthTx(t *testing.T, chainID int64, to ethcommon.Address, nonce uint64) (*ethtypes.Transaction, []byte) { + tx := ethtypes.NewTx(ðtypes.DynamicFeeTx{ + ChainID: big.NewInt(chainID), + Nonce: nonce, + GasTipCap: nil, + GasFeeCap: nil, + Gas: 21000, + To: &to, + Value: big.NewInt(5), + Data: nil, + }) + + txBytes, err := tx.MarshalBinary() + require.NoError(t, err) + + return tx, txBytes +} + +// EthTxSigned returns a sample signed ethereum transaction with the address of the sender +func EthTxSigned( + t *testing.T, + chainID int64, + to ethcommon.Address, + nonce uint64, +) (*ethtypes.Transaction, []byte, ethcommon.Address) { + tx, _ := EthTx(t, chainID, to, nonce) + + // generate a private key and get address + privateKey, err := ethcrypto.GenerateKey() + require.NoError(t, err) + publicKey := privateKey.Public() + publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) + fromAddress := ethcrypto.PubkeyToAddress(*publicKeyECDSA) + require.True(t, ok) + + // sign the transaction + signer := ethtypes.NewLondonSigner(tx.ChainId()) + signedTx, err := ethtypes.SignTx(tx, signer, privateKey) + require.NoError(t, err) + + txBytes, err := signedTx.MarshalBinary() + require.NoError(t, err) + + return signedTx, txBytes, fromAddress +} diff --git a/testutil/sample/lightclient.go b/testutil/sample/lightclient.go new file mode 100644 index 0000000000..6bb69f32d6 --- /dev/null +++ b/testutil/sample/lightclient.go @@ -0,0 +1,76 @@ +package sample + +import ( + "testing" + + ethcommon "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + "github.com/zeta-chain/zetacore/pkg/proofs/ethereum" + "github.com/zeta-chain/zetacore/pkg/testdata" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func BlockHeader(blockHash []byte) proofs.BlockHeader { + return proofs.BlockHeader{ + Height: 42, + Hash: blockHash, + ParentHash: Hash().Bytes(), + ChainId: 42, + Header: proofs.HeaderData{}, + } +} + +func ChainState(chainID int64) lightclienttypes.ChainState { + return lightclienttypes.ChainState{ + ChainId: chainID, + LatestHeight: 42, + EarliestHeight: 42, + LatestBlockHash: Hash().Bytes(), + } +} + +func VerificationFlags() lightclienttypes.VerificationFlags { + return lightclienttypes.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + } +} + +// Proof generates a proof and block header +// returns the proof, block header, block hash, tx index, chain id, and tx hash +func Proof(t *testing.T) (*proofs.Proof, proofs.BlockHeader, string, int64, int64, ethcommon.Hash) { + header, err := testdata.ReadEthHeader() + require.NoError(t, err) + b, err := rlp.EncodeToBytes(&header) + require.NoError(t, err) + + var txs ethtypes.Transactions + for i := 0; i < testdata.TxsCount; i++ { + tx, err := testdata.ReadEthTx(i) + require.NoError(t, err) + txs = append(txs, &tx) + } + txsTree := ethereum.NewTrie(txs) + + // choose 2 as the index of the tx to prove + txIndex := 2 + proof, err := txsTree.GenerateProof(txIndex) + require.NoError(t, err) + + chainID := chains.SepoliaChain().ChainId + ethProof := proofs.NewEthereumProof(proof) + ethHeader := proofs.NewEthereumHeader(b) + blockHeader := proofs.BlockHeader{ + Height: header.Number.Int64(), + Hash: header.Hash().Bytes(), + ParentHash: header.ParentHash.Bytes(), + ChainId: chainID, + Header: ethHeader, + } + txHash := txs[txIndex].Hash() + return ethProof, blockHeader, header.Hash().Hex(), int64(txIndex), chainID, txHash +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 71b9eac564..b0049ab589 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -7,18 +7,16 @@ import ( "strconv" "testing" + "github.com/zeta-chain/zetacore/pkg/chains" + sdkmath "cosmossdk.io/math" ethcrypto "github.com/ethereum/go-ethereum/crypto" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ethcommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/cosmos" - "github.com/zeta-chain/zetacore/pkg/crypto" ) var ErrSample = errors.New("sample error") @@ -40,35 +38,6 @@ func Rand() *rand.Rand { return newRandFromSeed(42) } -// PubKey returns a sample account PubKey -func PubKey(r *rand.Rand) cryptotypes.PubKey { - seed := []byte(strconv.Itoa(r.Int())) - return ed25519.GenPrivKeyFromSecret(seed).PubKey() -} - -// Bech32AccAddress returns a sample account address -func Bech32AccAddress() sdk.AccAddress { - pk := ed25519.GenPrivKey().PubKey() - addr := pk.Address() - return sdk.AccAddress(addr) -} - -// AccAddress returns a sample account address in string -func AccAddress() string { - pk := ed25519.GenPrivKey().PubKey() - addr := pk.Address() - return sdk.AccAddress(addr).String() -} - -func ConsAddress() sdk.ConsAddress { - return sdk.ConsAddress(PubKey(newRandFromSeed(1)).Address()) -} - -// ValAddress returns a sample validator operator address -func ValAddress(r *rand.Rand) sdk.ValAddress { - return sdk.ValAddress(PubKey(r).Address()) -} - // Validator returns a sample staking validator func Validator(t testing.TB, r *rand.Rand) stakingtypes.Validator { seed := []byte(strconv.Itoa(r.Int())) @@ -80,38 +49,6 @@ func Validator(t testing.TB, r *rand.Rand) stakingtypes.Validator { return val } -// PubKeyString returns a sample public key string -func PubKeyString() string { - priKey := ed25519.GenPrivKey() - s, err := cosmos.Bech32ifyPubKey(cosmos.Bech32PubKeyTypeAccPub, priKey.PubKey()) - if err != nil { - panic(err) - } - pubkey, err := crypto.NewPubKey(s) - if err != nil { - panic(err) - } - return pubkey.String() -} - -// PrivKeyAddressPair returns a private key, address pair -func PrivKeyAddressPair() (*ed25519.PrivKey, sdk.AccAddress) { - privKey := ed25519.GenPrivKey() - addr := privKey.PubKey().Address() - - return privKey, sdk.AccAddress(addr) -} - -// EthAddress returns a sample ethereum address -func EthAddress() ethcommon.Address { - return ethcommon.BytesToAddress(sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()).Bytes()) -} - -// Hash returns a sample hash -func Hash() ethcommon.Hash { - return EthAddress().Hash() -} - func ZetaIndex(t *testing.T) string { msg := CrossChainTx(t, "foo") hash := ethcrypto.Keccak256Hash([]byte(msg.String())) @@ -164,3 +101,17 @@ func IntInRange(low, high int64) sdkmath.Int { i := Int64InRange(low, high) return sdkmath.NewInt(i) } + +func Chain(chainID int64) *chains.Chain { + r := newRandFromSeed(chainID) + + return &chains.Chain{ + ChainName: chains.ChainName(r.Intn(4)), + ChainId: chainID, + } +} + +func EventIndex() uint64 { + r := newRandFromSeed(1) + return r.Uint64() +} diff --git a/typescript/observer/block_header_pb.d.ts b/typescript/lightclient/chain_state_pb.d.ts similarity index 58% rename from typescript/observer/block_header_pb.d.ts rename to typescript/lightclient/chain_state_pb.d.ts index 87f3e1d24d..ad9058cb50 100644 --- a/typescript/observer/block_header_pb.d.ts +++ b/typescript/lightclient/chain_state_pb.d.ts @@ -1,5 +1,5 @@ // @generated by protoc-gen-es v1.3.0 with parameter "target=dts" -// @generated from file observer/block_header.proto (package zetachain.zetacore.observer, syntax proto3) +// @generated from file lightclient/chain_state.proto (package zetachain.zetacore.lightclient, syntax proto3) /* eslint-disable */ // @ts-nocheck @@ -7,9 +7,11 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; /** - * @generated from message zetachain.zetacore.observer.BlockHeaderState + * ChainState defines the overall state of the block headers for a given chain + * + * @generated from message zetachain.zetacore.lightclient.ChainState */ -export declare class BlockHeaderState extends Message { +export declare class ChainState extends Message { /** * @generated from field: int64 chain_id = 1; */ @@ -30,18 +32,18 @@ export declare class BlockHeaderState extends Message { */ latestBlockHash: Uint8Array; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.BlockHeaderState"; + static readonly typeName = "zetachain.zetacore.lightclient.ChainState"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): BlockHeaderState; + static fromBinary(bytes: Uint8Array, options?: Partial): ChainState; - static fromJson(jsonValue: JsonValue, options?: Partial): BlockHeaderState; + static fromJson(jsonValue: JsonValue, options?: Partial): ChainState; - static fromJsonString(jsonString: string, options?: Partial): BlockHeaderState; + static fromJsonString(jsonString: string, options?: Partial): ChainState; - static equals(a: BlockHeaderState | PlainMessage | undefined, b: BlockHeaderState | PlainMessage | undefined): boolean; + static equals(a: ChainState | PlainMessage | undefined, b: ChainState | PlainMessage | undefined): boolean; } diff --git a/typescript/lightclient/genesis_pb.d.ts b/typescript/lightclient/genesis_pb.d.ts new file mode 100644 index 0000000000..03bdc94b3a --- /dev/null +++ b/typescript/lightclient/genesis_pb.d.ts @@ -0,0 +1,47 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file lightclient/genesis.proto (package zetachain.zetacore.lightclient, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; +import type { BlockHeader } from "../pkg/proofs/proofs_pb.js"; +import type { ChainState } from "./chain_state_pb.js"; +import type { VerificationFlags } from "./verification_flags_pb.js"; + +/** + * GenesisState defines the lightclient module's genesis state. + * + * @generated from message zetachain.zetacore.lightclient.GenesisState + */ +export declare class GenesisState extends Message { + /** + * @generated from field: repeated proofs.BlockHeader block_headers = 1; + */ + blockHeaders: BlockHeader[]; + + /** + * @generated from field: repeated zetachain.zetacore.lightclient.ChainState chain_states = 2; + */ + chainStates: ChainState[]; + + /** + * @generated from field: zetachain.zetacore.lightclient.VerificationFlags verification_flags = 3; + */ + verificationFlags?: VerificationFlags; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.GenesisState"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): GenesisState; + + static fromJson(jsonValue: JsonValue, options?: Partial): GenesisState; + + static fromJsonString(jsonString: string, options?: Partial): GenesisState; + + static equals(a: GenesisState | PlainMessage | undefined, b: GenesisState | PlainMessage | undefined): boolean; +} + diff --git a/typescript/lightclient/index.d.ts b/typescript/lightclient/index.d.ts new file mode 100644 index 0000000000..767468a720 --- /dev/null +++ b/typescript/lightclient/index.d.ts @@ -0,0 +1,5 @@ +export * from "./chain_state_pb"; +export * from "./genesis_pb"; +export * from "./query_pb"; +export * from "./tx_pb"; +export * from "./verification_flags_pb"; diff --git a/typescript/lightclient/query_pb.d.ts b/typescript/lightclient/query_pb.d.ts new file mode 100644 index 0000000000..50d17f1885 --- /dev/null +++ b/typescript/lightclient/query_pb.d.ts @@ -0,0 +1,325 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file lightclient/query.proto (package zetachain.zetacore.lightclient, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; +import type { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination_pb.js"; +import type { BlockHeader, Proof } from "../pkg/proofs/proofs_pb.js"; +import type { ChainState } from "./chain_state_pb.js"; +import type { VerificationFlags } from "./verification_flags_pb.js"; + +/** + * @generated from message zetachain.zetacore.lightclient.QueryAllBlockHeaderRequest + */ +export declare class QueryAllBlockHeaderRequest extends Message { + /** + * @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 1; + */ + pagination?: PageRequest; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryAllBlockHeaderRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryAllBlockHeaderRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryAllBlockHeaderRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryAllBlockHeaderRequest; + + static equals(a: QueryAllBlockHeaderRequest | PlainMessage | undefined, b: QueryAllBlockHeaderRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryAllBlockHeaderResponse + */ +export declare class QueryAllBlockHeaderResponse extends Message { + /** + * @generated from field: repeated proofs.BlockHeader block_headers = 1; + */ + blockHeaders: BlockHeader[]; + + /** + * @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2; + */ + pagination?: PageResponse; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryAllBlockHeaderResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryAllBlockHeaderResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryAllBlockHeaderResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryAllBlockHeaderResponse; + + static equals(a: QueryAllBlockHeaderResponse | PlainMessage | undefined, b: QueryAllBlockHeaderResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryGetBlockHeaderRequest + */ +export declare class QueryGetBlockHeaderRequest extends Message { + /** + * @generated from field: bytes block_hash = 1; + */ + blockHash: Uint8Array; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryGetBlockHeaderRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetBlockHeaderRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetBlockHeaderRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryGetBlockHeaderRequest; + + static equals(a: QueryGetBlockHeaderRequest | PlainMessage | undefined, b: QueryGetBlockHeaderRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryGetBlockHeaderResponse + */ +export declare class QueryGetBlockHeaderResponse extends Message { + /** + * @generated from field: proofs.BlockHeader block_header = 1; + */ + blockHeader?: BlockHeader; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryGetBlockHeaderResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetBlockHeaderResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetBlockHeaderResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryGetBlockHeaderResponse; + + static equals(a: QueryGetBlockHeaderResponse | PlainMessage | undefined, b: QueryGetBlockHeaderResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryAllChainStateRequest + */ +export declare class QueryAllChainStateRequest extends Message { + /** + * @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 1; + */ + pagination?: PageRequest; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryAllChainStateRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryAllChainStateRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryAllChainStateRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryAllChainStateRequest; + + static equals(a: QueryAllChainStateRequest | PlainMessage | undefined, b: QueryAllChainStateRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryAllChainStateResponse + */ +export declare class QueryAllChainStateResponse extends Message { + /** + * @generated from field: repeated zetachain.zetacore.lightclient.ChainState chain_state = 1; + */ + chainState: ChainState[]; + + /** + * @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2; + */ + pagination?: PageResponse; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryAllChainStateResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryAllChainStateResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryAllChainStateResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryAllChainStateResponse; + + static equals(a: QueryAllChainStateResponse | PlainMessage | undefined, b: QueryAllChainStateResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryGetChainStateRequest + */ +export declare class QueryGetChainStateRequest extends Message { + /** + * @generated from field: int64 chain_id = 1; + */ + chainId: bigint; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryGetChainStateRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetChainStateRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetChainStateRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryGetChainStateRequest; + + static equals(a: QueryGetChainStateRequest | PlainMessage | undefined, b: QueryGetChainStateRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryGetChainStateResponse + */ +export declare class QueryGetChainStateResponse extends Message { + /** + * @generated from field: zetachain.zetacore.lightclient.ChainState chain_state = 1; + */ + chainState?: ChainState; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryGetChainStateResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetChainStateResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetChainStateResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryGetChainStateResponse; + + static equals(a: QueryGetChainStateResponse | PlainMessage | undefined, b: QueryGetChainStateResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryProveRequest + */ +export declare class QueryProveRequest extends Message { + /** + * @generated from field: int64 chain_id = 1; + */ + chainId: bigint; + + /** + * @generated from field: string tx_hash = 2; + */ + txHash: string; + + /** + * @generated from field: proofs.Proof proof = 3; + */ + proof?: Proof; + + /** + * @generated from field: string block_hash = 4; + */ + blockHash: string; + + /** + * @generated from field: int64 tx_index = 5; + */ + txIndex: bigint; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryProveRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryProveRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryProveRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryProveRequest; + + static equals(a: QueryProveRequest | PlainMessage | undefined, b: QueryProveRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryProveResponse + */ +export declare class QueryProveResponse extends Message { + /** + * @generated from field: bool valid = 1; + */ + valid: boolean; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryProveResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryProveResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryProveResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryProveResponse; + + static equals(a: QueryProveResponse | PlainMessage | undefined, b: QueryProveResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryVerificationFlagsRequest + */ +export declare class QueryVerificationFlagsRequest extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryVerificationFlagsRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryVerificationFlagsRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryVerificationFlagsRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryVerificationFlagsRequest; + + static equals(a: QueryVerificationFlagsRequest | PlainMessage | undefined, b: QueryVerificationFlagsRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.QueryVerificationFlagsResponse + */ +export declare class QueryVerificationFlagsResponse extends Message { + /** + * @generated from field: zetachain.zetacore.lightclient.VerificationFlags verification_flags = 1; + */ + verificationFlags?: VerificationFlags; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.QueryVerificationFlagsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryVerificationFlagsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryVerificationFlagsResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryVerificationFlagsResponse; + + static equals(a: QueryVerificationFlagsResponse | PlainMessage | undefined, b: QueryVerificationFlagsResponse | PlainMessage | undefined): boolean; +} + diff --git a/typescript/lightclient/tx_pb.d.ts b/typescript/lightclient/tx_pb.d.ts new file mode 100644 index 0000000000..48e827c654 --- /dev/null +++ b/typescript/lightclient/tx_pb.d.ts @@ -0,0 +1,57 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file lightclient/tx.proto (package zetachain.zetacore.lightclient, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; +import type { VerificationFlags } from "./verification_flags_pb.js"; + +/** + * @generated from message zetachain.zetacore.lightclient.MsgUpdateVerificationFlags + */ +export declare class MsgUpdateVerificationFlags extends Message { + /** + * @generated from field: string creator = 1; + */ + creator: string; + + /** + * @generated from field: zetachain.zetacore.lightclient.VerificationFlags verification_flags = 2; + */ + verificationFlags?: VerificationFlags; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.MsgUpdateVerificationFlags"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateVerificationFlags; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateVerificationFlags; + + static fromJsonString(jsonString: string, options?: Partial): MsgUpdateVerificationFlags; + + static equals(a: MsgUpdateVerificationFlags | PlainMessage | undefined, b: MsgUpdateVerificationFlags | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.lightclient.MsgUpdateVerificationFlagsResponse + */ +export declare class MsgUpdateVerificationFlagsResponse extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.MsgUpdateVerificationFlagsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateVerificationFlagsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateVerificationFlagsResponse; + + static fromJsonString(jsonString: string, options?: Partial): MsgUpdateVerificationFlagsResponse; + + static equals(a: MsgUpdateVerificationFlagsResponse | PlainMessage | undefined, b: MsgUpdateVerificationFlagsResponse | PlainMessage | undefined): boolean; +} + diff --git a/typescript/lightclient/verification_flags_pb.d.ts b/typescript/lightclient/verification_flags_pb.d.ts new file mode 100644 index 0000000000..d2325779b2 --- /dev/null +++ b/typescript/lightclient/verification_flags_pb.d.ts @@ -0,0 +1,39 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file lightclient/verification_flags.proto (package zetachain.zetacore.lightclient, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * VerificationFlags is a structure containing information which chain types are enabled for block header verification + * + * @generated from message zetachain.zetacore.lightclient.VerificationFlags + */ +export declare class VerificationFlags extends Message { + /** + * @generated from field: bool ethTypeChainEnabled = 1; + */ + ethTypeChainEnabled: boolean; + + /** + * @generated from field: bool btcTypeChainEnabled = 2; + */ + btcTypeChainEnabled: boolean; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.lightclient.VerificationFlags"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): VerificationFlags; + + static fromJson(jsonValue: JsonValue, options?: Partial): VerificationFlags; + + static fromJsonString(jsonString: string, options?: Partial): VerificationFlags; + + static equals(a: VerificationFlags | PlainMessage | undefined, b: VerificationFlags | PlainMessage | undefined): boolean; +} + diff --git a/typescript/observer/crosschain_flags_pb.d.ts b/typescript/observer/crosschain_flags_pb.d.ts index d293425314..7bbcc35aa4 100644 --- a/typescript/observer/crosschain_flags_pb.d.ts +++ b/typescript/observer/crosschain_flags_pb.d.ts @@ -56,6 +56,8 @@ export declare class GasPriceIncreaseFlags extends Message { @@ -104,6 +106,8 @@ export declare class CrosschainFlags extends Message { gasPriceIncreaseFlags?: GasPriceIncreaseFlags; /** + * Deprecated(v16): Use VerificationFlags in the lightclient module instead + * * @generated from field: zetachain.zetacore.observer.BlockHeaderVerificationFlags blockHeaderVerificationFlags = 4; */ blockHeaderVerificationFlags?: BlockHeaderVerificationFlags; diff --git a/typescript/observer/index.d.ts b/typescript/observer/index.d.ts index d6e795bd79..bb2d29105f 100644 --- a/typescript/observer/index.d.ts +++ b/typescript/observer/index.d.ts @@ -1,6 +1,5 @@ export * from "./ballot_pb"; export * from "./blame_pb"; -export * from "./block_header_pb"; export * from "./chain_nonces_pb"; export * from "./crosschain_flags_pb"; export * from "./events_pb"; diff --git a/typescript/observer/query_pb.d.ts b/typescript/observer/query_pb.d.ts index a98680eeb8..a5d8bef48f 100644 --- a/typescript/observer/query_pb.d.ts +++ b/typescript/observer/query_pb.d.ts @@ -9,7 +9,6 @@ import type { ChainNonces } from "./chain_nonces_pb.js"; import type { PageRequest, PageResponse } from "../cosmos/base/query/v1beta1/pagination_pb.js"; import type { PendingNonces } from "./pending_nonces_pb.js"; import type { TSS } from "./tss_pb.js"; -import type { BlockHeader, Proof } from "../pkg/proofs/proofs_pb.js"; import type { ChainParams, ChainParamsList, Params } from "./params_pb.js"; import type { BallotStatus, VoteType } from "./ballot_pb.js"; import type { LastObserverCount, ObservationType } from "./observer_pb.js"; @@ -18,7 +17,6 @@ import type { NodeAccount } from "./node_account_pb.js"; import type { CrosschainFlags } from "./crosschain_flags_pb.js"; import type { Keygen } from "./keygen_pb.js"; import type { Blame } from "./blame_pb.js"; -import type { BlockHeaderState } from "./block_header_pb.js"; /** * @generated from message zetachain.zetacore.observer.QueryGetChainNoncesRequest @@ -429,74 +427,6 @@ export declare class QueryTssHistoryResponse extends Message | undefined, b: QueryTssHistoryResponse | PlainMessage | undefined): boolean; } -/** - * @generated from message zetachain.zetacore.observer.QueryProveRequest - */ -export declare class QueryProveRequest extends Message { - /** - * @generated from field: int64 chain_id = 1; - */ - chainId: bigint; - - /** - * @generated from field: string tx_hash = 2; - */ - txHash: string; - - /** - * @generated from field: proofs.Proof proof = 3; - */ - proof?: Proof; - - /** - * @generated from field: string block_hash = 4; - */ - blockHash: string; - - /** - * @generated from field: int64 tx_index = 5; - */ - txIndex: bigint; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.QueryProveRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryProveRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryProveRequest; - - static fromJsonString(jsonString: string, options?: Partial): QueryProveRequest; - - static equals(a: QueryProveRequest | PlainMessage | undefined, b: QueryProveRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message zetachain.zetacore.observer.QueryProveResponse - */ -export declare class QueryProveResponse extends Message { - /** - * @generated from field: bool valid = 1; - */ - valid: boolean; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.QueryProveResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryProveResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryProveResponse; - - static fromJsonString(jsonString: string, options?: Partial): QueryProveResponse; - - static equals(a: QueryProveResponse | PlainMessage | undefined, b: QueryProveResponse | PlainMessage | undefined): boolean; -} - /** * @generated from message zetachain.zetacore.observer.QueryParamsRequest */ @@ -1250,152 +1180,3 @@ export declare class QueryBlameByChainAndNonceResponse extends Message | undefined, b: QueryBlameByChainAndNonceResponse | PlainMessage | undefined): boolean; } -/** - * @generated from message zetachain.zetacore.observer.QueryAllBlockHeaderRequest - */ -export declare class QueryAllBlockHeaderRequest extends Message { - /** - * @generated from field: cosmos.base.query.v1beta1.PageRequest pagination = 1; - */ - pagination?: PageRequest; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.QueryAllBlockHeaderRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryAllBlockHeaderRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryAllBlockHeaderRequest; - - static fromJsonString(jsonString: string, options?: Partial): QueryAllBlockHeaderRequest; - - static equals(a: QueryAllBlockHeaderRequest | PlainMessage | undefined, b: QueryAllBlockHeaderRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message zetachain.zetacore.observer.QueryAllBlockHeaderResponse - */ -export declare class QueryAllBlockHeaderResponse extends Message { - /** - * @generated from field: repeated proofs.BlockHeader block_headers = 1; - */ - blockHeaders: BlockHeader[]; - - /** - * @generated from field: cosmos.base.query.v1beta1.PageResponse pagination = 2; - */ - pagination?: PageResponse; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.QueryAllBlockHeaderResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryAllBlockHeaderResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryAllBlockHeaderResponse; - - static fromJsonString(jsonString: string, options?: Partial): QueryAllBlockHeaderResponse; - - static equals(a: QueryAllBlockHeaderResponse | PlainMessage | undefined, b: QueryAllBlockHeaderResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message zetachain.zetacore.observer.QueryGetBlockHeaderByHashRequest - */ -export declare class QueryGetBlockHeaderByHashRequest extends Message { - /** - * @generated from field: bytes block_hash = 1; - */ - blockHash: Uint8Array; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.QueryGetBlockHeaderByHashRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetBlockHeaderByHashRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetBlockHeaderByHashRequest; - - static fromJsonString(jsonString: string, options?: Partial): QueryGetBlockHeaderByHashRequest; - - static equals(a: QueryGetBlockHeaderByHashRequest | PlainMessage | undefined, b: QueryGetBlockHeaderByHashRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message zetachain.zetacore.observer.QueryGetBlockHeaderByHashResponse - */ -export declare class QueryGetBlockHeaderByHashResponse extends Message { - /** - * @generated from field: proofs.BlockHeader block_header = 1; - */ - blockHeader?: BlockHeader; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.QueryGetBlockHeaderByHashResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetBlockHeaderByHashResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetBlockHeaderByHashResponse; - - static fromJsonString(jsonString: string, options?: Partial): QueryGetBlockHeaderByHashResponse; - - static equals(a: QueryGetBlockHeaderByHashResponse | PlainMessage | undefined, b: QueryGetBlockHeaderByHashResponse | PlainMessage | undefined): boolean; -} - -/** - * @generated from message zetachain.zetacore.observer.QueryGetBlockHeaderStateRequest - */ -export declare class QueryGetBlockHeaderStateRequest extends Message { - /** - * @generated from field: int64 chain_id = 1; - */ - chainId: bigint; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.QueryGetBlockHeaderStateRequest"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetBlockHeaderStateRequest; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetBlockHeaderStateRequest; - - static fromJsonString(jsonString: string, options?: Partial): QueryGetBlockHeaderStateRequest; - - static equals(a: QueryGetBlockHeaderStateRequest | PlainMessage | undefined, b: QueryGetBlockHeaderStateRequest | PlainMessage | undefined): boolean; -} - -/** - * @generated from message zetachain.zetacore.observer.QueryGetBlockHeaderStateResponse - */ -export declare class QueryGetBlockHeaderStateResponse extends Message { - /** - * @generated from field: zetachain.zetacore.observer.BlockHeaderState block_header_state = 1; - */ - blockHeaderState?: BlockHeaderState; - - constructor(data?: PartialMessage); - - static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.QueryGetBlockHeaderStateResponse"; - static readonly fields: FieldList; - - static fromBinary(bytes: Uint8Array, options?: Partial): QueryGetBlockHeaderStateResponse; - - static fromJson(jsonValue: JsonValue, options?: Partial): QueryGetBlockHeaderStateResponse; - - static fromJsonString(jsonString: string, options?: Partial): QueryGetBlockHeaderStateResponse; - - static equals(a: QueryGetBlockHeaderStateResponse | PlainMessage | undefined, b: QueryGetBlockHeaderStateResponse | PlainMessage | undefined): boolean; -} - diff --git a/typescript/observer/tx_pb.d.ts b/typescript/observer/tx_pb.d.ts index 21fe737462..a32abd14db 100644 --- a/typescript/observer/tx_pb.d.ts +++ b/typescript/observer/tx_pb.d.ts @@ -71,9 +71,9 @@ export declare class MsgUpdateObserverResponse extends Message { +export declare class MsgVoteBlockHeader extends Message { /** * @generated from field: string creator = 1; */ @@ -99,38 +99,48 @@ export declare class MsgAddBlockHeader extends Message { */ header?: HeaderData; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.MsgAddBlockHeader"; + static readonly typeName = "zetachain.zetacore.observer.MsgVoteBlockHeader"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgAddBlockHeader; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgVoteBlockHeader; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgAddBlockHeader; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgVoteBlockHeader; - static fromJsonString(jsonString: string, options?: Partial): MsgAddBlockHeader; + static fromJsonString(jsonString: string, options?: Partial): MsgVoteBlockHeader; - static equals(a: MsgAddBlockHeader | PlainMessage | undefined, b: MsgAddBlockHeader | PlainMessage | undefined): boolean; + static equals(a: MsgVoteBlockHeader | PlainMessage | undefined, b: MsgVoteBlockHeader | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.observer.MsgAddBlockHeaderResponse + * @generated from message zetachain.zetacore.observer.MsgVoteBlockHeaderResponse */ -export declare class MsgAddBlockHeaderResponse extends Message { - constructor(data?: PartialMessage); +export declare class MsgVoteBlockHeaderResponse extends Message { + /** + * @generated from field: bool ballot_created = 1; + */ + ballotCreated: boolean; + + /** + * @generated from field: bool vote_finalized = 2; + */ + voteFinalized: boolean; + + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.observer.MsgAddBlockHeaderResponse"; + static readonly typeName = "zetachain.zetacore.observer.MsgVoteBlockHeaderResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgAddBlockHeaderResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgVoteBlockHeaderResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgAddBlockHeaderResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgVoteBlockHeaderResponse; - static fromJsonString(jsonString: string, options?: Partial): MsgAddBlockHeaderResponse; + static fromJsonString(jsonString: string, options?: Partial): MsgVoteBlockHeaderResponse; - static equals(a: MsgAddBlockHeaderResponse | PlainMessage | undefined, b: MsgAddBlockHeaderResponse | PlainMessage | undefined): boolean; + static equals(a: MsgVoteBlockHeaderResponse | PlainMessage | undefined, b: MsgVoteBlockHeaderResponse | PlainMessage | undefined): boolean; } /** diff --git a/x/crosschain/keeper/grpc_query_cctx.go b/x/crosschain/keeper/grpc_query_cctx.go index 74bdc49293..66e809b6b7 100644 --- a/x/crosschain/keeper/grpc_query_cctx.go +++ b/x/crosschain/keeper/grpc_query_cctx.go @@ -73,7 +73,7 @@ func (k Keeper) CctxByNonce(c context.Context, req *types.QueryGetCctxByNonceReq return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(c) - tss, found := k.zetaObserverKeeper.GetTSS(ctx) + tss, found := k.GetObserverKeeper().GetTSS(ctx) if !found { return nil, status.Error(codes.Internal, "tss not found") } diff --git a/x/crosschain/keeper/keeper.go b/x/crosschain/keeper/keeper.go index 0962323ca5..0bdad4fb06 100644 --- a/x/crosschain/keeper/keeper.go +++ b/x/crosschain/keeper/keeper.go @@ -22,6 +22,7 @@ type ( zetaObserverKeeper types.ObserverKeeper fungibleKeeper types.FungibleKeeper authorityKeeper types.AuthorityKeeper + lightclientKeeper types.LightclientKeeper } ) @@ -35,6 +36,7 @@ func NewKeeper( zetaObserverKeeper types.ObserverKeeper, fungibleKeeper types.FungibleKeeper, authorityKeeper types.AuthorityKeeper, + lightclientKeeper types.LightclientKeeper, ) *Keeper { // ensure governance module account is set // FIXME: enable this check! (disabled for now to avoid unit test panic) @@ -52,6 +54,7 @@ func NewKeeper( zetaObserverKeeper: zetaObserverKeeper, fungibleKeeper: fungibleKeeper, authorityKeeper: authorityKeeper, + lightclientKeeper: lightclientKeeper, } } @@ -83,6 +86,10 @@ func (k Keeper) GetAuthorityKeeper() types.AuthorityKeeper { return k.authorityKeeper } +func (k Keeper) GetLightclientKeeper() types.LightclientKeeper { + return k.lightclientKeeper +} + func (k Keeper) GetStoreKey() storetypes.StoreKey { return k.storeKey } diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker.go index 45952a2112..51e3a7763e 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker.go @@ -6,52 +6,71 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg/chains" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) // AddToInTxTracker adds a new record to the inbound transaction tracker. -// -// Authorized: admin policy group 1, observer. func (k msgServer) AddToInTxTracker(goCtx context.Context, msg *types.MsgAddToInTxTracker) (*types.MsgAddToInTxTrackerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - chain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, msg.ChainId) + chain := k.GetObserverKeeper().GetSupportedChainFromChainID(ctx, msg.ChainId) if chain == nil { return nil, observertypes.ErrSupportedChains } - isAdmin := k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupEmergency) - isObserver := k.zetaObserverKeeper.IsNonTombstonedObserver(ctx, msg.Creator) + // emergency or observer group can submit tracker without proof + isEmergencyGroup := k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupEmergency) + isObserver := k.GetObserverKeeper().IsNonTombstonedObserver(ctx, msg.Creator) - isProven := false - if !(isAdmin || isObserver) && msg.Proof != nil { - txBytes, err := k.VerifyProof(ctx, msg.Proof, msg.ChainId, msg.BlockHash, msg.TxIndex) - if err != nil { - return nil, types.ErrProofVerificationFail.Wrapf(err.Error()) + // only emergency group and observer can submit tracker without proof + // if the sender is not from the emergency group or observer, the inbound proof must be provided + if !(isEmergencyGroup || isObserver) { + if msg.Proof == nil { + return nil, errorsmod.Wrap(authoritytypes.ErrUnauthorized, fmt.Sprintf("Creator %s", msg.Creator)) } - if chains.IsEVMChain(msg.ChainId) { - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - if err != nil { - return nil, types.ErrTxBodyVerificationFail.Wrapf(err.Error()) - } - } else { - return nil, types.ErrTxBodyVerificationFail.Wrapf(fmt.Sprintf("cannot verify inTx body for chain %d", msg.ChainId)) + // verify the proof and tx body + if err := verifyProofAndInTxBody(ctx, k, msg); err != nil { + return nil, err } - isProven = true - } - - // Sender needs to be either the admin policy account or an observer - if !(isAdmin || isObserver || isProven) { - return nil, errorsmod.Wrap(authoritytypes.ErrUnauthorized, fmt.Sprintf("Creator %s", msg.Creator)) } + // add the inTx tracker k.SetInTxTracker(ctx, types.InTxTracker{ ChainId: msg.ChainId, TxHash: msg.TxHash, CoinType: msg.CoinType, }) + return &types.MsgAddToInTxTrackerResponse{}, nil } + +// verifyProofAndInTxBody verifies the proof and inbound tx body +func verifyProofAndInTxBody(ctx sdk.Context, k msgServer, msg *types.MsgAddToInTxTracker) error { + txBytes, err := k.GetLightclientKeeper().VerifyProof(ctx, msg.Proof, msg.ChainId, msg.BlockHash, msg.TxIndex) + if err != nil { + return types.ErrProofVerificationFail.Wrapf(err.Error()) + } + + // get chain params and tss addresses to verify the inTx body + chainParams, found := k.GetObserverKeeper().GetChainParamsByChainID(ctx, msg.ChainId) + if !found || chainParams == nil { + return types.ErrUnsupportedChain.Wrapf("chain params not found for chain %d", msg.ChainId) + } + tss, err := k.GetObserverKeeper().GetTssAddress(ctx, &observertypes.QueryGetTssAddressRequest{ + BitcoinChainId: msg.ChainId, + }) + if err != nil { + return observertypes.ErrTssNotFound.Wrapf(err.Error()) + } + if tss == nil { + return observertypes.ErrTssNotFound.Wrapf("tss address nil") + } + + if err := types.VerifyInTxBody(*msg, txBytes, *chainParams, *tss); err != nil { + return types.ErrTxBodyVerificationFail.Wrapf(err.Error()) + } + + return nil +} diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go index 5ab8eba308..a18d7e737a 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go @@ -1,10 +1,12 @@ package keeper_test import ( + "errors" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" - ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/stretchr/testify/mock" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/pkg/proofs" @@ -16,211 +18,314 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) -func setupVerificationParams(zk keepertest.ZetaKeepers, ctx sdk.Context, tx_index int64, chainID int64, header ethtypes.Header, headerRLP []byte, block *ethtypes.Block) { - params := zk.ObserverKeeper.GetParamsIfExists(ctx) - zk.ObserverKeeper.SetParams(ctx, params) - zk.ObserverKeeper.SetBlockHeader(ctx, proofs.BlockHeader{ - Height: block.Number().Int64(), - Hash: block.Hash().Bytes(), - ParentHash: header.ParentHash.Bytes(), - ChainId: chainID, - Header: proofs.NewEthereumHeader(headerRLP), - }) - zk.ObserverKeeper.SetChainParamsList(ctx, observertypes.ChainParamsList{ChainParams: []*observertypes.ChainParams{ - { - ChainId: chainID, - ConnectorContractAddress: block.Transactions()[tx_index].To().Hex(), - BallotThreshold: sdk.OneDec(), - MinObserverDelegation: sdk.OneDec(), - IsSupported: true, - }, - }}) - zk.ObserverKeeper.SetCrosschainFlags(ctx, observertypes.CrosschainFlags{ - BlockHeaderVerificationFlags: &observertypes.BlockHeaderVerificationFlags{ - IsEthTypeChainEnabled: true, - IsBtcTypeChainEnabled: false, - }, - }) -} - func TestMsgServer_AddToInTxTracker(t *testing.T) { t.Run("fail normal user submit without proof", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - tx_hash := "string" + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) - chainID := getValidEthChainID(t) - setSupportedChain(ctx, zk, chainID) + nonAdmin := sample.AccAddress() - msgServer := keeper.NewMsgServerImpl(*k) + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, nonAdmin, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + + txHash := "string" + chainID := getValidEthChainID(t) _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ - Creator: sample.AccAddress(), + Creator: nonAdmin, ChainId: chainID, - TxHash: tx_hash, + TxHash: txHash, CoinType: coin.CoinType_Zeta, Proof: nil, BlockHash: "", TxIndex: 0, }) require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) - _, found := k.GetInTxTracker(ctx, chainID, tx_hash) + _, found := k.GetInTxTracker(ctx, chainID, txHash) require.False(t, found) }) t.Run("fail for unsupported chain id", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - tx_hash := "string" + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) - chainID := getValidEthChainID(t) - setSupportedChain(ctx, zk, chainID) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(nil) - msgServer := keeper.NewMsgServerImpl(*k) + txHash := "string" + chainID := getValidEthChainID(t) _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: sample.AccAddress(), ChainId: chainID + 1, - TxHash: tx_hash, + TxHash: txHash, CoinType: coin.CoinType_Zeta, Proof: nil, BlockHash: "", TxIndex: 0, }) require.ErrorIs(t, err, observertypes.ErrSupportedChains) - _, found := k.GetInTxTracker(ctx, chainID, tx_hash) + _, found := k.GetInTxTracker(ctx, chainID, txHash) require.False(t, found) }) t.Run("admin add tx tracker", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, + UseObserverMock: true, }) + msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) - tx_hash := "string" + txHash := "string" chainID := getValidEthChainID(t) setSupportedChain(ctx, zk, chainID) + _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + CoinType: coin.CoinType_Zeta, + Proof: nil, + BlockHash: "", + TxIndex: 0, + }) + require.NoError(t, err) + _, found := k.GetInTxTracker(ctx, chainID, txHash) + require.True(t, found) + }) + + t.Run("observer add tx tracker", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + }) msgServer := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, mock.Anything, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(true) + + txHash := "string" + chainID := getValidEthChainID(t) + _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: admin, ChainId: chainID, - TxHash: tx_hash, + TxHash: txHash, CoinType: coin.CoinType_Zeta, Proof: nil, BlockHash: "", TxIndex: 0, }) require.NoError(t, err) - _, found := k.GetInTxTracker(ctx, chainID, tx_hash) + _, found := k.GetInTxTracker(ctx, chainID, txHash) require.True(t, found) }) - t.Run("admin submit fake tracker", func(t *testing.T) { + t.Run("fail if proof is provided but not verified", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseLightclientMock: true, + UseObserverMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, mock.Anything, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, errors.New("error")) + + txHash := "string" + chainID := getValidEthChainID(t) + + _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + CoinType: coin.CoinType_Zeta, + Proof: &proofs.Proof{}, + BlockHash: "", + TxIndex: 0, + }) + require.ErrorIs(t, err, types.ErrProofVerificationFail) + }) + + t.Run("fail if proof is provided but can't find chain params to verify body", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseLightclientMock: true, + UseObserverMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, mock.Anything, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(sample.Bytes(), nil) + observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(nil, false) + + txHash := "string" + chainID := getValidEthChainID(t) + + _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + CoinType: coin.CoinType_Zeta, + Proof: &proofs.Proof{}, + BlockHash: "", + TxIndex: 0, + }) + require.ErrorIs(t, err, types.ErrUnsupportedChain) + }) + + t.Run("fail if proof is provided but can't find tss to verify body", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseAuthorityMock: true, + UseAuthorityMock: true, + UseLightclientMock: true, + UseObserverMock: true, }) + msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) - tx_hash := "string" + keepertest.MockIsAuthorized(&authorityMock.Mock, mock.Anything, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(sample.Bytes(), nil) + observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain().ChainId), true) + observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(nil, errors.New("error")) + + txHash := "string" chainID := getValidEthChainID(t) setSupportedChain(ctx, zk, chainID) + _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + CoinType: coin.CoinType_Zeta, + Proof: &proofs.Proof{}, + BlockHash: "", + TxIndex: 0, + }) + require.ErrorIs(t, err, observertypes.ErrTssNotFound) + }) + + t.Run("fail if proof is provided but error while verifying tx body", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseLightclientMock: true, + UseObserverMock: true, + }) msgServer := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, mock.Anything, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain().ChainId), true) + observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ + Eth: sample.EthAddress().Hex(), + }, nil) + + // verifying the body will fail because the bytes are tried to be unmarshaled but they are not valid + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]byte("invalid"), nil) + + txHash := "string" + chainID := getValidEthChainID(t) + setSupportedChain(ctx, zk, chainID) + _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: admin, ChainId: chainID, - TxHash: "Malicious TX HASH", + TxHash: txHash, CoinType: coin.CoinType_Zeta, - Proof: nil, + Proof: &proofs.Proof{}, + BlockHash: "", + TxIndex: 0, + }) + require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) + }) + + t.Run("can add a in tx tracker with a proof", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseLightclientMock: true, + UseObserverMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + + chainID := chains.EthChain().ChainId + tssAddress := sample.EthAddress() + ethTx, ethTxBytes := sample.EthTx(t, chainID, tssAddress, 42) + txHash := ethTx.Hash().Hex() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, mock.Anything, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(sample.ChainParams(chains.EthChain().ChainId), true) + observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ + Eth: tssAddress.Hex(), + }, nil) + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(ethTxBytes, nil) + + _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + CoinType: coin.CoinType_Gas, // use coin types gas: the receiver must be the tss address + Proof: &proofs.Proof{}, BlockHash: "", TxIndex: 0, }) require.NoError(t, err) - _, found := k.GetInTxTracker(ctx, chainID, "Malicious TX HASH") + _, found := k.GetInTxTracker(ctx, chainID, txHash) require.True(t, found) - _, found = k.GetInTxTracker(ctx, chainID, tx_hash) - require.False(t, found) }) - - // Commented out as these tests don't work without using RPC - // TODO: Reenable these tests - // https://github.com/zeta-chain/node/issues/1875 - //t.Run("add proof based tracker with correct proof", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := int64(5) - // - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: chainID, - // TxHash: tx.Hash().Hex(), - // CoinType: pkg.CoinType_Zeta, - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // }) - // require.NoError(t, err) - // _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - // require.True(t, found) - //}) - //t.Run("fail to add proof based tracker with wrong tx hash", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := getValidEthChainID(t) - // - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: chainID, - // TxHash: "fake_hash", - // CoinType: pkg.CoinType_Zeta, - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // }) - // require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) - // _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - // require.False(t, found) - //}) - //t.Run("fail to add proof based tracker with wrong chain id", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := getValidEthChainID(t) - // - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: 97, - // TxHash: tx.Hash().Hex(), - // CoinType: pkg.CoinType_Zeta, - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // }) - // require.ErrorIs(t, err, observertypes.ErrSupportedChains) - // _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - // require.False(t, found) - //}) } diff --git a/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go b/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go index b0c5f4e2db..9031d0bfe5 100644 --- a/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go +++ b/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go @@ -3,29 +3,27 @@ package keeper import ( "context" "fmt" - "math/big" "strings" cosmoserrors "cosmossdk.io/errors" - "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcutil" sdk "github.com/cosmos/cosmos-sdk/types" - eth "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/zeta-chain/zetacore/pkg/chains" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) +// MaxOutTxTrackerHashes is the maximum number of hashes that can be stored in the outbound transaction tracker +const MaxOutTxTrackerHashes = 2 + // AddToOutTxTracker adds a new record to the outbound transaction tracker. // only the admin policy account and the observer validators are authorized to broadcast this message without proof. // If no pending cctx is found, the tracker is removed, if there is an existed tracker with the nonce & chainID. -// -// Authorized: admin policy group 1, observer. func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToOutTxTracker) (*types.MsgAddToOutTxTrackerResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - chain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, msg.ChainId) + + // check the chain is supported + chain := k.GetObserverKeeper().GetSupportedChainFromChainID(ctx, msg.ChainId) if chain == nil { return nil, observertypes.ErrSupportedChains } @@ -36,180 +34,112 @@ func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToO Nonce: msg.Nonce, }) if err != nil { - return nil, cosmoserrors.Wrap(err, "CcxtByNonce failed") + return nil, cosmoserrors.Wrap(types.ErrCannotFindCctx, err.Error()) } if cctx == nil || cctx.CrossChainTx == nil { return nil, cosmoserrors.Wrapf(types.ErrCannotFindCctx, "no corresponding cctx found for chain %d, nonce %d", msg.ChainId, msg.Nonce) } + // tracker submission is only allowed when the cctx is pending if !IsPending(*cctx.CrossChainTx) { - // garbage tracker (for any reason) is harmful to outTx observation and should be removed + // garbage tracker (for any reason) is harmful to outTx observation and should be removed if it exists + // it if does not exist, RemoveOutTxTracker is a no-op k.RemoveOutTxTracker(ctx, msg.ChainId, msg.Nonce) return &types.MsgAddToOutTxTrackerResponse{IsRemoved: true}, nil } - if msg.Proof == nil { // without proof, only certain accounts can send this message - isAdmin := k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupEmergency) - isObserver := k.zetaObserverKeeper.IsNonTombstonedObserver(ctx, msg.Creator) + isEmergencyGroup := k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupEmergency) + isObserver := k.GetObserverKeeper().IsNonTombstonedObserver(ctx, msg.Creator) + isProven := false - // Sender needs to be either the admin policy account or an observer - if !(isAdmin || isObserver) { + // only emergency group and observer can submit tracker without proof + // if the sender is not from the emergency group or observer, the outbound proof must be provided + if !(isEmergencyGroup || isObserver) { + if msg.Proof == nil { return nil, cosmoserrors.Wrap(authoritytypes.ErrUnauthorized, fmt.Sprintf("Creator %s", msg.Creator)) } - } - - isProven := false - if msg.Proof != nil { // verify proof when it is provided - txBytes, err := k.VerifyProof(ctx, msg.Proof, msg.ChainId, msg.BlockHash, msg.TxIndex) - if err != nil { - return nil, types.ErrProofVerificationFail.Wrapf(err.Error()) - } - err = k.VerifyOutTxBody(ctx, msg, txBytes) - if err != nil { - return nil, types.ErrTxBodyVerificationFail.Wrapf(err.Error()) + // verify proof when it is provided + if err := verifyProofAndOutTxBody(ctx, k, msg); err != nil { + return nil, err } + isProven = true } + // fetch the tracker + // if the tracker does not exist, initialize a new one tracker, found := k.GetOutTxTracker(ctx, msg.ChainId, msg.Nonce) hash := types.TxHashList{ TxHash: msg.TxHash, TxSigner: msg.Creator, + Proved: isProven, } if !found { k.SetOutTxTracker(ctx, types.OutTxTracker{ Index: "", - ChainId: chain.ChainId, + ChainId: msg.ChainId, Nonce: msg.Nonce, HashList: []*types.TxHashList{&hash}, }) - ctx.Logger().Info(fmt.Sprintf("Add tracker %s: , Block Height : %d ", getOutTrackerIndex(chain.ChainId, msg.Nonce), ctx.BlockHeight())) return &types.MsgAddToOutTxTrackerResponse{}, nil } - var isDup = false - for _, hash := range tracker.HashList { + // check if the hash is already in the tracker + for i, hash := range tracker.HashList { + hash := hash if strings.EqualFold(hash.TxHash, msg.TxHash) { - isDup = true + // if the hash is already in the tracker but we have a proof, mark it as proven and only keep this one in the list if isProven { - hash.Proved = true + tracker.HashList[i].Proved = true k.SetOutTxTracker(ctx, tracker) - k.Logger(ctx).Info("Proof'd outbound transaction") - return &types.MsgAddToOutTxTrackerResponse{}, nil } - break + return &types.MsgAddToOutTxTrackerResponse{}, nil } } - if !isDup { - if isProven { - hash.Proved = true - tracker.HashList = append([]*types.TxHashList{&hash}, tracker.HashList...) - k.Logger(ctx).Info("Proof'd outbound transaction") - } else if len(tracker.HashList) < 2 { - tracker.HashList = append(tracker.HashList, &hash) - } - k.SetOutTxTracker(ctx, tracker) + + // check if max hashes are reached + if len(tracker.HashList) >= MaxOutTxTrackerHashes { + return nil, types.ErrMaxTxOutTrackerHashesReached.Wrapf( + "max hashes reached for chain %d, nonce %d, hash number: %d", + msg.ChainId, + msg.Nonce, + len(tracker.HashList), + ) } + + // add the tracker to the list + tracker.HashList = append(tracker.HashList, &hash) + k.SetOutTxTracker(ctx, tracker) return &types.MsgAddToOutTxTrackerResponse{}, nil } -func (k Keeper) VerifyOutTxBody(ctx sdk.Context, msg *types.MsgAddToOutTxTracker, txBytes []byte) error { +// verifyProofAndOutTxBody verifies the proof and outbound tx body +// Precondition: the proof must be non-nil +func verifyProofAndOutTxBody(ctx sdk.Context, k msgServer, msg *types.MsgAddToOutTxTracker) error { + txBytes, err := k.lightclientKeeper.VerifyProof(ctx, msg.Proof, msg.ChainId, msg.BlockHash, msg.TxIndex) + if err != nil { + return types.ErrProofVerificationFail.Wrapf(err.Error()) + } + // get tss address var bitcoinChainID int64 if chains.IsBitcoinChain(msg.ChainId) { bitcoinChainID = msg.ChainId } - tss, err := k.zetaObserverKeeper.GetTssAddress(ctx, &observertypes.QueryGetTssAddressRequest{ + + tss, err := k.GetObserverKeeper().GetTssAddress(ctx, &observertypes.QueryGetTssAddressRequest{ BitcoinChainId: bitcoinChainID, }) if err != nil { - return err + return observertypes.ErrTssNotFound.Wrapf(err.Error()) } - - // verify message against transaction body - if chains.IsEVMChain(msg.ChainId) { - err = VerifyEVMOutTxBody(msg, txBytes, tss.Eth) - } else if chains.IsBitcoinChain(msg.ChainId) { - err = VerifyBTCOutTxBody(msg, txBytes, tss.Btc) - } else { - return fmt.Errorf("cannot verify outTx body for chain %d", msg.ChainId) + if tss == nil { + return observertypes.ErrTssNotFound.Wrapf("tss address nil") } - return err -} -// VerifyEVMOutTxBody validates the sender address, nonce, chain id and tx hash. -// Note: 'msg' may contain fabricated information -func VerifyEVMOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssEth string) error { - var txx ethtypes.Transaction - err := txx.UnmarshalBinary(txBytes) - if err != nil { - return err - } - signer := ethtypes.NewLondonSigner(txx.ChainId()) - sender, err := ethtypes.Sender(signer, &txx) - if err != nil { - return err - } - tssAddr := eth.HexToAddress(tssEth) - if tssAddr == (eth.Address{}) { - return fmt.Errorf("tss address not found") - } - if sender != tssAddr { - return fmt.Errorf("sender %s is not tss address", sender) - } - if txx.ChainId().Cmp(big.NewInt(msg.ChainId)) != 0 { - return fmt.Errorf("want evm chain id %d, got %d", txx.ChainId(), msg.ChainId) - } - if txx.Nonce() != msg.Nonce { - return fmt.Errorf("want nonce %d, got %d", txx.Nonce(), msg.Nonce) - } - if txx.Hash().Hex() != msg.TxHash { - return fmt.Errorf("want tx hash %s, got %s", txx.Hash().Hex(), msg.TxHash) + if err := types.VerifyOutTxBody(*msg, txBytes, *tss); err != nil { + return types.ErrTxBodyVerificationFail.Wrapf(err.Error()) } - return nil -} -// VerifyBTCOutTxBody validates the SegWit sender address, nonce and chain id and tx hash -// Note: 'msg' may contain fabricated information -func VerifyBTCOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssBtc string) error { - if !chains.IsBitcoinChain(msg.ChainId) { - return fmt.Errorf("not a Bitcoin chain ID %d", msg.ChainId) - } - tx, err := btcutil.NewTxFromBytes(txBytes) - if err != nil { - return err - } - for _, vin := range tx.MsgTx().TxIn { - if len(vin.Witness) != 2 { // outTx is SegWit transaction for now - return fmt.Errorf("not a SegWit transaction") - } - pubKey, err := btcec.ParsePubKey(vin.Witness[1], btcec.S256()) - if err != nil { - return fmt.Errorf("failed to parse public key") - } - bitcoinNetParams, err := chains.BitcoinNetParamsFromChainID(msg.ChainId) - if err != nil { - return fmt.Errorf("failed to get Bitcoin net params, error %s", err.Error()) - } - addrP2WPKH, err := btcutil.NewAddressWitnessPubKeyHash( - btcutil.Hash160(pubKey.SerializeCompressed()), - bitcoinNetParams, - ) - if err != nil { - return fmt.Errorf("failed to create P2WPKH address") - } - if addrP2WPKH.EncodeAddress() != tssBtc { - return fmt.Errorf("sender %s is not tss address", addrP2WPKH.EncodeAddress()) - } - } - if len(tx.MsgTx().TxOut) < 1 { - return fmt.Errorf("outTx should have at least one output") - } - if tx.MsgTx().TxOut[0].Value != chains.NonceMarkAmount(msg.Nonce) { - return fmt.Errorf("want nonce mark %d, got %d", tx.MsgTx().TxOut[0].Value, chains.NonceMarkAmount(msg.Nonce)) - } - if tx.MsgTx().TxHash().String() != msg.TxHash { - return fmt.Errorf("want tx hash %s, got %s", tx.MsgTx().TxHash(), msg.TxHash) - } return nil } diff --git a/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go index 010486017d..2de8a61606 100644 --- a/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go @@ -1,10 +1,13 @@ package keeper_test import ( + "errors" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -17,89 +20,145 @@ func getEthereumChainID() int64 { return 5 // Goerli } -// setEnabledChain sets the chain as enabled in chain params -func setEnabledChain(ctx sdk.Context, zk keepertest.ZetaKeepers, chainID int64) { - zk.ObserverKeeper.SetChainParamsList(ctx, observertypes.ChainParamsList{ChainParams: []*observertypes.ChainParams{ - { - ChainId: chainID, - ConnectorContractAddress: sample.EthAddress().Hex(), - BallotThreshold: sdk.OneDec(), - MinObserverDelegation: sdk.OneDec(), - IsSupported: true, - }, - }}) -} - -// setupTssAndNonceToCctx sets tss and nonce to cctx -func setupTssAndNonceToCctx(k *keeper.Keeper, ctx sdk.Context, chainId, nonce int64, status types.CctxStatus) { - tssPubKey := "zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p" - k.GetObserverKeeper().SetTSS(ctx, observertypes.TSS{ - TssPubkey: tssPubKey, - }) - k.GetObserverKeeper().SetPendingNonces(ctx, observertypes.PendingNonces{ - Tss: tssPubKey, - NonceLow: 0, - NonceHigh: 1, - ChainId: chainId, - }) - cctx := types.CrossChainTx{ - Creator: "any", - Index: "0x123", - CctxStatus: &types.Status{ - Status: status, - }, - } - k.SetCrossChainTx(ctx, cctx) - k.GetObserverKeeper().SetNonceToCctx(ctx, observertypes.NonceToCctx{ - ChainId: chainId, - Nonce: nonce, - CctxIndex: "0x123", - Tss: "zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p", - }) -} +// TODO: Add a test case with proof and Bitcoin chain +// https://github.com/zeta-chain/node/issues/1994 func TestMsgServer_AddToOutTxTracker(t *testing.T) { - t.Run("add tracker admin", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + t.Run("admin can add tracker", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, + UseObserverMock: true, }) + msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) chainID := getEthereumChainID() - setupTssAndNonceToCctx(k, ctx, chainID, 0, types.CctxStatus_PendingOutbound) - setEnabledChain(ctx, zk, chainID) + hash := sample.Hash().Hex() + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: hash, + Proof: nil, + BlockHash: "", + TxIndex: 0, + Nonce: 0, + }) + require.NoError(t, err) + tracker, found := k.GetOutTxTracker(ctx, chainID, 0) + require.True(t, found) + require.Equal(t, hash, tracker.HashList[0].TxHash) + }) + + t.Run("observer can add tracker", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + }) msgServer := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(true) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) + + chainID := getEthereumChainID() + hash := sample.Hash().Hex() + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: admin, ChainId: chainID, - TxHash: sample.Hash().Hex(), + TxHash: hash, Proof: nil, BlockHash: "", TxIndex: 0, Nonce: 0, }) require.NoError(t, err) - _, found := k.GetOutTxTracker(ctx, chainID, 0) + tracker, found := k.GetOutTxTracker(ctx, chainID, 0) require.True(t, found) + require.Equal(t, hash, tracker.HashList[0].TxHash) }) - t.Run("should return early if cctx not pending", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + t.Run("can add hash to existing tracker", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, + UseObserverMock: true, }) + msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) + chainID := getEthereumChainID() - setupTssAndNonceToCctx(k, ctx, chainID, 0, types.CctxStatus_OutboundMined) - setEnabledChain(ctx, zk, chainID) + existinghHash := sample.Hash().Hex() + newHash := sample.Hash().Hex() + + k.SetOutTxTracker(ctx, types.OutTxTracker{ + ChainId: chainID, + Nonce: 42, + HashList: []*types.TxHashList{ + { + TxHash: existinghHash, + }, + }, + }) + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: newHash, + Proof: nil, + BlockHash: "", + TxIndex: 0, + Nonce: 42, + }) + require.NoError(t, err) + tracker, found := k.GetOutTxTracker(ctx, chainID, 42) + require.True(t, found) + require.Len(t, tracker.HashList, 2) + require.EqualValues(t, existinghHash, tracker.HashList[0].TxHash) + require.EqualValues(t, newHash, tracker.HashList[1].TxHash) + }) + + t.Run("should return early if cctx not pending", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + }) msgServer := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + observerMock := keepertest.GetCrosschainObserverMock(t, k) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + + // set cctx status to outbound mined + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_OutboundMined, false) + + chainID := getEthereumChainID() + res, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: admin, ChainId: chainID, @@ -111,46 +170,53 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { }) require.NoError(t, err) require.Equal(t, &types.MsgAddToOutTxTrackerResponse{IsRemoved: true}, res) + + // check if tracker is removed _, found := k.GetOutTxTracker(ctx, chainID, 0) require.False(t, found) }) t.Run("should error for unsupported chain", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, + UseObserverMock: true, }) + msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() - chainID := getEthereumChainID() - setupTssAndNonceToCctx(k, ctx, chainID, 0, types.CctxStatus_PendingOutbound) - setEnabledChain(ctx, zk, chainID) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(nil) - msgServer := keeper.NewMsgServerImpl(*k) + chainID := getEthereumChainID() _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: admin, - ChainId: chainID + 1, + ChainId: chainID, TxHash: sample.Hash().Hex(), Proof: nil, BlockHash: "", TxIndex: 0, Nonce: 0, }) - require.Error(t, err) + require.ErrorIs(t, err, observertypes.ErrSupportedChains) }) - t.Run("should error if no tss", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + t.Run("should error if no CctxByNonce", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, + UseObserverMock: true, }) + msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() - chainID := getEthereumChainID() - setEnabledChain(ctx, zk, chainID) + observerMock := keepertest.GetCrosschainObserverMock(t, k) - msgServer := keeper.NewMsgServerImpl(*k) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, true) + + chainID := getEthereumChainID() _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: admin, @@ -161,297 +227,310 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { TxIndex: 0, Nonce: 0, }) - require.Error(t, err) + require.ErrorIs(t, err, types.ErrCannotFindCctx) }) - t.Run("should error if no cctx", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + t.Run("should fail if max tracker hashes reached", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, + UseObserverMock: true, }) + msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) + + hashes := make([]*types.TxHashList, keeper.MaxOutTxTrackerHashes) + for i := 0; i < keeper.MaxOutTxTrackerHashes; i++ { + hashes[i] = &types.TxHashList{ + TxHash: sample.Hash().Hex(), + } + } + chainID := getEthereumChainID() - setEnabledChain(ctx, zk, chainID) + newHash := sample.Hash().Hex() - msgServer := keeper.NewMsgServerImpl(*k) + k.SetOutTxTracker(ctx, types.OutTxTracker{ + ChainId: chainID, + Nonce: 42, + HashList: hashes, + }) _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: admin, ChainId: chainID, - TxHash: sample.Hash().Hex(), + TxHash: newHash, Proof: nil, BlockHash: "", TxIndex: 0, - Nonce: 0, + Nonce: 42, }) - require.Error(t, err) + require.ErrorIs(t, err, types.ErrMaxTxOutTrackerHashesReached) }) - t.Run("unable to add tracker admin exceeding maximum allowed length of hashlist without proof", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + t.Run("no hash added if already exist", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, + UseObserverMock: true, }) + msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) chainID := getEthereumChainID() - setupTssAndNonceToCctx(k, ctx, chainID, 0, types.CctxStatus_PendingOutbound) - setEnabledChain(ctx, zk, chainID) + existinghHash := sample.Hash().Hex() k.SetOutTxTracker(ctx, types.OutTxTracker{ ChainId: chainID, - Nonce: 0, + Nonce: 42, HashList: []*types.TxHashList{ { - TxHash: "hash1", - TxSigner: sample.AccAddress(), - Proved: false, - }, - { - TxHash: "hash2", - TxSigner: sample.AccAddress(), - Proved: false, + TxHash: existinghHash, }, }, }) + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: existinghHash, + Proof: nil, + BlockHash: "", + TxIndex: 0, + Nonce: 42, + }) + require.NoError(t, err) + tracker, found := k.GetOutTxTracker(ctx, chainID, 42) + require.True(t, found) + require.Len(t, tracker.HashList, 1) + require.EqualValues(t, existinghHash, tracker.HashList[0].TxHash) + }) + + t.Run("can add tracker with proof", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + UseLightclientMock: true, + }) msgServer := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + chainID := getEthereumChainID() + ethTx, ethTxBytes, tssAddress := sample.EthTxSigned(t, chainID, sample.EthAddress(), 42) + txHash := ethTx.Hash().Hex() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) + observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ + Eth: tssAddress.Hex(), + }, nil) + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(ethTxBytes, nil) + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: admin, ChainId: chainID, - TxHash: sample.Hash().Hex(), - Proof: nil, + TxHash: txHash, + Proof: &proofs.Proof{}, BlockHash: "", TxIndex: 0, - Nonce: 0, + Nonce: 42, }) require.NoError(t, err) - tracker, found := k.GetOutTxTracker(ctx, chainID, 0) + tracker, found := k.GetOutTxTracker(ctx, chainID, 42) require.True(t, found) - require.Equal(t, 2, len(tracker.HashList)) + require.EqualValues(t, txHash, tracker.HashList[0].TxHash) + require.True(t, tracker.HashList[0].Proved) }) - // Commented out as these tests don't work without using RPC - // TODO: Reenable these tests - // https://github.com/zeta-chain/node/issues/1875 - //t.Run("fail add proof based tracker with wrong chainID", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := getEthereumChainID() - // - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - // - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: 97, - // TxHash: tx.Hash().Hex(), - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // Nonce: tx.Nonce(), - // }) - // require.ErrorIs(t, err, observertypes.ErrSupportedChains) - // _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - // require.False(t, found) - //}) - // - //t.Run("fail add proof based tracker with wrong nonce", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := getEthereumChainID() - // - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // setupTssAndNonceToCctx(k, ctx, chainID, 1) - // - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: chainID, - // TxHash: tx.Hash().Hex(), - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // Nonce: 1, - // }) - // require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) - // _, found := k.GetOutTxTracker(ctx, chainID, 1) - // require.False(t, found) - //}) - // - //t.Run("fail add proof based tracker with wrong tx_hash", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := getEthereumChainID() - // - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - // - // msgServer := keeper.NewMsgServerImpl(*k) - // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: chainID, - // TxHash: "wrong_hash", - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // Nonce: tx.Nonce(), - // }) - // require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) - // _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - // require.False(t, found) - //}) - // - //t.Run("fail proof based tracker with incorrect proof", func(t *testing.T) { - // - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // chainID := getEthereumChainID() - // - // txIndex, block, header, headerRLP, _, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - // - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: chainID, - // TxHash: tx.Hash().Hex(), - // Proof: common.NewEthereumProof(ethereum.NewProof()), - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // Nonce: tx.Nonce(), - // }) - // require.ErrorIs(t, err, types.ErrProofVerificationFail) - // _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - // require.False(t, found) - //}) - // - //t.Run("add proof based tracker with correct proof", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := getEthereumChainID() - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - // - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: chainID, - // TxHash: tx.Hash().Hex(), - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // Nonce: tx.Nonce(), - // }) - // require.NoError(t, err) - // _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - // require.True(t, found) - //}) - // - //t.Run("add proven txHash even if length of hashList is already 2", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := getEthereumChainID() - // - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - // k.SetOutTxTracker(ctx, types.OutTxTracker{ - // ChainId: chainID, - // Nonce: tx.Nonce(), - // HashList: []*types.TxHashList{ - // { - // TxHash: "hash1", - // TxSigner: sample.AccAddress(), - // Proved: false, - // }, - // { - // TxHash: "hash2", - // TxSigner: sample.AccAddress(), - // Proved: false, - // }, - // }, - // }) - // - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: chainID, - // TxHash: tx.Hash().Hex(), - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // Nonce: tx.Nonce(), - // }) - // require.NoError(t, err) - // tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - // require.True(t, found) - // require.Equal(t, 3, len(tracker.HashList)) - // // Proven tracker is prepended to the list - // require.True(t, tracker.HashList[0].Proved) - // require.False(t, tracker.HashList[1].Proved) - // require.False(t, tracker.HashList[2].Proved) - //}) - // - //t.Run("add proof for existing txHash", func(t *testing.T) { - // k, ctx, _, zk := keepertest.CrosschainKeeper(t) - // - // chainID := getEthereumChainID() - // - // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - // require.NoError(t, err) - // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - // k.SetOutTxTracker(ctx, types.OutTxTracker{ - // ChainId: chainID, - // Nonce: tx.Nonce(), - // HashList: []*types.TxHashList{ - // { - // TxHash: tx.Hash().Hex(), - // TxSigner: sample.AccAddress(), - // Proved: false, - // }, - // }, - // }) - // tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - // require.True(t, found) - // require.False(t, tracker.HashList[0].Proved) - // - // msgServer := keeper.NewMsgServerImpl(*k) - // - // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - // Creator: sample.AccAddress(), - // ChainId: chainID, - // TxHash: tx.Hash().Hex(), - // Proof: proof, - // BlockHash: block.Hash().Hex(), - // TxIndex: txIndex, - // Nonce: tx.Nonce(), - // }) - // require.NoError(t, err) - // tracker, found = k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - // require.True(t, found) - // require.Equal(t, 1, len(tracker.HashList)) - // require.True(t, tracker.HashList[0].Proved) - //}) + t.Run("adding existing hash with proof make it proven", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + UseLightclientMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + chainID := getEthereumChainID() + ethTx, ethTxBytes, tssAddress := sample.EthTxSigned(t, chainID, sample.EthAddress(), 42) + txHash := ethTx.Hash().Hex() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) + observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ + Eth: tssAddress.Hex(), + }, nil) + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(ethTxBytes, nil) + + k.SetOutTxTracker(ctx, types.OutTxTracker{ + ChainId: chainID, + Nonce: 42, + HashList: []*types.TxHashList{ + { + TxHash: sample.Hash().Hex(), + Proved: false, + }, + { + TxHash: txHash, + Proved: false, + }, + }, + }) + + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + Proof: &proofs.Proof{}, + BlockHash: "", + TxIndex: 0, + Nonce: 42, + }) + require.NoError(t, err) + tracker, found := k.GetOutTxTracker(ctx, chainID, 42) + require.True(t, found) + require.Len(t, tracker.HashList, 2) + require.EqualValues(t, txHash, tracker.HashList[1].TxHash) + require.True(t, tracker.HashList[1].Proved) + }) + + t.Run("should fail if verify proof fail", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + UseLightclientMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + chainID := getEthereumChainID() + ethTx, ethTxBytes, _ := sample.EthTxSigned(t, chainID, sample.EthAddress(), 42) + txHash := ethTx.Hash().Hex() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(ethTxBytes, errors.New("error")) + + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + Proof: &proofs.Proof{}, + BlockHash: "", + TxIndex: 0, + Nonce: 42, + }) + require.ErrorIs(t, err, types.ErrProofVerificationFail) + }) + + t.Run("should fail if no tss when adding hash with proof", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + UseLightclientMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + chainID := getEthereumChainID() + ethTx, ethTxBytes, tssAddress := sample.EthTxSigned(t, chainID, sample.EthAddress(), 42) + txHash := ethTx.Hash().Hex() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(ethTxBytes, nil) + observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ + Eth: tssAddress.Hex(), + }, errors.New("error")) + + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + Proof: &proofs.Proof{}, + BlockHash: "", + TxIndex: 0, + Nonce: 42, + }) + require.ErrorIs(t, err, observertypes.ErrTssNotFound) + }) + + t.Run("should fail if body verification fail with proof", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + UseObserverMock: true, + UseLightclientMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + chainID := getEthereumChainID() + ethTx, _, tssAddress := sample.EthTxSigned(t, chainID, sample.EthAddress(), 42) + txHash := ethTx.Hash().Hex() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + observerMock := keepertest.GetCrosschainObserverMock(t, k) + lightclientMock := keepertest.GetCrosschainLightclientMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) + observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(&chains.Chain{}) + observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) + keepertest.MockCctxByNonce(t, ctx, *k, observerMock, types.CctxStatus_PendingOutbound, false) + observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ + Eth: tssAddress.Hex(), + }, nil) + + // makes VerifyProof returning an invalid hash + lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(sample.Bytes(), nil) + + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + Creator: admin, + ChainId: chainID, + TxHash: txHash, + Proof: &proofs.Proof{}, + BlockHash: "", + TxIndex: 0, + Nonce: 42, + }) + require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) + }) } diff --git a/x/crosschain/keeper/out_tx_tracker.go b/x/crosschain/keeper/out_tx_tracker.go index f28ef5a35b..2f3a39787e 100644 --- a/x/crosschain/keeper/out_tx_tracker.go +++ b/x/crosschain/keeper/out_tx_tracker.go @@ -27,7 +27,6 @@ func (k Keeper) GetOutTxTracker( ctx sdk.Context, chainID int64, nonce uint64, - ) (val types.OutTxTracker, found bool) { index := getOutTrackerIndex(chainID, nonce) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OutTxTrackerKeyPrefix)) diff --git a/x/crosschain/keeper/verify_proof.go b/x/crosschain/keeper/verify_proof.go deleted file mode 100644 index 5c58c98b10..0000000000 --- a/x/crosschain/keeper/verify_proof.go +++ /dev/null @@ -1,109 +0,0 @@ -package keeper - -import ( - "fmt" - "math/big" - - sdk "github.com/cosmos/cosmos-sdk/types" - eth "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/zeta-chain/zetacore/pkg/chains" - "github.com/zeta-chain/zetacore/pkg/coin" - "github.com/zeta-chain/zetacore/pkg/proofs" - "github.com/zeta-chain/zetacore/x/crosschain/types" - observertypes "github.com/zeta-chain/zetacore/x/observer/types" -) - -func (k Keeper) VerifyProof(ctx sdk.Context, proof *proofs.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) { - // header-based merkle proof verification must be enabled - crosschainFlags, found := k.zetaObserverKeeper.GetCrosschainFlags(ctx) - if !found { - return nil, fmt.Errorf("crosschain flags not found") - } - if crosschainFlags.BlockHeaderVerificationFlags == nil { - return nil, fmt.Errorf("block header verification flags not found") - } - if chains.IsBitcoinChain(chainID) && !crosschainFlags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled { - return nil, fmt.Errorf("proof verification not enabled for bitcoin chain") - } - if chains.IsEVMChain(chainID) && !crosschainFlags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled { - return nil, fmt.Errorf("proof verification not enabled for evm chain") - } - - // chain must support header-based merkle proof verification - senderChain := chains.GetChainFromChainID(chainID) - if senderChain == nil { - return nil, types.ErrUnsupportedChain - } - if !senderChain.SupportMerkleProof() { - return nil, fmt.Errorf("chain %d does not support block header-based verification", chainID) - } - - // get block header from the store - hashBytes, err := chains.StringToHash(chainID, blockHash) - if err != nil { - return nil, fmt.Errorf("block hash %s conversion failed %s", blockHash, err) - } - res, found := k.zetaObserverKeeper.GetBlockHeader(ctx, hashBytes) - if !found { - return nil, fmt.Errorf("block header not found %s", blockHash) - } - - // verify merkle proof - txBytes, err := proof.Verify(res.Header, int(txIndex)) - if err != nil { - return nil, err - } - return txBytes, err -} - -func (k Keeper) VerifyEVMInTxBody(ctx sdk.Context, msg *types.MsgAddToInTxTracker, txBytes []byte) error { - var txx ethtypes.Transaction - err := txx.UnmarshalBinary(txBytes) - if err != nil { - return err - } - if txx.Hash().Hex() != msg.TxHash { - return fmt.Errorf("want tx hash %s, got %s", txx.Hash().Hex(), msg.TxHash) - } - if txx.ChainId().Cmp(big.NewInt(msg.ChainId)) != 0 { - return fmt.Errorf("want evm chain id %d, got %d", txx.ChainId(), msg.ChainId) - } - switch msg.CoinType { - case coin.CoinType_Zeta: - chainParams, found := k.zetaObserverKeeper.GetChainParamsByChainID(ctx, msg.ChainId) - if !found { - return types.ErrUnsupportedChain.Wrapf("chain params not found for chain %d", msg.ChainId) - } - if txx.To().Hex() != chainParams.ConnectorContractAddress { - return fmt.Errorf("receiver is not connector contract for coin type %s", msg.CoinType) - } - return nil - case coin.CoinType_ERC20: - chainParams, found := k.zetaObserverKeeper.GetChainParamsByChainID(ctx, msg.ChainId) - if !found { - return types.ErrUnsupportedChain.Wrapf("chain params not found for chain %d", msg.ChainId) - } - if txx.To().Hex() != chainParams.Erc20CustodyContractAddress { - return fmt.Errorf("receiver is not erc20Custory contract for coin type %s", msg.CoinType) - } - return nil - case coin.CoinType_Gas: - tss, err := k.zetaObserverKeeper.GetTssAddress(ctx, &observertypes.QueryGetTssAddressRequest{ - BitcoinChainId: msg.ChainId, - }) - if err != nil { - return err - } - tssAddr := eth.HexToAddress(tss.Eth) - if tssAddr == (eth.Address{}) { - return fmt.Errorf("tss address not found") - } - if txx.To().Hex() != tssAddr.Hex() { - return fmt.Errorf("receiver is not tssAddress contract for coin type %s", msg.CoinType) - } - return nil - default: - return fmt.Errorf("coin type %s not supported", msg.CoinType) - } -} diff --git a/x/crosschain/keeper/verify_proof_test.go b/x/crosschain/keeper/verify_proof_test.go deleted file mode 100644 index 62d47773b9..0000000000 --- a/x/crosschain/keeper/verify_proof_test.go +++ /dev/null @@ -1,393 +0,0 @@ -package keeper_test - -import ( - "errors" - "math/big" - "testing" - - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/coin" - "github.com/zeta-chain/zetacore/pkg/proofs" - keepertest "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/testutil/sample" - "github.com/zeta-chain/zetacore/x/crosschain/types" - observertypes "github.com/zeta-chain/zetacore/x/observer/types" -) - -func TestKeeper_VerifyProof(t *testing.T) { - t.Run("should error if crosschain flags not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetCrosschainFlags", mock.Anything).Return(observertypes.CrosschainFlags{}, false) - - res, err := k.VerifyProof(ctx, &proofs.Proof{}, 5, sample.Hash().String(), 1) - require.Error(t, err) - require.Nil(t, res) - }) - - t.Run("should error if BlockHeaderVerificationFlags nil", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetCrosschainFlags", mock.Anything).Return(observertypes.CrosschainFlags{ - BlockHeaderVerificationFlags: nil, - }, true) - - res, err := k.VerifyProof(ctx, &proofs.Proof{}, 5, sample.Hash().String(), 1) - require.Error(t, err) - require.Nil(t, res) - }) - - t.Run("should error if verification not enabled for btc chain", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetCrosschainFlags", mock.Anything).Return(observertypes.CrosschainFlags{ - BlockHeaderVerificationFlags: &observertypes.BlockHeaderVerificationFlags{ - IsBtcTypeChainEnabled: false, - }, - }, true) - - res, err := k.VerifyProof(ctx, &proofs.Proof{}, 18444, sample.Hash().String(), 1) - require.Error(t, err) - require.Nil(t, res) - }) - - t.Run("should error if verification not enabled for evm chain", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetCrosschainFlags", mock.Anything).Return(observertypes.CrosschainFlags{ - BlockHeaderVerificationFlags: &observertypes.BlockHeaderVerificationFlags{ - IsEthTypeChainEnabled: false, - }, - }, true) - - res, err := k.VerifyProof(ctx, &proofs.Proof{}, 5, sample.Hash().String(), 1) - require.Error(t, err) - require.Nil(t, res) - }) - - t.Run("should error if block header-based verification not supported", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetCrosschainFlags", mock.Anything).Return(observertypes.CrosschainFlags{ - BlockHeaderVerificationFlags: &observertypes.BlockHeaderVerificationFlags{ - IsEthTypeChainEnabled: false, - }, - }, true) - - res, err := k.VerifyProof(ctx, &proofs.Proof{}, 101, sample.Hash().String(), 1) - require.Error(t, err) - require.Nil(t, res) - }) - - t.Run("should error if blockhash invalid", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetCrosschainFlags", mock.Anything).Return(observertypes.CrosschainFlags{ - BlockHeaderVerificationFlags: &observertypes.BlockHeaderVerificationFlags{ - IsBtcTypeChainEnabled: true, - }, - }, true) - - res, err := k.VerifyProof(ctx, &proofs.Proof{}, 18444, "invalid", 1) - require.Error(t, err) - require.Nil(t, res) - }) - - t.Run("should error if block header not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetCrosschainFlags", mock.Anything).Return(observertypes.CrosschainFlags{ - BlockHeaderVerificationFlags: &observertypes.BlockHeaderVerificationFlags{ - IsEthTypeChainEnabled: true, - }, - }, true) - - observerMock.On("GetBlockHeader", mock.Anything, mock.Anything).Return(proofs.BlockHeader{}, false) - - res, err := k.VerifyProof(ctx, &proofs.Proof{}, 5, sample.Hash().String(), 1) - require.Error(t, err) - require.Nil(t, res) - }) - // TODO: // https://github.com/zeta-chain/node/issues/1875 add more tests -} - -func TestKeeper_VerifyEVMInTxBody(t *testing.T) { - to := sample.EthAddress() - tx := ethtypes.NewTx(ðtypes.DynamicFeeTx{ - ChainID: big.NewInt(5), - Nonce: 1, - GasTipCap: nil, - GasFeeCap: nil, - Gas: 21000, - To: &to, - Value: big.NewInt(5), - Data: nil, - }) - t.Run("should error if msg tx hash not correct", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: "0x0", - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should error if msg chain id not correct", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: 1, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should error if not supported coin type", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_Cmd, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should error for cointype_zeta if chain params not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(&observertypes.ChainParams{}, false) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_Zeta, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should error for cointype_zeta if tx.to wrong", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(&observertypes.ChainParams{ - ConnectorContractAddress: sample.EthAddress().Hex(), - }, true) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_Zeta, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should not error for cointype_zeta", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(&observertypes.ChainParams{ - ConnectorContractAddress: to.Hex(), - }, true) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_Zeta, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.NoError(t, err) - }) - - t.Run("should error for cointype_erc20 if chain params not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(&observertypes.ChainParams{}, false) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_ERC20, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should error for cointype_erc20 if tx.to wrong", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(&observertypes.ChainParams{ - Erc20CustodyContractAddress: sample.EthAddress().Hex(), - }, true) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_ERC20, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should not error for cointype_erc20", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(&observertypes.ChainParams{ - Erc20CustodyContractAddress: to.Hex(), - }, true) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_ERC20, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.NoError(t, err) - }) - - t.Run("should error for cointype_gas if tss address not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{}, errors.New("err")) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_Gas, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should error for cointype_gas if tss eth address is empty", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ - Eth: "0x", - }, nil) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_Gas, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should error for cointype_gas if tss eth address is wrong", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ - Eth: sample.EthAddress().Hex(), - }, nil) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_Gas, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.Error(t, err) - }) - - t.Run("should not error for cointype_gas", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ - UseObserverMock: true, - }) - observerMock := keepertest.GetCrosschainObserverMock(t, k) - observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(&observertypes.QueryGetTssAddressResponse{ - Eth: to.Hex(), - }, nil) - - txBytes, err := tx.MarshalBinary() - require.NoError(t, err) - msg := &types.MsgAddToInTxTracker{ - TxHash: tx.Hash().Hex(), - ChainId: tx.ChainId().Int64(), - CoinType: coin.CoinType_Gas, - } - - err = k.VerifyEVMInTxBody(ctx, msg, txBytes) - require.NoError(t, err) - }) -} diff --git a/x/crosschain/types/authz.go b/x/crosschain/types/authz.go index 5df64a701a..6b27c1fd40 100644 --- a/x/crosschain/types/authz.go +++ b/x/crosschain/types/authz.go @@ -14,6 +14,6 @@ func GetAllAuthzZetaclientTxTypes() []string { sdk.MsgTypeURL(&MsgAddToOutTxTracker{}), sdk.MsgTypeURL(&observertypes.MsgVoteTSS{}), sdk.MsgTypeURL(&observertypes.MsgAddBlameVote{}), - sdk.MsgTypeURL(&observertypes.MsgAddBlockHeader{}), + sdk.MsgTypeURL(&observertypes.MsgVoteBlockHeader{}), } } diff --git a/x/crosschain/types/authz_test.go b/x/crosschain/types/authz_test.go index 0ebd56f3b7..d8a581bd07 100644 --- a/x/crosschain/types/authz_test.go +++ b/x/crosschain/types/authz_test.go @@ -14,6 +14,6 @@ func TestGetAllAuthzZetaclientTxTypes(t *testing.T) { "/zetachain.zetacore.crosschain.MsgAddToOutTxTracker", "/zetachain.zetacore.observer.MsgVoteTSS", "/zetachain.zetacore.observer.MsgAddBlameVote", - "/zetachain.zetacore.observer.MsgAddBlockHeader"}, + "/zetachain.zetacore.observer.MsgVoteBlockHeader"}, crosschaintypes.GetAllAuthzZetaclientTxTypes()) } diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index 62720aaf66..0578e68fa6 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -41,4 +41,5 @@ var ( ErrUnableProcessRefund = errorsmod.Register(ModuleName, 1148, "unable to process refund") ErrUnableToFindZetaAccounting = errorsmod.Register(ModuleName, 1149, "unable to find zeta accounting") ErrInsufficientZetaAmount = errorsmod.Register(ModuleName, 1150, "insufficient zeta amount") + ErrMaxTxOutTrackerHashesReached = errorsmod.Register(ModuleName, 1151, "max tx out tracker hashes reached") ) diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index c985a01915..3fbea3a483 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -50,7 +50,6 @@ type ObserverKeeper interface { IsNonTombstonedObserver(ctx sdk.Context, address string) bool FindBallot(ctx sdk.Context, index string, chain *chains.Chain, observationType observertypes.ObservationType) (ballot observertypes.Ballot, isNew bool, err error) AddBallotToList(ctx sdk.Context, ballot observertypes.Ballot) - GetBlockHeader(ctx sdk.Context, hash []byte) (val proofs.BlockHeader, found bool) CheckIfTssPubkeyHasBeenGenerated(ctx sdk.Context, tssPubkey string) (observertypes.TSS, bool) GetAllTSS(ctx sdk.Context) (list []observertypes.TSS) GetTSS(ctx sdk.Context) (val observertypes.TSS, found bool) @@ -167,3 +166,7 @@ type FungibleKeeper interface { type AuthorityKeeper interface { IsAuthorized(ctx sdk.Context, address string, policyType authoritytypes.PolicyType) bool } + +type LightclientKeeper interface { + VerifyProof(ctx sdk.Context, proof *proofs.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) +} diff --git a/x/crosschain/types/genesis_test.go b/x/crosschain/types/genesis_test.go index d84d811bd9..c3e555fa61 100644 --- a/x/crosschain/types/genesis_test.go +++ b/x/crosschain/types/genesis_test.go @@ -8,7 +8,6 @@ import ( "github.com/zeta-chain/zetacore/x/crosschain/types" ) -// FIXME: make it work func TestGenesisState_Validate(t *testing.T) { for _, tc := range []struct { desc string @@ -23,15 +22,6 @@ func TestGenesisState_Validate(t *testing.T) { { desc: "valid genesis state", genState: &types.GenesisState{ - - //ZetaConversionRateList: []types.ZetaConversionRate{ - // { - // Index: "0", - // }, - // { - // Index: "1", - // }, - //}, OutTxTrackerList: []types.OutTxTracker{ { Index: "0", diff --git a/x/crosschain/types/tx_body_verification.go b/x/crosschain/types/tx_body_verification.go new file mode 100644 index 0000000000..eebc49cc5d --- /dev/null +++ b/x/crosschain/types/tx_body_verification.go @@ -0,0 +1,164 @@ +package types + +import ( + "fmt" + "math/big" + + "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcutil" + eth "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +// VerifyInTxBody validates the tx body for a inbound tx +func VerifyInTxBody( + msg MsgAddToInTxTracker, + txBytes []byte, + chainParams observertypes.ChainParams, + tss observertypes.QueryGetTssAddressResponse, +) error { + // verify message against transaction body + if chains.IsEVMChain(msg.ChainId) { + return verifyInTxBodyEVM(msg, txBytes, chainParams, tss) + } + + // TODO: implement verifyInTxBodyBTC + // https://github.com/zeta-chain/node/issues/1993 + + return fmt.Errorf("cannot verify inTx body for chain %d", msg.ChainId) +} + +// verifyInTxBodyEVM validates the chain id and connector contract address for Zeta, ERC20 custody contract address for ERC20 and TSS address for Gas. +func verifyInTxBodyEVM( + msg MsgAddToInTxTracker, + txBytes []byte, + chainParams observertypes.ChainParams, + tss observertypes.QueryGetTssAddressResponse, +) error { + var txx ethtypes.Transaction + err := txx.UnmarshalBinary(txBytes) + if err != nil { + return fmt.Errorf("failed to unmarshal transaction %s", err.Error()) + } + if txx.Hash().Hex() != msg.TxHash { + return fmt.Errorf("invalid hash, want tx hash %s, got %s", txx.Hash().Hex(), msg.TxHash) + } + if txx.ChainId().Cmp(big.NewInt(msg.ChainId)) != 0 { + return fmt.Errorf("invalid chain id, want evm chain id %d, got %d", txx.ChainId(), msg.ChainId) + } + switch msg.CoinType { + case coin.CoinType_Zeta: + // Inbound depositing ZETA interacts with connector contract + if txx.To().Hex() != chainParams.ConnectorContractAddress { + return fmt.Errorf("receiver is not connector contract for coin type %s", msg.CoinType) + } + case coin.CoinType_ERC20: + // Inbound depositing ERC20 interacts with ERC20 custody contract + if txx.To().Hex() != chainParams.Erc20CustodyContractAddress { + return fmt.Errorf("receiver is not erc20Custory contract for coin type %s", msg.CoinType) + } + case coin.CoinType_Gas: + // Inbound depositing Gas interacts with TSS address + tssAddr := eth.HexToAddress(tss.Eth) + if tssAddr == (eth.Address{}) { + return fmt.Errorf("tss address not found") + } + if txx.To().Hex() != tssAddr.Hex() { + return fmt.Errorf("receiver is not tssAddress contract for coin type %s", msg.CoinType) + } + default: + return fmt.Errorf("coin type not supported %s", msg.CoinType) + } + return nil +} + +// VerifyOutTxBody verifies the tx body for a outbound tx +func VerifyOutTxBody(msg MsgAddToOutTxTracker, txBytes []byte, tss observertypes.QueryGetTssAddressResponse) error { + // verify message against transaction body + if chains.IsEVMChain(msg.ChainId) { + return verifyOutTxBodyEVM(msg, txBytes, tss.Eth) + } else if chains.IsBitcoinChain(msg.ChainId) { + return verifyOutTxBodyBTC(msg, txBytes, tss.Btc) + } + return fmt.Errorf("cannot verify outTx body for chain %d", msg.ChainId) +} + +// verifyOutTxBodyEVM validates the sender address, nonce, chain id and tx hash. +func verifyOutTxBodyEVM(msg MsgAddToOutTxTracker, txBytes []byte, tssEth string) error { + var txx ethtypes.Transaction + err := txx.UnmarshalBinary(txBytes) + if err != nil { + return fmt.Errorf("failed to unmarshal transaction %s", err.Error()) + } + signer := ethtypes.NewLondonSigner(txx.ChainId()) + sender, err := ethtypes.Sender(signer, &txx) + if err != nil { + return fmt.Errorf("failed to recover sender %s", err.Error()) + } + tssAddr := eth.HexToAddress(tssEth) + if tssAddr == (eth.Address{}) { + return fmt.Errorf("tss address not found") + } + if sender != tssAddr { + return fmt.Errorf("sender is not tss address %s", sender) + } + if txx.ChainId().Cmp(big.NewInt(msg.ChainId)) != 0 { + return fmt.Errorf("invalid chain id, want evm chain id %d, got %d", txx.ChainId(), msg.ChainId) + } + if txx.Nonce() != msg.Nonce { + return fmt.Errorf("invalid nonce, want nonce %d, got %d", txx.Nonce(), msg.Nonce) + } + if txx.Hash().Hex() != msg.TxHash { + return fmt.Errorf("invalid tx hash, want tx hash %s, got %s", txx.Hash().Hex(), msg.TxHash) + } + return nil +} + +// verifyOutTxBodyBTC validates the SegWit sender address, nonce and chain id and tx hash +// TODO: Implement tests for the function +// https://github.com/zeta-chain/node/issues/1994 +func verifyOutTxBodyBTC(msg MsgAddToOutTxTracker, txBytes []byte, tssBtc string) error { + if !chains.IsBitcoinChain(msg.ChainId) { + return fmt.Errorf("not a Bitcoin chain ID %d", msg.ChainId) + } + tx, err := btcutil.NewTxFromBytes(txBytes) + if err != nil { + return err + } + for _, vin := range tx.MsgTx().TxIn { + if len(vin.Witness) != 2 { // outTx is SegWit transaction for now + return fmt.Errorf("not a SegWit transaction") + } + pubKey, err := btcec.ParsePubKey(vin.Witness[1], btcec.S256()) + if err != nil { + return fmt.Errorf("failed to parse public key") + } + bitcoinNetParams, err := chains.BitcoinNetParamsFromChainID(msg.ChainId) + if err != nil { + return fmt.Errorf("failed to get Bitcoin net params, error %s", err.Error()) + } + addrP2WPKH, err := btcutil.NewAddressWitnessPubKeyHash( + btcutil.Hash160(pubKey.SerializeCompressed()), + bitcoinNetParams, + ) + if err != nil { + return fmt.Errorf("failed to create P2WPKH address") + } + if addrP2WPKH.EncodeAddress() != tssBtc { + return fmt.Errorf("sender %s is not tss address", addrP2WPKH.EncodeAddress()) + } + } + if len(tx.MsgTx().TxOut) < 1 { + return fmt.Errorf("outTx should have at least one output") + } + if tx.MsgTx().TxOut[0].Value != chains.NonceMarkAmount(msg.Nonce) { + return fmt.Errorf("want nonce mark %d, got %d", tx.MsgTx().TxOut[0].Value, chains.NonceMarkAmount(msg.Nonce)) + } + if tx.MsgTx().TxHash().String() != msg.TxHash { + return fmt.Errorf("want tx hash %s, got %s", tx.MsgTx().TxHash(), msg.TxHash) + } + return nil +} diff --git a/x/crosschain/types/tx_body_verification_test.go b/x/crosschain/types/tx_body_verification_test.go new file mode 100644 index 0000000000..2836b755e9 --- /dev/null +++ b/x/crosschain/types/tx_body_verification_test.go @@ -0,0 +1,278 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func TestVerifyInTxBody(t *testing.T) { + sampleTo := sample.EthAddress() + sampleEthTx, sampleEthTxBytes := sample.EthTx(t, chains.EthChain().ChainId, sampleTo, 42) + + // NOTE: errContains == "" means no error + for _, tc := range []struct { + desc string + msg types.MsgAddToInTxTracker + txBytes []byte + chainParams observertypes.ChainParams + tss observertypes.QueryGetTssAddressResponse + errContains string + }{ + { + desc: "can't verify btc tx tx body", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.BtcMainnetChain().ChainId, + }, + txBytes: sample.Bytes(), + errContains: "cannot verify inTx body for chain", + }, + { + desc: "txBytes can't be unmarshaled", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + }, + txBytes: []byte("invalid"), + errContains: "failed to unmarshal transaction", + }, + { + desc: "txHash doesn't correspond", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sample.Hash().Hex(), + }, + txBytes: sampleEthTxBytes, + errContains: "invalid hash", + }, + { + desc: "chain id doesn't correspond", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.SepoliaChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + }, + txBytes: sampleEthTxBytes, + errContains: "invalid chain id", + }, + { + desc: "invalid coin type", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + CoinType: coin.CoinType(1000), + }, + txBytes: sampleEthTxBytes, + errContains: "coin type not supported", + }, + { + desc: "coin types is zeta, but connector contract address is wrong", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + CoinType: coin.CoinType_Zeta, + }, + txBytes: sampleEthTxBytes, + chainParams: observertypes.ChainParams{ConnectorContractAddress: sample.EthAddress().Hex()}, + errContains: "receiver is not connector contract for coin type", + }, + { + desc: "coin types is zeta, connector contract address is correct", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + CoinType: coin.CoinType_Zeta, + }, + txBytes: sampleEthTxBytes, + chainParams: observertypes.ChainParams{ConnectorContractAddress: sampleTo.Hex()}, + }, + { + desc: "coin types is erc20, but erc20 custody contract address is wrong", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + CoinType: coin.CoinType_ERC20, + }, + txBytes: sampleEthTxBytes, + chainParams: observertypes.ChainParams{Erc20CustodyContractAddress: sample.EthAddress().Hex()}, + errContains: "receiver is not erc20Custory contract for coin type", + }, + { + desc: "coin types is erc20, erc20 custody contract address is correct", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + CoinType: coin.CoinType_ERC20, + }, + txBytes: sampleEthTxBytes, + chainParams: observertypes.ChainParams{Erc20CustodyContractAddress: sampleTo.Hex()}, + }, + { + desc: "coin types is gas, but tss address is not found", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + CoinType: coin.CoinType_Gas, + }, + txBytes: sampleEthTxBytes, + tss: observertypes.QueryGetTssAddressResponse{}, + errContains: "tss address not found", + }, + { + desc: "coin types is gas, but tss address is wrong", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + CoinType: coin.CoinType_Gas, + }, + txBytes: sampleEthTxBytes, + tss: observertypes.QueryGetTssAddressResponse{Eth: sample.EthAddress().Hex()}, + errContains: "receiver is not tssAddress contract for coin type", + }, + { + desc: "coin types is gas, tss address is correct", + msg: types.MsgAddToInTxTracker{ + ChainId: chains.EthChain().ChainId, + TxHash: sampleEthTx.Hash().Hex(), + CoinType: coin.CoinType_Gas, + }, + txBytes: sampleEthTxBytes, + tss: observertypes.QueryGetTssAddressResponse{Eth: sampleTo.Hex()}, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + err := types.VerifyInTxBody(tc.msg, tc.txBytes, tc.chainParams, tc.tss) + if tc.errContains == "" { + require.NoError(t, err) + } else { + require.ErrorContains(t, err, tc.errContains) + } + }) + } +} + +func TestVerifyOutTxBody(t *testing.T) { + + sampleTo := sample.EthAddress() + sampleEthTx, sampleEthTxBytes, sampleFrom := sample.EthTxSigned(t, chains.EthChain().ChainId, sampleTo, 42) + _, sampleEthTxBytesNonSigned := sample.EthTx(t, chains.EthChain().ChainId, sampleTo, 42) + + // NOTE: errContains == "" means no error + for _, tc := range []struct { + desc string + msg types.MsgAddToOutTxTracker + txBytes []byte + tss observertypes.QueryGetTssAddressResponse + errContains string + }{ + { + desc: "invalid chain id", + msg: types.MsgAddToOutTxTracker{ + ChainId: int64(1000), + Nonce: 42, + TxHash: sampleEthTx.Hash().Hex(), + }, + txBytes: sample.Bytes(), + errContains: "cannot verify outTx body for chain", + }, + { + desc: "txBytes can't be unmarshaled", + msg: types.MsgAddToOutTxTracker{ + ChainId: chains.EthChain().ChainId, + Nonce: 42, + TxHash: sampleEthTx.Hash().Hex(), + }, + txBytes: []byte("invalid"), + errContains: "failed to unmarshal transaction", + }, + { + desc: "can't recover sender address", + msg: types.MsgAddToOutTxTracker{ + ChainId: chains.EthChain().ChainId, + Nonce: 42, + TxHash: sampleEthTx.Hash().Hex(), + }, + txBytes: sampleEthTxBytesNonSigned, + errContains: "failed to recover sender", + }, + { + desc: "tss address not found", + msg: types.MsgAddToOutTxTracker{ + ChainId: chains.EthChain().ChainId, + Nonce: 42, + TxHash: sampleEthTx.Hash().Hex(), + }, + tss: observertypes.QueryGetTssAddressResponse{}, + txBytes: sampleEthTxBytes, + errContains: "tss address not found", + }, + { + desc: "tss address is wrong", + msg: types.MsgAddToOutTxTracker{ + ChainId: chains.EthChain().ChainId, + Nonce: 42, + TxHash: sampleEthTx.Hash().Hex(), + }, + tss: observertypes.QueryGetTssAddressResponse{Eth: sample.EthAddress().Hex()}, + txBytes: sampleEthTxBytes, + errContains: "sender is not tss address", + }, + { + desc: "chain id doesn't correspond", + msg: types.MsgAddToOutTxTracker{ + ChainId: chains.SepoliaChain().ChainId, + Nonce: 42, + TxHash: sampleEthTx.Hash().Hex(), + }, + tss: observertypes.QueryGetTssAddressResponse{Eth: sampleFrom.Hex()}, + txBytes: sampleEthTxBytes, + errContains: "invalid chain id", + }, + { + desc: "nonce doesn't correspond", + msg: types.MsgAddToOutTxTracker{ + ChainId: chains.EthChain().ChainId, + Nonce: 100, + TxHash: sampleEthTx.Hash().Hex(), + }, + tss: observertypes.QueryGetTssAddressResponse{Eth: sampleFrom.Hex()}, + txBytes: sampleEthTxBytes, + errContains: "invalid nonce", + }, + { + desc: "tx hash doesn't correspond", + msg: types.MsgAddToOutTxTracker{ + ChainId: chains.EthChain().ChainId, + Nonce: 42, + TxHash: sample.Hash().Hex(), + }, + tss: observertypes.QueryGetTssAddressResponse{Eth: sampleFrom.Hex()}, + txBytes: sampleEthTxBytes, + errContains: "invalid tx hash", + }, + { + desc: "valid out tx body", + msg: types.MsgAddToOutTxTracker{ + ChainId: chains.EthChain().ChainId, + Nonce: 42, + TxHash: sampleEthTx.Hash().Hex(), + }, + tss: observertypes.QueryGetTssAddressResponse{Eth: sampleFrom.Hex()}, + txBytes: sampleEthTxBytes, + }, + // TODO: Implement tests for verifyOutTxBodyBTC + // https://github.com/zeta-chain/node/issues/1994 + } { + t.Run(tc.desc, func(t *testing.T) { + err := types.VerifyOutTxBody(tc.msg, tc.txBytes, tc.tss) + if tc.errContains == "" { + require.NoError(t, err) + } else { + require.ErrorContains(t, err, tc.errContains) + } + }) + } +} diff --git a/x/lightclient/client/cli/query.go b/x/lightclient/client/cli/query.go new file mode 100644 index 0000000000..304c730bb7 --- /dev/null +++ b/x/lightclient/client/cli/query.go @@ -0,0 +1,31 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(_ string) *cobra.Command { + // Group lightclient queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdShowBlockHeader(), + CmdListBlockHeader(), + CmdShowChainState(), + CmdListChainState(), + CmdShowVerificationFlags(), + ) + + return cmd +} diff --git a/x/lightclient/client/cli/query_block_header.go b/x/lightclient/client/cli/query_block_header.go new file mode 100644 index 0000000000..a183d295e5 --- /dev/null +++ b/x/lightclient/client/cli/query_block_header.go @@ -0,0 +1,77 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func CmdListBlockHeader() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-block-header", + Short: "List all the block headers", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllBlockHeaderRequest{ + Pagination: pageReq, + } + + res, err := queryClient.BlockHeaderAll(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowBlockHeader() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-block-header [block-hash]", + Short: "Show a block header from its hash", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + blockHash := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetBlockHeaderRequest{ + BlockHash: []byte(blockHash), + } + + res, err := queryClient.BlockHeader(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/lightclient/client/cli/query_chain_state.go b/x/lightclient/client/cli/query_chain_state.go new file mode 100644 index 0000000000..888f15b012 --- /dev/null +++ b/x/lightclient/client/cli/query_chain_state.go @@ -0,0 +1,82 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func CmdListChainState() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-chain-state", + Short: "List all the chain states", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllChainStateRequest{ + Pagination: pageReq, + } + + res, err := queryClient.ChainStateAll(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowChainState() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-chain-state [chain-id]", + Short: "Show a chain state from its chain id", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + chainID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetChainStateRequest{ + ChainId: chainID, + } + + res, err := queryClient.ChainState(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/lightclient/client/cli/query_verification_flags.go b/x/lightclient/client/cli/query_verification_flags.go new file mode 100644 index 0000000000..19b5cd3691 --- /dev/null +++ b/x/lightclient/client/cli/query_verification_flags.go @@ -0,0 +1,37 @@ +package cli + +import ( + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func CmdShowVerificationFlags() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-verification-flags", + Short: "Show the verification flags", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryVerificationFlagsRequest{} + + res, err := queryClient.VerificationFlags(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/lightclient/client/cli/tx.go b/x/lightclient/client/cli/tx.go new file mode 100644 index 0000000000..5b14f7db20 --- /dev/null +++ b/x/lightclient/client/cli/tx.go @@ -0,0 +1,26 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + CmdUpdateVerificationFlags(), + ) + + return cmd +} diff --git a/x/lightclient/client/cli/tx_update_verification_flags.go b/x/lightclient/client/cli/tx_update_verification_flags.go new file mode 100644 index 0000000000..40b53989d4 --- /dev/null +++ b/x/lightclient/client/cli/tx_update_verification_flags.go @@ -0,0 +1,41 @@ +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/zetacore/x/lightclient/types" +) + +func CmdUpdateVerificationFlags() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-verification-flags [eth-type-chain-enabled] [btc-type-chain-enabled]", + Short: "Update verification flags", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + argEthEnabled, err := strconv.ParseBool(args[0]) + if err != nil { + return err + } + arsBtcEnabled, err := strconv.ParseBool(args[1]) + if err != nil { + return err + } + msg := types.NewMsgUpdateVerificationFlags(clientCtx.GetFromAddress().String(), argEthEnabled, arsBtcEnabled) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/lightclient/genesis.go b/x/lightclient/genesis.go new file mode 100644 index 0000000000..6211550b60 --- /dev/null +++ b/x/lightclient/genesis.go @@ -0,0 +1,37 @@ +package lightclient + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/lightclient/keeper" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// InitGenesis initializes the lightclient module's state from a provided genesis state +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // set block headers + for _, elem := range genState.BlockHeaders { + k.SetBlockHeader(ctx, elem) + } + + // set chain states + for _, elem := range genState.ChainStates { + k.SetChainState(ctx, elem) + } + + // set verification flags + k.SetVerificationFlags(ctx, genState.VerificationFlags) +} + +// ExportGenesis returns the lightclient module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + verificationFlags, found := k.GetVerificationFlags(ctx) + if !found { + verificationFlags = types.DefaultVerificationFlags() + } + + return &types.GenesisState{ + BlockHeaders: k.GetAllBlockHeaders(ctx), + ChainStates: k.GetAllChainStates(ctx), + VerificationFlags: verificationFlags, + } +} diff --git a/x/lightclient/genesis_test.go b/x/lightclient/genesis_test.go new file mode 100644 index 0000000000..049cfbe848 --- /dev/null +++ b/x/lightclient/genesis_test.go @@ -0,0 +1,63 @@ +package lightclient_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/nullify" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestGenesis(t *testing.T) { + t.Run("can import and export genesis", func(t *testing.T) { + genesisState := types.GenesisState{ + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }, + BlockHeaders: []proofs.BlockHeader{ + sample.BlockHeader(sample.Hash().Bytes()), + sample.BlockHeader(sample.Hash().Bytes()), + sample.BlockHeader(sample.Hash().Bytes()), + }, + ChainStates: []types.ChainState{ + sample.ChainState(chains.EthChain().ChainId), + sample.ChainState(chains.BtcMainnetChain().ChainId), + sample.ChainState(chains.BscMainnetChain().ChainId), + }, + } + + // Init and export + k, ctx, _, _ := keepertest.LightclientKeeper(t) + lightclient.InitGenesis(ctx, *k, genesisState) + got := lightclient.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + // Compare genesis after init and export + nullify.Fill(&genesisState) + nullify.Fill(got) + require.Equal(t, genesisState, *got) + }) + + t.Run("can export genesis with empty state", func(t *testing.T) { + // Export genesis with empty state + k, ctx, _, _ := keepertest.LightclientKeeper(t) + got := lightclient.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + // Compare genesis after export + expected := types.GenesisState{ + VerificationFlags: types.DefaultVerificationFlags(), + BlockHeaders: []proofs.BlockHeader{}, + ChainStates: []types.ChainState{}, + } + nullify.Fill(got) + nullify.Fill(expected) + require.Equal(t, expected, *got) + }) +} diff --git a/x/lightclient/keeper/block_header.go b/x/lightclient/keeper/block_header.go new file mode 100644 index 0000000000..88acb7828f --- /dev/null +++ b/x/lightclient/keeper/block_header.go @@ -0,0 +1,155 @@ +package keeper + +import ( + "fmt" + + cosmoserrors "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/pkg/proofs" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// GetAllBlockHeaders returns all block headers +func (k Keeper) GetAllBlockHeaders(ctx sdk.Context) (list []proofs.BlockHeader) { + p := types.KeyPrefix(fmt.Sprintf("%s", types.BlockHeaderKey)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), p) + + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val proofs.BlockHeader + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return list +} + +// SetBlockHeader set a specific block header in the store from its index +func (k Keeper) SetBlockHeader(ctx sdk.Context, header proofs.BlockHeader) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderKey)) + b := k.cdc.MustMarshal(&header) + store.Set(header.Hash, b) +} + +// GetBlockHeader returns a block header from its hash +func (k Keeper) GetBlockHeader(ctx sdk.Context, hash []byte) (val proofs.BlockHeader, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderKey)) + + b := store.Get(hash) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveBlockHeader removes a block header from the store +func (k Keeper) RemoveBlockHeader(ctx sdk.Context, hash []byte) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderKey)) + store.Delete(hash) +} + +// CheckNewBlockHeader checks if a new block header is valid and can be added to the store +// It checks that the parent block header exists and that the block height is valid +// It also checks that the block header does not already exist +// It returns an error if the block header is invalid +// Upon success, it returns the parent hash +func (k Keeper) CheckNewBlockHeader( + ctx sdk.Context, + chainID int64, + blockHash []byte, + height int64, + header proofs.HeaderData, +) ([]byte, error) { + // check verification flags are set + if err := k.CheckVerificationFlagsEnabled(ctx, chainID); err != nil { + return nil, err + } + + // check if the block header already exists + if _, found := k.GetBlockHeader(ctx, blockHash); found { + return nil, cosmoserrors.Wrap(types.ErrBlockAlreadyExist, fmt.Sprintf("block hash: %x", blockHash)) + } + + // NOTE: error is checked in BasicValidation in msg; check again for extra caution + parentHash, err := header.ParentHash() + if err != nil { + return nil, cosmoserrors.Wrap(types.ErrNoParentHash, err.Error()) + } + + // if the chain state exists and parent block header is not found, returns error + // the Earliest/Latest height with this block header (after voting, not here) + // if ChainState is found, check if the block height is valid + // validate block height as it's not part of the header itself + chainState, found := k.GetChainState(ctx, chainID) + if found && chainState.EarliestHeight > 0 && chainState.EarliestHeight < height { + if height != chainState.LatestHeight+1 { + return nil, cosmoserrors.Wrap(types.ErrInvalidHeight, fmt.Sprintf( + "invalid block height: wanted %d, got %d", + chainState.LatestHeight+1, + height, + )) + } + _, found = k.GetBlockHeader(ctx, parentHash) + if !found { + return nil, cosmoserrors.Wrap(types.ErrNoParentHash, "parent block header not found") + } + } + + // Check timestamp + if err := header.ValidateTimestamp(ctx.BlockTime()); err != nil { + return nil, cosmoserrors.Wrap(types.ErrInvalidTimestamp, err.Error()) + } + + return parentHash, nil +} + +// AddBlockHeader adds a new block header to the store and updates the chain state +func (k Keeper) AddBlockHeader( + ctx sdk.Context, + chainID int64, + height int64, + blockHash []byte, + header proofs.HeaderData, + parentHash []byte, +) { + // update chain state + chainState, found := k.GetChainState(ctx, chainID) + if !found { + // create a new chain state if it does not exist + chainState = types.ChainState{ + ChainId: chainID, + LatestHeight: height, + EarliestHeight: height, + LatestBlockHash: blockHash, + } + } else { + // update the chain state with the latest block header + // TODO: these checks would need to be more sophisticated for production + // We should investigate and implement the correct assumptions for adding new block header + // https://github.com/zeta-chain/node/issues/1997 + if height > chainState.LatestHeight { + chainState.LatestHeight = height + chainState.LatestBlockHash = blockHash + } + if chainState.EarliestHeight == 0 { + chainState.EarliestHeight = height + } + } + k.SetChainState(ctx, chainState) + + // add the block header to the store + blockHeader := proofs.BlockHeader{ + Header: header, + Height: height, + Hash: blockHash, + ParentHash: parentHash, + ChainId: chainID, + } + k.SetBlockHeader(ctx, blockHeader) +} diff --git a/x/lightclient/keeper/block_header_test.go b/x/lightclient/keeper/block_header_test.go new file mode 100644 index 0000000000..2ecf50c1d9 --- /dev/null +++ b/x/lightclient/keeper/block_header_test.go @@ -0,0 +1,330 @@ +package keeper_test + +import ( + "encoding/json" + "os" + "testing" + + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rlp" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// readReceipt reads a receipt from a file. +// TODO: centralize test data +// https://github.com/zeta-chain/node/issues/1874 +func readHeader(filename string) (*ethtypes.Header, error) { + file, err := os.Open(filename) + if err != nil { + return nil, err + } + defer file.Close() + + decoder := json.NewDecoder(file) + var NewHeader ethtypes.Header + err = decoder.Decode(&NewHeader) + return &NewHeader, err +} + +func ethHeaders() (*ethtypes.Header, *ethtypes.Header, *ethtypes.Header, error) { + header1, err := readHeader("./testdata/header_sepolia_5000000.json") + if err != nil { + return nil, nil, nil, err + } + header2, err := readHeader("./testdata/header_sepolia_5000001.json") + if err != nil { + return nil, nil, nil, err + } + header3, err := readHeader("./testdata/header_sepolia_5000002.json") + if err != nil { + return nil, nil, nil, err + } + return header1, header2, header3, nil +} + +// sepoliaBlockHeaders returns three block headers for the Sepolia chain. +func sepoliaBlockHeaders(t *testing.T) (proofs.BlockHeader, proofs.BlockHeader, proofs.BlockHeader) { + header1, header2, header3, err := ethHeaders() + if err != nil { + panic(err) + } + + headerRLP1, err := rlp.EncodeToBytes(header1) + require.NoError(t, err) + headerRLP2, err := rlp.EncodeToBytes(header1) + require.NoError(t, err) + headerRLP3, err := rlp.EncodeToBytes(header1) + require.NoError(t, err) + + hex := header1.Hash().Hex() + hex = hex + + return proofs.BlockHeader{ + Height: 5000000, + Hash: header1.Hash().Bytes(), + ParentHash: header1.ParentHash.Bytes(), + ChainId: chains.SepoliaChain().ChainId, + Header: proofs.NewEthereumHeader(headerRLP1), + }, + proofs.BlockHeader{ + Height: 5000001, + Hash: header2.Hash().Bytes(), + ParentHash: header2.ParentHash.Bytes(), + ChainId: chains.SepoliaChain().ChainId, + Header: proofs.NewEthereumHeader(headerRLP2), + }, + proofs.BlockHeader{ + Height: 5000002, + Hash: header3.Hash().Bytes(), + ParentHash: header3.ParentHash.Bytes(), + ChainId: chains.SepoliaChain().ChainId, + Header: proofs.NewEthereumHeader(headerRLP3), + } +} + +// TestKeeper_GetBlockHeader tests get, set, and remove block header +func TestKeeper_GetBlockHeader(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + blockHash := sample.Hash().Bytes() + _, found := k.GetBlockHeader(ctx, blockHash) + require.False(t, found) + + k.SetBlockHeader(ctx, sample.BlockHeader(blockHash)) + _, found = k.GetBlockHeader(ctx, blockHash) + require.True(t, found) + + k.RemoveBlockHeader(ctx, blockHash) + _, found = k.GetBlockHeader(ctx, blockHash) + require.False(t, found) +} + +func TestKeeper_GetAllBlockHeaders(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + b1 := sample.BlockHeader(sample.Hash().Bytes()) + b2 := sample.BlockHeader(sample.Hash().Bytes()) + b3 := sample.BlockHeader(sample.Hash().Bytes()) + + k.SetBlockHeader(ctx, b1) + k.SetBlockHeader(ctx, b2) + k.SetBlockHeader(ctx, b3) + + list := k.GetAllBlockHeaders(ctx) + require.Len(t, list, 3) + require.Contains(t, list, b1) + require.Contains(t, list, b2) + require.Contains(t, list, b3) +} + +// TODO: Test with bitcoin headers +// https://github.com/zeta-chain/node/issues/1994 + +func TestKeeper_CheckNewBlockHeader(t *testing.T) { + t.Run("should succeed if block header is valid", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + }) + + bh, _, _ := sepoliaBlockHeaders(t) + + parentHash, err := k.CheckNewBlockHeader(ctx, bh.ChainId, bh.Hash, bh.Height, bh.Header) + require.NoError(t, err) + require.Equal(t, bh.ParentHash, parentHash) + }) + + t.Run("should fail if verification flag not enabled", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: false, + }) + + bh, _, _ := sepoliaBlockHeaders(t) + + _, err := k.CheckNewBlockHeader(ctx, bh.ChainId, bh.Hash, bh.Height, bh.Header) + require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) + }) + + // TODO: Fix the Sepolia sample headers to enable this test: + // https://github.com/zeta-chain/node/issues/1996 + //t.Run("should succeed if block header is valid with chain state existing", func(t *testing.T) { + // k, ctx, _, _ := keepertest.LightclientKeeper(t) + // + // k.SetVerificationFlags(ctx, types.VerificationFlags{ + // EthTypeChainEnabled: true, + // }) + // + // bh1, bh2, _ := sepoliaBlockHeaders(t) + // k.SetChainState(ctx, types.ChainState{ + // ChainId: bh1.ChainId, + // LatestHeight: bh1.Height, + // EarliestHeight: bh1.Height - 100, + // LatestBlockHash: bh1.Hash, + // }) + // k.SetBlockHeader(ctx, bh1) + // + // parentHash, err := k.CheckNewBlockHeader(ctx, bh2.ChainId, bh2.Hash, bh2.Height, bh2.Header) + // require.NoError(t, err) + // require.Equal(t, bh2.ParentHash, parentHash) + //}) + + t.Run("fail if block already exist", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + }) + + bh, _, _ := sepoliaBlockHeaders(t) + k.SetBlockHeader(ctx, bh) + + _, err := k.CheckNewBlockHeader(ctx, bh.ChainId, bh.Hash, bh.Height, bh.Header) + require.ErrorIs(t, err, types.ErrBlockAlreadyExist) + }) + + t.Run("fail if chain state and invalid height", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + }) + + bh, _, _ := sepoliaBlockHeaders(t) + + k.SetChainState(ctx, types.ChainState{ + ChainId: bh.ChainId, + LatestHeight: bh.Height - 2, + EarliestHeight: bh.Height - 100, + LatestBlockHash: bh.Hash, + }) + + _, err := k.CheckNewBlockHeader(ctx, bh.ChainId, bh.Hash, bh.Height, bh.Header) + require.ErrorIs(t, err, types.ErrInvalidHeight) + }) + + t.Run("fail if chain state and no parent", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + }) + + bh, _, _ := sepoliaBlockHeaders(t) + + k.SetChainState(ctx, types.ChainState{ + ChainId: bh.ChainId, + LatestHeight: bh.Height - 1, + EarliestHeight: bh.Height - 100, + LatestBlockHash: bh.Hash, + }) + + _, err := k.CheckNewBlockHeader(ctx, bh.ChainId, bh.Hash, bh.Height, bh.Header) + require.ErrorIs(t, err, types.ErrNoParentHash) + }) +} + +func TestKeeper_AddBlockHeader(t *testing.T) { + t.Run("should add a block header and create chain state if doesn't exist", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + }) + + bh, _, _ := sepoliaBlockHeaders(t) + + k.AddBlockHeader(ctx, bh.ChainId, bh.Height, bh.Hash, bh.Header, bh.ParentHash) + + retrieved, found := k.GetBlockHeader(ctx, bh.Hash) + require.True(t, found) + require.EqualValues(t, bh.Header, retrieved.Header) + require.EqualValues(t, bh.Height, retrieved.Height) + require.EqualValues(t, bh.Hash, retrieved.Hash) + require.EqualValues(t, bh.ParentHash, retrieved.ParentHash) + require.EqualValues(t, bh.ChainId, retrieved.ChainId) + + // Check chain state + chainState, found := k.GetChainState(ctx, bh.ChainId) + require.True(t, found) + require.EqualValues(t, bh.Height, chainState.LatestHeight) + require.EqualValues(t, bh.Height, chainState.EarliestHeight) + require.EqualValues(t, bh.Hash, chainState.LatestBlockHash) + require.EqualValues(t, bh.ChainId, chainState.ChainId) + }) + + t.Run("should add a block header and update chain state if exists", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + }) + + bh, _, _ := sepoliaBlockHeaders(t) + + k.SetChainState(ctx, types.ChainState{ + ChainId: bh.ChainId, + LatestHeight: bh.Height - 1, + EarliestHeight: bh.Height - 100, + LatestBlockHash: bh.ParentHash, + }) + + k.AddBlockHeader(ctx, bh.ChainId, bh.Height, bh.Hash, bh.Header, bh.ParentHash) + + retrieved, found := k.GetBlockHeader(ctx, bh.Hash) + require.True(t, found) + require.EqualValues(t, bh.Header, retrieved.Header) + require.EqualValues(t, bh.Height, retrieved.Height) + require.EqualValues(t, bh.Hash, retrieved.Hash) + require.EqualValues(t, bh.ParentHash, retrieved.ParentHash) + require.EqualValues(t, bh.ChainId, retrieved.ChainId) + + // Check chain state + chainState, found := k.GetChainState(ctx, bh.ChainId) + require.True(t, found) + require.EqualValues(t, bh.Height, chainState.LatestHeight) + require.EqualValues(t, bh.Height-100, chainState.EarliestHeight) + require.EqualValues(t, bh.Hash, chainState.LatestBlockHash) + require.EqualValues(t, bh.ChainId, chainState.ChainId) + }) + + t.Run("should add a block header and update chain state if exists and set earliest height if 0", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + }) + + bh, _, _ := sepoliaBlockHeaders(t) + + k.SetChainState(ctx, types.ChainState{ + ChainId: bh.ChainId, + LatestHeight: bh.Height - 1, + EarliestHeight: 0, + LatestBlockHash: bh.ParentHash, + }) + + k.AddBlockHeader(ctx, bh.ChainId, bh.Height, bh.Hash, bh.Header, bh.ParentHash) + + retrieved, found := k.GetBlockHeader(ctx, bh.Hash) + require.True(t, found) + require.EqualValues(t, bh.Header, retrieved.Header) + require.EqualValues(t, bh.Height, retrieved.Height) + require.EqualValues(t, bh.Hash, retrieved.Hash) + require.EqualValues(t, bh.ParentHash, retrieved.ParentHash) + require.EqualValues(t, bh.ChainId, retrieved.ChainId) + + // Check chain state + chainState, found := k.GetChainState(ctx, bh.ChainId) + require.True(t, found) + require.EqualValues(t, bh.Height, chainState.LatestHeight) + require.EqualValues(t, bh.Height, chainState.EarliestHeight) + require.EqualValues(t, bh.Hash, chainState.LatestBlockHash) + require.EqualValues(t, bh.ChainId, chainState.ChainId) + }) +} diff --git a/x/lightclient/keeper/chain_state.go b/x/lightclient/keeper/chain_state.go new file mode 100644 index 0000000000..9803f1d927 --- /dev/null +++ b/x/lightclient/keeper/chain_state.go @@ -0,0 +1,49 @@ +package keeper + +import ( + "fmt" + "strconv" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// GetAllChainStates returns all chain states +func (k Keeper) GetAllChainStates(ctx sdk.Context) (list []types.ChainState) { + p := types.KeyPrefix(fmt.Sprintf("%s", types.ChainStateKey)) + store := prefix.NewStore(ctx.KVStore(k.storeKey), p) + + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.ChainState + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return list +} + +// SetChainState set a specific chain state in the store from its index +func (k Keeper) SetChainState(ctx sdk.Context, chainState types.ChainState) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ChainStateKey)) + b := k.cdc.MustMarshal(&chainState) + key := strconv.FormatInt(chainState.ChainId, 10) + store.Set(types.KeyPrefix(key), b) +} + +// GetChainState returns a chain state from its chainID +func (k Keeper) GetChainState(ctx sdk.Context, chainID int64) (val types.ChainState, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ChainStateKey)) + + b := store.Get(types.KeyPrefix(strconv.FormatInt(chainID, 10))) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} diff --git a/x/lightclient/keeper/chain_state_test.go b/x/lightclient/keeper/chain_state_test.go new file mode 100644 index 0000000000..73c1b2f098 --- /dev/null +++ b/x/lightclient/keeper/chain_state_test.go @@ -0,0 +1,37 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" +) + +// TestKeeper_GetChainState tests get, and set chain state +func TestKeeper_GetChainState(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + _, found := k.GetChainState(ctx, 42) + require.False(t, found) + + k.SetChainState(ctx, sample.ChainState(42)) + _, found = k.GetChainState(ctx, 42) + require.True(t, found) +} + +func TestKeeper_GetAllChainStates(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + c1 := sample.ChainState(42) + c2 := sample.ChainState(43) + c3 := sample.ChainState(44) + + k.SetChainState(ctx, c1) + k.SetChainState(ctx, c2) + k.SetChainState(ctx, c3) + + list := k.GetAllChainStates(ctx) + require.Len(t, list, 3) + require.Contains(t, list, c1) + require.Contains(t, list, c2) + require.Contains(t, list, c3) +} diff --git a/x/lightclient/keeper/grpc_query.go b/x/lightclient/keeper/grpc_query.go new file mode 100644 index 0000000000..e1aee5607e --- /dev/null +++ b/x/lightclient/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/observer/keeper/grpc_query_block_header.go b/x/lightclient/keeper/grpc_query_block_header.go similarity index 50% rename from x/observer/keeper/grpc_query_block_header.go rename to x/lightclient/keeper/grpc_query_block_header.go index 18e9c955c6..d862ee3036 100644 --- a/x/observer/keeper/grpc_query_block_header.go +++ b/x/lightclient/keeper/grpc_query_block_header.go @@ -1,20 +1,18 @@ package keeper import ( - "context" - "fmt" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/zeta-chain/zetacore/pkg/proofs" - "github.com/zeta-chain/zetacore/x/observer/types" + "github.com/zeta-chain/zetacore/x/lightclient/types" + "golang.org/x/net/context" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -// GetAllBlockHeaders queries all for block header -func (k Keeper) GetAllBlockHeaders(c context.Context, req *types.QueryAllBlockHeaderRequest) (*types.QueryAllBlockHeaderResponse, error) { +// BlockHeaderAll queries all block headers +func (k Keeper) BlockHeaderAll(c context.Context, req *types.QueryAllBlockHeaderRequest) (*types.QueryAllBlockHeaderResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -22,14 +20,14 @@ func (k Keeper) GetAllBlockHeaders(c context.Context, req *types.QueryAllBlockHe store := ctx.KVStore(k.storeKey) blockHeaderStore := prefix.NewStore(store, types.KeyPrefix(types.BlockHeaderKey)) - var blockHeaders []*proofs.BlockHeader + var blockHeaders []proofs.BlockHeader pageRes, err := query.Paginate(blockHeaderStore, req.Pagination, func(key []byte, value []byte) error { var blockHeader proofs.BlockHeader if err := k.cdc.Unmarshal(value, &blockHeader); err != nil { return err } - blockHeaders = append(blockHeaders, &blockHeader) + blockHeaders = append(blockHeaders, blockHeader) return nil }) if err != nil { @@ -38,8 +36,8 @@ func (k Keeper) GetAllBlockHeaders(c context.Context, req *types.QueryAllBlockHe return &types.QueryAllBlockHeaderResponse{BlockHeaders: blockHeaders, Pagination: pageRes}, nil } -// GetBlockHeaderByHash queries block header by hash -func (k Keeper) GetBlockHeaderByHash(c context.Context, req *types.QueryGetBlockHeaderByHashRequest) (*types.QueryGetBlockHeaderByHashResponse, error) { +// BlockHeader queries block header by hash +func (k Keeper) BlockHeader(c context.Context, req *types.QueryGetBlockHeaderRequest) (*types.QueryGetBlockHeaderResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -49,18 +47,5 @@ func (k Keeper) GetBlockHeaderByHash(c context.Context, req *types.QueryGetBlock return nil, status.Error(codes.NotFound, "not found") } - return &types.QueryGetBlockHeaderByHashResponse{BlockHeader: &header}, nil -} - -func (k Keeper) GetBlockHeaderStateByChain(c context.Context, req *types.QueryGetBlockHeaderStateRequest) (*types.QueryGetBlockHeaderStateResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - state, found := k.GetBlockHeaderState(sdk.UnwrapSDKContext(c), req.ChainId) - if !found { - return nil, status.Error(codes.NotFound, fmt.Sprintf("not found: chain id %d", req.ChainId)) - } - - return &types.QueryGetBlockHeaderStateResponse{BlockHeaderState: &state}, nil + return &types.QueryGetBlockHeaderResponse{BlockHeader: &header}, nil } diff --git a/x/lightclient/keeper/grpc_query_block_header_test.go b/x/lightclient/keeper/grpc_query_block_header_test.go new file mode 100644 index 0000000000..8be62d2d75 --- /dev/null +++ b/x/lightclient/keeper/grpc_query_block_header_test.go @@ -0,0 +1,129 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/proofs" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/nullify" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestKeeper_BlockHeaderAll(t *testing.T) { + t.Run("should error if req is nil", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.BlockHeaderAll(wctx, nil) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should return if block header is found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + bh := sample.BlockHeader(sample.Hash().Bytes()) + k.SetBlockHeader(ctx, bh) + + res, err := k.BlockHeaderAll(wctx, &types.QueryAllBlockHeaderRequest{}) + require.NoError(t, err) + require.Equal(t, bh, res.BlockHeaders[0]) + }) + + t.Run("can run paginated queries", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + nbItems := 5 + + items := make([]proofs.BlockHeader, nbItems) + for i := range items { + items[i] = sample.BlockHeader(sample.Hash().Bytes()) + k.SetBlockHeader(ctx, items[i]) + } + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllBlockHeaderRequest { + return &types.QueryAllBlockHeaderRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < nbItems; i += step { + resp, err := k.BlockHeaderAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.BlockHeaders), step) + require.Subset(t, + nullify.Fill(items), + nullify.Fill(resp.BlockHeaders), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < nbItems; i += step { + resp, err := k.BlockHeaderAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.BlockHeaders), step) + require.Subset(t, + nullify.Fill(items), + nullify.Fill(resp.BlockHeaders), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := k.BlockHeaderAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, nbItems, int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(resp.BlockHeaders), + ) + }) + }) +} + +func TestKeeper_BlockHeader(t *testing.T) { + t.Run("should error if req is nil", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.BlockHeader(wctx, nil) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should error if not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.BlockHeader(wctx, &types.QueryGetBlockHeaderRequest{ + BlockHash: sample.Hash().Bytes(), + }) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should return if block header is found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + bh := sample.BlockHeader(sample.Hash().Bytes()) + k.SetBlockHeader(ctx, bh) + + res, err := k.BlockHeader(wctx, &types.QueryGetBlockHeaderRequest{ + BlockHash: bh.Hash, + }) + require.NoError(t, err) + require.Equal(t, &bh, res.BlockHeader) + }) +} diff --git a/x/lightclient/keeper/grpc_query_chain_state.go b/x/lightclient/keeper/grpc_query_chain_state.go new file mode 100644 index 0000000000..2fe168d536 --- /dev/null +++ b/x/lightclient/keeper/grpc_query_chain_state.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "context" + "fmt" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/zeta-chain/zetacore/x/lightclient/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// ChainStateAll queries all chain statess +func (k Keeper) ChainStateAll(c context.Context, req *types.QueryAllChainStateRequest) (*types.QueryAllChainStateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + store := ctx.KVStore(k.storeKey) + chainStateStore := prefix.NewStore(store, types.KeyPrefix(types.ChainStateKey)) + + var chainStates []types.ChainState + pageRes, err := query.Paginate(chainStateStore, req.Pagination, func(key []byte, value []byte) error { + var chainState types.ChainState + if err := k.cdc.Unmarshal(value, &chainState); err != nil { + return err + } + + chainStates = append(chainStates, chainState) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + return &types.QueryAllChainStateResponse{ChainState: chainStates, Pagination: pageRes}, nil +} + +// ChainState queries chain state by chain +func (k Keeper) ChainState(c context.Context, req *types.QueryGetChainStateRequest) (*types.QueryGetChainStateResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + state, found := k.GetChainState(sdk.UnwrapSDKContext(c), req.ChainId) + if !found { + return nil, status.Error(codes.NotFound, fmt.Sprintf("not found: chain id %d", req.ChainId)) + } + + return &types.QueryGetChainStateResponse{ChainState: &state}, nil +} diff --git a/x/lightclient/keeper/grpc_query_chain_state_test.go b/x/lightclient/keeper/grpc_query_chain_state_test.go new file mode 100644 index 0000000000..e8e9fe175e --- /dev/null +++ b/x/lightclient/keeper/grpc_query_chain_state_test.go @@ -0,0 +1,129 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/nullify" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestKeeper_ChainStateAll(t *testing.T) { + t.Run("should error if req is nil", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.ChainStateAll(wctx, nil) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should return if block header is found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + chainState := sample.ChainState(42) + k.SetChainState(ctx, chainState) + + res, err := k.ChainStateAll(wctx, &types.QueryAllChainStateRequest{}) + require.NoError(t, err) + require.Equal(t, chainState, res.ChainState[0]) + }) + + t.Run("can run paginated queries", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + nbItems := 5 + + items := make([]types.ChainState, nbItems) + for i := range items { + items[i] = sample.ChainState(int64(i)) + k.SetChainState(ctx, items[i]) + } + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllChainStateRequest { + return &types.QueryAllChainStateRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < nbItems; i += step { + resp, err := k.ChainStateAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.ChainState), step) + require.Subset(t, + nullify.Fill(items), + nullify.Fill(resp.ChainState), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < nbItems; i += step { + resp, err := k.ChainStateAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.ChainState), step) + require.Subset(t, + nullify.Fill(items), + nullify.Fill(resp.ChainState), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := k.ChainStateAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, nbItems, int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(resp.ChainState), + ) + }) + }) +} + +func TestKeeper_ChainState(t *testing.T) { + t.Run("should error if req is nil", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.ChainState(wctx, nil) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should error if not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.ChainState(wctx, &types.QueryGetChainStateRequest{ + ChainId: 1, + }) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should return if block header state is found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + chainState := sample.ChainState(42) + k.SetChainState(ctx, chainState) + + res, err := k.ChainState(wctx, &types.QueryGetChainStateRequest{ + ChainId: 42, + }) + require.NoError(t, err) + require.Equal(t, &chainState, res.ChainState) + }) +} diff --git a/x/observer/keeper/grpc_query_prove.go b/x/lightclient/keeper/grpc_query_prove.go similarity index 96% rename from x/observer/keeper/grpc_query_prove.go rename to x/lightclient/keeper/grpc_query_prove.go index edfd0588e5..7fbbc8bf3c 100644 --- a/x/observer/keeper/grpc_query_prove.go +++ b/x/lightclient/keeper/grpc_query_prove.go @@ -5,17 +5,16 @@ import ( "fmt" "github.com/btcsuite/btcutil" - "github.com/zeta-chain/zetacore/pkg/chains" - "github.com/zeta-chain/zetacore/pkg/proofs" - sdk "github.com/cosmos/cosmos-sdk/types" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/zeta-chain/zetacore/x/observer/types" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + "github.com/zeta-chain/zetacore/x/lightclient/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) -// Prove simply checks two things: +// Prove checks two things: // 1. the block header is available // 2. the proof is valid func (k Keeper) Prove(c context.Context, req *types.QueryProveRequest) (*types.QueryProveResponse, error) { diff --git a/x/lightclient/keeper/grpc_query_prove_test.go b/x/lightclient/keeper/grpc_query_prove_test.go new file mode 100644 index 0000000000..34ca1b7f28 --- /dev/null +++ b/x/lightclient/keeper/grpc_query_prove_test.go @@ -0,0 +1,134 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/proofs" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// TODO: Add test for Bitcoin proof verification +// https://github.com/zeta-chain/node/issues/1994 + +func TestKeeper_Prove(t *testing.T) { + t.Run("should error if req is nil", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + _, err := k.Prove(wctx, nil) + require.Error(t, err) + }) + + t.Run("should error if block hash is invalid", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + proof, _, _, txIndex, _, hash := sample.Proof(t) + + _, err := k.Prove(wctx, &types.QueryProveRequest{ + ChainId: 1000, + TxHash: hash.Hex(), + Proof: proof, + BlockHash: "invalid", + TxIndex: txIndex, + }) + require.ErrorContains(t, err, "cannot convert hash to bytes for chain") + }) + + t.Run("should error if block header not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + proof, _, blockHash, txIndex, chainID, hash := sample.Proof(t) + + _, err := k.Prove(wctx, &types.QueryProveRequest{ + ChainId: chainID, + TxHash: hash.Hex(), + Proof: proof, + BlockHash: blockHash, + TxIndex: txIndex, + }) + require.ErrorContains(t, err, "block header not found") + }) + + t.Run("should returns response with proven false if invalid proof", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + proof, blockHeader, blockHash, txIndex, chainID, hash := sample.Proof(t) + + k.SetBlockHeader(ctx, blockHeader) + + res, err := k.Prove(wctx, &types.QueryProveRequest{ + ChainId: chainID, + TxHash: hash.Hex(), + Proof: proof, + BlockHash: blockHash, + TxIndex: txIndex + 1, // change txIndex to make it invalid + }) + require.NoError(t, err) + require.False(t, res.Valid) + }) + + t.Run("should returns response with proven true if valid proof", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + proof, blockHeader, blockHash, txIndex, chainID, hash := sample.Proof(t) + + k.SetBlockHeader(ctx, blockHeader) + + res, err := k.Prove(wctx, &types.QueryProveRequest{ + ChainId: chainID, + TxHash: hash.Hex(), + Proof: proof, + BlockHash: blockHash, + TxIndex: txIndex, + }) + require.NoError(t, err) + require.True(t, res.Valid) + }) + + t.Run("should error if error during proof verification", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + proof, blockHeader, blockHash, txIndex, chainID, hash := sample.Proof(t) + + // corrupt the block header + blockHeader.Header = proofs.HeaderData{} + + k.SetBlockHeader(ctx, blockHeader) + + _, err := k.Prove(wctx, &types.QueryProveRequest{ + ChainId: chainID, + TxHash: hash.Hex(), + Proof: proof, + BlockHash: blockHash, + TxIndex: txIndex, + }) + require.Error(t, err) + }) + + t.Run("should error if tx hash mismatch", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) + + k.SetBlockHeader(ctx, blockHeader) + + _, err := k.Prove(wctx, &types.QueryProveRequest{ + ChainId: chainID, + TxHash: sample.Hash().Hex(), // change tx hash to make it invalid + Proof: proof, + BlockHash: blockHash, + TxIndex: txIndex, + }) + require.ErrorContains(t, err, "tx hash mismatch") + }) +} diff --git a/x/lightclient/keeper/grpc_query_verification_flags.go b/x/lightclient/keeper/grpc_query_verification_flags.go new file mode 100644 index 0000000000..aca55988c0 --- /dev/null +++ b/x/lightclient/keeper/grpc_query_verification_flags.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/lightclient/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// VerificationFlags implements the Query/VerificationFlags gRPC method +func (k Keeper) VerificationFlags(c context.Context, req *types.QueryVerificationFlagsRequest) (*types.QueryVerificationFlagsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + val, found := k.GetVerificationFlags(ctx) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryVerificationFlagsResponse{VerificationFlags: val}, nil +} diff --git a/x/lightclient/keeper/grpc_query_verification_flags_test.go b/x/lightclient/keeper/grpc_query_verification_flags_test.go new file mode 100644 index 0000000000..d11d6eb637 --- /dev/null +++ b/x/lightclient/keeper/grpc_query_verification_flags_test.go @@ -0,0 +1,47 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestKeeper_VerificationFlags(t *testing.T) { + t.Run("should error if req is nil", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.VerificationFlags(wctx, nil) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should error if not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.VerificationFlags(wctx, &types.QueryVerificationFlagsRequest{}) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should return if block header state is found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }) + + res, err := k.VerificationFlags(wctx, &types.QueryVerificationFlagsRequest{}) + require.NoError(t, err) + require.Equal(t, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }, res.VerificationFlags) + }) +} diff --git a/x/lightclient/keeper/keeper.go b/x/lightclient/keeper/keeper.go new file mode 100644 index 0000000000..e0e6277c88 --- /dev/null +++ b/x/lightclient/keeper/keeper.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/libs/log" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine +type Keeper struct { + cdc codec.Codec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + authorityKeeper types.AuthorityKeeper +} + +// NewKeeper creates new instances of the lightclient Keeper +func NewKeeper( + cdc codec.Codec, + storeKey, + memKey storetypes.StoreKey, + authorityKeeper types.AuthorityKeeper, +) Keeper { + return Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + authorityKeeper: authorityKeeper, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// GetStoreKey returns the key to the store for lightclient +func (k Keeper) GetStoreKey() storetypes.StoreKey { + return k.storeKey +} + +// GetMemKey returns the mem key to the store for lightclient +func (k Keeper) GetMemKey() storetypes.StoreKey { + return k.memKey +} + +// GetCodec returns the codec for lightclient +func (k Keeper) GetCodec() codec.Codec { + return k.cdc +} + +// GetAuthorityKeeper returns the authority keeper +func (k Keeper) GetAuthorityKeeper() types.AuthorityKeeper { + return k.authorityKeeper +} diff --git a/x/lightclient/keeper/msg_server.go b/x/lightclient/keeper/msg_server.go new file mode 100644 index 0000000000..6f67361196 --- /dev/null +++ b/x/lightclient/keeper/msg_server.go @@ -0,0 +1,15 @@ +package keeper + +import "github.com/zeta-chain/zetacore/x/lightclient/types" + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} //nolint:typecheck +} + +var _ types.MsgServer = msgServer{} //nolint:typecheck diff --git a/x/lightclient/keeper/msg_server_update_verification_flags.go b/x/lightclient/keeper/msg_server_update_verification_flags.go new file mode 100644 index 0000000000..3330522e5e --- /dev/null +++ b/x/lightclient/keeper/msg_server_update_verification_flags.go @@ -0,0 +1,28 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// UpdateVerificationFlags updates the light client verification flags. +// This disables/enables blocks verification of the light client for the specified chain. +// Emergency group can disable flags, it requires operational group if at least one flag is being enabled +func (k msgServer) UpdateVerificationFlags(goCtx context.Context, msg *types.MsgUpdateVerificationFlags) ( + *types.MsgUpdateVerificationFlagsResponse, + error, +) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // check permission + if !k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, msg.GetRequireGroup()) { + return &types.MsgUpdateVerificationFlagsResponse{}, authoritytypes.ErrUnauthorized + } + + k.SetVerificationFlags(ctx, msg.VerificationFlags) + + return &types.MsgUpdateVerificationFlagsResponse{}, nil +} diff --git a/x/lightclient/keeper/msg_server_update_verification_flags_test.go b/x/lightclient/keeper/msg_server_update_verification_flags_test.go new file mode 100644 index 0000000000..4c483802be --- /dev/null +++ b/x/lightclient/keeper/msg_server_update_verification_flags_test.go @@ -0,0 +1,142 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/lightclient/keeper" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestMsgServer_UpdateVerificationFlags(t *testing.T) { + t.Run("operational group can enable verification flags", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: false, + }) + + // enable eth type chain + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + _, err := srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ + Creator: admin, + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: false, + }, + }) + require.NoError(t, err) + vf, found := k.GetVerificationFlags(ctx) + require.True(t, found) + require.True(t, vf.EthTypeChainEnabled) + require.False(t, vf.BtcTypeChainEnabled) + + // enable btc type chain + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + _, err = srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ + Creator: admin, + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }, + }) + require.NoError(t, err) + vf, found = k.GetVerificationFlags(ctx) + require.True(t, found) + require.False(t, vf.EthTypeChainEnabled) + require.True(t, vf.BtcTypeChainEnabled) + + // enable both eth and btc type chain + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + _, err = srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ + Creator: admin, + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + }, + }) + require.NoError(t, err) + vf, found = k.GetVerificationFlags(ctx) + require.True(t, found) + require.True(t, vf.EthTypeChainEnabled) + require.True(t, vf.BtcTypeChainEnabled) + }) + + t.Run("emergency group can disable verification flags", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: false, + }) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) + _, err := srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ + Creator: admin, + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: false, + }, + }) + require.NoError(t, err) + vf, found := k.GetVerificationFlags(ctx) + require.True(t, found) + require.False(t, vf.EthTypeChainEnabled) + require.False(t, vf.BtcTypeChainEnabled) + }) + + t.Run("cannot update if not authorized group", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeperWithMocks(t, keepertest.LightclientMockOptions{ + UseAuthorityMock: true, + }) + srv := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + // mock the authority keeper for authorization + authorityMock := keepertest.GetLightclientAuthorityMock(t, k) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: false, + }) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) + _, err := srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ + Creator: admin, + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: false, + }, + }) + require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) + _, err = srv.UpdateVerificationFlags(sdk.WrapSDKContext(ctx), &types.MsgUpdateVerificationFlags{ + Creator: admin, + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: false, + }, + }) + require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) + }) +} diff --git a/x/lightclient/keeper/proof.go b/x/lightclient/keeper/proof.go new file mode 100644 index 0000000000..9cfcd45828 --- /dev/null +++ b/x/lightclient/keeper/proof.go @@ -0,0 +1,35 @@ +package keeper + +import ( + cosmoserror "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// VerifyProof verifies the merkle proof for a given chain and block header +// It returns the transaction bytes if the proof is valid +func (k Keeper) VerifyProof(ctx sdk.Context, proof *proofs.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) { + // check verification flags are set + if err := k.CheckVerificationFlagsEnabled(ctx, chainID); err != nil { + return nil, err + } + + // get block header from the store + hashBytes, err := chains.StringToHash(chainID, blockHash) + if err != nil { + return nil, cosmoserror.Wrapf(types.ErrInvalidBlockHash, "block hash %s conversion failed %s", blockHash, err.Error()) + } + res, found := k.GetBlockHeader(ctx, hashBytes) + if !found { + return nil, cosmoserror.Wrapf(types.ErrBlockHeaderNotFound, "block header not found %s", blockHash) + } + + // verify merkle proof + txBytes, err := proof.Verify(res.Header, int(txIndex)) + if err != nil { + return nil, cosmoserror.Wrapf(types.ErrProofVerificationFailed, "failed to verify merkle proof: %s", err.Error()) + } + return txBytes, nil +} diff --git a/x/lightclient/keeper/proof_test.go b/x/lightclient/keeper/proof_test.go new file mode 100644 index 0000000000..810c9a0371 --- /dev/null +++ b/x/lightclient/keeper/proof_test.go @@ -0,0 +1,115 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestKeeper_VerifyProof(t *testing.T) { + t.Run("should error if verification flags not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain().ChainId, sample.Hash().String(), 1) + require.ErrorIs(t, err, types.ErrVerificationFlagsNotFound) + }) + + t.Run("should error if verification not enabled for btc chain", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: false, + }) + + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain().ChainId, sample.Hash().String(), 1) + require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) + }) + + t.Run("should error if verification not enabled for evm chain", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }) + + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain().ChainId, sample.Hash().String(), 1) + require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) + }) + + t.Run("should error if block header-based verification not supported", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + }) + + _, err := k.VerifyProof(ctx, &proofs.Proof{}, 101, sample.Hash().String(), 1) + require.ErrorIs(t, err, types.ErrChainNotSupported) + }) + + t.Run("should error if blockhash invalid", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + }) + + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.BtcMainnetChain().ChainId, "invalid", 1) + require.ErrorIs(t, err, types.ErrInvalidBlockHash) + }) + + t.Run("should error if block header not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + }) + + _, err := k.VerifyProof(ctx, &proofs.Proof{}, chains.SepoliaChain().ChainId, sample.Hash().String(), 1) + require.ErrorIs(t, err, types.ErrBlockHeaderNotFound) + }) + + t.Run("should fail if proof can't be verified", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + }) + + k.SetBlockHeader(ctx, blockHeader) + + // providing wrong tx index + _, err := k.VerifyProof(ctx, proof, chainID, blockHash, txIndex+1) + require.ErrorIs(t, err, types.ErrProofVerificationFailed) + }) + + t.Run("can verify a proof", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + proof, blockHeader, blockHash, txIndex, chainID, _ := sample.Proof(t) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + }) + + k.SetBlockHeader(ctx, blockHeader) + + txBytes, err := k.VerifyProof(ctx, proof, chainID, blockHash, txIndex) + require.NoError(t, err) + require.NotNil(t, txBytes) + }) +} diff --git a/x/observer/keeper/testdata/header_sepolia_5000000.json b/x/lightclient/keeper/testdata/header_sepolia_5000000.json similarity index 100% rename from x/observer/keeper/testdata/header_sepolia_5000000.json rename to x/lightclient/keeper/testdata/header_sepolia_5000000.json diff --git a/x/observer/keeper/testdata/header_sepolia_5000001.json b/x/lightclient/keeper/testdata/header_sepolia_5000001.json similarity index 100% rename from x/observer/keeper/testdata/header_sepolia_5000001.json rename to x/lightclient/keeper/testdata/header_sepolia_5000001.json diff --git a/x/observer/keeper/testdata/header_sepolia_5000002.json b/x/lightclient/keeper/testdata/header_sepolia_5000002.json similarity index 100% rename from x/observer/keeper/testdata/header_sepolia_5000002.json rename to x/lightclient/keeper/testdata/header_sepolia_5000002.json diff --git a/x/lightclient/keeper/verification_flags.go b/x/lightclient/keeper/verification_flags.go new file mode 100644 index 0000000000..169eb3a4b6 --- /dev/null +++ b/x/lightclient/keeper/verification_flags.go @@ -0,0 +1,65 @@ +package keeper + +import ( + cosmoserrors "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +// SetVerificationFlags set the verification flags in the store +func (k Keeper) SetVerificationFlags(ctx sdk.Context, crosschainFlags types.VerificationFlags) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) + b := k.cdc.MustMarshal(&crosschainFlags) + store.Set([]byte{0}, b) +} + +// GetVerificationFlags returns the verification flags +func (k Keeper) GetVerificationFlags(ctx sdk.Context) (val types.VerificationFlags, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.VerificationFlagsKey)) + + b := store.Get([]byte{0}) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// CheckVerificationFlagsEnabled checks for a specific chain if the verification flags are enabled +// It returns an error if the chain is not enabled +func (k Keeper) CheckVerificationFlagsEnabled(ctx sdk.Context, chainID int64) error { + verificationFlags, found := k.GetVerificationFlags(ctx) + if !found { + return types.ErrVerificationFlagsNotFound + } + + // check if the chain is enabled for the specific type + if chains.IsBitcoinChain(chainID) { + if !verificationFlags.BtcTypeChainEnabled { + return cosmoserrors.Wrapf( + types.ErrBlockHeaderVerificationDisabled, + "proof verification not enabled for bitcoin ,chain id: %d", + chainID, + ) + } + } else if chains.IsEVMChain(chainID) { + if !verificationFlags.EthTypeChainEnabled { + return cosmoserrors.Wrapf( + types.ErrBlockHeaderVerificationDisabled, + "proof verification not enabled for evm ,chain id: %d", + chainID, + ) + } + } else { + return cosmoserrors.Wrapf( + types.ErrChainNotSupported, + "chain ID %d doesn't support block header verification", + chainID, + ) + } + + return nil +} diff --git a/x/lightclient/keeper/verification_flags_test.go b/x/lightclient/keeper/verification_flags_test.go new file mode 100644 index 0000000000..f90f78966a --- /dev/null +++ b/x/lightclient/keeper/verification_flags_test.go @@ -0,0 +1,70 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestKeeper_GetVerificationFlags(t *testing.T) { + t.Run("can get and set verification flags", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + + vf, found := k.GetVerificationFlags(ctx) + require.False(t, found) + + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }) + vf, found = k.GetVerificationFlags(ctx) + require.True(t, found) + require.Equal(t, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }, vf) + }) +} + +func TestKeeper_CheckVerificationFlagsEnabled(t *testing.T) { + t.Run("can check verification flags with ethereum enabled", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: false, + }) + + err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain().ChainId) + require.NoError(t, err) + + err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain().ChainId) + require.Error(t, err) + require.ErrorContains(t, err, "proof verification not enabled for bitcoin") + + err = k.CheckVerificationFlagsEnabled(ctx, 1000) + require.Error(t, err) + require.ErrorContains(t, err, "doesn't support block header verification") + }) + + t.Run("can check verification flags with bitcoin enabled", func(t *testing.T) { + k, ctx, _, _ := keepertest.LightclientKeeper(t) + k.SetVerificationFlags(ctx, types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }) + + err := k.CheckVerificationFlagsEnabled(ctx, chains.EthChain().ChainId) + require.Error(t, err) + require.ErrorContains(t, err, "proof verification not enabled for evm") + + err = k.CheckVerificationFlagsEnabled(ctx, chains.BtcMainnetChain().ChainId) + require.NoError(t, err) + + err = k.CheckVerificationFlagsEnabled(ctx, 1000) + require.Error(t, err) + require.ErrorContains(t, err, "doesn't support block header verification") + }) +} diff --git a/x/lightclient/module.go b/x/lightclient/module.go new file mode 100644 index 0000000000..ab1d287a6f --- /dev/null +++ b/x/lightclient/module.go @@ -0,0 +1,171 @@ +package lightclient + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/zeta-chain/zetacore/x/lightclient/client/cli" + "github.com/zeta-chain/zetacore/x/lightclient/keeper" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the lightclient module. +type AppModuleBasic struct { + cdc codec.Codec +} + +func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the lightclient module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the lightclient module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the lightclient module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the lightclient module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + fmt.Println("RegisterQueryHandlerClient err: %w", err) + } +} + +// GetTxCmd returns the lightclient module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the lightclient module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the lightclient module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the lightclient module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the lightclient module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +// QuerierRoute returns the lightclient module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the lightclient module's Querier. +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the lightclient module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the lightclient module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the lightclient module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the lightclient module. +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the lightclient module. It +// returns no validator updates. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/observer/types/block_header.pb.go b/x/lightclient/types/chain_state.pb.go similarity index 55% rename from x/observer/types/block_header.pb.go rename to x/lightclient/types/chain_state.pb.go index b70effc517..83c7c30e9a 100644 --- a/x/observer/types/block_header.pb.go +++ b/x/lightclient/types/chain_state.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: observer/block_header.proto +// source: lightclient/chain_state.proto package types @@ -24,25 +24,26 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type BlockHeaderState struct { +// ChainState defines the overall state of the block headers for a given chain +type ChainState struct { ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` LatestHeight int64 `protobuf:"varint,2,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height,omitempty"` EarliestHeight int64 `protobuf:"varint,3,opt,name=earliest_height,json=earliestHeight,proto3" json:"earliest_height,omitempty"` LatestBlockHash []byte `protobuf:"bytes,4,opt,name=latest_block_hash,json=latestBlockHash,proto3" json:"latest_block_hash,omitempty"` } -func (m *BlockHeaderState) Reset() { *m = BlockHeaderState{} } -func (m *BlockHeaderState) String() string { return proto.CompactTextString(m) } -func (*BlockHeaderState) ProtoMessage() {} -func (*BlockHeaderState) Descriptor() ([]byte, []int) { - return fileDescriptor_9fad6da3aeeeaa45, []int{0} +func (m *ChainState) Reset() { *m = ChainState{} } +func (m *ChainState) String() string { return proto.CompactTextString(m) } +func (*ChainState) ProtoMessage() {} +func (*ChainState) Descriptor() ([]byte, []int) { + return fileDescriptor_f37529902e23c4eb, []int{0} } -func (m *BlockHeaderState) XXX_Unmarshal(b []byte) error { +func (m *ChainState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *BlockHeaderState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ChainState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_BlockHeaderState.Marshal(b, m, deterministic) + return xxx_messageInfo_ChainState.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -52,40 +53,40 @@ func (m *BlockHeaderState) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *BlockHeaderState) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockHeaderState.Merge(m, src) +func (m *ChainState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChainState.Merge(m, src) } -func (m *BlockHeaderState) XXX_Size() int { +func (m *ChainState) XXX_Size() int { return m.Size() } -func (m *BlockHeaderState) XXX_DiscardUnknown() { - xxx_messageInfo_BlockHeaderState.DiscardUnknown(m) +func (m *ChainState) XXX_DiscardUnknown() { + xxx_messageInfo_ChainState.DiscardUnknown(m) } -var xxx_messageInfo_BlockHeaderState proto.InternalMessageInfo +var xxx_messageInfo_ChainState proto.InternalMessageInfo -func (m *BlockHeaderState) GetChainId() int64 { +func (m *ChainState) GetChainId() int64 { if m != nil { return m.ChainId } return 0 } -func (m *BlockHeaderState) GetLatestHeight() int64 { +func (m *ChainState) GetLatestHeight() int64 { if m != nil { return m.LatestHeight } return 0 } -func (m *BlockHeaderState) GetEarliestHeight() int64 { +func (m *ChainState) GetEarliestHeight() int64 { if m != nil { return m.EarliestHeight } return 0 } -func (m *BlockHeaderState) GetLatestBlockHash() []byte { +func (m *ChainState) GetLatestBlockHash() []byte { if m != nil { return m.LatestBlockHash } @@ -93,33 +94,32 @@ func (m *BlockHeaderState) GetLatestBlockHash() []byte { } func init() { - proto.RegisterType((*BlockHeaderState)(nil), "zetachain.zetacore.observer.BlockHeaderState") + proto.RegisterType((*ChainState)(nil), "zetachain.zetacore.lightclient.ChainState") } -func init() { proto.RegisterFile("observer/block_header.proto", fileDescriptor_9fad6da3aeeeaa45) } +func init() { proto.RegisterFile("lightclient/chain_state.proto", fileDescriptor_f37529902e23c4eb) } -var fileDescriptor_9fad6da3aeeeaa45 = []byte{ - // 267 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0x4f, 0x2a, 0x4e, - 0x2d, 0x2a, 0x4b, 0x2d, 0xd2, 0x4f, 0xca, 0xc9, 0x4f, 0xce, 0x8e, 0xcf, 0x48, 0x4d, 0x4c, 0x49, - 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xae, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, - 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x60, 0xea, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, - 0xf3, 0xc1, 0xea, 0xf4, 0x41, 0x2c, 0x88, 0x16, 0x29, 0x71, 0xb8, 0x79, 0x30, 0x06, 0x44, 0x42, - 0x69, 0x39, 0x23, 0x97, 0x80, 0x13, 0xc8, 0x0a, 0x0f, 0xb0, 0x0d, 0xc1, 0x25, 0x89, 0x25, 0xa9, - 0x42, 0x92, 0x5c, 0x1c, 0x60, 0xe3, 0xe3, 0x33, 0x53, 0x24, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83, - 0xd8, 0xc1, 0x7c, 0xcf, 0x14, 0x21, 0x65, 0x2e, 0xde, 0x9c, 0xc4, 0x92, 0xd4, 0xe2, 0x92, 0xf8, - 0x8c, 0xd4, 0xcc, 0xf4, 0x8c, 0x12, 0x09, 0x26, 0xb0, 0x3c, 0x0f, 0x44, 0xd0, 0x03, 0x2c, 0x26, - 0xa4, 0xce, 0xc5, 0x9f, 0x9a, 0x58, 0x94, 0x93, 0x89, 0xa4, 0x8c, 0x19, 0xac, 0x8c, 0x0f, 0x26, - 0x0c, 0x55, 0xa8, 0xc5, 0x25, 0x08, 0x35, 0x0d, 0xea, 0xcd, 0xc4, 0xe2, 0x0c, 0x09, 0x16, 0x05, - 0x46, 0x0d, 0x9e, 0x20, 0x7e, 0x88, 0x04, 0xc4, 0x6d, 0x89, 0xc5, 0x19, 0x4e, 0x9e, 0x27, 0x1e, - 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, - 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9f, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, - 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x0a, 0x10, 0x5d, 0xb0, 0x63, 0xf5, 0x61, 0x61, 0xa3, 0x5f, 0x01, - 0xf7, 0xb4, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xef, 0xc6, 0x80, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xa7, 0xf5, 0x45, 0x4d, 0x66, 0x01, 0x00, 0x00, +var fileDescriptor_f37529902e23c4eb = []byte{ + // 256 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0xc9, 0x4c, 0xcf, + 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x4f, 0xce, 0x48, 0xcc, 0xcc, 0x8b, 0x2f, 0x2e, + 0x49, 0x2c, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x04, + 0x0b, 0xeb, 0x81, 0x59, 0xf9, 0x45, 0xa9, 0x7a, 0x48, 0x3a, 0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, 0xdc, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x25, 0xd8, 0xef, 0x7c, 0x4f, 0x01, 0x00, 0x00, } -func (m *BlockHeaderState) Marshal() (dAtA []byte, err error) { +func (m *ChainState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -129,12 +129,12 @@ func (m *BlockHeaderState) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *BlockHeaderState) MarshalTo(dAtA []byte) (int, error) { +func (m *ChainState) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *BlockHeaderState) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ChainState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -142,30 +142,30 @@ func (m *BlockHeaderState) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.LatestBlockHash) > 0 { i -= len(m.LatestBlockHash) copy(dAtA[i:], m.LatestBlockHash) - i = encodeVarintBlockHeader(dAtA, i, uint64(len(m.LatestBlockHash))) + i = encodeVarintChainState(dAtA, i, uint64(len(m.LatestBlockHash))) i-- dAtA[i] = 0x22 } if m.EarliestHeight != 0 { - i = encodeVarintBlockHeader(dAtA, i, uint64(m.EarliestHeight)) + i = encodeVarintChainState(dAtA, i, uint64(m.EarliestHeight)) i-- dAtA[i] = 0x18 } if m.LatestHeight != 0 { - i = encodeVarintBlockHeader(dAtA, i, uint64(m.LatestHeight)) + i = encodeVarintChainState(dAtA, i, uint64(m.LatestHeight)) i-- dAtA[i] = 0x10 } if m.ChainId != 0 { - i = encodeVarintBlockHeader(dAtA, i, uint64(m.ChainId)) + i = encodeVarintChainState(dAtA, i, uint64(m.ChainId)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func encodeVarintBlockHeader(dAtA []byte, offset int, v uint64) int { - offset -= sovBlockHeader(v) +func encodeVarintChainState(dAtA []byte, offset int, v uint64) int { + offset -= sovChainState(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -175,35 +175,35 @@ func encodeVarintBlockHeader(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *BlockHeaderState) Size() (n int) { +func (m *ChainState) Size() (n int) { if m == nil { return 0 } var l int _ = l if m.ChainId != 0 { - n += 1 + sovBlockHeader(uint64(m.ChainId)) + n += 1 + sovChainState(uint64(m.ChainId)) } if m.LatestHeight != 0 { - n += 1 + sovBlockHeader(uint64(m.LatestHeight)) + n += 1 + sovChainState(uint64(m.LatestHeight)) } if m.EarliestHeight != 0 { - n += 1 + sovBlockHeader(uint64(m.EarliestHeight)) + n += 1 + sovChainState(uint64(m.EarliestHeight)) } l = len(m.LatestBlockHash) if l > 0 { - n += 1 + l + sovBlockHeader(uint64(l)) + n += 1 + l + sovChainState(uint64(l)) } return n } -func sovBlockHeader(x uint64) (n int) { +func sovChainState(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozBlockHeader(x uint64) (n int) { - return sovBlockHeader(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozChainState(x uint64) (n int) { + return sovChainState(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { +func (m *ChainState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -211,7 +211,7 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowBlockHeader + return ErrIntOverflowChainState } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -226,10 +226,10 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BlockHeaderState: wiretype end group for non-group") + return fmt.Errorf("proto: ChainState: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BlockHeaderState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ChainState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -239,7 +239,7 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { m.ChainId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowBlockHeader + return ErrIntOverflowChainState } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -258,7 +258,7 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { m.LatestHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowBlockHeader + return ErrIntOverflowChainState } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -277,7 +277,7 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { m.EarliestHeight = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowBlockHeader + return ErrIntOverflowChainState } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -296,7 +296,7 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowBlockHeader + return ErrIntOverflowChainState } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -309,11 +309,11 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthBlockHeader + return ErrInvalidLengthChainState } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthBlockHeader + return ErrInvalidLengthChainState } if postIndex > l { return io.ErrUnexpectedEOF @@ -325,12 +325,12 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipBlockHeader(dAtA[iNdEx:]) + skippy, err := skipChainState(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthBlockHeader + return ErrInvalidLengthChainState } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -344,7 +344,7 @@ func (m *BlockHeaderState) Unmarshal(dAtA []byte) error { } return nil } -func skipBlockHeader(dAtA []byte) (n int, err error) { +func skipChainState(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -352,7 +352,7 @@ func skipBlockHeader(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowBlockHeader + return 0, ErrIntOverflowChainState } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -369,7 +369,7 @@ func skipBlockHeader(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowBlockHeader + return 0, ErrIntOverflowChainState } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -385,7 +385,7 @@ func skipBlockHeader(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowBlockHeader + return 0, ErrIntOverflowChainState } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -398,14 +398,14 @@ func skipBlockHeader(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthBlockHeader + return 0, ErrInvalidLengthChainState } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupBlockHeader + return 0, ErrUnexpectedEndOfGroupChainState } depth-- case 5: @@ -414,7 +414,7 @@ func skipBlockHeader(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthBlockHeader + return 0, ErrInvalidLengthChainState } if depth == 0 { return iNdEx, nil @@ -424,7 +424,7 @@ func skipBlockHeader(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthBlockHeader = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowBlockHeader = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupBlockHeader = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthChainState = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowChainState = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupChainState = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/lightclient/types/codec.go b/x/lightclient/types/codec.go new file mode 100644 index 0000000000..b8a4fe6c43 --- /dev/null +++ b/x/lightclient/types/codec.go @@ -0,0 +1,25 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgUpdateVerificationFlags{}, "lightclient/UpdateVerificationFlags", nil) +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateVerificationFlags{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/lightclient/types/errors.go b/x/lightclient/types/errors.go new file mode 100644 index 0000000000..b4f5d93d94 --- /dev/null +++ b/x/lightclient/types/errors.go @@ -0,0 +1,17 @@ +package types + +import errorsmod "cosmossdk.io/errors" + +var ( + ErrBlockAlreadyExist = errorsmod.Register(ModuleName, 1101, "block already exists") + ErrNoParentHash = errorsmod.Register(ModuleName, 1102, "no parent hash") + ErrInvalidTimestamp = errorsmod.Register(ModuleName, 1103, "invalid timestamp") + ErrBlockHeaderVerificationDisabled = errorsmod.Register(ModuleName, 1104, "block header verification is disabled") + ErrVerificationFlagsNotFound = errorsmod.Register(ModuleName, 1105, "verification flags not found") + ErrChainNotSupported = errorsmod.Register(ModuleName, 1106, "chain not supported") + ErrInvalidBlockHash = errorsmod.Register(ModuleName, 1107, "invalid block hash") + ErrBlockHeaderNotFound = errorsmod.Register(ModuleName, 1108, "block header not found") + ErrProofVerificationFailed = errorsmod.Register(ModuleName, 1109, "proof verification failed") + ErrInvalidHeight = errorsmod.Register(ModuleName, 1110, "invalid height") + ErrInvalidBlockHeader = errorsmod.Register(ModuleName, 1111, "invalid block header") +) diff --git a/x/lightclient/types/expected_keepers.go b/x/lightclient/types/expected_keepers.go new file mode 100644 index 0000000000..4361fa112a --- /dev/null +++ b/x/lightclient/types/expected_keepers.go @@ -0,0 +1,10 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" +) + +type AuthorityKeeper interface { + IsAuthorized(ctx sdk.Context, address string, policyType authoritytypes.PolicyType) bool +} diff --git a/x/lightclient/types/genesis.go b/x/lightclient/types/genesis.go new file mode 100644 index 0000000000..d4883d5b33 --- /dev/null +++ b/x/lightclient/types/genesis.go @@ -0,0 +1,41 @@ +package types + +import ( + "fmt" + + "github.com/zeta-chain/zetacore/pkg/proofs" +) + +// DefaultGenesis returns the default lightclient genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + BlockHeaders: []proofs.BlockHeader{}, + ChainStates: []ChainState{}, + VerificationFlags: VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: false, + }, + } +} + +// Validate performs basic genesis state validation returning an error upon any failure +func (gs GenesisState) Validate() error { + // Check there is no duplicate + blockHeaderMap := make(map[string]bool) + for _, elem := range gs.BlockHeaders { + if _, ok := blockHeaderMap[string(elem.Hash)]; ok { + return fmt.Errorf("duplicated hash for block headers") + } + blockHeaderMap[string(elem.Hash)] = true + } + + ChainStateMap := make(map[int64]bool) + for _, elem := range gs.ChainStates { + if _, ok := ChainStateMap[elem.ChainId]; ok { + return fmt.Errorf("duplicated chain id for chain states") + } + ChainStateMap[elem.ChainId] = true + } + + return nil +} diff --git a/x/lightclient/types/genesis.pb.go b/x/lightclient/types/genesis.pb.go new file mode 100644 index 0000000000..adca0d82ee --- /dev/null +++ b/x/lightclient/types/genesis.pb.go @@ -0,0 +1,454 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lightclient/genesis.proto + +package types + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" + proofs "github.com/zeta-chain/zetacore/pkg/proofs" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the lightclient module's genesis state. +type GenesisState struct { + BlockHeaders []proofs.BlockHeader `protobuf:"bytes,1,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers"` + ChainStates []ChainState `protobuf:"bytes,2,rep,name=chain_states,json=chainStates,proto3" json:"chain_states"` + VerificationFlags VerificationFlags `protobuf:"bytes,3,opt,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_645b5300b371cd43, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetBlockHeaders() []proofs.BlockHeader { + if m != nil { + return m.BlockHeaders + } + return nil +} + +func (m *GenesisState) GetChainStates() []ChainState { + if m != nil { + return m.ChainStates + } + return nil +} + +func (m *GenesisState) GetVerificationFlags() VerificationFlags { + if m != nil { + return m.VerificationFlags + } + return VerificationFlags{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "zetachain.zetacore.lightclient.GenesisState") +} + +func init() { proto.RegisterFile("lightclient/genesis.proto", fileDescriptor_645b5300b371cd43) } + +var fileDescriptor_645b5300b371cd43 = []byte{ + // 314 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0xc9, 0x4c, 0xcf, + 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, + 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x90, 0x54, 0x4b, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, + 0x95, 0xea, 0x83, 0x58, 0x10, 0x5d, 0x52, 0xb2, 0xc8, 0x06, 0x82, 0x75, 0xc7, 0x17, 0x97, 0x24, + 0x96, 0xa4, 0x42, 0xa5, 0x55, 0x90, 0xa5, 0xcb, 0x52, 0x8b, 0x32, 0xd3, 0x32, 0x93, 0x13, 0x4b, + 0x32, 0xf3, 0xf3, 0xe2, 0xd3, 0x72, 0x12, 0xd3, 0xa1, 0x56, 0x4b, 0x89, 0x17, 0x64, 0xa7, 0xeb, + 0x17, 0x14, 0xe5, 0xe7, 0xa7, 0x15, 0x43, 0x29, 0x88, 0x84, 0x52, 0x37, 0x13, 0x17, 0x8f, 0x3b, + 0xc4, 0x95, 0xc1, 0x20, 0x53, 0x85, 0xec, 0xb8, 0x78, 0x93, 0x72, 0xf2, 0x93, 0xb3, 0xe3, 0x33, + 0x52, 0x13, 0x53, 0x52, 0x8b, 0x8a, 0x25, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x84, 0xf5, 0xa0, + 0xda, 0x9c, 0x40, 0x92, 0x1e, 0x60, 0x39, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x78, 0x92, + 0x10, 0x42, 0xc5, 0x42, 0xc1, 0x5c, 0x3c, 0x48, 0x8e, 0x2c, 0x96, 0x60, 0x02, 0x6b, 0xd7, 0xd2, + 0xc3, 0xef, 0x77, 0x3d, 0x67, 0x90, 0x14, 0xd8, 0x05, 0x50, 0x53, 0xb9, 0x93, 0xe1, 0x22, 0xc5, + 0x42, 0x69, 0x5c, 0x42, 0x98, 0x5e, 0x93, 0x60, 0x56, 0x60, 0xd4, 0xe0, 0x36, 0x32, 0x24, 0x64, + 0x74, 0x18, 0x92, 0x4e, 0x37, 0x90, 0x46, 0xa8, 0x0d, 0x82, 0x65, 0x18, 0x12, 0x3e, 0x27, 0x1e, + 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, + 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x94, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, + 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0xb2, 0x45, 0x17, 0x6c, 0xa1, 0x3e, 0xcc, 0x42, 0xfd, 0x0a, 0x7d, + 0xe4, 0x78, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x07, 0xb1, 0x31, 0x20, 0x00, 0x00, + 0xff, 0xff, 0xd4, 0xfb, 0x01, 0x8d, 0x13, 0x02, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.VerificationFlags.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ChainStates) > 0 { + for iNdEx := len(m.ChainStates) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ChainStates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.BlockHeaders) > 0 { + for iNdEx := len(m.BlockHeaders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BlockHeaders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.BlockHeaders) > 0 { + for _, e := range m.BlockHeaders { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.ChainStates) > 0 { + for _, e := range m.ChainStates { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + l = m.VerificationFlags.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHeaders = append(m.BlockHeaders, proofs.BlockHeader{}) + if err := m.BlockHeaders[len(m.BlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainStates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainStates = append(m.ChainStates, ChainState{}) + if err := m.ChainStates[len(m.ChainStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VerificationFlags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VerificationFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/lightclient/types/genesis_test.go b/x/lightclient/types/genesis_test.go new file mode 100644 index 0000000000..1bec10f3be --- /dev/null +++ b/x/lightclient/types/genesis_test.go @@ -0,0 +1,79 @@ +package types_test + +import ( + "testing" + + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestGenesisState_Validate(t *testing.T) { + duplicatedHash := sample.Hash().Bytes() + + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "valid genesis state", + genState: &types.GenesisState{ + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }, + BlockHeaders: []proofs.BlockHeader{ + sample.BlockHeader(sample.Hash().Bytes()), + sample.BlockHeader(sample.Hash().Bytes()), + sample.BlockHeader(sample.Hash().Bytes()), + }, + ChainStates: []types.ChainState{ + sample.ChainState(chains.EthChain().ChainId), + sample.ChainState(chains.BtcMainnetChain().ChainId), + sample.ChainState(chains.BscMainnetChain().ChainId), + }, + }, + valid: true, + }, + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "duplicate block headers is invalid", + genState: &types.GenesisState{ + BlockHeaders: []proofs.BlockHeader{ + sample.BlockHeader(sample.Hash().Bytes()), + sample.BlockHeader(duplicatedHash), + sample.BlockHeader(duplicatedHash), + }, + }, + valid: false, + }, + { + desc: "duplicate chain state is invalid", + genState: &types.GenesisState{ + ChainStates: []types.ChainState{ + sample.ChainState(chains.EthChain().ChainId), + sample.ChainState(chains.EthChain().ChainId), + sample.ChainState(chains.BscMainnetChain().ChainId), + }, + }, + valid: false, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/lightclient/types/keys.go b/x/lightclient/types/keys.go new file mode 100644 index 0000000000..6369421e58 --- /dev/null +++ b/x/lightclient/types/keys.go @@ -0,0 +1,28 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "lightclient" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_" + ModuleName +) + +const ( + BlockHeaderKey = "BlockHeader-value-" + ChainStateKey = "ChainState-value-" + VerificationFlagsKey = "VerificationFlags-value-" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/lightclient/types/message_update_verification_flags.go b/x/lightclient/types/message_update_verification_flags.go new file mode 100644 index 0000000000..a180596e40 --- /dev/null +++ b/x/lightclient/types/message_update_verification_flags.go @@ -0,0 +1,62 @@ +package types + +import ( + cosmoserrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" +) + +const ( + TypeMsgUpdateVerificationFlags = "update_verification_flags" +) + +var _ sdk.Msg = &MsgUpdateVerificationFlags{} + +func NewMsgUpdateVerificationFlags(creator string, ethTypeChainEnabled, btcTypeChainEnabled bool) *MsgUpdateVerificationFlags { + return &MsgUpdateVerificationFlags{ + Creator: creator, + VerificationFlags: VerificationFlags{ + EthTypeChainEnabled: ethTypeChainEnabled, + BtcTypeChainEnabled: btcTypeChainEnabled, + }, + } +} + +func (msg *MsgUpdateVerificationFlags) Route() string { + return RouterKey +} + +func (msg *MsgUpdateVerificationFlags) Type() string { + return TypeMsgUpdateVerificationFlags +} + +func (msg *MsgUpdateVerificationFlags) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateVerificationFlags) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateVerificationFlags) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} + +// GetRequireGroup returns the required group to execute the message +func (msg *MsgUpdateVerificationFlags) GetRequireGroup() authoritytypes.PolicyType { + requiredGroup := authoritytypes.PolicyType_groupEmergency + if msg.VerificationFlags.EthTypeChainEnabled || msg.VerificationFlags.BtcTypeChainEnabled { + requiredGroup = authoritytypes.PolicyType_groupOperational + } + + return requiredGroup +} diff --git a/x/lightclient/types/message_update_verification_flags_test.go b/x/lightclient/types/message_update_verification_flags_test.go new file mode 100644 index 0000000000..0b667ee08d --- /dev/null +++ b/x/lightclient/types/message_update_verification_flags_test.go @@ -0,0 +1,173 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/lightclient/types" +) + +func TestMsgUpdateVerificationFlags_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg types.MsgUpdateVerificationFlags + err error + }{ + { + name: "invalid address", + msg: types.MsgUpdateVerificationFlags{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "valid address", + msg: types.MsgUpdateVerificationFlags{ + Creator: sample.AccAddress(), + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + }, + }, + }, + { + name: "verification flags can be false", + msg: types.MsgUpdateVerificationFlags{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgUpdateVerificationFlags_GetSigners(t *testing.T) { + signer := sample.AccAddress() + tests := []struct { + name string + msg *types.MsgUpdateVerificationFlags + panics bool + }{ + { + name: "valid signer", + msg: types.NewMsgUpdateVerificationFlags( + signer, + true, + true, + ), + panics: false, + }, + { + name: "invalid signer", + msg: types.NewMsgUpdateVerificationFlags( + "invalid", + true, + true, + ), + 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 TestMsgUpdateVerificationFlags_Type(t *testing.T) { + msg := types.MsgUpdateVerificationFlags{ + Creator: sample.AccAddress(), + } + require.Equal(t, types.TypeMsgUpdateVerificationFlags, msg.Type()) +} + +func TestMsgUpdateVerificationFlags_Route(t *testing.T) { + msg := types.MsgUpdateVerificationFlags{ + Creator: sample.AccAddress(), + } + require.Equal(t, types.RouterKey, msg.Route()) +} + +func TestMsgUpdateVerificationFlags_GetSignBytes(t *testing.T) { + msg := types.MsgUpdateVerificationFlags{ + Creator: sample.AccAddress(), + } + require.NotPanics(t, func() { + msg.GetSignBytes() + }) +} + +func TestMsgUpdateVerificationFlags_GetRequireGroup(t *testing.T) { + tests := []struct { + name string + msg types.MsgUpdateVerificationFlags + want authoritytypes.PolicyType + }{ + { + name: "groupEmergency", + msg: types.MsgUpdateVerificationFlags{ + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: false, + }, + }, + want: authoritytypes.PolicyType_groupEmergency, + }, + { + name: "groupOperational", + msg: types.MsgUpdateVerificationFlags{ + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: false, + }, + }, + want: authoritytypes.PolicyType_groupOperational, + }, + { + name: "groupOperational", + msg: types.MsgUpdateVerificationFlags{ + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: true, + }, + }, + want: authoritytypes.PolicyType_groupOperational, + }, + { + name: "groupOperational", + msg: types.MsgUpdateVerificationFlags{ + VerificationFlags: types.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: true, + }, + }, + want: authoritytypes.PolicyType_groupOperational, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := tt.msg.GetRequireGroup() + require.Equal(t, tt.want, got) + }) + } +} diff --git a/x/lightclient/types/query.pb.go b/x/lightclient/types/query.pb.go new file mode 100644 index 0000000000..7d96e11051 --- /dev/null +++ b/x/lightclient/types/query.pb.go @@ -0,0 +1,2783 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lightclient/query.proto + +package types + +import ( + context "context" + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + proofs "github.com/zeta-chain/zetacore/pkg/proofs" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type QueryAllBlockHeaderRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllBlockHeaderRequest) Reset() { *m = QueryAllBlockHeaderRequest{} } +func (m *QueryAllBlockHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllBlockHeaderRequest) ProtoMessage() {} +func (*QueryAllBlockHeaderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{0} +} +func (m *QueryAllBlockHeaderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllBlockHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllBlockHeaderRequest.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 *QueryAllBlockHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllBlockHeaderRequest.Merge(m, src) +} +func (m *QueryAllBlockHeaderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllBlockHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllBlockHeaderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllBlockHeaderRequest proto.InternalMessageInfo + +func (m *QueryAllBlockHeaderRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllBlockHeaderResponse struct { + BlockHeaders []proofs.BlockHeader `protobuf:"bytes,1,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllBlockHeaderResponse) Reset() { *m = QueryAllBlockHeaderResponse{} } +func (m *QueryAllBlockHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllBlockHeaderResponse) ProtoMessage() {} +func (*QueryAllBlockHeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{1} +} +func (m *QueryAllBlockHeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllBlockHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllBlockHeaderResponse.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 *QueryAllBlockHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllBlockHeaderResponse.Merge(m, src) +} +func (m *QueryAllBlockHeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllBlockHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllBlockHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllBlockHeaderResponse proto.InternalMessageInfo + +func (m *QueryAllBlockHeaderResponse) GetBlockHeaders() []proofs.BlockHeader { + if m != nil { + return m.BlockHeaders + } + return nil +} + +func (m *QueryAllBlockHeaderResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryGetBlockHeaderRequest struct { + BlockHash []byte `protobuf:"bytes,1,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` +} + +func (m *QueryGetBlockHeaderRequest) Reset() { *m = QueryGetBlockHeaderRequest{} } +func (m *QueryGetBlockHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetBlockHeaderRequest) ProtoMessage() {} +func (*QueryGetBlockHeaderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{2} +} +func (m *QueryGetBlockHeaderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBlockHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBlockHeaderRequest.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 *QueryGetBlockHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBlockHeaderRequest.Merge(m, src) +} +func (m *QueryGetBlockHeaderRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBlockHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBlockHeaderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBlockHeaderRequest proto.InternalMessageInfo + +func (m *QueryGetBlockHeaderRequest) GetBlockHash() []byte { + if m != nil { + return m.BlockHash + } + return nil +} + +type QueryGetBlockHeaderResponse struct { + BlockHeader *proofs.BlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"` +} + +func (m *QueryGetBlockHeaderResponse) Reset() { *m = QueryGetBlockHeaderResponse{} } +func (m *QueryGetBlockHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetBlockHeaderResponse) ProtoMessage() {} +func (*QueryGetBlockHeaderResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{3} +} +func (m *QueryGetBlockHeaderResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetBlockHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetBlockHeaderResponse.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 *QueryGetBlockHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetBlockHeaderResponse.Merge(m, src) +} +func (m *QueryGetBlockHeaderResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetBlockHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetBlockHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetBlockHeaderResponse proto.InternalMessageInfo + +func (m *QueryGetBlockHeaderResponse) GetBlockHeader() *proofs.BlockHeader { + if m != nil { + return m.BlockHeader + } + return nil +} + +type QueryAllChainStateRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllChainStateRequest) Reset() { *m = QueryAllChainStateRequest{} } +func (m *QueryAllChainStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllChainStateRequest) ProtoMessage() {} +func (*QueryAllChainStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{4} +} +func (m *QueryAllChainStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllChainStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllChainStateRequest.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 *QueryAllChainStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllChainStateRequest.Merge(m, src) +} +func (m *QueryAllChainStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllChainStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllChainStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllChainStateRequest proto.InternalMessageInfo + +func (m *QueryAllChainStateRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllChainStateResponse struct { + ChainState []ChainState `protobuf:"bytes,1,rep,name=chain_state,json=chainState,proto3" json:"chain_state"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllChainStateResponse) Reset() { *m = QueryAllChainStateResponse{} } +func (m *QueryAllChainStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllChainStateResponse) ProtoMessage() {} +func (*QueryAllChainStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{5} +} +func (m *QueryAllChainStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllChainStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllChainStateResponse.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 *QueryAllChainStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllChainStateResponse.Merge(m, src) +} +func (m *QueryAllChainStateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllChainStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllChainStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllChainStateResponse proto.InternalMessageInfo + +func (m *QueryAllChainStateResponse) GetChainState() []ChainState { + if m != nil { + return m.ChainState + } + return nil +} + +func (m *QueryAllChainStateResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryGetChainStateRequest struct { + ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *QueryGetChainStateRequest) Reset() { *m = QueryGetChainStateRequest{} } +func (m *QueryGetChainStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetChainStateRequest) ProtoMessage() {} +func (*QueryGetChainStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{6} +} +func (m *QueryGetChainStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetChainStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetChainStateRequest.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 *QueryGetChainStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetChainStateRequest.Merge(m, src) +} +func (m *QueryGetChainStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetChainStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetChainStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetChainStateRequest proto.InternalMessageInfo + +func (m *QueryGetChainStateRequest) GetChainId() int64 { + if m != nil { + return m.ChainId + } + return 0 +} + +type QueryGetChainStateResponse struct { + ChainState *ChainState `protobuf:"bytes,1,opt,name=chain_state,json=chainState,proto3" json:"chain_state,omitempty"` +} + +func (m *QueryGetChainStateResponse) Reset() { *m = QueryGetChainStateResponse{} } +func (m *QueryGetChainStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetChainStateResponse) ProtoMessage() {} +func (*QueryGetChainStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{7} +} +func (m *QueryGetChainStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetChainStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetChainStateResponse.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 *QueryGetChainStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetChainStateResponse.Merge(m, src) +} +func (m *QueryGetChainStateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetChainStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetChainStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetChainStateResponse proto.InternalMessageInfo + +func (m *QueryGetChainStateResponse) GetChainState() *ChainState { + if m != nil { + return m.ChainState + } + return nil +} + +type QueryProveRequest struct { + ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + TxHash string `protobuf:"bytes,2,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` + Proof *proofs.Proof `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` + BlockHash string `protobuf:"bytes,4,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` + TxIndex int64 `protobuf:"varint,5,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` +} + +func (m *QueryProveRequest) Reset() { *m = QueryProveRequest{} } +func (m *QueryProveRequest) String() string { return proto.CompactTextString(m) } +func (*QueryProveRequest) ProtoMessage() {} +func (*QueryProveRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{8} +} +func (m *QueryProveRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryProveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryProveRequest.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 *QueryProveRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryProveRequest.Merge(m, src) +} +func (m *QueryProveRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryProveRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryProveRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryProveRequest proto.InternalMessageInfo + +func (m *QueryProveRequest) GetChainId() int64 { + if m != nil { + return m.ChainId + } + return 0 +} + +func (m *QueryProveRequest) GetTxHash() string { + if m != nil { + return m.TxHash + } + return "" +} + +func (m *QueryProveRequest) GetProof() *proofs.Proof { + if m != nil { + return m.Proof + } + return nil +} + +func (m *QueryProveRequest) GetBlockHash() string { + if m != nil { + return m.BlockHash + } + return "" +} + +func (m *QueryProveRequest) GetTxIndex() int64 { + if m != nil { + return m.TxIndex + } + return 0 +} + +type QueryProveResponse struct { + Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"` +} + +func (m *QueryProveResponse) Reset() { *m = QueryProveResponse{} } +func (m *QueryProveResponse) String() string { return proto.CompactTextString(m) } +func (*QueryProveResponse) ProtoMessage() {} +func (*QueryProveResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{9} +} +func (m *QueryProveResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryProveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryProveResponse.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 *QueryProveResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryProveResponse.Merge(m, src) +} +func (m *QueryProveResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryProveResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryProveResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryProveResponse proto.InternalMessageInfo + +func (m *QueryProveResponse) GetValid() bool { + if m != nil { + return m.Valid + } + return false +} + +type QueryVerificationFlagsRequest struct { +} + +func (m *QueryVerificationFlagsRequest) Reset() { *m = QueryVerificationFlagsRequest{} } +func (m *QueryVerificationFlagsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryVerificationFlagsRequest) ProtoMessage() {} +func (*QueryVerificationFlagsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{10} +} +func (m *QueryVerificationFlagsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVerificationFlagsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVerificationFlagsRequest.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 *QueryVerificationFlagsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVerificationFlagsRequest.Merge(m, src) +} +func (m *QueryVerificationFlagsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryVerificationFlagsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVerificationFlagsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVerificationFlagsRequest proto.InternalMessageInfo + +type QueryVerificationFlagsResponse struct { + VerificationFlags VerificationFlags `protobuf:"bytes,1,opt,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` +} + +func (m *QueryVerificationFlagsResponse) Reset() { *m = QueryVerificationFlagsResponse{} } +func (m *QueryVerificationFlagsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryVerificationFlagsResponse) ProtoMessage() {} +func (*QueryVerificationFlagsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_03e46747c4ffba77, []int{11} +} +func (m *QueryVerificationFlagsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryVerificationFlagsResponse.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 *QueryVerificationFlagsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryVerificationFlagsResponse.Merge(m, src) +} +func (m *QueryVerificationFlagsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryVerificationFlagsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryVerificationFlagsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryVerificationFlagsResponse proto.InternalMessageInfo + +func (m *QueryVerificationFlagsResponse) GetVerificationFlags() VerificationFlags { + if m != nil { + return m.VerificationFlags + } + return VerificationFlags{} +} + +func init() { + proto.RegisterType((*QueryAllBlockHeaderRequest)(nil), "zetachain.zetacore.lightclient.QueryAllBlockHeaderRequest") + proto.RegisterType((*QueryAllBlockHeaderResponse)(nil), "zetachain.zetacore.lightclient.QueryAllBlockHeaderResponse") + proto.RegisterType((*QueryGetBlockHeaderRequest)(nil), "zetachain.zetacore.lightclient.QueryGetBlockHeaderRequest") + proto.RegisterType((*QueryGetBlockHeaderResponse)(nil), "zetachain.zetacore.lightclient.QueryGetBlockHeaderResponse") + proto.RegisterType((*QueryAllChainStateRequest)(nil), "zetachain.zetacore.lightclient.QueryAllChainStateRequest") + proto.RegisterType((*QueryAllChainStateResponse)(nil), "zetachain.zetacore.lightclient.QueryAllChainStateResponse") + proto.RegisterType((*QueryGetChainStateRequest)(nil), "zetachain.zetacore.lightclient.QueryGetChainStateRequest") + proto.RegisterType((*QueryGetChainStateResponse)(nil), "zetachain.zetacore.lightclient.QueryGetChainStateResponse") + proto.RegisterType((*QueryProveRequest)(nil), "zetachain.zetacore.lightclient.QueryProveRequest") + proto.RegisterType((*QueryProveResponse)(nil), "zetachain.zetacore.lightclient.QueryProveResponse") + proto.RegisterType((*QueryVerificationFlagsRequest)(nil), "zetachain.zetacore.lightclient.QueryVerificationFlagsRequest") + proto.RegisterType((*QueryVerificationFlagsResponse)(nil), "zetachain.zetacore.lightclient.QueryVerificationFlagsResponse") +} + +func init() { proto.RegisterFile("lightclient/query.proto", fileDescriptor_03e46747c4ffba77) } + +var fileDescriptor_03e46747c4ffba77 = []byte{ + // 843 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcd, 0x4e, 0xdb, 0x4a, + 0x14, 0xc7, 0x33, 0x40, 0xf8, 0x98, 0xc0, 0x95, 0x98, 0x8b, 0x44, 0xf0, 0xbd, 0x31, 0xc8, 0x5c, + 0x2e, 0x28, 0x2d, 0x76, 0x93, 0x56, 0x48, 0x0d, 0x2a, 0x12, 0x54, 0x82, 0xa2, 0x76, 0x01, 0xae, + 0xda, 0x45, 0x37, 0x91, 0xe3, 0x4c, 0x1c, 0x0b, 0xe3, 0x31, 0xf1, 0x10, 0x85, 0x22, 0x36, 0x5d, + 0x75, 0x59, 0xa9, 0xea, 0x2b, 0xf4, 0x05, 0xba, 0x41, 0xea, 0xae, 0x8b, 0x8a, 0x25, 0x52, 0x37, + 0x5d, 0x54, 0x55, 0x05, 0x7d, 0x90, 0xca, 0xe3, 0x49, 0x3d, 0xf9, 0x2a, 0x26, 0x62, 0x15, 0x7b, + 0xc6, 0xe7, 0x9c, 0xdf, 0xff, 0x3f, 0x67, 0x8e, 0x02, 0xa7, 0x1d, 0xdb, 0xaa, 0x52, 0xd3, 0xb1, + 0xb1, 0x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x23, 0xb4, 0x11, + 0xb6, 0x59, 0xe0, 0xcc, 0x98, 0x3e, 0x4c, 0x1b, 0x41, 0x8f, 0xa1, 0x79, 0x98, 0x64, 0xfd, 0x92, + 0x1e, 0x64, 0x40, 0x13, 0xcd, 0xee, 0xd9, 0x09, 0x7e, 0xf4, 0x70, 0xaf, 0xad, 0x4f, 0x87, 0x58, + 0x82, 0xa8, 0x4f, 0x83, 0xba, 0xb4, 0x51, 0xb4, 0xdd, 0x32, 0x6e, 0xa4, 0x93, 0x61, 0x5d, 0xda, + 0xd8, 0x0e, 0x5e, 0x95, 0x2c, 0x44, 0x22, 0x27, 0xf7, 0x62, 0x0a, 0x26, 0xeb, 0x86, 0xc3, 0x29, + 0x47, 0xf5, 0xf0, 0x45, 0x99, 0x85, 0x19, 0xf6, 0xed, 0x73, 0x61, 0xe8, 0x6c, 0x06, 0x33, 0x87, + 0xeb, 0x53, 0x5e, 0x03, 0x28, 0xf7, 0xfa, 0x82, 0x67, 0xae, 0x40, 0xd4, 0x39, 0xb3, 0xb8, 0xd9, + 0xb9, 0xab, 0xcc, 0xee, 0x48, 0xcb, 0xbb, 0x6c, 0xb2, 0xde, 0xbe, 0x91, 0xff, 0x36, 0x0a, 0x93, + 0x0c, 0x05, 0x9d, 0x02, 0xf8, 0x97, 0x70, 0xd5, 0xd6, 0x1d, 0x07, 0x15, 0xae, 0x2a, 0xd4, 0x7b, + 0x42, 0x4a, 0xab, 0x7d, 0xc5, 0x86, 0xea, 0x95, 0xe5, 0x57, 0x5f, 0x7e, 0xbe, 0x1d, 0x58, 0x44, + 0x0b, 0x5a, 0x10, 0xba, 0xcc, 0xb2, 0x68, 0xe2, 0x3c, 0x6f, 0x19, 0x8a, 0xe8, 0x13, 0x80, 0x29, + 0x21, 0x4d, 0x4c, 0xee, 0xae, 0xa3, 0x2c, 0x26, 0x77, 0xf7, 0x49, 0xa6, 0x14, 0x18, 0xf7, 0x3d, + 0x94, 0x8f, 0xc5, 0xad, 0x1d, 0x47, 0xcd, 0x78, 0x82, 0x3e, 0x00, 0x38, 0x11, 0xdd, 0x92, 0xc0, + 0xfe, 0xfb, 0x71, 0x2d, 0xec, 0xb8, 0xdd, 0x52, 0xa1, 0x9f, 0x50, 0x2e, 0xe2, 0x16, 0x13, 0xb1, + 0x80, 0xe6, 0x7b, 0x89, 0x10, 0xae, 0x3f, 0xfa, 0x08, 0x20, 0x8c, 0x72, 0xc4, 0x44, 0xee, 0x36, + 0x90, 0xa4, 0x42, 0x3f, 0xa1, 0x1c, 0x79, 0x85, 0x21, 0xdf, 0x41, 0x6a, 0x0c, 0x64, 0xed, 0xb8, + 0x39, 0x5b, 0x4e, 0xd0, 0x3b, 0x00, 0x93, 0xec, 0x46, 0xa3, 0x5c, 0xac, 0xea, 0xe2, 0x94, 0x92, + 0xf2, 0xd7, 0x09, 0xe1, 0xa0, 0x0b, 0x0c, 0x74, 0x16, 0x65, 0x7a, 0x81, 0x7a, 0x8c, 0xe6, 0x33, + 0x80, 0x93, 0x1d, 0x97, 0x18, 0x3d, 0x88, 0x55, 0xb0, 0xd7, 0xd4, 0x91, 0xd6, 0xfa, 0x0d, 0xe7, + 0xec, 0x79, 0xc6, 0x7e, 0x1b, 0x65, 0x7b, 0xb1, 0x77, 0x0e, 0xac, 0x8d, 0x27, 0x67, 0x17, 0x32, + 0x38, 0xbf, 0x90, 0xc1, 0x8f, 0x0b, 0x19, 0xbc, 0xb9, 0x94, 0x13, 0xe7, 0x97, 0x72, 0xe2, 0xeb, + 0xa5, 0x9c, 0x78, 0x91, 0xb7, 0x6c, 0x5a, 0x3d, 0x2c, 0xa9, 0x26, 0xd9, 0x17, 0xf3, 0x35, 0xc1, + 0xb4, 0x46, 0x4b, 0x6a, 0x7a, 0xe4, 0x61, 0xbf, 0x34, 0xcc, 0xfe, 0x9a, 0xdd, 0xfd, 0x15, 0x00, + 0x00, 0xff, 0xff, 0x4b, 0x9e, 0x6d, 0x85, 0x93, 0x0a, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + BlockHeaderAll(ctx context.Context, in *QueryAllBlockHeaderRequest, opts ...grpc.CallOption) (*QueryAllBlockHeaderResponse, error) + BlockHeader(ctx context.Context, in *QueryGetBlockHeaderRequest, opts ...grpc.CallOption) (*QueryGetBlockHeaderResponse, error) + ChainStateAll(ctx context.Context, in *QueryAllChainStateRequest, opts ...grpc.CallOption) (*QueryAllChainStateResponse, error) + ChainState(ctx context.Context, in *QueryGetChainStateRequest, opts ...grpc.CallOption) (*QueryGetChainStateResponse, error) + Prove(ctx context.Context, in *QueryProveRequest, opts ...grpc.CallOption) (*QueryProveResponse, error) + VerificationFlags(ctx context.Context, in *QueryVerificationFlagsRequest, opts ...grpc.CallOption) (*QueryVerificationFlagsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) BlockHeaderAll(ctx context.Context, in *QueryAllBlockHeaderRequest, opts ...grpc.CallOption) (*QueryAllBlockHeaderResponse, error) { + out := new(QueryAllBlockHeaderResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/BlockHeaderAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) BlockHeader(ctx context.Context, in *QueryGetBlockHeaderRequest, opts ...grpc.CallOption) (*QueryGetBlockHeaderResponse, error) { + out := new(QueryGetBlockHeaderResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/BlockHeader", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ChainStateAll(ctx context.Context, in *QueryAllChainStateRequest, opts ...grpc.CallOption) (*QueryAllChainStateResponse, error) { + out := new(QueryAllChainStateResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/ChainStateAll", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ChainState(ctx context.Context, in *QueryGetChainStateRequest, opts ...grpc.CallOption) (*QueryGetChainStateResponse, error) { + out := new(QueryGetChainStateResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/ChainState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Prove(ctx context.Context, in *QueryProveRequest, opts ...grpc.CallOption) (*QueryProveResponse, error) { + out := new(QueryProveResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/Prove", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) VerificationFlags(ctx context.Context, in *QueryVerificationFlagsRequest, opts ...grpc.CallOption) (*QueryVerificationFlagsResponse, error) { + out := new(QueryVerificationFlagsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Query/VerificationFlags", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + BlockHeaderAll(context.Context, *QueryAllBlockHeaderRequest) (*QueryAllBlockHeaderResponse, error) + BlockHeader(context.Context, *QueryGetBlockHeaderRequest) (*QueryGetBlockHeaderResponse, error) + ChainStateAll(context.Context, *QueryAllChainStateRequest) (*QueryAllChainStateResponse, error) + ChainState(context.Context, *QueryGetChainStateRequest) (*QueryGetChainStateResponse, error) + Prove(context.Context, *QueryProveRequest) (*QueryProveResponse, error) + VerificationFlags(context.Context, *QueryVerificationFlagsRequest) (*QueryVerificationFlagsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) BlockHeaderAll(ctx context.Context, req *QueryAllBlockHeaderRequest) (*QueryAllBlockHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BlockHeaderAll not implemented") +} +func (*UnimplementedQueryServer) BlockHeader(ctx context.Context, req *QueryGetBlockHeaderRequest) (*QueryGetBlockHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method BlockHeader not implemented") +} +func (*UnimplementedQueryServer) ChainStateAll(ctx context.Context, req *QueryAllChainStateRequest) (*QueryAllChainStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChainStateAll not implemented") +} +func (*UnimplementedQueryServer) ChainState(ctx context.Context, req *QueryGetChainStateRequest) (*QueryGetChainStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ChainState not implemented") +} +func (*UnimplementedQueryServer) Prove(ctx context.Context, req *QueryProveRequest) (*QueryProveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Prove not implemented") +} +func (*UnimplementedQueryServer) VerificationFlags(ctx context.Context, req *QueryVerificationFlagsRequest) (*QueryVerificationFlagsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VerificationFlags not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_BlockHeaderAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllBlockHeaderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).BlockHeaderAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Query/BlockHeaderAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).BlockHeaderAll(ctx, req.(*QueryAllBlockHeaderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_BlockHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetBlockHeaderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).BlockHeader(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Query/BlockHeader", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).BlockHeader(ctx, req.(*QueryGetBlockHeaderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ChainStateAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllChainStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ChainStateAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Query/ChainStateAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ChainStateAll(ctx, req.(*QueryAllChainStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ChainState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetChainStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ChainState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Query/ChainState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ChainState(ctx, req.(*QueryGetChainStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Prove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryProveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Prove(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Query/Prove", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Prove(ctx, req.(*QueryProveRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_VerificationFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryVerificationFlagsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).VerificationFlags(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Query/VerificationFlags", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).VerificationFlags(ctx, req.(*QueryVerificationFlagsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zetachain.zetacore.lightclient.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "BlockHeaderAll", + Handler: _Query_BlockHeaderAll_Handler, + }, + { + MethodName: "BlockHeader", + Handler: _Query_BlockHeader_Handler, + }, + { + MethodName: "ChainStateAll", + Handler: _Query_ChainStateAll_Handler, + }, + { + MethodName: "ChainState", + Handler: _Query_ChainState_Handler, + }, + { + MethodName: "Prove", + Handler: _Query_Prove_Handler, + }, + { + MethodName: "VerificationFlags", + Handler: _Query_VerificationFlags_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lightclient/query.proto", +} + +func (m *QueryAllBlockHeaderRequest) 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 *QueryAllBlockHeaderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllBlockHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllBlockHeaderResponse) 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 *QueryAllBlockHeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllBlockHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.BlockHeaders) > 0 { + for iNdEx := len(m.BlockHeaders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BlockHeaders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGetBlockHeaderRequest) 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 *QueryGetBlockHeaderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBlockHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BlockHash) > 0 { + i -= len(m.BlockHash) + copy(dAtA[i:], m.BlockHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BlockHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetBlockHeaderResponse) 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 *QueryGetBlockHeaderResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetBlockHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockHeader != nil { + { + size, err := m.BlockHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllChainStateRequest) 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 *QueryAllChainStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllChainStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllChainStateResponse) 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 *QueryAllChainStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllChainStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ChainState) > 0 { + for iNdEx := len(m.ChainState) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ChainState[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGetChainStateRequest) 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 *QueryGetChainStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetChainStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChainId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryGetChainStateResponse) 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 *QueryGetChainStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetChainStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChainState != nil { + { + size, err := m.ChainState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryProveRequest) 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 *QueryProveRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProveRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TxIndex != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.TxIndex)) + i-- + dAtA[i] = 0x28 + } + if len(m.BlockHash) > 0 { + i -= len(m.BlockHash) + copy(dAtA[i:], m.BlockHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BlockHash))) + i-- + dAtA[i] = 0x22 + } + if m.Proof != nil { + { + size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.TxHash) > 0 { + i -= len(m.TxHash) + copy(dAtA[i:], m.TxHash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.TxHash))) + i-- + dAtA[i] = 0x12 + } + if m.ChainId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryProveResponse) 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 *QueryProveResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryProveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Valid { + i-- + if m.Valid { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryVerificationFlagsRequest) 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 *QueryVerificationFlagsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVerificationFlagsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryVerificationFlagsResponse) 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 *QueryVerificationFlagsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryVerificationFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.VerificationFlags.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryAllBlockHeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllBlockHeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.BlockHeaders) > 0 { + for _, e := range m.BlockHeaders { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBlockHeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.BlockHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetBlockHeaderResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeader != nil { + l = m.BlockHeader.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllChainStateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllChainStateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ChainState) > 0 { + for _, e := range m.ChainState { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetChainStateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChainId != 0 { + n += 1 + sovQuery(uint64(m.ChainId)) + } + return n +} + +func (m *QueryGetChainStateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChainState != nil { + l = m.ChainState.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryProveRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChainId != 0 { + n += 1 + sovQuery(uint64(m.ChainId)) + } + l = len(m.TxHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Proof != nil { + l = m.Proof.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.BlockHash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.TxIndex != 0 { + n += 1 + sovQuery(uint64(m.TxIndex)) + } + return n +} + +func (m *QueryProveResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Valid { + n += 2 + } + return n +} + +func (m *QueryVerificationFlagsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryVerificationFlagsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.VerificationFlags.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryAllBlockHeaderRequest) 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 ErrIntOverflowQuery + } + 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: QueryAllBlockHeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllBlockHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllBlockHeaderResponse) 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 ErrIntOverflowQuery + } + 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: QueryAllBlockHeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllBlockHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHeaders = append(m.BlockHeaders, proofs.BlockHeader{}) + if err := m.BlockHeaders[len(m.BlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetBlockHeaderRequest) 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 ErrIntOverflowQuery + } + 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: QueryGetBlockHeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBlockHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHash = append(m.BlockHash[:0], dAtA[iNdEx:postIndex]...) + if m.BlockHash == nil { + m.BlockHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetBlockHeaderResponse) 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 ErrIntOverflowQuery + } + 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: QueryGetBlockHeaderResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetBlockHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BlockHeader == nil { + m.BlockHeader = &proofs.BlockHeader{} + } + if err := m.BlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllChainStateRequest) 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 ErrIntOverflowQuery + } + 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: QueryAllChainStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllChainStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllChainStateResponse) 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 ErrIntOverflowQuery + } + 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: QueryAllChainStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllChainStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainState = append(m.ChainState, ChainState{}) + if err := m.ChainState[len(m.ChainState)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetChainStateRequest) 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 ErrIntOverflowQuery + } + 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: QueryGetChainStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetChainStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetChainStateResponse) 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 ErrIntOverflowQuery + } + 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: QueryGetChainStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetChainStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ChainState == nil { + m.ChainState = &ChainState{} + } + if err := m.ChainState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryProveRequest) 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 ErrIntOverflowQuery + } + 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: QueryProveRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryProveRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Proof == nil { + m.Proof = &proofs.Proof{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TxIndex", wireType) + } + m.TxIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TxIndex |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryProveResponse) 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 ErrIntOverflowQuery + } + 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: QueryProveResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryProveResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Valid", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Valid = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVerificationFlagsRequest) 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 ErrIntOverflowQuery + } + 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: QueryVerificationFlagsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVerificationFlagsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryVerificationFlagsResponse) 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 ErrIntOverflowQuery + } + 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: QueryVerificationFlagsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryVerificationFlagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VerificationFlags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VerificationFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/lightclient/types/query.pb.gw.go b/x/lightclient/types/query.pb.gw.go new file mode 100644 index 0000000000..1b62c608cb --- /dev/null +++ b/x/lightclient/types/query.pb.gw.go @@ -0,0 +1,604 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: lightclient/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Query_BlockHeaderAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_BlockHeaderAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllBlockHeaderRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BlockHeaderAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.BlockHeaderAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_BlockHeaderAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllBlockHeaderRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BlockHeaderAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.BlockHeaderAll(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_BlockHeader_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBlockHeaderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["block_hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block_hash") + } + + protoReq.BlockHash, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block_hash", err) + } + + msg, err := client.BlockHeader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_BlockHeader_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetBlockHeaderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["block_hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block_hash") + } + + protoReq.BlockHash, err = runtime.Bytes(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block_hash", err) + } + + msg, err := server.BlockHeader(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_ChainStateAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_ChainStateAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllChainStateRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChainStateAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ChainStateAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ChainStateAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllChainStateRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ChainStateAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ChainStateAll(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_ChainState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetChainStateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["chain_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + } + + protoReq.ChainId, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + + msg, err := client.ChainState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ChainState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetChainStateRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["chain_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") + } + + protoReq.ChainId, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) + } + + msg, err := server.ChainState(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Prove_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Prove_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryProveRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Prove_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Prove(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Prove_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryProveRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Prove_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Prove(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_VerificationFlags_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVerificationFlagsRequest + var metadata runtime.ServerMetadata + + msg, err := client.VerificationFlags(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_VerificationFlags_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryVerificationFlagsRequest + var metadata runtime.ServerMetadata + + msg, err := server.VerificationFlags(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_BlockHeaderAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_BlockHeaderAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BlockHeaderAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_BlockHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_BlockHeader_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BlockHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ChainStateAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ChainStateAll_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChainStateAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ChainState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ChainState_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChainState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Prove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Prove_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Prove_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_VerificationFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_VerificationFlags_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_VerificationFlags_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_BlockHeaderAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_BlockHeaderAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BlockHeaderAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_BlockHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_BlockHeader_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_BlockHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ChainStateAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ChainStateAll_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChainStateAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ChainState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ChainState_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ChainState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Prove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Prove_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Prove_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_VerificationFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_VerificationFlags_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_VerificationFlags_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_BlockHeaderAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "block_headers"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_BlockHeader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "lightclient", "block_headers", "block_hash"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ChainStateAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "chain_state"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ChainState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "lightclient", "chain_state", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Prove_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "prove"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_VerificationFlags_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "lightclient", "verification_flags"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_BlockHeaderAll_0 = runtime.ForwardResponseMessage + + forward_Query_BlockHeader_0 = runtime.ForwardResponseMessage + + forward_Query_ChainStateAll_0 = runtime.ForwardResponseMessage + + forward_Query_ChainState_0 = runtime.ForwardResponseMessage + + forward_Query_Prove_0 = runtime.ForwardResponseMessage + + forward_Query_VerificationFlags_0 = runtime.ForwardResponseMessage +) diff --git a/x/lightclient/types/tx.pb.go b/x/lightclient/types/tx.pb.go new file mode 100644 index 0000000000..669311aeda --- /dev/null +++ b/x/lightclient/types/tx.pb.go @@ -0,0 +1,581 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lightclient/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgUpdateVerificationFlags struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + VerificationFlags VerificationFlags `protobuf:"bytes,2,opt,name=verification_flags,json=verificationFlags,proto3" json:"verification_flags"` +} + +func (m *MsgUpdateVerificationFlags) Reset() { *m = MsgUpdateVerificationFlags{} } +func (m *MsgUpdateVerificationFlags) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateVerificationFlags) ProtoMessage() {} +func (*MsgUpdateVerificationFlags) Descriptor() ([]byte, []int) { + return fileDescriptor_81fed8987f08d9c5, []int{0} +} +func (m *MsgUpdateVerificationFlags) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateVerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateVerificationFlags.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 *MsgUpdateVerificationFlags) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateVerificationFlags.Merge(m, src) +} +func (m *MsgUpdateVerificationFlags) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateVerificationFlags) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateVerificationFlags.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateVerificationFlags proto.InternalMessageInfo + +func (m *MsgUpdateVerificationFlags) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateVerificationFlags) GetVerificationFlags() VerificationFlags { + if m != nil { + return m.VerificationFlags + } + return VerificationFlags{} +} + +type MsgUpdateVerificationFlagsResponse struct { +} + +func (m *MsgUpdateVerificationFlagsResponse) Reset() { *m = MsgUpdateVerificationFlagsResponse{} } +func (m *MsgUpdateVerificationFlagsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateVerificationFlagsResponse) ProtoMessage() {} +func (*MsgUpdateVerificationFlagsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_81fed8987f08d9c5, []int{1} +} +func (m *MsgUpdateVerificationFlagsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateVerificationFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateVerificationFlagsResponse.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 *MsgUpdateVerificationFlagsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateVerificationFlagsResponse.Merge(m, src) +} +func (m *MsgUpdateVerificationFlagsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateVerificationFlagsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateVerificationFlagsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateVerificationFlagsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgUpdateVerificationFlags)(nil), "zetachain.zetacore.lightclient.MsgUpdateVerificationFlags") + proto.RegisterType((*MsgUpdateVerificationFlagsResponse)(nil), "zetachain.zetacore.lightclient.MsgUpdateVerificationFlagsResponse") +} + +func init() { proto.RegisterFile("lightclient/tx.proto", fileDescriptor_81fed8987f08d9c5) } + +var fileDescriptor_81fed8987f08d9c5 = []byte{ + // 282 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc9, 0xc9, 0x4c, 0xcf, + 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, + 0x52, 0xf5, 0x90, 0x14, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x95, 0xea, 0x83, 0x58, 0x10, + 0x5d, 0x52, 0x2a, 0xc8, 0x66, 0x95, 0xa5, 0x16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, 0xf4, + 0x51, 0xd2, 0x45, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x38, 0xfe, 0x8c, 0x01, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x5d, 0x1d, 0xfc, 0x77, 0x33, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// 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 { + UpdateVerificationFlags(ctx context.Context, in *MsgUpdateVerificationFlags, opts ...grpc.CallOption) (*MsgUpdateVerificationFlagsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) UpdateVerificationFlags(ctx context.Context, in *MsgUpdateVerificationFlags, opts ...grpc.CallOption) (*MsgUpdateVerificationFlagsResponse, error) { + out := new(MsgUpdateVerificationFlagsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.lightclient.Msg/UpdateVerificationFlags", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + UpdateVerificationFlags(context.Context, *MsgUpdateVerificationFlags) (*MsgUpdateVerificationFlagsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) UpdateVerificationFlags(ctx context.Context, req *MsgUpdateVerificationFlags) (*MsgUpdateVerificationFlagsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateVerificationFlags not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_UpdateVerificationFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateVerificationFlags) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateVerificationFlags(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.lightclient.Msg/UpdateVerificationFlags", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateVerificationFlags(ctx, req.(*MsgUpdateVerificationFlags)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zetachain.zetacore.lightclient.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateVerificationFlags", + Handler: _Msg_UpdateVerificationFlags_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "lightclient/tx.proto", +} + +func (m *MsgUpdateVerificationFlags) 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 *MsgUpdateVerificationFlags) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateVerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.VerificationFlags.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + 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 *MsgUpdateVerificationFlagsResponse) 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 *MsgUpdateVerificationFlagsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateVerificationFlagsResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgUpdateVerificationFlags) 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)) + } + l = m.VerificationFlags.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateVerificationFlagsResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgUpdateVerificationFlags) 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: MsgUpdateVerificationFlags: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateVerificationFlags: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VerificationFlags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.VerificationFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 *MsgUpdateVerificationFlagsResponse) 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: MsgUpdateVerificationFlagsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateVerificationFlagsResponse: 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/lightclient/types/verification_flags.go b/x/lightclient/types/verification_flags.go new file mode 100644 index 0000000000..c410158336 --- /dev/null +++ b/x/lightclient/types/verification_flags.go @@ -0,0 +1,10 @@ +package types + +// DefaultVerificationFlags returns the default verification flags. +// By default, everything disabled. +func DefaultVerificationFlags() VerificationFlags { + return VerificationFlags{ + EthTypeChainEnabled: false, + BtcTypeChainEnabled: false, + } +} diff --git a/x/lightclient/types/verification_flags.pb.go b/x/lightclient/types/verification_flags.pb.go new file mode 100644 index 0000000000..94c90b358a --- /dev/null +++ b/x/lightclient/types/verification_flags.pb.go @@ -0,0 +1,352 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: lightclient/verification_flags.proto + +package types + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// VerificationFlags is a structure containing information which chain types are enabled for block header verification +type VerificationFlags struct { + EthTypeChainEnabled bool `protobuf:"varint,1,opt,name=ethTypeChainEnabled,proto3" json:"ethTypeChainEnabled,omitempty"` + BtcTypeChainEnabled bool `protobuf:"varint,2,opt,name=btcTypeChainEnabled,proto3" json:"btcTypeChainEnabled,omitempty"` +} + +func (m *VerificationFlags) Reset() { *m = VerificationFlags{} } +func (m *VerificationFlags) String() string { return proto.CompactTextString(m) } +func (*VerificationFlags) ProtoMessage() {} +func (*VerificationFlags) Descriptor() ([]byte, []int) { + return fileDescriptor_86eae6d737b3f8cc, []int{0} +} +func (m *VerificationFlags) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VerificationFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VerificationFlags.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 *VerificationFlags) XXX_Merge(src proto.Message) { + xxx_messageInfo_VerificationFlags.Merge(m, src) +} +func (m *VerificationFlags) XXX_Size() int { + return m.Size() +} +func (m *VerificationFlags) XXX_DiscardUnknown() { + xxx_messageInfo_VerificationFlags.DiscardUnknown(m) +} + +var xxx_messageInfo_VerificationFlags proto.InternalMessageInfo + +func (m *VerificationFlags) GetEthTypeChainEnabled() bool { + if m != nil { + return m.EthTypeChainEnabled + } + return false +} + +func (m *VerificationFlags) GetBtcTypeChainEnabled() bool { + if m != nil { + return m.BtcTypeChainEnabled + } + return false +} + +func init() { + proto.RegisterType((*VerificationFlags)(nil), "zetachain.zetacore.lightclient.VerificationFlags") +} + +func init() { + proto.RegisterFile("lightclient/verification_flags.proto", fileDescriptor_86eae6d737b3f8cc) +} + +var fileDescriptor_86eae6d737b3f8cc = []byte{ + // 199 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xc9, 0xc9, 0x4c, 0xcf, + 0x28, 0x49, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0x2f, 0x4b, 0x2d, 0xca, 0x4c, 0xcb, 0x4c, 0x4e, + 0x2c, 0xc9, 0xcc, 0xcf, 0x8b, 0x4f, 0xcb, 0x49, 0x4c, 0x2f, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x92, 0xab, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, + 0x52, 0xf5, 0x90, 0x34, 0x2a, 0x95, 0x73, 0x09, 0x86, 0x21, 0xe9, 0x75, 0x03, 0x69, 0x15, 0x32, + 0xe0, 0x12, 0x4e, 0x2d, 0xc9, 0x08, 0xa9, 0x2c, 0x48, 0x75, 0x06, 0xe9, 0x74, 0xcd, 0x4b, 0x4c, + 0xca, 0x49, 0x4d, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x08, 0xc2, 0x26, 0x05, 0xd2, 0x91, 0x54, + 0x92, 0x8c, 0xa1, 0x83, 0x09, 0xa2, 0x03, 0x8b, 0x94, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, + 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, + 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, + 0xea, 0x83, 0xdc, 0xac, 0x0b, 0x76, 0xbe, 0x3e, 0xcc, 0xf9, 0xfa, 0x15, 0xfa, 0xc8, 0x3e, 0x2f, + 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xfb, 0xd6, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x84, + 0x57, 0x0d, 0x3e, 0x15, 0x01, 0x00, 0x00, +} + +func (m *VerificationFlags) 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 *VerificationFlags) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VerificationFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BtcTypeChainEnabled { + i-- + if m.BtcTypeChainEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if m.EthTypeChainEnabled { + i-- + if m.EthTypeChainEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintVerificationFlags(dAtA []byte, offset int, v uint64) int { + offset -= sovVerificationFlags(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *VerificationFlags) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.EthTypeChainEnabled { + n += 2 + } + if m.BtcTypeChainEnabled { + n += 2 + } + return n +} + +func sovVerificationFlags(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozVerificationFlags(x uint64) (n int) { + return sovVerificationFlags(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *VerificationFlags) 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 ErrIntOverflowVerificationFlags + } + 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: VerificationFlags: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VerificationFlags: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EthTypeChainEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVerificationFlags + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.EthTypeChainEnabled = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcTypeChainEnabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowVerificationFlags + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BtcTypeChainEnabled = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipVerificationFlags(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthVerificationFlags + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipVerificationFlags(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVerificationFlags + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVerificationFlags + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowVerificationFlags + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthVerificationFlags + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupVerificationFlags + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthVerificationFlags + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthVerificationFlags = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowVerificationFlags = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupVerificationFlags = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/lightclient/types/verification_flags_test.go b/x/lightclient/types/verification_flags_test.go new file mode 100644 index 0000000000..6cb3806480 --- /dev/null +++ b/x/lightclient/types/verification_flags_test.go @@ -0,0 +1,15 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDefaultVerificationFlags(t *testing.T) { + t.Run("default verification flags is all disabled", func(t *testing.T) { + flags := DefaultVerificationFlags() + require.False(t, flags.EthTypeChainEnabled) + require.False(t, flags.BtcTypeChainEnabled) + }) +} diff --git a/x/observer/keeper/block_header.go b/x/observer/keeper/block_header.go deleted file mode 100644 index aaf06bca4b..0000000000 --- a/x/observer/keeper/block_header.go +++ /dev/null @@ -1,55 +0,0 @@ -package keeper - -import ( - "strconv" - - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg/proofs" - "github.com/zeta-chain/zetacore/x/observer/types" -) - -// SetBlockHeader set a specific block header in the store from its index -func (k Keeper) SetBlockHeader(ctx sdk.Context, header proofs.BlockHeader) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderKey)) - b := k.cdc.MustMarshal(&header) - store.Set(header.Hash, b) -} - -// GetBlockHeader returns a block header from its hash -func (k Keeper) GetBlockHeader(ctx sdk.Context, hash []byte) (val proofs.BlockHeader, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderKey)) - - b := store.Get(hash) - if b == nil { - return val, false - } - - k.cdc.MustUnmarshal(b, &val) - return val, true -} - -// RemoveBlockHeader removes a block header from the store -func (k Keeper) RemoveBlockHeader(ctx sdk.Context, hash []byte) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderKey)) - store.Delete(hash) -} - -func (k Keeper) SetBlockHeaderState(ctx sdk.Context, blockHeaderState types.BlockHeaderState) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderStateKey)) - b := k.cdc.MustMarshal(&blockHeaderState) - key := strconv.FormatInt(blockHeaderState.ChainId, 10) - store.Set(types.KeyPrefix(key), b) -} - -func (k Keeper) GetBlockHeaderState(ctx sdk.Context, chainID int64) (val types.BlockHeaderState, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderStateKey)) - - b := store.Get(types.KeyPrefix(strconv.FormatInt(chainID, 10))) - if b == nil { - return val, false - } - - k.cdc.MustUnmarshal(b, &val) - return val, true -} diff --git a/x/observer/keeper/block_header_test.go b/x/observer/keeper/block_header_test.go deleted file mode 100644 index 5ab61ed20f..0000000000 --- a/x/observer/keeper/block_header_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/proofs" - keepertest "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/testutil/sample" -) - -func TestKeeper_GetBlockHeader(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - blockHash := sample.Hash().Bytes() - _, found := k.GetBlockHeader(ctx, blockHash) - require.False(t, found) - - bh := proofs.BlockHeader{ - Height: 1, - Hash: blockHash, - ParentHash: sample.Hash().Bytes(), - ChainId: 1, - Header: proofs.HeaderData{}, - } - k.SetBlockHeader(ctx, bh) - _, found = k.GetBlockHeader(ctx, blockHash) - require.True(t, found) - - k.RemoveBlockHeader(ctx, blockHash) - _, found = k.GetBlockHeader(ctx, blockHash) - require.False(t, found) -} diff --git a/x/observer/keeper/grpc_query_block_header_test.go b/x/observer/keeper/grpc_query_block_header_test.go deleted file mode 100644 index 9cf50f07a4..0000000000 --- a/x/observer/keeper/grpc_query_block_header_test.go +++ /dev/null @@ -1,119 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/proofs" - keepertest "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/testutil/sample" - "github.com/zeta-chain/zetacore/x/observer/types" -) - -func TestKeeper_GetAllBlockHeaders(t *testing.T) { - t.Run("should error if req is nil", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.GetAllBlockHeaders(wctx, nil) - require.Nil(t, res) - require.Error(t, err) - }) - - t.Run("should return if block header is found", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - bh := proofs.BlockHeader{ - Height: 1, - Hash: sample.Hash().Bytes(), - ParentHash: sample.Hash().Bytes(), - ChainId: 1, - Header: proofs.HeaderData{}, - } - k.SetBlockHeader(ctx, bh) - - res, err := k.GetAllBlockHeaders(wctx, &types.QueryAllBlockHeaderRequest{}) - require.NoError(t, err) - require.Equal(t, &bh, res.BlockHeaders[0]) - }) -} - -func TestKeeper_GetBlockHeaderByHash(t *testing.T) { - t.Run("should error if req is nil", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.GetBlockHeaderByHash(wctx, nil) - require.Nil(t, res) - require.Error(t, err) - }) - - t.Run("should error if not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.GetBlockHeaderByHash(wctx, &types.QueryGetBlockHeaderByHashRequest{ - BlockHash: sample.Hash().Bytes(), - }) - require.Nil(t, res) - require.Error(t, err) - }) - - t.Run("should return if block header is found", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - bh := proofs.BlockHeader{ - Height: 1, - Hash: sample.Hash().Bytes(), - ParentHash: sample.Hash().Bytes(), - ChainId: 1, - Header: proofs.HeaderData{}, - } - k.SetBlockHeader(ctx, bh) - - res, err := k.GetBlockHeaderByHash(wctx, &types.QueryGetBlockHeaderByHashRequest{ - BlockHash: bh.Hash, - }) - require.NoError(t, err) - require.Equal(t, &bh, res.BlockHeader) - }) -} - -func TestKeeper_GetBlockHeaderStateByChain(t *testing.T) { - t.Run("should error if req is nil", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.GetBlockHeaderStateByChain(wctx, nil) - require.Nil(t, res) - require.Error(t, err) - }) - - t.Run("should error if not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.GetBlockHeaderStateByChain(wctx, &types.QueryGetBlockHeaderStateRequest{ - ChainId: 1, - }) - require.Nil(t, res) - require.Error(t, err) - }) - - t.Run("should return if block header state is found", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - bhs := types.BlockHeaderState{ - ChainId: 1, - } - k.SetBlockHeaderState(ctx, bhs) - - res, err := k.GetBlockHeaderStateByChain(wctx, &types.QueryGetBlockHeaderStateRequest{ - ChainId: 1, - }) - require.NoError(t, err) - require.Equal(t, &bhs, res.BlockHeaderState) - }) -} diff --git a/x/observer/keeper/grpc_query_prove_test.go b/x/observer/keeper/grpc_query_prove_test.go deleted file mode 100644 index 7eb11b00f5..0000000000 --- a/x/observer/keeper/grpc_query_prove_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package keeper_test - -import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/proofs" - keepertest "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/testutil/sample" - "github.com/zeta-chain/zetacore/x/observer/types" -) - -func TestKeeper_Prove(t *testing.T) { - t.Run("should error if req is nil", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.Prove(wctx, nil) - require.Nil(t, res) - require.Error(t, err) - }) - - t.Run("should error if invalid hash", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.Prove(wctx, &types.QueryProveRequest{ - ChainId: 987, - BlockHash: sample.Hash().String(), - }) - require.Nil(t, res) - require.Error(t, err) - }) - - t.Run("should error if header not found", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - res, err := k.Prove(wctx, &types.QueryProveRequest{ - ChainId: 5, - BlockHash: sample.Hash().String(), - }) - require.Nil(t, res) - require.Error(t, err) - }) - - t.Run("should error if proof not valid", func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - - hash := sample.Hash() - bh := proofs.BlockHeader{ - Height: 1, - Hash: hash.Bytes(), - ParentHash: sample.Hash().Bytes(), - ChainId: 1, - Header: proofs.HeaderData{}, - } - k.SetBlockHeader(ctx, bh) - - res, err := k.Prove(wctx, &types.QueryProveRequest{ - ChainId: 5, - BlockHash: hash.String(), - Proof: &proofs.Proof{}, - }) - require.Nil(t, res) - require.Error(t, err) - }) - - // TODO: // https://github.com/zeta-chain/node/issues/1875 add more tests -} diff --git a/x/observer/keeper/grpc_query_tss.go b/x/observer/keeper/grpc_query_tss.go index 48485f0112..0b6f4a7614 100644 --- a/x/observer/keeper/grpc_query_tss.go +++ b/x/observer/keeper/grpc_query_tss.go @@ -12,7 +12,7 @@ import ( "google.golang.org/grpc/status" ) -// Tss returns the tss address for the current tss only +// TSS returns the tss address for the current tss only func (k Keeper) TSS(c context.Context, req *types.QueryGetTSSRequest) (*types.QueryGetTSSResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") diff --git a/x/observer/keeper/keeper.go b/x/observer/keeper/keeper.go index cda854ccc6..7d72d49f06 100644 --- a/x/observer/keeper/keeper.go +++ b/x/observer/keeper/keeper.go @@ -13,13 +13,14 @@ import ( type ( Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace - stakingKeeper types.StakingKeeper - slashingKeeper types.SlashingKeeper - authorityKeeper types.AuthorityKeeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + stakingKeeper types.StakingKeeper + slashingKeeper types.SlashingKeeper + authorityKeeper types.AuthorityKeeper + lightclientKeeper types.LightclientKeeper } ) @@ -31,6 +32,7 @@ func NewKeeper( stakingKeeper types.StakingKeeper, slashinKeeper types.SlashingKeeper, authorityKeeper types.AuthorityKeeper, + lightclientKeeper types.LightclientKeeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -38,13 +40,14 @@ func NewKeeper( } return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - stakingKeeper: stakingKeeper, - slashingKeeper: slashinKeeper, - authorityKeeper: authorityKeeper, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + stakingKeeper: stakingKeeper, + slashingKeeper: slashinKeeper, + authorityKeeper: authorityKeeper, + lightclientKeeper: lightclientKeeper, } } @@ -60,6 +63,10 @@ func (k Keeper) GetAuthorityKeeper() types.AuthorityKeeper { return k.authorityKeeper } +func (k Keeper) GetLightclientKeeper() types.LightclientKeeper { + return k.lightclientKeeper +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/observer/keeper/msg_server_add_block_header.go b/x/observer/keeper/msg_server_add_block_header.go deleted file mode 100644 index 3a0e291f18..0000000000 --- a/x/observer/keeper/msg_server_add_block_header.go +++ /dev/null @@ -1,125 +0,0 @@ -package keeper - -import ( - "context" - "fmt" - - cosmoserrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg/chains" - "github.com/zeta-chain/zetacore/pkg/proofs" - "github.com/zeta-chain/zetacore/x/observer/types" -) - -// AddBlockHeader handles adding a block header to the store, through majority voting of observers -func (k msgServer) AddBlockHeader(goCtx context.Context, msg *types.MsgAddBlockHeader) (*types.MsgAddBlockHeaderResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // check authorization for this chain - chain := k.GetSupportedChainFromChainID(ctx, msg.ChainId) - if chain == nil { - return nil, cosmoserrors.Wrapf(types.ErrSupportedChains, "chain id: %d", msg.ChainId) - } - - if ok := k.IsNonTombstonedObserver(ctx, msg.Creator); !ok { - return nil, types.ErrNotObserver - } - - crosschainFlags, found := k.GetCrosschainFlags(ctx) - if !found { - return nil, fmt.Errorf("crosschain flags not found") - } - if crosschainFlags.BlockHeaderVerificationFlags == nil { - return nil, fmt.Errorf("block header verification flags not found") - } - if chains.IsBitcoinChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled { - return nil, cosmoserrors.Wrapf(types.ErrBlockHeaderVerificationDisabled, "proof verification not enabled for bitcoin ,chain id: %d", msg.ChainId) - } - if chains.IsEVMChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled { - return nil, cosmoserrors.Wrapf(types.ErrBlockHeaderVerificationDisabled, "proof verification not enabled for evm ,chain id: %d", msg.ChainId) - } - - _, found = k.GetBlockHeader(ctx, msg.BlockHash) - if found { - return nil, cosmoserrors.Wrap(types.ErrBlockAlreadyExist, fmt.Sprintf("block hash: %x", msg.BlockHash)) - } - - // if BlockHeaderState exists and parent block header is not found, this tx is rejected - // if no BlockHeaderState is found, allow this vote to pass through to create and initialize - // the Earliest/Latest height with this block header (after voting, not here) - // if BlockHeaderState is found, check if the block height is valid - // validate block height as it's not part of the header itself - bhs, found := k.Keeper.GetBlockHeaderState(ctx, msg.ChainId) - if found && bhs.EarliestHeight > 0 && bhs.EarliestHeight < msg.Height { - pHash, err := msg.Header.ParentHash() - if err != nil { - return nil, cosmoserrors.Wrap(types.ErrNoParentHash, err.Error()) - } - _, found = k.GetBlockHeader(ctx, pHash) - if !found { - return nil, cosmoserrors.Wrap(types.ErrNoParentHash, "parent block header not found") - } - if msg.Height != bhs.LatestHeight+1 { - return nil, cosmoserrors.Wrap(types.ErrNoParentHash, fmt.Sprintf("invalid block height: wanted %d, got %d", bhs.LatestHeight+1, msg.Height)) - } - } - - // Check timestamp - err := msg.Header.ValidateTimestamp(ctx.BlockTime()) - if err != nil { - return nil, cosmoserrors.Wrap(types.ErrInvalidTimestamp, err.Error()) - } - - // NOTE: error is checked in BasicValidation in msg; check again for extra caution - pHash, err := msg.Header.ParentHash() - if err != nil { - return nil, cosmoserrors.Wrap(types.ErrNoParentHash, err.Error()) - } - - // add vote to ballot - ballot, _, err := k.FindBallot(ctx, msg.Digest(), chain, types.ObservationType_InBoundTx) - if err != nil { - return nil, cosmoserrors.Wrap(err, "failed to find ballot") - } - ballot, err = k.AddVoteToBallot(ctx, ballot, msg.Creator, types.VoteType_SuccessObservation) - if err != nil { - return nil, cosmoserrors.Wrap(err, "failed to add vote to ballot") - } - _, isFinalized := k.CheckIfFinalizingVote(ctx, ballot) - if !isFinalized { - return &types.MsgAddBlockHeaderResponse{}, nil - } - - /** - * Vote finalized, add block header to store - */ - bhs, found = k.Keeper.GetBlockHeaderState(ctx, msg.ChainId) - if !found { - bhs = types.BlockHeaderState{ - ChainId: msg.ChainId, - LatestHeight: msg.Height, - EarliestHeight: msg.Height, - LatestBlockHash: msg.BlockHash, - } - } else { - if msg.Height > bhs.LatestHeight { - bhs.LatestHeight = msg.Height - bhs.LatestBlockHash = msg.BlockHash - } - if bhs.EarliestHeight == 0 { - bhs.EarliestHeight = msg.Height - } - } - k.Keeper.SetBlockHeaderState(ctx, bhs) - - bh := proofs.BlockHeader{ - Header: msg.Header, - Height: msg.Height, - Hash: msg.BlockHash, - ParentHash: pHash, - ChainId: msg.ChainId, - } - k.SetBlockHeader(ctx, bh) - - return &types.MsgAddBlockHeaderResponse{}, nil -} diff --git a/x/observer/keeper/msg_server_add_block_header_test.go b/x/observer/keeper/msg_server_add_block_header_test.go deleted file mode 100644 index 2bd1949c95..0000000000 --- a/x/observer/keeper/msg_server_add_block_header_test.go +++ /dev/null @@ -1,218 +0,0 @@ -package keeper_test - -import ( - "encoding/json" - "math/rand" - "os" - "testing" - - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rlp" - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg/chains" - "github.com/zeta-chain/zetacore/pkg/proofs" - keepertest "github.com/zeta-chain/zetacore/testutil/keeper" - "github.com/zeta-chain/zetacore/testutil/sample" - "github.com/zeta-chain/zetacore/x/observer/keeper" - "github.com/zeta-chain/zetacore/x/observer/types" -) - -func TestMsgServer_AddBlockHeader(t *testing.T) { - header, header2, header3, err := ethHeaders() - require.NoError(t, err) - header1RLP, err := rlp.EncodeToBytes(header) - require.NoError(t, err) - header2RLP, err := rlp.EncodeToBytes(header2) - require.NoError(t, err) - header3RLP, err := rlp.EncodeToBytes(header3) - require.NoError(t, err) - - r := rand.New(rand.NewSource(9)) - validator := sample.Validator(t, r) - observerAddress, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - require.NoError(t, err) - // Add tests for btc headers : https://github.com/zeta-chain/node/issues/1336 - tt := []struct { - name string - msg *types.MsgAddBlockHeader - IsEthTypeChainEnabled bool - IsBtcTypeChainEnabled bool - validator stakingtypes.Validator - wantErr require.ErrorAssertionFunc - }{ - { - name: "success submit eth header", - msg: &types.MsgAddBlockHeader{ - Creator: observerAddress.String(), - ChainId: chains.GoerliLocalnetChain().ChainId, - BlockHash: header.Hash().Bytes(), - Height: 1, - Header: proofs.NewEthereumHeader(header1RLP), - }, - IsEthTypeChainEnabled: true, - IsBtcTypeChainEnabled: true, - validator: validator, - wantErr: require.NoError, - }, - { - name: "failure submit eth header eth disabled", - msg: &types.MsgAddBlockHeader{ - Creator: observerAddress.String(), - ChainId: chains.GoerliLocalnetChain().ChainId, - BlockHash: header.Hash().Bytes(), - Height: 1, - Header: proofs.NewEthereumHeader(header1RLP), - }, - IsEthTypeChainEnabled: false, - IsBtcTypeChainEnabled: true, - validator: validator, - wantErr: func(t require.TestingT, err error, i ...interface{}) { - require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) - }, - }, - { - name: "failure submit eth header eth disabled", - msg: &types.MsgAddBlockHeader{ - Creator: sample.AccAddress(), - ChainId: chains.GoerliLocalnetChain().ChainId, - BlockHash: header.Hash().Bytes(), - Height: 1, - Header: proofs.NewEthereumHeader(header1RLP), - }, - IsEthTypeChainEnabled: false, - IsBtcTypeChainEnabled: true, - validator: validator, - wantErr: func(t require.TestingT, err error, i ...interface{}) { - require.ErrorIs(t, err, types.ErrNotObserver) - }, - }, - { - name: "should succeed if block header parent does exist", - msg: &types.MsgAddBlockHeader{ - Creator: observerAddress.String(), - ChainId: chains.GoerliLocalnetChain().ChainId, - BlockHash: header2.Hash().Bytes(), - Height: 2, - Header: proofs.NewEthereumHeader(header2RLP), - }, - IsEthTypeChainEnabled: true, - IsBtcTypeChainEnabled: true, - validator: validator, - wantErr: require.NoError, - }, - // These tests don't work when using the static headers, the previous sample were also not correct (header3 used to be nil) - // The second test mention it should success but assert an error - // TODO: fix these tests - // https://github.com/zeta-chain/node/issues/1875 - //{ - // name: "should fail if block header parent does not exist", - // msg: &types.MsgAddBlockHeader{ - // Creator: observerAddress.String(), - // ChainId: chains.GoerliLocalnetChain().ChainId, - // BlockHash: header3.Hash().Bytes(), - // Height: 3, - // Header: chains.NewEthereumHeader(header3RLP), - // }, - // IsEthTypeChainEnabled: true, - // IsBtcTypeChainEnabled: true, - // validator: validator, - // wantErr: func(t require.TestingT, err error, i ...interface{}) { - // require.Error(t, err) - // }, - //}, - //{ - // name: "should succeed to post 3rd header if 2nd header is posted", - // msg: &types.MsgAddBlockHeader{ - // Creator: observerAddress.String(), - // ChainId: chains.GoerliLocalnetChain().ChainId, - // BlockHash: header3.Hash().Bytes(), - // Height: 3, - // Header: chains.NewEthereumHeader(header3RLP), - // }, - // IsEthTypeChainEnabled: true, - // IsBtcTypeChainEnabled: true, - // validator: validator, - // wantErr: func(t require.TestingT, err error, i ...interface{}) { - // require.Error(t, err) - // }, - //}, - { - name: "should fail if chain is not supported", - msg: &types.MsgAddBlockHeader{ - Creator: observerAddress.String(), - ChainId: 9999, - BlockHash: header3.Hash().Bytes(), - Height: 3, - Header: proofs.NewEthereumHeader(header3RLP), - }, - IsEthTypeChainEnabled: true, - IsBtcTypeChainEnabled: true, - validator: validator, - wantErr: func(t require.TestingT, err error, i ...interface{}) { - require.ErrorIs(t, err, types.ErrSupportedChains) - }, - }, - } - for _, tc := range tt { - t.Run(tc.name, func(t *testing.T) { - k, ctx, _, _ := keepertest.ObserverKeeper(t) - srv := keeper.NewMsgServerImpl(*k) - k.SetObserverSet(ctx, types.ObserverSet{ - ObserverList: []string{observerAddress.String()}, - }) - k.GetStakingKeeper().SetValidator(ctx, tc.validator) - k.SetCrosschainFlags(ctx, types.CrosschainFlags{ - IsInboundEnabled: true, - IsOutboundEnabled: true, - GasPriceIncreaseFlags: nil, - BlockHeaderVerificationFlags: &types.BlockHeaderVerificationFlags{ - IsEthTypeChainEnabled: tc.IsEthTypeChainEnabled, - IsBtcTypeChainEnabled: tc.IsBtcTypeChainEnabled, - }, - }) - - setSupportedChain(ctx, *k, chains.GoerliLocalnetChain().ChainId) - - _, err := srv.AddBlockHeader(ctx, tc.msg) - tc.wantErr(t, err) - if err == nil { - bhs, found := k.GetBlockHeaderState(ctx, tc.msg.ChainId) - require.True(t, found) - require.Equal(t, tc.msg.Height, bhs.LatestHeight) - } - }) - } -} - -func ethHeaders() (*ethtypes.Header, *ethtypes.Header, *ethtypes.Header, error) { - header1, err := readHeader("./testdata/header_sepolia_5000000.json") - if err != nil { - return nil, nil, nil, err - } - header2, err := readHeader("./testdata/header_sepolia_5000001.json") - if err != nil { - return nil, nil, nil, err - } - header3, err := readHeader("./testdata/header_sepolia_5000002.json") - if err != nil { - return nil, nil, nil, err - } - return header1, header2, header3, nil -} - -// readReceipt reads a receipt from a file. -// TODO: centralize test data -// https://github.com/zeta-chain/node/issues/1874 -func readHeader(filename string) (*ethtypes.Header, error) { - file, err := os.Open(filename) - if err != nil { - return nil, err - } - defer file.Close() - - decoder := json.NewDecoder(file) - var NewHeader ethtypes.Header - err = decoder.Decode(&NewHeader) - return &NewHeader, err -} diff --git a/x/observer/keeper/msg_server_vote_block_header.go b/x/observer/keeper/msg_server_vote_block_header.go new file mode 100644 index 0000000000..a9050e7ebc --- /dev/null +++ b/x/observer/keeper/msg_server_vote_block_header.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "context" + + cosmoserrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +// VoteBlockHeader vote for a new block header to the storers +func (k msgServer) VoteBlockHeader(goCtx context.Context, msg *types.MsgVoteBlockHeader) (*types.MsgVoteBlockHeaderResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // check if the chain is enabled + chain := k.GetSupportedChainFromChainID(ctx, msg.ChainId) + if chain == nil { + return nil, cosmoserrors.Wrapf(types.ErrSupportedChains, "chain id: %d", msg.ChainId) + } + + // check if observer + if ok := k.IsNonTombstonedObserver(ctx, msg.Creator); !ok { + return nil, types.ErrNotObserver + } + + // check the new block header is valid + parentHash, err := k.lightclientKeeper.CheckNewBlockHeader(ctx, msg.ChainId, msg.BlockHash, msg.Height, msg.Header) + if err != nil { + return nil, cosmoserrors.Wrap(lightclienttypes.ErrInvalidBlockHeader, err.Error()) + } + + // add vote to ballot + ballot, isNew, err := k.FindBallot(ctx, msg.Digest(), chain, types.ObservationType_InBoundTx) + if err != nil { + return nil, cosmoserrors.Wrap(err, "failed to find ballot") + } + ballot, err = k.AddVoteToBallot(ctx, ballot, msg.Creator, types.VoteType_SuccessObservation) + if err != nil { + return nil, cosmoserrors.Wrap(err, "failed to add vote to ballot") + } + _, isFinalized := k.CheckIfFinalizingVote(ctx, ballot) + if !isFinalized { + return &types.MsgVoteBlockHeaderResponse{ + BallotCreated: isNew, + VoteFinalized: false, + }, nil + } + + // add the new block header to the store + k.lightclientKeeper.AddBlockHeader(ctx, msg.ChainId, msg.Height, msg.BlockHash, msg.Header, parentHash) + + return &types.MsgVoteBlockHeaderResponse{ + BallotCreated: isNew, + VoteFinalized: true, + }, nil +} diff --git a/x/observer/keeper/msg_server_vote_block_header_test.go b/x/observer/keeper/msg_server_vote_block_header_test.go new file mode 100644 index 0000000000..161d26ff5a --- /dev/null +++ b/x/observer/keeper/msg_server_vote_block_header_test.go @@ -0,0 +1,294 @@ +package keeper_test + +import ( + "errors" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + mocks "github.com/zeta-chain/zetacore/testutil/keeper/mocks/observer" + "github.com/zeta-chain/zetacore/testutil/sample" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" + "github.com/zeta-chain/zetacore/x/observer/keeper" + "github.com/zeta-chain/zetacore/x/observer/types" +) + +func mockCheckNewBlockHeader(m *mocks.ObserverLightclientKeeper, err error) { + m.On( + "CheckNewBlockHeader", + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + ).Return(sample.Hash().Bytes(), err) +} + +func mockAddBlockHeader(m *mocks.ObserverLightclientKeeper) { + m.On( + "AddBlockHeader", + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + mock.Anything, + ) +} + +func TestMsgServer_VoteBlockHeader(t *testing.T) { + one, err := sdk.NewDecFromStr("1.0") + require.NoError(t, err) + + t.Run("fails if the chain is not supported", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + + _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: sample.AccAddress(), + ChainId: 9999, + BlockHash: sample.Hash().Bytes(), + Height: 42, + Header: proofs.HeaderData{}, + }) + + require.ErrorIs(t, err, types.ErrSupportedChains) + }) + + t.Run("fails if the observer is not in the observer set", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + + k.SetChainParamsList(ctx, types.ChainParamsList{ + ChainParams: []*types.ChainParams{ + { + ChainId: chains.GoerliLocalnetChain().ChainId, + IsSupported: true, + BallotThreshold: one, + }, + }, + }) + + _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: sample.AccAddress(), + ChainId: chains.GoerliLocalnetChain().ChainId, + BlockHash: sample.Hash().Bytes(), + Height: 42, + Header: proofs.HeaderData{}, + }) + + require.ErrorIs(t, err, types.ErrNotObserver) + }) + + t.Run("fails if the new block header is invalid", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + srv := keeper.NewMsgServerImpl(*k) + observer := sample.AccAddress() + + stakingMock := keepertest.GetObserverStakingMock(t, k) + slashingMock := keepertest.GetObserverSlashingMock(t, k) + lightclientMock := keepertest.GetObserverLightclientMock(t, k) + + k.SetChainParamsList(ctx, types.ChainParamsList{ + ChainParams: []*types.ChainParams{ + { + ChainId: chains.GoerliLocalnetChain().ChainId, + IsSupported: true, + BallotThreshold: one, + }, + }, + }) + + k.SetObserverSet(ctx, types.ObserverSet{ + ObserverList: []string{observer}, + }) + + stakingMock.MockGetValidator(sample.Validator(t, sample.Rand())) + slashingMock.MockIsTombstoned(false) + mockCheckNewBlockHeader(lightclientMock, errors.New("foo")) + + _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: observer, + ChainId: chains.GoerliLocalnetChain().ChainId, + BlockHash: sample.Hash().Bytes(), + Height: 42, + Header: proofs.HeaderData{}, + }) + + require.ErrorIs(t, err, lightclienttypes.ErrInvalidBlockHeader) + }) + + t.Run("can create a new ballot, vote and finalize", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + srv := keeper.NewMsgServerImpl(*k) + observer := sample.AccAddress() + + stakingMock := keepertest.GetObserverStakingMock(t, k) + slashingMock := keepertest.GetObserverSlashingMock(t, k) + lightclientMock := keepertest.GetObserverLightclientMock(t, k) + + k.SetChainParamsList(ctx, types.ChainParamsList{ + ChainParams: []*types.ChainParams{ + { + ChainId: chains.GoerliLocalnetChain().ChainId, + IsSupported: true, + BallotThreshold: one, + }, + }, + }) + + k.SetObserverSet(ctx, types.ObserverSet{ + ObserverList: []string{observer}, + }) + + stakingMock.MockGetValidator(sample.Validator(t, sample.Rand())) + slashingMock.MockIsTombstoned(false) + mockCheckNewBlockHeader(lightclientMock, nil) + mockAddBlockHeader(lightclientMock) + + // there is a single node account, so the ballot will be created and finalized in a single vote + res, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: observer, + ChainId: chains.GoerliLocalnetChain().ChainId, + BlockHash: sample.Hash().Bytes(), + Height: 42, + Header: proofs.HeaderData{}, + }) + + require.NoError(t, err) + require.True(t, res.VoteFinalized) + require.True(t, res.BallotCreated) + }) + + t.Run("can create a new ballot, vote without finalizing, then add vote and finalizing", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + srv := keeper.NewMsgServerImpl(*k) + observer1 := sample.AccAddress() + observer2 := sample.AccAddress() + observer3 := sample.AccAddress() + blockHash := sample.Hash().Bytes() + + stakingMock := keepertest.GetObserverStakingMock(t, k) + slashingMock := keepertest.GetObserverSlashingMock(t, k) + lightclientMock := keepertest.GetObserverLightclientMock(t, k) + + k.SetChainParamsList(ctx, types.ChainParamsList{ + ChainParams: []*types.ChainParams{ + { + ChainId: chains.GoerliLocalnetChain().ChainId, + IsSupported: true, + BallotThreshold: one, + }, + }, + }) + + k.SetObserverSet(ctx, types.ObserverSet{ + ObserverList: []string{observer1, observer2, observer3}, + }) + + // first observer, created, not finalized + stakingMock.MockGetValidator(sample.Validator(t, sample.Rand())) + slashingMock.MockIsTombstoned(false) + mockCheckNewBlockHeader(lightclientMock, nil) + res, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: observer1, + ChainId: chains.GoerliLocalnetChain().ChainId, + BlockHash: blockHash, + Height: 42, + Header: proofs.HeaderData{}, + }) + + require.NoError(t, err) + require.False(t, res.VoteFinalized) + require.True(t, res.BallotCreated) + + // second observer, found, not finalized + stakingMock.MockGetValidator(sample.Validator(t, sample.Rand())) + slashingMock.MockIsTombstoned(false) + mockCheckNewBlockHeader(lightclientMock, nil) + res, err = srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: observer2, + ChainId: chains.GoerliLocalnetChain().ChainId, + BlockHash: blockHash, + Height: 42, + Header: proofs.HeaderData{}, + }) + + require.NoError(t, err) + require.False(t, res.VoteFinalized) + require.False(t, res.BallotCreated) + + // third observer, found, finalized, add block header called + stakingMock.MockGetValidator(sample.Validator(t, sample.Rand())) + slashingMock.MockIsTombstoned(false) + mockCheckNewBlockHeader(lightclientMock, nil) + mockAddBlockHeader(lightclientMock) + res, err = srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: observer3, + ChainId: chains.GoerliLocalnetChain().ChainId, + BlockHash: blockHash, + Height: 42, + Header: proofs.HeaderData{}, + }) + + require.NoError(t, err) + require.True(t, res.VoteFinalized) + require.False(t, res.BallotCreated) + }) + + t.Run("fail if voting fails", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeperWithMocks(t, keepertest.ObserverMocksAll) + srv := keeper.NewMsgServerImpl(*k) + observer := sample.AccAddress() + blockHash := sample.Hash().Bytes() + + stakingMock := keepertest.GetObserverStakingMock(t, k) + slashingMock := keepertest.GetObserverSlashingMock(t, k) + lightclientMock := keepertest.GetObserverLightclientMock(t, k) + + k.SetChainParamsList(ctx, types.ChainParamsList{ + ChainParams: []*types.ChainParams{ + { + ChainId: chains.GoerliLocalnetChain().ChainId, + IsSupported: true, + BallotThreshold: one, + }, + }, + }) + + // add multiple observers to not finalize the vote + k.SetObserverSet(ctx, types.ObserverSet{ + ObserverList: []string{observer, sample.AccAddress()}, + }) + + // vote once + stakingMock.MockGetValidator(sample.Validator(t, sample.Rand())) + slashingMock.MockIsTombstoned(false) + mockCheckNewBlockHeader(lightclientMock, nil) + _, err := srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: observer, + ChainId: chains.GoerliLocalnetChain().ChainId, + BlockHash: blockHash, + Height: 42, + Header: proofs.HeaderData{}, + }) + require.NoError(t, err) + + // vote a second time should make voting fail + stakingMock.MockGetValidator(sample.Validator(t, sample.Rand())) + slashingMock.MockIsTombstoned(false) + mockCheckNewBlockHeader(lightclientMock, nil) + _, err = srv.VoteBlockHeader(ctx, &types.MsgVoteBlockHeader{ + Creator: observer, + ChainId: chains.GoerliLocalnetChain().ChainId, + BlockHash: blockHash, + Height: 42, + Header: proofs.HeaderData{}, + }) + require.ErrorIs(t, err, types.ErrUnableToAddVote) + }) +} diff --git a/x/observer/keeper/utils.go b/x/observer/keeper/utils.go index 566b559630..ca3fc00f55 100644 --- a/x/observer/keeper/utils.go +++ b/x/observer/keeper/utils.go @@ -45,6 +45,8 @@ func (k Keeper) IsNonTombstonedObserver(ctx sdk.Context, address string) bool { return true } +// FindBallot finds the ballot for the given index +// If the ballot is not found, it creates a new ballot and returns it func (k Keeper) FindBallot( ctx sdk.Context, index string, @@ -58,8 +60,7 @@ func (k Keeper) FindBallot( cp, found := k.GetChainParamsByChainID(ctx, chain.ChainId) if !found || cp == nil || !cp.IsSupported { - err = types.ErrSupportedChains - return + return types.Ballot{}, false, types.ErrSupportedChains } ballot = types.Ballot{ diff --git a/x/observer/types/codec.go b/x/observer/types/codec.go index c729bb3a84..91cc9725db 100644 --- a/x/observer/types/codec.go +++ b/x/observer/types/codec.go @@ -11,10 +11,10 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgAddObserver{}, "observer/AddObserver", nil) cdc.RegisterConcrete(&MsgUpdateChainParams{}, "observer/UpdateChainParams", nil) cdc.RegisterConcrete(&MsgRemoveChainParams{}, "observer/RemoveChainParams", nil) + cdc.RegisterConcrete(&MsgVoteBlockHeader{}, "observer/VoteBlockHeader", nil) cdc.RegisterConcrete(&MsgAddBlameVote{}, "observer/AddBlameVote", nil) cdc.RegisterConcrete(&MsgUpdateCrosschainFlags{}, "observer/UpdateCrosschainFlags", nil) cdc.RegisterConcrete(&MsgUpdateKeygen{}, "observer/UpdateKeygen", nil) - cdc.RegisterConcrete(&MsgAddBlockHeader{}, "observer/AddBlockHeader", nil) cdc.RegisterConcrete(&MsgUpdateObserver{}, "observer/UpdateObserver", nil) cdc.RegisterConcrete(&MsgResetChainNonces{}, "observer/ResetChainNonces", nil) cdc.RegisterConcrete(&MsgVoteTSS{}, "observer/VoteTSS", nil) @@ -28,7 +28,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgAddBlameVote{}, &MsgUpdateCrosschainFlags{}, &MsgUpdateKeygen{}, - &MsgAddBlockHeader{}, + &MsgVoteBlockHeader{}, &MsgUpdateObserver{}, &MsgResetChainNonces{}, &MsgVoteTSS{}, diff --git a/x/observer/types/crosschain_flags.go b/x/observer/types/crosschain_flags.go index 876baf80e1..697e830e92 100644 --- a/x/observer/types/crosschain_flags.go +++ b/x/observer/types/crosschain_flags.go @@ -21,6 +21,8 @@ var DefaultGasPriceIncreaseFlags = GasPriceIncreaseFlags{ MaxPendingCctxs: 500, } +// DefaultBlockHeaderVerificationFlags returns the default block header verification flags used when not defined +// Deprecated(v16): VerificationFlags are now read in the `lightclient` module var DefaultBlockHeaderVerificationFlags = BlockHeaderVerificationFlags{ IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, @@ -29,9 +31,11 @@ var DefaultBlockHeaderVerificationFlags = BlockHeaderVerificationFlags{ // DefaultCrosschainFlags returns the default crosschain flags used when not defined func DefaultCrosschainFlags() *CrosschainFlags { return &CrosschainFlags{ - IsInboundEnabled: true, - IsOutboundEnabled: true, - GasPriceIncreaseFlags: &DefaultGasPriceIncreaseFlags, + IsInboundEnabled: true, + IsOutboundEnabled: true, + GasPriceIncreaseFlags: &DefaultGasPriceIncreaseFlags, + + // Deprecated(v16): VerificationFlags are now read in the `lightclient` module BlockHeaderVerificationFlags: &DefaultBlockHeaderVerificationFlags, } } diff --git a/x/observer/types/crosschain_flags.pb.go b/x/observer/types/crosschain_flags.pb.go index e1c4dd34ae..e8948a2b9b 100644 --- a/x/observer/types/crosschain_flags.pb.go +++ b/x/observer/types/crosschain_flags.pb.go @@ -107,6 +107,7 @@ func (m *GasPriceIncreaseFlags) GetMaxPendingCctxs() uint32 { return 0 } +// Deprecated(v16): Use VerificationFlags in the lightclient module instead type BlockHeaderVerificationFlags struct { IsEthTypeChainEnabled bool `protobuf:"varint,1,opt,name=isEthTypeChainEnabled,proto3" json:"isEthTypeChainEnabled,omitempty"` IsBtcTypeChainEnabled bool `protobuf:"varint,2,opt,name=isBtcTypeChainEnabled,proto3" json:"isBtcTypeChainEnabled,omitempty"` @@ -160,9 +161,10 @@ func (m *BlockHeaderVerificationFlags) GetIsBtcTypeChainEnabled() bool { } type CrosschainFlags struct { - IsInboundEnabled bool `protobuf:"varint,1,opt,name=isInboundEnabled,proto3" json:"isInboundEnabled,omitempty"` - IsOutboundEnabled bool `protobuf:"varint,2,opt,name=isOutboundEnabled,proto3" json:"isOutboundEnabled,omitempty"` - GasPriceIncreaseFlags *GasPriceIncreaseFlags `protobuf:"bytes,3,opt,name=gasPriceIncreaseFlags,proto3" json:"gasPriceIncreaseFlags,omitempty"` + IsInboundEnabled bool `protobuf:"varint,1,opt,name=isInboundEnabled,proto3" json:"isInboundEnabled,omitempty"` + IsOutboundEnabled bool `protobuf:"varint,2,opt,name=isOutboundEnabled,proto3" json:"isOutboundEnabled,omitempty"` + GasPriceIncreaseFlags *GasPriceIncreaseFlags `protobuf:"bytes,3,opt,name=gasPriceIncreaseFlags,proto3" json:"gasPriceIncreaseFlags,omitempty"` + // Deprecated(v16): Use VerificationFlags in the lightclient module instead BlockHeaderVerificationFlags *BlockHeaderVerificationFlags `protobuf:"bytes,4,opt,name=blockHeaderVerificationFlags,proto3" json:"blockHeaderVerificationFlags,omitempty"` } diff --git a/x/observer/types/errors.go b/x/observer/types/errors.go index 569bdc1754..1c03f9bbf9 100644 --- a/x/observer/types/errors.go +++ b/x/observer/types/errors.go @@ -20,19 +20,15 @@ var ( ErrKeygenBlockTooLow = errorsmod.Register(ModuleName, 1114, "please set a block number at-least 10 blocks higher than the current block number") ErrKeygenCompleted = errorsmod.Register(ModuleName, 1115, "keygen already completed") - ErrBlockAlreadyExist = errorsmod.Register(ModuleName, 1119, "block already exists") - ErrNoParentHash = errorsmod.Register(ModuleName, 1120, "no parent hash") - ErrInvalidTimestamp = errorsmod.Register(ModuleName, 1121, "invalid timestamp") - ErrBlockHeaderVerificationDisabled = errorsmod.Register(ModuleName, 1122, "block header verification is disabled") - ErrLastObserverCountNotFound = errorsmod.Register(ModuleName, 1123, "last observer count not found") - ErrUpdateObserver = errorsmod.Register(ModuleName, 1124, "unable to update observer") - ErrNodeAccountNotFound = errorsmod.Register(ModuleName, 1125, "node account not found") - ErrInvalidChainParams = errorsmod.Register(ModuleName, 1126, "invalid chain params") - ErrChainParamsNotFound = errorsmod.Register(ModuleName, 1127, "chain params not found") - ErrParamsMinObserverDelegation = errorsmod.Register(ModuleName, 1128, "min observer delegation cannot be nil") - ErrMinDelegationNotFound = errorsmod.Register(ModuleName, 1129, "min delegation not found") - ErrObserverSetNotFound = errorsmod.Register(ModuleName, 1130, "observer set not found") - ErrTssNotFound = errorsmod.Register(ModuleName, 1131, "tss not found") + ErrLastObserverCountNotFound = errorsmod.Register(ModuleName, 1123, "last observer count not found") + ErrUpdateObserver = errorsmod.Register(ModuleName, 1124, "unable to update observer") + ErrNodeAccountNotFound = errorsmod.Register(ModuleName, 1125, "node account not found") + ErrInvalidChainParams = errorsmod.Register(ModuleName, 1126, "invalid chain params") + ErrChainParamsNotFound = errorsmod.Register(ModuleName, 1127, "chain params not found") + ErrParamsMinObserverDelegation = errorsmod.Register(ModuleName, 1128, "min observer delegation cannot be nil") + ErrMinDelegationNotFound = errorsmod.Register(ModuleName, 1129, "min delegation not found") + ErrObserverSetNotFound = errorsmod.Register(ModuleName, 1130, "observer set not found") + ErrTssNotFound = errorsmod.Register(ModuleName, 1131, "tss not found") ErrInboundDisabled = errorsmod.Register(ModuleName, 1132, "inbound tx processing is disabled") ErrInvalidZetaCoinTypes = errorsmod.Register(ModuleName, 1133, "invalid zeta coin types") diff --git a/x/observer/types/expected_keepers.go b/x/observer/types/expected_keepers.go index ba1c9ab9c2..74f839c4ee 100644 --- a/x/observer/types/expected_keepers.go +++ b/x/observer/types/expected_keepers.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/zeta-chain/zetacore/pkg/proofs" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" ) @@ -31,3 +32,21 @@ type AuthorityKeeper interface { // SetPolicies is solely used for the migration of policies from observer to authority SetPolicies(ctx sdk.Context, policies authoritytypes.Policies) } + +type LightclientKeeper interface { + CheckNewBlockHeader( + ctx sdk.Context, + chainID int64, + blockHash []byte, + height int64, + header proofs.HeaderData, + ) ([]byte, error) + AddBlockHeader( + ctx sdk.Context, + chainID int64, + height int64, + blockHash []byte, + header proofs.HeaderData, + parentHash []byte, + ) +} diff --git a/x/observer/types/message_crosschain_flags.go b/x/observer/types/message_update_crosschain_flags.go similarity index 100% rename from x/observer/types/message_crosschain_flags.go rename to x/observer/types/message_update_crosschain_flags.go diff --git a/x/observer/types/message_crosschain_flags_test.go b/x/observer/types/message_update_crosschain_flags_test.go similarity index 100% rename from x/observer/types/message_crosschain_flags_test.go rename to x/observer/types/message_update_crosschain_flags_test.go diff --git a/x/observer/types/message_add_block_header.go b/x/observer/types/message_vote_block_header.go similarity index 61% rename from x/observer/types/message_add_block_header.go rename to x/observer/types/message_vote_block_header.go index 58be17f079..974db7d34d 100644 --- a/x/observer/types/message_add_block_header.go +++ b/x/observer/types/message_vote_block_header.go @@ -10,14 +10,14 @@ import ( "github.com/zeta-chain/zetacore/pkg/proofs" ) -var _ sdk.Msg = &MsgAddBlockHeader{} +var _ sdk.Msg = &MsgVoteBlockHeader{} const ( - TypeMsgAddBlockHeader = "add_block_header" + TypeMsgVoteBlockHeader = "vote_block_header" ) -func NewMsgAddBlockHeader(creator string, chainID int64, blockHash []byte, height int64, header proofs.HeaderData) *MsgAddBlockHeader { - return &MsgAddBlockHeader{ +func NewMsgVoteBlockHeader(creator string, chainID int64, blockHash []byte, height int64, header proofs.HeaderData) *MsgVoteBlockHeader { + return &MsgVoteBlockHeader{ Creator: creator, ChainId: chainID, BlockHash: blockHash, @@ -26,15 +26,15 @@ func NewMsgAddBlockHeader(creator string, chainID int64, blockHash []byte, heigh } } -func (msg *MsgAddBlockHeader) Route() string { +func (msg *MsgVoteBlockHeader) Route() string { return RouterKey } -func (msg *MsgAddBlockHeader) Type() string { - return TypeMsgAddBlockHeader +func (msg *MsgVoteBlockHeader) Type() string { + return TypeMsgVoteBlockHeader } -func (msg *MsgAddBlockHeader) GetSigners() []sdk.AccAddress { +func (msg *MsgVoteBlockHeader) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -42,25 +42,25 @@ func (msg *MsgAddBlockHeader) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{creator} } -func (msg *MsgAddBlockHeader) GetSignBytes() []byte { +func (msg *MsgVoteBlockHeader) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgAddBlockHeader) ValidateBasic() error { +func (msg *MsgVoteBlockHeader) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, err.Error()) } - if chains.IsHeaderSupportedEvmChain(msg.ChainId) || chains.IsBitcoinChain(msg.ChainId) { - if len(msg.BlockHash) != 32 { - return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid block hash length (%d)", len(msg.BlockHash)) - } - } else { + if !chains.IsHeaderSupportedEvmChain(msg.ChainId) && !chains.IsBitcoinChain(msg.ChainId) { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain id (%d)", msg.ChainId) } + if len(msg.BlockHash) != 32 { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid block hash length (%d)", len(msg.BlockHash)) + } + if err := msg.Header.Validate(msg.BlockHash, msg.ChainId, msg.Height); err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid block header (%s)", err) } @@ -72,7 +72,7 @@ func (msg *MsgAddBlockHeader) ValidateBasic() error { return nil } -func (msg *MsgAddBlockHeader) Digest() string { +func (msg *MsgVoteBlockHeader) Digest() string { m := *msg m.Creator = "" hash := crypto.Keccak256Hash([]byte(m.String())) diff --git a/x/observer/types/message_add_block_header_test.go b/x/observer/types/message_vote_block_header_test.go similarity index 77% rename from x/observer/types/message_add_block_header_test.go rename to x/observer/types/message_vote_block_header_test.go index 9f53590dde..46147c847b 100644 --- a/x/observer/types/message_add_block_header_test.go +++ b/x/observer/types/message_vote_block_header_test.go @@ -15,7 +15,7 @@ import ( "github.com/zeta-chain/zetacore/x/observer/types" ) -func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { +func TestMsgVoteBlockHeader_ValidateBasic(t *testing.T) { keeper.SetConfig(false) var header ethtypes.Header file, err := os.Open("../../../pkg/testdata/eth_header_18495266.json") @@ -32,12 +32,12 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { headerData := proofs.NewEthereumHeader(buffer.Bytes()) tests := []struct { name string - msg *types.MsgAddBlockHeader + msg *types.MsgVoteBlockHeader error bool }{ { name: "invalid creator", - msg: types.NewMsgAddBlockHeader( + msg: types.NewMsgVoteBlockHeader( "invalid_address", 1, []byte{}, @@ -48,7 +48,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { }, { name: "invalid chain id", - msg: types.NewMsgAddBlockHeader( + msg: types.NewMsgVoteBlockHeader( sample.AccAddress(), -1, []byte{}, @@ -59,7 +59,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { }, { name: "invalid header", - msg: types.NewMsgAddBlockHeader( + msg: types.NewMsgVoteBlockHeader( sample.AccAddress(), 5, sample.Hash().Bytes(), @@ -70,7 +70,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { }, { name: "invalid blockHash length", - msg: types.NewMsgAddBlockHeader( + msg: types.NewMsgVoteBlockHeader( sample.AccAddress(), 5, sample.Hash().Bytes()[:31], @@ -81,7 +81,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { }, { name: "valid", - msg: types.NewMsgAddBlockHeader( + msg: types.NewMsgVoteBlockHeader( sample.AccAddress(), 5, header.Hash().Bytes(), @@ -105,23 +105,23 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { } } -func TestMsgAddBlockHeader_GetSigners(t *testing.T) { +func TestMsgVoteBlockHeader_GetSigners(t *testing.T) { signer := sample.AccAddress() tests := []struct { name string - msg types.MsgAddBlockHeader + msg types.MsgVoteBlockHeader panics bool }{ { name: "valid signer", - msg: types.MsgAddBlockHeader{ + msg: types.MsgVoteBlockHeader{ Creator: signer, }, panics: false, }, { name: "invalid signer", - msg: types.MsgAddBlockHeader{ + msg: types.MsgVoteBlockHeader{ Creator: "invalid", }, panics: true, @@ -142,22 +142,22 @@ func TestMsgAddBlockHeader_GetSigners(t *testing.T) { } } -func TestMsgAddBlockHeader_Type(t *testing.T) { - msg := types.MsgAddBlockHeader{ +func TestMsgVoteBlockHeader_Type(t *testing.T) { + msg := types.MsgVoteBlockHeader{ Creator: sample.AccAddress(), } - require.Equal(t, types.TypeMsgAddBlockHeader, msg.Type()) + require.Equal(t, types.TypeMsgVoteBlockHeader, msg.Type()) } -func TestMsgAddBlockHeader_Route(t *testing.T) { - msg := types.MsgAddBlockHeader{ +func TestMsgVoteBlockHeader_Route(t *testing.T) { + msg := types.MsgVoteBlockHeader{ Creator: sample.AccAddress(), } require.Equal(t, types.RouterKey, msg.Route()) } -func TestMsgAddBlockHeader_GetSignBytes(t *testing.T) { - msg := types.MsgAddBlockHeader{ +func TestMsgVoteBlockHeader_GetSignBytes(t *testing.T) { + msg := types.MsgVoteBlockHeader{ Creator: sample.AccAddress(), } require.NotPanics(t, func() { @@ -165,8 +165,8 @@ func TestMsgAddBlockHeader_GetSignBytes(t *testing.T) { }) } -func TestMsgAddBlockHeader_Digest(t *testing.T) { - msg := types.MsgAddBlockHeader{ +func TestMsgVoteBlockHeader_Digest(t *testing.T) { + msg := types.MsgVoteBlockHeader{ Creator: sample.AccAddress(), } diff --git a/x/observer/types/query.pb.go b/x/observer/types/query.pb.go index 4c2dc1375c..e27bba6c4e 100644 --- a/x/observer/types/query.pb.go +++ b/x/observer/types/query.pb.go @@ -15,7 +15,7 @@ import ( grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" chains "github.com/zeta-chain/zetacore/pkg/chains" - proofs "github.com/zeta-chain/zetacore/pkg/proofs" + _ "github.com/zeta-chain/zetacore/pkg/proofs" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -785,126 +785,6 @@ func (m *QueryTssHistoryResponse) GetPagination() *query.PageResponse { return nil } -type QueryProveRequest struct { - ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - TxHash string `protobuf:"bytes,2,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` - Proof *proofs.Proof `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` - BlockHash string `protobuf:"bytes,4,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` - TxIndex int64 `protobuf:"varint,5,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` -} - -func (m *QueryProveRequest) Reset() { *m = QueryProveRequest{} } -func (m *QueryProveRequest) String() string { return proto.CompactTextString(m) } -func (*QueryProveRequest) ProtoMessage() {} -func (*QueryProveRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{16} -} -func (m *QueryProveRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryProveRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryProveRequest.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 *QueryProveRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryProveRequest.Merge(m, src) -} -func (m *QueryProveRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryProveRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryProveRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryProveRequest proto.InternalMessageInfo - -func (m *QueryProveRequest) GetChainId() int64 { - if m != nil { - return m.ChainId - } - return 0 -} - -func (m *QueryProveRequest) GetTxHash() string { - if m != nil { - return m.TxHash - } - return "" -} - -func (m *QueryProveRequest) GetProof() *proofs.Proof { - if m != nil { - return m.Proof - } - return nil -} - -func (m *QueryProveRequest) GetBlockHash() string { - if m != nil { - return m.BlockHash - } - return "" -} - -func (m *QueryProveRequest) GetTxIndex() int64 { - if m != nil { - return m.TxIndex - } - return 0 -} - -type QueryProveResponse struct { - Valid bool `protobuf:"varint,1,opt,name=valid,proto3" json:"valid,omitempty"` -} - -func (m *QueryProveResponse) Reset() { *m = QueryProveResponse{} } -func (m *QueryProveResponse) String() string { return proto.CompactTextString(m) } -func (*QueryProveResponse) ProtoMessage() {} -func (*QueryProveResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{17} -} -func (m *QueryProveResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryProveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryProveResponse.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 *QueryProveResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryProveResponse.Merge(m, src) -} -func (m *QueryProveResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryProveResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryProveResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryProveResponse proto.InternalMessageInfo - -func (m *QueryProveResponse) GetValid() bool { - if m != nil { - return m.Valid - } - return false -} - type QueryParamsRequest struct { } @@ -912,7 +792,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{18} + return fileDescriptor_dcb801e455adaee4, []int{16} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -951,7 +831,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{19} + return fileDescriptor_dcb801e455adaee4, []int{17} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -996,7 +876,7 @@ func (m *QueryHasVotedRequest) Reset() { *m = QueryHasVotedRequest{} } func (m *QueryHasVotedRequest) String() string { return proto.CompactTextString(m) } func (*QueryHasVotedRequest) ProtoMessage() {} func (*QueryHasVotedRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{20} + return fileDescriptor_dcb801e455adaee4, []int{18} } func (m *QueryHasVotedRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1047,7 +927,7 @@ func (m *QueryHasVotedResponse) Reset() { *m = QueryHasVotedResponse{} } func (m *QueryHasVotedResponse) String() string { return proto.CompactTextString(m) } func (*QueryHasVotedResponse) ProtoMessage() {} func (*QueryHasVotedResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{21} + return fileDescriptor_dcb801e455adaee4, []int{19} } func (m *QueryHasVotedResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1091,7 +971,7 @@ func (m *QueryBallotByIdentifierRequest) Reset() { *m = QueryBallotByIde func (m *QueryBallotByIdentifierRequest) String() string { return proto.CompactTextString(m) } func (*QueryBallotByIdentifierRequest) ProtoMessage() {} func (*QueryBallotByIdentifierRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{22} + return fileDescriptor_dcb801e455adaee4, []int{20} } func (m *QueryBallotByIdentifierRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1136,7 +1016,7 @@ func (m *VoterList) Reset() { *m = VoterList{} } func (m *VoterList) String() string { return proto.CompactTextString(m) } func (*VoterList) ProtoMessage() {} func (*VoterList) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{23} + return fileDescriptor_dcb801e455adaee4, []int{21} } func (m *VoterList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1190,7 +1070,7 @@ func (m *QueryBallotByIdentifierResponse) Reset() { *m = QueryBallotById func (m *QueryBallotByIdentifierResponse) String() string { return proto.CompactTextString(m) } func (*QueryBallotByIdentifierResponse) ProtoMessage() {} func (*QueryBallotByIdentifierResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{24} + return fileDescriptor_dcb801e455adaee4, []int{22} } func (m *QueryBallotByIdentifierResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1254,7 +1134,7 @@ func (m *QueryObserverSet) Reset() { *m = QueryObserverSet{} } func (m *QueryObserverSet) String() string { return proto.CompactTextString(m) } func (*QueryObserverSet) ProtoMessage() {} func (*QueryObserverSet) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{25} + return fileDescriptor_dcb801e455adaee4, []int{23} } func (m *QueryObserverSet) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1291,7 +1171,7 @@ func (m *QueryObserverSetResponse) Reset() { *m = QueryObserverSetRespon func (m *QueryObserverSetResponse) String() string { return proto.CompactTextString(m) } func (*QueryObserverSetResponse) ProtoMessage() {} func (*QueryObserverSetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{26} + return fileDescriptor_dcb801e455adaee4, []int{24} } func (m *QueryObserverSetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1334,7 +1214,7 @@ func (m *QuerySupportedChains) Reset() { *m = QuerySupportedChains{} } func (m *QuerySupportedChains) String() string { return proto.CompactTextString(m) } func (*QuerySupportedChains) ProtoMessage() {} func (*QuerySupportedChains) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{27} + return fileDescriptor_dcb801e455adaee4, []int{25} } func (m *QuerySupportedChains) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1371,7 +1251,7 @@ func (m *QuerySupportedChainsResponse) Reset() { *m = QuerySupportedChai func (m *QuerySupportedChainsResponse) String() string { return proto.CompactTextString(m) } func (*QuerySupportedChainsResponse) ProtoMessage() {} func (*QuerySupportedChainsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{28} + return fileDescriptor_dcb801e455adaee4, []int{26} } func (m *QuerySupportedChainsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1415,7 +1295,7 @@ func (m *QueryGetChainParamsForChainRequest) Reset() { *m = QueryGetChai func (m *QueryGetChainParamsForChainRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetChainParamsForChainRequest) ProtoMessage() {} func (*QueryGetChainParamsForChainRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{29} + return fileDescriptor_dcb801e455adaee4, []int{27} } func (m *QueryGetChainParamsForChainRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1459,7 +1339,7 @@ func (m *QueryGetChainParamsForChainResponse) Reset() { *m = QueryGetCha func (m *QueryGetChainParamsForChainResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetChainParamsForChainResponse) ProtoMessage() {} func (*QueryGetChainParamsForChainResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{30} + return fileDescriptor_dcb801e455adaee4, []int{28} } func (m *QueryGetChainParamsForChainResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1502,7 +1382,7 @@ func (m *QueryGetChainParamsRequest) Reset() { *m = QueryGetChainParamsR func (m *QueryGetChainParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetChainParamsRequest) ProtoMessage() {} func (*QueryGetChainParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{31} + return fileDescriptor_dcb801e455adaee4, []int{29} } func (m *QueryGetChainParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1539,7 +1419,7 @@ func (m *QueryGetChainParamsResponse) Reset() { *m = QueryGetChainParams func (m *QueryGetChainParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetChainParamsResponse) ProtoMessage() {} func (*QueryGetChainParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{32} + return fileDescriptor_dcb801e455adaee4, []int{30} } func (m *QueryGetChainParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1583,7 +1463,7 @@ func (m *QueryGetNodeAccountRequest) Reset() { *m = QueryGetNodeAccountR func (m *QueryGetNodeAccountRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetNodeAccountRequest) ProtoMessage() {} func (*QueryGetNodeAccountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{33} + return fileDescriptor_dcb801e455adaee4, []int{31} } func (m *QueryGetNodeAccountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1627,7 +1507,7 @@ func (m *QueryGetNodeAccountResponse) Reset() { *m = QueryGetNodeAccount func (m *QueryGetNodeAccountResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetNodeAccountResponse) ProtoMessage() {} func (*QueryGetNodeAccountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{34} + return fileDescriptor_dcb801e455adaee4, []int{32} } func (m *QueryGetNodeAccountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1671,7 +1551,7 @@ func (m *QueryAllNodeAccountRequest) Reset() { *m = QueryAllNodeAccountR func (m *QueryAllNodeAccountRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllNodeAccountRequest) ProtoMessage() {} func (*QueryAllNodeAccountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{35} + return fileDescriptor_dcb801e455adaee4, []int{33} } func (m *QueryAllNodeAccountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1716,7 +1596,7 @@ func (m *QueryAllNodeAccountResponse) Reset() { *m = QueryAllNodeAccount func (m *QueryAllNodeAccountResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllNodeAccountResponse) ProtoMessage() {} func (*QueryAllNodeAccountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{36} + return fileDescriptor_dcb801e455adaee4, []int{34} } func (m *QueryAllNodeAccountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1766,7 +1646,7 @@ func (m *QueryGetCrosschainFlagsRequest) Reset() { *m = QueryGetCrosscha func (m *QueryGetCrosschainFlagsRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetCrosschainFlagsRequest) ProtoMessage() {} func (*QueryGetCrosschainFlagsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{37} + return fileDescriptor_dcb801e455adaee4, []int{35} } func (m *QueryGetCrosschainFlagsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1803,7 +1683,7 @@ func (m *QueryGetCrosschainFlagsResponse) Reset() { *m = QueryGetCrossch func (m *QueryGetCrosschainFlagsResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetCrosschainFlagsResponse) ProtoMessage() {} func (*QueryGetCrosschainFlagsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{38} + return fileDescriptor_dcb801e455adaee4, []int{36} } func (m *QueryGetCrosschainFlagsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1846,7 +1726,7 @@ func (m *QueryGetKeygenRequest) Reset() { *m = QueryGetKeygenRequest{} } func (m *QueryGetKeygenRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetKeygenRequest) ProtoMessage() {} func (*QueryGetKeygenRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{39} + return fileDescriptor_dcb801e455adaee4, []int{37} } func (m *QueryGetKeygenRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1883,7 +1763,7 @@ func (m *QueryGetKeygenResponse) Reset() { *m = QueryGetKeygenResponse{} func (m *QueryGetKeygenResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetKeygenResponse) ProtoMessage() {} func (*QueryGetKeygenResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{40} + return fileDescriptor_dcb801e455adaee4, []int{38} } func (m *QueryGetKeygenResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1926,7 +1806,7 @@ func (m *QueryShowObserverCountRequest) Reset() { *m = QueryShowObserver func (m *QueryShowObserverCountRequest) String() string { return proto.CompactTextString(m) } func (*QueryShowObserverCountRequest) ProtoMessage() {} func (*QueryShowObserverCountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{41} + return fileDescriptor_dcb801e455adaee4, []int{39} } func (m *QueryShowObserverCountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1963,7 +1843,7 @@ func (m *QueryShowObserverCountResponse) Reset() { *m = QueryShowObserve func (m *QueryShowObserverCountResponse) String() string { return proto.CompactTextString(m) } func (*QueryShowObserverCountResponse) ProtoMessage() {} func (*QueryShowObserverCountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{42} + return fileDescriptor_dcb801e455adaee4, []int{40} } func (m *QueryShowObserverCountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2007,7 +1887,7 @@ func (m *QueryBlameByIdentifierRequest) Reset() { *m = QueryBlameByIdent func (m *QueryBlameByIdentifierRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlameByIdentifierRequest) ProtoMessage() {} func (*QueryBlameByIdentifierRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{43} + return fileDescriptor_dcb801e455adaee4, []int{41} } func (m *QueryBlameByIdentifierRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2051,7 +1931,7 @@ func (m *QueryBlameByIdentifierResponse) Reset() { *m = QueryBlameByIden func (m *QueryBlameByIdentifierResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlameByIdentifierResponse) ProtoMessage() {} func (*QueryBlameByIdentifierResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{44} + return fileDescriptor_dcb801e455adaee4, []int{42} } func (m *QueryBlameByIdentifierResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2095,7 +1975,7 @@ func (m *QueryAllBlameRecordsRequest) Reset() { *m = QueryAllBlameRecord func (m *QueryAllBlameRecordsRequest) String() string { return proto.CompactTextString(m) } func (*QueryAllBlameRecordsRequest) ProtoMessage() {} func (*QueryAllBlameRecordsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{45} + return fileDescriptor_dcb801e455adaee4, []int{43} } func (m *QueryAllBlameRecordsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2140,7 +2020,7 @@ func (m *QueryAllBlameRecordsResponse) Reset() { *m = QueryAllBlameRecor func (m *QueryAllBlameRecordsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAllBlameRecordsResponse) ProtoMessage() {} func (*QueryAllBlameRecordsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{46} + return fileDescriptor_dcb801e455adaee4, []int{44} } func (m *QueryAllBlameRecordsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2192,7 +2072,7 @@ func (m *QueryBlameByChainAndNonceRequest) Reset() { *m = QueryBlameByCh func (m *QueryBlameByChainAndNonceRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlameByChainAndNonceRequest) ProtoMessage() {} func (*QueryBlameByChainAndNonceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{47} + return fileDescriptor_dcb801e455adaee4, []int{45} } func (m *QueryBlameByChainAndNonceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2243,7 +2123,7 @@ func (m *QueryBlameByChainAndNonceResponse) Reset() { *m = QueryBlameByC func (m *QueryBlameByChainAndNonceResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlameByChainAndNonceResponse) ProtoMessage() {} func (*QueryBlameByChainAndNonceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{48} + return fileDescriptor_dcb801e455adaee4, []int{46} } func (m *QueryBlameByChainAndNonceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2279,506 +2159,204 @@ func (m *QueryBlameByChainAndNonceResponse) GetBlameInfo() []*Blame { return nil } -type QueryAllBlockHeaderRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryAllBlockHeaderRequest) Reset() { *m = QueryAllBlockHeaderRequest{} } -func (m *QueryAllBlockHeaderRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAllBlockHeaderRequest) ProtoMessage() {} -func (*QueryAllBlockHeaderRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{49} -} -func (m *QueryAllBlockHeaderRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAllBlockHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAllBlockHeaderRequest.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 *QueryAllBlockHeaderRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllBlockHeaderRequest.Merge(m, src) -} -func (m *QueryAllBlockHeaderRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAllBlockHeaderRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllBlockHeaderRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAllBlockHeaderRequest proto.InternalMessageInfo - -func (m *QueryAllBlockHeaderRequest) GetPagination() *query.PageRequest { - if m != nil { - return m.Pagination - } - return nil -} - -type QueryAllBlockHeaderResponse struct { - BlockHeaders []*proofs.BlockHeader `protobuf:"bytes,1,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QueryAllBlockHeaderResponse) Reset() { *m = QueryAllBlockHeaderResponse{} } -func (m *QueryAllBlockHeaderResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAllBlockHeaderResponse) ProtoMessage() {} -func (*QueryAllBlockHeaderResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{50} -} -func (m *QueryAllBlockHeaderResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAllBlockHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAllBlockHeaderResponse.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 *QueryAllBlockHeaderResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAllBlockHeaderResponse.Merge(m, src) -} -func (m *QueryAllBlockHeaderResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAllBlockHeaderResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAllBlockHeaderResponse.DiscardUnknown(m) +func init() { + proto.RegisterType((*QueryGetChainNoncesRequest)(nil), "zetachain.zetacore.observer.QueryGetChainNoncesRequest") + proto.RegisterType((*QueryGetChainNoncesResponse)(nil), "zetachain.zetacore.observer.QueryGetChainNoncesResponse") + proto.RegisterType((*QueryAllChainNoncesRequest)(nil), "zetachain.zetacore.observer.QueryAllChainNoncesRequest") + proto.RegisterType((*QueryAllChainNoncesResponse)(nil), "zetachain.zetacore.observer.QueryAllChainNoncesResponse") + proto.RegisterType((*QueryAllPendingNoncesRequest)(nil), "zetachain.zetacore.observer.QueryAllPendingNoncesRequest") + proto.RegisterType((*QueryAllPendingNoncesResponse)(nil), "zetachain.zetacore.observer.QueryAllPendingNoncesResponse") + proto.RegisterType((*QueryPendingNoncesByChainRequest)(nil), "zetachain.zetacore.observer.QueryPendingNoncesByChainRequest") + proto.RegisterType((*QueryPendingNoncesByChainResponse)(nil), "zetachain.zetacore.observer.QueryPendingNoncesByChainResponse") + proto.RegisterType((*QueryGetTSSRequest)(nil), "zetachain.zetacore.observer.QueryGetTSSRequest") + proto.RegisterType((*QueryGetTSSResponse)(nil), "zetachain.zetacore.observer.QueryGetTSSResponse") + proto.RegisterType((*QueryGetTssAddressRequest)(nil), "zetachain.zetacore.observer.QueryGetTssAddressRequest") + proto.RegisterType((*QueryGetTssAddressResponse)(nil), "zetachain.zetacore.observer.QueryGetTssAddressResponse") + proto.RegisterType((*QueryGetTssAddressByFinalizedHeightRequest)(nil), "zetachain.zetacore.observer.QueryGetTssAddressByFinalizedHeightRequest") + proto.RegisterType((*QueryGetTssAddressByFinalizedHeightResponse)(nil), "zetachain.zetacore.observer.QueryGetTssAddressByFinalizedHeightResponse") + proto.RegisterType((*QueryTssHistoryRequest)(nil), "zetachain.zetacore.observer.QueryTssHistoryRequest") + proto.RegisterType((*QueryTssHistoryResponse)(nil), "zetachain.zetacore.observer.QueryTssHistoryResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "zetachain.zetacore.observer.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "zetachain.zetacore.observer.QueryParamsResponse") + proto.RegisterType((*QueryHasVotedRequest)(nil), "zetachain.zetacore.observer.QueryHasVotedRequest") + proto.RegisterType((*QueryHasVotedResponse)(nil), "zetachain.zetacore.observer.QueryHasVotedResponse") + proto.RegisterType((*QueryBallotByIdentifierRequest)(nil), "zetachain.zetacore.observer.QueryBallotByIdentifierRequest") + proto.RegisterType((*VoterList)(nil), "zetachain.zetacore.observer.VoterList") + proto.RegisterType((*QueryBallotByIdentifierResponse)(nil), "zetachain.zetacore.observer.QueryBallotByIdentifierResponse") + proto.RegisterType((*QueryObserverSet)(nil), "zetachain.zetacore.observer.QueryObserverSet") + proto.RegisterType((*QueryObserverSetResponse)(nil), "zetachain.zetacore.observer.QueryObserverSetResponse") + proto.RegisterType((*QuerySupportedChains)(nil), "zetachain.zetacore.observer.QuerySupportedChains") + proto.RegisterType((*QuerySupportedChainsResponse)(nil), "zetachain.zetacore.observer.QuerySupportedChainsResponse") + proto.RegisterType((*QueryGetChainParamsForChainRequest)(nil), "zetachain.zetacore.observer.QueryGetChainParamsForChainRequest") + proto.RegisterType((*QueryGetChainParamsForChainResponse)(nil), "zetachain.zetacore.observer.QueryGetChainParamsForChainResponse") + proto.RegisterType((*QueryGetChainParamsRequest)(nil), "zetachain.zetacore.observer.QueryGetChainParamsRequest") + proto.RegisterType((*QueryGetChainParamsResponse)(nil), "zetachain.zetacore.observer.QueryGetChainParamsResponse") + proto.RegisterType((*QueryGetNodeAccountRequest)(nil), "zetachain.zetacore.observer.QueryGetNodeAccountRequest") + proto.RegisterType((*QueryGetNodeAccountResponse)(nil), "zetachain.zetacore.observer.QueryGetNodeAccountResponse") + proto.RegisterType((*QueryAllNodeAccountRequest)(nil), "zetachain.zetacore.observer.QueryAllNodeAccountRequest") + proto.RegisterType((*QueryAllNodeAccountResponse)(nil), "zetachain.zetacore.observer.QueryAllNodeAccountResponse") + proto.RegisterType((*QueryGetCrosschainFlagsRequest)(nil), "zetachain.zetacore.observer.QueryGetCrosschainFlagsRequest") + proto.RegisterType((*QueryGetCrosschainFlagsResponse)(nil), "zetachain.zetacore.observer.QueryGetCrosschainFlagsResponse") + proto.RegisterType((*QueryGetKeygenRequest)(nil), "zetachain.zetacore.observer.QueryGetKeygenRequest") + proto.RegisterType((*QueryGetKeygenResponse)(nil), "zetachain.zetacore.observer.QueryGetKeygenResponse") + proto.RegisterType((*QueryShowObserverCountRequest)(nil), "zetachain.zetacore.observer.QueryShowObserverCountRequest") + proto.RegisterType((*QueryShowObserverCountResponse)(nil), "zetachain.zetacore.observer.QueryShowObserverCountResponse") + proto.RegisterType((*QueryBlameByIdentifierRequest)(nil), "zetachain.zetacore.observer.QueryBlameByIdentifierRequest") + proto.RegisterType((*QueryBlameByIdentifierResponse)(nil), "zetachain.zetacore.observer.QueryBlameByIdentifierResponse") + proto.RegisterType((*QueryAllBlameRecordsRequest)(nil), "zetachain.zetacore.observer.QueryAllBlameRecordsRequest") + proto.RegisterType((*QueryAllBlameRecordsResponse)(nil), "zetachain.zetacore.observer.QueryAllBlameRecordsResponse") + proto.RegisterType((*QueryBlameByChainAndNonceRequest)(nil), "zetachain.zetacore.observer.QueryBlameByChainAndNonceRequest") + proto.RegisterType((*QueryBlameByChainAndNonceResponse)(nil), "zetachain.zetacore.observer.QueryBlameByChainAndNonceResponse") } -var xxx_messageInfo_QueryAllBlockHeaderResponse proto.InternalMessageInfo +func init() { proto.RegisterFile("observer/query.proto", fileDescriptor_dcb801e455adaee4) } -func (m *QueryAllBlockHeaderResponse) GetBlockHeaders() []*proofs.BlockHeader { - if m != nil { - return m.BlockHeaders - } - return nil +var fileDescriptor_dcb801e455adaee4 = []byte{ + // 2157 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x5a, 0xcd, 0x6f, 0x1b, 0xc7, + 0x15, 0xf7, 0x4a, 0x89, 0x22, 0x8d, 0xac, 0x0f, 0x8f, 0xe5, 0x8f, 0x50, 0x36, 0x25, 0x8f, 0xe2, + 0x58, 0x56, 0x6c, 0x6e, 0x2c, 0x27, 0xf5, 0x57, 0x1c, 0x5b, 0x74, 0x6d, 0xc9, 0x4e, 0x6a, 0x3b, + 0xa4, 0xda, 0x14, 0x46, 0x5b, 0x76, 0x49, 0x0e, 0xc9, 0x6d, 0xa8, 0x1d, 0x66, 0x67, 0xa4, 0x84, + 0x51, 0x05, 0x14, 0x3d, 0xe6, 0x14, 0xb4, 0x40, 0x7b, 0x2b, 0x7a, 0xe9, 0xb1, 0x40, 0x11, 0xa0, + 0x68, 0x81, 0xa2, 0x87, 0x9c, 0x9a, 0x43, 0x0f, 0x29, 0x0a, 0x14, 0x3d, 0xb5, 0x81, 0xdd, 0x3f, + 0xa4, 0xd8, 0x99, 0xb7, 0x9f, 0x5c, 0x2e, 0x87, 0xb2, 0x72, 0xd2, 0xee, 0x9b, 0x79, 0x6f, 0x7e, + 0xbf, 0xb7, 0x6f, 0x66, 0x7e, 0xc3, 0x11, 0x9a, 0x63, 0x55, 0x4e, 0xdd, 0x1d, 0xea, 0x9a, 0x1f, + 0x6e, 0x53, 0xb7, 0x5b, 0xe8, 0xb8, 0x4c, 0x30, 0x3c, 0xff, 0x09, 0x15, 0x56, 0xad, 0x65, 0xd9, + 0x4e, 0x41, 0x3e, 0x31, 0x97, 0x16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 0x00, } -func (m *QueryAllBlockHeaderResponse) GetPagination() *query.PageResponse { - if m != nil { - return m.Pagination - } - return nil -} +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn -type QueryGetBlockHeaderByHashRequest struct { - BlockHash []byte `protobuf:"bytes,1,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` -} - -func (m *QueryGetBlockHeaderByHashRequest) Reset() { *m = QueryGetBlockHeaderByHashRequest{} } -func (m *QueryGetBlockHeaderByHashRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetBlockHeaderByHashRequest) ProtoMessage() {} -func (*QueryGetBlockHeaderByHashRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{51} -} -func (m *QueryGetBlockHeaderByHashRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetBlockHeaderByHashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetBlockHeaderByHashRequest.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 *QueryGetBlockHeaderByHashRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetBlockHeaderByHashRequest.Merge(m, src) -} -func (m *QueryGetBlockHeaderByHashRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryGetBlockHeaderByHashRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetBlockHeaderByHashRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetBlockHeaderByHashRequest proto.InternalMessageInfo - -func (m *QueryGetBlockHeaderByHashRequest) GetBlockHash() []byte { - if m != nil { - return m.BlockHash - } - return nil -} - -type QueryGetBlockHeaderByHashResponse struct { - BlockHeader *proofs.BlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"` -} - -func (m *QueryGetBlockHeaderByHashResponse) Reset() { *m = QueryGetBlockHeaderByHashResponse{} } -func (m *QueryGetBlockHeaderByHashResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetBlockHeaderByHashResponse) ProtoMessage() {} -func (*QueryGetBlockHeaderByHashResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{52} -} -func (m *QueryGetBlockHeaderByHashResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetBlockHeaderByHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetBlockHeaderByHashResponse.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 *QueryGetBlockHeaderByHashResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetBlockHeaderByHashResponse.Merge(m, src) -} -func (m *QueryGetBlockHeaderByHashResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryGetBlockHeaderByHashResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetBlockHeaderByHashResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetBlockHeaderByHashResponse proto.InternalMessageInfo - -func (m *QueryGetBlockHeaderByHashResponse) GetBlockHeader() *proofs.BlockHeader { - if m != nil { - return m.BlockHeader - } - return nil -} - -type QueryGetBlockHeaderStateRequest struct { - ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` -} - -func (m *QueryGetBlockHeaderStateRequest) Reset() { *m = QueryGetBlockHeaderStateRequest{} } -func (m *QueryGetBlockHeaderStateRequest) String() string { return proto.CompactTextString(m) } -func (*QueryGetBlockHeaderStateRequest) ProtoMessage() {} -func (*QueryGetBlockHeaderStateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{53} -} -func (m *QueryGetBlockHeaderStateRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetBlockHeaderStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetBlockHeaderStateRequest.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 *QueryGetBlockHeaderStateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetBlockHeaderStateRequest.Merge(m, src) -} -func (m *QueryGetBlockHeaderStateRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryGetBlockHeaderStateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetBlockHeaderStateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetBlockHeaderStateRequest proto.InternalMessageInfo - -func (m *QueryGetBlockHeaderStateRequest) GetChainId() int64 { - if m != nil { - return m.ChainId - } - return 0 -} - -type QueryGetBlockHeaderStateResponse struct { - BlockHeaderState *BlockHeaderState `protobuf:"bytes,1,opt,name=block_header_state,json=blockHeaderState,proto3" json:"block_header_state,omitempty"` -} - -func (m *QueryGetBlockHeaderStateResponse) Reset() { *m = QueryGetBlockHeaderStateResponse{} } -func (m *QueryGetBlockHeaderStateResponse) String() string { return proto.CompactTextString(m) } -func (*QueryGetBlockHeaderStateResponse) ProtoMessage() {} -func (*QueryGetBlockHeaderStateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dcb801e455adaee4, []int{54} -} -func (m *QueryGetBlockHeaderStateResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryGetBlockHeaderStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryGetBlockHeaderStateResponse.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 *QueryGetBlockHeaderStateResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryGetBlockHeaderStateResponse.Merge(m, src) -} -func (m *QueryGetBlockHeaderStateResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryGetBlockHeaderStateResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryGetBlockHeaderStateResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryGetBlockHeaderStateResponse proto.InternalMessageInfo - -func (m *QueryGetBlockHeaderStateResponse) GetBlockHeaderState() *BlockHeaderState { - if m != nil { - return m.BlockHeaderState - } - return nil -} - -func init() { - proto.RegisterType((*QueryGetChainNoncesRequest)(nil), "zetachain.zetacore.observer.QueryGetChainNoncesRequest") - proto.RegisterType((*QueryGetChainNoncesResponse)(nil), "zetachain.zetacore.observer.QueryGetChainNoncesResponse") - proto.RegisterType((*QueryAllChainNoncesRequest)(nil), "zetachain.zetacore.observer.QueryAllChainNoncesRequest") - proto.RegisterType((*QueryAllChainNoncesResponse)(nil), "zetachain.zetacore.observer.QueryAllChainNoncesResponse") - proto.RegisterType((*QueryAllPendingNoncesRequest)(nil), "zetachain.zetacore.observer.QueryAllPendingNoncesRequest") - proto.RegisterType((*QueryAllPendingNoncesResponse)(nil), "zetachain.zetacore.observer.QueryAllPendingNoncesResponse") - proto.RegisterType((*QueryPendingNoncesByChainRequest)(nil), "zetachain.zetacore.observer.QueryPendingNoncesByChainRequest") - proto.RegisterType((*QueryPendingNoncesByChainResponse)(nil), "zetachain.zetacore.observer.QueryPendingNoncesByChainResponse") - proto.RegisterType((*QueryGetTSSRequest)(nil), "zetachain.zetacore.observer.QueryGetTSSRequest") - proto.RegisterType((*QueryGetTSSResponse)(nil), "zetachain.zetacore.observer.QueryGetTSSResponse") - proto.RegisterType((*QueryGetTssAddressRequest)(nil), "zetachain.zetacore.observer.QueryGetTssAddressRequest") - proto.RegisterType((*QueryGetTssAddressResponse)(nil), "zetachain.zetacore.observer.QueryGetTssAddressResponse") - proto.RegisterType((*QueryGetTssAddressByFinalizedHeightRequest)(nil), "zetachain.zetacore.observer.QueryGetTssAddressByFinalizedHeightRequest") - proto.RegisterType((*QueryGetTssAddressByFinalizedHeightResponse)(nil), "zetachain.zetacore.observer.QueryGetTssAddressByFinalizedHeightResponse") - proto.RegisterType((*QueryTssHistoryRequest)(nil), "zetachain.zetacore.observer.QueryTssHistoryRequest") - proto.RegisterType((*QueryTssHistoryResponse)(nil), "zetachain.zetacore.observer.QueryTssHistoryResponse") - proto.RegisterType((*QueryProveRequest)(nil), "zetachain.zetacore.observer.QueryProveRequest") - proto.RegisterType((*QueryProveResponse)(nil), "zetachain.zetacore.observer.QueryProveResponse") - proto.RegisterType((*QueryParamsRequest)(nil), "zetachain.zetacore.observer.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "zetachain.zetacore.observer.QueryParamsResponse") - proto.RegisterType((*QueryHasVotedRequest)(nil), "zetachain.zetacore.observer.QueryHasVotedRequest") - proto.RegisterType((*QueryHasVotedResponse)(nil), "zetachain.zetacore.observer.QueryHasVotedResponse") - proto.RegisterType((*QueryBallotByIdentifierRequest)(nil), "zetachain.zetacore.observer.QueryBallotByIdentifierRequest") - proto.RegisterType((*VoterList)(nil), "zetachain.zetacore.observer.VoterList") - proto.RegisterType((*QueryBallotByIdentifierResponse)(nil), "zetachain.zetacore.observer.QueryBallotByIdentifierResponse") - proto.RegisterType((*QueryObserverSet)(nil), "zetachain.zetacore.observer.QueryObserverSet") - proto.RegisterType((*QueryObserverSetResponse)(nil), "zetachain.zetacore.observer.QueryObserverSetResponse") - proto.RegisterType((*QuerySupportedChains)(nil), "zetachain.zetacore.observer.QuerySupportedChains") - proto.RegisterType((*QuerySupportedChainsResponse)(nil), "zetachain.zetacore.observer.QuerySupportedChainsResponse") - proto.RegisterType((*QueryGetChainParamsForChainRequest)(nil), "zetachain.zetacore.observer.QueryGetChainParamsForChainRequest") - proto.RegisterType((*QueryGetChainParamsForChainResponse)(nil), "zetachain.zetacore.observer.QueryGetChainParamsForChainResponse") - proto.RegisterType((*QueryGetChainParamsRequest)(nil), "zetachain.zetacore.observer.QueryGetChainParamsRequest") - proto.RegisterType((*QueryGetChainParamsResponse)(nil), "zetachain.zetacore.observer.QueryGetChainParamsResponse") - proto.RegisterType((*QueryGetNodeAccountRequest)(nil), "zetachain.zetacore.observer.QueryGetNodeAccountRequest") - proto.RegisterType((*QueryGetNodeAccountResponse)(nil), "zetachain.zetacore.observer.QueryGetNodeAccountResponse") - proto.RegisterType((*QueryAllNodeAccountRequest)(nil), "zetachain.zetacore.observer.QueryAllNodeAccountRequest") - proto.RegisterType((*QueryAllNodeAccountResponse)(nil), "zetachain.zetacore.observer.QueryAllNodeAccountResponse") - proto.RegisterType((*QueryGetCrosschainFlagsRequest)(nil), "zetachain.zetacore.observer.QueryGetCrosschainFlagsRequest") - proto.RegisterType((*QueryGetCrosschainFlagsResponse)(nil), "zetachain.zetacore.observer.QueryGetCrosschainFlagsResponse") - proto.RegisterType((*QueryGetKeygenRequest)(nil), "zetachain.zetacore.observer.QueryGetKeygenRequest") - proto.RegisterType((*QueryGetKeygenResponse)(nil), "zetachain.zetacore.observer.QueryGetKeygenResponse") - proto.RegisterType((*QueryShowObserverCountRequest)(nil), "zetachain.zetacore.observer.QueryShowObserverCountRequest") - proto.RegisterType((*QueryShowObserverCountResponse)(nil), "zetachain.zetacore.observer.QueryShowObserverCountResponse") - proto.RegisterType((*QueryBlameByIdentifierRequest)(nil), "zetachain.zetacore.observer.QueryBlameByIdentifierRequest") - proto.RegisterType((*QueryBlameByIdentifierResponse)(nil), "zetachain.zetacore.observer.QueryBlameByIdentifierResponse") - proto.RegisterType((*QueryAllBlameRecordsRequest)(nil), "zetachain.zetacore.observer.QueryAllBlameRecordsRequest") - proto.RegisterType((*QueryAllBlameRecordsResponse)(nil), "zetachain.zetacore.observer.QueryAllBlameRecordsResponse") - proto.RegisterType((*QueryBlameByChainAndNonceRequest)(nil), "zetachain.zetacore.observer.QueryBlameByChainAndNonceRequest") - proto.RegisterType((*QueryBlameByChainAndNonceResponse)(nil), "zetachain.zetacore.observer.QueryBlameByChainAndNonceResponse") - proto.RegisterType((*QueryAllBlockHeaderRequest)(nil), "zetachain.zetacore.observer.QueryAllBlockHeaderRequest") - proto.RegisterType((*QueryAllBlockHeaderResponse)(nil), "zetachain.zetacore.observer.QueryAllBlockHeaderResponse") - proto.RegisterType((*QueryGetBlockHeaderByHashRequest)(nil), "zetachain.zetacore.observer.QueryGetBlockHeaderByHashRequest") - proto.RegisterType((*QueryGetBlockHeaderByHashResponse)(nil), "zetachain.zetacore.observer.QueryGetBlockHeaderByHashResponse") - proto.RegisterType((*QueryGetBlockHeaderStateRequest)(nil), "zetachain.zetacore.observer.QueryGetBlockHeaderStateRequest") - proto.RegisterType((*QueryGetBlockHeaderStateResponse)(nil), "zetachain.zetacore.observer.QueryGetBlockHeaderStateResponse") -} - -func init() { proto.RegisterFile("observer/query.proto", fileDescriptor_dcb801e455adaee4) } - -var fileDescriptor_dcb801e455adaee4 = []byte{ - // 2504 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x5a, 0xcd, 0x6f, 0x1b, 0xc7, - 0x15, 0xf7, 0x5a, 0x91, 0x22, 0x3d, 0x7d, 0x58, 0x1e, 0xcb, 0x5f, 0x6b, 0x5b, 0x96, 0x57, 0x71, - 0x2c, 0x2b, 0x36, 0x19, 0xcb, 0x49, 0xfc, 0x1d, 0x5b, 0x74, 0x6d, 0xc9, 0x4e, 0x6a, 0x3b, 0xa4, - 0xdb, 0x14, 0x4e, 0x5b, 0x76, 0x49, 0x8e, 0xc8, 0xad, 0xa9, 0x5d, 0x66, 0x77, 0xa4, 0x88, 0x51, - 0x85, 0x16, 0x3d, 0x06, 0x3d, 0x04, 0x28, 0xd0, 0xde, 0x8a, 0x00, 0x45, 0x7b, 0x2b, 0x50, 0x04, - 0x28, 0x5a, 0xa0, 0xe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, 0x37, 0x60, 0x42, 0xa6, 0x8a, 0x41, 0x4d, 0x65, 0x3a, 0x2e, 0x31, 0x35, 0xae, - 0x47, 0xc7, 0xb8, 0x34, 0xc6, 0xaf, 0xd8, 0x14, 0x92, 0xcc, 0xf8, 0x61, 0x2a, 0x3b, 0xb4, 0x46, - 0x64, 0xef, 0x01, 0x91, 0x91, 0xf1, 0x62, 0x92, 0x22, 0xbe, 0xf3, 0x3d, 0xb2, 0x2a, 0xe1, 0x72, - 0xba, 0x92, 0x68, 0x59, 0xfa, 0xe5, 0x02, 0x0c, 0x73, 0x04, 0xe4, 0x63, 0x0d, 0x46, 0x44, 0xe1, - 0x41, 0xf2, 0x99, 0x5e, 0x3b, 0x25, 0x99, 0xfe, 0xaa, 0xba, 0x81, 0x20, 0x65, 0xcc, 0xff, 0xf8, - 0x6f, 0xff, 0xf9, 0xe9, 0xde, 0x13, 0xe4, 0x58, 0xde, 0x1f, 0x7f, 0x9e, 0x9b, 0xe6, 0x13, 0xff, - 0xc8, 0x25, 0x7f, 0xd2, 0x60, 0x34, 0x50, 0x48, 0xe4, 0x42, 0xef, 0x39, 0x12, 0xba, 0x4d, 0x5f, - 0xea, 0xc7, 0x04, 0x81, 0xdd, 0xe7, 0xc0, 0xbe, 0x46, 0x0a, 0xa9, 0xc0, 0x42, 0x6d, 0x96, 0xdf, - 0xee, 0x10, 0x28, 0x3b, 0xf9, 0xed, 0x98, 0x82, 0xda, 0x21, 0x7f, 0xd7, 0x80, 0x74, 0xaa, 0x1c, - 0x72, 0xad, 0x37, 0xac, 0xae, 0x0a, 0x4f, 0xbf, 0xbe, 0x3b, 0x63, 0x64, 0x77, 0x87, 0xb3, 0xbb, - 0x49, 0x6e, 0xa4, 0xb2, 0x43, 0x4a, 0x95, 0xb6, 0xc4, 0x2a, 0x8d, 0x28, 0xf9, 0x85, 0x06, 0xe3, - 0x92, 0xe2, 0x20, 0xe7, 0x7b, 0x83, 0x92, 0x86, 0xeb, 0xaf, 0xf7, 0x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xdd, 0xf3, 0xc5, 0xf3, 0xd9, 0x3d, 0xff, 0x78, 0x3e, 0xbb, - 0xe7, 0x49, 0xbe, 0x6e, 0xb1, 0xc6, 0x46, 0x25, 0x57, 0x75, 0xd6, 0x53, 0x0b, 0xfb, 0x2d, 0x69, - 0xef, 0xb4, 0x5b, 0xd4, 0xab, 0x8c, 0xf0, 0x0f, 0x27, 0x2f, 0xfe, 0x2f, 0x00, 0x00, 0xff, 0xff, - 0xcd, 0x82, 0xdb, 0xae, 0x1e, 0x2b, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 // QueryClient is the client API for Query service. // @@ -2812,11 +2390,6 @@ type QueryClient interface { GetAllBlameRecords(ctx context.Context, in *QueryAllBlameRecordsRequest, opts ...grpc.CallOption) (*QueryAllBlameRecordsResponse, error) // Queries a list of VoterByIdentifier items. BlamesByChainAndNonce(ctx context.Context, in *QueryBlameByChainAndNonceRequest, opts ...grpc.CallOption) (*QueryBlameByChainAndNonceResponse, error) - GetAllBlockHeaders(ctx context.Context, in *QueryAllBlockHeaderRequest, opts ...grpc.CallOption) (*QueryAllBlockHeaderResponse, error) - GetBlockHeaderByHash(ctx context.Context, in *QueryGetBlockHeaderByHashRequest, opts ...grpc.CallOption) (*QueryGetBlockHeaderByHashResponse, error) - GetBlockHeaderStateByChain(ctx context.Context, in *QueryGetBlockHeaderStateRequest, opts ...grpc.CallOption) (*QueryGetBlockHeaderStateResponse, error) - // merkle proof verification - Prove(ctx context.Context, in *QueryProveRequest, opts ...grpc.CallOption) (*QueryProveResponse, error) // Queries a list of GetTssAddress items. GetTssAddress(ctx context.Context, in *QueryGetTssAddressRequest, opts ...grpc.CallOption) (*QueryGetTssAddressResponse, error) GetTssAddressByFinalizedHeight(ctx context.Context, in *QueryGetTssAddressByFinalizedHeightRequest, opts ...grpc.CallOption) (*QueryGetTssAddressByFinalizedHeightResponse, error) @@ -2974,42 +2547,6 @@ func (c *queryClient) BlamesByChainAndNonce(ctx context.Context, in *QueryBlameB return out, nil } -func (c *queryClient) GetAllBlockHeaders(ctx context.Context, in *QueryAllBlockHeaderRequest, opts ...grpc.CallOption) (*QueryAllBlockHeaderResponse, error) { - out := new(QueryAllBlockHeaderResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Query/GetAllBlockHeaders", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetBlockHeaderByHash(ctx context.Context, in *QueryGetBlockHeaderByHashRequest, opts ...grpc.CallOption) (*QueryGetBlockHeaderByHashResponse, error) { - out := new(QueryGetBlockHeaderByHashResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Query/GetBlockHeaderByHash", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) GetBlockHeaderStateByChain(ctx context.Context, in *QueryGetBlockHeaderStateRequest, opts ...grpc.CallOption) (*QueryGetBlockHeaderStateResponse, error) { - out := new(QueryGetBlockHeaderStateResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Query/GetBlockHeaderStateByChain", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Prove(ctx context.Context, in *QueryProveRequest, opts ...grpc.CallOption) (*QueryProveResponse, error) { - out := new(QueryProveResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Query/Prove", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) GetTssAddress(ctx context.Context, in *QueryGetTssAddressRequest, opts ...grpc.CallOption) (*QueryGetTssAddressResponse, error) { out := new(QueryGetTssAddressResponse) err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Query/GetTssAddress", in, out, opts...) @@ -3112,11 +2649,6 @@ type QueryServer interface { GetAllBlameRecords(context.Context, *QueryAllBlameRecordsRequest) (*QueryAllBlameRecordsResponse, error) // Queries a list of VoterByIdentifier items. BlamesByChainAndNonce(context.Context, *QueryBlameByChainAndNonceRequest) (*QueryBlameByChainAndNonceResponse, error) - GetAllBlockHeaders(context.Context, *QueryAllBlockHeaderRequest) (*QueryAllBlockHeaderResponse, error) - GetBlockHeaderByHash(context.Context, *QueryGetBlockHeaderByHashRequest) (*QueryGetBlockHeaderByHashResponse, error) - GetBlockHeaderStateByChain(context.Context, *QueryGetBlockHeaderStateRequest) (*QueryGetBlockHeaderStateResponse, error) - // merkle proof verification - Prove(context.Context, *QueryProveRequest) (*QueryProveResponse, error) // Queries a list of GetTssAddress items. GetTssAddress(context.Context, *QueryGetTssAddressRequest) (*QueryGetTssAddressResponse, error) GetTssAddressByFinalizedHeight(context.Context, *QueryGetTssAddressByFinalizedHeightRequest) (*QueryGetTssAddressByFinalizedHeightResponse, error) @@ -3180,18 +2712,6 @@ func (*UnimplementedQueryServer) GetAllBlameRecords(ctx context.Context, req *Qu func (*UnimplementedQueryServer) BlamesByChainAndNonce(ctx context.Context, req *QueryBlameByChainAndNonceRequest) (*QueryBlameByChainAndNonceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method BlamesByChainAndNonce not implemented") } -func (*UnimplementedQueryServer) GetAllBlockHeaders(ctx context.Context, req *QueryAllBlockHeaderRequest) (*QueryAllBlockHeaderResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetAllBlockHeaders not implemented") -} -func (*UnimplementedQueryServer) GetBlockHeaderByHash(ctx context.Context, req *QueryGetBlockHeaderByHashRequest) (*QueryGetBlockHeaderByHashResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBlockHeaderByHash not implemented") -} -func (*UnimplementedQueryServer) GetBlockHeaderStateByChain(ctx context.Context, req *QueryGetBlockHeaderStateRequest) (*QueryGetBlockHeaderStateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBlockHeaderStateByChain not implemented") -} -func (*UnimplementedQueryServer) Prove(ctx context.Context, req *QueryProveRequest) (*QueryProveResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Prove not implemented") -} func (*UnimplementedQueryServer) GetTssAddress(ctx context.Context, req *QueryGetTssAddressRequest) (*QueryGetTssAddressResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetTssAddress not implemented") } @@ -3491,78 +3011,6 @@ func _Query_BlamesByChainAndNonce_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } -func _Query_GetAllBlockHeaders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAllBlockHeaderRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetAllBlockHeaders(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/zetachain.zetacore.observer.Query/GetAllBlockHeaders", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetAllBlockHeaders(ctx, req.(*QueryAllBlockHeaderRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetBlockHeaderByHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetBlockHeaderByHashRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetBlockHeaderByHash(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/zetachain.zetacore.observer.Query/GetBlockHeaderByHash", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetBlockHeaderByHash(ctx, req.(*QueryGetBlockHeaderByHashRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_GetBlockHeaderStateByChain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryGetBlockHeaderStateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).GetBlockHeaderStateByChain(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/zetachain.zetacore.observer.Query/GetBlockHeaderStateByChain", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetBlockHeaderStateByChain(ctx, req.(*QueryGetBlockHeaderStateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_Prove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryProveRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Prove(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/zetachain.zetacore.observer.Query/Prove", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Prove(ctx, req.(*QueryProveRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_GetTssAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryGetTssAddressRequest) if err := dec(in); err != nil { @@ -3771,22 +3219,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "BlamesByChainAndNonce", Handler: _Query_BlamesByChainAndNonce_Handler, }, - { - MethodName: "GetAllBlockHeaders", - Handler: _Query_GetAllBlockHeaders_Handler, - }, - { - MethodName: "GetBlockHeaderByHash", - Handler: _Query_GetBlockHeaderByHash_Handler, - }, - { - MethodName: "GetBlockHeaderStateByChain", - Handler: _Query_GetBlockHeaderStateByChain_Handler, - }, - { - MethodName: "Prove", - Handler: _Query_Prove_Handler, - }, { MethodName: "GetTssAddress", Handler: _Query_GetTssAddress_Handler, @@ -4391,7 +3823,7 @@ func (m *QueryTssHistoryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryProveRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4401,104 +3833,12 @@ func (m *QueryProveRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryProveRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryProveRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.TxIndex != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.TxIndex)) - i-- - dAtA[i] = 0x28 - } - if len(m.BlockHash) > 0 { - i -= len(m.BlockHash) - copy(dAtA[i:], m.BlockHash) - i = encodeVarintQuery(dAtA, i, uint64(len(m.BlockHash))) - i-- - dAtA[i] = 0x22 - } - if m.Proof != nil { - { - size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.TxHash) > 0 { - i -= len(m.TxHash) - copy(dAtA[i:], m.TxHash) - i = encodeVarintQuery(dAtA, i, uint64(len(m.TxHash))) - i-- - dAtA[i] = 0x12 - } - if m.ChainId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ChainId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryProveResponse) 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 *QueryProveResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryProveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Valid { - i-- - if m.Valid { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -5504,218 +4844,6 @@ func (m *QueryBlameByChainAndNonceResponse) MarshalToSizedBuffer(dAtA []byte) (i return len(dAtA) - i, nil } -func (m *QueryAllBlockHeaderRequest) 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 *QueryAllBlockHeaderRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAllBlockHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryAllBlockHeaderResponse) 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 *QueryAllBlockHeaderResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAllBlockHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.BlockHeaders) > 0 { - for iNdEx := len(m.BlockHeaders) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.BlockHeaders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QueryGetBlockHeaderByHashRequest) 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 *QueryGetBlockHeaderByHashRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGetBlockHeaderByHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BlockHash) > 0 { - i -= len(m.BlockHash) - copy(dAtA[i:], m.BlockHash) - i = encodeVarintQuery(dAtA, i, uint64(len(m.BlockHash))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryGetBlockHeaderByHashResponse) 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 *QueryGetBlockHeaderByHashResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGetBlockHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.BlockHeader != nil { - { - size, err := m.BlockHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryGetBlockHeaderStateRequest) 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 *QueryGetBlockHeaderStateRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGetBlockHeaderStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ChainId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ChainId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryGetBlockHeaderStateResponse) 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 *QueryGetBlockHeaderStateResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryGetBlockHeaderStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.BlockHeaderState != nil { - { - size, err := m.BlockHeaderState.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -5951,46 +5079,7 @@ func (m *QueryTssHistoryResponse) Size() (n int) { return n } -func (m *QueryProveRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ChainId != 0 { - n += 1 + sovQuery(uint64(m.ChainId)) - } - l = len(m.TxHash) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Proof != nil { - l = m.Proof.Size() - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.BlockHash) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.TxIndex != 0 { - n += 1 + sovQuery(uint64(m.TxIndex)) - } - return n -} - -func (m *QueryProveResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Valid { - n += 2 - } - return n -} - -func (m *QueryParamsRequest) Size() (n int) { +func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 } @@ -6398,89 +5487,6 @@ func (m *QueryBlameByChainAndNonceResponse) Size() (n int) { return n } -func (m *QueryAllBlockHeaderRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAllBlockHeaderResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BlockHeaders) > 0 { - for _, e := range m.BlockHeaders { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryGetBlockHeaderByHashRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.BlockHash) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryGetBlockHeaderByHashResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BlockHeader != nil { - l = m.BlockHeader.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryGetBlockHeaderStateRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ChainId != 0 { - n += 1 + sovQuery(uint64(m.ChainId)) - } - return n -} - -func (m *QueryGetBlockHeaderStateResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BlockHeaderState != nil { - l = m.BlockHeaderState.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -7940,7 +6946,7 @@ func (m *QueryTssHistoryResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryProveRequest) Unmarshal(dAtA []byte) error { +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7963,150 +6969,12 @@ func (m *QueryProveRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryProveRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProveRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ChainId |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TxHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TxHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Proof == nil { - m.Proof = &proofs.Proof{} - } - if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BlockHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TxIndex", wireType) - } - m.TxIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TxIndex |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -8128,7 +6996,7 @@ func (m *QueryProveRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryProveResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8151,17 +7019,17 @@ func (m *QueryProveResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryProveResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryProveResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Valid", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - var v int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -8171,12 +7039,25 @@ func (m *QueryProveResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - m.Valid = bool(v != 0) + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -8198,7 +7079,7 @@ func (m *QueryProveResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryHasVotedRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8221,143 +7102,10 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryHasVotedRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryParamsResponse) 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 ErrIntOverflowQuery - } - 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: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryHasVotedRequest) 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 ErrIntOverflowQuery - } - 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: QueryHasVotedRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryHasVotedRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryHasVotedRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -10734,537 +9482,6 @@ func (m *QueryBlameByChainAndNonceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllBlockHeaderRequest) 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 ErrIntOverflowQuery - } - 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: QueryAllBlockHeaderRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllBlockHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryAllBlockHeaderResponse) 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 ErrIntOverflowQuery - } - 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: QueryAllBlockHeaderResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllBlockHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaders", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BlockHeaders = append(m.BlockHeaders, &proofs.BlockHeader{}) - if err := m.BlockHeaders[len(m.BlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGetBlockHeaderByHashRequest) 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 ErrIntOverflowQuery - } - 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: QueryGetBlockHeaderByHashRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetBlockHeaderByHashRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BlockHash = append(m.BlockHash[:0], dAtA[iNdEx:postIndex]...) - if m.BlockHash == nil { - m.BlockHash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGetBlockHeaderByHashResponse) 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 ErrIntOverflowQuery - } - 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: QueryGetBlockHeaderByHashResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetBlockHeaderByHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.BlockHeader == nil { - m.BlockHeader = &proofs.BlockHeader{} - } - if err := m.BlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGetBlockHeaderStateRequest) 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 ErrIntOverflowQuery - } - 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: QueryGetBlockHeaderStateRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetBlockHeaderStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - 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 := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryGetBlockHeaderStateResponse) 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 ErrIntOverflowQuery - } - 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: QueryGetBlockHeaderStateResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetBlockHeaderStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaderState", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.BlockHeaderState == nil { - m.BlockHeaderState = &BlockHeaderState{} - } - if err := m.BlockHeaderState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/observer/types/query.pb.gw.go b/x/observer/types/query.pb.gw.go index 16460849d8..a99816daa0 100644 --- a/x/observer/types/query.pb.gw.go +++ b/x/observer/types/query.pb.gw.go @@ -599,186 +599,6 @@ func local_request_Query_BlamesByChainAndNonce_0(ctx context.Context, marshaler } -var ( - filter_Query_GetAllBlockHeaders_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_GetAllBlockHeaders_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllBlockHeaderRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetAllBlockHeaders_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.GetAllBlockHeaders(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetAllBlockHeaders_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAllBlockHeaderRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetAllBlockHeaders_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.GetAllBlockHeaders(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetBlockHeaderByHashRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["block_hash"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block_hash") - } - - protoReq.BlockHash, err = runtime.Bytes(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block_hash", err) - } - - msg, err := client.GetBlockHeaderByHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetBlockHeaderByHashRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["block_hash"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "block_hash") - } - - protoReq.BlockHash, err = runtime.Bytes(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "block_hash", err) - } - - msg, err := server.GetBlockHeaderByHash(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_GetBlockHeaderStateByChain_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetBlockHeaderStateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.Int64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - msg, err := client.GetBlockHeaderStateByChain(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_GetBlockHeaderStateByChain_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryGetBlockHeaderStateRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["chain_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "chain_id") - } - - protoReq.ChainId, err = runtime.Int64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) - } - - msg, err := server.GetBlockHeaderStateByChain(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_Prove_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Prove_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryProveRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Prove_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Prove(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Prove_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryProveRequest - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Prove_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Prove(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_GetTssAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryGetTssAddressRequest var metadata runtime.ServerMetadata @@ -1494,98 +1314,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_GetAllBlockHeaders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetAllBlockHeaders_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetAllBlockHeaders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetBlockHeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetBlockHeaderByHash_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetBlockHeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetBlockHeaderStateByChain_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_GetBlockHeaderStateByChain_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetBlockHeaderStateByChain_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Prove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_Prove_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Prove_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_GetTssAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -2111,86 +1839,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_GetAllBlockHeaders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_GetAllBlockHeaders_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetAllBlockHeaders_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetBlockHeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_GetBlockHeaderByHash_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetBlockHeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_GetBlockHeaderStateByChain_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_GetBlockHeaderStateByChain_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_GetBlockHeaderStateByChain_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Prove_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Prove_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_Prove_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_GetTssAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -2385,14 +2033,6 @@ var ( pattern_Query_BlamesByChainAndNonce_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"zeta-chain", "observer", "blame_by_chain_and_nonce", "chain_id", "nonce"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_GetAllBlockHeaders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "observer", "get_all_block_headers"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetBlockHeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "observer", "get_block_header_by_hash", "block_hash"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_GetBlockHeaderStateByChain_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "observer", "get_block_header_state_by_chain_id", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_Prove_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "observer", "prove"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_GetTssAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"zeta-chain", "observer", "get_tss_address", "bitcoin_chain_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_GetTssAddressByFinalizedHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"zeta-chain", "observer", "get_tss_address_historical", "finalized_zeta_height", "bitcoin_chain_id"}, "", runtime.AssumeColonVerbOpt(false))) @@ -2441,14 +2081,6 @@ var ( forward_Query_BlamesByChainAndNonce_0 = runtime.ForwardResponseMessage - forward_Query_GetAllBlockHeaders_0 = runtime.ForwardResponseMessage - - forward_Query_GetBlockHeaderByHash_0 = runtime.ForwardResponseMessage - - forward_Query_GetBlockHeaderStateByChain_0 = runtime.ForwardResponseMessage - - forward_Query_Prove_0 = runtime.ForwardResponseMessage - forward_Query_GetTssAddress_0 = runtime.ForwardResponseMessage forward_Query_GetTssAddressByFinalizedHeight_0 = runtime.ForwardResponseMessage diff --git a/x/observer/types/tx.pb.go b/x/observer/types/tx.pb.go index 3c423aba9c..87585e885d 100644 --- a/x/observer/types/tx.pb.go +++ b/x/observer/types/tx.pb.go @@ -135,7 +135,7 @@ func (m *MsgUpdateObserverResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateObserverResponse proto.InternalMessageInfo -type MsgAddBlockHeader struct { +type MsgVoteBlockHeader 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"` BlockHash []byte `protobuf:"bytes,3,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` @@ -143,18 +143,18 @@ type MsgAddBlockHeader struct { Header proofs.HeaderData `protobuf:"bytes,5,opt,name=header,proto3" json:"header"` } -func (m *MsgAddBlockHeader) Reset() { *m = MsgAddBlockHeader{} } -func (m *MsgAddBlockHeader) String() string { return proto.CompactTextString(m) } -func (*MsgAddBlockHeader) ProtoMessage() {} -func (*MsgAddBlockHeader) Descriptor() ([]byte, []int) { +func (m *MsgVoteBlockHeader) Reset() { *m = MsgVoteBlockHeader{} } +func (m *MsgVoteBlockHeader) String() string { return proto.CompactTextString(m) } +func (*MsgVoteBlockHeader) ProtoMessage() {} +func (*MsgVoteBlockHeader) Descriptor() ([]byte, []int) { return fileDescriptor_1bcd40fa296a2b1d, []int{2} } -func (m *MsgAddBlockHeader) XXX_Unmarshal(b []byte) error { +func (m *MsgVoteBlockHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddBlockHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgVoteBlockHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddBlockHeader.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgVoteBlockHeader.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -164,68 +164,70 @@ func (m *MsgAddBlockHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *MsgAddBlockHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddBlockHeader.Merge(m, src) +func (m *MsgVoteBlockHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteBlockHeader.Merge(m, src) } -func (m *MsgAddBlockHeader) XXX_Size() int { +func (m *MsgVoteBlockHeader) XXX_Size() int { return m.Size() } -func (m *MsgAddBlockHeader) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddBlockHeader.DiscardUnknown(m) +func (m *MsgVoteBlockHeader) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteBlockHeader.DiscardUnknown(m) } -var xxx_messageInfo_MsgAddBlockHeader proto.InternalMessageInfo +var xxx_messageInfo_MsgVoteBlockHeader proto.InternalMessageInfo -func (m *MsgAddBlockHeader) GetCreator() string { +func (m *MsgVoteBlockHeader) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgAddBlockHeader) GetChainId() int64 { +func (m *MsgVoteBlockHeader) GetChainId() int64 { if m != nil { return m.ChainId } return 0 } -func (m *MsgAddBlockHeader) GetBlockHash() []byte { +func (m *MsgVoteBlockHeader) GetBlockHash() []byte { if m != nil { return m.BlockHash } return nil } -func (m *MsgAddBlockHeader) GetHeight() int64 { +func (m *MsgVoteBlockHeader) GetHeight() int64 { if m != nil { return m.Height } return 0 } -func (m *MsgAddBlockHeader) GetHeader() proofs.HeaderData { +func (m *MsgVoteBlockHeader) GetHeader() proofs.HeaderData { if m != nil { return m.Header } return proofs.HeaderData{} } -type MsgAddBlockHeaderResponse struct { +type MsgVoteBlockHeaderResponse struct { + BallotCreated bool `protobuf:"varint,1,opt,name=ballot_created,json=ballotCreated,proto3" json:"ballot_created,omitempty"` + VoteFinalized bool `protobuf:"varint,2,opt,name=vote_finalized,json=voteFinalized,proto3" json:"vote_finalized,omitempty"` } -func (m *MsgAddBlockHeaderResponse) Reset() { *m = MsgAddBlockHeaderResponse{} } -func (m *MsgAddBlockHeaderResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAddBlockHeaderResponse) ProtoMessage() {} -func (*MsgAddBlockHeaderResponse) Descriptor() ([]byte, []int) { +func (m *MsgVoteBlockHeaderResponse) Reset() { *m = MsgVoteBlockHeaderResponse{} } +func (m *MsgVoteBlockHeaderResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVoteBlockHeaderResponse) ProtoMessage() {} +func (*MsgVoteBlockHeaderResponse) Descriptor() ([]byte, []int) { return fileDescriptor_1bcd40fa296a2b1d, []int{3} } -func (m *MsgAddBlockHeaderResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgVoteBlockHeaderResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgAddBlockHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgVoteBlockHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgAddBlockHeaderResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgVoteBlockHeaderResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -235,17 +237,31 @@ func (m *MsgAddBlockHeaderResponse) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *MsgAddBlockHeaderResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddBlockHeaderResponse.Merge(m, src) +func (m *MsgVoteBlockHeaderResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteBlockHeaderResponse.Merge(m, src) } -func (m *MsgAddBlockHeaderResponse) XXX_Size() int { +func (m *MsgVoteBlockHeaderResponse) XXX_Size() int { return m.Size() } -func (m *MsgAddBlockHeaderResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddBlockHeaderResponse.DiscardUnknown(m) +func (m *MsgVoteBlockHeaderResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteBlockHeaderResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVoteBlockHeaderResponse proto.InternalMessageInfo + +func (m *MsgVoteBlockHeaderResponse) GetBallotCreated() bool { + if m != nil { + return m.BallotCreated + } + return false } -var xxx_messageInfo_MsgAddBlockHeaderResponse proto.InternalMessageInfo +func (m *MsgVoteBlockHeaderResponse) GetVoteFinalized() bool { + if m != nil { + return m.VoteFinalized + } + return false +} type MsgUpdateChainParams struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` @@ -1058,8 +1074,8 @@ func (m *MsgVoteTSSResponse) GetKeygenSuccess() bool { func init() { proto.RegisterType((*MsgUpdateObserver)(nil), "zetachain.zetacore.observer.MsgUpdateObserver") proto.RegisterType((*MsgUpdateObserverResponse)(nil), "zetachain.zetacore.observer.MsgUpdateObserverResponse") - proto.RegisterType((*MsgAddBlockHeader)(nil), "zetachain.zetacore.observer.MsgAddBlockHeader") - proto.RegisterType((*MsgAddBlockHeaderResponse)(nil), "zetachain.zetacore.observer.MsgAddBlockHeaderResponse") + proto.RegisterType((*MsgVoteBlockHeader)(nil), "zetachain.zetacore.observer.MsgVoteBlockHeader") + proto.RegisterType((*MsgVoteBlockHeaderResponse)(nil), "zetachain.zetacore.observer.MsgVoteBlockHeaderResponse") proto.RegisterType((*MsgUpdateChainParams)(nil), "zetachain.zetacore.observer.MsgUpdateChainParams") proto.RegisterType((*MsgUpdateChainParamsResponse)(nil), "zetachain.zetacore.observer.MsgUpdateChainParamsResponse") proto.RegisterType((*MsgRemoveChainParams)(nil), "zetachain.zetacore.observer.MsgRemoveChainParams") @@ -1081,82 +1097,82 @@ func init() { func init() { proto.RegisterFile("observer/tx.proto", fileDescriptor_1bcd40fa296a2b1d) } var fileDescriptor_1bcd40fa296a2b1d = []byte{ - // 1186 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0xcd, 0x72, 0xe3, 0x44, - 0x10, 0x8e, 0x36, 0xbb, 0x89, 0xd3, 0xf9, 0x17, 0xc9, 0xc6, 0x71, 0x36, 0xde, 0x94, 0xaa, 0x80, - 0x00, 0x59, 0x3b, 0xf1, 0x02, 0xc5, 0x52, 0xc5, 0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a, 0x14, 0xc6, 0x2b, 0x56, - 0x66, 0x07, 0x88, 0x80, 0xaa, 0x2f, 0xc7, 0x84, 0xed, 0x2e, 0xa9, 0x51, 0x6b, 0x11, 0x16, 0xae, - 0x10, 0xd2, 0x64, 0xff, 0xbb, 0x03, 0xf9, 0x56, 0x6f, 0xe8, 0x59, 0xf9, 0x2c, 0x19, 0x95, 0x19, - 0xac, 0xdf, 0x87, 0x99, 0x90, 0xed, 0x92, 0x2a, 0x6d, 0x12, 0xef, 0x0b, 0x82, 0xaa, 0x11, 0xf6, - 0x04, 0xc1, 0x9c, 0xdd, 0x25, 0x37, 0xd7, 0x60, 0x36, 0x64, 0xfb, 0x4d, 0xde, 0x01, 0x96, 0x85, - 0xed, 0x56, 0x98, 0x01, 0xcc, 0xfb, 0x88, 0x1d, 0xc4, 0xa1, 0x8b, 0x77, 0x49, 0x12, 0x8e, 0x61, - 0x41, 0x46, 0xdd, 0xc3, 0x4a, 0x66, 0xfe, 0xdb, 0xbd, 0x2c, 0xed, 0xde, 0x0e, 0xcd, 0xef, 0xe0, - 0x41, 0xb5, 0x75, 0x55, 0x8f, 0x70, 0x1c, 0xd6, 0x42, 0x17, 0xf1, 0x90, 0xca, 0xec, 0xf3, 0x23, - 0x22, 0xe0, 0x93, 0x3e, 0x05, 0xbf, 0xde, 0x81, 0x9d, 0xe9, 0xde, 0xb2, 0x60, 0xe5, 0xba, 0xc2, - 0xeb, 0xd3, 0xd9, 0x14, 0x9d, 0x24, 0x31, 0xcf, 0xf1, 0xb9, 0x8f, 0x49, 0xc6, 0x99, 0xcc, 0xc1, - 0x3d, 0x11, 0x50, 0xb5, 0x91, 0x7c, 0x51, 0x67, 0xdf, 0xee, 0x42, 0x7b, 0xff, 0xd5, 0x80, 0xb7, - 0xc4, 0x55, 0x65, 0x98, 0x8b, 0x9b, 0xfa, 0x42, 0xac, 0xb4, 0xdb, 0x35, 0xeb, 0x3b, 0x30, 0x2d, - 0x55, 0x62, 0x2f, 0x3a, 0x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0xbf, - 0x2e, 0x8b, 0x43, 0x2f, 0xcb, 0x7e, 0xc8, 0x83, 0x66, 0xb5, 0xe4, 0xd2, 0x7a, 0x39, 0x71, 0xf5, - 0x48, 0x78, 0x2d, 0xa7, 0x5e, 0xcb, 0x67, 0xe5, 0xd6, 0x1f, 0xb6, 0xf3, 0x06, 0x66, 0xd5, 0x11, - 0xf1, 0x0f, 0xec, 0xf1, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x8d, 0x3c, 0x01, 0x95, 0x0e, - 0x00, 0x00, + // 1200 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4b, 0x6f, 0xdb, 0x46, + 0x10, 0x36, 0xe3, 0xc4, 0x96, 0xc7, 0x6f, 0xd6, 0x8e, 0x65, 0x39, 0x56, 0x0c, 0x02, 0x6d, 0xdd, + 0xd6, 0x91, 0x6c, 0xa5, 0xaf, 0x14, 0xe8, 0xc1, 0x4e, 0x1b, 0xdb, 0x4d, 0x1d, 0x1b, 0x94, 0xeb, + 0x43, 0x2e, 0xc4, 0x8a, 0x5c, 0x91, 0xac, 0xe9, 0x5d, 0x81, 0xbb, 0xf2, 0x23, 0x7d, 0x00, 0x3d, + 0xf6, 0x50, 0xb4, 0x3f, 0xa0, 0xa7, 0xfe, 0x84, 0xfe, 0x86, 0x1e, 0x72, 0x0c, 0x7a, 0xea, 0xa9, + 0x28, 0xec, 0x53, 0x7f, 0x41, 0xaf, 0x05, 0x77, 0x97, 0xd4, 0xd3, 0x94, 0x64, 0x20, 0x27, 0x91, + 0x33, 0xdf, 0x7c, 0x33, 0xb3, 0x33, 0x3b, 0x43, 0xc1, 0x2c, 0xad, 0x30, 0x1c, 0x9e, 0xe2, 0xb0, + 0xc8, 0xcf, 0x0b, 0xb5, 0x90, 0x72, 0xaa, 0x2f, 0xbd, 0xc0, 0x1c, 0xd9, 0x1e, 0xf2, 0x49, 0x41, + 0x3c, 0xd1, 0x10, 0x17, 0x62, 0x54, 0x6e, 0xce, 0xa5, 0x2e, 0x15, 0xb8, 0x62, 0xf4, 0x24, 0x4d, + 0x72, 0x73, 0x09, 0x4b, 0x25, 0x40, 0x27, 0x58, 0x49, 0xef, 0x27, 0x52, 0x3b, 0xa4, 0x8c, 0x09, + 0x4a, 0xab, 0x1a, 0x20, 0x97, 0x29, 0xc0, 0x42, 0x02, 0x88, 0x1f, 0x94, 0x62, 0x3e, 0x51, 0xd4, + 0x50, 0x88, 0x4e, 0x62, 0xfc, 0x72, 0x43, 0x8c, 0x89, 0xe3, 0x13, 0xd7, 0x22, 0x94, 0xd8, 0x38, + 0x56, 0xeb, 0x8d, 0x5c, 0x58, 0xe2, 0xa2, 0x76, 0xec, 0x16, 0x85, 0x67, 0xa6, 0x7e, 0x9a, 0x15, + 0xb5, 0x90, 0xd2, 0x2a, 0x53, 0x3f, 0x52, 0x61, 0xfc, 0xab, 0xc1, 0xec, 0x1e, 0x73, 0xbf, 0xaa, + 0x39, 0x88, 0xe3, 0x7d, 0xc5, 0xa8, 0x67, 0x61, 0xd4, 0x0e, 0x31, 0xe2, 0x34, 0xcc, 0x6a, 0x2b, + 0xda, 0xea, 0x98, 0x19, 0xbf, 0xea, 0xeb, 0x30, 0x47, 0x03, 0xc7, 0x8a, 0x7d, 0x5b, 0xc8, 0x71, + 0x42, 0xcc, 0x58, 0xf6, 0x96, 0x80, 0xe9, 0x34, 0x70, 0x62, 0x92, 0x4d, 0xa9, 0x89, 0x2c, 0x08, + 0x3e, 0xeb, 0xb4, 0x18, 0x96, 0x16, 0x04, 0x9f, 0xb5, 0x5b, 0x1c, 0xc1, 0x64, 0x5d, 0xc4, 0x63, + 0x85, 0x18, 0x31, 0x4a, 0xb2, 0xb7, 0x57, 0xb4, 0xd5, 0xa9, 0xd2, 0x46, 0x21, 0xa5, 0x54, 0x85, + 0x98, 0x44, 0x66, 0x62, 0x0a, 0x43, 0x73, 0xa2, 0xde, 0xf4, 0x66, 0x2c, 0xc1, 0x62, 0x47, 0xaa, + 0x26, 0x66, 0x35, 0x4a, 0x18, 0x36, 0x7e, 0xd7, 0x40, 0xdf, 0x63, 0xee, 0x11, 0xe5, 0x78, 0x2b, + 0xa0, 0xf6, 0xf1, 0x0e, 0x46, 0x4e, 0xea, 0x49, 0x2c, 0x42, 0x46, 0xd6, 0xd8, 0x77, 0x44, 0xf6, + 0xc3, 0xe6, 0xa8, 0x78, 0xdf, 0x75, 0xf4, 0x65, 0x80, 0x4a, 0xc4, 0x61, 0x79, 0x88, 0x79, 0x22, + 0xd1, 0x09, 0x73, 0x4c, 0x48, 0x76, 0x10, 0xf3, 0xf4, 0xbb, 0x30, 0xe2, 0x61, 0xdf, 0xf5, 0xb8, + 0x48, 0x6c, 0xd8, 0x54, 0x6f, 0xfa, 0x7a, 0x24, 0x8f, 0xbc, 0x66, 0xef, 0xac, 0x68, 0xab, 0xe3, + 0x25, 0xbd, 0xa0, 0x4a, 0x25, 0x63, 0xf9, 0x0c, 0x71, 0xb4, 0x75, 0xfb, 0xe5, 0xdf, 0xf7, 0x87, + 0x4c, 0x85, 0x33, 0xbe, 0x86, 0x5c, 0x67, 0xcc, 0x71, 0x4a, 0xfa, 0x9b, 0x30, 0x55, 0x41, 0x41, + 0x40, 0xb9, 0x25, 0x62, 0xc6, 0x8e, 0x48, 0x21, 0x63, 0x4e, 0x4a, 0xe9, 0x63, 0x29, 0x8c, 0x60, + 0xa7, 0x94, 0x63, 0xab, 0xea, 0x13, 0x14, 0xf8, 0x2f, 0xb0, 0x4c, 0x27, 0x63, 0x4e, 0x46, 0xd2, + 0x27, 0xb1, 0xd0, 0xf8, 0x16, 0xe6, 0x92, 0xd3, 0x7b, 0x1c, 0x25, 0x7a, 0x20, 0x9a, 0x35, 0xe5, + 0x84, 0xbe, 0x80, 0x71, 0xbb, 0x01, 0x14, 0xac, 0xe3, 0xa5, 0xd5, 0xd4, 0x2a, 0x36, 0x11, 0x9b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xf3, 0x27, 0x0d, 0xe6, 0xbb, 0xaf, 0x95, 0x0f, 0xfa, 0x3c, 0xcc, 0x56, 0xb3, + 0xdc, 0xa7, 0x37, 0x32, 0x6b, 0x3e, 0x83, 0x96, 0x41, 0xba, 0xd6, 0x1f, 0x9d, 0x44, 0xf7, 0x3e, + 0x83, 0x6e, 0x13, 0x56, 0xff, 0x06, 0xa6, 0xdb, 0xbf, 0x89, 0x8b, 0xbd, 0x88, 0xda, 0x0c, 0x72, + 0x1f, 0x0d, 0x68, 0x90, 0x38, 0xff, 0x1e, 0x66, 0x3a, 0x46, 0xfb, 0x7a, 0xef, 0x1e, 0x6a, 0xb5, + 0xc8, 0x7d, 0x3c, 0xa8, 0x45, 0xe2, 0xdf, 0x86, 0xd1, 0x78, 0x38, 0xbf, 0xdd, 0x4f, 0x0e, 0x87, + 0xe5, 0x72, 0xae, 0xd8, 0x27, 0x30, 0x76, 0xb2, 0xb5, 0xfb, 0xf2, 0x32, 0xaf, 0xbd, 0xba, 0xcc, + 0x6b, 0xff, 0x5c, 0xe6, 0xb5, 0x5f, 0xae, 0xf2, 0x43, 0xaf, 0xae, 0xf2, 0x43, 0x7f, 0x5d, 0xe5, + 0x87, 0x9e, 0x17, 0x5d, 0x9f, 0x7b, 0xf5, 0x4a, 0xc1, 0xa6, 0x27, 0xc5, 0x88, 0xea, 0x81, 0x60, + 0x2d, 0xc6, 0xac, 0xc5, 0xf3, 0x62, 0xe3, 0x3f, 0xe0, 0x45, 0x0d, 0xb3, 0xca, 0x88, 0xf8, 0x53, + 0xf7, 0xf0, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe4, 0xd6, 0x5e, 0xab, 0xe8, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1178,7 +1194,7 @@ type MsgClient interface { AddBlameVote(ctx context.Context, in *MsgAddBlameVote, opts ...grpc.CallOption) (*MsgAddBlameVoteResponse, error) UpdateCrosschainFlags(ctx context.Context, in *MsgUpdateCrosschainFlags, opts ...grpc.CallOption) (*MsgUpdateCrosschainFlagsResponse, error) UpdateKeygen(ctx context.Context, in *MsgUpdateKeygen, opts ...grpc.CallOption) (*MsgUpdateKeygenResponse, error) - AddBlockHeader(ctx context.Context, in *MsgAddBlockHeader, opts ...grpc.CallOption) (*MsgAddBlockHeaderResponse, error) + VoteBlockHeader(ctx context.Context, in *MsgVoteBlockHeader, opts ...grpc.CallOption) (*MsgVoteBlockHeaderResponse, error) ResetChainNonces(ctx context.Context, in *MsgResetChainNonces, opts ...grpc.CallOption) (*MsgResetChainNoncesResponse, error) VoteTSS(ctx context.Context, in *MsgVoteTSS, opts ...grpc.CallOption) (*MsgVoteTSSResponse, error) } @@ -1254,9 +1270,9 @@ func (c *msgClient) UpdateKeygen(ctx context.Context, in *MsgUpdateKeygen, opts return out, nil } -func (c *msgClient) AddBlockHeader(ctx context.Context, in *MsgAddBlockHeader, opts ...grpc.CallOption) (*MsgAddBlockHeaderResponse, error) { - out := new(MsgAddBlockHeaderResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Msg/AddBlockHeader", in, out, opts...) +func (c *msgClient) VoteBlockHeader(ctx context.Context, in *MsgVoteBlockHeader, opts ...grpc.CallOption) (*MsgVoteBlockHeaderResponse, error) { + out := new(MsgVoteBlockHeaderResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.observer.Msg/VoteBlockHeader", in, out, opts...) if err != nil { return nil, err } @@ -1290,7 +1306,7 @@ type MsgServer interface { AddBlameVote(context.Context, *MsgAddBlameVote) (*MsgAddBlameVoteResponse, error) UpdateCrosschainFlags(context.Context, *MsgUpdateCrosschainFlags) (*MsgUpdateCrosschainFlagsResponse, error) UpdateKeygen(context.Context, *MsgUpdateKeygen) (*MsgUpdateKeygenResponse, error) - AddBlockHeader(context.Context, *MsgAddBlockHeader) (*MsgAddBlockHeaderResponse, error) + VoteBlockHeader(context.Context, *MsgVoteBlockHeader) (*MsgVoteBlockHeaderResponse, error) ResetChainNonces(context.Context, *MsgResetChainNonces) (*MsgResetChainNoncesResponse, error) VoteTSS(context.Context, *MsgVoteTSS) (*MsgVoteTSSResponse, error) } @@ -1320,8 +1336,8 @@ func (*UnimplementedMsgServer) UpdateCrosschainFlags(ctx context.Context, req *M func (*UnimplementedMsgServer) UpdateKeygen(ctx context.Context, req *MsgUpdateKeygen) (*MsgUpdateKeygenResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateKeygen not implemented") } -func (*UnimplementedMsgServer) AddBlockHeader(ctx context.Context, req *MsgAddBlockHeader) (*MsgAddBlockHeaderResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddBlockHeader not implemented") +func (*UnimplementedMsgServer) VoteBlockHeader(ctx context.Context, req *MsgVoteBlockHeader) (*MsgVoteBlockHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VoteBlockHeader not implemented") } func (*UnimplementedMsgServer) ResetChainNonces(ctx context.Context, req *MsgResetChainNonces) (*MsgResetChainNoncesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ResetChainNonces not implemented") @@ -1460,20 +1476,20 @@ func _Msg_UpdateKeygen_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } -func _Msg_AddBlockHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddBlockHeader) +func _Msg_VoteBlockHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVoteBlockHeader) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).AddBlockHeader(ctx, in) + return srv.(MsgServer).VoteBlockHeader(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.observer.Msg/AddBlockHeader", + FullMethod: "/zetachain.zetacore.observer.Msg/VoteBlockHeader", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).AddBlockHeader(ctx, req.(*MsgAddBlockHeader)) + return srv.(MsgServer).VoteBlockHeader(ctx, req.(*MsgVoteBlockHeader)) } return interceptor(ctx, in, info, handler) } @@ -1547,8 +1563,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_UpdateKeygen_Handler, }, { - MethodName: "AddBlockHeader", - Handler: _Msg_AddBlockHeader_Handler, + MethodName: "VoteBlockHeader", + Handler: _Msg_VoteBlockHeader_Handler, }, { MethodName: "ResetChainNonces", @@ -1635,7 +1651,7 @@ func (m *MsgUpdateObserverResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *MsgAddBlockHeader) Marshal() (dAtA []byte, err error) { +func (m *MsgVoteBlockHeader) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1645,12 +1661,12 @@ func (m *MsgAddBlockHeader) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddBlockHeader) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgVoteBlockHeader) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddBlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgVoteBlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1692,7 +1708,7 @@ func (m *MsgAddBlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgAddBlockHeaderResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgVoteBlockHeaderResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1702,16 +1718,36 @@ func (m *MsgAddBlockHeaderResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddBlockHeaderResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgVoteBlockHeaderResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddBlockHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgVoteBlockHeaderResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.VoteFinalized { + i-- + if m.VoteFinalized { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if m.BallotCreated { + i-- + if m.BallotCreated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -2350,7 +2386,7 @@ func (m *MsgUpdateObserverResponse) Size() (n int) { return n } -func (m *MsgAddBlockHeader) Size() (n int) { +func (m *MsgVoteBlockHeader) Size() (n int) { if m == nil { return 0 } @@ -2375,12 +2411,18 @@ func (m *MsgAddBlockHeader) Size() (n int) { return n } -func (m *MsgAddBlockHeaderResponse) Size() (n int) { +func (m *MsgVoteBlockHeaderResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l + if m.BallotCreated { + n += 2 + } + if m.VoteFinalized { + n += 2 + } return n } @@ -2849,7 +2891,7 @@ func (m *MsgUpdateObserverResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAddBlockHeader) Unmarshal(dAtA []byte) error { +func (m *MsgVoteBlockHeader) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2872,10 +2914,10 @@ func (m *MsgAddBlockHeader) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddBlockHeader: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteBlockHeader: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddBlockHeader: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteBlockHeader: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3036,7 +3078,7 @@ func (m *MsgAddBlockHeader) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAddBlockHeaderResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVoteBlockHeaderResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3059,12 +3101,52 @@ func (m *MsgAddBlockHeaderResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddBlockHeaderResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteBlockHeaderResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddBlockHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteBlockHeaderResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BallotCreated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BallotCreated = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VoteFinalized", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.VoteFinalized = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index defb5bd054..801171a88c 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -353,9 +353,9 @@ func (ob *BTCChainClient) WatchInTx() { func (ob *BTCChainClient) postBlockHeader(tip int64) error { ob.logger.InTx.Info().Msgf("postBlockHeader: tip %d", tip) bn := tip - res, err := ob.zetaClient.GetBlockHeaderStateByChain(ob.chain.ChainId) - if err == nil && res.BlockHeaderState != nil && res.BlockHeaderState.EarliestHeight > 0 { - bn = res.BlockHeaderState.LatestHeight + 1 + res, err := ob.zetaClient.GetBlockHeaderChainState(ob.chain.ChainId) + if err == nil && res.ChainState != nil && res.ChainState.EarliestHeight > 0 { + bn = res.ChainState.LatestHeight + 1 } if bn > tip { return fmt.Errorf("postBlockHeader: must post block confirmed block header: %d > %d", bn, tip) @@ -372,7 +372,7 @@ func (ob *BTCChainClient) postBlockHeader(tip int64) error { return err } blockHash := res2.Header.BlockHash() - _, err = ob.zetaClient.PostAddBlockHeader( + _, err = ob.zetaClient.PostVoteBlockHeader( ob.chain.ChainId, blockHash[:], res2.Block.Height, @@ -436,8 +436,8 @@ func (ob *BTCChainClient) ObserveInTx() error { // add block header to zetabridge // TODO: consider having a separate ticker(from TSS scaning) for posting block headers // https://github.com/zeta-chain/node/issues/1847 - flags := ob.coreContext.GetCrossChainFlags() - if flags.BlockHeaderVerificationFlags != nil && flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled { + verificationFlags := ob.coreContext.GetVerificationFlags() + if verificationFlags.BtcTypeChainEnabled { err = ob.postBlockHeader(bn) if err != nil { ob.logger.InTx.Warn().Err(err).Msgf("observeInTxBTC: error posting block header %d", bn) diff --git a/zetaclient/core_context/zeta_core_context.go b/zetaclient/core_context/zeta_core_context.go index 346563be04..5bb8d23089 100644 --- a/zetaclient/core_context/zeta_core_context.go +++ b/zetaclient/core_context/zeta_core_context.go @@ -5,6 +5,8 @@ import ( "sort" "sync" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" + "github.com/rs/zerolog" "github.com/zeta-chain/zetacore/pkg/chains" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -21,6 +23,9 @@ type ZetaCoreContext struct { bitcoinChainParams *observertypes.ChainParams currentTssPubkey string crossChainFlags observertypes.CrosschainFlags + + // verificationFlags is used to store the verification flags for the lightclient module to enable header/proof verification + verificationFlags lightclienttypes.VerificationFlags } // NewZetaCoreContext creates and returns new ZetaCoreContext @@ -41,6 +46,7 @@ func NewZetaCoreContext(cfg config.Config) *ZetaCoreContext { evmChainParams: evmChainParams, bitcoinChainParams: bitcoinChainParams, crossChainFlags: observertypes.CrosschainFlags{}, + verificationFlags: lightclienttypes.VerificationFlags{}, } } @@ -114,6 +120,12 @@ func (c *ZetaCoreContext) GetCrossChainFlags() observertypes.CrosschainFlags { return c.crossChainFlags } +func (c *ZetaCoreContext) GetVerificationFlags() lightclienttypes.VerificationFlags { + c.coreContextLock.RLock() + defer c.coreContextLock.RUnlock() + return c.verificationFlags +} + // Update updates core context and params for all chains // this must be the ONLY function that writes to core context func (c *ZetaCoreContext) Update( @@ -123,6 +135,7 @@ func (c *ZetaCoreContext) Update( btcChainParams *observertypes.ChainParams, tssPubKey string, crosschainFlags observertypes.CrosschainFlags, + verificationFlags lightclienttypes.VerificationFlags, init bool, logger zerolog.Logger, ) { @@ -162,6 +175,7 @@ func (c *ZetaCoreContext) Update( } c.chainsEnabled = newChains c.crossChainFlags = crosschainFlags + c.verificationFlags = verificationFlags // update chain params for bitcoin if it has config in file if c.bitcoinChainParams != nil && btcChainParams != nil { c.bitcoinChainParams = btcChainParams diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index 8745fdc95c..93b0e1c57f 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -26,7 +27,9 @@ func assertPanic(t *testing.T, f func(), errorLog string) { func getTestCoreContext( evmChain chains.Chain, evmChainParams *observertypes.ChainParams, - ccFlags observertypes.CrosschainFlags) *corecontext.ZetaCoreContext { + ccFlags observertypes.CrosschainFlags, + verificationFlags lightclienttypes.VerificationFlags, +) *corecontext.ZetaCoreContext { // create config cfg := config.NewConfig() cfg.EVMChainConfigs[evmChain.ChainId] = config.EVMConfig{ @@ -45,6 +48,7 @@ func getTestCoreContext( nil, "", ccFlags, + verificationFlags, true, zerolog.Logger{}, ) @@ -166,6 +170,8 @@ func TestUpdateZetaCoreContext(t *testing.T) { tssPubKeyToUpdate := "tsspubkeytest" loggers := clientcommon.DefaultLoggers() crosschainFlags := sample.CrosschainFlags() + verificationFlags := sample.VerificationFlags() + require.NotNil(t, crosschainFlags) zetaContext.Update( &keyGenToUpdate, @@ -174,6 +180,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { btcChainParamsToUpdate, tssPubKeyToUpdate, *crosschainFlags, + verificationFlags, false, loggers.Std, ) @@ -200,6 +207,9 @@ func TestUpdateZetaCoreContext(t *testing.T) { ccFlags := zetaContext.GetCrossChainFlags() require.Equal(t, *crosschainFlags, ccFlags) + + verFlags := zetaContext.GetVerificationFlags() + require.Equal(t, verificationFlags, verFlags) }) t.Run("should update core context after being created from config with evm and btc chain params", func(t *testing.T) { @@ -257,6 +267,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { } tssPubKeyToUpdate := "tsspubkeytest" crosschainFlags := sample.CrosschainFlags() + verificationFlags := sample.VerificationFlags() require.NotNil(t, crosschainFlags) loggers := clientcommon.DefaultLoggers() zetaContext.Update( @@ -266,6 +277,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { btcChainParamsToUpdate, tssPubKeyToUpdate, *crosschainFlags, + verificationFlags, false, loggers.Std, ) @@ -300,6 +312,9 @@ func TestUpdateZetaCoreContext(t *testing.T) { ccFlags := zetaContext.GetCrossChainFlags() require.Equal(t, ccFlags, *crosschainFlags) + + verFlags := zetaContext.GetVerificationFlags() + require.Equal(t, verFlags, verificationFlags) }) } @@ -307,13 +322,14 @@ func TestIsOutboundObservationEnabled(t *testing.T) { // create test chain params and flags evmChain := chains.EthChain() ccFlags := *sample.CrosschainFlags() + verificationFlags := sample.VerificationFlags() chainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, IsSupported: true, } t.Run("should return true if chain is supported and outbound flag is enabled", func(t *testing.T) { - coreCTX := getTestCoreContext(evmChain, chainParams, ccFlags) + coreCTX := getTestCoreContext(evmChain, chainParams, ccFlags, verificationFlags) require.True(t, corecontext.IsOutboundObservationEnabled(coreCTX, *chainParams)) }) t.Run("should return false if chain is not supported yet", func(t *testing.T) { @@ -321,13 +337,13 @@ func TestIsOutboundObservationEnabled(t *testing.T) { ChainId: evmChain.ChainId, IsSupported: false, } - coreCTXUnsupported := getTestCoreContext(evmChain, paramsUnsupported, ccFlags) + coreCTXUnsupported := getTestCoreContext(evmChain, paramsUnsupported, ccFlags, verificationFlags) require.False(t, corecontext.IsOutboundObservationEnabled(coreCTXUnsupported, *paramsUnsupported)) }) t.Run("should return false if outbound flag is disabled", func(t *testing.T) { flagsDisabled := ccFlags flagsDisabled.IsOutboundEnabled = false - coreCTXDisabled := getTestCoreContext(evmChain, chainParams, flagsDisabled) + coreCTXDisabled := getTestCoreContext(evmChain, chainParams, flagsDisabled, verificationFlags) require.False(t, corecontext.IsOutboundObservationEnabled(coreCTXDisabled, *chainParams)) }) } @@ -336,13 +352,14 @@ func TestIsInboundObservationEnabled(t *testing.T) { // create test chain params and flags evmChain := chains.EthChain() ccFlags := *sample.CrosschainFlags() + verificationFlags := sample.VerificationFlags() chainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, IsSupported: true, } t.Run("should return true if chain is supported and inbound flag is enabled", func(t *testing.T) { - coreCTX := getTestCoreContext(evmChain, chainParams, ccFlags) + coreCTX := getTestCoreContext(evmChain, chainParams, ccFlags, verificationFlags) require.True(t, corecontext.IsInboundObservationEnabled(coreCTX, *chainParams)) }) t.Run("should return false if chain is not supported yet", func(t *testing.T) { @@ -350,13 +367,13 @@ func TestIsInboundObservationEnabled(t *testing.T) { ChainId: evmChain.ChainId, IsSupported: false, } - coreCTXUnsupported := getTestCoreContext(evmChain, paramsUnsupported, ccFlags) + coreCTXUnsupported := getTestCoreContext(evmChain, paramsUnsupported, ccFlags, verificationFlags) require.False(t, corecontext.IsInboundObservationEnabled(coreCTXUnsupported, *paramsUnsupported)) }) t.Run("should return false if inbound flag is disabled", func(t *testing.T) { flagsDisabled := ccFlags flagsDisabled.IsInboundEnabled = false - coreCTXDisabled := getTestCoreContext(evmChain, chainParams, flagsDisabled) + coreCTXDisabled := getTestCoreContext(evmChain, chainParams, flagsDisabled, verificationFlags) require.False(t, corecontext.IsInboundObservationEnabled(coreCTXDisabled, *chainParams)) }) } diff --git a/zetaclient/evm/evm_client.go b/zetaclient/evm/evm_client.go index 916f9e636f..63e8da7d7c 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -584,10 +584,10 @@ func (ob *ChainClient) calcBlockRangeToScan(latestConfirmed, lastScanned, batchS func (ob *ChainClient) postBlockHeader(tip uint64) error { bn := tip - res, err := ob.zetaBridge.GetBlockHeaderStateByChain(ob.chain.ChainId) - if err == nil && res.BlockHeaderState != nil && res.BlockHeaderState.EarliestHeight > 0 { + res, err := ob.zetaBridge.GetBlockHeaderChainState(ob.chain.ChainId) + if err == nil && res.ChainState != nil && res.ChainState.EarliestHeight > 0 { // #nosec G701 always positive - bn = uint64(res.BlockHeaderState.LatestHeight) + 1 // the next header to post + bn = uint64(res.ChainState.LatestHeight) + 1 // the next header to post } if bn > tip { @@ -605,7 +605,7 @@ func (ob *ChainClient) postBlockHeader(tip uint64) error { return err } - _, err = ob.zetaBridge.PostAddBlockHeader( + _, err = ob.zetaBridge.PostVoteBlockHeader( ob.chain.ChainId, header.Hash().Bytes(), header.Number.Int64(), @@ -839,10 +839,9 @@ func (ob *ChainClient) ObserverTSSReceive(startBlock, toBlock uint64) uint64 { // post new block header (if any) to zetabridge and ignore error // TODO: consider having a independent ticker(from TSS scaning) for posting block headers // https://github.com/zeta-chain/node/issues/1847 - flags := ob.coreContext.GetCrossChainFlags() - if flags.BlockHeaderVerificationFlags != nil && - flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled && - chains.IsHeaderSupportedEvmChain(ob.chain.ChainId) { // post block header for supported chains + verificationFlags := ob.coreContext.GetVerificationFlags() + if verificationFlags.EthTypeChainEnabled && chains.IsHeaderSupportedEvmChain(ob.chain.ChainId) { + // post block header for supported chains err := ob.postBlockHeader(toBlock) if err != nil { ob.logger.InTx.Error().Err(err).Msg("error posting block header") diff --git a/zetaclient/evm/evm_client_test.go b/zetaclient/evm/evm_client_test.go index 4fc947288e..e71bfd49ed 100644 --- a/zetaclient/evm/evm_client_test.go +++ b/zetaclient/evm/evm_client_test.go @@ -5,6 +5,7 @@ import ( "testing" "cosmossdk.io/math" + lru "github.com/hashicorp/golang-lru" "github.com/onrik/ethrpc" "github.com/rs/zerolog" @@ -36,7 +37,6 @@ func getAppContext(evmChain chains.Chain, evmChainParams *observertypes.ChainPar coreCtx := corecontext.NewZetaCoreContext(cfg) evmChainParamsMap := make(map[int64]*observertypes.ChainParams) evmChainParamsMap[evmChain.ChainId] = evmChainParams - ccFlags := *sample.CrosschainFlags() // feed chain params coreCtx.Update( @@ -45,7 +45,8 @@ func getAppContext(evmChain chains.Chain, evmChainParams *observertypes.ChainPar evmChainParamsMap, nil, "", - ccFlags, + *sample.CrosschainFlags(), + sample.VerificationFlags(), true, zerolog.Logger{}, ) diff --git a/zetaclient/interfaces/interfaces.go b/zetaclient/interfaces/interfaces.go index 20d56bc320..387e764688 100644 --- a/zetaclient/interfaces/interfaces.go +++ b/zetaclient/interfaces/interfaces.go @@ -4,6 +4,8 @@ import ( "context" "math/big" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" + "github.com/onrik/ethrpc" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" @@ -79,8 +81,8 @@ type ZetaCoreBridger interface { coinType coin.CoinType, ) (string, string, error) PostGasPrice(chain chains.Chain, gasPrice uint64, supply string, blockNum uint64) (string, error) - PostAddBlockHeader(chainID int64, txhash []byte, height int64, header proofs.HeaderData) (string, error) - GetBlockHeaderStateByChain(chainID int64) (observertypes.QueryGetBlockHeaderStateResponse, error) + PostVoteBlockHeader(chainID int64, txhash []byte, height int64, header proofs.HeaderData) (string, error) + GetBlockHeaderChainState(chainID int64) (lightclienttypes.QueryGetChainStateResponse, error) PostBlameData(blame *blame.Blame, chainID int64, index string) (string, error) AddTxHashToOutTxTracker( diff --git a/zetaclient/testutils/stub/core_bridge.go b/zetaclient/testutils/stub/core_bridge.go index fe785741ae..2f0ddaa732 100644 --- a/zetaclient/testutils/stub/core_bridge.go +++ b/zetaclient/testutils/stub/core_bridge.go @@ -4,6 +4,8 @@ import ( "errors" "math/big" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" + "cosmossdk.io/math" "github.com/rs/zerolog" "github.com/zeta-chain/go-tss/blame" @@ -59,18 +61,18 @@ func (z *MockZetaCoreBridge) PostGasPrice(_ chains.Chain, _ uint64, _ string, _ return "", nil } -func (z *MockZetaCoreBridge) PostAddBlockHeader(_ int64, _ []byte, _ int64, _ proofs.HeaderData) (string, error) { +func (z *MockZetaCoreBridge) PostVoteBlockHeader(_ int64, _ []byte, _ int64, _ proofs.HeaderData) (string, error) { if z.paused { return "", errors.New(ErrMsgPaused) } return "", nil } -func (z *MockZetaCoreBridge) GetBlockHeaderStateByChain(_ int64) (observerTypes.QueryGetBlockHeaderStateResponse, error) { +func (z *MockZetaCoreBridge) GetBlockHeaderChainState(_ int64) (lightclienttypes.QueryGetChainStateResponse, error) { if z.paused { - return observerTypes.QueryGetBlockHeaderStateResponse{}, errors.New(ErrMsgPaused) + return lightclienttypes.QueryGetChainStateResponse{}, errors.New(ErrMsgPaused) } - return observerTypes.QueryGetBlockHeaderStateResponse{}, nil + return lightclienttypes.QueryGetChainStateResponse{}, nil } func (z *MockZetaCoreBridge) PostBlameData(_ *blame.Blame, _ int64, _ string) (string, error) { diff --git a/zetaclient/zetabridge/broadcast_test.go b/zetaclient/zetabridge/broadcast_test.go index ce0aeaa57d..4d838358b0 100644 --- a/zetaclient/zetabridge/broadcast_test.go +++ b/zetaclient/zetabridge/broadcast_test.go @@ -79,7 +79,7 @@ func TestBroadcast(t *testing.T) { zetabridge.EnableMockSDKClient(stub.NewSDKClientWithErr(nil, 0)) blockHash, err := hex.DecodeString(ethBlockHash) require.NoError(t, err) - msg := observerTypes.NewMsgAddBlockHeader(address.String(), chains.EthChain().ChainId, blockHash, 18495266, getHeaderData(t)) + msg := observerTypes.NewMsgVoteBlockHeader(address.String(), chains.EthChain().ChainId, blockHash, 18495266, getHeaderData(t)) authzMsg, authzSigner, err := zetabridge.WrapMessageWithAuthz(msg) require.NoError(t, err) _, err = BroadcastToZetaCore(zetabridge, 10000, authzMsg, authzSigner) @@ -90,7 +90,7 @@ func TestBroadcast(t *testing.T) { zetabridge.EnableMockSDKClient(stub.NewSDKClientWithErr(errors.New("account sequence mismatch, expected 5 got 4"), 32)) blockHash, err := hex.DecodeString(ethBlockHash) require.NoError(t, err) - msg := observerTypes.NewMsgAddBlockHeader(address.String(), chains.EthChain().ChainId, blockHash, 18495266, getHeaderData(t)) + msg := observerTypes.NewMsgVoteBlockHeader(address.String(), chains.EthChain().ChainId, blockHash, 18495266, getHeaderData(t)) authzMsg, authzSigner, err := zetabridge.WrapMessageWithAuthz(msg) require.NoError(t, err) _, err = BroadcastToZetaCore(zetabridge, 10000, authzMsg, authzSigner) diff --git a/zetaclient/zetabridge/query.go b/zetaclient/zetabridge/query.go index 218c8494fa..b9e08bef56 100644 --- a/zetaclient/zetabridge/query.go +++ b/zetaclient/zetabridge/query.go @@ -6,22 +6,21 @@ import ( "sort" "time" - "github.com/zeta-chain/zetacore/pkg/chains" - "github.com/zeta-chain/zetacore/pkg/proofs" - "github.com/zeta-chain/zetacore/zetaclient/interfaces" - sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" - genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" - "github.com/cosmos/cosmos-sdk/types/query" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" tmhttp "github.com/tendermint/tendermint/rpc/client/http" "github.com/zeta-chain/zetacore/cmd/zetacored/config" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/x/crosschain/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" + "github.com/zeta-chain/zetacore/zetaclient/interfaces" "google.golang.org/grpc" ) @@ -34,6 +33,15 @@ func (b *ZetaCoreBridge) GetCrosschainFlags() (observertypes.CrosschainFlags, er return resp.CrosschainFlags, nil } +func (b *ZetaCoreBridge) GetVerificationFlags() (lightclienttypes.VerificationFlags, error) { + client := lightclienttypes.NewQueryClient(b.grpcConn) + resp, err := client.VerificationFlags(context.Background(), &lightclienttypes.QueryVerificationFlagsRequest{}) + if err != nil { + return lightclienttypes.VerificationFlags{}, err + } + return resp.VerificationFlags, nil +} + func (b *ZetaCoreBridge) GetChainParamsForChainID(externalChainID int64) (*observertypes.ChainParams, error) { client := observertypes.NewQueryClient(b.grpcConn) resp, err := client.GetChainParamsForChain(context.Background(), &observertypes.QueryGetChainParamsForChainRequest{ChainId: externalChainID}) @@ -372,11 +380,11 @@ func (b *ZetaCoreBridge) GetPendingNoncesByChain(chainID int64) (observertypes.P return resp.PendingNonces, nil } -func (b *ZetaCoreBridge) GetBlockHeaderStateByChain(chainID int64) (observertypes.QueryGetBlockHeaderStateResponse, error) { - client := observertypes.NewQueryClient(b.grpcConn) - resp, err := client.GetBlockHeaderStateByChain(context.Background(), &observertypes.QueryGetBlockHeaderStateRequest{ChainId: chainID}) +func (b *ZetaCoreBridge) GetBlockHeaderChainState(chainID int64) (lightclienttypes.QueryGetChainStateResponse, error) { + client := lightclienttypes.NewQueryClient(b.grpcConn) + resp, err := client.ChainState(context.Background(), &lightclienttypes.QueryGetChainStateRequest{ChainId: chainID}) if err != nil { - return observertypes.QueryGetBlockHeaderStateResponse{}, err + return lightclienttypes.QueryGetChainStateResponse{}, err } return *resp, nil } @@ -400,8 +408,8 @@ func (b *ZetaCoreBridge) GetPendingNonces() (*observertypes.QueryAllPendingNonce } func (b *ZetaCoreBridge) Prove(blockHash string, txHash string, txIndex int64, proof *proofs.Proof, chainID int64) (bool, error) { - client := observertypes.NewQueryClient(b.grpcConn) - resp, err := client.Prove(context.Background(), &observertypes.QueryProveRequest{ + client := lightclienttypes.NewQueryClient(b.grpcConn) + resp, err := client.Prove(context.Background(), &lightclienttypes.QueryProveRequest{ BlockHash: blockHash, TxIndex: txIndex, Proof: proof, diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index c5dabc31fd..3844482dd3 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -16,6 +16,7 @@ import ( "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" crosschainTypes "github.com/zeta-chain/zetacore/x/crosschain/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/interfaces" "github.com/zeta-chain/zetacore/zetaclient/keys" @@ -101,6 +102,25 @@ func TestZetaCoreBridge_GetCrosschainFlags(t *testing.T) { require.Equal(t, expectedOutput.CrosschainFlags, resp) } +func TestZetaCoreBridge_GetVerificationFlags(t *testing.T) { + expectedOutput := lightclienttypes.QueryVerificationFlagsResponse{VerificationFlags: lightclienttypes.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: false, + }} + input := lightclienttypes.QueryVerificationFlagsRequest{} + method := "/zetachain.zetacore.lightclient.Query/VerificationFlags" + server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) + server.Serve() + defer closeMockServer(t, server) + + zetabridge, err := setupCoreBridge() + require.NoError(t, err) + + resp, err := zetabridge.GetVerificationFlags() + require.NoError(t, err) + require.Equal(t, expectedOutput.VerificationFlags, resp) +} + func TestZetaCoreBridge_GetChainParamsForChainID(t *testing.T) { expectedOutput := observertypes.QueryGetChainParamsForChainResponse{ChainParams: &observertypes.ChainParams{ ChainId: 123, @@ -738,24 +758,24 @@ func TestZetaCoreBridge_GetPendingNoncesByChain(t *testing.T) { require.Equal(t, expectedOutput.PendingNonces, resp) } -func TestZetaCoreBridge_GetBlockHeaderStateByChain(t *testing.T) { +func TestZetaCoreBridge_GetBlockHeaderChainState(t *testing.T) { chainID := chains.BscMainnetChain().ChainId - expectedOutput := observertypes.QueryGetBlockHeaderStateResponse{BlockHeaderState: &observertypes.BlockHeaderState{ + expectedOutput := lightclienttypes.QueryGetChainStateResponse{ChainState: &lightclienttypes.ChainState{ ChainId: chainID, LatestHeight: 5566654, EarliestHeight: 4454445, LatestBlockHash: nil, }} - input := observertypes.QueryGetBlockHeaderStateRequest{ChainId: chainID} - method := "/zetachain.zetacore.observer.Query/GetBlockHeaderStateByChain" - server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) + input := lightclienttypes.QueryGetChainStateRequest{ChainId: chainID} + method := "/zetachain.zetacore.lightclient.Query/ChainState" + server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) zetabridge, err := setupCoreBridge() require.NoError(t, err) - resp, err := zetabridge.GetBlockHeaderStateByChain(chainID) + resp, err := zetabridge.GetBlockHeaderChainState(chainID) require.NoError(t, err) require.Equal(t, expectedOutput, resp) } @@ -815,18 +835,18 @@ func TestZetaCoreBridge_Prove(t *testing.T) { txHash := "9c8d02b6956b9c78ecb6090a8160faaa48e7aecfd0026fcdf533721d861436a3" blockHash := "0000000000000000000172c9a64f86f208b867a84dc7a0b7c75be51e750ed8eb" txIndex := 555 - expectedOutput := observertypes.QueryProveResponse{ + expectedOutput := lightclienttypes.QueryProveResponse{ Valid: true, } - input := observertypes.QueryProveRequest{ + input := lightclienttypes.QueryProveRequest{ ChainId: chainId, TxHash: txHash, Proof: nil, BlockHash: blockHash, TxIndex: int64(txIndex), } - method := "/zetachain.zetacore.observer.Query/Prove" - server := setupMockServer(t, observertypes.RegisterQueryServer, method, input, expectedOutput) + method := "/zetachain.zetacore.lightclient.Query/Prove" + server := setupMockServer(t, lightclienttypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) diff --git a/zetaclient/zetabridge/tx.go b/zetaclient/zetabridge/tx.go index 47df6fdfdf..b76996e79a 100644 --- a/zetaclient/zetabridge/tx.go +++ b/zetaclient/zetabridge/tx.go @@ -174,10 +174,10 @@ func (b *ZetaCoreBridge) PostBlameData(blame *blame.Blame, chainID int64, index return "", fmt.Errorf("post blame data failed after %d retries", DefaultRetryCount) } -func (b *ZetaCoreBridge) PostAddBlockHeader(chainID int64, blockHash []byte, height int64, header proofs.HeaderData) (string, error) { +func (b *ZetaCoreBridge) PostVoteBlockHeader(chainID int64, blockHash []byte, height int64, header proofs.HeaderData) (string, error) { signerAddress := b.keys.GetOperatorAddress().String() - msg := observertypes.NewMsgAddBlockHeader(signerAddress, chainID, blockHash, height, header) + msg := observertypes.NewMsgVoteBlockHeader(signerAddress, chainID, blockHash, height, header) authzMsg, authzSigner, err := b.WrapMessageWithAuthz(msg) if err != nil { @@ -190,7 +190,7 @@ func (b *ZetaCoreBridge) PostAddBlockHeader(chainID int64, blockHash []byte, hei if err == nil { return zetaTxHash, nil } - b.logger.Error().Err(err).Msgf("PostAddBlockHeader broadcast fail | Retry count : %d", i+1) + b.logger.Error().Err(err).Msgf("PostVoteBlockHeader broadcast fail | Retry count : %d", i+1) time.Sleep(DefaultRetryInterval * time.Second) } return "", fmt.Errorf("post add block header failed after %d retries", DefaultRetryCount) diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index 8dc6668384..4fd2ee19fb 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -20,6 +20,7 @@ import ( "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/pkg/proofs" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/authz" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -205,6 +206,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { grpcmock.RegisterService(crosschaintypes.RegisterQueryServer), grpcmock.RegisterService(upgradetypes.RegisterQueryServer), grpcmock.RegisterService(observertypes.RegisterQueryServer), + grpcmock.RegisterService(lightclienttypes.RegisterQueryServer), grpcmock.WithPlanner(planner.FirstMatch()), grpcmock.WithListener(listener), func(s *grpcmock.Server) { @@ -287,6 +289,15 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { GasPriceIncreaseFlags: nil, BlockHeaderVerificationFlags: nil, }}) + + method = "/zetachain.zetacore.lightclient.Query/VerificationFlags" + s.ExpectUnary(method). + UnlimitedTimes(). + WithPayload(lightclienttypes.QueryVerificationFlagsRequest{}). + Return(lightclienttypes.QueryVerificationFlagsResponse{VerificationFlags: lightclienttypes.VerificationFlags{ + EthTypeChainEnabled: true, + BtcTypeChainEnabled: false, + }}) }, )(t) @@ -330,7 +341,7 @@ func TestZetaCoreBridge_PostBlameData(t *testing.T) { }) } -func TestZetaCoreBridge_PostAddBlockHeader(t *testing.T) { +func TestZetaCoreBridge_PostVoteBlockHeader(t *testing.T) { zetabridge, err := setupCoreBridge() require.NoError(t, err) address := sdktypes.AccAddress(stub.TestKeyringPair.PubKey().Address().Bytes()) @@ -340,7 +351,7 @@ func TestZetaCoreBridge_PostAddBlockHeader(t *testing.T) { t.Run("post add block header success", func(t *testing.T) { zetaBridgeBroadcast = ZetaBridgeBroadcastTest - hash, err := zetabridge.PostAddBlockHeader( + hash, err := zetabridge.PostVoteBlockHeader( chains.EthChain().ChainId, blockHash, 18495266, diff --git a/zetaclient/zetabridge/zetacore_bridge.go b/zetaclient/zetabridge/zetacore_bridge.go index 00e04632a2..3899d51d82 100644 --- a/zetaclient/zetabridge/zetacore_bridge.go +++ b/zetaclient/zetabridge/zetacore_bridge.go @@ -266,7 +266,24 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore return err } - coreContext.Update(keyGen, newChains, newEVMParams, newBTCParams, tssPubKey, crosschainFlags, init, b.logger) + verificationFlags, err := b.GetVerificationFlags() + if err != nil { + b.logger.Info().Msg("Unable to fetch verification flags from zetabridge") + return err + } + + coreContext.Update( + keyGen, + newChains, + newEVMParams, + newBTCParams, + tssPubKey, + crosschainFlags, + verificationFlags, + init, + b.logger, + ) + return nil } diff --git a/zetaclient/zetacore_observer_test.go b/zetaclient/zetacore_observer_test.go index 56ca752b97..d47c062757 100644 --- a/zetaclient/zetacore_observer_test.go +++ b/zetaclient/zetacore_observer_test.go @@ -56,6 +56,7 @@ func CreateCoreContext(evmChain, btcChain chains.Chain, evmChainParams, btcChain evmChainParamsMap := make(map[int64]*observertypes.ChainParams) evmChainParamsMap[evmChain.ChainId] = evmChainParams ccFlags := sample.CrosschainFlags() + verificationFlags := sample.VerificationFlags() // feed chain params coreContext.Update( @@ -65,6 +66,7 @@ func CreateCoreContext(evmChain, btcChain chains.Chain, evmChainParams, btcChain btcChainParams, "", *ccFlags, + verificationFlags, true, zerolog.Logger{}, ) From e0ea646d1f42c065d9da5613eba3215a0cc7706c Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Thu, 18 Apr 2024 20:14:08 +0200 Subject: [PATCH 05/11] feat(`crosschain`): add rate limiter flags singleton state variable (#2046) * initialize type * keeper and genesis * new state variable * add query * make generate * changelog * fix lint * fix unit test * address comments --- changelog.md | 1 + .../zetacored/zetacored_query_crosschain.md | 1 + ...uery_crosschain_update_rate_limit_flags.md | 33 + docs/openapi/openapi.swagger.yaml | 47 ++ docs/spec/crosschain/messages.md | 12 + proto/crosschain/genesis.proto | 2 + proto/crosschain/query.proto | 12 + proto/crosschain/rate_limiter_flags.proto | 30 + proto/crosschain/tx.proto | 10 + testutil/sample/crosschain.go | 34 + typescript/crosschain/genesis_pb.d.ts | 6 + typescript/crosschain/index.d.ts | 1 + typescript/crosschain/query_pb.d.ts | 44 ++ .../crosschain/rate_limiter_flags_pb.d.ts | 82 +++ typescript/crosschain/tx_pb.d.ts | 49 ++ x/crosschain/client/cli/query.go | 8 +- .../client/cli/query_rate_limiter_flags.go | 33 + x/crosschain/genesis.go | 7 + x/crosschain/genesis_test.go | 1 + .../keeper/grpc_query_rate_limiter_flags.go | 26 + .../grpc_query_rate_limiter_flags_test.go | 46 ++ .../msg_server_update_rate_limiter_flags.go | 25 + ...g_server_update_rate_limiter_flags_test.go | 57 ++ x/crosschain/keeper/rate_limiter_flags.go | 27 + .../keeper/rate_limiter_flags_test.go | 24 + x/crosschain/types/codec.go | 2 + x/crosschain/types/errors.go | 3 +- x/crosschain/types/genesis.go | 16 +- x/crosschain/types/genesis.pb.go | 119 ++- x/crosschain/types/genesis_test.go | 16 + x/crosschain/types/keys.go | 2 + .../message_update_rate_limiter_flags.go | 49 ++ .../message_update_rate_limiter_flags_test.go | 97 +++ x/crosschain/types/query.pb.go | 552 +++++++++++--- x/crosschain/types/query.pb.gw.go | 65 ++ x/crosschain/types/rate_limiter_flags.go | 47 ++ x/crosschain/types/rate_limiter_flags.pb.go | 684 ++++++++++++++++++ x/crosschain/types/rate_limiter_flags_test.go | 186 +++++ x/crosschain/types/tx.pb.go | 567 ++++++++++++--- 39 files changed, 2769 insertions(+), 254 deletions(-) create mode 100644 docs/cli/zetacored/zetacored_query_crosschain_update_rate_limit_flags.md create mode 100644 proto/crosschain/rate_limiter_flags.proto create mode 100644 typescript/crosschain/rate_limiter_flags_pb.d.ts create mode 100644 x/crosschain/client/cli/query_rate_limiter_flags.go create mode 100644 x/crosschain/keeper/grpc_query_rate_limiter_flags.go create mode 100644 x/crosschain/keeper/grpc_query_rate_limiter_flags_test.go create mode 100644 x/crosschain/keeper/msg_server_update_rate_limiter_flags.go create mode 100644 x/crosschain/keeper/msg_server_update_rate_limiter_flags_test.go create mode 100644 x/crosschain/keeper/rate_limiter_flags.go create mode 100644 x/crosschain/keeper/rate_limiter_flags_test.go create mode 100644 x/crosschain/types/message_update_rate_limiter_flags.go create mode 100644 x/crosschain/types/message_update_rate_limiter_flags_test.go create mode 100644 x/crosschain/types/rate_limiter_flags.go create mode 100644 x/crosschain/types/rate_limiter_flags.pb.go create mode 100644 x/crosschain/types/rate_limiter_flags_test.go diff --git a/changelog.md b/changelog.md index 3c13ec7bee..fd1a9c8b99 100644 --- a/changelog.md +++ b/changelog.md @@ -53,6 +53,7 @@ * [1935](https://github.com/zeta-chain/node/pull/1935) - add an operational authority group * [1954](https://github.com/zeta-chain/node/pull/1954) - add metric for concurrent keysigns * [2006](https://github.com/zeta-chain/node/pull/2006) - add Amoy testnet static chain information +* [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags ### Tests diff --git a/docs/cli/zetacored/zetacored_query_crosschain.md b/docs/cli/zetacored/zetacored_query_crosschain.md index db80778e2a..48345c136d 100644 --- a/docs/cli/zetacored/zetacored_query_crosschain.md +++ b/docs/cli/zetacored/zetacored_query_crosschain.md @@ -39,4 +39,5 @@ zetacored query crosschain [flags] * [zetacored query crosschain show-gas-price](zetacored_query_crosschain_show-gas-price.md) - shows a gasPrice * [zetacored query crosschain show-in-tx-hash-to-cctx](zetacored_query_crosschain_show-in-tx-hash-to-cctx.md) - shows a inTxHashToCctx * [zetacored query crosschain show-out-tx-tracker](zetacored_query_crosschain_show-out-tx-tracker.md) - shows a OutTxTracker +* [zetacored query crosschain update_rate_limit_flags](zetacored_query_crosschain_update_rate_limit_flags.md) - shows the rate limiter flags diff --git a/docs/cli/zetacored/zetacored_query_crosschain_update_rate_limit_flags.md b/docs/cli/zetacored/zetacored_query_crosschain_update_rate_limit_flags.md new file mode 100644 index 0000000000..a4455cc6b0 --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_crosschain_update_rate_limit_flags.md @@ -0,0 +1,33 @@ +# query crosschain update_rate_limit_flags + +shows the rate limiter flags + +``` +zetacored query crosschain update_rate_limit_flags [flags] +``` + +### Options + +``` + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) + -h, --help help for update_rate_limit_flags + --node string [host]:[port] to Tendermint RPC interface for this chain + -o, --output string Output format (text|json) +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query crosschain](zetacored_query_crosschain.md) - Querying commands for the crosschain module + diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index a35e40ae93..f18907f74f 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -27187,6 +27187,21 @@ paths: $ref: '#/definitions/googlerpcStatus' tags: - Query + /zeta-chain/crosschain/rateLimiterFlags: + get: + summary: Queries the rate limiter flags + operationId: Query_RateLimiterFlags + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/crosschainQueryRateLimiterFlagsResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + tags: + - Query /zeta-chain/crosschain/zetaAccounting: get: operationId: Query_ZetaAccounting @@ -53614,6 +53629,13 @@ definitions: - PendingRevert: outbound cannot succeed; should revert inbound - Reverted: inbound reverted. - Aborted: inbound tx error or invalid paramters and cannot revert; just abort. But the amount can be refunded to zetachain using and admin proposal + crosschainConversion: + type: object + properties: + zrc20: + type: string + rate: + type: string crosschainCrossChainTx: type: object properties: @@ -53743,6 +53765,8 @@ definitions: type: object crosschainMsgRemoveFromOutTxTrackerResponse: type: object + crosschainMsgUpdateRateLimiterFlagsResponse: + type: object crosschainMsgUpdateTssAddressResponse: type: object crosschainMsgVoteGasPriceResponse: @@ -53962,11 +53986,34 @@ definitions: properties: feeInZeta: type: string + crosschainQueryRateLimiterFlagsResponse: + type: object + properties: + rateLimiterFlags: + $ref: '#/definitions/crosschainRateLimiterFlags' crosschainQueryZetaAccountingResponse: type: object properties: aborted_zeta_amount: type: string + crosschainRateLimiterFlags: + type: object + properties: + enabled: + type: boolean + window: + type: string + format: int64 + title: window in blocks + rate: + type: string + title: rate in azeta per block + conversions: + type: array + items: + type: object + $ref: '#/definitions/crosschainConversion' + title: conversion in azeta per token crosschainTxFinalizationStatus: type: string enum: diff --git a/docs/spec/crosschain/messages.md b/docs/spec/crosschain/messages.md index 068c8c8597..549b719407 100644 --- a/docs/spec/crosschain/messages.md +++ b/docs/spec/crosschain/messages.md @@ -260,3 +260,15 @@ message MsgRefundAbortedCCTX { } ``` +## MsgUpdateRateLimiterFlags + +UpdateRateLimiterFlags updates the rate limiter flags. +Authorized: admin policy operational. + +```proto +message MsgUpdateRateLimiterFlags { + string creator = 1; + RateLimiterFlags rate_limiter_flags = 2; +} +``` + diff --git a/proto/crosschain/genesis.proto b/proto/crosschain/genesis.proto index 2d5d96c3a9..9213a128a5 100644 --- a/proto/crosschain/genesis.proto +++ b/proto/crosschain/genesis.proto @@ -7,6 +7,7 @@ import "crosschain/in_tx_hash_to_cctx.proto"; import "crosschain/in_tx_tracker.proto"; import "crosschain/last_block_height.proto"; import "crosschain/out_tx_tracker.proto"; +import "crosschain/rate_limiter_flags.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types"; @@ -21,4 +22,5 @@ message GenesisState { repeated InTxTracker in_tx_tracker_list = 11 [(gogoproto.nullable) = false]; ZetaAccounting zeta_accounting = 12 [(gogoproto.nullable) = false]; repeated string FinalizedInbounds = 16; + RateLimiterFlags rate_limiter_flags = 17 [(gogoproto.nullable) = false]; } diff --git a/proto/crosschain/query.proto b/proto/crosschain/query.proto index 99ad6b4b72..326b615560 100644 --- a/proto/crosschain/query.proto +++ b/proto/crosschain/query.proto @@ -8,6 +8,7 @@ import "crosschain/in_tx_hash_to_cctx.proto"; import "crosschain/in_tx_tracker.proto"; import "crosschain/last_block_height.proto"; import "crosschain/out_tx_tracker.proto"; +import "crosschain/rate_limiter_flags.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; @@ -106,6 +107,11 @@ service Query { rpc LastZetaHeight(QueryLastZetaHeightRequest) returns (QueryLastZetaHeightResponse) { option (google.api.http).get = "/zeta-chain/crosschain/lastZetaHeight"; } + + // Queries the rate limiter flags + rpc RateLimiterFlags(QueryRateLimiterFlagsRequest) returns (QueryRateLimiterFlagsResponse) { + option (google.api.http).get = "/zeta-chain/crosschain/rateLimiterFlags"; + } } message QueryZetaAccountingRequest {} @@ -274,3 +280,9 @@ message QueryMessagePassingProtocolFeeRequest {} message QueryMessagePassingProtocolFeeResponse { string feeInZeta = 1; } + +message QueryRateLimiterFlagsRequest {} + +message QueryRateLimiterFlagsResponse { + RateLimiterFlags rateLimiterFlags = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/crosschain/rate_limiter_flags.proto b/proto/crosschain/rate_limiter_flags.proto new file mode 100644 index 0000000000..0e8185713b --- /dev/null +++ b/proto/crosschain/rate_limiter_flags.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package zetachain.zetacore.crosschain; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types"; + +message RateLimiterFlags { + bool enabled = 1; + + // window in blocks + int64 window = 2; + + // rate in azeta per block + string rate = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", + (gogoproto.nullable) = false + ]; + + // conversion in azeta per token + repeated Conversion conversions = 4 [(gogoproto.nullable) = false]; +} + +message Conversion { + string zrc20 = 1; + string rate = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/crosschain/tx.proto b/proto/crosschain/tx.proto index ab33e1e1bb..31a6ead988 100644 --- a/proto/crosschain/tx.proto +++ b/proto/crosschain/tx.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package zetachain.zetacore.crosschain; +import "crosschain/rate_limiter_flags.proto"; import "gogoproto/gogo.proto"; import "pkg/chains/chains.proto"; import "pkg/coin/coin.proto"; @@ -23,6 +24,8 @@ service Msg { rpc AbortStuckCCTX(MsgAbortStuckCCTX) returns (MsgAbortStuckCCTXResponse); rpc RefundAbortedCCTX(MsgRefundAbortedCCTX) returns (MsgRefundAbortedCCTXResponse); + + rpc UpdateRateLimiterFlags(MsgUpdateRateLimiterFlags) returns (MsgUpdateRateLimiterFlagsResponse); } message MsgMigrateTssFunds { @@ -164,3 +167,10 @@ message MsgRefundAbortedCCTX { } message MsgRefundAbortedCCTXResponse {} + +message MsgUpdateRateLimiterFlags { + string creator = 1; + RateLimiterFlags rate_limiter_flags = 2 [(gogoproto.nullable) = false]; +} + +message MsgUpdateRateLimiterFlagsResponse {} diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index 0040a7fc3a..f7b563d2bf 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -5,6 +5,8 @@ import ( "math/rand" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/math" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" @@ -14,6 +16,38 @@ import ( "github.com/zeta-chain/zetacore/x/crosschain/types" ) +func RateLimiterFlags() types.RateLimiterFlags { + r := Rand() + + return types.RateLimiterFlags{ + Enabled: true, + Window: r.Int63(), + Rate: sdk.NewUint(r.Uint64()), + Conversions: []types.Conversion{ + { + Zrc20: EthAddress().Hex(), + Rate: sdk.NewDec(r.Int63()), + }, + { + Zrc20: EthAddress().Hex(), + Rate: sdk.NewDec(r.Int63()), + }, + { + Zrc20: EthAddress().Hex(), + Rate: sdk.NewDec(r.Int63()), + }, + { + Zrc20: EthAddress().Hex(), + Rate: sdk.NewDec(r.Int63()), + }, + { + Zrc20: EthAddress().Hex(), + Rate: sdk.NewDec(r.Int63()), + }, + }, + } +} + func OutTxTracker(t *testing.T, index string) types.OutTxTracker { r := newRandFromStringSeed(t, index) diff --git a/typescript/crosschain/genesis_pb.d.ts b/typescript/crosschain/genesis_pb.d.ts index 08d35e3746..9ff48d6f47 100644 --- a/typescript/crosschain/genesis_pb.d.ts +++ b/typescript/crosschain/genesis_pb.d.ts @@ -11,6 +11,7 @@ import type { CrossChainTx, ZetaAccounting } from "./cross_chain_tx_pb.js"; import type { LastBlockHeight } from "./last_block_height_pb.js"; import type { InTxHashToCctx } from "./in_tx_hash_to_cctx_pb.js"; import type { InTxTracker } from "./in_tx_tracker_pb.js"; +import type { RateLimiterFlags } from "./rate_limiter_flags_pb.js"; /** * GenesisState defines the metacore module's genesis state. @@ -58,6 +59,11 @@ export declare class GenesisState extends Message { */ FinalizedInbounds: string[]; + /** + * @generated from field: zetachain.zetacore.crosschain.RateLimiterFlags rate_limiter_flags = 17; + */ + rateLimiterFlags?: RateLimiterFlags; + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; diff --git a/typescript/crosschain/index.d.ts b/typescript/crosschain/index.d.ts index e357b4b8b3..0f542908cb 100644 --- a/typescript/crosschain/index.d.ts +++ b/typescript/crosschain/index.d.ts @@ -7,4 +7,5 @@ export * from "./in_tx_tracker_pb"; export * from "./last_block_height_pb"; export * from "./out_tx_tracker_pb"; export * from "./query_pb"; +export * from "./rate_limiter_flags_pb"; export * from "./tx_pb"; diff --git a/typescript/crosschain/query_pb.d.ts b/typescript/crosschain/query_pb.d.ts index 370926427e..e73ef4394d 100644 --- a/typescript/crosschain/query_pb.d.ts +++ b/typescript/crosschain/query_pb.d.ts @@ -12,6 +12,7 @@ import type { InTxHashToCctx } from "./in_tx_hash_to_cctx_pb.js"; import type { CrossChainTx } from "./cross_chain_tx_pb.js"; import type { GasPrice } from "./gas_price_pb.js"; import type { LastBlockHeight } from "./last_block_height_pb.js"; +import type { RateLimiterFlags } from "./rate_limiter_flags_pb.js"; /** * @generated from message zetachain.zetacore.crosschain.QueryZetaAccountingRequest @@ -1019,3 +1020,46 @@ export declare class QueryMessagePassingProtocolFeeResponse extends Message | undefined, b: QueryMessagePassingProtocolFeeResponse | PlainMessage | undefined): boolean; } +/** + * @generated from message zetachain.zetacore.crosschain.QueryRateLimiterFlagsRequest + */ +export declare class QueryRateLimiterFlagsRequest extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.QueryRateLimiterFlagsRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryRateLimiterFlagsRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryRateLimiterFlagsRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryRateLimiterFlagsRequest; + + static equals(a: QueryRateLimiterFlagsRequest | PlainMessage | undefined, b: QueryRateLimiterFlagsRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.crosschain.QueryRateLimiterFlagsResponse + */ +export declare class QueryRateLimiterFlagsResponse extends Message { + /** + * @generated from field: zetachain.zetacore.crosschain.RateLimiterFlags rateLimiterFlags = 1; + */ + rateLimiterFlags?: RateLimiterFlags; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.QueryRateLimiterFlagsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryRateLimiterFlagsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryRateLimiterFlagsResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryRateLimiterFlagsResponse; + + static equals(a: QueryRateLimiterFlagsResponse | PlainMessage | undefined, b: QueryRateLimiterFlagsResponse | PlainMessage | undefined): boolean; +} + diff --git a/typescript/crosschain/rate_limiter_flags_pb.d.ts b/typescript/crosschain/rate_limiter_flags_pb.d.ts new file mode 100644 index 0000000000..02997cd099 --- /dev/null +++ b/typescript/crosschain/rate_limiter_flags_pb.d.ts @@ -0,0 +1,82 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file crosschain/rate_limiter_flags.proto (package zetachain.zetacore.crosschain, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message zetachain.zetacore.crosschain.RateLimiterFlags + */ +export declare class RateLimiterFlags extends Message { + /** + * @generated from field: bool enabled = 1; + */ + enabled: boolean; + + /** + * window in blocks + * + * @generated from field: int64 window = 2; + */ + window: bigint; + + /** + * rate in azeta per block + * + * @generated from field: string rate = 3; + */ + rate: string; + + /** + * conversion in azeta per token + * + * @generated from field: repeated zetachain.zetacore.crosschain.Conversion conversions = 4; + */ + conversions: Conversion[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.RateLimiterFlags"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): RateLimiterFlags; + + static fromJson(jsonValue: JsonValue, options?: Partial): RateLimiterFlags; + + static fromJsonString(jsonString: string, options?: Partial): RateLimiterFlags; + + static equals(a: RateLimiterFlags | PlainMessage | undefined, b: RateLimiterFlags | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.crosschain.Conversion + */ +export declare class Conversion extends Message { + /** + * @generated from field: string zrc20 = 1; + */ + zrc20: string; + + /** + * @generated from field: string rate = 2; + */ + rate: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.Conversion"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): Conversion; + + static fromJson(jsonValue: JsonValue, options?: Partial): Conversion; + + static fromJsonString(jsonString: string, options?: Partial): Conversion; + + static equals(a: Conversion | PlainMessage | undefined, b: Conversion | PlainMessage | undefined): boolean; +} + diff --git a/typescript/crosschain/tx_pb.d.ts b/typescript/crosschain/tx_pb.d.ts index b7a76801dd..c43d5da4bc 100644 --- a/typescript/crosschain/tx_pb.d.ts +++ b/typescript/crosschain/tx_pb.d.ts @@ -8,6 +8,7 @@ import { Message, proto3 } from "@bufbuild/protobuf"; import type { CoinType } from "../pkg/coin/coin_pb.js"; import type { Proof } from "../pkg/proofs/proofs_pb.js"; import type { ReceiveStatus } from "../pkg/chains/chains_pb.js"; +import type { RateLimiterFlags } from "./rate_limiter_flags_pb.js"; /** * @generated from message zetachain.zetacore.crosschain.MsgMigrateTssFunds @@ -777,3 +778,51 @@ export declare class MsgRefundAbortedCCTXResponse extends Message | undefined, b: MsgRefundAbortedCCTXResponse | PlainMessage | undefined): boolean; } +/** + * @generated from message zetachain.zetacore.crosschain.MsgUpdateRateLimiterFlags + */ +export declare class MsgUpdateRateLimiterFlags extends Message { + /** + * @generated from field: string creator = 1; + */ + creator: string; + + /** + * @generated from field: zetachain.zetacore.crosschain.RateLimiterFlags rate_limiter_flags = 2; + */ + rateLimiterFlags?: RateLimiterFlags; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.MsgUpdateRateLimiterFlags"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateRateLimiterFlags; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateRateLimiterFlags; + + static fromJsonString(jsonString: string, options?: Partial): MsgUpdateRateLimiterFlags; + + static equals(a: MsgUpdateRateLimiterFlags | PlainMessage | undefined, b: MsgUpdateRateLimiterFlags | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.crosschain.MsgUpdateRateLimiterFlagsResponse + */ +export declare class MsgUpdateRateLimiterFlagsResponse extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.MsgUpdateRateLimiterFlagsResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateRateLimiterFlagsResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateRateLimiterFlagsResponse; + + static fromJsonString(jsonString: string, options?: Partial): MsgUpdateRateLimiterFlagsResponse; + + static equals(a: MsgUpdateRateLimiterFlagsResponse | PlainMessage | undefined, b: MsgUpdateRateLimiterFlagsResponse | PlainMessage | undefined): boolean; +} + diff --git a/x/crosschain/client/cli/query.go b/x/crosschain/client/cli/query.go index cd966e55af..9f9ae29752 100644 --- a/x/crosschain/client/cli/query.go +++ b/x/crosschain/client/cli/query.go @@ -3,14 +3,8 @@ package cli import ( "fmt" - // "strings" - "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" - - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -42,6 +36,8 @@ func GetQueryCmd(_ string) *cobra.Command { CmdListInTxTrackerByChain(), CmdListInTxTrackers(), CmdGetZetaAccounting(), + + CmdShowUpdateRateLimiterFlags(), ) return cmd diff --git a/x/crosschain/client/cli/query_rate_limiter_flags.go b/x/crosschain/client/cli/query_rate_limiter_flags.go new file mode 100644 index 0000000000..43377e8b50 --- /dev/null +++ b/x/crosschain/client/cli/query_rate_limiter_flags.go @@ -0,0 +1,33 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func CmdShowUpdateRateLimiterFlags() *cobra.Command { + cmd := &cobra.Command{ + Use: "update_rate_limit_flags", + Short: "shows the rate limiter flags", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.RateLimiterFlags(context.Background(), &types.QueryRateLimiterFlagsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/crosschain/genesis.go b/x/crosschain/genesis.go index c2603532a6..895ca05639 100644 --- a/x/crosschain/genesis.go +++ b/x/crosschain/genesis.go @@ -50,6 +50,8 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.FinalizedInbounds { k.SetFinalizedInbound(ctx, elem) } + + k.SetRateLimiterFlags(ctx, genState.RateLimiterFlags) } // ExportGenesis returns the crosschain module's exported genesis. @@ -87,5 +89,10 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { } genesis.FinalizedInbounds = k.GetAllFinalizedInbound(ctx) + rateLimiterFlags, found := k.GetRateLimiterFlags(ctx) + if found { + genesis.RateLimiterFlags = rateLimiterFlags + } + return &genesis } diff --git a/x/crosschain/genesis_test.go b/x/crosschain/genesis_test.go index 470d07b09b..bc624baf29 100644 --- a/x/crosschain/genesis_test.go +++ b/x/crosschain/genesis_test.go @@ -49,6 +49,7 @@ func TestGenesis(t *testing.T) { sample.InTxHashToCctx(t, "0x1"), sample.InTxHashToCctx(t, "0x2"), }, + RateLimiterFlags: sample.RateLimiterFlags(), } // Init and export diff --git a/x/crosschain/keeper/grpc_query_rate_limiter_flags.go b/x/crosschain/keeper/grpc_query_rate_limiter_flags.go new file mode 100644 index 0000000000..998b9cf0a2 --- /dev/null +++ b/x/crosschain/keeper/grpc_query_rate_limiter_flags.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/crosschain/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// RateLimiterFlags queries the rate limiter flags +func (k Keeper) RateLimiterFlags(c context.Context, req *types.QueryRateLimiterFlagsRequest) (*types.QueryRateLimiterFlagsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(c) + + rateLimiterFlags, found := k.GetRateLimiterFlags(ctx) + if !found { + return nil, status.Error(codes.Internal, "not found") + } + + return &types.QueryRateLimiterFlagsResponse{RateLimiterFlags: rateLimiterFlags}, nil +} diff --git a/x/crosschain/keeper/grpc_query_rate_limiter_flags_test.go b/x/crosschain/keeper/grpc_query_rate_limiter_flags_test.go new file mode 100644 index 0000000000..66aaf2d751 --- /dev/null +++ b/x/crosschain/keeper/grpc_query_rate_limiter_flags_test.go @@ -0,0 +1,46 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestKeeper_RateLimiterFlags(t *testing.T) { + t.Run("should error if req is nil", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.RateLimiterFlags(wctx, nil) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should error if rate limiter flags not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + res, err := k.RateLimiterFlags(wctx, &types.QueryRateLimiterFlagsRequest{}) + require.Nil(t, res) + require.Error(t, err) + }) + + t.Run("should return if rate limiter flags found", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + + flags := sample.RateLimiterFlags() + k.SetRateLimiterFlags(ctx, flags) + + res, err := k.RateLimiterFlags(wctx, &types.QueryRateLimiterFlagsRequest{}) + + require.NoError(t, err) + require.Equal(t, &types.QueryRateLimiterFlagsResponse{ + RateLimiterFlags: flags, + }, res) + }) +} diff --git a/x/crosschain/keeper/msg_server_update_rate_limiter_flags.go b/x/crosschain/keeper/msg_server_update_rate_limiter_flags.go new file mode 100644 index 0000000000..357bbfa7fc --- /dev/null +++ b/x/crosschain/keeper/msg_server_update_rate_limiter_flags.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + "fmt" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// UpdateRateLimiterFlags updates the rate limiter flags. +// Authorized: admin policy operational. +func (k msgServer) UpdateRateLimiterFlags(goCtx context.Context, msg *types.MsgUpdateRateLimiterFlags) (*types.MsgUpdateRateLimiterFlagsResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if !k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupOperational) { + return nil, errorsmod.Wrap(authoritytypes.ErrUnauthorized, fmt.Sprintf("Creator %s", msg.Creator)) + } + + k.SetRateLimiterFlags(ctx, msg.RateLimiterFlags) + + return &types.MsgUpdateRateLimiterFlagsResponse{}, nil +} diff --git a/x/crosschain/keeper/msg_server_update_rate_limiter_flags_test.go b/x/crosschain/keeper/msg_server_update_rate_limiter_flags_test.go new file mode 100644 index 0000000000..53b1d6772d --- /dev/null +++ b/x/crosschain/keeper/msg_server_update_rate_limiter_flags_test.go @@ -0,0 +1,57 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/crosschain/keeper" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestMsgServer_UpdateRateLimiterFlags(t *testing.T) { + t.Run("can update rate limiter flags", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + + _, found := k.GetRateLimiterFlags(ctx) + require.False(t, found) + + flags := sample.RateLimiterFlags() + + _, err := msgServer.UpdateRateLimiterFlags(ctx, types.NewMsgUpdateRateLimiterFlags( + admin, + flags, + )) + require.NoError(t, err) + + storedFlags, found := k.GetRateLimiterFlags(ctx) + require.True(t, found) + require.Equal(t, flags, storedFlags) + }) + + t.Run("cannot update rate limiter flags if unauthorized", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ + UseAuthorityMock: true, + }) + msgServer := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + + authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) + + _, err := msgServer.UpdateRateLimiterFlags(ctx, types.NewMsgUpdateRateLimiterFlags( + admin, + sample.RateLimiterFlags(), + )) + require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) + }) +} diff --git a/x/crosschain/keeper/rate_limiter_flags.go b/x/crosschain/keeper/rate_limiter_flags.go new file mode 100644 index 0000000000..d0d7e2febc --- /dev/null +++ b/x/crosschain/keeper/rate_limiter_flags.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// SetRateLimiterFlags set the rate limiter flags in the store +func (k Keeper) SetRateLimiterFlags(ctx sdk.Context, rateLimiterFlags types.RateLimiterFlags) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RateLimiterFlagsKey)) + b := k.cdc.MustMarshal(&rateLimiterFlags) + store.Set([]byte{0}, b) +} + +// GetRateLimiterFlags returns the rate limiter flags +func (k Keeper) GetRateLimiterFlags(ctx sdk.Context) (val types.RateLimiterFlags, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RateLimiterFlagsKey)) + + b := store.Get([]byte{0}) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} diff --git a/x/crosschain/keeper/rate_limiter_flags_test.go b/x/crosschain/keeper/rate_limiter_flags_test.go new file mode 100644 index 0000000000..044d02bc67 --- /dev/null +++ b/x/crosschain/keeper/rate_limiter_flags_test.go @@ -0,0 +1,24 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" +) + +func TestKeeper_GetRateLimiterFlags(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + + // not found + _, found := k.GetRateLimiterFlags(ctx) + require.False(t, found) + + flags := sample.RateLimiterFlags() + + k.SetRateLimiterFlags(ctx, flags) + r, found := k.GetRateLimiterFlags(ctx) + require.True(t, found) + require.Equal(t, flags, r) +} diff --git a/x/crosschain/types/codec.go b/x/crosschain/types/codec.go index 757cb73ad7..2f0bcc0eb0 100644 --- a/x/crosschain/types/codec.go +++ b/x/crosschain/types/codec.go @@ -18,6 +18,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgMigrateTssFunds{}, "crosschain/MigrateTssFunds", nil) cdc.RegisterConcrete(&MsgUpdateTssAddress{}, "crosschain/UpdateTssAddress", nil) cdc.RegisterConcrete(&MsgAbortStuckCCTX{}, "crosschain/AbortStuckCCTX", nil) + cdc.RegisterConcrete(&MsgUpdateRateLimiterFlags{}, "crosschain/UpdateRateLimiterFlags", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -32,6 +33,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgMigrateTssFunds{}, &MsgUpdateTssAddress{}, &MsgAbortStuckCCTX{}, + &MsgUpdateRateLimiterFlags{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index 0578e68fa6..1b80e4fe19 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -41,5 +41,6 @@ var ( ErrUnableProcessRefund = errorsmod.Register(ModuleName, 1148, "unable to process refund") ErrUnableToFindZetaAccounting = errorsmod.Register(ModuleName, 1149, "unable to find zeta accounting") ErrInsufficientZetaAmount = errorsmod.Register(ModuleName, 1150, "insufficient zeta amount") - ErrMaxTxOutTrackerHashesReached = errorsmod.Register(ModuleName, 1151, "max tx out tracker hashes reached") + ErrInvalidRateLimiterFlags = errorsmod.Register(ModuleName, 1151, "invalid rate limiter flags") + ErrMaxTxOutTrackerHashesReached = errorsmod.Register(ModuleName, 1152, "max tx out tracker hashes reached") ) diff --git a/x/crosschain/types/genesis.go b/x/crosschain/types/genesis.go index 23343133c8..834e4ddb9d 100644 --- a/x/crosschain/types/genesis.go +++ b/x/crosschain/types/genesis.go @@ -7,9 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// DefaultIndex is the default crosschain global index -const DefaultIndex uint64 = 1 - // DefaultGenesis returns the default crosschain genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ @@ -44,7 +41,6 @@ func (gs GenesisState) Validate() error { } inTxHashToCctxIndexMap[index] = struct{}{} } - // TODO add migrate for TSS // Check for duplicated index in gasPrice gasPriceIndexMap := make(map[string]bool) @@ -56,17 +52,7 @@ func (gs GenesisState) Validate() error { gasPriceIndexMap[elem.Index] = true } - // Check for duplicated index in send - //sendIndexMap := make(map[string]bool) - - //for _, elem := range gs.SendList { - // if _, ok := sendIndexMap[elem.Index]; ok { - // return fmt.Errorf("duplicated index for send") - // } - // sendIndexMap[elem.Index] = true - //} - - return nil + return gs.RateLimiterFlags.Validate() } func GetGenesisStateFromAppState(marshaler codec.JSONCodec, appState map[string]json.RawMessage) GenesisState { diff --git a/x/crosschain/types/genesis.pb.go b/x/crosschain/types/genesis.pb.go index d7511b155d..8045b2d098 100644 --- a/x/crosschain/types/genesis.pb.go +++ b/x/crosschain/types/genesis.pb.go @@ -34,6 +34,7 @@ type GenesisState struct { InTxTrackerList []InTxTracker `protobuf:"bytes,11,rep,name=in_tx_tracker_list,json=inTxTrackerList,proto3" json:"in_tx_tracker_list"` ZetaAccounting ZetaAccounting `protobuf:"bytes,12,opt,name=zeta_accounting,json=zetaAccounting,proto3" json:"zeta_accounting"` FinalizedInbounds []string `protobuf:"bytes,16,rep,name=FinalizedInbounds,proto3" json:"FinalizedInbounds,omitempty"` + RateLimiterFlags RateLimiterFlags `protobuf:"bytes,17,opt,name=rate_limiter_flags,json=rateLimiterFlags,proto3" json:"rate_limiter_flags"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -125,6 +126,13 @@ func (m *GenesisState) GetFinalizedInbounds() []string { return nil } +func (m *GenesisState) GetRateLimiterFlags() RateLimiterFlags { + if m != nil { + return m.RateLimiterFlags + } + return RateLimiterFlags{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "zetachain.zetacore.crosschain.GenesisState") } @@ -132,37 +140,39 @@ func init() { func init() { proto.RegisterFile("crosschain/genesis.proto", fileDescriptor_dd51403692d571f4) } var fileDescriptor_dd51403692d571f4 = []byte{ - // 465 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x5b, 0xc6, 0x80, 0x79, 0x85, 0x0d, 0xc3, 0x21, 0xaa, 0x44, 0x56, 0x8d, 0x03, 0x13, - 0xb0, 0x44, 0xc0, 0x27, 0xa0, 0x95, 0xd8, 0xa6, 0x4d, 0x02, 0x42, 0x4e, 0x13, 0x93, 0x71, 0x3c, - 0x2b, 0xb1, 0x16, 0xec, 0x2a, 0x7e, 0x91, 0x42, 0x3f, 0x05, 0xdf, 0x88, 0xeb, 0x8e, 0x3b, 0x72, - 0x42, 0xa8, 0xfd, 0x22, 0xc8, 0x4e, 0x18, 0x8e, 0x32, 0xd1, 0xde, 0x9e, 0xfc, 0xde, 0xff, 0xf7, - 0x7f, 0xf9, 0x3b, 0x46, 0x1e, 0x2b, 0x94, 0xd6, 0x2c, 0xa3, 0x42, 0x86, 0x29, 0x97, 0x5c, 0x0b, - 0x1d, 0x4c, 0x0b, 0x05, 0x0a, 0x3f, 0x99, 0x71, 0xa0, 0xb6, 0x11, 0xd8, 0x4a, 0x15, 0x3c, 0xf8, - 0x37, 0x3c, 0xdc, 0x71, 0x84, 0xb6, 0x24, 0xb6, 0x26, 0x50, 0xd5, 0xfa, 0xe1, 0xd0, 0x25, 0x53, - 0x4d, 0xa6, 0x85, 0x60, 0xbc, 0xe9, 0x3d, 0x75, 0x7a, 0x56, 0x43, 0x32, 0xaa, 0x33, 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, 0x71, 0xfe, 0x01, 0x92, 0x1b, 0x93, 0x4d, 0x6b, 0xf2, 0x7c, 0x05, - 0x93, 0xf6, 0x35, 0x6e, 0x09, 0xd9, 0xbe, 0xc5, 0xcf, 0x68, 0xcb, 0x28, 0x09, 0x65, 0x4c, 0x95, - 0x12, 0x84, 0x4c, 0xbd, 0xc1, 0xa8, 0xbf, 0xc2, 0x07, 0x9c, 0x72, 0xa0, 0x6f, 0xaf, 0x45, 0x0d, - 0xfe, 0xc1, 0xac, 0x75, 0x8a, 0x5f, 0xa2, 0x87, 0xef, 0x84, 0xa4, 0xb9, 0x98, 0xf1, 0xf3, 0x23, - 0x99, 0xa8, 0x52, 0x9e, 0x6b, 0x6f, 0x7b, 0xb4, 0xb6, 0xb7, 0x11, 0x75, 0x1b, 0xe3, 0xe3, 0xcb, - 0xb9, 0xdf, 0xbf, 0x9a, 0xfb, 0xfd, 0xdf, 0x73, 0xbf, 0xff, 0x7d, 0xe1, 0xf7, 0xae, 0x16, 0x7e, - 0xef, 0xe7, 0xc2, 0xef, 0x9d, 0xbe, 0x4a, 0x05, 0x64, 0x65, 0x12, 0x30, 0xf5, 0x35, 0x34, 0x16, - 0xfb, 0xf5, 0xeb, 0xf8, 0xbb, 0x57, 0x58, 0x85, 0xce, 0x9b, 0x81, 0x6f, 0x53, 0xae, 0x93, 0x3b, - 0xf6, 0x55, 0xbc, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff, 0x28, 0xc8, 0xb0, 0x72, 0x2d, 0x04, 0x00, - 0x00, + // 507 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xdf, 0x6e, 0xd3, 0x30, + 0x14, 0xc6, 0x5b, 0x06, 0x83, 0x79, 0x85, 0x6d, 0x86, 0x8b, 0xa8, 0x12, 0x59, 0x35, 0x2e, 0x98, + 0x80, 0x25, 0x02, 0x9e, 0x80, 0x55, 0xda, 0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 0xe7, 0xda, 0xdb, 0xec, 0xad, 0xec, 0xae, 0x45, 0xcd, 0x84, + 0x99, 0x67, 0xf3, 0xcd, 0x7b, 0x5b, 0xb6, 0x9d, 0x70, 0x41, 0x3b, 0x11, 0x05, 0x3e, 0x28, 0x75, + 0x07, 0x46, 0x76, 0xf3, 0x6c, 0xd5, 0xbf, 0xe7, 0x27, 0x57, 0x53, 0xbf, 0x7d, 0x3d, 0xf5, 0xdb, + 0xbf, 0xa7, 0x7e, 0xfb, 0xfb, 0xcc, 0x6f, 0x5d, 0xcf, 0xfc, 0xd6, 0xcf, 0x99, 0xdf, 0x3a, 0x7d, + 0x1d, 0x0b, 0x48, 0xf2, 0x51, 0xc0, 0xe4, 0x65, 0x68, 0x2c, 0xf6, 0xca, 0x6f, 0x78, 0xe3, 0x16, + 0x16, 0xa1, 0xf3, 0x39, 0xe1, 0xdb, 0x98, 0xeb, 0xd1, 0xaa, 0xfd, 0x7a, 0x6f, 0xff, 0x04, 0x00, + 0x00, 0xff, 0xff, 0x4d, 0xc1, 0xbb, 0x72, 0xb7, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -185,6 +195,18 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.RateLimiterFlags.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a if len(m.FinalizedInbounds) > 0 { for iNdEx := len(m.FinalizedInbounds) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.FinalizedInbounds[iNdEx]) @@ -354,6 +376,8 @@ func (m *GenesisState) Size() (n int) { n += 2 + l + sovGenesis(uint64(l)) } } + l = m.RateLimiterFlags.Size() + n += 2 + l + sovGenesis(uint64(l)) return n } @@ -661,6 +685,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } m.FinalizedInbounds = append(m.FinalizedInbounds, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 17: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RateLimiterFlags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RateLimiterFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/crosschain/types/genesis_test.go b/x/crosschain/types/genesis_test.go index c3e555fa61..1d09c26488 100644 --- a/x/crosschain/types/genesis_test.go +++ b/x/crosschain/types/genesis_test.go @@ -43,6 +43,7 @@ func TestGenesisState_Validate(t *testing.T) { sample.GasPrice(t, "1"), sample.GasPrice(t, "2"), }, + RateLimiterFlags: sample.RateLimiterFlags(), }, valid: true, }, @@ -60,6 +61,21 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, + { + desc: "duplicated outTxTracker", + genState: &types.GenesisState{ + OutTxTrackerList: []types.OutTxTracker{ + { + Index: "0", + }, + }, + RateLimiterFlags: types.RateLimiterFlags{ + Enabled: true, + Window: -1, + }, + }, + valid: false, + }, { desc: "duplicated inTxHashToCctx", genState: &types.GenesisState{ diff --git a/x/crosschain/types/keys.go b/x/crosschain/types/keys.go index 719f54687f..af888d0324 100644 --- a/x/crosschain/types/keys.go +++ b/x/crosschain/types/keys.go @@ -53,6 +53,8 @@ const ( // #nosec G101: Potential hardcoded credentials (gosec) // ZetaAccountingKey value is used as prefix for storing ZetaAccountingKey ZetaAccountingKey = "ZetaAccounting-value-" + + RateLimiterFlagsKey = "RateLimiterFlags-value-" ) // OutTxTrackerKey returns the store key to retrieve a OutTxTracker from the index fields diff --git a/x/crosschain/types/message_update_rate_limiter_flags.go b/x/crosschain/types/message_update_rate_limiter_flags.go new file mode 100644 index 0000000000..85d3ccf7c4 --- /dev/null +++ b/x/crosschain/types/message_update_rate_limiter_flags.go @@ -0,0 +1,49 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUpdateRateLimiterFlags = "UpdateRateLimiterFlags" + +var _ sdk.Msg = &MsgUpdateRateLimiterFlags{} + +func NewMsgUpdateRateLimiterFlags(creator string, flags RateLimiterFlags) *MsgUpdateRateLimiterFlags { + return &MsgUpdateRateLimiterFlags{ + Creator: creator, + RateLimiterFlags: flags, + } +} + +func (msg *MsgUpdateRateLimiterFlags) Route() string { + return RouterKey +} + +func (msg *MsgUpdateRateLimiterFlags) Type() string { + return TypeMsgUpdateRateLimiterFlags +} + +func (msg *MsgUpdateRateLimiterFlags) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateRateLimiterFlags) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateRateLimiterFlags) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Creator); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + if err := msg.RateLimiterFlags.Validate(); err != nil { + return errorsmod.Wrapf(ErrInvalidRateLimiterFlags, err.Error()) + } + return nil +} diff --git a/x/crosschain/types/message_update_rate_limiter_flags_test.go b/x/crosschain/types/message_update_rate_limiter_flags_test.go new file mode 100644 index 0000000000..9a6f933a8b --- /dev/null +++ b/x/crosschain/types/message_update_rate_limiter_flags_test.go @@ -0,0 +1,97 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestMsgUpdateRateLimiterFlags_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg *types.MsgUpdateRateLimiterFlags + err error + }{ + { + name: "valid message", + msg: types.NewMsgUpdateRateLimiterFlags(sample.AccAddress(), sample.RateLimiterFlags()), + }, + { + name: "invalid creator address", + msg: types.NewMsgUpdateRateLimiterFlags("invalid", sample.RateLimiterFlags()), + err: sdkerrors.ErrInvalidAddress, + }, + { + name: "invalid rate limiter flags", + msg: types.NewMsgUpdateRateLimiterFlags(sample.AccAddress(), types.RateLimiterFlags{ + Window: -1, + }), + err: types.ErrInvalidRateLimiterFlags, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgUpdateRateLimiterFlags_GetSigners(t *testing.T) { + signer := sample.AccAddress() + tests := []struct { + name string + msg *types.MsgUpdateRateLimiterFlags + panics bool + }{ + { + name: "valid signer", + msg: types.NewMsgUpdateRateLimiterFlags(signer, sample.RateLimiterFlags()), + panics: false, + }, + { + name: "invalid signer", + msg: types.NewMsgUpdateRateLimiterFlags("invalid", sample.RateLimiterFlags()), + 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 TestMsgUpdateRateLimiterFlags_Type(t *testing.T) { + msg := types.NewMsgUpdateRateLimiterFlags(sample.AccAddress(), sample.RateLimiterFlags()) + require.Equal(t, types.TypeMsgUpdateRateLimiterFlags, msg.Type()) +} + +func TestMsgUpdateRateLimiterFlags_Route(t *testing.T) { + msg := types.NewMsgUpdateRateLimiterFlags(sample.AccAddress(), sample.RateLimiterFlags()) + require.Equal(t, types.RouterKey, msg.Route()) +} + +func TestMsgUpdateRateLimiterFlags_GetSignBytes(t *testing.T) { + msg := types.NewMsgUpdateRateLimiterFlags(sample.AccAddress(), sample.RateLimiterFlags()) + require.NotPanics(t, func() { + msg.GetSignBytes() + }) +} diff --git a/x/crosschain/types/query.pb.go b/x/crosschain/types/query.pb.go index af554543a3..2add2ae2ae 100644 --- a/x/crosschain/types/query.pb.go +++ b/x/crosschain/types/query.pb.go @@ -1861,6 +1861,86 @@ func (m *QueryMessagePassingProtocolFeeResponse) GetFeeInZeta() string { return "" } +type QueryRateLimiterFlagsRequest struct { +} + +func (m *QueryRateLimiterFlagsRequest) Reset() { *m = QueryRateLimiterFlagsRequest{} } +func (m *QueryRateLimiterFlagsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRateLimiterFlagsRequest) ProtoMessage() {} +func (*QueryRateLimiterFlagsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_65a992045e92a606, []int{39} +} +func (m *QueryRateLimiterFlagsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRateLimiterFlagsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRateLimiterFlagsRequest.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 *QueryRateLimiterFlagsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRateLimiterFlagsRequest.Merge(m, src) +} +func (m *QueryRateLimiterFlagsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryRateLimiterFlagsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRateLimiterFlagsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRateLimiterFlagsRequest proto.InternalMessageInfo + +type QueryRateLimiterFlagsResponse struct { + RateLimiterFlags RateLimiterFlags `protobuf:"bytes,1,opt,name=rateLimiterFlags,proto3" json:"rateLimiterFlags"` +} + +func (m *QueryRateLimiterFlagsResponse) Reset() { *m = QueryRateLimiterFlagsResponse{} } +func (m *QueryRateLimiterFlagsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRateLimiterFlagsResponse) ProtoMessage() {} +func (*QueryRateLimiterFlagsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_65a992045e92a606, []int{40} +} +func (m *QueryRateLimiterFlagsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryRateLimiterFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryRateLimiterFlagsResponse.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 *QueryRateLimiterFlagsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRateLimiterFlagsResponse.Merge(m, src) +} +func (m *QueryRateLimiterFlagsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryRateLimiterFlagsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRateLimiterFlagsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryRateLimiterFlagsResponse proto.InternalMessageInfo + +func (m *QueryRateLimiterFlagsResponse) GetRateLimiterFlags() RateLimiterFlags { + if m != nil { + return m.RateLimiterFlags + } + return RateLimiterFlags{} +} + func init() { proto.RegisterType((*QueryZetaAccountingRequest)(nil), "zetachain.zetacore.crosschain.QueryZetaAccountingRequest") proto.RegisterType((*QueryZetaAccountingResponse)(nil), "zetachain.zetacore.crosschain.QueryZetaAccountingResponse") @@ -1901,120 +1981,127 @@ func init() { proto.RegisterType((*QueryConvertGasToZetaResponse)(nil), "zetachain.zetacore.crosschain.QueryConvertGasToZetaResponse") proto.RegisterType((*QueryMessagePassingProtocolFeeRequest)(nil), "zetachain.zetacore.crosschain.QueryMessagePassingProtocolFeeRequest") proto.RegisterType((*QueryMessagePassingProtocolFeeResponse)(nil), "zetachain.zetacore.crosschain.QueryMessagePassingProtocolFeeResponse") + proto.RegisterType((*QueryRateLimiterFlagsRequest)(nil), "zetachain.zetacore.crosschain.QueryRateLimiterFlagsRequest") + proto.RegisterType((*QueryRateLimiterFlagsResponse)(nil), "zetachain.zetacore.crosschain.QueryRateLimiterFlagsResponse") } func init() { proto.RegisterFile("crosschain/query.proto", fileDescriptor_65a992045e92a606) } var fileDescriptor_65a992045e92a606 = []byte{ - // 1715 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x59, 0xd1, 0x6f, 0x14, 0x45, - 0x18, 0xef, 0xf4, 0x28, 0x94, 0x69, 0xa1, 0x32, 0x54, 0xac, 0x4b, 0x7b, 0x85, 0xad, 0xd0, 0x0a, - 0xf6, 0x16, 0x0a, 0x14, 0x81, 0x62, 0xbc, 0x16, 0x29, 0xc4, 0x02, 0xf5, 0x52, 0xa3, 0xc1, 0x98, - 0xcb, 0x74, 0x6f, 0xdd, 0xdb, 0xb0, 0xdd, 0x29, 0xb7, 0x7b, 0xa4, 0xa5, 0xe9, 0x0b, 0x0f, 0x3e, - 0x9b, 0xf0, 0xe0, 0x8b, 0xaf, 0x46, 0x1f, 0x7c, 0xf0, 0xc1, 0xe8, 0x83, 0x09, 0xc6, 0xa8, 0xc8, - 0x23, 0x89, 0x89, 0x31, 0x9a, 0x18, 0x03, 0xfe, 0x05, 0xfe, 0x05, 0x66, 0x67, 0xbf, 0xbd, 0x9b, - 0xdd, 0xdb, 0xbd, 0x9b, 0x5e, 0x8f, 0x07, 0x9e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0, 0x68, - 0x5e, 0xd7, 0x59, 0xd5, 0xf1, 0x2c, 0xc7, 0x2c, 0x18, 0xb7, 0xab, 0x86, 0xeb, 0xa9, 0xd7, 0xf0, - 0xc1, 0xc4, 0x51, 0x77, 0x95, 0x39, 0xae, 0x41, 0x72, 0x78, 0x3f, 0x5d, 0x66, 0x15, 0xcf, 0x28, - 0x15, 0xfd, 0x2d, 0x28, 0xd2, 0x15, 0x7f, 0xc6, 0x10, 0x3a, 0x84, 0x26, 0x76, 0x17, 0xf6, 0xc1, - 0x10, 0xb7, 0xe5, 0x03, 0x35, 0x77, 0xf3, 0x86, 0x77, 0xa3, 0xea, 0x2d, 0xad, 0x2d, 0x05, 0xf0, - 0x61, 0x35, 0x32, 0x84, 0x77, 0x71, 0x76, 0x57, 0x2f, 0x71, 0x17, 0x99, 0x42, 0xf8, 0x48, 0x06, - 0x71, 0x8f, 0xc3, 0x1c, 0xdd, 0x18, 0xea, 0x3e, 0x84, 0x26, 0x76, 0x14, 0x82, 0x07, 0xb5, 0x8a, - 0x87, 0x93, 0xdd, 0x01, 0xbc, 0x77, 0x71, 0x3f, 0x13, 0xde, 0x73, 0xa7, 0x7d, 0x53, 0xc7, 0x73, - 0x4d, 0x03, 0x27, 0x27, 0xba, 0x9a, 0xdd, 0xf1, 0xe8, 0xef, 0xd1, 0xae, 0x42, 0xc4, 0x8d, 0x6a, - 0x00, 0x8b, 0xbc, 0x6d, 0x27, 0xb1, 0xb8, 0x8c, 0x71, 0x3d, 0xc0, 0x60, 0xcd, 0xa3, 0xb9, 0x20, - 0x1a, 0x73, 0x7e, 0x34, 0xe6, 0x82, 0x28, 0x86, 0x68, 0xcc, 0x2d, 0x52, 0xd3, 0x00, 0xdb, 0x82, - 0x60, 0xa9, 0x3e, 0x40, 0x40, 0xaf, 0x61, 0x9d, 0x54, 0x7a, 0x99, 0x0e, 0xd0, 0x23, 0xf3, 0x11, - 0xfc, 0xdd, 0x1c, 0xff, 0x78, 0x4b, 0xfc, 0x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xcb, 0xc2, - 0xc6, 0x1a, 0x7d, 0x75, 0x8c, 0x63, 0x1d, 0x21, 0x07, 0x9b, 0x60, 0xf5, 0x2b, 0xb0, 0x01, 0xdf, - 0xca, 0x6f, 0x91, 0xa1, 0x43, 0x95, 0x2b, 0xc1, 0x92, 0x9b, 0x74, 0xb9, 0x12, 0x2c, 0xa5, 0x1f, - 0x6f, 0x99, 0x39, 0xf4, 0xba, 0x0d, 0x2f, 0x1d, 0xa3, 0xff, 0x48, 0x96, 0x0b, 0x86, 0xc4, 0x7f, - 0x4d, 0x2b, 0xe7, 0xdb, 0x31, 0x95, 0xfc, 0xaa, 0xdf, 0x8d, 0xa2, 0xf4, 0x81, 0x47, 0xbb, 0x7b, - 0x39, 0xe0, 0x89, 0xf7, 0x05, 0x72, 0xc0, 0x93, 0x2f, 0x13, 0x5a, 0x02, 0xb7, 0x23, 0x66, 0xb3, - 0x6f, 0x3f, 0x7a, 0x92, 0x45, 0x8f, 0x9f, 0x64, 0xd1, 0x3f, 0x4f, 0xb2, 0xe8, 0x93, 0xa7, 0xd9, - 0xae, 0xc7, 0x4f, 0xb3, 0x5d, 0x7f, 0x3c, 0xcd, 0x76, 0xdd, 0x3c, 0x69, 0x5a, 0x5e, 0xb9, 0xba, - 0x9c, 0xd3, 0xd9, 0x8a, 0xe8, 0x2a, 0xc4, 0xa3, 0xad, 0x89, 0x5e, 0xbd, 0xf5, 0x55, 0xc3, 0x5d, - 0xde, 0xc9, 0xbf, 0x02, 0xa7, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0xda, 0xf6, 0xfb, 0xb3, 0x90, - 0x21, 0x00, 0x00, + // 1796 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x59, 0xcf, 0x6f, 0x14, 0xc7, + 0x12, 0x76, 0x7b, 0x31, 0x98, 0xb6, 0xc1, 0xd0, 0xf8, 0xf1, 0xfc, 0x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3a, 0x67, + 0x4c, 0xe1, 0x06, 0x0b, 0x5b, 0x3a, 0x9d, 0xbe, 0xc1, 0xdf, 0x08, 0x37, 0x38, 0xbc, 0xcf, 0xab, + 0x60, 0xa4, 0xcb, 0x78, 0x24, 0x88, 0xae, 0xde, 0x96, 0xd7, 0xa8, 0x53, 0x59, 0xb6, 0xe7, 0x34, + 0x77, 0x3d, 0x30, 0x53, 0x16, 0xf7, 0x1a, 0x30, 0x01, 0x21, 0xbf, 0x3e, 0x56, 0xb6, 0x70, 0x2e, + 0x4d, 0x18, 0xb8, 0xbf, 0x8b, 0xf7, 0x1b, 0xa1, 0x19, 0x30, 0xf4, 0xa4, 0x04, 0xfd, 0x86, 0x10, + 0x58, 0x20, 0xa2, 0x4a, 0x99, 0x81, 0xed, 0xc3, 0x8b, 0xaf, 0x52, 0x97, 0xca, 0x80, 0x7f, 0x80, + 0x47, 0x53, 0xa5, 0x01, 0xfd, 0xdb, 0x78, 0xdf, 0x9c, 0x87, 0x89, 0x3b, 0xfd, 0xf2, 0xba, 0x23, + 0x19, 0x2f, 0x44, 0x19, 0x80, 0x1e, 0xd6, 0xa3, 0xe8, 0x60, 0x75, 0x70, 0x99, 0xb8, 0xd5, 0x3b, + 0xe5, 0x9c, 0x4f, 0x10, 0xd8, 0x28, 0x61, 0xa7, 0x26, 0x47, 0x94, 0xe9, 0xd0, 0x11, 0x75, 0xce, + 0x4f, 0x55, 0xfc, 0xcf, 0xc0, 0xd5, 0x16, 0xa8, 0xb3, 0xe4, 0xa5, 0x6f, 0xc2, 0xd3, 0x62, 0x58, + 0x65, 0xb6, 0x0e, 0x27, 0xec, 0x0f, 0x94, 0x12, 0x1e, 0x8a, 0x0b, 0x00, 0xe5, 0x39, 0xdc, 0x1b, + 0x7c, 0x03, 0xdb, 0x8e, 0xb7, 0x20, 0x5b, 0x57, 0x51, 0x17, 0x54, 0x28, 0x20, 0x2a, 0x98, 0x66, + 0x14, 0x51, 0xa7, 0x4e, 0xef, 0x53, 0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x27, 0x30, 0x71, 0xc8, 0x4f, 0x00, + 0x5c, 0xa8, 0x93, 0x66, 0x24, 0x2f, 0x6f, 0x62, 0xb5, 0x98, 0xbd, 0xd2, 0xa6, 0x34, 0x80, 0xff, + 0x1f, 0x07, 0x3f, 0x45, 0x4e, 0x37, 0x01, 0xdf, 0x10, 0x53, 0x37, 0x83, 0xf1, 0x16, 0xf9, 0x05, + 0x61, 0x12, 0xaf, 0x9f, 0x89, 0x14, 0x9e, 0xd4, 0xaa, 0x3d, 0xfb, 0xff, 0x76, 0xc5, 0x81, 0x4f, + 0x81, 0xf3, 0xb9, 0x4c, 0x2e, 0xa6, 0xf2, 0x89, 0x36, 0xf9, 0x4b, 0x65, 0xea, 0x52, 0x91, 0xd8, + 0xb7, 0x08, 0x1f, 0x0c, 0xef, 0xe0, 0xb9, 0xd7, 0xcc, 0x36, 0x5c, 0xa4, 0xcd, 0x53, 0x4a, 0xad, + 0xd3, 0x95, 0x49, 0xce, 0x6a, 0x9c, 0x1c, 0x97, 0x3a, 0x25, 0xf2, 0x19, 0x6a, 0xd4, 0x87, 0x64, + 0x5a, 0xd2, 0x41, 0x22, 0x85, 0x6c, 0xf6, 0xc2, 0xb6, 0xe5, 0x00, 0xac, 0xca, 0xc1, 0xfe, 0x87, + 0x8c, 0xa7, 0x80, 0xd5, 0x41, 0xc0, 0xb3, 0x79, 0x99, 0xad, 0x6f, 0x91, 0x4f, 0x10, 0xee, 0x0b, + 0xb4, 0x78, 0xa6, 0x9e, 0x96, 0x34, 0x56, 0x5b, 0x88, 0x13, 0xca, 0x69, 0x65, 0x9c, 0x23, 0x3e, + 0x46, 0x46, 0x5b, 0x20, 0x26, 0x8f, 0x11, 0x3e, 0x10, 0xcd, 0xbb, 0x88, 0x54, 0xf0, 0x48, 0x49, + 0x02, 0xb3, 0x33, 0xed, 0x09, 0x4b, 0x9a, 0x5a, 0x8b, 0x62, 0x7d, 0x82, 0x70, 0x9f, 0x90, 0x5a, + 0x91, 0xab, 0x32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, 0xe2, 0xff, 0xcf, 0xb3, 0x97, 0xda, 0x11, + 0x95, 0x7c, 0xd5, 0x1f, 0x84, 0x51, 0x7a, 0xc0, 0xc3, 0x2d, 0x08, 0x39, 0xe0, 0x89, 0x4d, 0x0d, + 0x39, 0xe0, 0xc9, 0x1d, 0x8f, 0x96, 0xc0, 0xcd, 0x30, 0x4a, 0xef, 0xd5, 0x8c, 0x56, 0xc8, 0x72, + 0xaf, 0x66, 0x4a, 0x2d, 0x2f, 0xf7, 0x6a, 0xa6, 0xd5, 0xf9, 0x2d, 0x5f, 0xcd, 0x68, 0xd5, 0x3e, + 0xfb, 0xc6, 0xd3, 0xe7, 0x39, 0xf4, 0xec, 0x79, 0x0e, 0xfd, 0xf9, 0x3c, 0x87, 0x3e, 0x78, 0x91, + 0xeb, 0x7a, 0xf6, 0x22, 0xd7, 0xf5, 0xeb, 0x8b, 0x5c, 0xd7, 0xed, 0x33, 0xba, 0xe1, 0x56, 0x6a, + 0x2b, 0x79, 0xcd, 0x5e, 0x15, 0x95, 0x05, 0x98, 0xd4, 0x75, 0x51, 0xaf, 0xbb, 0xb1, 0xc6, 0x9c, + 0x95, 0xdd, 0xfc, 0x19, 0x3b, 0xfb, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x51, 0x5a, 0xb9, + 0x1b, 0x23, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2063,6 +2150,8 @@ type QueryClient interface { ZetaAccounting(ctx context.Context, in *QueryZetaAccountingRequest, opts ...grpc.CallOption) (*QueryZetaAccountingResponse, error) // Queries a list of lastMetaHeight items. LastZetaHeight(ctx context.Context, in *QueryLastZetaHeightRequest, opts ...grpc.CallOption) (*QueryLastZetaHeightResponse, error) + // Queries the rate limiter flags + RateLimiterFlags(ctx context.Context, in *QueryRateLimiterFlagsRequest, opts ...grpc.CallOption) (*QueryRateLimiterFlagsResponse, error) } type queryClient struct { @@ -2253,6 +2342,15 @@ func (c *queryClient) LastZetaHeight(ctx context.Context, in *QueryLastZetaHeigh return out, nil } +func (c *queryClient) RateLimiterFlags(ctx context.Context, in *QueryRateLimiterFlagsRequest, opts ...grpc.CallOption) (*QueryRateLimiterFlagsResponse, error) { + out := new(QueryRateLimiterFlagsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Query/RateLimiterFlags", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Queries a OutTxTracker by index. @@ -2289,6 +2387,8 @@ type QueryServer interface { ZetaAccounting(context.Context, *QueryZetaAccountingRequest) (*QueryZetaAccountingResponse, error) // Queries a list of lastMetaHeight items. LastZetaHeight(context.Context, *QueryLastZetaHeightRequest) (*QueryLastZetaHeightResponse, error) + // Queries the rate limiter flags + RateLimiterFlags(context.Context, *QueryRateLimiterFlagsRequest) (*QueryRateLimiterFlagsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -2355,6 +2455,9 @@ func (*UnimplementedQueryServer) ZetaAccounting(ctx context.Context, req *QueryZ func (*UnimplementedQueryServer) LastZetaHeight(ctx context.Context, req *QueryLastZetaHeightRequest) (*QueryLastZetaHeightResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method LastZetaHeight not implemented") } +func (*UnimplementedQueryServer) RateLimiterFlags(ctx context.Context, req *QueryRateLimiterFlagsRequest) (*QueryRateLimiterFlagsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RateLimiterFlags not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2720,6 +2823,24 @@ func _Query_LastZetaHeight_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Query_RateLimiterFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRateLimiterFlagsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RateLimiterFlags(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.crosschain.Query/RateLimiterFlags", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RateLimiterFlags(ctx, req.(*QueryRateLimiterFlagsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.crosschain.Query", HandlerType: (*QueryServer)(nil), @@ -2804,6 +2925,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "LastZetaHeight", Handler: _Query_LastZetaHeight_Handler, }, + { + MethodName: "RateLimiterFlags", + Handler: _Query_RateLimiterFlags_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "crosschain/query.proto", @@ -4224,6 +4349,62 @@ func (m *QueryMessagePassingProtocolFeeResponse) MarshalToSizedBuffer(dAtA []byt return len(dAtA) - i, nil } +func (m *QueryRateLimiterFlagsRequest) 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 *QueryRateLimiterFlagsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRateLimiterFlagsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryRateLimiterFlagsResponse) 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 *QueryRateLimiterFlagsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryRateLimiterFlagsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RateLimiterFlags.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -4802,6 +4983,26 @@ func (m *QueryMessagePassingProtocolFeeResponse) Size() (n int) { return n } +func (m *QueryRateLimiterFlagsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryRateLimiterFlagsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.RateLimiterFlags.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -8396,6 +8597,139 @@ func (m *QueryMessagePassingProtocolFeeResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryRateLimiterFlagsRequest) 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 ErrIntOverflowQuery + } + 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: QueryRateLimiterFlagsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRateLimiterFlagsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryRateLimiterFlagsResponse) 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 ErrIntOverflowQuery + } + 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: QueryRateLimiterFlagsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryRateLimiterFlagsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RateLimiterFlags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RateLimiterFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/crosschain/types/query.pb.gw.go b/x/crosschain/types/query.pb.gw.go index 6234a732ea..e25a590184 100644 --- a/x/crosschain/types/query.pb.gw.go +++ b/x/crosschain/types/query.pb.gw.go @@ -941,6 +941,24 @@ func local_request_Query_LastZetaHeight_0(ctx context.Context, marshaler runtime } +func request_Query_RateLimiterFlags_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRateLimiterFlagsRequest + var metadata runtime.ServerMetadata + + msg, err := client.RateLimiterFlags(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RateLimiterFlags_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRateLimiterFlagsRequest + var metadata runtime.ServerMetadata + + msg, err := server.RateLimiterFlags(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -1407,6 +1425,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_RateLimiterFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_RateLimiterFlags_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RateLimiterFlags_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1848,6 +1889,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_RateLimiterFlags_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_RateLimiterFlags_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_RateLimiterFlags_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -1891,6 +1952,8 @@ var ( pattern_Query_ZetaAccounting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "zetaAccounting"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_LastZetaHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "lastZetaHeight"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RateLimiterFlags_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "rateLimiterFlags"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -1933,4 +1996,6 @@ var ( forward_Query_ZetaAccounting_0 = runtime.ForwardResponseMessage forward_Query_LastZetaHeight_0 = runtime.ForwardResponseMessage + + forward_Query_RateLimiterFlags_0 = runtime.ForwardResponseMessage ) diff --git a/x/crosschain/types/rate_limiter_flags.go b/x/crosschain/types/rate_limiter_flags.go new file mode 100644 index 0000000000..93a9617961 --- /dev/null +++ b/x/crosschain/types/rate_limiter_flags.go @@ -0,0 +1,47 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" +) + +// Validate checks that the RateLimiterFlags is valid +func (r RateLimiterFlags) Validate() error { + // window must not be negative + if r.Window < 0 { + return fmt.Errorf("window must be positive: %d", r.Window) + } + + seen := make(map[string]bool) + for _, conversion := range r.Conversions { + // check no duplicated conversion + if _, ok := seen[conversion.Zrc20]; ok { + return fmt.Errorf("duplicated conversion: %s", conversion.Zrc20) + } + seen[conversion.Zrc20] = true + + // check conversion is valid + if conversion.Rate.IsNil() { + return fmt.Errorf("rate is nil for conversion: %s", conversion.Zrc20) + } + + // check address is valid + if !ethcommon.IsHexAddress(conversion.Zrc20) { + return fmt.Errorf("invalid zrc20 address (%s)", conversion.Zrc20) + } + } + + return nil +} + +// GetConversionRate returns the conversion rate for the given zrc20 +func (r RateLimiterFlags) GetConversionRate(zrc20 string) (sdk.Dec, bool) { + for _, conversion := range r.Conversions { + if conversion.Zrc20 == zrc20 { + return conversion.Rate, true + } + } + return sdk.NewDec(0), false +} diff --git a/x/crosschain/types/rate_limiter_flags.pb.go b/x/crosschain/types/rate_limiter_flags.pb.go new file mode 100644 index 0000000000..899a1d7099 --- /dev/null +++ b/x/crosschain/types/rate_limiter_flags.pb.go @@ -0,0 +1,684 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: crosschain/rate_limiter_flags.proto + +package types + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type RateLimiterFlags struct { + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` + // window in blocks + Window int64 `protobuf:"varint,2,opt,name=window,proto3" json:"window,omitempty"` + // rate in azeta per block + Rate github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,3,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"rate"` + // conversion in azeta per token + Conversions []Conversion `protobuf:"bytes,4,rep,name=conversions,proto3" json:"conversions"` +} + +func (m *RateLimiterFlags) Reset() { *m = RateLimiterFlags{} } +func (m *RateLimiterFlags) String() string { return proto.CompactTextString(m) } +func (*RateLimiterFlags) ProtoMessage() {} +func (*RateLimiterFlags) Descriptor() ([]byte, []int) { + return fileDescriptor_b17ae80d5af4e97e, []int{0} +} +func (m *RateLimiterFlags) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RateLimiterFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RateLimiterFlags.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 *RateLimiterFlags) XXX_Merge(src proto.Message) { + xxx_messageInfo_RateLimiterFlags.Merge(m, src) +} +func (m *RateLimiterFlags) XXX_Size() int { + return m.Size() +} +func (m *RateLimiterFlags) XXX_DiscardUnknown() { + xxx_messageInfo_RateLimiterFlags.DiscardUnknown(m) +} + +var xxx_messageInfo_RateLimiterFlags proto.InternalMessageInfo + +func (m *RateLimiterFlags) GetEnabled() bool { + if m != nil { + return m.Enabled + } + return false +} + +func (m *RateLimiterFlags) GetWindow() int64 { + if m != nil { + return m.Window + } + return 0 +} + +func (m *RateLimiterFlags) GetConversions() []Conversion { + if m != nil { + return m.Conversions + } + return nil +} + +type Conversion struct { + Zrc20 string `protobuf:"bytes,1,opt,name=zrc20,proto3" json:"zrc20,omitempty"` + Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate"` +} + +func (m *Conversion) Reset() { *m = Conversion{} } +func (m *Conversion) String() string { return proto.CompactTextString(m) } +func (*Conversion) ProtoMessage() {} +func (*Conversion) Descriptor() ([]byte, []int) { + return fileDescriptor_b17ae80d5af4e97e, []int{1} +} +func (m *Conversion) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Conversion) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Conversion.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 *Conversion) XXX_Merge(src proto.Message) { + xxx_messageInfo_Conversion.Merge(m, src) +} +func (m *Conversion) XXX_Size() int { + return m.Size() +} +func (m *Conversion) XXX_DiscardUnknown() { + xxx_messageInfo_Conversion.DiscardUnknown(m) +} + +var xxx_messageInfo_Conversion proto.InternalMessageInfo + +func (m *Conversion) GetZrc20() string { + if m != nil { + return m.Zrc20 + } + return "" +} + +func init() { + proto.RegisterType((*RateLimiterFlags)(nil), "zetachain.zetacore.crosschain.RateLimiterFlags") + proto.RegisterType((*Conversion)(nil), "zetachain.zetacore.crosschain.Conversion") +} + +func init() { + proto.RegisterFile("crosschain/rate_limiter_flags.proto", fileDescriptor_b17ae80d5af4e97e) +} + +var fileDescriptor_b17ae80d5af4e97e = []byte{ + // 331 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 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 0xc7, 0x54, + 0x4e, 0x08, 0x95, 0x7a, 0x22, 0x75, 0xfe, 0xb4, 0xf5, 0xe0, 0x91, 0x98, 0xd7, 0x29, 0xd3, 0xf8, + 0x9e, 0x0b, 0x13, 0x59, 0x31, 0xba, 0x83, 0x75, 0x2a, 0xc5, 0x33, 0x53, 0x9a, 0x4b, 0xa1, 0xdd, + 0x8a, 0x5f, 0x0e, 0xea, 0x9d, 0x33, 0xfc, 0x6b, 0x2c, 0xdc, 0xfd, 0x51, 0x84, 0x95, 0xf4, 0xdb, + 0xa8, 0xe8, 0xd1, 0x1a, 0x42, 0xb8, 0x3b, 0x40, 0x0d, 0xf8, 0x6f, 0xae, 0x68, 0xe7, 0xdc, 0xa6, + 0xaa, 0x45, 0xd9, 0x82, 0xc2, 0x9c, 0xbd, 0x64, 0xd9, 0x71, 0xce, 0x7e, 0xf2, 0x07, 0xf6, 0x2b, + 0x46, 0x33, 0xf4, 0xf0, 0x66, 0xb1, 0xf6, 0xc0, 0x72, 0xed, 0x81, 0xaf, 0xb5, 0x07, 0xde, 0x36, + 0x9e, 0xb3, 0xdc, 0x78, 0xce, 0xfb, 0xc6, 0x73, 0x1e, 0x2e, 0x0a, 0x3e, 0x29, 0x7f, 0x3b, 0x6b, + 0x71, 0x1b, 0x85, 0xbc, 0x90, 0x42, 0xb7, 0xd6, 0xb6, 0x5f, 0xb5, 0xd5, 0x5c, 0x7e, 0x07, 0x00, + 0x00, 0xff, 0xff, 0xd2, 0x2c, 0x21, 0x90, 0xf6, 0x01, 0x00, 0x00, +} + +func (m *RateLimiterFlags) 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 *RateLimiterFlags) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RateLimiterFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Conversions) > 0 { + for iNdEx := len(m.Conversions) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Conversions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRateLimiterFlags(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + { + size := m.Rate.Size() + i -= size + if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintRateLimiterFlags(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.Window != 0 { + i = encodeVarintRateLimiterFlags(dAtA, i, uint64(m.Window)) + i-- + dAtA[i] = 0x10 + } + if m.Enabled { + i-- + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Conversion) 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 *Conversion) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Conversion) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Rate.Size() + i -= size + if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintRateLimiterFlags(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Zrc20) > 0 { + i -= len(m.Zrc20) + copy(dAtA[i:], m.Zrc20) + i = encodeVarintRateLimiterFlags(dAtA, i, uint64(len(m.Zrc20))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintRateLimiterFlags(dAtA []byte, offset int, v uint64) int { + offset -= sovRateLimiterFlags(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RateLimiterFlags) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Enabled { + n += 2 + } + if m.Window != 0 { + n += 1 + sovRateLimiterFlags(uint64(m.Window)) + } + l = m.Rate.Size() + n += 1 + l + sovRateLimiterFlags(uint64(l)) + if len(m.Conversions) > 0 { + for _, e := range m.Conversions { + l = e.Size() + n += 1 + l + sovRateLimiterFlags(uint64(l)) + } + } + return n +} + +func (m *Conversion) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Zrc20) + if l > 0 { + n += 1 + l + sovRateLimiterFlags(uint64(l)) + } + l = m.Rate.Size() + n += 1 + l + sovRateLimiterFlags(uint64(l)) + return n +} + +func sovRateLimiterFlags(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRateLimiterFlags(x uint64) (n int) { + return sovRateLimiterFlags(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RateLimiterFlags) 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 ErrIntOverflowRateLimiterFlags + } + 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: RateLimiterFlags: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RateLimiterFlags: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRateLimiterFlags + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Window", wireType) + } + m.Window = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRateLimiterFlags + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Window |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRateLimiterFlags + } + 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 ErrInvalidLengthRateLimiterFlags + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRateLimiterFlags + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Conversions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRateLimiterFlags + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRateLimiterFlags + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRateLimiterFlags + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Conversions = append(m.Conversions, Conversion{}) + if err := m.Conversions[len(m.Conversions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRateLimiterFlags(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRateLimiterFlags + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Conversion) 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 ErrIntOverflowRateLimiterFlags + } + 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: Conversion: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Conversion: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Zrc20", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRateLimiterFlags + } + 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 ErrInvalidLengthRateLimiterFlags + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRateLimiterFlags + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Zrc20 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRateLimiterFlags + } + 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 ErrInvalidLengthRateLimiterFlags + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRateLimiterFlags + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRateLimiterFlags(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRateLimiterFlags + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipRateLimiterFlags(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRateLimiterFlags + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRateLimiterFlags + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowRateLimiterFlags + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthRateLimiterFlags + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupRateLimiterFlags + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthRateLimiterFlags + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthRateLimiterFlags = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowRateLimiterFlags = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupRateLimiterFlags = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/crosschain/types/rate_limiter_flags_test.go b/x/crosschain/types/rate_limiter_flags_test.go new file mode 100644 index 0000000000..d837fabc51 --- /dev/null +++ b/x/crosschain/types/rate_limiter_flags_test.go @@ -0,0 +1,186 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestRateLimiterFlags_Validate(t *testing.T) { + dec, err := sdk.NewDecFromStr("0.00042") + require.NoError(t, err) + duplicatedAddress := sample.EthAddress().String() + + tt := []struct { + name string + flags types.RateLimiterFlags + isErr bool + }{ + { + name: "valid flags", + flags: types.RateLimiterFlags{ + Enabled: true, + Window: 42, + Rate: sdk.NewUint(42), + Conversions: []types.Conversion{ + { + Zrc20: sample.EthAddress().String(), + Rate: sdk.NewDec(42), + }, + { + Zrc20: sample.EthAddress().String(), + Rate: dec, + }, + }, + }, + }, + { + name: "empty is valid", + flags: types.RateLimiterFlags{}, + }, + { + name: "invalid zrc20 address", + flags: types.RateLimiterFlags{ + Enabled: true, + Window: 42, + Rate: sdk.NewUint(42), + Conversions: []types.Conversion{ + { + Zrc20: "invalid", + Rate: sdk.NewDec(42), + }, + { + Zrc20: sample.EthAddress().String(), + Rate: dec, + }, + }, + }, + isErr: true, + }, + { + name: "duplicated conversion", + flags: types.RateLimiterFlags{ + Enabled: true, + Window: 42, + Rate: sdk.NewUint(42), + Conversions: []types.Conversion{ + { + Zrc20: duplicatedAddress, + Rate: sdk.NewDec(42), + }, + { + Zrc20: duplicatedAddress, + Rate: dec, + }, + }, + }, + isErr: true, + }, + { + name: "invalid conversion rate", + flags: types.RateLimiterFlags{ + Enabled: true, + Window: 42, + Rate: sdk.NewUint(42), + Conversions: []types.Conversion{ + { + Zrc20: sample.EthAddress().String(), + Rate: sdk.NewDec(42), + }, + { + Zrc20: sample.EthAddress().String(), + }, + }, + }, + isErr: true, + }, + { + name: "negative window", + flags: types.RateLimiterFlags{ + Enabled: true, + Window: -1, + }, + isErr: true, + }, + } + + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + err := tc.flags.Validate() + if tc.isErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } + +} + +func TestRateLimiterFlags_GetConversionRate(t *testing.T) { + dec, err := sdk.NewDecFromStr("0.00042") + require.NoError(t, err) + address := sample.EthAddress().String() + + tt := []struct { + name string + flags types.RateLimiterFlags + zrc20 string + expected sdk.Dec + shouldFind bool + }{ + { + name: "valid conversion", + flags: types.RateLimiterFlags{ + Enabled: true, + Window: 42, + Rate: sdk.NewUint(42), + Conversions: []types.Conversion{ + { + Zrc20: address, + Rate: sdk.NewDec(42), + }, + { + Zrc20: sample.EthAddress().String(), + Rate: dec, + }, + }, + }, + zrc20: address, + expected: sdk.NewDec(42), + shouldFind: true, + }, + { + name: "not found", + flags: types.RateLimiterFlags{ + Enabled: true, + Window: 42, + Rate: sdk.NewUint(42), + Conversions: []types.Conversion{ + { + Zrc20: sample.EthAddress().String(), + Rate: sdk.NewDec(42), + }, + { + Zrc20: sample.EthAddress().String(), + Rate: dec, + }, + }, + }, + zrc20: address, + expected: sdk.NewDec(0), + shouldFind: false, + }, + } + + for _, tc := range tt { + t.Run(tc.name, func(t *testing.T) { + actual, found := tc.flags.GetConversionRate(tc.zrc20) + require.Equal(t, tc.expected, actual) + require.Equal(t, tc.shouldFind, found) + }) + } +} diff --git a/x/crosschain/types/tx.pb.go b/x/crosschain/types/tx.pb.go index 54c8aee125..f7fa9790e4 100644 --- a/x/crosschain/types/tx.pb.go +++ b/x/crosschain/types/tx.pb.go @@ -1344,6 +1344,94 @@ func (m *MsgRefundAbortedCCTXResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRefundAbortedCCTXResponse proto.InternalMessageInfo +type MsgUpdateRateLimiterFlags struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + RateLimiterFlags RateLimiterFlags `protobuf:"bytes,2,opt,name=rate_limiter_flags,json=rateLimiterFlags,proto3" json:"rate_limiter_flags"` +} + +func (m *MsgUpdateRateLimiterFlags) Reset() { *m = MsgUpdateRateLimiterFlags{} } +func (m *MsgUpdateRateLimiterFlags) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateRateLimiterFlags) ProtoMessage() {} +func (*MsgUpdateRateLimiterFlags) Descriptor() ([]byte, []int) { + return fileDescriptor_81d6d611190b7635, []int{22} +} +func (m *MsgUpdateRateLimiterFlags) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateRateLimiterFlags) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateRateLimiterFlags.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 *MsgUpdateRateLimiterFlags) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateRateLimiterFlags.Merge(m, src) +} +func (m *MsgUpdateRateLimiterFlags) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateRateLimiterFlags) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateRateLimiterFlags.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateRateLimiterFlags proto.InternalMessageInfo + +func (m *MsgUpdateRateLimiterFlags) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateRateLimiterFlags) GetRateLimiterFlags() RateLimiterFlags { + if m != nil { + return m.RateLimiterFlags + } + return RateLimiterFlags{} +} + +type MsgUpdateRateLimiterFlagsResponse struct { +} + +func (m *MsgUpdateRateLimiterFlagsResponse) Reset() { *m = MsgUpdateRateLimiterFlagsResponse{} } +func (m *MsgUpdateRateLimiterFlagsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateRateLimiterFlagsResponse) ProtoMessage() {} +func (*MsgUpdateRateLimiterFlagsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_81d6d611190b7635, []int{23} +} +func (m *MsgUpdateRateLimiterFlagsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateRateLimiterFlagsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateRateLimiterFlagsResponse.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 *MsgUpdateRateLimiterFlagsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateRateLimiterFlagsResponse.Merge(m, src) +} +func (m *MsgUpdateRateLimiterFlagsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateRateLimiterFlagsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateRateLimiterFlagsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateRateLimiterFlagsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgMigrateTssFunds)(nil), "zetachain.zetacore.crosschain.MsgMigrateTssFunds") proto.RegisterType((*MsgMigrateTssFundsResponse)(nil), "zetachain.zetacore.crosschain.MsgMigrateTssFundsResponse") @@ -1367,103 +1455,110 @@ func init() { proto.RegisterType((*MsgAbortStuckCCTXResponse)(nil), "zetachain.zetacore.crosschain.MsgAbortStuckCCTXResponse") proto.RegisterType((*MsgRefundAbortedCCTX)(nil), "zetachain.zetacore.crosschain.MsgRefundAbortedCCTX") proto.RegisterType((*MsgRefundAbortedCCTXResponse)(nil), "zetachain.zetacore.crosschain.MsgRefundAbortedCCTXResponse") + proto.RegisterType((*MsgUpdateRateLimiterFlags)(nil), "zetachain.zetacore.crosschain.MsgUpdateRateLimiterFlags") + proto.RegisterType((*MsgUpdateRateLimiterFlagsResponse)(nil), "zetachain.zetacore.crosschain.MsgUpdateRateLimiterFlagsResponse") } func init() { proto.RegisterFile("crosschain/tx.proto", fileDescriptor_81d6d611190b7635) } var fileDescriptor_81d6d611190b7635 = []byte{ - // 1452 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0x5d, 0x4f, 0xdb, 0x56, - 0x1b, 0xbf, 0x40, 0x48, 0x1e, 0x48, 0x78, 0x6b, 0x68, 0x09, 0xa6, 0x04, 0x6a, 0xde, 0xf6, 0x45, - 0x7a, 0xd5, 0xa4, 0x4d, 0xf5, 0x4e, 0x6d, 0xb7, 0x49, 0x03, 0xd4, 0x0f, 0xb6, 0x52, 0x2a, 0x37, - 0xdd, 0xa6, 0xdd, 0x58, 0x8e, 0x7d, 0x70, 0x2c, 0x12, 0x9f, 0xc8, 0xe7, 0x38, 0x0a, 0x68, 0xd2, - 0xa6, 0x49, 0xbb, 0x9f, 0xa6, 0x49, 0x95, 0xf6, 0x8b, 0x7a, 0x59, 0xed, 0x66, 0x1f, 0x17, 0xd5, - 0x44, 0x7f, 0xc0, 0xa4, 0xfd, 0x82, 0xc9, 0xcf, 0x39, 0x31, 0x71, 0x42, 0x3e, 0xa0, 0xea, 0x4d, - 0xe2, 0xe7, 0x39,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 0x6b, 0x88, 0x3b, 0x36, 0x20, 0x4b, 0x02, 0xbb, 0x7c, 0xcb, 0xb4, 0x84, 0x67, 0x65, 0x04, 0xe6, - 0x10, 0xd9, 0x89, 0x5e, 0xb7, 0xcf, 0x26, 0x93, 0x3e, 0x53, 0x61, 0xca, 0xb7, 0x1a, 0xc2, 0x2b, - 0x19, 0x03, 0x9f, 0xd5, 0x2b, 0x90, 0x62, 0x47, 0x8d, 0x2a, 0xad, 0xa3, 0x0b, 0x32, 0x86, 0x84, - 0x54, 0x0d, 0xd2, 0x0e, 0xb1, 0xbd, 0x86, 0x55, 0x67, 0x68, 0x72, 0xd6, 0x88, 0x61, 0x75, 0x05, - 0x32, 0xae, 0xc5, 0xcc, 0xba, 0xd7, 0xf0, 0xb8, 0x34, 0x39, 0xed, 0x5a, 0xec, 0x49, 0x04, 0xeb, - 0x26, 0x2c, 0xf7, 0xd9, 0xd4, 0xb1, 0x38, 0xb2, 0xe0, 0x38, 0x61, 0x81, 0xb0, 0x70, 0xee, 0xb8, - 0xdb, 0x82, 0x55, 0x00, 0xdb, 0x8e, 0x5d, 0x2a, 0xb3, 0x2c, 0xc2, 0x08, 0xa7, 0xfe, 0xae, 0xc0, - 0x62, 0xc7, 0xab, 0xfb, 0x21, 0x7f, 0xc7, 0x3c, 0x5a, 0x84, 0x69, 0x9f, 0xfa, 0x36, 0x41, 0x5f, - 0x4d, 0x19, 0x02, 0xe8, 0xce, 0xae, 0xa9, 0x44, 0x76, 0xbd, 0xe7, 0x84, 0xf9, 0x18, 0xae, 0x9e, - 0x65, 0x5a, 0xec, 0xbf, 0x55, 0x00, 0x8f, 0x99, 0x01, 0x69, 0xd0, 0x16, 0x71, 0xd0, 0xca, 0xb4, - 0x91, 0xf1, 0x98, 0x21, 0x10, 0xfa, 0x01, 0xfa, 0x5e, 0x40, 0x0f, 0x03, 0xda, 0x78, 0x4f, 0xee, - 0xd1, 0x37, 0xe0, 0xda, 0x40, 0x39, 0x71, 0x76, 0xbf,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xe8, 0x21, 0x1a, 0xa7, 0xa9, 0x0e, 0x6c, 0xf2, 0xdb, 0x9f, 0xbd, 0x3a, 0x29, 0x28, 0xaf, - 0x4f, 0x0a, 0xca, 0x9f, 0x27, 0x05, 0xe5, 0x87, 0xb7, 0x85, 0x89, 0xd7, 0x6f, 0x0b, 0x13, 0xbf, - 0xbd, 0x2d, 0x4c, 0x7c, 0x75, 0xbb, 0x6b, 0xad, 0x88, 0xd8, 0xde, 0x14, 0x5f, 0xa3, 0x3a, 0x12, - 0x4a, 0xed, 0x52, 0xf7, 0x37, 0xaa, 0x68, 0xcb, 0xa8, 0xa6, 0xf0, 0x5b, 0xd1, 0x9d, 0x7f, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x14, 0x36, 0x6f, 0x72, 0xbe, 0x12, 0x00, 0x00, + // 1528 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0x5b, 0x6b, 0xdb, 0x56, + 0x38, 0x5a, 0x6e, 0xf6, 0x97, 0x38, 0x69, 0x95, 0xb4, 0x71, 0x9c, 0xc6, 0x49, 0x9d, 0xb5, 0x0b, + 0x8c, 0xda, 0xad, 0xcb, 0x46, 0xdb, 0x6d, 0xb0, 0x24, 0xf4, 0x92, 0xad, 0x69, 0x8a, 0xea, 0x6e, + 0x63, 0x2f, 0x42, 0x96, 0x4e, 0x14, 0x11, 0x5b, 0xc7, 0xe8, 0x1c, 0x05, 0x27, 0x0c, 0x36, 0x06, + 0x7b, 0x1f, 0x63, 0x50, 0xe8, 0x2f, 0xea, 0x63, 0xd9, 0xcb, 0x2e, 0x0f, 0x65, 0xb4, 0x3f, 0x60, + 0xb0, 0xb7, 0xbd, 0x8d, 0xf3, 0x9d, 0x63, 0xc5, 0x92, 0xaf, 0x49, 0xe9, 0x8b, 0xad, 0xef, 0x3b, + 0xe7, 0xbb, 0x5f, 0x25, 0x98, 0xb3, 0x03, 0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0x29, 0xac, 0xc1, 0xe5, + 0x9e, 0x72, 0xa2, 0xec, 0x7e, 0xa6, 0xc1, 0xec, 0x0e, 0x73, 0xbf, 0xa2, 0x9c, 0xdc, 0xb7, 0xd8, + 0xe3, 0xc0, 0xb3, 0xc9, 0x99, 0x75, 0x68, 0x08, 0xea, 0x96, 0x0e, 0x08, 0xe8, 0x97, 0x61, 0x5a, + 0x3a, 0xd9, 0x0f, 0xeb, 0x55, 0x12, 0x60, 0x9c, 0xc6, 0x8c, 0x29, 0xc4, 0x3d, 0x42, 0x14, 0xe6, + 0x76, 0xd8, 0x68, 0xd4, 0x8e, 0xa2, 0xdc, 0x46, 0xa8, 0xb0, 0x08, 0x0b, 0x09, 0xc5, 0x22, 0xa5, + 0x7f, 0x1f, 0xc7, 0x92, 0x15, 0x67, 0xbb, 0xfe, 0x6e, 0x95, 0x91, 0xe0, 0x90, 0x38, 0xbb, 0x21, + 0xaf, 0xd2, 0xd0, 0x77, 0x2a, 0xcd, 0x3e, 0x06, 0x2c, 0x01, 0xe6, 0xa8, 0x8c, 0xb9, 0x4c, 0xda, + 0x94, 0x40, 0x60, 0xc8, 0x8b, 0x30, 0x47, 0x15, 0x33, 0x93, 0x0a, 0x67, 0xb5, 0x77, 0xae, 0xf3, + 0xf4, 0x44, 0x4e, 0x45, 0xde, 0xff, 0x14, 0x72, 0x89, 0xfb, 0x32, 0x7d, 0x88, 0xe7, 0xee, 0x73, + 0x65, 0x6a, 0x36, 0x46, 0xb6, 0x79, 0x72, 0xae, 0x7f, 0x04, 0x0b, 0x09, 0x6a, 0x51, 0xae, 0x21, + 0x23, 0x4e, 0x16, 0x90, 0x74, 0x3e, 0x46, 0x7a, 0xdf, 0x62, 0x4f, 0x19, 0x71, 0xf4, 0x63, 0x28, + 0x24, 0xc8, 0xc8, 0xde, 0x1e, 0xb1, 0xb9, 0x77, 0x48, 0x90, 0x81, 0x0c, 0xc2, 0x14, 0x4e, 0xa4, + 0xa2, 0x9a, 0x48, 0x57, 0x87, 0x98, 0x48, 0xdb, 0x3e, 0x37, 0xf2, 0x31, 0x89, 0x77, 0x5b, 0x7c, + 0xa3, 0xc4, 0xf8, 0x62, 0x80, 0x6c, 0xd9, 0x6b, 0xa6, 0x51, 0xfb, 0xde, 0xbc, 0xb0, 0x03, 0xe9, + 0x14, 0x66, 0x0e, 0xad, 0x5a, 0x48, 0xcc, 0x80, 0xd8, 0xc4, 0x13, 0x85, 0x82, 0xe1, 0xdf, 0x7c, + 0x70, 0xca, 0x29, 0xfa, 0xef, 0xab, 0x95, 0x0b, 0x47, 0x56, 0xbd, 0x76, 0xa7, 0x10, 0x67, 0x57, + 0x30, 0x32, 0x88, 0x30, 0x14, 0xac, 0x5f, 0x83, 0x09, 0xc6, 0x2d, 0x1e, 0xca, 0x4e, 0x39, 0x53, + 0xbe, 0x50, 0x54, 0x7b, 0x84, 0xba, 0xf1, 0x04, 0x0f, 0x0d, 0x75, 0x49, 0x5f, 0x81, 0x29, 0x69, + 0x22, 0xde, 0x52, 0x2d, 0x00, 0x10, 0xb5, 0x25, 0x30, 0xfa, 0x55, 0x98, 0x95, 0x17, 0xc4, 0xb0, + 0x95, 0xe5, 0x97, 0x42, 0xcb, 0x33, 0x88, 0xae, 0x30, 0xf6, 0x08, 0xbb, 0x54, 0x6c, 0xd4, 0xa5, + 0xfb, 0x8f, 0xba, 0xc2, 0x15, 0x58, 0xeb, 0x93, 0xd8, 0x51, 0x01, 0xfc, 0x30, 0x86, 0x2b, 0x43, + 0xfc, 0xde, 0xb6, 0x3f, 0x38, 0xff, 0x45, 0xb1, 0x11, 0xdf, 0x21, 0x81, 0x4a, 0x7e, 0x05, 0x09, + 0x63, 0xe4, 0x93, 0x99, 0x18, 0x4b, 0x19, 0x89, 0xde, 0x52, 0x55, 0x9e, 0x83, 0x94, 0x72, 0x70, + 0xa0, 0x7a, 0x6e, 0x04, 0xeb, 0x57, 0x60, 0xa6, 0xf5, 0xac, 0x9c, 0x36, 0x2e, 0x59, 0xb4, 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0x51, 0x48, 0x49, 0x9a, + 0x61, 0x0a, 0xa9, 0xd7, 0x0b, 0xbf, 0xfe, 0x3d, 0xcc, 0x26, 0x3f, 0x87, 0xdc, 0x18, 0xcc, 0x2e, + 0x41, 0x92, 0xbb, 0x7d, 0x6a, 0x92, 0xf6, 0x18, 0x24, 0x06, 0xd4, 0x10, 0x31, 0x88, 0x53, 0x0c, + 0x13, 0x83, 0xee, 0x63, 0x0b, 0x9b, 0x6a, 0xe7, 0xd0, 0xba, 0x39, 0x4c, 0x23, 0x48, 0x10, 0x0d, + 0xd3, 0x54, 0x7b, 0x8e, 0x29, 0xec, 0x67, 0x3d, 0x66, 0xd4, 0xad, 0x61, 0xa3, 0x9b, 0xa4, 0x1c, + 0xa6, 0x9f, 0xf5, 0x9f, 0x3d, 0x9b, 0x5f, 0xbe, 0x78, 0x9d, 0xd7, 0x5e, 0xbe, 0xce, 0x6b, 0x7f, + 0xbf, 0xce, 0x6b, 0x3f, 0xbf, 0xc9, 0x8f, 0xbc, 0x7c, 0x93, 0x1f, 0xf9, 0xe3, 0x4d, 0x7e, 0xe4, + 0xdb, 0x1b, 0x6d, 0xfb, 0x9a, 0xe0, 0x7d, 0x4d, 0x7e, 0xd7, 0x6b, 0x89, 0x29, 0x35, 0x4b, 0xed, + 0x5f, 0x08, 0xc5, 0xfa, 0x56, 0x9d, 0xc0, 0x8f, 0x70, 0x37, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, + 0x8e, 0xcd, 0x56, 0x06, 0x3c, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1489,6 +1584,7 @@ type MsgClient interface { MigrateTssFunds(ctx context.Context, in *MsgMigrateTssFunds, opts ...grpc.CallOption) (*MsgMigrateTssFundsResponse, error) AbortStuckCCTX(ctx context.Context, in *MsgAbortStuckCCTX, opts ...grpc.CallOption) (*MsgAbortStuckCCTXResponse, error) RefundAbortedCCTX(ctx context.Context, in *MsgRefundAbortedCCTX, opts ...grpc.CallOption) (*MsgRefundAbortedCCTXResponse, error) + UpdateRateLimiterFlags(ctx context.Context, in *MsgUpdateRateLimiterFlags, opts ...grpc.CallOption) (*MsgUpdateRateLimiterFlagsResponse, error) } type msgClient struct { @@ -1598,6 +1694,15 @@ func (c *msgClient) RefundAbortedCCTX(ctx context.Context, in *MsgRefundAbortedC return out, nil } +func (c *msgClient) UpdateRateLimiterFlags(ctx context.Context, in *MsgUpdateRateLimiterFlags, opts ...grpc.CallOption) (*MsgUpdateRateLimiterFlagsResponse, error) { + out := new(MsgUpdateRateLimiterFlagsResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Msg/UpdateRateLimiterFlags", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { AddToOutTxTracker(context.Context, *MsgAddToOutTxTracker) (*MsgAddToOutTxTrackerResponse, error) @@ -1611,6 +1716,7 @@ type MsgServer interface { MigrateTssFunds(context.Context, *MsgMigrateTssFunds) (*MsgMigrateTssFundsResponse, error) AbortStuckCCTX(context.Context, *MsgAbortStuckCCTX) (*MsgAbortStuckCCTXResponse, error) RefundAbortedCCTX(context.Context, *MsgRefundAbortedCCTX) (*MsgRefundAbortedCCTXResponse, error) + UpdateRateLimiterFlags(context.Context, *MsgUpdateRateLimiterFlags) (*MsgUpdateRateLimiterFlagsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1650,6 +1756,9 @@ func (*UnimplementedMsgServer) AbortStuckCCTX(ctx context.Context, req *MsgAbort func (*UnimplementedMsgServer) RefundAbortedCCTX(ctx context.Context, req *MsgRefundAbortedCCTX) (*MsgRefundAbortedCCTXResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RefundAbortedCCTX not implemented") } +func (*UnimplementedMsgServer) UpdateRateLimiterFlags(ctx context.Context, req *MsgUpdateRateLimiterFlags) (*MsgUpdateRateLimiterFlagsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateRateLimiterFlags not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1853,6 +1962,24 @@ func _Msg_RefundAbortedCCTX_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Msg_UpdateRateLimiterFlags_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateRateLimiterFlags) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateRateLimiterFlags(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.crosschain.Msg/UpdateRateLimiterFlags", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateRateLimiterFlags(ctx, req.(*MsgUpdateRateLimiterFlags)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.crosschain.Msg", HandlerType: (*MsgServer)(nil), @@ -1901,6 +2028,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "RefundAbortedCCTX", Handler: _Msg_RefundAbortedCCTX_Handler, }, + { + MethodName: "UpdateRateLimiterFlags", + Handler: _Msg_UpdateRateLimiterFlags_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "crosschain/tx.proto", @@ -2857,6 +2988,69 @@ func (m *MsgRefundAbortedCCTXResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *MsgUpdateRateLimiterFlags) 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 *MsgUpdateRateLimiterFlags) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateRateLimiterFlags) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RateLimiterFlags.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + 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 *MsgUpdateRateLimiterFlagsResponse) 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 *MsgUpdateRateLimiterFlagsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateRateLimiterFlagsResponse) 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 @@ -3301,6 +3495,30 @@ func (m *MsgRefundAbortedCCTXResponse) Size() (n int) { return n } +func (m *MsgUpdateRateLimiterFlags) 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)) + } + l = m.RateLimiterFlags.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateRateLimiterFlagsResponse) 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 } @@ -6223,6 +6441,171 @@ func (m *MsgRefundAbortedCCTXResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateRateLimiterFlags) 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: MsgUpdateRateLimiterFlags: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateRateLimiterFlags: 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RateLimiterFlags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RateLimiterFlags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 *MsgUpdateRateLimiterFlagsResponse) 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: MsgUpdateRateLimiterFlagsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateRateLimiterFlagsResponse: 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 From 1051a3115b3ffe565bc7677cc57b600a62080306 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Fri, 19 Apr 2024 08:22:10 -0700 Subject: [PATCH 06/11] chore: improve localnet incremental build times (#2049) * chore: improve localnet incremental build times * try to enable buildkit in github actions --- Dockerfile-localnet | 5 +++-- Makefile | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile-localnet b/Dockerfile-localnet index 65ca4188b4..ba86debb86 100644 --- a/Dockerfile-localnet +++ b/Dockerfile-localnet @@ -3,6 +3,7 @@ FROM golang:1.20-alpine3.18 ENV GOPATH /go ENV GOOS=linux ENV CGO_ENABLED=1 +ENV GOCACHE=/root/.cache/go-build RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux python3 py3-pip RUN pip install requests @@ -14,8 +15,8 @@ COPY go.sum . RUN go mod download COPY . . -RUN make install -RUN make install-zetae2e +RUN --mount=type=cache,target="/root/.cache/go-build" make install +RUN --mount=type=cache,target="/root/.cache/go-build" make install-zetae2e RUN ssh-keygen -A WORKDIR /root diff --git a/Makefile b/Makefile index b8a6d7415f..2cc2bf1d80 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,8 @@ TEST_DIR?="./..." TEST_BUILD_FLAGS := -tags pebbledb,ledger HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test +export DOCKER_BUILDKIT := 1 + clean: clean-binaries clean-dir clean-test-dir clean-coverage clean-binaries: From fe916e2816a9ad4602254c3e5be8fee85f87a597 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 19 Apr 2024 16:44:24 -0400 Subject: [PATCH 07/11] feat: zevm message passing (#2034) * add evm unit tests * add unit tests for ZevmOnReceive and ZevmOnRevert * add unit tests for reverts * changes to evm deposti * refactor call to use connector for deposit to contract * fix unit tests for ZEVMdeposit * add unit tests for revert * add todo for message encoding and decoding * add base54 encoding and decoding * add e2e test for revert * add e2e test for revert * add e2e test for revert * add debugging for issue * add logs * add refund for gas meter * increase gas limit to 400000 for msg passing * add zEVM to EVM messages * add tests for onRevert * fix unit tests * fix unit tests * add comments * add changelog * Fix the error in execution Replace error code duplicated to fix the execution error * Update testutil/contracts/Dapp.sol Co-authored-by: Lucas Bertrand * fixed logs and resolved comments 1 * move end to end tests to zeta advanced tests * move end to end tests to zeta advanced tests * revert a cctx instead of aborting when message decode fails * separate processing for ZEVM orginating and non ZEVM originating txs into separate functions * fix lint issues --------- Co-authored-by: Lucas Bertrand --- app/ante/ante.go | 10 +- changelog.md | 1 + cmd/zetae2e/config/config.go | 2 +- cmd/zetae2e/config/contracts.go | 4 +- cmd/zetae2e/local/local.go | 4 + e2e/e2etests/e2etests.go | 37 ++ e2e/e2etests/test_eth_deposit.go | 1 + e2e/e2etests/test_message_passing.go | 8 +- e2e/e2etests/test_message_passing_zevm.go | 324 +++++++++++++ e2e/e2etests/test_zeta_withdraw.go | 3 +- e2e/runner/runner.go | 11 +- e2e/runner/setup_evm.go | 2 +- e2e/runner/setup_zeta.go | 12 +- e2e/utils/zetacore.go | 1 + go.mod | 11 +- go.sum | 12 +- testutil/contracts/Dapp.abi | 170 +++++++ testutil/contracts/Dapp.bin | 1 + testutil/contracts/Dapp.go | 449 ++++++++++++++++++ testutil/contracts/Dapp.json | 173 +++++++ testutil/contracts/Dapp.sol | 83 ++++ testutil/contracts/DappReverter.abi | 16 + testutil/contracts/DappReverter.bin | 1 + testutil/contracts/DappReverter.go | 244 ++++++++++ testutil/contracts/DappReverter.json | 19 + testutil/contracts/DappReverter.sol | 9 + testutil/contracts/Depositor.bin | 2 +- testutil/contracts/Depositor.go | 7 +- testutil/contracts/Depositor.json | 2 +- testutil/contracts/Example.bin | 2 +- testutil/contracts/Example.go | 7 +- testutil/contracts/Example.json | 2 +- testutil/contracts/Reverter.bin | 2 +- testutil/contracts/Reverter.go | 7 +- testutil/contracts/Reverter.json | 2 +- testutil/contracts/Withdrawer.bin | 2 +- testutil/contracts/Withdrawer.go | 7 +- testutil/contracts/Withdrawer.json | 2 +- testutil/contracts/bindings.go | 13 + testutil/keeper/mocks/crosschain/fungible.go | 60 +++ testutil/sample/crosschain.go | 3 +- x/crosschain/keeper/cctx.go | 32 +- x/crosschain/keeper/evm_deposit.go | 20 +- x/crosschain/keeper/evm_deposit_test.go | 19 +- x/crosschain/keeper/evm_hooks.go | 7 +- x/crosschain/keeper/gas_payment.go | 1 - .../grpc_query_in_tx_hash_to_cctx_test.go | 6 +- .../keeper/msg_server_vote_inbound_tx_test.go | 19 +- .../keeper/msg_server_vote_outbound_tx.go | 3 + x/crosschain/keeper/process_inbound.go | 6 +- x/crosschain/keeper/process_inbound_test.go | 9 +- x/crosschain/keeper/process_outbound_test.go | 78 ++- x/crosschain/keeper/processs_outbound.go | 166 +++++-- x/crosschain/types/cctx.go | 24 +- x/crosschain/types/cctx_test.go | 16 +- x/crosschain/types/errors.go | 5 +- x/crosschain/types/expected_keepers.go | 59 ++- x/fungible/keeper/deposits.go | 4 + x/fungible/keeper/deposits_test.go | 67 ++- x/fungible/keeper/evm.go | 107 ++++- x/fungible/keeper/evm_test.go | 155 ++++++ x/fungible/keeper/system_contract.go | 4 +- x/fungible/keeper/zeta.go | 6 + .../keeper/zevm_message_passing_test.go | 263 ++++++++++ x/fungible/keeper/zevm_msg_passing.go | 61 +++ x/fungible/types/errors.go | 1 + x/observer/keeper/nonce_to_cctx_test.go | 12 + zetaclient/evm/evm_signer.go | 11 +- zetaclient/zetabridge/tx_vote_inbound.go | 2 +- 69 files changed, 2693 insertions(+), 198 deletions(-) create mode 100644 e2e/e2etests/test_message_passing_zevm.go create mode 100644 testutil/contracts/Dapp.abi create mode 100644 testutil/contracts/Dapp.bin create mode 100644 testutil/contracts/Dapp.go create mode 100644 testutil/contracts/Dapp.json create mode 100644 testutil/contracts/Dapp.sol create mode 100644 testutil/contracts/DappReverter.abi create mode 100644 testutil/contracts/DappReverter.bin create mode 100644 testutil/contracts/DappReverter.go create mode 100644 testutil/contracts/DappReverter.json create mode 100644 testutil/contracts/DappReverter.sol create mode 100644 x/fungible/keeper/zevm_message_passing_test.go create mode 100644 x/fungible/keeper/zevm_msg_passing.go diff --git a/app/ante/ante.go b/app/ante/ante.go index 18947d01fa..f1a8b21d45 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -26,7 +26,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmlog "github.com/tendermint/tendermint/libs/log" - cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -168,10 +168,10 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool { } } switch innerMsg.(type) { - case *cctxtypes.MsgVoteGasPrice, - *cctxtypes.MsgVoteOnObservedInboundTx, - *cctxtypes.MsgVoteOnObservedOutboundTx, - *cctxtypes.MsgAddToOutTxTracker, + case *crosschaintypes.MsgVoteGasPrice, + *crosschaintypes.MsgVoteOnObservedInboundTx, + *crosschaintypes.MsgVoteOnObservedOutboundTx, + *crosschaintypes.MsgAddToOutTxTracker, *observertypes.MsgVoteBlockHeader, *observertypes.MsgVoteTSS, *observertypes.MsgAddBlameVote: diff --git a/changelog.md b/changelog.md index fd1a9c8b99..a939f0cd4b 100644 --- a/changelog.md +++ b/changelog.md @@ -54,6 +54,7 @@ * [1954](https://github.com/zeta-chain/node/pull/1954) - add metric for concurrent keysigns * [2006](https://github.com/zeta-chain/node/pull/2006) - add Amoy testnet static chain information * [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags +* [2034](https://github.com/zeta-chain/node/pull/2034) - add support for zEVM message passing ### Tests diff --git a/cmd/zetae2e/config/config.go b/cmd/zetae2e/config/config.go index cc6c64b532..da8ef55cda 100644 --- a/cmd/zetae2e/config/config.go +++ b/cmd/zetae2e/config/config.go @@ -106,7 +106,7 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C conf.Contracts.ZEVM.WZetaAddr = r.WZetaAddr.Hex() conf.Contracts.ZEVM.ZEVMSwapAppAddr = r.ZEVMSwapAppAddr.Hex() conf.Contracts.ZEVM.ContextAppAddr = r.ContextAppAddr.Hex() - conf.Contracts.ZEVM.TestDappAddr = r.TestDAppAddr.Hex() + conf.Contracts.ZEVM.TestDappAddr = r.EvmTestDAppAddr.Hex() return conf } diff --git a/cmd/zetae2e/config/contracts.go b/cmd/zetae2e/config/contracts.go index 2d456a8989..a4f05f0058 100644 --- a/cmd/zetae2e/config/contracts.go +++ b/cmd/zetae2e/config/contracts.go @@ -7,9 +7,9 @@ import ( "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol" zetaeth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zeta.eth.sol" zetaconnectoreth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.eth.sol" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" @@ -181,7 +181,7 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error { if !ethcommon.IsHexAddress(c) { return fmt.Errorf("invalid TestDappAddr: %s", c) } - r.TestDAppAddr = ethcommon.HexToAddress(c) + r.EvmTestDAppAddr = ethcommon.HexToAddress(c) } return nil diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 1d6a664d71..0fee34f8a9 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -253,6 +253,10 @@ func localE2ETest(cmd *cobra.Command, _ []string) { } zetaAdvancedTests := []string{ e2etests.TestZetaDepositRestrictedName, + e2etests.TestMessagePassingZEVMToEVMName, + e2etests.TestMessagePassingEVMtoZEVMName, + e2etests.TestMessagePassingEVMtoZEVMRevertName, + e2etests.TestMessagePassingZEVMtoEVMRevertName, } bitcoinTests := []string{ e2etests.TestBitcoinWithdrawSegWitName, diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 765194c425..09197c874a 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -25,6 +25,11 @@ const ( TestCrosschainSwapName = "crosschain_swap" TestMessagePassingRevertFailName = "message_passing_revert_fail" TestMessagePassingRevertSuccessName = "message_passing_revert_success" + TestMessagePassingEVMtoZEVMName = "message_passing_zevm" + TestMessagePassingZEVMToEVMName = "message_passing_zevm_to_evm" + + TestMessagePassingZEVMtoEVMRevertName = "message_passing_zevm_to_evm_revert" + TestMessagePassingEVMtoZEVMRevertName = "message_passing_revert_zevm" TestERC20DepositAndCallRefundName = "erc20_deposit_and_call_refund" TestEtherDepositAndCallName = "eth_deposit_and_call" TestDepositEtherLiquidityCapName = "deposit_eth_liquidity_cap" @@ -372,4 +377,36 @@ var AllE2ETests = []runner.E2ETest{ []runner.ArgDefinition{}, TestUpdateBytecodeConnector, ), + runner.NewE2ETest( + TestMessagePassingZEVMToEVMName, + "zevm -> evm message passing contract call", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000007"}, + }, + TestMessagePassingZEVMtoEVM, + ), + runner.NewE2ETest( + TestMessagePassingZEVMtoEVMRevertName, + "zevm -> evm message passing contract call reverts", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000006"}, + }, + TestMessagePassingZEVMtoEVMRevert, + ), + runner.NewE2ETest( + TestMessagePassingEVMtoZEVMName, + "evm -> zevm message passing contract call ", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000009"}, + }, + TestMessagePassingEVMtoZEVM, + ), + runner.NewE2ETest( + TestMessagePassingEVMtoZEVMRevertName, + "evm -> zevm message passing and revert back to evm", + []runner.ArgDefinition{ + runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "10000000000000000008"}, + }, + TestMessagePassingEVMtoZEVMRevert, + ), } diff --git a/e2e/e2etests/test_eth_deposit.go b/e2e/e2etests/test_eth_deposit.go index bfcc33e1a8..65a79f9c15 100644 --- a/e2e/e2etests/test_eth_deposit.go +++ b/e2e/e2etests/test_eth_deposit.go @@ -139,6 +139,7 @@ func TestEtherDepositAndCall(r *runner.E2ERunner, args []string) { if receipt.Status == 0 { panic("tx failed") } + cctx = utils.WaitCctxMinedByInTxHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) if cctx.CctxStatus.Status != types.CctxStatus_Reverted { panic(fmt.Sprintf("expected cctx status to be reverted; got %s", cctx.CctxStatus.Status)) diff --git a/e2e/e2etests/test_message_passing.go b/e2e/e2etests/test_message_passing.go index c01c2a92ac..b17aff8f6b 100644 --- a/e2e/e2etests/test_message_passing.go +++ b/e2e/e2etests/test_message_passing.go @@ -190,7 +190,7 @@ func TestMessagePassingRevertSuccess(r *runner.E2ERunner, args []string) { auth := r.EVMAuth - tx, err := r.ZetaEth.Approve(auth, r.TestDAppAddr, amount) + tx, err := r.ZetaEth.Approve(auth, r.EvmTestDAppAddr, amount) if err != nil { panic(err) } @@ -202,8 +202,8 @@ func TestMessagePassingRevertSuccess(r *runner.E2ERunner, args []string) { } r.Logger.Info("Approve tx receipt: %d", receipt.Status) - r.Logger.Info("Calling TestDApp.SendHello on contract address %s", r.TestDAppAddr.Hex()) - testDApp, err := testdapp.NewTestDApp(r.TestDAppAddr, r.EVMClient) + r.Logger.Info("Calling TestDApp.SendHello on contract address %s", r.EvmTestDAppAddr.Hex()) + testDApp, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) if err != nil { panic(err) } @@ -216,7 +216,7 @@ func TestMessagePassingRevertSuccess(r *runner.E2ERunner, args []string) { } r.Logger.Info("$$$ Before: SUPPLY OF AZETA: %d", res2.Amount.Amount) - tx, err = testDApp.SendHelloWorld(auth, r.TestDAppAddr, chainID, amount, true) + tx, err = testDApp.SendHelloWorld(auth, r.EvmTestDAppAddr, chainID, amount, true) if err != nil { panic(err) } diff --git a/e2e/e2etests/test_message_passing_zevm.go b/e2e/e2etests/test_message_passing_zevm.go new file mode 100644 index 0000000000..54ca59b589 --- /dev/null +++ b/e2e/e2etests/test_message_passing_zevm.go @@ -0,0 +1,324 @@ +package e2etests + +import ( + "fmt" + "math/big" + + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/zeta-chain/zetacore/e2e/contracts/testdapp" + "github.com/zeta-chain/zetacore/e2e/runner" + "github.com/zeta-chain/zetacore/e2e/utils" + cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestMessagePassingEVMtoZEVM(r *runner.E2ERunner, args []string) { + if len(args) != 1 { + panic("TestMessagePassing requires exactly one argument for the amount.") + } + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassing.") + } + + // Set destination details + zEVMChainID, err := r.ZEVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.ZevmTestDAppAddr + + // Contract call originates from EVM chain + tx, err := r.ZetaEth.Approve(r.EVMAuth, r.EvmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status != 1 { + panic("approve tx failed") + } + r.Logger.Info("Approve tx receipt: %d", receipt.Status) + testDAppEVM, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) + if err != nil { + panic(err) + } + // Call the SendHelloWorld function on the EVM dapp Contract which would in turn create a new send, to be picked up by the zeta-clients + // set Do revert to false which adds a message to signal the ZEVM zetaReceiver to not revert the transaction + tx, err = testDAppEVM.SendHelloWorld(r.EVMAuth, destinationAddress, zEVMChainID, amount, false) + if err != nil { + panic(err) + } + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + + // New inbound message picked up by zeta-clients and voted on by observers to initiate a contract call on zEVM + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_OutboundMined { + panic("expected cctx to be outbound_mined") + } + r.Logger.Info(fmt.Sprintf("🔄 Cctx mined for contract call chain zevm %s", cctx.Index)) + + // On finalization the Fungible module calls the onReceive function which in turn calls the onZetaMessage function on the destination contract + receipt, err = r.ZEVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + if receipt.Status != 1 { + panic("tx failed") + } + testDAppZEVM, err := testdapp.NewTestDApp(r.ZevmTestDAppAddr, r.ZEVMClient) + if err != nil { + panic(err) + } + receivedHelloWorldEvent := false + for _, log := range receipt.Logs { + _, err := testDAppZEVM.ParseHelloWorldEvent(*log) + if err == nil { + r.Logger.Info("Received HelloWorld event") + receivedHelloWorldEvent = true + } + } + if !receivedHelloWorldEvent { + panic(fmt.Sprintf("expected HelloWorld event, logs: %+v", receipt.Logs)) + } +} + +func TestMessagePassingEVMtoZEVMRevert(r *runner.E2ERunner, args []string) { + + if len(args) != 1 { + panic("TestMessagePassingRevert requires exactly one argument for the amount.") + } + + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassingRevert.") + } + + // Set destination details + zEVMChainID, err := r.ZEVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.ZevmTestDAppAddr + + // Contract call originates from EVM chain + tx, err := r.ZetaEth.Approve(r.EVMAuth, r.EvmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("Approve tx hash: %s", tx.Hash().Hex()) + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status != 1 { + panic("tx failed") + } + r.Logger.Info("Approve tx receipt: %d", receipt.Status) + testDAppEVM, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) + if err != nil { + panic(err) + } + // Call the SendHelloWorld function on the EVM dapp Contract which would in turn create a new send, to be picked up by the zeta-clients + // set Do revert to true which adds a message to signal the ZEVM zetaReceiver to revert the transaction + tx, err = testDAppEVM.SendHelloWorld(r.EVMAuth, destinationAddress, zEVMChainID, amount, true) + if err != nil { + panic(err) + } + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout) + + // New inbound message picked up by zeta-clients and voted on by observers to initiate a contract call on zEVM which would revert the transaction + // A revert transaction is created and gets fialized on the original sender chain. + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_Reverted { + panic("expected cctx to be reverted") + } + + // On finalization the Tss address calls the onRevert function which in turn calls the onZetaRevert function on the sender contract + receipt, err = r.EVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + if receipt.Status != 1 { + panic("tx failed") + } + receivedHelloWorldEvent := false + for _, log := range receipt.Logs { + _, err := testDAppEVM.ParseRevertedHelloWorldEvent(*log) + if err == nil { + r.Logger.Info("Received RevertHelloWorld event:") + receivedHelloWorldEvent = true + } + } + if !receivedHelloWorldEvent { + panic(fmt.Sprintf("expected Reverted HelloWorld event, logs: %+v", receipt.Logs)) + } +} + +func TestMessagePassingZEVMtoEVM(r *runner.E2ERunner, args []string) { + if len(args) != 1 { + panic("TestMessagePassing requires exactly one argument for the amount.") + } + + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassing.") + } + // Set destination details + EVMChainID, err := r.EVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.EvmTestDAppAddr + + // Contract call originates from ZEVM chain + r.ZEVMAuth.Value = amount + tx, err := r.WZeta.Deposit(r.ZEVMAuth) + if err != nil { + panic(err) + } + r.ZEVMAuth.Value = big.NewInt(0) + r.Logger.Info("wzeta deposit tx hash: %s", tx.Hash().Hex()) + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + r.Logger.EVMReceipt(*receipt, "wzeta deposit") + if receipt.Status == 0 { + panic("deposit failed") + } + tx, err = r.WZeta.Approve(r.ZEVMAuth, r.ZevmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("wzeta approve tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + r.Logger.EVMReceipt(*receipt, "wzeta approve") + if receipt.Status == 0 { + panic(fmt.Sprintf("approve failed, logs: %+v", receipt.Logs)) + } + testDAppZEVM, err := testdapp.NewTestDApp(r.ZevmTestDAppAddr, r.ZEVMClient) + if err != nil { + panic(err) + } + // Call the SendHelloWorld function on the ZEVM dapp Contract which would in turn create a new send, to be picked up by the zetanode evm hooks + // set Do revert to false which adds a message to signal the EVM zetaReceiver to not revert the transaction + tx, err = testDAppZEVM.SendHelloWorld(r.ZEVMAuth, destinationAddress, EVMChainID, amount, false) + if err != nil { + panic(err) + } + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic(fmt.Sprintf("send failed, logs: %+v", receipt.Logs)) + } + + // Transaction is picked up by the zetanode evm hooks and a new contract call is initiated on the EVM chain + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_OutboundMined { + panic("expected cctx to be outbound_mined") + } + + // On finalization the Tss calls the onReceive function which in turn calls the onZetaMessage function on the destination contract. + receipt, err = r.EVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + if receipt.Status != 1 { + panic("tx failed") + } + testDAppEVM, err := testdapp.NewTestDApp(r.EvmTestDAppAddr, r.EVMClient) + if err != nil { + panic(err) + } + receivedHelloWorldEvent := false + for _, log := range receipt.Logs { + _, err := testDAppEVM.ParseHelloWorldEvent(*log) + if err == nil { + r.Logger.Info("Received HelloWorld event:") + receivedHelloWorldEvent = true + } + } + if !receivedHelloWorldEvent { + panic(fmt.Sprintf("expected HelloWorld event, logs: %+v", receipt.Logs)) + } +} + +func TestMessagePassingZEVMtoEVMRevert(r *runner.E2ERunner, args []string) { + if len(args) != 1 { + panic("TestMessagePassing requires exactly one argument for the amount.") + } + + amount, ok := big.NewInt(0).SetString(args[0], 10) + if !ok { + panic("Invalid amount specified for TestMessagePassing.") + } + + // Set destination details + EVMChainID, err := r.EVMClient.ChainID(r.Ctx) + if err != nil { + panic(err) + } + destinationAddress := r.EvmTestDAppAddr + + // Contract call originates from ZEVM chain + r.ZEVMAuth.Value = amount + tx, err := r.WZeta.Deposit(r.ZEVMAuth) + if err != nil { + panic(err) + } + r.ZEVMAuth.Value = big.NewInt(0) + r.Logger.Info("wzeta deposit tx hash: %s", tx.Hash().Hex()) + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + r.Logger.EVMReceipt(*receipt, "wzeta deposit") + if receipt.Status == 0 { + panic("deposit failed") + } + tx, err = r.WZeta.Approve(r.ZEVMAuth, r.ZevmTestDAppAddr, amount) + if err != nil { + panic(err) + } + r.Logger.Info("wzeta approve tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + r.Logger.EVMReceipt(*receipt, "wzeta approve") + if receipt.Status == 0 { + panic(fmt.Sprintf("approve failed, logs: %+v", receipt.Logs)) + } + testDAppZEVM, err := testdapp.NewTestDApp(r.ZevmTestDAppAddr, r.ZEVMClient) + if err != nil { + panic(err) + } + // Call the SendHelloWorld function on the ZEVM dapp Contract which would in turn create a new send, to be picked up by the zetanode evm hooks + // set Do revert to true which adds a message to signal the EVM zetaReceiver to revert the transaction + tx, err = testDAppZEVM.SendHelloWorld(r.ZEVMAuth, destinationAddress, EVMChainID, amount, true) + if err != nil { + panic(err) + } + + r.Logger.Info("TestDApp.SendHello tx hash: %s", tx.Hash().Hex()) + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic(fmt.Sprintf("send failed, logs: %+v", receipt.Logs)) + } + + // New inbound message picked up by zetanode evm hooks and processed directly to initiate a contract call on EVM which would revert the transaction + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != cctxtypes.CctxStatus_Reverted { + panic("expected cctx to be reverted") + } + + // On finalization the Fungible module calls the onRevert function which in turn calls the onZetaRevert function on the sender contract + receipt, err = r.ZEVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutTxParam().OutboundTxHash)) + if err != nil { + panic(err) + } + if receipt.Status != 1 { + panic("tx failed") + } + receivedHelloWorldEvent := false + for _, log := range receipt.Logs { + _, err := testDAppZEVM.ParseRevertedHelloWorldEvent(*log) + if err == nil { + r.Logger.Info("Received HelloWorld event:") + receivedHelloWorldEvent = true + } + } + if !receivedHelloWorldEvent { + panic(fmt.Sprintf("expected Reverted HelloWorld event, logs: %+v", receipt.Logs)) + } +} diff --git a/e2e/e2etests/test_zeta_withdraw.go b/e2e/e2etests/test_zeta_withdraw.go index 2b5dc055e0..6dfc664813 100644 --- a/e2e/e2etests/test_zeta_withdraw.go +++ b/e2e/e2etests/test_zeta_withdraw.go @@ -6,7 +6,7 @@ import ( "math/big" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" "github.com/zeta-chain/zetacore/e2e/runner" "github.com/zeta-chain/zetacore/e2e/utils" "github.com/zeta-chain/zetacore/pkg/chains" @@ -70,7 +70,6 @@ func TestZetaWithdraw(r *runner.E2ERunner, args []string) { r.Logger.EVMReceipt(*receipt, "send") if receipt.Status == 0 { panic(fmt.Sprintf("send failed, logs: %+v", receipt.Logs)) - } r.Logger.Info(" Logs:") diff --git a/e2e/runner/runner.go b/e2e/runner/runner.go index d45b542c97..da8944c7d9 100644 --- a/e2e/runner/runner.go +++ b/e2e/runner/runner.go @@ -16,9 +16,9 @@ import ( "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol" zetaeth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zeta.eth.sol" zetaconnectoreth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.eth.sol" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" @@ -73,6 +73,7 @@ type E2ERunner struct { ERC20Custody *erc20custody.ERC20Custody ERC20Addr ethcommon.Address ERC20 *erc20.ERC20 + EvmTestDAppAddr ethcommon.Address // contracts zevm ERC20ZRC20Addr ethcommon.Address @@ -89,13 +90,13 @@ type E2ERunner struct { ConnectorZEVM *connectorzevm.ZetaConnectorZEVM WZetaAddr ethcommon.Address WZeta *wzeta.WETH9 - TestDAppAddr ethcommon.Address ZEVMSwapAppAddr ethcommon.Address ZEVMSwapApp *zevmswap.ZEVMSwapApp ContextAppAddr ethcommon.Address ContextApp *contextapp.ContextApp SystemContractAddr ethcommon.Address SystemContract *systemcontract.SystemContract + ZevmTestDAppAddr ethcommon.Address // config CctxTimeout time.Duration @@ -179,10 +180,11 @@ func (runner *E2ERunner) CopyAddressesFrom(other *E2ERunner) (err error) { runner.UniswapV2RouterAddr = other.UniswapV2RouterAddr runner.ConnectorZEVMAddr = other.ConnectorZEVMAddr runner.WZetaAddr = other.WZetaAddr - runner.TestDAppAddr = other.TestDAppAddr + runner.EvmTestDAppAddr = other.EvmTestDAppAddr runner.ZEVMSwapAppAddr = other.ZEVMSwapAppAddr runner.ContextAppAddr = other.ContextAppAddr runner.SystemContractAddr = other.SystemContractAddr + runner.ZevmTestDAppAddr = other.ZevmTestDAppAddr // create instances of contracts runner.ZetaEth, err = zetaeth.NewZetaEth(runner.ZetaEthAddr, runner.EVMClient) @@ -272,7 +274,7 @@ func (runner *E2ERunner) PrintContractAddresses() { runner.Logger.Print("ZEVMSwapApp: %s", runner.ZEVMSwapAppAddr.Hex()) runner.Logger.Print("ContextApp: %s", runner.ContextAppAddr.Hex()) - runner.Logger.Print("TestDapp: %s", runner.TestDAppAddr.Hex()) + runner.Logger.Print("TestDappZEVM: %s", runner.ZevmTestDAppAddr.Hex()) // evm contracts runner.Logger.Print(" --- 📜EVM contracts ---") @@ -280,4 +282,5 @@ func (runner *E2ERunner) PrintContractAddresses() { runner.Logger.Print("ConnectorEth: %s", runner.ConnectorEthAddr.Hex()) runner.Logger.Print("ERC20Custody: %s", runner.ERC20CustodyAddr.Hex()) runner.Logger.Print("ERC20: %s", runner.ERC20Addr.Hex()) + runner.Logger.Print("TestDappEVM: %s", runner.EvmTestDAppAddr.Hex()) } diff --git a/e2e/runner/setup_evm.go b/e2e/runner/setup_evm.go index 8e76ac7409..01188c759a 100644 --- a/e2e/runner/setup_evm.go +++ b/e2e/runner/setup_evm.go @@ -131,7 +131,7 @@ func (runner *E2ERunner) SetupEVM(contractsDeployed bool, whitelistERC20 bool) { if err != nil { panic(err) } - runner.TestDAppAddr = appAddr + runner.EvmTestDAppAddr = appAddr runner.Logger.Info("TestDApp contract address: %s, tx hash: %s", appAddr.Hex(), txApp.Hash().Hex()) // check contract deployment receipt diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 0de4693210..e332f98af9 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -7,13 +7,14 @@ import ( "github.com/btcsuite/btcutil" "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" "github.com/zeta-chain/zetacore/e2e/contracts/contextapp" + "github.com/zeta-chain/zetacore/e2e/contracts/testdapp" "github.com/zeta-chain/zetacore/e2e/contracts/zevmswap" "github.com/zeta-chain/zetacore/e2e/txserver" e2eutils "github.com/zeta-chain/zetacore/e2e/utils" @@ -141,6 +142,14 @@ func (runner *E2ERunner) SetZEVMContracts() { runner.SetupETHZRC20() runner.SetupBTCZRC20() + // deploy TestDApp contract on zEVM + appAddr, txApp, _, err := testdapp.DeployTestDApp(runner.ZEVMAuth, runner.ZEVMClient, runner.ConnectorZEVMAddr, runner.WZetaAddr) + if err != nil { + panic(err) + } + runner.ZevmTestDAppAddr = appAddr + runner.Logger.Info("TestDApp Zevm contract address: %s, tx hash: %s", appAddr.Hex(), txApp.Hash().Hex()) + // deploy ZEVMSwapApp and ContextApp zevmSwapAppAddr, txZEVMSwapApp, zevmSwapApp, err := zevmswap.DeployZEVMSwapApp( runner.ZEVMAuth, @@ -170,6 +179,7 @@ func (runner *E2ERunner) SetZEVMContracts() { } runner.ContextAppAddr = contextAppAddr runner.ContextApp = contextApp + } // SetupETHZRC20 sets up the ETH ZRC20 in the runner from the values queried from the chain diff --git a/e2e/utils/zetacore.go b/e2e/utils/zetacore.go index 4aeac71ba3..9abaea7284 100644 --- a/e2e/utils/zetacore.go +++ b/e2e/utils/zetacore.go @@ -57,6 +57,7 @@ func WaitCctxsMinedByInTxHash( res, err := cctxClient.InTxHashToCctxData(ctx, &crosschaintypes.QueryInTxHashToCctxDataRequest{ InTxHash: inTxHash, }) + if err != nil { // prevent spamming logs if i%10 == 0 { diff --git a/go.mod b/go.mod index 245536d185..f1ed9826e8 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-retryablehttp v0.7.0 github.com/multiformats/go-multiaddr v0.9.0 github.com/prometheus/client_golang v1.14.0 github.com/rs/zerolog v1.29.1 @@ -44,7 +43,7 @@ require ( github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98 github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 - github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b + github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240418181724-c222fd3ae1f5 google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f gopkg.in/yaml.v2 v2.4.0 ) @@ -59,6 +58,7 @@ require ( require ( github.com/binance-chain/tss-lib v0.0.0-20201118045712-70b2cb4bf916 + github.com/btcsuite/btcd/btcutil v1.1.3 github.com/nanmu42/etherscan-api v1.10.0 github.com/onrik/ethrpc v1.2.0 go.nhat.io/grpcmock v0.25.0 @@ -68,7 +68,6 @@ require ( github.com/DataDog/zstd v1.5.2 // indirect github.com/agl/ed25519 v0.0.0-20200225211852-fd4d107ace12 // indirect github.com/bool64/shared v0.1.5 // indirect - github.com/btcsuite/btcd/btcutil v1.1.3 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cockroachdb/errors v1.9.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect @@ -156,7 +155,7 @@ require ( github.com/confio/ics23/go v0.9.0 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect - github.com/cosmos/btcutil v1.0.5 // indirect + github.com/cosmos/btcutil v1.0.5 github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogoproto v1.4.7 @@ -294,7 +293,7 @@ require ( github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/afero v1.11.0 github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/viper v1.15.0 github.com/status-im/keycard-go v0.2.0 // indirect @@ -315,7 +314,7 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.17.0 // indirect + golang.org/x/crypto v0.17.0 golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/net v0.19.0 diff --git a/go.sum b/go.sum index 256540ef43..c28932ba96 100644 --- a/go.sum +++ b/go.sum @@ -1739,7 +1739,6 @@ github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrj github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= @@ -1753,7 +1752,6 @@ github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9 github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.6.4/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= -github.com/hashicorp/go-retryablehttp v0.7.0 h1:eu1EI/mbirUgP5C8hVsTNaGZreBDlYiwC1FZWkvQPQ4= github.com/hashicorp/go-retryablehttp v0.7.0/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= @@ -1857,6 +1855,7 @@ github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8 github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= +github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= @@ -2773,6 +2772,7 @@ github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34c github.com/sourcegraph/go-diff v0.5.3/go.mod h1:v9JDtjCE4HHHCZGId75rg8gkKKa98RVjBcBGsVmMmak= github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= +github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= @@ -3056,8 +3056,12 @@ github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98 h1:GCSRgszQbAR github.com/zeta-chain/go-tss v0.1.1-0.20240208222330-f3be0d4a0d98/go.mod h1:+lJfk/qqt+oxXeVuJV+PzpUoxftUfoTRf2eF3qlbyFI= github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2 h1:gd2uE0X+ZbdFJ8DubxNqLbOVlCB12EgWdzSNRAR82tM= github.com/zeta-chain/keystone/keys v0.0.0-20231105174229-903bc9405da2/go.mod h1:x7Bkwbzt2W2lQfjOirnff0Dj+tykdbTG1FMJPVPZsvE= -github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b h1:aZRt5BtXdoDdyrUKwcv3B7mS30m/B854cjKjmnXBE5A= -github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230816152528-db7d2bf9144b/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30 h1:V1Kl0xLsdL2l9ThMEx/NLqRvr8zTAAyq2IoM+nhPMhE= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240415192848-ad076a028d30/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240417132824-4be6fd4cb877 h1:Lp1HUBFI4M1vJg5exJ4zasIEAtD/iPef/OYW4eM9pXw= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240417132824-4be6fd4cb877/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240418181724-c222fd3ae1f5 h1:ljM7xka3WZvth9k1uYxrG3/FKQQTkR96FZlIjUKOoYw= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20240418181724-c222fd3ae1f5/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= diff --git a/testutil/contracts/Dapp.abi b/testutil/contracts/Dapp.abi new file mode 100644 index 0000000000..903a4f02d7 --- /dev/null +++ b/testutil/contracts/Dapp.abi @@ -0,0 +1,170 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "destinationAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "destinationChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "message", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "zetaTxSenderAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "destinationAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "zetaValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.ZetaMessage", + "name": "zetaMessage", + "type": "tuple" + } + ], + "name": "onZetaMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "zetaTxSenderAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "destinationAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "destinationChainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "remainingZetaValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.ZetaRevert", + "name": "zetaRevert", + "type": "tuple" + } + ], + "name": "onZetaRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sourceChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "zetaTxSenderAddress", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "zetaValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/testutil/contracts/Dapp.bin b/testutil/contracts/Dapp.bin new file mode 100644 index 0000000000..52bfd6c0ac --- /dev/null +++ b/testutil/contracts/Dapp.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b50604051806020016040528060008152506000908161002f91906102fe565b5060006001819055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600381905550600060048190555060405180602001604052806000815250600590816100a891906102fe565b506103d0565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061012f57607f821691505b602082108103610142576101416100e8565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026101aa7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261016d565b6101b4868361016d565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006101fb6101f66101f1846101cc565b6101d6565b6101cc565b9050919050565b6000819050919050565b610215836101e0565b61022961022182610202565b84845461017a565b825550505050565b600090565b61023e610231565b61024981848461020c565b505050565b5b8181101561026d57610262600082610236565b60018101905061024f565b5050565b601f8211156102b25761028381610148565b61028c8461015d565b8101602085101561029b578190505b6102af6102a78561015d565b83018261024e565b50505b505050565b600082821c905092915050565b60006102d5600019846008026102b7565b1980831691505092915050565b60006102ee83836102c4565b9150826002028217905092915050565b610307826100ae565b67ffffffffffffffff8111156103205761031f6100b9565b5b61032a8254610117565b610335828285610271565b600060209050601f8311600181146103685760008415610356578287015190505b61036085826102e2565b8655506103c8565b601f19841661037686610148565b60005b8281101561039e57848901518255600182019150602085019450602081019050610379565b868310156103bb57848901516103b7601f8916826102c4565b8355505b6001600288020188555050505b505050505050565b610c2c806103df6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b07506111161005b578063b075061114610101578063ca3254691461011f578063e21f37ce1461013d578063ed6b866b1461015b57610088565b8063050337a21461008d5780631544298e146100ab5780633749c51a146100c95780633ff0693c146100e5575b600080fd5b610095610179565b6040516100a29190610480565b60405180910390f35b6100b361017f565b6040516100c09190610480565b60405180910390f35b6100e360048036038101906100de91906104c9565b610185565b005b6100ff60048036038101906100fa9190610531565b610231565b005b61010961031f565b6040516101169190610480565b60405180910390f35b610127610325565b60405161013491906105bb565b60405180910390f35b61014561034b565b6040516101529190610666565b60405180910390f35b6101636103d9565b6040516101709190610666565b60405180910390f35b60045481565b60015481565b8080600001906101959190610697565b600091826101a4929190610940565b5080602001356001819055508060400160208101906101c39190610a3c565b600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806060013560048190555080806080019061021e9190610697565b6005918261022d929190610940565b5050565b8060000160208101906102449190610a3c565b6040516020016102549190610ab1565b604051602081830303815290604052600090816102719190610acc565b50806020013560018190555080806040019061028d9190610697565b60405161029b929190610bdd565b604051809103902060001c600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080606001356003819055508060800135600481905550808060a0019061030c9190610697565b6005918261031b929190610940565b5050565b60035481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6005805461035890610763565b80601f016020809104026020016040519081016040528092919081815260200182805461038490610763565b80156103d15780601f106103a6576101008083540402835291602001916103d1565b820191906000526020600020905b8154815290600101906020018083116103b457829003601f168201915b505050505081565b600080546103e690610763565b80601f016020809104026020016040519081016040528092919081815260200182805461041290610763565b801561045f5780601f106104345761010080835404028352916020019161045f565b820191906000526020600020905b81548152906001019060200180831161044257829003601f168201915b505050505081565b6000819050919050565b61047a81610467565b82525050565b60006020820190506104956000830184610471565b92915050565b600080fd5b600080fd5b600080fd5b600060a082840312156104c0576104bf6104a5565b5b81905092915050565b6000602082840312156104df576104de61049b565b5b600082013567ffffffffffffffff8111156104fd576104fc6104a0565b5b610509848285016104aa565b91505092915050565b600060c08284031215610528576105276104a5565b5b81905092915050565b6000602082840312156105475761054661049b565b5b600082013567ffffffffffffffff811115610565576105646104a0565b5b61057184828501610512565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105a58261057a565b9050919050565b6105b58161059a565b82525050565b60006020820190506105d060008301846105ac565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156106105780820151818401526020810190506105f5565b60008484015250505050565b6000601f19601f8301169050919050565b6000610638826105d6565b61064281856105e1565b93506106528185602086016105f2565b61065b8161061c565b840191505092915050565b60006020820190508181036000830152610680818461062d565b905092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126106b4576106b3610688565b5b80840192508235915067ffffffffffffffff8211156106d6576106d561068d565b5b6020830192506001820236038313156106f2576106f1610692565b5b509250929050565b600082905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061077b57607f821691505b60208210810361078e5761078d610734565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026107f67fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107b9565b61080086836107b9565b95508019841693508086168417925050509392505050565b6000819050919050565b600061083d61083861083384610467565b610818565b610467565b9050919050565b6000819050919050565b61085783610822565b61086b61086382610844565b8484546107c6565b825550505050565b600090565b610880610873565b61088b81848461084e565b505050565b5b818110156108af576108a4600082610878565b600181019050610891565b5050565b601f8211156108f4576108c581610794565b6108ce846107a9565b810160208510156108dd578190505b6108f16108e9856107a9565b830182610890565b50505b505050565b600082821c905092915050565b6000610917600019846008026108f9565b1980831691505092915050565b60006109308383610906565b9150826002028217905092915050565b61094a83836106fa565b67ffffffffffffffff81111561096357610962610705565b5b61096d8254610763565b6109788282856108b3565b6000601f8311600181146109a75760008415610995578287013590505b61099f8582610924565b865550610a07565b601f1984166109b586610794565b60005b828110156109dd578489013582556001820191506020850194506020810190506109b8565b868310156109fa57848901356109f6601f891682610906565b8355505b6001600288020188555050505b50505050505050565b610a198161059a565b8114610a2457600080fd5b50565b600081359050610a3681610a10565b92915050565b600060208284031215610a5257610a5161049b565b5b6000610a6084828501610a27565b91505092915050565b60008160601b9050919050565b6000610a8182610a69565b9050919050565b6000610a9382610a76565b9050919050565b610aab610aa68261059a565b610a88565b82525050565b6000610abd8284610a9a565b60148201915081905092915050565b610ad5826105d6565b67ffffffffffffffff811115610aee57610aed610705565b5b610af88254610763565b610b038282856108b3565b600060209050601f831160018114610b365760008415610b24578287015190505b610b2e8582610924565b865550610b96565b601f198416610b4486610794565b60005b82811015610b6c57848901518255600182019150602085019450602081019050610b47565b86831015610b895784890151610b85601f891682610906565b8355505b6001600288020188555050505b505050505050565b600081905092915050565b82818337600083830152505050565b6000610bc48385610b9e565b9350610bd1838584610ba9565b82840190509392505050565b6000610bea828486610bb8565b9150819050939250505056fea26469706673582212207c5ed9b805f7e22d563799330b1c6e310dd5b1625dc35c9598846e17a8a5686664736f6c63430008190033 diff --git a/testutil/contracts/Dapp.go b/testutil/contracts/Dapp.go new file mode 100644 index 0000000000..075e1d24dc --- /dev/null +++ b/testutil/contracts/Dapp.go @@ -0,0 +1,449 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// ZetaInterfacesZetaMessage is an auto generated low-level Go binding around an user-defined struct. +type ZetaInterfacesZetaMessage struct { + ZetaTxSenderAddress []byte + SourceChainId *big.Int + DestinationAddress common.Address + ZetaValue *big.Int + Message []byte +} + +// ZetaInterfacesZetaRevert is an auto generated low-level Go binding around an user-defined struct. +type ZetaInterfacesZetaRevert struct { + ZetaTxSenderAddress common.Address + SourceChainId *big.Int + DestinationAddress []byte + DestinationChainId *big.Int + RemainingZetaValue *big.Int + Message []byte +} + +// DappMetaData contains all meta data concerning the Dapp contract. +var DappMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"destinationAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"destinationChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"message\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"zetaTxSenderAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"sourceChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"zetaValue\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structZetaInterfaces.ZetaMessage\",\"name\":\"zetaMessage\",\"type\":\"tuple\"}],\"name\":\"onZetaMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"zetaTxSenderAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"sourceChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"destinationAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"destinationChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"remainingZetaValue\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structZetaInterfaces.ZetaRevert\",\"name\":\"zetaRevert\",\"type\":\"tuple\"}],\"name\":\"onZetaRevert\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sourceChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"zetaTxSenderAddress\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"zetaValue\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50604051806020016040528060008152506000908161002f91906102fe565b5060006001819055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600381905550600060048190555060405180602001604052806000815250600590816100a891906102fe565b506103d0565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061012f57607f821691505b602082108103610142576101416100e8565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026101aa7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261016d565b6101b4868361016d565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006101fb6101f66101f1846101cc565b6101d6565b6101cc565b9050919050565b6000819050919050565b610215836101e0565b61022961022182610202565b84845461017a565b825550505050565b600090565b61023e610231565b61024981848461020c565b505050565b5b8181101561026d57610262600082610236565b60018101905061024f565b5050565b601f8211156102b25761028381610148565b61028c8461015d565b8101602085101561029b578190505b6102af6102a78561015d565b83018261024e565b50505b505050565b600082821c905092915050565b60006102d5600019846008026102b7565b1980831691505092915050565b60006102ee83836102c4565b9150826002028217905092915050565b610307826100ae565b67ffffffffffffffff8111156103205761031f6100b9565b5b61032a8254610117565b610335828285610271565b600060209050601f8311600181146103685760008415610356578287015190505b61036085826102e2565b8655506103c8565b601f19841661037686610148565b60005b8281101561039e57848901518255600182019150602085019450602081019050610379565b868310156103bb57848901516103b7601f8916826102c4565b8355505b6001600288020188555050505b505050505050565b610c2c806103df6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b07506111161005b578063b075061114610101578063ca3254691461011f578063e21f37ce1461013d578063ed6b866b1461015b57610088565b8063050337a21461008d5780631544298e146100ab5780633749c51a146100c95780633ff0693c146100e5575b600080fd5b610095610179565b6040516100a29190610480565b60405180910390f35b6100b361017f565b6040516100c09190610480565b60405180910390f35b6100e360048036038101906100de91906104c9565b610185565b005b6100ff60048036038101906100fa9190610531565b610231565b005b61010961031f565b6040516101169190610480565b60405180910390f35b610127610325565b60405161013491906105bb565b60405180910390f35b61014561034b565b6040516101529190610666565b60405180910390f35b6101636103d9565b6040516101709190610666565b60405180910390f35b60045481565b60015481565b8080600001906101959190610697565b600091826101a4929190610940565b5080602001356001819055508060400160208101906101c39190610a3c565b600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806060013560048190555080806080019061021e9190610697565b6005918261022d929190610940565b5050565b8060000160208101906102449190610a3c565b6040516020016102549190610ab1565b604051602081830303815290604052600090816102719190610acc565b50806020013560018190555080806040019061028d9190610697565b60405161029b929190610bdd565b604051809103902060001c600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080606001356003819055508060800135600481905550808060a0019061030c9190610697565b6005918261031b929190610940565b5050565b60035481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6005805461035890610763565b80601f016020809104026020016040519081016040528092919081815260200182805461038490610763565b80156103d15780601f106103a6576101008083540402835291602001916103d1565b820191906000526020600020905b8154815290600101906020018083116103b457829003601f168201915b505050505081565b600080546103e690610763565b80601f016020809104026020016040519081016040528092919081815260200182805461041290610763565b801561045f5780601f106104345761010080835404028352916020019161045f565b820191906000526020600020905b81548152906001019060200180831161044257829003601f168201915b505050505081565b6000819050919050565b61047a81610467565b82525050565b60006020820190506104956000830184610471565b92915050565b600080fd5b600080fd5b600080fd5b600060a082840312156104c0576104bf6104a5565b5b81905092915050565b6000602082840312156104df576104de61049b565b5b600082013567ffffffffffffffff8111156104fd576104fc6104a0565b5b610509848285016104aa565b91505092915050565b600060c08284031215610528576105276104a5565b5b81905092915050565b6000602082840312156105475761054661049b565b5b600082013567ffffffffffffffff811115610565576105646104a0565b5b61057184828501610512565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105a58261057a565b9050919050565b6105b58161059a565b82525050565b60006020820190506105d060008301846105ac565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156106105780820151818401526020810190506105f5565b60008484015250505050565b6000601f19601f8301169050919050565b6000610638826105d6565b61064281856105e1565b93506106528185602086016105f2565b61065b8161061c565b840191505092915050565b60006020820190508181036000830152610680818461062d565b905092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126106b4576106b3610688565b5b80840192508235915067ffffffffffffffff8211156106d6576106d561068d565b5b6020830192506001820236038313156106f2576106f1610692565b5b509250929050565b600082905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061077b57607f821691505b60208210810361078e5761078d610734565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026107f67fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107b9565b61080086836107b9565b95508019841693508086168417925050509392505050565b6000819050919050565b600061083d61083861083384610467565b610818565b610467565b9050919050565b6000819050919050565b61085783610822565b61086b61086382610844565b8484546107c6565b825550505050565b600090565b610880610873565b61088b81848461084e565b505050565b5b818110156108af576108a4600082610878565b600181019050610891565b5050565b601f8211156108f4576108c581610794565b6108ce846107a9565b810160208510156108dd578190505b6108f16108e9856107a9565b830182610890565b50505b505050565b600082821c905092915050565b6000610917600019846008026108f9565b1980831691505092915050565b60006109308383610906565b9150826002028217905092915050565b61094a83836106fa565b67ffffffffffffffff81111561096357610962610705565b5b61096d8254610763565b6109788282856108b3565b6000601f8311600181146109a75760008415610995578287013590505b61099f8582610924565b865550610a07565b601f1984166109b586610794565b60005b828110156109dd578489013582556001820191506020850194506020810190506109b8565b868310156109fa57848901356109f6601f891682610906565b8355505b6001600288020188555050505b50505050505050565b610a198161059a565b8114610a2457600080fd5b50565b600081359050610a3681610a10565b92915050565b600060208284031215610a5257610a5161049b565b5b6000610a6084828501610a27565b91505092915050565b60008160601b9050919050565b6000610a8182610a69565b9050919050565b6000610a9382610a76565b9050919050565b610aab610aa68261059a565b610a88565b82525050565b6000610abd8284610a9a565b60148201915081905092915050565b610ad5826105d6565b67ffffffffffffffff811115610aee57610aed610705565b5b610af88254610763565b610b038282856108b3565b600060209050601f831160018114610b365760008415610b24578287015190505b610b2e8582610924565b865550610b96565b601f198416610b4486610794565b60005b82811015610b6c57848901518255600182019150602085019450602081019050610b47565b86831015610b895784890151610b85601f891682610906565b8355505b6001600288020188555050505b505050505050565b600081905092915050565b82818337600083830152505050565b6000610bc48385610b9e565b9350610bd1838584610ba9565b82840190509392505050565b6000610bea828486610bb8565b9150819050939250505056fea26469706673582212207c5ed9b805f7e22d563799330b1c6e310dd5b1625dc35c9598846e17a8a5686664736f6c63430008190033", +} + +// DappABI is the input ABI used to generate the binding from. +// Deprecated: Use DappMetaData.ABI instead. +var DappABI = DappMetaData.ABI + +// DappBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use DappMetaData.Bin instead. +var DappBin = DappMetaData.Bin + +// DeployDapp deploys a new Ethereum contract, binding an instance of Dapp to it. +func DeployDapp(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Dapp, error) { + parsed, err := DappMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(DappBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &Dapp{DappCaller: DappCaller{contract: contract}, DappTransactor: DappTransactor{contract: contract}, DappFilterer: DappFilterer{contract: contract}}, nil +} + +// Dapp is an auto generated Go binding around an Ethereum contract. +type Dapp struct { + DappCaller // Read-only binding to the contract + DappTransactor // Write-only binding to the contract + DappFilterer // Log filterer for contract events +} + +// DappCaller is an auto generated read-only Go binding around an Ethereum contract. +type DappCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappTransactor is an auto generated write-only Go binding around an Ethereum contract. +type DappTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type DappFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type DappSession struct { + Contract *Dapp // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DappCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type DappCallerSession struct { + Contract *DappCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// DappTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type DappTransactorSession struct { + Contract *DappTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DappRaw is an auto generated low-level Go binding around an Ethereum contract. +type DappRaw struct { + Contract *Dapp // Generic contract binding to access the raw methods on +} + +// DappCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type DappCallerRaw struct { + Contract *DappCaller // Generic read-only contract binding to access the raw methods on +} + +// DappTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type DappTransactorRaw struct { + Contract *DappTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewDapp creates a new instance of Dapp, bound to a specific deployed contract. +func NewDapp(address common.Address, backend bind.ContractBackend) (*Dapp, error) { + contract, err := bindDapp(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Dapp{DappCaller: DappCaller{contract: contract}, DappTransactor: DappTransactor{contract: contract}, DappFilterer: DappFilterer{contract: contract}}, nil +} + +// NewDappCaller creates a new read-only instance of Dapp, bound to a specific deployed contract. +func NewDappCaller(address common.Address, caller bind.ContractCaller) (*DappCaller, error) { + contract, err := bindDapp(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &DappCaller{contract: contract}, nil +} + +// NewDappTransactor creates a new write-only instance of Dapp, bound to a specific deployed contract. +func NewDappTransactor(address common.Address, transactor bind.ContractTransactor) (*DappTransactor, error) { + contract, err := bindDapp(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &DappTransactor{contract: contract}, nil +} + +// NewDappFilterer creates a new log filterer instance of Dapp, bound to a specific deployed contract. +func NewDappFilterer(address common.Address, filterer bind.ContractFilterer) (*DappFilterer, error) { + contract, err := bindDapp(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &DappFilterer{contract: contract}, nil +} + +// bindDapp binds a generic wrapper to an already deployed contract. +func bindDapp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(DappABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Dapp *DappRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Dapp.Contract.DappCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Dapp *DappRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Dapp.Contract.DappTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Dapp *DappRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Dapp.Contract.DappTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Dapp *DappCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Dapp.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Dapp *DappTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Dapp.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Dapp *DappTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Dapp.Contract.contract.Transact(opts, method, params...) +} + +// DestinationAddress is a free data retrieval call binding the contract method 0xca325469. +// +// Solidity: function destinationAddress() view returns(address) +func (_Dapp *DappCaller) DestinationAddress(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "destinationAddress") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// DestinationAddress is a free data retrieval call binding the contract method 0xca325469. +// +// Solidity: function destinationAddress() view returns(address) +func (_Dapp *DappSession) DestinationAddress() (common.Address, error) { + return _Dapp.Contract.DestinationAddress(&_Dapp.CallOpts) +} + +// DestinationAddress is a free data retrieval call binding the contract method 0xca325469. +// +// Solidity: function destinationAddress() view returns(address) +func (_Dapp *DappCallerSession) DestinationAddress() (common.Address, error) { + return _Dapp.Contract.DestinationAddress(&_Dapp.CallOpts) +} + +// DestinationChainId is a free data retrieval call binding the contract method 0xb0750611. +// +// Solidity: function destinationChainId() view returns(uint256) +func (_Dapp *DappCaller) DestinationChainId(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "destinationChainId") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// DestinationChainId is a free data retrieval call binding the contract method 0xb0750611. +// +// Solidity: function destinationChainId() view returns(uint256) +func (_Dapp *DappSession) DestinationChainId() (*big.Int, error) { + return _Dapp.Contract.DestinationChainId(&_Dapp.CallOpts) +} + +// DestinationChainId is a free data retrieval call binding the contract method 0xb0750611. +// +// Solidity: function destinationChainId() view returns(uint256) +func (_Dapp *DappCallerSession) DestinationChainId() (*big.Int, error) { + return _Dapp.Contract.DestinationChainId(&_Dapp.CallOpts) +} + +// Message is a free data retrieval call binding the contract method 0xe21f37ce. +// +// Solidity: function message() view returns(bytes) +func (_Dapp *DappCaller) Message(opts *bind.CallOpts) ([]byte, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "message") + + if err != nil { + return *new([]byte), err + } + + out0 := *abi.ConvertType(out[0], new([]byte)).(*[]byte) + + return out0, err + +} + +// Message is a free data retrieval call binding the contract method 0xe21f37ce. +// +// Solidity: function message() view returns(bytes) +func (_Dapp *DappSession) Message() ([]byte, error) { + return _Dapp.Contract.Message(&_Dapp.CallOpts) +} + +// Message is a free data retrieval call binding the contract method 0xe21f37ce. +// +// Solidity: function message() view returns(bytes) +func (_Dapp *DappCallerSession) Message() ([]byte, error) { + return _Dapp.Contract.Message(&_Dapp.CallOpts) +} + +// SourceChainId is a free data retrieval call binding the contract method 0x1544298e. +// +// Solidity: function sourceChainId() view returns(uint256) +func (_Dapp *DappCaller) SourceChainId(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "sourceChainId") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// SourceChainId is a free data retrieval call binding the contract method 0x1544298e. +// +// Solidity: function sourceChainId() view returns(uint256) +func (_Dapp *DappSession) SourceChainId() (*big.Int, error) { + return _Dapp.Contract.SourceChainId(&_Dapp.CallOpts) +} + +// SourceChainId is a free data retrieval call binding the contract method 0x1544298e. +// +// Solidity: function sourceChainId() view returns(uint256) +func (_Dapp *DappCallerSession) SourceChainId() (*big.Int, error) { + return _Dapp.Contract.SourceChainId(&_Dapp.CallOpts) +} + +// ZetaTxSenderAddress is a free data retrieval call binding the contract method 0xed6b866b. +// +// Solidity: function zetaTxSenderAddress() view returns(bytes) +func (_Dapp *DappCaller) ZetaTxSenderAddress(opts *bind.CallOpts) ([]byte, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "zetaTxSenderAddress") + + if err != nil { + return *new([]byte), err + } + + out0 := *abi.ConvertType(out[0], new([]byte)).(*[]byte) + + return out0, err + +} + +// ZetaTxSenderAddress is a free data retrieval call binding the contract method 0xed6b866b. +// +// Solidity: function zetaTxSenderAddress() view returns(bytes) +func (_Dapp *DappSession) ZetaTxSenderAddress() ([]byte, error) { + return _Dapp.Contract.ZetaTxSenderAddress(&_Dapp.CallOpts) +} + +// ZetaTxSenderAddress is a free data retrieval call binding the contract method 0xed6b866b. +// +// Solidity: function zetaTxSenderAddress() view returns(bytes) +func (_Dapp *DappCallerSession) ZetaTxSenderAddress() ([]byte, error) { + return _Dapp.Contract.ZetaTxSenderAddress(&_Dapp.CallOpts) +} + +// ZetaValue is a free data retrieval call binding the contract method 0x050337a2. +// +// Solidity: function zetaValue() view returns(uint256) +func (_Dapp *DappCaller) ZetaValue(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Dapp.contract.Call(opts, &out, "zetaValue") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ZetaValue is a free data retrieval call binding the contract method 0x050337a2. +// +// Solidity: function zetaValue() view returns(uint256) +func (_Dapp *DappSession) ZetaValue() (*big.Int, error) { + return _Dapp.Contract.ZetaValue(&_Dapp.CallOpts) +} + +// ZetaValue is a free data retrieval call binding the contract method 0x050337a2. +// +// Solidity: function zetaValue() view returns(uint256) +func (_Dapp *DappCallerSession) ZetaValue() (*big.Int, error) { + return _Dapp.Contract.ZetaValue(&_Dapp.CallOpts) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x3749c51a. +// +// Solidity: function onZetaMessage((bytes,uint256,address,uint256,bytes) zetaMessage) returns() +func (_Dapp *DappTransactor) OnZetaMessage(opts *bind.TransactOpts, zetaMessage ZetaInterfacesZetaMessage) (*types.Transaction, error) { + return _Dapp.contract.Transact(opts, "onZetaMessage", zetaMessage) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x3749c51a. +// +// Solidity: function onZetaMessage((bytes,uint256,address,uint256,bytes) zetaMessage) returns() +func (_Dapp *DappSession) OnZetaMessage(zetaMessage ZetaInterfacesZetaMessage) (*types.Transaction, error) { + return _Dapp.Contract.OnZetaMessage(&_Dapp.TransactOpts, zetaMessage) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x3749c51a. +// +// Solidity: function onZetaMessage((bytes,uint256,address,uint256,bytes) zetaMessage) returns() +func (_Dapp *DappTransactorSession) OnZetaMessage(zetaMessage ZetaInterfacesZetaMessage) (*types.Transaction, error) { + return _Dapp.Contract.OnZetaMessage(&_Dapp.TransactOpts, zetaMessage) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x3ff0693c. +// +// Solidity: function onZetaRevert((address,uint256,bytes,uint256,uint256,bytes) zetaRevert) returns() +func (_Dapp *DappTransactor) OnZetaRevert(opts *bind.TransactOpts, zetaRevert ZetaInterfacesZetaRevert) (*types.Transaction, error) { + return _Dapp.contract.Transact(opts, "onZetaRevert", zetaRevert) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x3ff0693c. +// +// Solidity: function onZetaRevert((address,uint256,bytes,uint256,uint256,bytes) zetaRevert) returns() +func (_Dapp *DappSession) OnZetaRevert(zetaRevert ZetaInterfacesZetaRevert) (*types.Transaction, error) { + return _Dapp.Contract.OnZetaRevert(&_Dapp.TransactOpts, zetaRevert) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x3ff0693c. +// +// Solidity: function onZetaRevert((address,uint256,bytes,uint256,uint256,bytes) zetaRevert) returns() +func (_Dapp *DappTransactorSession) OnZetaRevert(zetaRevert ZetaInterfacesZetaRevert) (*types.Transaction, error) { + return _Dapp.Contract.OnZetaRevert(&_Dapp.TransactOpts, zetaRevert) +} diff --git a/testutil/contracts/Dapp.json b/testutil/contracts/Dapp.json new file mode 100644 index 0000000000..b2bbb3a299 --- /dev/null +++ b/testutil/contracts/Dapp.json @@ -0,0 +1,173 @@ +{ + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "destinationAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "destinationChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "message", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "zetaTxSenderAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "destinationAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "zetaValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.ZetaMessage", + "name": "zetaMessage", + "type": "tuple" + } + ], + "name": "onZetaMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "zetaTxSenderAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "sourceChainId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "destinationAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "destinationChainId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "remainingZetaValue", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.ZetaRevert", + "name": "zetaRevert", + "type": "tuple" + } + ], + "name": "onZetaRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sourceChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "zetaTxSenderAddress", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "zetaValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bin": "608060405234801561001057600080fd5b50604051806020016040528060008152506000908161002f91906102fe565b5060006001819055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600381905550600060048190555060405180602001604052806000815250600590816100a891906102fe565b506103d0565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061012f57607f821691505b602082108103610142576101416100e8565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026101aa7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261016d565b6101b4868361016d565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006101fb6101f66101f1846101cc565b6101d6565b6101cc565b9050919050565b6000819050919050565b610215836101e0565b61022961022182610202565b84845461017a565b825550505050565b600090565b61023e610231565b61024981848461020c565b505050565b5b8181101561026d57610262600082610236565b60018101905061024f565b5050565b601f8211156102b25761028381610148565b61028c8461015d565b8101602085101561029b578190505b6102af6102a78561015d565b83018261024e565b50505b505050565b600082821c905092915050565b60006102d5600019846008026102b7565b1980831691505092915050565b60006102ee83836102c4565b9150826002028217905092915050565b610307826100ae565b67ffffffffffffffff8111156103205761031f6100b9565b5b61032a8254610117565b610335828285610271565b600060209050601f8311600181146103685760008415610356578287015190505b61036085826102e2565b8655506103c8565b601f19841661037686610148565b60005b8281101561039e57848901518255600182019150602085019450602081019050610379565b868310156103bb57848901516103b7601f8916826102c4565b8355505b6001600288020188555050505b505050505050565b610c2c806103df6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063b07506111161005b578063b075061114610101578063ca3254691461011f578063e21f37ce1461013d578063ed6b866b1461015b57610088565b8063050337a21461008d5780631544298e146100ab5780633749c51a146100c95780633ff0693c146100e5575b600080fd5b610095610179565b6040516100a29190610480565b60405180910390f35b6100b361017f565b6040516100c09190610480565b60405180910390f35b6100e360048036038101906100de91906104c9565b610185565b005b6100ff60048036038101906100fa9190610531565b610231565b005b61010961031f565b6040516101169190610480565b60405180910390f35b610127610325565b60405161013491906105bb565b60405180910390f35b61014561034b565b6040516101529190610666565b60405180910390f35b6101636103d9565b6040516101709190610666565b60405180910390f35b60045481565b60015481565b8080600001906101959190610697565b600091826101a4929190610940565b5080602001356001819055508060400160208101906101c39190610a3c565b600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806060013560048190555080806080019061021e9190610697565b6005918261022d929190610940565b5050565b8060000160208101906102449190610a3c565b6040516020016102549190610ab1565b604051602081830303815290604052600090816102719190610acc565b50806020013560018190555080806040019061028d9190610697565b60405161029b929190610bdd565b604051809103902060001c600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080606001356003819055508060800135600481905550808060a0019061030c9190610697565b6005918261031b929190610940565b5050565b60035481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6005805461035890610763565b80601f016020809104026020016040519081016040528092919081815260200182805461038490610763565b80156103d15780601f106103a6576101008083540402835291602001916103d1565b820191906000526020600020905b8154815290600101906020018083116103b457829003601f168201915b505050505081565b600080546103e690610763565b80601f016020809104026020016040519081016040528092919081815260200182805461041290610763565b801561045f5780601f106104345761010080835404028352916020019161045f565b820191906000526020600020905b81548152906001019060200180831161044257829003601f168201915b505050505081565b6000819050919050565b61047a81610467565b82525050565b60006020820190506104956000830184610471565b92915050565b600080fd5b600080fd5b600080fd5b600060a082840312156104c0576104bf6104a5565b5b81905092915050565b6000602082840312156104df576104de61049b565b5b600082013567ffffffffffffffff8111156104fd576104fc6104a0565b5b610509848285016104aa565b91505092915050565b600060c08284031215610528576105276104a5565b5b81905092915050565b6000602082840312156105475761054661049b565b5b600082013567ffffffffffffffff811115610565576105646104a0565b5b61057184828501610512565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006105a58261057a565b9050919050565b6105b58161059a565b82525050565b60006020820190506105d060008301846105ac565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156106105780820151818401526020810190506105f5565b60008484015250505050565b6000601f19601f8301169050919050565b6000610638826105d6565b61064281856105e1565b93506106528185602086016105f2565b61065b8161061c565b840191505092915050565b60006020820190508181036000830152610680818461062d565b905092915050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126106b4576106b3610688565b5b80840192508235915067ffffffffffffffff8211156106d6576106d561068d565b5b6020830192506001820236038313156106f2576106f1610692565b5b509250929050565b600082905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061077b57607f821691505b60208210810361078e5761078d610734565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026107f67fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107b9565b61080086836107b9565b95508019841693508086168417925050509392505050565b6000819050919050565b600061083d61083861083384610467565b610818565b610467565b9050919050565b6000819050919050565b61085783610822565b61086b61086382610844565b8484546107c6565b825550505050565b600090565b610880610873565b61088b81848461084e565b505050565b5b818110156108af576108a4600082610878565b600181019050610891565b5050565b601f8211156108f4576108c581610794565b6108ce846107a9565b810160208510156108dd578190505b6108f16108e9856107a9565b830182610890565b50505b505050565b600082821c905092915050565b6000610917600019846008026108f9565b1980831691505092915050565b60006109308383610906565b9150826002028217905092915050565b61094a83836106fa565b67ffffffffffffffff81111561096357610962610705565b5b61096d8254610763565b6109788282856108b3565b6000601f8311600181146109a75760008415610995578287013590505b61099f8582610924565b865550610a07565b601f1984166109b586610794565b60005b828110156109dd578489013582556001820191506020850194506020810190506109b8565b868310156109fa57848901356109f6601f891682610906565b8355505b6001600288020188555050505b50505050505050565b610a198161059a565b8114610a2457600080fd5b50565b600081359050610a3681610a10565b92915050565b600060208284031215610a5257610a5161049b565b5b6000610a6084828501610a27565b91505092915050565b60008160601b9050919050565b6000610a8182610a69565b9050919050565b6000610a9382610a76565b9050919050565b610aab610aa68261059a565b610a88565b82525050565b6000610abd8284610a9a565b60148201915081905092915050565b610ad5826105d6565b67ffffffffffffffff811115610aee57610aed610705565b5b610af88254610763565b610b038282856108b3565b600060209050601f831160018114610b365760008415610b24578287015190505b610b2e8582610924565b865550610b96565b601f198416610b4486610794565b60005b82811015610b6c57848901518255600182019150602085019450602081019050610b47565b86831015610b895784890151610b85601f891682610906565b8355505b6001600288020188555050505b505050505050565b600081905092915050565b82818337600083830152505050565b6000610bc48385610b9e565b9350610bd1838584610ba9565b82840190509392505050565b6000610bea828486610bb8565b9150819050939250505056fea26469706673582212207c5ed9b805f7e22d563799330b1c6e310dd5b1625dc35c9598846e17a8a5686664736f6c63430008190033" +} diff --git a/testutil/contracts/Dapp.sol b/testutil/contracts/Dapp.sol new file mode 100644 index 0000000000..c8deef9e6b --- /dev/null +++ b/testutil/contracts/Dapp.sol @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.7; + +interface ZetaInterfaces { + /** + * @dev Use SendInput to interact with the Connector: connector.send(SendInput) + */ + struct SendInput { + /// @dev Chain id of the destination chain. More about chain ids https://docs.zetachain.com/learn/glossary#chain-id + uint256 destinationChainId; + /// @dev Address receiving the message on the destination chain (expressed in bytes since it can be non-EVM) + bytes destinationAddress; + /// @dev Gas limit for the destination chain's transaction + uint256 destinationGasLimit; + /// @dev An encoded, arbitrary message to be parsed by the destination contract + bytes message; + /// @dev ZETA to be sent cross-chain + ZetaChain gas fees + destination chain gas fees (expressed in ZETA) + uint256 zetaValueAndGas; + /// @dev Optional parameters for the ZetaChain protocol + bytes zetaParams; + } + + /** + * @dev Our Connector calls onZetaMessage with this struct as argument + */ + struct ZetaMessage { + bytes zetaTxSenderAddress; + uint256 sourceChainId; + address destinationAddress; + /// @dev Remaining ZETA from zetaValueAndGas after subtracting ZetaChain gas fees and destination gas fees + uint256 zetaValue; + bytes message; + } + + /** + * @dev Our Connector calls onZetaRevert with this struct as argument + */ + struct ZetaRevert { + address zetaTxSenderAddress; + uint256 sourceChainId; + bytes destinationAddress; + uint256 destinationChainId; + /// @dev Equals to: zetaValueAndGas - ZetaChain gas fees - destination chain gas fees - source chain revert tx gas fees + uint256 remainingZetaValue; + bytes message; + } +} + +// Dapp is a sample comtract that implements ZetaReceiver and is used for unit testing +// It sets the values of the ZetaMessage struct to its public variables which can then be queried to check if the function was called correctly +contract Dapp { + bytes public zetaTxSenderAddress; + uint256 public sourceChainId; + address public destinationAddress; + uint256 public destinationChainId; + uint256 public zetaValue; + bytes public message; + + constructor() { + zetaTxSenderAddress = ""; + sourceChainId = 0; + destinationAddress = address(0); + destinationChainId = 0; + zetaValue = 0; + message = ""; + } + + function onZetaMessage(ZetaInterfaces.ZetaMessage calldata zetaMessage) external{ + zetaTxSenderAddress = zetaMessage.zetaTxSenderAddress; + sourceChainId = zetaMessage.sourceChainId; + destinationAddress = zetaMessage.destinationAddress; + zetaValue = zetaMessage.zetaValue; + message = zetaMessage.message; + } + function onZetaRevert(ZetaInterfaces.ZetaRevert calldata zetaRevert) external { + zetaTxSenderAddress = abi.encodePacked(zetaRevert.zetaTxSenderAddress); + sourceChainId = zetaRevert.sourceChainId; + destinationAddress = address(uint160(uint256(keccak256(zetaRevert.destinationAddress)))); + destinationChainId = zetaRevert.destinationChainId; + zetaValue = zetaRevert.remainingZetaValue; + message = zetaRevert.message; + } +} \ No newline at end of file diff --git a/testutil/contracts/DappReverter.abi b/testutil/contracts/DappReverter.abi new file mode 100644 index 0000000000..8d7a270e57 --- /dev/null +++ b/testutil/contracts/DappReverter.abi @@ -0,0 +1,16 @@ +[ + { + "inputs": [], + "name": "onZetaMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "onZetaRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/testutil/contracts/DappReverter.bin b/testutil/contracts/DappReverter.bin new file mode 100644 index 0000000000..8971240dc6 --- /dev/null +++ b/testutil/contracts/DappReverter.bin @@ -0,0 +1 @@ +6080604052348015600f57600080fd5b50608180601d6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063705847b71460375780639a19074914603f575b600080fd5b603d6047565b005b60456049565b005b565b56fea26469706673582212202ae32d3809d629fd01d309562a51297d761f547f4633bf45c73bf33c9955651164736f6c63430008190033 diff --git a/testutil/contracts/DappReverter.go b/testutil/contracts/DappReverter.go new file mode 100644 index 0000000000..590b28f515 --- /dev/null +++ b/testutil/contracts/DappReverter.go @@ -0,0 +1,244 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contracts + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// DappReverterMetaData contains all meta data concerning the DappReverter contract. +var DappReverterMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"onZetaMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"onZetaRevert\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x6080604052348015600f57600080fd5b50608180601d6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063705847b71460375780639a19074914603f575b600080fd5b603d6047565b005b60456049565b005b565b56fea26469706673582212202ae32d3809d629fd01d309562a51297d761f547f4633bf45c73bf33c9955651164736f6c63430008190033", +} + +// DappReverterABI is the input ABI used to generate the binding from. +// Deprecated: Use DappReverterMetaData.ABI instead. +var DappReverterABI = DappReverterMetaData.ABI + +// DappReverterBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use DappReverterMetaData.Bin instead. +var DappReverterBin = DappReverterMetaData.Bin + +// DeployDappReverter deploys a new Ethereum contract, binding an instance of DappReverter to it. +func DeployDappReverter(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *DappReverter, error) { + parsed, err := DappReverterMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(DappReverterBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &DappReverter{DappReverterCaller: DappReverterCaller{contract: contract}, DappReverterTransactor: DappReverterTransactor{contract: contract}, DappReverterFilterer: DappReverterFilterer{contract: contract}}, nil +} + +// DappReverter is an auto generated Go binding around an Ethereum contract. +type DappReverter struct { + DappReverterCaller // Read-only binding to the contract + DappReverterTransactor // Write-only binding to the contract + DappReverterFilterer // Log filterer for contract events +} + +// DappReverterCaller is an auto generated read-only Go binding around an Ethereum contract. +type DappReverterCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappReverterTransactor is an auto generated write-only Go binding around an Ethereum contract. +type DappReverterTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappReverterFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type DappReverterFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DappReverterSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type DappReverterSession struct { + Contract *DappReverter // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DappReverterCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type DappReverterCallerSession struct { + Contract *DappReverterCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// DappReverterTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type DappReverterTransactorSession struct { + Contract *DappReverterTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DappReverterRaw is an auto generated low-level Go binding around an Ethereum contract. +type DappReverterRaw struct { + Contract *DappReverter // Generic contract binding to access the raw methods on +} + +// DappReverterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type DappReverterCallerRaw struct { + Contract *DappReverterCaller // Generic read-only contract binding to access the raw methods on +} + +// DappReverterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type DappReverterTransactorRaw struct { + Contract *DappReverterTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewDappReverter creates a new instance of DappReverter, bound to a specific deployed contract. +func NewDappReverter(address common.Address, backend bind.ContractBackend) (*DappReverter, error) { + contract, err := bindDappReverter(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &DappReverter{DappReverterCaller: DappReverterCaller{contract: contract}, DappReverterTransactor: DappReverterTransactor{contract: contract}, DappReverterFilterer: DappReverterFilterer{contract: contract}}, nil +} + +// NewDappReverterCaller creates a new read-only instance of DappReverter, bound to a specific deployed contract. +func NewDappReverterCaller(address common.Address, caller bind.ContractCaller) (*DappReverterCaller, error) { + contract, err := bindDappReverter(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &DappReverterCaller{contract: contract}, nil +} + +// NewDappReverterTransactor creates a new write-only instance of DappReverter, bound to a specific deployed contract. +func NewDappReverterTransactor(address common.Address, transactor bind.ContractTransactor) (*DappReverterTransactor, error) { + contract, err := bindDappReverter(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &DappReverterTransactor{contract: contract}, nil +} + +// NewDappReverterFilterer creates a new log filterer instance of DappReverter, bound to a specific deployed contract. +func NewDappReverterFilterer(address common.Address, filterer bind.ContractFilterer) (*DappReverterFilterer, error) { + contract, err := bindDappReverter(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &DappReverterFilterer{contract: contract}, nil +} + +// bindDappReverter binds a generic wrapper to an already deployed contract. +func bindDappReverter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(DappReverterABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_DappReverter *DappReverterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _DappReverter.Contract.DappReverterCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_DappReverter *DappReverterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DappReverter.Contract.DappReverterTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_DappReverter *DappReverterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _DappReverter.Contract.DappReverterTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_DappReverter *DappReverterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _DappReverter.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_DappReverter *DappReverterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DappReverter.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_DappReverter *DappReverterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _DappReverter.Contract.contract.Transact(opts, method, params...) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x705847b7. +// +// Solidity: function onZetaMessage() returns() +func (_DappReverter *DappReverterTransactor) OnZetaMessage(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DappReverter.contract.Transact(opts, "onZetaMessage") +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x705847b7. +// +// Solidity: function onZetaMessage() returns() +func (_DappReverter *DappReverterSession) OnZetaMessage() (*types.Transaction, error) { + return _DappReverter.Contract.OnZetaMessage(&_DappReverter.TransactOpts) +} + +// OnZetaMessage is a paid mutator transaction binding the contract method 0x705847b7. +// +// Solidity: function onZetaMessage() returns() +func (_DappReverter *DappReverterTransactorSession) OnZetaMessage() (*types.Transaction, error) { + return _DappReverter.Contract.OnZetaMessage(&_DappReverter.TransactOpts) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x9a190749. +// +// Solidity: function onZetaRevert() returns() +func (_DappReverter *DappReverterTransactor) OnZetaRevert(opts *bind.TransactOpts) (*types.Transaction, error) { + return _DappReverter.contract.Transact(opts, "onZetaRevert") +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x9a190749. +// +// Solidity: function onZetaRevert() returns() +func (_DappReverter *DappReverterSession) OnZetaRevert() (*types.Transaction, error) { + return _DappReverter.Contract.OnZetaRevert(&_DappReverter.TransactOpts) +} + +// OnZetaRevert is a paid mutator transaction binding the contract method 0x9a190749. +// +// Solidity: function onZetaRevert() returns() +func (_DappReverter *DappReverterTransactorSession) OnZetaRevert() (*types.Transaction, error) { + return _DappReverter.Contract.OnZetaRevert(&_DappReverter.TransactOpts) +} diff --git a/testutil/contracts/DappReverter.json b/testutil/contracts/DappReverter.json new file mode 100644 index 0000000000..25f594b048 --- /dev/null +++ b/testutil/contracts/DappReverter.json @@ -0,0 +1,19 @@ +{ + "abi": [ + { + "inputs": [], + "name": "onZetaMessage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "onZetaRevert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bin": "6080604052348015600f57600080fd5b50608180601d6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063705847b71460375780639a19074914603f575b600080fd5b603d6047565b005b60456049565b005b565b56fea26469706673582212202ae32d3809d629fd01d309562a51297d761f547f4633bf45c73bf33c9955651164736f6c63430008190033" +} diff --git a/testutil/contracts/DappReverter.sol b/testutil/contracts/DappReverter.sol new file mode 100644 index 0000000000..781a9b5cc5 --- /dev/null +++ b/testutil/contracts/DappReverter.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.7; + +// DappReverter is a contract that can be used to test the reversion of a cross-chain call. +// It implements the onZetaMessage and onZetaRevert functions, which are called the ZEVM connector +contract DappReverter { + function onZetaMessage() external{} + function onZetaRevert() external {} +} \ No newline at end of file diff --git a/testutil/contracts/Depositor.bin b/testutil/contracts/Depositor.bin index ee38821756..ecf83280fc 100644 --- a/testutil/contracts/Depositor.bin +++ b/testutil/contracts/Depositor.bin @@ -1 +1 @@ -60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220760a7fe17b2cb5c1149915eaca64e78bee5636d1a85f4e43d923d0c1e246d44864736f6c63430008170033 +60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220a5a92c8f323a5a31ee98d3f743848cbaba73616e237bfd5f78b15847c3c0abb864736f6c63430008190033 diff --git a/testutil/contracts/Depositor.go b/testutil/contracts/Depositor.go index dafc33060e..6c85c24c5e 100644 --- a/testutil/contracts/Depositor.go +++ b/testutil/contracts/Depositor.go @@ -26,13 +26,12 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // DepositorMetaData contains all meta data concerning the Depositor contract. var DepositorMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"custody_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"},{\"internalType\":\"contractIERC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"runDeposits\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220760a7fe17b2cb5c1149915eaca64e78bee5636d1a85f4e43d923d0c1e246d44864736f6c63430008170033", + Bin: "0x60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220a5a92c8f323a5a31ee98d3f743848cbaba73616e237bfd5f78b15847c3c0abb864736f6c63430008190033", } // DepositorABI is the input ABI used to generate the binding from. @@ -157,11 +156,11 @@ func NewDepositorFilterer(address common.Address, filterer bind.ContractFilterer // bindDepositor binds a generic wrapper to an already deployed contract. func bindDepositor(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := DepositorMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(DepositorABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/testutil/contracts/Depositor.json b/testutil/contracts/Depositor.json index 93a4dd6c1e..f54b3e932f 100644 --- a/testutil/contracts/Depositor.json +++ b/testutil/contracts/Depositor.json @@ -45,5 +45,5 @@ "type": "function" } ], - "bin": "60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220760a7fe17b2cb5c1149915eaca64e78bee5636d1a85f4e43d923d0c1e246d44864736f6c63430008170033" + "bin": "60a060405234801561001057600080fd5b5060405161073c38038061073c833981810160405281019061003291906100cf565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050506100fc565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061009c82610071565b9050919050565b6100ac81610091565b81146100b757600080fd5b50565b6000815190506100c9816100a3565b92915050565b6000602082840312156100e5576100e461006c565b5b60006100f3848285016100ba565b91505092915050565b60805161061f61011d6000396000818160e4015261016b015261061f6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80633d496c9314610030575b600080fd5b61004a6004803603810190610045919061032a565b61004c565b005b8473ffffffffffffffffffffffffffffffffffffffff166323b872dd333084886100769190610415565b6040518463ffffffff1660e01b815260040161009493929190610475565b600060405180830381600087803b1580156100ae57600080fd5b505af11580156100c2573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000838761010f9190610415565b6040518363ffffffff1660e01b815260040161012c9291906104ac565b600060405180830381600087803b15801561014657600080fd5b505af115801561015a573d6000803e3d6000fd5b5050505060005b8181101561020b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e609055e8989898989896040518763ffffffff1660e01b81526004016101cc96959493929190610592565b600060405180830381600087803b1580156101e657600080fd5b505af11580156101fa573d6000803e3d6000fd5b505050508080600101915050610161565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126102445761024361021f565b5b8235905067ffffffffffffffff81111561026157610260610224565b5b60208301915083600182028301111561027d5761027c610229565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006102af82610284565b9050919050565b60006102c1826102a4565b9050919050565b6102d1816102b6565b81146102dc57600080fd5b50565b6000813590506102ee816102c8565b92915050565b6000819050919050565b610307816102f4565b811461031257600080fd5b50565b600081359050610324816102fe565b92915050565b600080600080600080600060a0888a03121561034957610348610215565b5b600088013567ffffffffffffffff8111156103675761036661021a565b5b6103738a828b0161022e565b975097505060206103868a828b016102df565b95505060406103978a828b01610315565b945050606088013567ffffffffffffffff8111156103b8576103b761021a565b5b6103c48a828b0161022e565b935093505060806103d78a828b01610315565b91505092959891949750929550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610420826102f4565b915061042b836102f4565b9250828202610439816102f4565b915082820484148315176104505761044f6103e6565b5b5092915050565b610460816102a4565b82525050565b61046f816102f4565b82525050565b600060608201905061048a6000830186610457565b6104976020830185610457565b6104a46040830184610466565b949350505050565b60006040820190506104c16000830185610457565b6104ce6020830184610466565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b600061051283856104d5565b935061051f8385846104e6565b610528836104f5565b840190509392505050565b6000819050919050565b600061055861055361054e84610284565b610533565b610284565b9050919050565b600061056a8261053d565b9050919050565b600061057c8261055f565b9050919050565b61058c81610571565b82525050565b600060808201905081810360008301526105ad81888a610506565b90506105bc6020830187610583565b6105c96040830186610466565b81810360608301526105dc818486610506565b905097965050505050505056fea2646970667358221220a5a92c8f323a5a31ee98d3f743848cbaba73616e237bfd5f78b15847c3c0abb864736f6c63430008190033" } diff --git a/testutil/contracts/Example.bin b/testutil/contracts/Example.bin index 99664eb481..2243b22b87 100644 --- a/testutil/contracts/Example.bin +++ b/testutil/contracts/Example.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b506000808190555061043f806100276000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220938fb59316eb3dc6f80fe78e4272acbfc1f7115cdb0203223aeea348212973f764736f6c63430008170033 +6080604052348015600f57600080fd5b506000808190555061043f806100266000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220c9cedad580b18532a00be1e615813af1c20bb609a0a69b5f36d49ed76cc20b5064736f6c63430008190033 diff --git a/testutil/contracts/Example.go b/testutil/contracts/Example.go index feb9153d4e..ce9cab5826 100644 --- a/testutil/contracts/Example.go +++ b/testutil/contracts/Example.go @@ -26,7 +26,6 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // ExamplezContext is an auto generated low-level Go binding around an user-defined struct. @@ -39,7 +38,7 @@ type ExamplezContext struct { // ExampleMetaData contains all meta data concerning the Example contract. var ExampleMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"Foo\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"bar\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"doRevert\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"doRevertWithMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"doRevertWithRequire\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"doSucceed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structExample.zContext\",\"name\":\"context\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b506000808190555061043f806100276000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220938fb59316eb3dc6f80fe78e4272acbfc1f7115cdb0203223aeea348212973f764736f6c63430008170033", + Bin: "0x6080604052348015600f57600080fd5b506000808190555061043f806100266000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220c9cedad580b18532a00be1e615813af1c20bb609a0a69b5f36d49ed76cc20b5064736f6c63430008190033", } // ExampleABI is the input ABI used to generate the binding from. @@ -164,11 +163,11 @@ func NewExampleFilterer(address common.Address, filterer bind.ContractFilterer) // bindExample binds a generic wrapper to an already deployed contract. func bindExample(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ExampleMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(ExampleABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/testutil/contracts/Example.json b/testutil/contracts/Example.json index 8276007384..9c67ba2186 100644 --- a/testutil/contracts/Example.json +++ b/testutil/contracts/Example.json @@ -97,5 +97,5 @@ "type": "function" } ], - "bin": "608060405234801561001057600080fd5b506000808190555061043f806100276000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220938fb59316eb3dc6f80fe78e4272acbfc1f7115cdb0203223aeea348212973f764736f6c63430008170033" + "bin": "6080604052348015600f57600080fd5b506000808190555061043f806100266000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063afc874d214610067578063d720cb4514610071578063dd8e556c1461007b578063de43156e14610085578063fd5ad965146100a1578063febb0f7e146100ab575b600080fd5b61006f6100c9565b005b6100796100fb565b005b610083610136565b005b61009f600480360381019061009a91906102be565b610179565b005b6100a9610187565b005b6100b3610191565b6040516100c09190610371565b60405180910390f35b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012d906103e9565b60405180910390fd5b6000610177576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016e906103e9565b60405180910390fd5b565b826000819055505050505050565b6001600081905550565b60005481565b600080fd5b600080fd5b600080fd5b6000606082840312156101bc576101bb6101a1565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006101f0826101c5565b9050919050565b610200816101e5565b811461020b57600080fd5b50565b60008135905061021d816101f7565b92915050565b6000819050919050565b61023681610223565b811461024157600080fd5b50565b6000813590506102538161022d565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261027e5761027d610259565b5b8235905067ffffffffffffffff81111561029b5761029a61025e565b5b6020830191508360018202830111156102b7576102b6610263565b5b9250929050565b6000806000806000608086880312156102da576102d9610197565b5b600086013567ffffffffffffffff8111156102f8576102f761019c565b5b610304888289016101a6565b95505060206103158882890161020e565b945050604061032688828901610244565b935050606086013567ffffffffffffffff8111156103475761034661019c565b5b61035388828901610268565b92509250509295509295909350565b61036b81610223565b82525050565b60006020820190506103866000830184610362565b92915050565b600082825260208201905092915050565b7f666f6f0000000000000000000000000000000000000000000000000000000000600082015250565b60006103d360038361038c565b91506103de8261039d565b602082019050919050565b60006020820190508181036000830152610402816103c6565b905091905056fea2646970667358221220c9cedad580b18532a00be1e615813af1c20bb609a0a69b5f36d49ed76cc20b5064736f6c63430008190033" } diff --git a/testutil/contracts/Reverter.bin b/testutil/contracts/Reverter.bin index 99f23ea6b2..582d94be71 100644 --- a/testutil/contracts/Reverter.bin +++ b/testutil/contracts/Reverter.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b5061027f806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212205caf3458b11aefa34e575c056a968a87419cba0e852d4f512f684f63a45c509c64736f6c63430008170033 +6080604052348015600f57600080fd5b5061027f8061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212209d6fef8c2cffe61b2d6b1a5bf4d6f71d1ade0e1a1e6a8c8e9f09fe1c28a520d164736f6c63430008190033 diff --git a/testutil/contracts/Reverter.go b/testutil/contracts/Reverter.go index 57c46137f4..1e551e9362 100644 --- a/testutil/contracts/Reverter.go +++ b/testutil/contracts/Reverter.go @@ -26,7 +26,6 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // ReverterzContext is an auto generated low-level Go binding around an user-defined struct. @@ -39,7 +38,7 @@ type ReverterzContext struct { // ReverterMetaData contains all meta data concerning the Reverter contract. var ReverterMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[],\"name\":\"Foo\",\"type\":\"error\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structReverter.zContext\",\"name\":\"context\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b5061027f806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212205caf3458b11aefa34e575c056a968a87419cba0e852d4f512f684f63a45c509c64736f6c63430008170033", + Bin: "0x6080604052348015600f57600080fd5b5061027f8061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212209d6fef8c2cffe61b2d6b1a5bf4d6f71d1ade0e1a1e6a8c8e9f09fe1c28a520d164736f6c63430008190033", } // ReverterABI is the input ABI used to generate the binding from. @@ -164,11 +163,11 @@ func NewReverterFilterer(address common.Address, filterer bind.ContractFilterer) // bindReverter binds a generic wrapper to an already deployed contract. func bindReverter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ReverterMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(ReverterABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/testutil/contracts/Reverter.json b/testutil/contracts/Reverter.json index d644ed825d..c6ac51dde4 100644 --- a/testutil/contracts/Reverter.json +++ b/testutil/contracts/Reverter.json @@ -51,5 +51,5 @@ "type": "function" } ], - "bin": "608060405234801561001057600080fd5b5061027f806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212205caf3458b11aefa34e575c056a968a87419cba0e852d4f512f684f63a45c509c64736f6c63430008170033" + "bin": "6080604052348015600f57600080fd5b5061027f8061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a600480360381019061004591906101a5565b61004c565b005b6040517fbfb4ebcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080fd5b600080fd5b600080fd5b6000606082840312156100a3576100a2610088565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d7826100ac565b9050919050565b6100e7816100cc565b81146100f257600080fd5b50565b600081359050610104816100de565b92915050565b6000819050919050565b61011d8161010a565b811461012857600080fd5b50565b60008135905061013a81610114565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261016557610164610140565b5b8235905067ffffffffffffffff81111561018257610181610145565b5b60208301915083600182028301111561019e5761019d61014a565b5b9250929050565b6000806000806000608086880312156101c1576101c061007e565b5b600086013567ffffffffffffffff8111156101df576101de610083565b5b6101eb8882890161008d565b95505060206101fc888289016100f5565b945050604061020d8882890161012b565b935050606086013567ffffffffffffffff81111561022e5761022d610083565b5b61023a8882890161014f565b9250925050929550929590935056fea26469706673582212209d6fef8c2cffe61b2d6b1a5bf4d6f71d1ade0e1a1e6a8c8e9f09fe1c28a520d164736f6c63430008190033" } diff --git a/testutil/contracts/Withdrawer.bin b/testutil/contracts/Withdrawer.bin index 3962c86387..b618dfb11d 100644 --- a/testutil/contracts/Withdrawer.bin +++ b/testutil/contracts/Withdrawer.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50610756806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea26469706673582212204ea5580fd884f66b08516c0cea46d9e71553f966a77e2954832ccf2d9abe611b64736f6c63430008170033 +6080604052348015600f57600080fd5b506107568061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea264697066735822122041c37b70ead002476ecfdd58a860341299d12b3a46089a50bd573e25dbb8af3a64736f6c63430008190033 diff --git a/testutil/contracts/Withdrawer.go b/testutil/contracts/Withdrawer.go index 182335fe9b..3fb88de4aa 100644 --- a/testutil/contracts/Withdrawer.go +++ b/testutil/contracts/Withdrawer.go @@ -26,13 +26,12 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // WithdrawerMetaData contains all meta data concerning the Withdrawer contract. var WithdrawerMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"},{\"internalType\":\"contractIZRC20\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"name\":\"runWithdraws\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50610756806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea26469706673582212204ea5580fd884f66b08516c0cea46d9e71553f966a77e2954832ccf2d9abe611b64736f6c63430008170033", + Bin: "0x6080604052348015600f57600080fd5b506107568061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea264697066735822122041c37b70ead002476ecfdd58a860341299d12b3a46089a50bd573e25dbb8af3a64736f6c63430008190033", } // WithdrawerABI is the input ABI used to generate the binding from. @@ -157,11 +156,11 @@ func NewWithdrawerFilterer(address common.Address, filterer bind.ContractFiltere // bindWithdrawer binds a generic wrapper to an already deployed contract. func bindWithdrawer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := WithdrawerMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(WithdrawerABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/testutil/contracts/Withdrawer.json b/testutil/contracts/Withdrawer.json index 58e8ec35b6..75e65977fa 100644 --- a/testutil/contracts/Withdrawer.json +++ b/testutil/contracts/Withdrawer.json @@ -29,5 +29,5 @@ "type": "function" } ], - "bin": "608060405234801561001057600080fd5b50610756806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea26469706673582212204ea5580fd884f66b08516c0cea46d9e71553f966a77e2954832ccf2d9abe611b64736f6c63430008170033" + "bin": "6080604052348015600f57600080fd5b506107568061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e3be6f6814610030575b600080fd5b61004a600480360381019061004591906103ff565b61004c565b005b6000808473ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b815260040160408051808303816000875af115801561009b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bf91906104c8565b915091508173ffffffffffffffffffffffffffffffffffffffff166323b872dd33306001876100ee9190610537565b856100f9919061056b565b6040518463ffffffff1660e01b8152600401610117939291906105cb565b600060405180830381600087803b15801561013157600080fd5b505af1158015610145573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b3866001866101739190610537565b8461017e919061056b565b6040518363ffffffff1660e01b815260040161019b929190610602565b600060405180830381600087803b1580156101b557600080fd5b505af11580156101c9573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff166323b872dd333086886101f7919061056b565b6040518463ffffffff1660e01b8152600401610215939291906105cb565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b5050505060005b838110156102e0578573ffffffffffffffffffffffffffffffffffffffff1663c70126268989886040518463ffffffff1660e01b815260040161028f93929190610689565b6020604051808303816000875af11580156102ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d291906106f3565b50808060010191505061024a565b5050505050505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610319576103186102f4565b5b8235905067ffffffffffffffff811115610336576103356102f9565b5b602083019150836001820283011115610352576103516102fe565b5b9250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061038482610359565b9050919050565b600061039682610379565b9050919050565b6103a68161038b565b81146103b157600080fd5b50565b6000813590506103c38161039d565b92915050565b6000819050919050565b6103dc816103c9565b81146103e757600080fd5b50565b6000813590506103f9816103d3565b92915050565b60008060008060006080868803121561041b5761041a6102ea565b5b600086013567ffffffffffffffff811115610439576104386102ef565b5b61044588828901610303565b95509550506020610458888289016103b4565b9350506040610469888289016103ea565b925050606061047a888289016103ea565b9150509295509295909350565b61049081610379565b811461049b57600080fd5b50565b6000815190506104ad81610487565b92915050565b6000815190506104c2816103d3565b92915050565b600080604083850312156104df576104de6102ea565b5b60006104ed8582860161049e565b92505060206104fe858286016104b3565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610542826103c9565b915061054d836103c9565b925082820190508082111561056557610564610508565b5b92915050565b6000610576826103c9565b9150610581836103c9565b925082820261058f816103c9565b915082820484148315176105a6576105a5610508565b5b5092915050565b6105b681610379565b82525050565b6105c5816103c9565b82525050565b60006060820190506105e060008301866105ad565b6105ed60208301856105ad565b6105fa60408301846105bc565b949350505050565b600060408201905061061760008301856105ad565b61062460208301846105bc565b9392505050565b600082825260208201905092915050565b82818337600083830152505050565b6000601f19601f8301169050919050565b6000610668838561062b565b935061067583858461063c565b61067e8361064b565b840190509392505050565b600060408201905081810360008301526106a481858761065c565b90506106b360208301846105bc565b949350505050565b60008115159050919050565b6106d0816106bb565b81146106db57600080fd5b50565b6000815190506106ed816106c7565b92915050565b600060208284031215610709576107086102ea565b5b6000610717848285016106de565b9150509291505056fea264697066735822122041c37b70ead002476ecfdd58a860341299d12b3a46089a50bd573e25dbb8af3a64736f6c63430008190033" } diff --git a/testutil/contracts/bindings.go b/testutil/contracts/bindings.go index 88052fa2b2..70db08dca4 100644 --- a/testutil/contracts/bindings.go +++ b/testutil/contracts/bindings.go @@ -22,4 +22,17 @@ //go:generate sh -c "cat Withdrawer.json | jq .bin | tr -d '\"' > Withdrawer.bin" //go:generate sh -c "abigen --abi Withdrawer.abi --bin Withdrawer.bin --pkg contracts --type Withdrawer --out Withdrawer.go" +// Dapp +// +//go:generate sh -c "solc --evm-version paris Dapp.sol --combined-json abi,bin | jq '.contracts.\"Dapp.sol:Dapp\"' > Dapp.json" +//go:generate sh -c "cat Dapp.json | jq .abi > Dapp.abi" +//go:generate sh -c "cat Dapp.json | jq .bin | tr -d '\"' > Dapp.bin" +//go:generate sh -c "abigen --abi Dapp.abi --bin Dapp.bin --pkg contracts --type Dapp --out Dapp.go" + +// DappReverter +//go:generate sh -c "solc --evm-version paris DappReverter.sol --combined-json abi,bin | jq '.contracts.\"DappReverter.sol:DappReverter\"' > DappReverter.json" +//go:generate sh -c "cat DappReverter.json | jq .abi > DappReverter.abi" +//go:generate sh -c "cat DappReverter.json | jq .bin | tr -d '\"' > DappReverter.bin" +//go:generate sh -c "abigen --abi DappReverter.abi --bin DappReverter.bin --pkg contracts --type DappReverter --out DappReverter.go" + package contracts diff --git a/testutil/keeper/mocks/crosschain/fungible.go b/testutil/keeper/mocks/crosschain/fungible.go index 0b7fc53c89..1380308910 100644 --- a/testutil/keeper/mocks/crosschain/fungible.go +++ b/testutil/keeper/mocks/crosschain/fungible.go @@ -597,6 +597,66 @@ func (_m *CrosschainFungibleKeeper) WithdrawFromGasStabilityPool(ctx types.Conte return r0 } +// ZEVMDepositAndCallContract provides a mock function with given fields: ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes +func (_m *CrosschainFungibleKeeper) ZETADepositAndCallContract(ctx types.Context, sender common.Address, to common.Address, inboundSenderChainID int64, inboundAmount *big.Int, data []byte, indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { + ret := _m.Called(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + + if len(ret) == 0 { + panic("no return value specified for ZETADepositAndCallContract") + } + + var r0 *evmtypes.MsgEthereumTxResponse + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, common.Address, common.Address, int64, *big.Int, []byte, [32]byte) (*evmtypes.MsgEthereumTxResponse, error)); ok { + return rf(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + } + if rf, ok := ret.Get(0).(func(types.Context, common.Address, common.Address, int64, *big.Int, []byte, [32]byte) *evmtypes.MsgEthereumTxResponse); ok { + r0 = rf(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*evmtypes.MsgEthereumTxResponse) + } + } + + if rf, ok := ret.Get(1).(func(types.Context, common.Address, common.Address, int64, *big.Int, []byte, [32]byte) error); ok { + r1 = rf(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ZEVMRevertAndCallContract provides a mock function with given fields: ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes +func (_m *CrosschainFungibleKeeper) ZETARevertAndCallContract(ctx types.Context, sender common.Address, to common.Address, inboundSenderChainID int64, destinationChainID int64, remainingAmount *big.Int, data []byte, indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { + ret := _m.Called(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) + + if len(ret) == 0 { + panic("no return value specified for ZETARevertAndCallContract") + } + + var r0 *evmtypes.MsgEthereumTxResponse + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, common.Address, common.Address, int64, int64, *big.Int, []byte, [32]byte) (*evmtypes.MsgEthereumTxResponse, error)); ok { + return rf(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) + } + if rf, ok := ret.Get(0).(func(types.Context, common.Address, common.Address, int64, int64, *big.Int, []byte, [32]byte) *evmtypes.MsgEthereumTxResponse); ok { + r0 = rf(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*evmtypes.MsgEthereumTxResponse) + } + } + + if rf, ok := ret.Get(1).(func(types.Context, common.Address, common.Address, int64, int64, *big.Int, []byte, [32]byte) error); ok { + r1 = rf(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // ZRC20DepositAndCallContract provides a mock function with given fields: ctx, from, to, amount, senderChainID, data, coinType, asset func (_m *CrosschainFungibleKeeper) ZRC20DepositAndCallContract(ctx types.Context, from []byte, to common.Address, amount *big.Int, senderChainID int64, data []byte, coinType coin.CoinType, asset string) (*evmtypes.MsgEthereumTxResponse, bool, error) { ret := _m.Called(ctx, from, to, amount, senderChainID, data, coinType, asset) diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index f7b563d2bf..5a0d8aafdb 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -1,6 +1,7 @@ package sample import ( + "encoding/base64" "encoding/json" "math/rand" "testing" @@ -208,7 +209,7 @@ func InboundVote(coinType coin.CoinType, from, to int64) types.MsgVoteOnObserved Receiver: EthAddress().String(), ReceiverChain: Chain(to).GetChainId(), Amount: UintInRange(10000000, 1000000000), - Message: String(), + Message: base64.StdEncoding.EncodeToString(Bytes()), InBlockHeight: Uint64InRange(1, 10000), GasLimit: 1000000000, InTxHash: Hash().String(), diff --git a/x/crosschain/keeper/cctx.go b/x/crosschain/keeper/cctx.go index 10613e2d6c..42604c9098 100644 --- a/x/crosschain/keeper/cctx.go +++ b/x/crosschain/keeper/cctx.go @@ -16,12 +16,26 @@ import ( // 3. set the mapping nonce => cctx // 4. update the zeta accounting func (k Keeper) SetCctxAndNonceToCctxAndInTxHashToCctx(ctx sdk.Context, cctx types.CrossChainTx) { - k.SetCrossChainTx(ctx, cctx) + tss, found := k.zetaObserverKeeper.GetTSS(ctx) + if !found { + return + } + // set mapping nonce => cctxIndex + if cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert { + k.GetObserverKeeper().SetNonceToCctx(ctx, observerTypes.NonceToCctx{ + ChainId: cctx.GetCurrentOutTxParam().ReceiverChainId, + // #nosec G701 always in range + Nonce: int64(cctx.GetCurrentOutTxParam().OutboundTxTssNonce), + CctxIndex: cctx.Index, + Tss: tss.TssPubkey, + }) + } + k.SetCrossChainTx(ctx, cctx) // set mapping inTxHash -> cctxIndex in, _ := k.GetInTxHashToCctx(ctx, cctx.InboundTxParams.InboundTxObservedHash) in.InTxHash = cctx.InboundTxParams.InboundTxObservedHash - found := false + found = false for _, cctxIndex := range in.CctxIndex { if cctxIndex == cctx.Index { found = true @@ -33,20 +47,6 @@ func (k Keeper) SetCctxAndNonceToCctxAndInTxHashToCctx(ctx sdk.Context, cctx typ } k.SetInTxHashToCctx(ctx, in) - tss, found := k.zetaObserverKeeper.GetTSS(ctx) - if !found { - return - } - // set mapping nonce => cctxIndex - if cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert { - k.GetObserverKeeper().SetNonceToCctx(ctx, observerTypes.NonceToCctx{ - ChainId: cctx.GetCurrentOutTxParam().ReceiverChainId, - // #nosec G701 always in range - Nonce: int64(cctx.GetCurrentOutTxParam().OutboundTxTssNonce), - CctxIndex: cctx.Index, - Tss: tss.TssPubkey, - }) - } if cctx.CctxStatus.Status == types.CctxStatus_Aborted && cctx.InboundTxParams.CoinType == coin.CoinType_Zeta { k.AddZetaAbortedAmount(ctx, GetAbortedAmount(cctx)) } diff --git a/x/crosschain/keeper/evm_deposit.go b/x/crosschain/keeper/evm_deposit.go index 0ce56a829c..5b04c7d3b3 100644 --- a/x/crosschain/keeper/evm_deposit.go +++ b/x/crosschain/keeper/evm_deposit.go @@ -1,6 +1,7 @@ package keeper import ( + "encoding/base64" "encoding/hex" "fmt" @@ -21,11 +22,13 @@ import ( // (true, non-nil) means CallEVM() reverted func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (bool, error) { to := ethcommon.HexToAddress(cctx.GetCurrentOutTxParam().Receiver) + sender := ethcommon.HexToAddress(cctx.InboundTxParams.Sender) var ethTxHash ethcommon.Hash inboundAmount := cctx.GetInboundTxParams().Amount.BigInt() inboundSender := cctx.GetInboundTxParams().Sender inboundSenderChainID := cctx.GetInboundTxParams().SenderChainId inboundCoinType := cctx.InboundTxParams.CoinType + if len(ctx.TxBytes()) > 0 { // add event for tendermint transaction hash format hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) @@ -36,9 +39,22 @@ func (k Keeper) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) (boo } if inboundCoinType == coin.CoinType_Zeta { - // if coin type is Zeta, this is a deposit ZETA to zEVM cctx. - err := k.fungibleKeeper.DepositCoinZeta(ctx, to, inboundAmount) + // In case of an error + // - Return true will revert the cctx and create a revert cctx with status PendingRevert + // - Return false will abort the cctx + indexBytes, err := cctx.GetCCTXIndexBytes() + if err != nil { + return false, err + } + data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) if err != nil { + return true, errors.Wrap(types.ErrUnableToDecodeMessageString, err.Error()) + } + // if coin type is Zeta, this is a deposit ZETA to zEVM cctx. + evmTxResponse, err := k.fungibleKeeper.ZETADepositAndCallContract(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) + if fungibletypes.IsContractReverted(evmTxResponse, err) || errShouldRevertCctx(err) { + return true, err + } else if err != nil { return false, err } } else { diff --git a/x/crosschain/keeper/evm_deposit_test.go b/x/crosschain/keeper/evm_deposit_test.go index f82872566a..1f6cd4fad4 100644 --- a/x/crosschain/keeper/evm_deposit_test.go +++ b/x/crosschain/keeper/evm_deposit_test.go @@ -7,6 +7,7 @@ import ( "testing" "cosmossdk.io/math" + ethcommon "github.com/ethereum/go-ethereum/common" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -26,16 +27,19 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) + sender := sample.EthAddress() + senderChainId := int64(0) // expect DepositCoinZeta to be called - fungibleMock.On("DepositCoinZeta", ctx, receiver, amount).Return(nil) + fungibleMock.On("ZETADepositAndCallContract", ctx, ethcommon.HexToAddress(sender.String()), receiver, senderChainId, amount, mock.Anything, mock.Anything).Return(nil, nil) // call HandleEVMDeposit cctx := sample.CrossChainTx(t, "foo") cctx.GetCurrentOutTxParam().Receiver = receiver.String() cctx.GetInboundTxParams().Amount = math.NewUintFromBigInt(amount) cctx.GetInboundTxParams().CoinType = coin.CoinType_Zeta - cctx.GetInboundTxParams().SenderChainId = 0 + cctx.GetInboundTxParams().SenderChainId = senderChainId + cctx.InboundTxParams.Sender = sender.String() reverted, err := k.HandleEVMDeposit( ctx, cctx, @@ -52,19 +56,20 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() + sender := sample.EthAddress() + senderChainId := int64(0) amount := big.NewInt(42) - + cctx := sample.CrossChainTx(t, "foo") // expect DepositCoinZeta to be called errDeposit := errors.New("deposit failed") - fungibleMock.On("DepositCoinZeta", ctx, receiver, amount).Return(errDeposit) - + fungibleMock.On("ZETADepositAndCallContract", ctx, ethcommon.HexToAddress(sender.String()), receiver, senderChainId, amount, mock.Anything, mock.Anything).Return(nil, errDeposit) // call HandleEVMDeposit - cctx := sample.CrossChainTx(t, "foo") + cctx.InboundTxParams.Sender = sender.String() cctx.GetCurrentOutTxParam().Receiver = receiver.String() cctx.GetInboundTxParams().Amount = math.NewUintFromBigInt(amount) cctx.GetInboundTxParams().CoinType = coin.CoinType_Zeta - cctx.GetInboundTxParams().SenderChainId = 0 + cctx.GetInboundTxParams().SenderChainId = senderChainId reverted, err := k.HandleEVMDeposit( ctx, cctx, diff --git a/x/crosschain/keeper/evm_hooks.go b/x/crosschain/keeper/evm_hooks.go index 5ca8c8e814..0bdda7a6ae 100644 --- a/x/crosschain/keeper/evm_hooks.go +++ b/x/crosschain/keeper/evm_hooks.go @@ -1,6 +1,7 @@ package keeper import ( + "encoding/base64" "encoding/hex" "fmt" "math/big" @@ -13,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" evmtypes "github.com/evmos/ethermint/x/evm/types" - connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" + connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/pkg/chains" @@ -224,7 +225,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC return fmt.Errorf("ProcessZetaSentEvent: failed to convert chainID: %s", err.Error()) } amount := math.NewUintFromBigInt(event.ZetaValueAndGas) - + messageString := base64.StdEncoding.EncodeToString(event.Message) // Bump gasLimit by event index (which is very unlikely to be larger than 1000) to always have different ZetaSent events msgs. msg := types.NewMsgVoteOnObservedInboundTx( "", @@ -233,7 +234,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC txOrigin, toAddr, receiverChain.ChainId, amount, - "", + messageString, event.Raw.TxHash.String(), event.Raw.BlockNumber, 90000, diff --git a/x/crosschain/keeper/gas_payment.go b/x/crosschain/keeper/gas_payment.go index fe51187199..a26658534c 100644 --- a/x/crosschain/keeper/gas_payment.go +++ b/x/crosschain/keeper/gas_payment.go @@ -295,7 +295,6 @@ func (k Keeper) PayGasInZetaAndUpdateCctx( return cosmoserrors.Wrap(err, "PayGasInZetaAndUpdateCctx: unable to QueryUniswapV2RouterGetZetaAmountsIn") } feeInZeta := types.GetProtocolFee().Add(math.NewUintFromBigInt(outTxGasFeeInZeta)) - // reduce the amount of the outbound tx if feeInZeta.GT(zetaBurnt) { return cosmoserrors.Wrap(types.ErrNotEnoughZetaBurnt, fmt.Sprintf("feeInZeta(%s) more than zetaBurnt (%s) | Identifiers : %s ", diff --git a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go index 5704fdc54a..306b977ed9 100644 --- a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go +++ b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx_test.go @@ -6,6 +6,7 @@ import ( "testing" "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/testutil/sample" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -134,6 +135,7 @@ func createInTxHashToCctxWithCctxs(keeper *crosschainkeeper.Keeper, ctx sdk.Cont cctxs[i].Index = fmt.Sprintf("0x123%d", i) cctxs[i].ZetaFees = math.OneUint() cctxs[i].InboundTxParams = &types.InboundTxParams{InboundTxObservedHash: fmt.Sprintf("%d", i), Amount: math.OneUint()} + cctxs[i].CctxStatus = &types.Status{Status: types.CctxStatus_PendingInbound} keeper.SetCctxAndNonceToCctxAndInTxHashToCctx(ctx, cctxs[i]) } @@ -148,9 +150,9 @@ func createInTxHashToCctxWithCctxs(keeper *crosschainkeeper.Keeper, ctx sdk.Cont } func TestKeeper_InTxHashToCctxDataQuery(t *testing.T) { - keeper, ctx, _, _ := keepertest.CrosschainKeeper(t) + keeper, ctx, _, zk := keepertest.CrosschainKeeper(t) wctx := sdk.WrapSDKContext(ctx) - + zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) t.Run("can query all cctxs data with in tx hash", func(t *testing.T) { cctxs, inTxHashToCctx := createInTxHashToCctxWithCctxs(keeper, ctx) req := &types.QueryInTxHashToCctxDataRequest{ diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go index 87ff60e729..f8d6a4bcb8 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -10,6 +10,8 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" @@ -45,7 +47,7 @@ func setObservers(t *testing.T, k *keeper.Keeper, ctx sdk.Context, zk keepertest // https://github.com/zeta-chain/node/issues/1542 func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { t.Run("successfully vote on evm deposit", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) msgServer := keeper.NewMsgServerImpl(*k) validatorList := setObservers(t, k, ctx, zk) to, from := int64(1337), int64(101) @@ -61,6 +63,13 @@ func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) msg := sample.InboundVote(0, from, to) + + err := sdkk.EvmKeeper.SetAccount(ctx, ethcommon.HexToAddress(msg.Receiver), statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) for _, validatorAddr := range validatorList { msg.Creator = validatorAddr _, err := msgServer.VoteOnObservedInboundTx( @@ -78,7 +87,7 @@ func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { require.Equal(t, ballot.BallotStatus, observertypes.BallotStatus_BallotFinalized_SuccessObservation) cctx, found := k.GetCrossChainTx(ctx, msg.Digest()) require.True(t, found) - require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_OutboundMined) + require.Equal(t, types.CctxStatus_OutboundMined, cctx.CctxStatus.Status) require.Equal(t, cctx.InboundTxParams.TxFinalizationStatus, types.TxFinalizationStatus_Executed) }) @@ -299,7 +308,8 @@ func TestStatus_ChangeStatus(t *testing.T) { func TestKeeper_SaveInbound(t *testing.T) { t.Run("should save the cctx", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeper(t) + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) receiver := sample.EthAddress() amount := big.NewInt(42) senderChain := getValidEthChain(t) @@ -313,7 +323,7 @@ func TestKeeper_SaveInbound(t *testing.T) { }) t.Run("should save the cctx and remove tracker", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeper(t) + k, ctx, _, zk := keepertest.CrosschainKeeper(t) receiver := sample.EthAddress() amount := big.NewInt(42) senderChain := getValidEthChain(t) @@ -326,6 +336,7 @@ func TestKeeper_SaveInbound(t *testing.T) { CoinType: 0, }) eventIndex := sample.Uint64InRange(1, 100) + zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) k.SaveInbound(ctx, cctx, eventIndex) require.Equal(t, types.TxFinalizationStatus_Executed, cctx.InboundTxParams.TxFinalizationStatus) diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx.go b/x/crosschain/keeper/msg_server_vote_outbound_tx.go index 22afff1218..fd0c462e4e 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -154,6 +154,7 @@ SaveFailedOutbound saves a failed outbound transaction.It does the following thi 2. Save the outbound */ + func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, errMessage string, ballotIndex string) { cctx.SetAbort(errMessage) ctx.Logger().Error(errMessage) @@ -162,6 +163,8 @@ func (k Keeper) SaveFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, er } // SaveSuccessfulOutbound saves a successful outbound transaction. +// This function does not set the CCTX status, therefore all successful outbound transactions need +// to have their status set during processing func (k Keeper) SaveSuccessfulOutbound(ctx sdk.Context, cctx *types.CrossChainTx, ballotIndex string) { k.SaveOutbound(ctx, cctx, ballotIndex) } diff --git a/x/crosschain/keeper/process_inbound.go b/x/crosschain/keeper/process_inbound.go index 3178ee34b0..9b2eddbffd 100644 --- a/x/crosschain/keeper/process_inbound.go +++ b/x/crosschain/keeper/process_inbound.go @@ -37,21 +37,20 @@ func (k Keeper) processZEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) { if err != nil && !isContractReverted { // exceptional case; internal error; should abort CCTX cctx.SetAbort(err.Error()) return - } else if err != nil && isContractReverted { // contract call reverted; should refund + } else if err != nil && isContractReverted { // contract call reverted; should refund via a revert tx revertMessage := err.Error() senderChain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, cctx.InboundTxParams.SenderChainId) if senderChain == nil { cctx.SetAbort(fmt.Sprintf("invalid sender chain id %d", cctx.InboundTxParams.SenderChainId)) return } - gasLimit, err := k.GetRevertGasLimit(ctx, *cctx) if err != nil { cctx.SetAbort(fmt.Sprintf("revert gas limit error: %s", err.Error())) return } if gasLimit == 0 { - // use same gas limit of outbound as a fallback -- should not happen + // use same gas limit of outbound as a fallback -- should not be required gasLimit = cctx.GetCurrentOutTxParam().OutboundTxGasLimit } @@ -60,7 +59,6 @@ func (k Keeper) processZEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx) { cctx.SetAbort(fmt.Sprintf("revert outbound error: %s", err.Error())) return } - // we create a new cached context, and we don't commit the previous one with EVM deposit tmpCtxRevert, commitRevert := ctx.CacheContext() err = func() error { diff --git a/x/crosschain/keeper/process_inbound_test.go b/x/crosschain/keeper/process_inbound_test.go index 491e362f78..ec3bcaea94 100644 --- a/x/crosschain/keeper/process_inbound_test.go +++ b/x/crosschain/keeper/process_inbound_test.go @@ -29,8 +29,9 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { amount := big.NewInt(42) // expect DepositCoinZeta to be called - fungibleMock.On("DepositCoinZeta", mock.Anything, receiver, amount). - Return(nil) + fungibleMock.On("ZETADepositAndCallContract", mock.Anything, + mock.Anything, + receiver, int64(0), amount, mock.Anything, mock.Anything).Return(nil, nil) // call ProcessInbound cctx := sample.CrossChainTx(t, "test") @@ -55,8 +56,8 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { amount := big.NewInt(42) // mock unsuccessful HandleEVMDeposit which does not revert - fungibleMock.On("DepositCoinZeta", mock.Anything, receiver, amount). - Return(fmt.Errorf("deposit error"), false) + + fungibleMock.On("ZETADepositAndCallContract", mock.Anything, mock.Anything, receiver, int64(0), amount, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("deposit error")) // call ProcessInbound cctx := sample.CrossChainTx(t, "test") diff --git a/x/crosschain/keeper/process_outbound_test.go b/x/crosschain/keeper/process_outbound_test.go index 90837f17d8..2bd17818c6 100644 --- a/x/crosschain/keeper/process_outbound_test.go +++ b/x/crosschain/keeper/process_outbound_test.go @@ -1,13 +1,17 @@ package keeper_test import ( + "encoding/base64" "math/big" "testing" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/evmos/ethermint/x/evm/statedb" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/testutil/contracts" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -42,14 +46,84 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { require.Equal(t, cctx.GetCurrentOutTxParam().TxFinalizationStatus, types.TxFinalizationStatus_Executed) }) - t.Run("successfully process failed outbound set to aborted for withdraw tx", func(t *testing.T) { + t.Run("successfully process failed outbound if original sender is a address", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.CrosschainKeeper(t) + receiver := sample.EthAddress() + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) + err := sdkk.EvmKeeper.SetAccount(ctx, ethcommon.HexToAddress(cctx.InboundTxParams.Sender), *statedb.NewEmptyAccount()) + require.NoError(t, err) + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + err = k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.NoError(t, err) + require.Equal(t, types.CctxStatus_Reverted, cctx.CctxStatus.Status) + require.Equal(t, cctx.GetCurrentOutTxParam().TxFinalizationStatus, types.TxFinalizationStatus_Executed) + }) + t.Run("unable to process failed outbound if GetCCTXIndexBytes fails", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + receiver := sample.EthAddress() + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) + cctx.Index = "" + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.ErrorContains(t, err, "failed reverting GetCCTXIndexBytes") + }) + + t.Run("unable to process failed outbound if Adding Revert fails", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) cctx := sample.CrossChainTx(t, "test") cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.ErrorContains(t, err, "failed AddRevertOutbound") + }) + + t.Run("unable to process failed outbound if ZETARevertAndCallContract fails", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + receiver := sample.EthAddress() + cctx := GetERC20Cctx(t, receiver, chains.GoerliChain(), "", big.NewInt(42)) + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + err := k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.ErrorContains(t, err, "failed ZETARevertAndCallContract") + }) + + t.Run("successfully revert failed outbound if original sender is a contract", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + _ = zk.FungibleKeeper.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := GetERC20Cctx(t, sample.EthAddress(), chains.GoerliChain(), "", big.NewInt(42)) + cctx.RelayedMessage = base64.StdEncoding.EncodeToString([]byte("sample message")) + + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + dAppContract, err := zk.FungibleKeeper.DeployContract(ctx, contracts.DappMetaData) require.NoError(t, err) - require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_Aborted) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + cctx.InboundTxParams.Sender = dAppContract.String() + cctx.InboundTxParams.SenderChainId = chains.ZetaChainMainnet().ChainId + + err = k.ProcessFailedOutbound(ctx, cctx, sample.String()) + require.NoError(t, err) + require.Equal(t, types.CctxStatus_Reverted, cctx.CctxStatus.Status) require.Equal(t, cctx.GetCurrentOutTxParam().TxFinalizationStatus, types.TxFinalizationStatus_Executed) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := zk.FungibleKeeper.CallEVM( + ctx, + *dappAbi, + fungibletypes.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, dAppContract.Bytes(), valSenderAddress) }) t.Run("successfully process failed outbound set to pending revert", func(t *testing.T) { diff --git a/x/crosschain/keeper/processs_outbound.go b/x/crosschain/keeper/processs_outbound.go index b10df821cc..a6ae80fca3 100644 --- a/x/crosschain/keeper/processs_outbound.go +++ b/x/crosschain/keeper/processs_outbound.go @@ -1,11 +1,18 @@ package keeper import ( + "encoding/base64" + "fmt" + cosmoserrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + tmbytes "github.com/tendermint/tendermint/libs/bytes" + tmtypes "github.com/tendermint/tendermint/types" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" + fungiblekeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -20,6 +27,10 @@ import ( 3. Emit an event for the successful outbound transaction */ +// This function sets CCTX status , in cases where the outbound tx is successful, but tx itself fails +// This is done because SaveSuccessfulOutbound does not set the cctx status +// For cases where the outbound tx is unsuccessful, the cctx status is automatically set to Aborted in the ProcessFailedOutbound function, so we can just return and error to trigger that + func (k Keeper) ProcessSuccessfulOutbound(ctx sdk.Context, cctx *types.CrossChainTx, valueReceived string) { oldStatus := cctx.CctxStatus.Status switch oldStatus { @@ -48,54 +59,133 @@ ProcessFailedOutbound processes a failed outbound transaction. It does the follo 4. Set the finalization status of the current outbound tx to executed. If a revert tx is is created, the finalization status is not set, it would get set when the revert is processed via a subsequent transaction */ + +// This function sets CCTX status , in cases where the outbound tx is successful, but tx itself fails +// This is done because SaveSuccessfulOutbound does not set the cctx status +// For cases where the outbound tx is unsuccessful, the cctx status is automatically set to Aborted in the ProcessFailedOutbound function, so we can just return and error to trigger that func (k Keeper) ProcessFailedOutbound(ctx sdk.Context, cctx *types.CrossChainTx, valueReceived string) error { oldStatus := cctx.CctxStatus.Status - if cctx.InboundTxParams.CoinType == coin.CoinType_Cmd || chains.IsZetaChain(cctx.InboundTxParams.SenderChainId) { + // The following logic is used to handler the mentioned conditions separately. The reason being + // All admin tx is created using a policy message , there is no associated inbound tx , therefore we do not need any revert logic + // For transactions which originated from ZEVM , we can process the outbound in the same block as there is no TSS signing required for the revert + // For all other transactions we need to create a revert tx and set the status to pending revert + + if cctx.InboundTxParams.CoinType == coin.CoinType_Cmd { // if the cctx is of coin type cmd or the sender chain is zeta chain, then we do not revert, the cctx is aborted cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, "") + cctx.SetAbort("Outbound failed") + } else if chains.IsZetaChain(cctx.InboundTxParams.SenderChainId) { + err := k.processFailedOutboundForZEVMTx(ctx, cctx) + if err != nil { + return cosmoserrors.Wrap(err, "ProcessFailedOutboundForZEVMTx") + } } else { - switch oldStatus { - case types.CctxStatus_PendingOutbound: + err := k.processFailedOutBoundForExternalChainTx(ctx, cctx, oldStatus) + if err != nil { + return cosmoserrors.Wrap(err, "ProcessFailedOutBoundForExternalChainTx") + } + } + newStatus := cctx.CctxStatus.Status.String() + EmitOutboundFailure(ctx, valueReceived, oldStatus.String(), newStatus, cctx.Index) + return nil +} - gasLimit, err := k.GetRevertGasLimit(ctx, *cctx) - if err != nil { - return cosmoserrors.Wrap(err, "GetRevertGasLimit") - } - if gasLimit == 0 { - // use same gas limit of outbound as a fallback -- should not happen - gasLimit = cctx.OutboundTxParams[0].OutboundTxGasLimit - } +func (k Keeper) processFailedOutBoundForExternalChainTx(ctx sdk.Context, cctx *types.CrossChainTx, oldStatus types.CctxStatus) error { + switch oldStatus { + case types.CctxStatus_PendingOutbound: - // create new OutboundTxParams for the revert - err = cctx.AddRevertOutbound(gasLimit) - if err != nil { - return cosmoserrors.Wrap(err, "AddRevertOutbound") - } + gasLimit, err := k.GetRevertGasLimit(ctx, *cctx) + if err != nil { + return cosmoserrors.Wrap(err, "GetRevertGasLimit") + } + if gasLimit == 0 { + // use same gas limit of outbound as a fallback -- should not happen + gasLimit = cctx.OutboundTxParams[0].OutboundTxGasLimit + } - err = k.PayGasAndUpdateCctx( - ctx, - cctx.InboundTxParams.SenderChainId, - cctx, - cctx.OutboundTxParams[0].Amount, - false, - ) - if err != nil { - return err - } - err = k.UpdateNonce(ctx, cctx.InboundTxParams.SenderChainId, cctx) - if err != nil { - return err - } - // Not setting the finalization status here, the required changes have been made while creating the revert tx - cctx.SetPendingRevert("Outbound failed, start revert") - case types.CctxStatus_PendingRevert: - cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed - cctx.SetAbort("Outbound failed: revert failed; abort TX") + // create new OutboundTxParams for the revert + err = cctx.AddRevertOutbound(gasLimit) + if err != nil { + return cosmoserrors.Wrap(err, "AddRevertOutbound") + } + + err = k.PayGasAndUpdateCctx( + ctx, + cctx.InboundTxParams.SenderChainId, + cctx, + cctx.OutboundTxParams[0].Amount, + false, + ) + if err != nil { + return err + } + err = k.UpdateNonce(ctx, cctx.InboundTxParams.SenderChainId, cctx) + if err != nil { + return err } + // Not setting the finalization status here, the required changes have been made while creating the revert tx + cctx.SetPendingRevert("Outbound failed, start revert") + case types.CctxStatus_PendingRevert: + cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed + cctx.SetAbort("Outbound failed: revert failed; abort TX") } - newStatus := cctx.CctxStatus.Status.String() - EmitOutboundFailure(ctx, valueReceived, oldStatus.String(), newStatus, cctx.Index) + return nil +} +func (k Keeper) processFailedOutboundForZEVMTx(ctx sdk.Context, cctx *types.CrossChainTx) error { + indexBytes, err := cctx.GetCCTXIndexBytes() + if err != nil { + // Return err to save the failed outbound ad set to aborted + return fmt.Errorf("failed reverting GetCCTXIndexBytes: %s", err.Error()) + } + // Finalize the older outbound tx + cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed + + // create new OutboundTxParams for the revert. We use the fixed gas limit for revert when calling zEVM + err = cctx.AddRevertOutbound(fungiblekeeper.ZEVMGasLimitDepositAndCall.Uint64()) + if err != nil { + // Return err to save the failed outbound ad set to aborted + return fmt.Errorf("failed AddRevertOutbound: %s", err.Error()) + } + + // Trying to revert the transaction this would get set to a finalized status in the same block as this does not need a TSS singing + cctx.SetPendingRevert("Outbound failed, trying revert") + data, err := base64.StdEncoding.DecodeString(cctx.RelayedMessage) + if err != nil { + return fmt.Errorf("failed decoding relayed message: %s", err.Error()) + } + + // Fetch the original sender and receiver from the CCTX , since this is a revert the sender with be the receiver in the new tx + originalSender := ethcommon.HexToAddress(cctx.InboundTxParams.Sender) + // This transaction will always have two outbounds, the following logic is just an added precaution. + // The contract call or token deposit would go the original sender. + originalReceiver := ethcommon.HexToAddress(cctx.GetCurrentOutTxParam().Receiver) + orginalReceiverChainID := cctx.GetCurrentOutTxParam().ReceiverChainId + if len(cctx.OutboundTxParams) == 2 { + // If there are 2 outbound tx, then the original receiver is the receiver in the first outbound tx + originalReceiver = ethcommon.HexToAddress(cctx.OutboundTxParams[0].Receiver) + orginalReceiverChainID = cctx.OutboundTxParams[0].ReceiverChainId + } + // Call evm to revert the transaction + _, err = k.fungibleKeeper.ZETARevertAndCallContract(ctx, + originalSender, + originalReceiver, + cctx.InboundTxParams.SenderChainId, + orginalReceiverChainID, + cctx.GetCurrentOutTxParam().Amount.BigInt(), data, indexBytes) + // If revert fails, we set it to abort directly there is no way to refund here as the revert failed + if err != nil { + return fmt.Errorf("failed ZETARevertAndCallContract: %s", err.Error()) + } + cctx.SetReverted("Outbound failed, revert executed") + if len(ctx.TxBytes()) > 0 { + // add event for tendermint transaction hash format + hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) + ethTxHash := ethcommon.BytesToHash(hash) + cctx.GetCurrentOutTxParam().OutboundTxHash = ethTxHash.String() + // #nosec G701 always positive + cctx.GetCurrentOutTxParam().OutboundTxObservedExternalHeight = uint64(ctx.BlockHeight()) + } + cctx.GetCurrentOutTxParam().TxFinalizationStatus = types.TxFinalizationStatus_Executed return nil } diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index 45138232fc..98fedf0d5d 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -1,6 +1,7 @@ package types import ( + "encoding/hex" "fmt" cosmoserrors "cosmossdk.io/errors" @@ -82,10 +83,14 @@ func (m *CrossChainTx) AddRevertOutbound(gasLimit uint64) error { if m.IsCurrentOutTxRevert() { return fmt.Errorf("cannot revert a revert tx") } + if len(m.OutboundTxParams) == 0 { + return fmt.Errorf("cannot revert before trying to process an outbound tx") + } + revertTxParams := &OutboundTxParams{ Receiver: m.InboundTxParams.Sender, ReceiverChainId: m.InboundTxParams.SenderChainId, - Amount: m.InboundTxParams.Amount, + Amount: m.GetCurrentOutTxParam().Amount, OutboundTxGasLimit: gasLimit, TssPubkey: m.GetCurrentOutTxParam().TssPubkey, } @@ -140,6 +145,23 @@ func (m CrossChainTx) SetReverted(message string) { m.CctxStatus.ChangeStatus(CctxStatus_Reverted, message) } +func (m CrossChainTx) GetCCTXIndexBytes() ([32]byte, error) { + sendHash := [32]byte{} + if len(m.Index) < 2 { + return [32]byte{}, fmt.Errorf("decode CCTX %s index too short", m.Index) + } + decodedIndex, err := hex.DecodeString(m.Index[2:]) // remove the leading 0x + if err != nil || len(decodedIndex) != 32 { + return [32]byte{}, fmt.Errorf("decode CCTX %s error", m.Index) + } + copy(sendHash[:32], decodedIndex[:32]) + return sendHash, nil +} + +func GetCctxIndexFromBytes(sendHash [32]byte) string { + return fmt.Sprintf("0x%s", hex.EncodeToString(sendHash[:])) +} + // NewCCTX creates a new CCTX.From a MsgVoteOnObservedInboundTx message and a TSS pubkey. // It also validates the created cctx func NewCCTX(ctx sdk.Context, msg MsgVoteOnObservedInboundTx, tssPubkey string) (CrossChainTx, error) { diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index 15df60238e..0b7f267d2d 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -15,6 +15,13 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) +func TestCrossChainTx_GetCCTXIndexBytes(t *testing.T) { + cctx := sample.CrossChainTx(t, "sample") + indexBytes, err := cctx.GetCCTXIndexBytes() + require.NoError(t, err) + require.Equal(t, cctx.Index, types.GetCctxIndexFromBytes(indexBytes)) +} + func Test_InitializeCCTX(t *testing.T) { t.Run("should return a cctx with correct values", func(t *testing.T) { _, ctx, _, _ := keepertest.CrosschainKeeper(t) @@ -245,7 +252,7 @@ func Test_SetRevertOutboundValues(t *testing.T) { require.Len(t, cctx.OutboundTxParams, 2) require.Equal(t, cctx.GetCurrentOutTxParam().Receiver, cctx.InboundTxParams.Sender) require.Equal(t, cctx.GetCurrentOutTxParam().ReceiverChainId, cctx.InboundTxParams.SenderChainId) - require.Equal(t, cctx.GetCurrentOutTxParam().Amount, cctx.InboundTxParams.Amount) + require.Equal(t, cctx.GetCurrentOutTxParam().Amount, cctx.OutboundTxParams[0].Amount) require.Equal(t, cctx.GetCurrentOutTxParam().OutboundTxGasLimit, uint64(100)) require.Equal(t, cctx.GetCurrentOutTxParam().TssPubkey, cctx.OutboundTxParams[0].TssPubkey) require.Equal(t, types.TxFinalizationStatus_Executed, cctx.OutboundTxParams[0].TxFinalizationStatus) @@ -256,6 +263,13 @@ func Test_SetRevertOutboundValues(t *testing.T) { err := cctx.AddRevertOutbound(100) require.ErrorContains(t, err, "cannot revert a revert tx") }) + + t.Run("failed to set revert outbound values if revert outbound already exists", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + cctx.OutboundTxParams = make([]*types.OutboundTxParams, 0) + err := cctx.AddRevertOutbound(100) + require.ErrorContains(t, err, "cannot revert before trying to process an outbound tx") + }) } func TestCrossChainTx_SetAbort(t *testing.T) { diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index 1b80e4fe19..edde41849d 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -41,6 +41,7 @@ var ( ErrUnableProcessRefund = errorsmod.Register(ModuleName, 1148, "unable to process refund") ErrUnableToFindZetaAccounting = errorsmod.Register(ModuleName, 1149, "unable to find zeta accounting") ErrInsufficientZetaAmount = errorsmod.Register(ModuleName, 1150, "insufficient zeta amount") - ErrInvalidRateLimiterFlags = errorsmod.Register(ModuleName, 1151, "invalid rate limiter flags") - ErrMaxTxOutTrackerHashesReached = errorsmod.Register(ModuleName, 1152, "max tx out tracker hashes reached") + ErrUnableToDecodeMessageString = errorsmod.Register(ModuleName, 1151, "unable to decode message string") + ErrInvalidRateLimiterFlags = errorsmod.Register(ModuleName, 1152, "invalid rate limiter flags") + ErrMaxTxOutTrackerHashesReached = errorsmod.Register(ModuleName, 1153, "max tx out tracker hashes reached") ) diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index 3fbea3a483..ed5aacb267 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - eth "github.com/ethereum/go-ethereum/common" + ethcommon "github.com/ethereum/go-ethereum/common" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" @@ -100,24 +100,24 @@ type FungibleKeeper interface { GetForeignCoinFromAsset(ctx sdk.Context, asset string, chainID int64) (fungibletypes.ForeignCoins, bool) GetGasCoinForForeignCoin(ctx sdk.Context, chainID int64) (fungibletypes.ForeignCoins, bool) GetSystemContract(ctx sdk.Context) (val fungibletypes.SystemContract, found bool) - QuerySystemContractGasCoinZRC20(ctx sdk.Context, chainID *big.Int) (eth.Address, error) - GetUniswapV2Router02Address(ctx sdk.Context) (eth.Address, error) - QueryUniswapV2RouterGetZetaAmountsIn(ctx sdk.Context, amountOut *big.Int, outZRC4 eth.Address) (*big.Int, error) - QueryUniswapV2RouterGetZRC4ToZRC4AmountsIn(ctx sdk.Context, amountOut *big.Int, inZRC4, outZRC4 eth.Address) (*big.Int, error) - QueryGasLimit(ctx sdk.Context, contract eth.Address) (*big.Int, error) - QueryProtocolFlatFee(ctx sdk.Context, contract eth.Address) (*big.Int, error) + QuerySystemContractGasCoinZRC20(ctx sdk.Context, chainID *big.Int) (ethcommon.Address, error) + GetUniswapV2Router02Address(ctx sdk.Context) (ethcommon.Address, error) + QueryUniswapV2RouterGetZetaAmountsIn(ctx sdk.Context, amountOut *big.Int, outZRC4 ethcommon.Address) (*big.Int, error) + QueryUniswapV2RouterGetZRC4ToZRC4AmountsIn(ctx sdk.Context, amountOut *big.Int, inZRC4, outZRC4 ethcommon.Address) (*big.Int, error) + QueryGasLimit(ctx sdk.Context, contract ethcommon.Address) (*big.Int, error) + QueryProtocolFlatFee(ctx sdk.Context, contract ethcommon.Address) (*big.Int, error) SetGasPrice(ctx sdk.Context, chainID *big.Int, gasPrice *big.Int) (uint64, error) - DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int) error + DepositCoinZeta(ctx sdk.Context, to ethcommon.Address, amount *big.Int) error DepositZRC20( ctx sdk.Context, - contract eth.Address, - to eth.Address, + contract ethcommon.Address, + to ethcommon.Address, amount *big.Int, ) (*evmtypes.MsgEthereumTxResponse, error) ZRC20DepositAndCallContract( ctx sdk.Context, from []byte, - to eth.Address, + to ethcommon.Address, amount *big.Int, senderChainID int64, data []byte, @@ -126,27 +126,27 @@ type FungibleKeeper interface { ) (*evmtypes.MsgEthereumTxResponse, bool, error) CallUniswapV2RouterSwapExactTokensForTokens( ctx sdk.Context, - sender eth.Address, - to eth.Address, + sender ethcommon.Address, + to ethcommon.Address, amountIn *big.Int, inZRC4, - outZRC4 eth.Address, + outZRC4 ethcommon.Address, noEthereumTxEvent bool, ) (ret []*big.Int, err error) CallUniswapV2RouterSwapExactETHForToken( ctx sdk.Context, - sender eth.Address, - to eth.Address, + sender ethcommon.Address, + to ethcommon.Address, amountIn *big.Int, - outZRC4 eth.Address, + outZRC4 ethcommon.Address, noEthereumTxEvent bool, ) ([]*big.Int, error) - CallZRC20Burn(ctx sdk.Context, sender eth.Address, zrc20address eth.Address, amount *big.Int, noEthereumTxEvent bool) error + CallZRC20Burn(ctx sdk.Context, sender ethcommon.Address, zrc20address ethcommon.Address, amount *big.Int, noEthereumTxEvent bool) error CallZRC20Approve( ctx sdk.Context, - owner eth.Address, - zrc20address eth.Address, - spender eth.Address, + owner ethcommon.Address, + zrc20address ethcommon.Address, + spender ethcommon.Address, amount *big.Int, noEthereumTxEvent bool, ) error @@ -158,9 +158,24 @@ type FungibleKeeper interface { coinType coin.CoinType, erc20Contract string, gasLimit *big.Int, - ) (eth.Address, error) + ) (ethcommon.Address, error) FundGasStabilityPool(ctx sdk.Context, chainID int64, amount *big.Int) error WithdrawFromGasStabilityPool(ctx sdk.Context, chainID int64, amount *big.Int) error + ZETADepositAndCallContract(ctx sdk.Context, + sender ethcommon.Address, + to ethcommon.Address, + inboundSenderChainID int64, + inboundAmount *big.Int, + data []byte, + indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) + ZETARevertAndCallContract(ctx sdk.Context, + sender ethcommon.Address, + to ethcommon.Address, + inboundSenderChainID int64, + destinationChainID int64, + remainingAmount *big.Int, + data []byte, + indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) } type AuthorityKeeper interface { diff --git a/x/fungible/keeper/deposits.go b/x/fungible/keeper/deposits.go index c7d786db18..695386fd01 100644 --- a/x/fungible/keeper/deposits.go +++ b/x/fungible/keeper/deposits.go @@ -18,6 +18,10 @@ func (k Keeper) DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int return k.MintZetaToEVMAccount(ctx, zetaToAddress, amount) } +func (k Keeper) DepositCoinsToFungibleModule(ctx sdk.Context, amount *big.Int) error { + return k.MintZetaToFungibleModule(ctx, amount) +} + // ZRC20DepositAndCallContract deposits ZRC20 to the EVM account and calls the contract // returns [txResponse, isContractCall, error] // isContractCall is true if the receiver is a contract and a contract call was made diff --git a/x/fungible/keeper/deposits_test.go b/x/fungible/keeper/deposits_test.go index dc69febd24..0e6f245173 100644 --- a/x/fungible/keeper/deposits_test.go +++ b/x/fungible/keeper/deposits_test.go @@ -4,15 +4,16 @@ import ( "math/big" "testing" + "cosmossdk.io/errors" "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/testutil/contracts" - testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/x/fungible/types" @@ -21,7 +22,7 @@ import ( func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("can deposit gas coin for transfers", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -52,7 +53,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { }) t.Run("can deposit non-gas coin for transfers", func(t *testing.T) { - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -84,7 +85,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { }) t.Run("should fail if trying to call a contract with data to a EOC", func(t *testing.T) { - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -112,7 +113,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("can deposit coin for transfers with liquidity cap not reached", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -158,7 +159,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should fail if coin paused", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -190,7 +191,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should fail if liquidity cap reached", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -231,7 +232,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should fail if gas coin not found", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -256,7 +257,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { }) t.Run("should fail if zrc20 not found", func(t *testing.T) { - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -283,7 +284,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should return contract call if receiver is a contract", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -321,7 +322,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { t.Run("should fail if call contract fails", func(t *testing.T) { // setup gas coin - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) chainList := chains.DefaultChainsList() @@ -356,16 +357,34 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { } func TestKeeper_DepositCoinZeta(t *testing.T) { - k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) - to := sample.EthAddress() - amount := big.NewInt(1) - zetaToAddress := sdk.AccAddress(to.Bytes()) - - b := sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) - require.Equal(t, int64(0), b.Amount.Int64()) - - err := k.DepositCoinZeta(ctx, to, amount) - require.NoError(t, err) - b = sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) - require.Equal(t, amount.Int64(), b.Amount.Int64()) + t.Run("successfully deposit coin", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + to := sample.EthAddress() + amount := big.NewInt(1) + zetaToAddress := sdk.AccAddress(to.Bytes()) + + b := sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) + require.Equal(t, int64(0), b.Amount.Int64()) + + err := k.DepositCoinZeta(ctx, to, amount) + require.NoError(t, err) + b = sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) + require.Equal(t, amount.Int64(), b.Amount.Int64()) + }) + + t.Run("should fail if MintZetaToEVMAccount fails", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{UseBankMock: true}) + bankMock := keepertest.GetFungibleBankMock(t, k) + to := sample.EthAddress() + amount := big.NewInt(1) + zetaToAddress := sdk.AccAddress(to.Bytes()) + + b := sdkk.BankKeeper.GetBalance(ctx, zetaToAddress, config.BaseDenom) + require.Equal(t, int64(0), b.Amount.Int64()) + errorMint := errors.New("", 1, "error minting coins") + bankMock.On("MintCoins", ctx, types.ModuleName, mock.Anything).Return(errorMint).Once() + err := k.DepositCoinZeta(ctx, to, amount) + require.ErrorIs(t, err, errorMint) + + }) } diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 427849f19c..04dda559e9 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -20,12 +20,12 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" tmbytes "github.com/tendermint/tendermint/libs/bytes" tmtypes "github.com/tendermint/tendermint/types" - connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" - systemcontract "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol" - zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" - uniswapv2factory "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" - uniswapv2router02 "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" + zevmconnectercontract "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" + "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" + "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/server/config" @@ -37,6 +37,8 @@ import ( var ( BigIntZero = big.NewInt(0) ZEVMGasLimitDepositAndCall = big.NewInt(1_000_000) + + ZEVMGasLimitConnectorCall = big.NewInt(1_000_000) ) // DeployContract deploys a new contract in the ZEVM @@ -179,7 +181,7 @@ func (k Keeper) DeployWZETA(ctx sdk.Context) (common.Address, error) { } func (k Keeper) DeployConnectorZEVM(ctx sdk.Context, wzeta common.Address) (common.Address, error) { - contractAddr, err := k.DeployContract(ctx, connectorzevm.ZetaConnectorZEVMMetaData, wzeta) + contractAddr, err := k.DeployContract(ctx, zevmconnectercontract.ZetaConnectorZEVMMetaData, wzeta) if err != nil { return common.Address{}, cosmoserrors.Wrapf(err, "ZetaConnectorZEVM") } @@ -305,6 +307,99 @@ func (k Keeper) DepositZRC20AndCallContract(ctx sdk.Context, ) } +// CallOnReceiveZevmConnector calls the onReceive function of the ZevmConnector contract +// Before calling it mints the zetaValue tokens to the fungible module , and this amount is then provided as value to the onReceive function +// The onReceive function will then wrap this native zeta into WZETA and call the onReceive function of the destination contract specified by the destinationAddress +func (k Keeper) CallOnReceiveZevmConnector(ctx sdk.Context, + zetaTxSenderAddress []byte, + sourceChainID *big.Int, + destinationAddress common.Address, + zetaValue *big.Int, + message []byte, + internalSendHash [32]byte, +) (*evmtypes.MsgEthereumTxResponse, error) { + system, found := k.GetSystemContract(ctx) + if !found { + return nil, cosmoserrors.Wrapf(types.ErrContractNotFound, "GetSystemContract address not found") + } + connectorAddress := common.HexToAddress(system.ConnectorZevm) + + zevmConnecterAbi, err := zevmconnectercontract.ZetaConnectorZEVMMetaData.GetAbi() + if err != nil { + return nil, err + } + + err = k.DepositCoinsToFungibleModule(ctx, zetaValue) + if err != nil { + return nil, err + } + + return k.CallEVM( + ctx, + *zevmConnecterAbi, + types.ModuleAddressEVM, + connectorAddress, + zetaValue, + ZEVMGasLimitConnectorCall, + true, + false, + "onReceive", + zetaTxSenderAddress, + sourceChainID, + destinationAddress, + zetaValue, + message, + internalSendHash, + ) +} + +// CallOnRevertZevmConnector calls the onRevert function of the ZevmConnector contract +// Before calling it mints the remainingZetaValue tokens to the fungible module , and this amount is then provided as value to the onRevert function +// The onRevert function will then wrap this native zeta into WZETA and call the onRevert function of the contract specified by the zetaTxSenderAddress +// Note the destination address is the original destination address of the transaction and not the current destination . +func (k Keeper) CallOnRevertZevmConnector(ctx sdk.Context, + zetaTxSenderAddress common.Address, + sourceChainID *big.Int, + destinationAddress []byte, + destinationChainID *big.Int, + remainingZetaValue *big.Int, + message []byte, + internalSendHash [32]byte, +) (*evmtypes.MsgEthereumTxResponse, error) { + system, found := k.GetSystemContract(ctx) + if !found { + return nil, cosmoserrors.Wrapf(types.ErrContractNotFound, "GetSystemContract address not found") + } + connectorAddress := common.HexToAddress(system.ConnectorZevm) + + zevmConnecterAbi, err := zevmconnectercontract.ZetaConnectorZEVMMetaData.GetAbi() + if err != nil { + return nil, err + } + err = k.DepositCoinsToFungibleModule(ctx, remainingZetaValue) + if err != nil { + return nil, err + } + return k.CallEVM( + ctx, + *zevmConnecterAbi, + types.ModuleAddressEVM, + connectorAddress, + remainingZetaValue, + ZEVMGasLimitConnectorCall, + true, + false, + "onRevert", + zetaTxSenderAddress, + sourceChainID, + destinationAddress, + destinationChainID, + remainingZetaValue, + message, + internalSendHash, + ) +} + // QueryProtocolFlatFee returns the protocol flat fee associated with a given zrc20 func (k Keeper) QueryProtocolFlatFee(ctx sdk.Context, contract common.Address) (*big.Int, error) { zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() diff --git a/x/fungible/keeper/evm_test.go b/x/fungible/keeper/evm_test.go index 753d82e7e6..1ca8b7cbe4 100644 --- a/x/fungible/keeper/evm_test.go +++ b/x/fungible/keeper/evm_test.go @@ -1326,3 +1326,158 @@ func TestKeeper_QueryZRC20Data(t *testing.T) { require.Equal(t, "symbol", res.Symbol) }) } + +func TestKeeper_CallOnReceiveZevmConnector(t *testing.T) { + t.Run("should call on receive on connector which calls onZetaMessage on sample DAPP", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + senderAddress := sample.EthAddress().Bytes() + sourceChainID := big.NewInt(1) + destinationAddress := dAppContract + zetaValue := big.NewInt(45) + data := []byte("message") + internalSendHash := [32]byte{} + + _, err = k.CallOnReceiveZevmConnector(ctx, senderAddress, sourceChainID, destinationAddress, zetaValue, data, internalSendHash) + require.NoError(t, err) + + require.NoError(t, err) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := k.CallEVM( + ctx, + *dappAbi, + types.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, senderAddress, valSenderAddress) + }) + + t.Run("should error if system contract not found", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + _, err = k.CallOnReceiveZevmConnector(ctx, + sample.EthAddress().Bytes(), + big.NewInt(1), + dAppContract, + big.NewInt(45), []byte("message"), [32]byte{}) + require.ErrorIs(t, err, types.ErrContractNotFound) + }) + + t.Run("should error in contract call reverts", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappReverterMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + _, err = k.CallOnReceiveZevmConnector(ctx, + sample.EthAddress().Bytes(), + big.NewInt(1), + dAppContract, + big.NewInt(45), []byte("message"), [32]byte{}) + require.ErrorContains(t, err, "execution reverted") + }) +} + +func TestKeeper_CallOnRevertZevmConnector(t *testing.T) { + t.Run("should call on revert on connector which calls onZetaRevert on sample DAPP", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + senderAddress := dAppContract + sourceChainID := big.NewInt(1) + destinationAddress := sample.EthAddress().Bytes() + destinationChainID := big.NewInt(1) + zetaValue := big.NewInt(45) + data := []byte("message") + internalSendHash := [32]byte{} + _, err = k.CallOnRevertZevmConnector(ctx, senderAddress, sourceChainID, destinationAddress, destinationChainID, zetaValue, data, internalSendHash) + require.NoError(t, err) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := k.CallEVM( + ctx, + *dappAbi, + types.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, senderAddress.Bytes(), valSenderAddress) + }) + + t.Run("should error if system contract not found", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + _, err = k.CallOnRevertZevmConnector(ctx, + dAppContract, + big.NewInt(1), + sample.EthAddress().Bytes(), + big.NewInt(1), + big.NewInt(45), []byte("message"), [32]byte{}) + require.ErrorIs(t, err, types.ErrContractNotFound) + }) + + t.Run("should error in contract call reverts", func(t *testing.T) { + k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappReverterMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + _, err = k.CallOnRevertZevmConnector(ctx, + dAppContract, + big.NewInt(1), + sample.EthAddress().Bytes(), + big.NewInt(1), + big.NewInt(45), []byte("message"), [32]byte{}) + require.ErrorContains(t, err, "execution reverted") + }) +} diff --git a/x/fungible/keeper/system_contract.go b/x/fungible/keeper/system_contract.go index af36727f54..822bccf766 100644 --- a/x/fungible/keeper/system_contract.go +++ b/x/fungible/keeper/system_contract.go @@ -1,6 +1,7 @@ package keeper import ( + "fmt" "math/big" cosmoserrors "cosmossdk.io/errors" @@ -533,7 +534,8 @@ func (k *Keeper) QueryUniswapV2RouterGetZetaAmountsIn(ctx sdk.Context, amountOut []ethcommon.Address{wzetaAddr, outZRC4}, ) if err != nil { - return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to CallEVM method getAmountsIn (%s)", err.Error()) + fmt.Println(err.Error()) + return nil, cosmoserrors.Wrap(types.ErrContractCall, fmt.Sprintf("failed to CallEVM method getAmountsIn (%s)", err.Error())) } amounts := new([2]*big.Int) diff --git a/x/fungible/keeper/zeta.go b/x/fungible/keeper/zeta.go index 0a5e72b31d..33f3d81486 100644 --- a/x/fungible/keeper/zeta.go +++ b/x/fungible/keeper/zeta.go @@ -20,3 +20,9 @@ func (k *Keeper) MintZetaToEVMAccount(ctx sdk.Context, to sdk.AccAddress, amount // Send minted coins to the receiver return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, to, coins) } + +func (k *Keeper) MintZetaToFungibleModule(ctx sdk.Context, amount *big.Int) error { + coins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, sdk.NewIntFromBigInt(amount))) + // Mint coins + return k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) +} diff --git a/x/fungible/keeper/zevm_message_passing_test.go b/x/fungible/keeper/zevm_message_passing_test.go new file mode 100644 index 0000000000..b37621667d --- /dev/null +++ b/x/fungible/keeper/zevm_message_passing_test.go @@ -0,0 +1,263 @@ +package keeper_test + +import ( + "math/big" + "testing" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/evmos/ethermint/x/evm/statedb" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/cmd/zetacored/config" + "github.com/zeta-chain/zetacore/testutil/contracts" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func TestKeeper_ZEVMDepositAndCallContract(t *testing.T) { + t.Run("successfully call ZETADepositAndCallContract on connector contract ", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + zetaTxSender := sample.EthAddress() + zetaTxReceiver := dAppContract + inboundSenderChainID := int64(1) + inboundAmount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err = k.ZETADepositAndCallContract(ctx, zetaTxSender, zetaTxReceiver, inboundSenderChainID, inboundAmount, data, cctxIndexBytes) + require.NoError(t, err) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := k.CallEVM( + ctx, + *dappAbi, + types.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, zetaTxSender.Bytes(), valSenderAddress) + }) + + t.Run("successfully deposit coin if account is not a contract", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + inboundSenderChainID := int64(1) + inboundAmount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + err := sdkk.EvmKeeper.SetAccount(ctx, zetaTxReceiver, statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) + + _, err = k.ZETADepositAndCallContract(ctx, zetaTxSender, zetaTxReceiver, inboundSenderChainID, inboundAmount, data, cctxIndexBytes) + require.NoError(t, err) + b := sdkk.BankKeeper.GetBalance(ctx, sdk.AccAddress(zetaTxReceiver.Bytes()), config.BaseDenom) + require.Equal(t, inboundAmount.Int64(), b.Amount.Int64()) + }) + + t.Run("fail ZETADepositAndCallContract if account not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + inboundSenderChainID := int64(1) + inboundAmount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err := k.ZETADepositAndCallContract(ctx, zetaTxSender, zetaTxReceiver, inboundSenderChainID, inboundAmount, data, cctxIndexBytes) + require.ErrorIs(t, err, types.ErrAccountNotFound) + require.ErrorContains(t, err, "account not found") + }) + + t.Run("fail ZETADepositAndCallContract id Deposit Fails", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{UseBankMock: true}) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + bankMock := keepertest.GetFungibleBankMock(t, k) + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + inboundSenderChainID := int64(1) + inboundAmount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + err := sdkk.EvmKeeper.SetAccount(ctx, zetaTxReceiver, statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) + errorMint := errors.New("", 10, "error minting coins") + bankMock.On("MintCoins", ctx, types.ModuleName, mock.Anything).Return(errorMint).Once() + + _, err = k.ZETADepositAndCallContract(ctx, zetaTxSender, zetaTxReceiver, inboundSenderChainID, inboundAmount, data, cctxIndexBytes) + require.ErrorIs(t, err, errorMint) + }) +} + +func TestKeeper_ZEVMRevertAndCallContract(t *testing.T) { + t.Run("successfully call ZETARevertAndCallContract if receiver is a contract", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + dAppContract, err := k.DeployContract(ctx, contracts.DappMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + zetaTxSender := dAppContract + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + zetaTxReceiver := sample.EthAddress() + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err = k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.NoError(t, err) + + dappAbi, err := contracts.DappMetaData.GetAbi() + require.NoError(t, err) + res, err := k.CallEVM( + ctx, + *dappAbi, + types.ModuleAddressEVM, + dAppContract, + big.NewInt(0), + nil, + false, + false, + "zetaTxSenderAddress", + ) + require.NoError(t, err) + unpacked, err := dappAbi.Unpack("zetaTxSenderAddress", res.Ret) + require.NoError(t, err) + require.NotZero(t, len(unpacked)) + valSenderAddress, ok := unpacked[0].([]byte) + require.True(t, ok) + require.Equal(t, zetaTxSender.Bytes(), valSenderAddress) + }) + + t.Run("successfully deposit coin if account is not a contract", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + err := sdkk.EvmKeeper.SetAccount(ctx, zetaTxSender, statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) + + _, err = k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.NoError(t, err) + b := sdkk.BankKeeper.GetBalance(ctx, sdk.AccAddress(zetaTxSender.Bytes()), config.BaseDenom) + require.Equal(t, amount.Int64(), b.Amount.Int64()) + }) + + t.Run("fail ZETARevertAndCallContract if account not found", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err := k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.ErrorIs(t, err, types.ErrAccountNotFound) + require.ErrorContains(t, err, "account not found") + }) + + t.Run("fail ZETARevertAndCallContract if Deposit Fails", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{UseBankMock: true}) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + bankMock := keepertest.GetFungibleBankMock(t, k) + deploySystemContracts(t, ctx, k, sdkk.EvmKeeper) + zetaTxSender := sample.EthAddress() + zetaTxReceiver := sample.EthAddress() + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + err := sdkk.EvmKeeper.SetAccount(ctx, zetaTxSender, statedb.Account{ + Nonce: 0, + Balance: big.NewInt(0), + CodeHash: crypto.Keccak256(nil), + }) + require.NoError(t, err) + errorMint := errors.New("", 101, "error minting coins") + bankMock.On("MintCoins", ctx, types.ModuleName, mock.Anything).Return(errorMint).Once() + + _, err = k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.ErrorIs(t, err, errorMint) + }) + + t.Run("fail ZETARevertAndCallContract if ZevmOnRevert fails", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.FungibleKeeper(t) + _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + + dAppContract, err := k.DeployContract(ctx, contracts.DappReverterMetaData) + require.NoError(t, err) + assertContractDeployment(t, sdkk.EvmKeeper, ctx, dAppContract) + + zetaTxSender := dAppContract + zetaTxReceiver := sample.EthAddress() + senderChainID := big.NewInt(1) + destinationChainID := big.NewInt(2) + amount := big.NewInt(45) + data := []byte("message") + cctxIndexBytes := [32]byte{} + + _, err = k.ZETARevertAndCallContract(ctx, zetaTxSender, zetaTxReceiver, senderChainID.Int64(), destinationChainID.Int64(), amount, data, cctxIndexBytes) + require.ErrorIs(t, err, types.ErrContractNotFound) + require.ErrorContains(t, err, "GetSystemContract address not found") + }) +} diff --git a/x/fungible/keeper/zevm_msg_passing.go b/x/fungible/keeper/zevm_msg_passing.go new file mode 100644 index 0000000000..ab3210c002 --- /dev/null +++ b/x/fungible/keeper/zevm_msg_passing.go @@ -0,0 +1,61 @@ +package keeper + +import ( + "fmt" + "math/big" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +// ZEVMDepositAndCallContract deposits ZETA to the to address if its an account +// If it's not an account it calls onReceive function of the connector contract and provides the address as the destinationAddress +func (k Keeper) ZETADepositAndCallContract(ctx sdk.Context, + sender ethcommon.Address, + to ethcommon.Address, + inboundSenderChainID int64, + inboundAmount *big.Int, + data []byte, + indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { + acc := k.evmKeeper.GetAccount(ctx, to) + if acc == nil { + return nil, errors.Wrap(types.ErrAccountNotFound, fmt.Sprintf("address: %s", to.String())) + } + if !acc.IsContract() { + err := k.DepositCoinZeta(ctx, to, inboundAmount) + if err != nil { + return nil, err + } + return nil, nil + } + // Call onReceive function of the connector contract. The connector contract will then call the onReceive function of the destination contract which is the to address + return k.CallOnReceiveZevmConnector(ctx, sender.Bytes(), big.NewInt(inboundSenderChainID), to, inboundAmount, data, indexBytes) +} + +// ZEVMRevertAndCallContract deposits ZETA to the sender address if its an account +// If it's not an account it calls onRevert function of the connector contract and provides the sender address as the zetaTxSenderAddress +func (k Keeper) ZETARevertAndCallContract(ctx sdk.Context, + sender ethcommon.Address, + to ethcommon.Address, + inboundSenderChainID int64, + destinationChainID int64, + remainingAmount *big.Int, + data []byte, + indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { + acc := k.evmKeeper.GetAccount(ctx, sender) + if acc == nil { + return nil, errors.Wrap(types.ErrAccountNotFound, fmt.Sprintf("address: %s", to.String())) + } + if !acc.IsContract() { + err := k.DepositCoinZeta(ctx, sender, remainingAmount) + if err != nil { + return nil, err + } + return nil, nil + } + // Call onRevert function of the connector contract. The connector contract will then call the onRevert function of the zetaTxSender contract which is the sender address + return k.CallOnRevertZevmConnector(ctx, sender, big.NewInt(inboundSenderChainID), to.Bytes(), big.NewInt(destinationChainID), remainingAmount, data, indexBytes) +} diff --git a/x/fungible/types/errors.go b/x/fungible/types/errors.go index bee52cae17..dad99cfd9b 100644 --- a/x/fungible/types/errors.go +++ b/x/fungible/types/errors.go @@ -27,4 +27,5 @@ var ( ErrCallNonContract = cosmoserrors.Register(ModuleName, 1124, "can't call a non-contract address") ErrForeignCoinAlreadyExist = cosmoserrors.Register(ModuleName, 1125, "foreign coin already exist") ErrNilGasPrice = cosmoserrors.Register(ModuleName, 1127, "nil gas price") + ErrAccountNotFound = cosmoserrors.Register(ModuleName, 1128, "account not found") ) diff --git a/x/observer/keeper/nonce_to_cctx_test.go b/x/observer/keeper/nonce_to_cctx_test.go index a16a21f5ec..e72d076a1e 100644 --- a/x/observer/keeper/nonce_to_cctx_test.go +++ b/x/observer/keeper/nonce_to_cctx_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/observer/types" ) func TestKeeper_GetNonceToCctx(t *testing.T) { @@ -29,6 +30,17 @@ func TestKeeper_GetNonceToCctx(t *testing.T) { require.False(t, found) } }) + t.Run("test nonce to cctx", func(t *testing.T) { + k, ctx, _, _ := keepertest.ObserverKeeper(t) + k.SetNonceToCctx(ctx, types.NonceToCctx{ + ChainId: 1337, + Nonce: 0, + CctxIndex: "0x705b88814b2a049e75b591fd80595c53f3bd9ddfb67ad06aa6965ed91023ee9a", + Tss: "zetapub1addwnpepq0akz8ene4z2mg3tghamr0m5eg3eeuqtjcfamkh5ecetua9u0pcyvjeyerd", + }) + _, found := k.GetNonceToCctx(ctx, "zetapub1addwnpepq0akz8ene4z2mg3tghamr0m5eg3eeuqtjcfamkh5ecetua9u0pcyvjeyerd", 1337, 0) + require.True(t, found) + }) t.Run("Get nonce to cctx not found", func(t *testing.T) { k, ctx, _, _ := keepertest.ObserverKeeper(t) nonceToCctxList := sample.NonceToCctxList(t, "sample", 1) diff --git a/zetaclient/evm/evm_signer.go b/zetaclient/evm/evm_signer.go index e077d19fe2..c0de8ea40b 100644 --- a/zetaclient/evm/evm_signer.go +++ b/zetaclient/evm/evm_signer.go @@ -359,7 +359,7 @@ func (signer *Signer) TryProcessOutTx( // Get cross-chain flags crossChainflags := signer.coreContext.GetCrossChainFlags() - + // https://github.com/zeta-chain/node/issues/2050 var tx *ethtypes.Transaction // compliance check goes first if compliance.IsCctxRestricted(cctx) { @@ -410,6 +410,11 @@ func (signer *Signer) TryProcessOutTx( } } else if cctx.CctxStatus.Status == types.CctxStatus_PendingRevert && cctx.OutboundTxParams[0].ReceiverChainId == zetaBridge.ZetaChain().ChainId { switch cctx.InboundTxParams.CoinType { + case coin.CoinType_Zeta: + logger.Info().Msgf("SignRevertTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) + txData.srcChainID = big.NewInt(cctx.OutboundTxParams[0].ReceiverChainId) + txData.toChainID = big.NewInt(cctx.GetCurrentOutTxParam().ReceiverChainId) + tx, err = signer.SignRevertTx(txData) case coin.CoinType_Gas: logger.Info().Msgf("SignWithdrawTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) tx, err = signer.SignWithdrawTx(txData) @@ -456,7 +461,9 @@ func (signer *Signer) BroadcastOutTx( txData *OutBoundTransactionData) { // Get destination chain for logging toChain := chains.GetChainFromChainID(txData.toChainID.Int64()) - + if tx == nil { + logger.Warn().Msgf("BroadcastOutTx: no tx to broadcast %s", cctx.Index) + } // Try to broadcast transaction if tx != nil { outTxHash := tx.Hash().Hex() diff --git a/zetaclient/zetabridge/tx_vote_inbound.go b/zetaclient/zetabridge/tx_vote_inbound.go index 43bbd4aaaf..f75a409a1c 100644 --- a/zetaclient/zetabridge/tx_vote_inbound.go +++ b/zetaclient/zetabridge/tx_vote_inbound.go @@ -15,7 +15,7 @@ const ( PostVoteInboundExecutionGasLimit = 4_000_000 // PostVoteInboundMessagePassingExecutionGasLimit is the gas limit for voting on, and executing ,observed inbound tx related to message passing (coin_type == zeta) - PostVoteInboundMessagePassingExecutionGasLimit = 1_000_000 + PostVoteInboundMessagePassingExecutionGasLimit = 4_000_000 ) // GetInBoundVoteMessage returns a new MsgVoteOnObservedInboundTx From fb05f0d6a38e437dd8ca08cf203763a10351f74e Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 19 Apr 2024 17:02:48 -0400 Subject: [PATCH 08/11] feat: add command to modify genesis before import (#1979) * add script to modify genesis * fix unit tests * copy only nonce to cctx and ballot list while importing genesis state * skip copying group data * generate files * use constant for max items * generate files 2 * undate sample genesis * Fix lint * Update cmd/zetacored/parse_genesis.go Co-authored-by: Lucas Bertrand * add more comments * add more comments * add error checks * Update cmd/zetacored/parse_genesis.go Co-authored-by: Lucas Bertrand * generate files * generate files --------- Co-authored-by: Lucas Bertrand --- app/app.go | 25 +- app/init_genesis.go | 53 ++++ changelog.md | 1 + cmd/zetacored/parse_genesis.go | 202 +++++++++++++++ cmd/zetacored/parse_genesis_test.go | 230 ++++++++++++++++++ cmd/zetacored/root.go | 1 + docs/cli/zetacored/zetacored.md | 1 + .../zetacored/zetacored_parse-genesis-file.md | 27 ++ testutil/sample/observer.go | 10 + testutil/sample/sample.go | 15 ++ 10 files changed, 541 insertions(+), 24 deletions(-) create mode 100644 app/init_genesis.go create mode 100644 cmd/zetacored/parse_genesis.go create mode 100644 cmd/zetacored/parse_genesis_test.go create mode 100644 docs/cli/zetacored/zetacored_parse-genesis-file.md diff --git a/app/app.go b/app/app.go index 27300a47d9..79e91fa3b8 100644 --- a/app/app.go +++ b/app/app.go @@ -591,30 +591,7 @@ func New( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. // NOTE: Cross-chain module must be initialized after observer module, as pending nonces in crosschain needs the tss pubkey from observer module - app.mm.SetOrderInitGenesis( - authtypes.ModuleName, - banktypes.ModuleName, - distrtypes.ModuleName, - stakingtypes.ModuleName, - slashingtypes.ModuleName, - govtypes.ModuleName, - crisistypes.ModuleName, - evmtypes.ModuleName, - feemarkettypes.ModuleName, - paramstypes.ModuleName, - group.ModuleName, - genutiltypes.ModuleName, - upgradetypes.ModuleName, - evidencetypes.ModuleName, - vestingtypes.ModuleName, - observertypes.ModuleName, - crosschaintypes.ModuleName, - fungibletypes.ModuleName, - emissionstypes.ModuleName, - authz.ModuleName, - authoritytypes.ModuleName, - lightclienttypes.ModuleName, - ) + app.mm.SetOrderInitGenesis(InitGenesisModuleList()...) app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) diff --git a/app/init_genesis.go b/app/init_genesis.go new file mode 100644 index 0000000000..7f424ee5bc --- /dev/null +++ b/app/init_genesis.go @@ -0,0 +1,53 @@ +package app + +import ( + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/group" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + emissionsModuleTypes "github.com/zeta-chain/zetacore/x/emissions/types" + fungibleModuleTypes "github.com/zeta-chain/zetacore/x/fungible/types" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func InitGenesisModuleList() []string { + return []string{ + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + slashingtypes.ModuleName, + govtypes.ModuleName, + crisistypes.ModuleName, + evmtypes.ModuleName, + feemarkettypes.ModuleName, + paramstypes.ModuleName, + group.ModuleName, + genutiltypes.ModuleName, + upgradetypes.ModuleName, + evidencetypes.ModuleName, + vestingtypes.ModuleName, + observertypes.ModuleName, + crosschaintypes.ModuleName, + fungibleModuleTypes.ModuleName, + emissionsModuleTypes.ModuleName, + authz.ModuleName, + authoritytypes.ModuleName, + lightclienttypes.ModuleName, + } +} diff --git a/changelog.md b/changelog.md index a939f0cd4b..dac460d24a 100644 --- a/changelog.md +++ b/changelog.md @@ -52,6 +52,7 @@ * [1942](https://github.com/zeta-chain/node/pull/1982) - support Bitcoin P2TR, P2WSH, P2SH, P2PKH addresses * [1935](https://github.com/zeta-chain/node/pull/1935) - add an operational authority group * [1954](https://github.com/zeta-chain/node/pull/1954) - add metric for concurrent keysigns +* [1979](https://github.com/zeta-chain/node/pull/1979) - add script to import genesis data into an existing genesis file * [2006](https://github.com/zeta-chain/node/pull/2006) - add Amoy testnet static chain information * [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags * [2034](https://github.com/zeta-chain/node/pull/2034) - add support for zEVM message passing diff --git a/cmd/zetacored/parse_genesis.go b/cmd/zetacored/parse_genesis.go new file mode 100644 index 0000000000..d0529b64d8 --- /dev/null +++ b/cmd/zetacored/parse_genesis.go @@ -0,0 +1,202 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/group" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + evmtypes "github.com/evmos/ethermint/x/evm/types" + feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" + "github.com/spf13/cobra" + "github.com/tendermint/tendermint/types" + "github.com/zeta-chain/zetacore/app" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +const MaxItemsForList = 10 + +// Copy represents a set of modules for which, the entire state is copied without any modifications +var Copy = map[string]bool{ + slashingtypes.ModuleName: true, + govtypes.ModuleName: true, + crisistypes.ModuleName: true, + feemarkettypes.ModuleName: true, + paramstypes.ModuleName: true, + upgradetypes.ModuleName: true, + evidencetypes.ModuleName: true, + vestingtypes.ModuleName: true, + fungibletypes.ModuleName: true, + emissionstypes.ModuleName: true, + authz.ModuleName: true, +} + +// Skip represents a set of modules for which, the entire state is skipped and nothing gets imported +var Skip = map[string]bool{ + evmtypes.ModuleName: true, + stakingtypes.ModuleName: true, + genutiltypes.ModuleName: true, + authtypes.ModuleName: true, + banktypes.ModuleName: true, + distributiontypes.ModuleName: true, + group.ModuleName: true, +} + +// Modify represents a set of modules for which, the state is modified before importing. Each Module should have a corresponding Modify function +var Modify = map[string]bool{ + crosschaintypes.ModuleName: true, + observertypes.ModuleName: true, +} + +func CmdParseGenesisFile() *cobra.Command { + cmd := &cobra.Command{ + Use: "parse-genesis-file [import-genesis-file] [optional-genesis-file]", + Short: "Parse the provided genesis file and import the required data into the optionally provided genesis file", + Args: cobra.MaximumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + cdc := clientCtx.Codec + genesisFilePath := filepath.Join(app.DefaultNodeHome, "config", "genesis.json") + if len(args) == 2 { + genesisFilePath = args[1] + } + genDoc, err := GetGenDoc(genesisFilePath) + if err != nil { + return err + } + importData, err := GetGenDoc(args[0]) + if err != nil { + return err + } + err = ImportDataIntoFile(genDoc, importData, cdc) + if err != nil { + return err + } + + err = genutil.ExportGenesisFile(genDoc, genesisFilePath) + if err != nil { + return err + } + + return nil + }, + } + return cmd +} + +func ImportDataIntoFile(genDoc *types.GenesisDoc, importFile *types.GenesisDoc, cdc codec.Codec) error { + + appState, err := genutiltypes.GenesisStateFromGenDoc(*genDoc) + if err != nil { + return err + } + importAppState, err := genutiltypes.GenesisStateFromGenDoc(*importFile) + if err != nil { + return err + } + moduleList := app.InitGenesisModuleList() + for _, m := range moduleList { + if Skip[m] { + continue + } + if Copy[m] { + appState[m] = importAppState[m] + } + if Modify[m] { + switch m { + case crosschaintypes.ModuleName: + err := ModifyCrosschainState(appState, importAppState, cdc) + if err != nil { + return err + } + case observertypes.ModuleName: + err := ModifyObserverState(appState, importAppState, cdc) + if err != nil { + return err + } + default: + return fmt.Errorf("modify function for %s not found", m) + } + } + } + + appStateJSON, err := json.Marshal(appState) + if err != nil { + return fmt.Errorf("failed to marshal application genesis state: %w", err) + } + genDoc.AppState = appStateJSON + + return nil +} + +// ModifyCrosschainState modifies the crosschain state before importing +// It truncates the crosschain transactions, inbound transactions and finalized inbounds to MaxItemsForList +func ModifyCrosschainState(appState map[string]json.RawMessage, importAppState map[string]json.RawMessage, cdc codec.Codec) error { + importedCrossChainGenState := crosschaintypes.GetGenesisStateFromAppState(cdc, importAppState) + importedCrossChainGenState.CrossChainTxs = importedCrossChainGenState.CrossChainTxs[:math.Min(MaxItemsForList, len(importedCrossChainGenState.CrossChainTxs))] + importedCrossChainGenState.InTxHashToCctxList = importedCrossChainGenState.InTxHashToCctxList[:math.Min(MaxItemsForList, len(importedCrossChainGenState.InTxHashToCctxList))] + importedCrossChainGenState.FinalizedInbounds = importedCrossChainGenState.FinalizedInbounds[:math.Min(MaxItemsForList, len(importedCrossChainGenState.FinalizedInbounds))] + importedCrossChainStateBz, err := json.Marshal(importedCrossChainGenState) + if err != nil { + return fmt.Errorf("failed to marshal zetacrosschain genesis state: %w", err) + } + appState[crosschaintypes.ModuleName] = importedCrossChainStateBz + return nil +} + +// ModifyObserverState modifies the observer state before importing +// It truncates the ballots and nonce to cctx list to MaxItemsForList +func ModifyObserverState(appState map[string]json.RawMessage, importAppState map[string]json.RawMessage, cdc codec.Codec) error { + importedObserverGenState := observertypes.GetGenesisStateFromAppState(cdc, importAppState) + importedObserverGenState.Ballots = importedObserverGenState.Ballots[:math.Min(MaxItemsForList, len(importedObserverGenState.Ballots))] + importedObserverGenState.NonceToCctx = importedObserverGenState.NonceToCctx[:math.Min(MaxItemsForList, len(importedObserverGenState.NonceToCctx))] + + currentGenState := observertypes.GetGenesisStateFromAppState(cdc, appState) + currentGenState.Ballots = importedObserverGenState.Ballots + currentGenState.NonceToCctx = importedObserverGenState.NonceToCctx + + currentGenStateBz, err := cdc.MarshalJSON(¤tGenState) + if err != nil { + return fmt.Errorf("failed to marshal observer genesis state: %w", err) + } + + appState[observertypes.ModuleName] = currentGenStateBz + return nil +} + +func GetGenDoc(fp string) (*types.GenesisDoc, error) { + path, err := filepath.Abs(fp) + if err != nil { + return nil, err + } + jsonBlob, err := os.ReadFile(filepath.Clean(path)) + if err != nil { + return nil, err + } + genData, err := types.GenesisDocFromJSON(jsonBlob) + if err != nil { + return nil, err + } + return genData, nil +} diff --git a/cmd/zetacored/parse_genesis_test.go b/cmd/zetacored/parse_genesis_test.go new file mode 100644 index 0000000000..76a9e1247f --- /dev/null +++ b/cmd/zetacored/parse_genesis_test.go @@ -0,0 +1,230 @@ +package main_test + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/genutil" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/types" + "github.com/zeta-chain/zetacore/app" + zetacored "github.com/zeta-chain/zetacore/cmd/zetacored" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func setConfig(t *testing.T) { + defer func(t *testing.T) { + if r := recover(); r != nil { + t.Log("config is already sealed", r) + } + }(t) + cfg := sdk.GetConfig() + cfg.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub) + cfg.Seal() +} +func Test_ModifyCrossChainState(t *testing.T) { + setConfig(t) + t.Run("successfully modify cross chain state to reduce data", func(t *testing.T) { + cdc := keepertest.NewCodec() + appState := sample.AppState(t) + importData := GetImportData(t, cdc, 100) + err := zetacored.ModifyCrosschainState(appState, importData, cdc) + require.NoError(t, err) + + modifiedCrosschainAppState := crosschaintypes.GetGenesisStateFromAppState(cdc, appState) + require.Len(t, modifiedCrosschainAppState.CrossChainTxs, 10) + require.Len(t, modifiedCrosschainAppState.InTxHashToCctxList, 10) + require.Len(t, modifiedCrosschainAppState.FinalizedInbounds, 10) + }) + + t.Run("successfully modify cross chain state without changing data when not needed", func(t *testing.T) { + cdc := keepertest.NewCodec() + appState := sample.AppState(t) + importData := GetImportData(t, cdc, 8) + err := zetacored.ModifyCrosschainState(appState, importData, cdc) + require.NoError(t, err) + + modifiedCrosschainAppState := crosschaintypes.GetGenesisStateFromAppState(cdc, appState) + require.Len(t, modifiedCrosschainAppState.CrossChainTxs, 8) + require.Len(t, modifiedCrosschainAppState.InTxHashToCctxList, 8) + require.Len(t, modifiedCrosschainAppState.FinalizedInbounds, 8) + }) +} + +func Test_ModifyObserverState(t *testing.T) { + setConfig(t) + t.Run("successfully modify observer state to reduce data", func(t *testing.T) { + cdc := keepertest.NewCodec() + appState := sample.AppState(t) + importData := GetImportData(t, cdc, 100) + err := zetacored.ModifyObserverState(appState, importData, cdc) + require.NoError(t, err) + + modifiedObserverAppState := observertypes.GetGenesisStateFromAppState(cdc, appState) + require.Len(t, modifiedObserverAppState.Ballots, zetacored.MaxItemsForList) + require.Len(t, modifiedObserverAppState.NonceToCctx, zetacored.MaxItemsForList) + }) + + t.Run("successfully modify observer state without changing data when not needed", func(t *testing.T) { + cdc := keepertest.NewCodec() + appState := sample.AppState(t) + importData := GetImportData(t, cdc, 8) + err := zetacored.ModifyObserverState(appState, importData, cdc) + require.NoError(t, err) + + modifiedObserverAppState := observertypes.GetGenesisStateFromAppState(cdc, appState) + require.Len(t, modifiedObserverAppState.Ballots, 8) + require.Len(t, modifiedObserverAppState.NonceToCctx, 8) + }) + +} + +func Test_ImportDataIntoFile(t *testing.T) { + setConfig(t) + cdc := keepertest.NewCodec() + genDoc := sample.GenDoc(t) + importGenDoc := ImportGenDoc(t, cdc, 100) + + err := zetacored.ImportDataIntoFile(genDoc, importGenDoc, cdc) + require.NoError(t, err) + + appState, err := genutiltypes.GenesisStateFromGenDoc(*genDoc) + require.NoError(t, err) + + // Crosschain module is in Modify list + crosschainStateAfterImport := crosschaintypes.GetGenesisStateFromAppState(cdc, appState) + require.Len(t, crosschainStateAfterImport.CrossChainTxs, zetacored.MaxItemsForList) + require.Len(t, crosschainStateAfterImport.InTxHashToCctxList, zetacored.MaxItemsForList) + require.Len(t, crosschainStateAfterImport.FinalizedInbounds, zetacored.MaxItemsForList) + + // Bank module is in Skip list + var bankStateAfterImport banktypes.GenesisState + if appState[banktypes.ModuleName] != nil { + err := cdc.UnmarshalJSON(appState[banktypes.ModuleName], &bankStateAfterImport) + if err != nil { + panic(fmt.Sprintf("Failed to get genesis state from app state: %s", err.Error())) + } + } + // 4 balances were present in the original genesis state + require.Len(t, bankStateAfterImport.Balances, 4) + + // Emissions module is in Copy list + var emissionStateAfterImport emissionstypes.GenesisState + if appState[emissionstypes.ModuleName] != nil { + err := cdc.UnmarshalJSON(appState[emissionstypes.ModuleName], &emissionStateAfterImport) + if err != nil { + panic(fmt.Sprintf("Failed to get genesis state from app state: %s", err.Error())) + } + } + require.Len(t, emissionStateAfterImport.WithdrawableEmissions, 100) +} + +func Test_GetGenDoc(t *testing.T) { + t.Run("successfully get genesis doc from file", func(t *testing.T) { + fp := filepath.Join(os.TempDir(), "genesis.json") + err := genutil.ExportGenesisFile(sample.GenDoc(t), fp) + require.NoError(t, err) + _, err = zetacored.GetGenDoc(fp) + require.NoError(t, err) + }) + t.Run("fail to get genesis doc from file", func(t *testing.T) { + _, err := zetacored.GetGenDoc("test") + require.ErrorContains(t, err, "no such file or directory") + }) +} + +func ImportGenDoc(t *testing.T, cdc *codec.ProtoCodec, n int) *types.GenesisDoc { + importGenDoc := sample.GenDoc(t) + importStateJson, err := json.Marshal(GetImportData(t, cdc, n)) + require.NoError(t, err) + importGenDoc.AppState = importStateJson + return importGenDoc +} + +func GetImportData(t *testing.T, cdc *codec.ProtoCodec, n int) map[string]json.RawMessage { + importData := sample.AppState(t) + + // Add crosschain data to genesis state + importedCrossChainGenState := crosschaintypes.GetGenesisStateFromAppState(cdc, importData) + cctxList := make([]*crosschaintypes.CrossChainTx, n) + intxHashToCctxList := make([]crosschaintypes.InTxHashToCctx, n) + finalLizedInbounds := make([]string, n) + for i := 0; i < n; i++ { + cctxList[i] = sample.CrossChainTx(t, fmt.Sprintf("crosschain-%d", i)) + intxHashToCctxList[i] = sample.InTxHashToCctx(t, fmt.Sprintf("intxHashToCctxList-%d", i)) + finalLizedInbounds[i] = fmt.Sprintf("finalLizedInbounds-%d", i) + } + importedCrossChainGenState.CrossChainTxs = cctxList + importedCrossChainGenState.InTxHashToCctxList = intxHashToCctxList + importedCrossChainGenState.FinalizedInbounds = finalLizedInbounds + importedCrossChainStateBz, err := json.Marshal(importedCrossChainGenState) + require.NoError(t, err) + importData[crosschaintypes.ModuleName] = importedCrossChainStateBz + + // Add observer data to genesis state + importedObserverGenState := observertypes.GetGenesisStateFromAppState(cdc, importData) + ballots := make([]*observertypes.Ballot, n) + nonceToCctx := make([]observertypes.NonceToCctx, n) + for i := 0; i < n; i++ { + ballots[i] = sample.Ballot(t, fmt.Sprintf("ballots-%d", i)) + nonceToCctx[i] = sample.NonceToCCTX(t, fmt.Sprintf("nonceToCctx-%d", i)) + } + importedObserverGenState.Ballots = ballots + importedObserverGenState.NonceToCctx = nonceToCctx + importedObserverStateBz, err := cdc.MarshalJSON(&importedObserverGenState) + require.NoError(t, err) + importData[observertypes.ModuleName] = importedObserverStateBz + + // Add emission data to genesis state + var importedEmissionGenesis emissionstypes.GenesisState + if importData[emissionstypes.ModuleName] != nil { + err := cdc.UnmarshalJSON(importData[emissionstypes.ModuleName], &importedEmissionGenesis) + if err != nil { + panic(fmt.Sprintf("Failed to get genesis state from app state: %s", err.Error())) + } + } + withdrawableEmissions := make([]emissionstypes.WithdrawableEmissions, n) + for i := 0; i < n; i++ { + withdrawableEmissions[i] = sample.WithdrawableEmissions(t) + } + importedEmissionGenesis.WithdrawableEmissions = withdrawableEmissions + importedEmissionGenesisBz, err := cdc.MarshalJSON(&importedEmissionGenesis) + require.NoError(t, err) + importData[emissionstypes.ModuleName] = importedEmissionGenesisBz + + // Add bank data to genesis state + var importedBankGenesis banktypes.GenesisState + if importData[banktypes.ModuleName] != nil { + err := cdc.UnmarshalJSON(importData[banktypes.ModuleName], &importedBankGenesis) + if err != nil { + panic(fmt.Sprintf("Failed to get genesis state from app state: %s", err.Error())) + } + } + balances := make([]banktypes.Balance, n) + supply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.ZeroInt())) + for i := 0; i < n; i++ { + balances[i] = banktypes.Balance{ + Address: sample.AccAddress(), + Coins: sample.Coins(), + } + supply = supply.Add(balances[i].Coins...) + } + importedBankGenesis.Balances = balances + importedBankGenesis.Supply = supply + importedBankGenesisBz, err := cdc.MarshalJSON(&importedBankGenesis) + require.NoError(t, err) + importData[banktypes.ModuleName] = importedBankGenesisBz + + return importData +} diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 0254602289..a79bf2d111 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -134,6 +134,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig genutilcli.ValidateGenesisCmd(app.ModuleBasics), AddGenesisAccountCmd(app.DefaultNodeHome), AddObserverAccountsCmd(), + CmdParseGenesisFile(), GetPubKeyCmd(), CollectObserverInfoCmd(), AddrConversionCmd(), diff --git a/docs/cli/zetacored/zetacored.md b/docs/cli/zetacored/zetacored.md index 4b5f360d55..f501a6a46b 100644 --- a/docs/cli/zetacored/zetacored.md +++ b/docs/cli/zetacored/zetacored.md @@ -29,6 +29,7 @@ Zetacore Daemon (server) * [zetacored index-eth-tx](zetacored_index-eth-tx.md) - Index historical eth txs * [zetacored init](zetacored_init.md) - Initialize private validator, p2p, genesis, and application configuration files * [zetacored keys](zetacored_keys.md) - Manage your application's keys +* [zetacored parse-genesis-file](zetacored_parse-genesis-file.md) - Parse the provided genesis file and import the required data into the optionally provided genesis file * [zetacored query](zetacored_query.md) - Querying subcommands * [zetacored rollback](zetacored_rollback.md) - rollback cosmos-sdk and tendermint state by one height * [zetacored rosetta](zetacored_rosetta.md) - spin up a rosetta server diff --git a/docs/cli/zetacored/zetacored_parse-genesis-file.md b/docs/cli/zetacored/zetacored_parse-genesis-file.md new file mode 100644 index 0000000000..b35a5c6b97 --- /dev/null +++ b/docs/cli/zetacored/zetacored_parse-genesis-file.md @@ -0,0 +1,27 @@ +# parse-genesis-file + +Parse the provided genesis file and import the required data into the optionally provided genesis file + +``` +zetacored parse-genesis-file [import-genesis-file] [optional-genesis-file] [flags] +``` + +### Options + +``` + -h, --help help for parse-genesis-file +``` + +### 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) + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored](zetacored.md) - Zetacore Daemon (server) + diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 7d9d54c646..a05c4ecf52 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -264,3 +264,13 @@ func VotesSuccessOnly(voteCount int) []types.VoteType { } return votes } + +func NonceToCCTX(t *testing.T, seed string) types.NonceToCctx { + r := newRandFromStringSeed(t, seed) + return types.NonceToCctx{ + ChainId: r.Int63(), + Nonce: r.Int63(), + CctxIndex: StringRandom(r, 64), + Tss: Tss().TssPubkey, + } +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index b0049ab589..7dae4b7dd2 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -1,6 +1,7 @@ package sample import ( + "encoding/json" "errors" "hash/fnv" "math/rand" @@ -10,7 +11,9 @@ import ( "github.com/zeta-chain/zetacore/pkg/chains" sdkmath "cosmossdk.io/math" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ethcrypto "github.com/ethereum/go-ethereum/crypto" + "github.com/tendermint/tendermint/types" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -101,6 +104,18 @@ func IntInRange(low, high int64) sdkmath.Int { i := Int64InRange(low, high) return sdkmath.NewInt(i) } +func AppState(t *testing.T) map[string]json.RawMessage { + appState, err := genutiltypes.GenesisStateFromGenDoc(*GenDoc(t)) + require.NoError(t, err) + return appState +} + +func GenDoc(t *testing.T) *types.GenesisDoc { + jsonBlob := []byte("{\n \"genesis_time\": \"2024-04-12T05:07:56.004517Z\",\n \"chain_id\": \"localnet_101-1\",\n \"initial_height\": \"1\",\n \"consensus_params\": {\n \"block\": {\n \"max_bytes\": \"22020096\",\n \"max_gas\": \"10000000\",\n \"time_iota_ms\": \"1000\"\n },\n \"evidence\": {\n \"max_age_num_blocks\": \"100000\",\n \"max_age_duration\": \"172800000000000\",\n \"max_bytes\": \"1048576\"\n },\n \"validator\": {\n \"pub_key_types\": [\n \"ed25519\"\n ]\n },\n \"version\": {}\n },\n \"app_hash\": \"\",\n \"app_state\": {\n \"auth\": {\n \"params\": {\n \"max_memo_characters\": \"256\",\n \"tx_sig_limit\": \"7\",\n \"tx_size_cost_per_byte\": \"10\",\n \"sig_verify_cost_ed25519\": \"590\",\n \"sig_verify_cost_secp256k1\": \"1000\"\n },\n \"accounts\": [\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n },\n {\n \"@type\": \"/ethermint.types.v1.EthAccount\",\n \"base_account\": {\n \"address\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"pub_key\": null,\n \"account_number\": \"0\",\n \"sequence\": \"0\"\n },\n \"code_hash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\"\n }\n ]\n },\n \"authority\": {\n \"policies\": {\n \"items\": [\n {\n \"policy_type\": \"groupEmergency\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n },\n {\n \"policy_type\": \"groupOperational\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n },\n {\n \"policy_type\": \"groupAdmin\",\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n }\n ]\n }\n },\n \"authz\": {\n \"authorization\": [\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgGasPriceVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgCreateTSSVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgAddToOutTxTracker\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlameVote\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"grantee\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlockHeader\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgGasPriceVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgCreateTSSVoter\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.crosschain.MsgAddToOutTxTracker\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlameVote\"\n },\n \"expiration\": null\n },\n {\n \"granter\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"grantee\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"authorization\": {\n \"@type\": \"/cosmos.authz.v1beta1.GenericAuthorization\",\n \"msg\": \"/zetachain.zetacore.observer.MsgAddBlockHeader\"\n },\n \"expiration\": null\n }\n ]\n },\n \"bank\": {\n \"params\": {\n \"send_enabled\": [],\n \"default_send_enabled\": true\n },\n \"balances\": [\n {\n \"address\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"4200000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"4200000000000000000000000\"\n }\n ]\n },\n {\n \"address\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"coins\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n ]\n }\n ],\n \"supply\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"8402000000000000000000000\"\n }\n ],\n \"denom_metadata\": []\n },\n \"crisis\": {\n \"constant_fee\": {\n \"denom\": \"azeta\",\n \"amount\": \"1000\"\n }\n },\n \"crosschain\": {\n \"outTxTrackerList\": [],\n \"inTxHashToCctxList\": [],\n \"in_tx_tracker_list\": [],\n \"zeta_accounting\": {\n \"aborted_zeta_amount\": \"0\"\n }\n },\n \"distribution\": {\n \"params\": {\n \"community_tax\": \"0.020000000000000000\",\n \"base_proposer_reward\": \"0.010000000000000000\",\n \"bonus_proposer_reward\": \"0.040000000000000000\",\n \"withdraw_addr_enabled\": true\n },\n \"fee_pool\": {\n \"community_pool\": []\n },\n \"delegator_withdraw_infos\": [],\n \"previous_proposer\": \"\",\n \"outstanding_rewards\": [],\n \"validator_accumulated_commissions\": [],\n \"validator_historical_rewards\": [],\n \"validator_current_rewards\": [],\n \"delegator_starting_infos\": [],\n \"validator_slash_events\": []\n },\n \"emissions\": {\n \"params\": {\n \"max_bond_factor\": \"1.25\",\n \"min_bond_factor\": \"0.75\",\n \"avg_block_time\": \"6.00\",\n \"target_bond_ratio\": \"00.67\",\n \"validator_emission_percentage\": \"00.50\",\n \"observer_emission_percentage\": \"00.25\",\n \"tss_signer_emission_percentage\": \"00.25\",\n \"duration_factor_constant\": \"0.001877876953694702\",\n \"observer_slash_amount\": \"0\"\n },\n \"withdrawableEmissions\": []\n },\n \"evidence\": {\n \"evidence\": []\n },\n \"evm\": {\n \"accounts\": [],\n \"params\": {\n \"evm_denom\": \"azeta\",\n \"enable_create\": true,\n \"enable_call\": true,\n \"extra_eips\": [],\n \"chain_config\": {\n \"homestead_block\": \"0\",\n \"dao_fork_block\": \"0\",\n \"dao_fork_support\": true,\n \"eip150_block\": \"0\",\n \"eip150_hash\": \"0x0000000000000000000000000000000000000000000000000000000000000000\",\n \"eip155_block\": \"0\",\n \"eip158_block\": \"0\",\n \"byzantium_block\": \"0\",\n \"constantinople_block\": \"0\",\n \"petersburg_block\": \"0\",\n \"istanbul_block\": \"0\",\n \"muir_glacier_block\": \"0\",\n \"berlin_block\": \"0\",\n \"london_block\": \"0\",\n \"arrow_glacier_block\": \"0\",\n \"gray_glacier_block\": \"0\",\n \"merge_netsplit_block\": \"0\",\n \"shanghai_block\": \"0\",\n \"cancun_block\": \"0\"\n },\n \"allow_unprotected_txs\": false\n }\n },\n \"feemarket\": {\n \"params\": {\n \"no_base_fee\": false,\n \"base_fee_change_denominator\": 8,\n \"elasticity_multiplier\": 2,\n \"enable_height\": \"0\",\n \"base_fee\": \"1000000000\",\n \"min_gas_price\": \"0.000000000000000000\",\n \"min_gas_multiplier\": \"0.500000000000000000\"\n },\n \"block_gas\": \"0\"\n },\n \"fungible\": {\n \"params\": {},\n \"foreignCoinsList\": [],\n \"systemContract\": null\n },\n \"genutil\": {\n \"gen_txs\": [\n {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"/cosmos.staking.v1beta1.MsgCreateValidator\",\n \"description\": {\n \"moniker\": \"Zetanode-Localnet\",\n \"identity\": \"\",\n \"website\": \"\",\n \"security_contact\": \"\",\n \"details\": \"\"\n },\n \"commission\": {\n \"rate\": \"0.100000000000000000\",\n \"max_rate\": \"0.200000000000000000\",\n \"max_change_rate\": \"0.010000000000000000\"\n },\n \"min_self_delegation\": \"1\",\n \"delegator_address\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"validator_address\": \"zetavaloper13c7p3xrhd6q2rx3h235jpt8pjdwvacyw7tkass\",\n \"pubkey\": {\n \"@type\": \"/cosmos.crypto.ed25519.PubKey\",\n \"key\": \"sBSs5r1vQn1idTp4uRTbdUK0jjmEscI3pn88LUXI4CQ=\"\n },\n \"value\": {\n \"denom\": \"azeta\",\n \"amount\": \"1000000000000000000000\"\n }\n }\n ],\n \"memo\": \"1db4f4185e68c1c17d508294de2592616dad37a5@192.168.2.12:26656\",\n \"timeout_height\": \"0\",\n \"extension_options\": [],\n \"non_critical_extension_options\": []\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"/cosmos.crypto.secp256k1.PubKey\",\n \"key\": \"A05F6QuFVpb/5KrIPvlHr209ZsD22gW0omhLSXWAtQrh\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_DIRECT\"\n }\n },\n \"sequence\": \"0\"\n }\n ],\n \"fee\": {\n \"amount\": [],\n \"gas_limit\": \"200000\",\n \"payer\": \"\",\n \"granter\": \"\"\n },\n \"tip\": null\n },\n \"signatures\": [\n \"y5YROwZmV0jcgv5BgRJCDE+Kq5OsX8+88or1ogekPLBw3ecPt8GsCeEbPQ24JONLzNwQEIUDNYTeSQnXnCfzyg==\"\n ]\n }\n ]\n },\n \"gov\": {\n \"starting_proposal_id\": \"1\",\n \"deposits\": [],\n \"votes\": [],\n \"proposals\": [],\n \"deposit_params\": {\n \"min_deposit\": [\n {\n \"denom\": \"azeta\",\n \"amount\": \"10000000\"\n }\n ],\n \"max_deposit_period\": \"172800s\"\n },\n \"voting_params\": {\n \"voting_period\": \"10s\"\n },\n \"tally_params\": {\n \"quorum\": \"0.334000000000000000\",\n \"threshold\": \"0.500000000000000000\",\n \"veto_threshold\": \"0.334000000000000000\"\n }\n },\n \"group\": {\n \"group_seq\": \"0\",\n \"groups\": [],\n \"group_members\": [],\n \"group_policy_seq\": \"0\",\n \"group_policies\": [],\n \"proposal_seq\": \"0\",\n \"proposals\": [],\n \"votes\": []\n },\n \"mint\": {\n \"params\": {\n \"mint_denom\": \"azeta\"\n }\n },\n \"observer\": {\n \"observers\": {\n \"observer_list\": [\n \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\"\n ]\n },\n \"nodeAccountList\": [\n {\n \"operator\": \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"granteeAddress\": \"zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n\",\n \"granteePubkey\": {\n \"secp256k1\": \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\"\n },\n \"nodeStatus\": 4\n },\n {\n \"operator\": \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\",\n \"granteeAddress\": \"zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx\",\n \"granteePubkey\": {\n \"secp256k1\": \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n },\n \"nodeStatus\": 4\n }\n ],\n \"crosschain_flags\": {\n \"isInboundEnabled\": true,\n \"isOutboundEnabled\": true\n },\n \"params\": {\n \"observer_params\": [\n {\n \"chain\": {\n \"chain_name\": 2,\n \"chain_id\": 101\n },\n \"ballot_threshold\": \"0.660000000000000000\",\n \"min_observer_delegation\": \"1000000000000000000000.000000000000000000\",\n \"is_supported\": true\n },\n {\n \"chain\": {\n \"chain_name\": 15,\n \"chain_id\": 18444\n },\n \"ballot_threshold\": \"0.660000000000000000\",\n \"min_observer_delegation\": \"1000000000000000000000.000000000000000000\",\n \"is_supported\": true\n },\n {\n \"chain\": {\n \"chain_name\": 14,\n \"chain_id\": 1337\n },\n \"ballot_threshold\": \"0.660000000000000000\",\n \"min_observer_delegation\": \"1000000000000000000000.000000000000000000\",\n \"is_supported\": true\n }\n ],\n \"admin_policy\": [\n {\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n },\n {\n \"policy_type\": 1,\n \"address\": \"zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73\"\n }\n ],\n \"ballot_maturity_blocks\": 100\n },\n \"keygen\": {\n \"status\": 1,\n \"granteePubkeys\": [\n \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\",\n \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n ]\n },\n \"chain_params_list\": {},\n \"tss\": {\n \"tss_pubkey\": \"zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p\",\n \"tss_participant_list\": [\n \"zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp\",\n \"zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045\"\n ],\n \"operator_address_list\": [\n \"zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax\",\n \"zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2\"\n ]\n },\n \"tss_history\": [],\n \"tss_fund_migrators\": [],\n \"blame_list\": [],\n \"pending_nonces\": [],\n \"chain_nonces\": [],\n \"nonce_to_cctx\": []\n },\n \"params\": null,\n \"slashing\": {\n \"params\": {\n \"signed_blocks_window\": \"100\",\n \"min_signed_per_window\": \"0.500000000000000000\",\n \"downtime_jail_duration\": \"600s\",\n \"slash_fraction_double_sign\": \"0.050000000000000000\",\n \"slash_fraction_downtime\": \"0.010000000000000000\"\n },\n \"signing_infos\": [],\n \"missed_blocks\": []\n },\n \"staking\": {\n \"params\": {\n \"unbonding_time\": \"1814400s\",\n \"max_validators\": 100,\n \"max_entries\": 7,\n \"historical_entries\": 10000,\n \"bond_denom\": \"azeta\",\n \"min_commission_rate\": \"0.000000000000000000\"\n },\n \"last_total_power\": \"0\",\n \"last_validator_powers\": [],\n \"validators\": [],\n \"delegations\": [],\n \"unbonding_delegations\": [],\n \"redelegations\": [],\n \"exported\": false\n },\n \"upgrade\": {},\n \"vesting\": {}\n }\n}") + genDoc, err := types.GenesisDocFromJSON(jsonBlob) + require.NoError(t, err) + return genDoc +} func Chain(chainID int64) *chains.Chain { r := newRandFromSeed(chainID) From f7e5c078be59f9b6aa1ae6e8cf232894e9e221b9 Mon Sep 17 00:00:00 2001 From: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:42:24 -0500 Subject: [PATCH 09/11] feat: outbound cctx scheduling with rate limiter (#2045) * initial commit of grpc pending cctx query with rate limiter * replace big.Float with sdk.Dec and update mock rate limiter flags * split big loop into backwards loop and forwards loop to be more accurate * adjust zetaclient code to query pending cctx with rate limit * update change log and add one more rate limiter flag test * use outboun amount for calculation * some minimum code refactor * created separate file for cctx query with rate limit * improved a few error handlling * use old cctx query as fallback when rate limiter is disabled; some renaming * fixed unit test compile * added unit test for fallback query --------- Co-authored-by: Lucas Bertrand --- changelog.md | 1 + cmd/zetae2e/stress.go | 2 +- docs/openapi/openapi.swagger.yaml | 88 +- proto/crosschain/query.proto | 23 +- testutil/keeper/mocks/crosschain/fungible.go | 20 + testutil/keeper/mocks/crosschain/observer.go | 20 + testutil/sample/fungible.go | 30 + typescript/crosschain/query_pb.d.ts | 90 +- x/crosschain/client/cli/cli_cctx.go | 4 +- x/crosschain/keeper/abci.go | 2 +- x/crosschain/keeper/cctx_utils.go | 2 +- x/crosschain/keeper/cctx_utils_test.go | 10 +- x/crosschain/keeper/evm_deposit_test.go | 22 +- x/crosschain/keeper/foreign_coins.go | 4 +- x/crosschain/keeper/foreign_coins_test.go | 3 +- x/crosschain/keeper/gas_payment_test.go | 28 +- x/crosschain/keeper/grpc_query_cctx.go | 77 +- .../keeper/grpc_query_cctx_rate_limit.go | 259 ++++++ .../keeper/grpc_query_cctx_rate_limit_test.go | 182 ++++ x/crosschain/keeper/grpc_query_cctx_test.go | 36 +- .../msg_server_add_to_intx_tracker_test.go | 16 +- .../keeper/msg_server_add_to_outtx_tracker.go | 2 +- .../msg_server_migrate_tss_funds_test.go | 28 +- .../msg_server_refund_aborted_tx_test.go | 26 +- .../keeper/msg_server_vote_inbound_tx_test.go | 4 +- .../msg_server_vote_outbound_tx_test.go | 12 +- .../keeper/msg_server_whitelist_erc20_test.go | 10 +- x/crosschain/keeper/process_inbound_test.go | 20 +- x/crosschain/keeper/process_outbound_test.go | 16 +- x/crosschain/keeper/rate_limiter_flags.go | 34 + .../keeper/rate_limiter_flags_test.go | 67 ++ x/crosschain/keeper/refund_test.go | 32 +- x/crosschain/keeper/utils_test.go | 6 +- x/crosschain/types/expected_keepers.go | 2 + x/crosschain/types/query.pb.go | 831 ++++++++++++++---- x/crosschain/types/query.pb.gw.go | 117 ++- x/fungible/keeper/foreign_coins.go | 18 + x/observer/keeper/chain_params.go | 13 + zetaclient/evm/evm_signer.go | 2 +- zetaclient/interfaces/interfaces.go | 1 + zetaclient/testutils/stub/core_bridge.go | 7 + zetaclient/zetabridge/query.go | 26 +- zetaclient/zetabridge/query_test.go | 6 +- zetaclient/zetacore_observer.go | 48 +- 44 files changed, 1798 insertions(+), 449 deletions(-) create mode 100644 x/crosschain/keeper/grpc_query_cctx_rate_limit.go create mode 100644 x/crosschain/keeper/grpc_query_cctx_rate_limit_test.go diff --git a/changelog.md b/changelog.md index dac460d24a..ede402b460 100644 --- a/changelog.md +++ b/changelog.md @@ -54,6 +54,7 @@ * [1954](https://github.com/zeta-chain/node/pull/1954) - add metric for concurrent keysigns * [1979](https://github.com/zeta-chain/node/pull/1979) - add script to import genesis data into an existing genesis file * [2006](https://github.com/zeta-chain/node/pull/2006) - add Amoy testnet static chain information +* [2045](https://github.com/zeta-chain/node/pull/2046) - add grpc query with outbound rate limit for zetaclient to use * [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags * [2034](https://github.com/zeta-chain/node/pull/2034) - add support for zEVM message passing diff --git a/cmd/zetae2e/stress.go b/cmd/zetae2e/stress.go index 5228905074..f8ca5b9f28 100644 --- a/cmd/zetae2e/stress.go +++ b/cmd/zetae2e/stress.go @@ -252,7 +252,7 @@ func EchoNetworkMetrics(runner *runner.E2ERunner) { case <-ticker.C: numTicks++ // Get all pending outbound transactions - cctxResp, err := runner.CctxClient.CctxListPending(context.Background(), &crosschaintypes.QueryListCctxPendingRequest{ + cctxResp, err := runner.CctxClient.ListPendingCctx(context.Background(), &crosschaintypes.QueryListPendingCctxRequest{ ChainId: chainID.Int64(), }) if err != nil { diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index f18907f74f..1eb8fe4593 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -26582,32 +26582,6 @@ paths: type: string tags: - Query - /zeta-chain/crosschain/cctxPending: - get: - summary: Queries a list of pending cctxs. - operationId: Query_CctxListPending - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/crosschainQueryListCctxPendingResponse' - default: - description: An unexpected error response. - schema: - $ref: '#/definitions/googlerpcStatus' - parameters: - - name: chain_id - in: query - required: false - type: string - format: int64 - - name: limit - in: query - required: false - type: integer - format: int64 - tags: - - Query /zeta-chain/crosschain/convertGasToZeta: get: operationId: Query_ConvertGasToZeta @@ -27173,6 +27147,53 @@ paths: type: boolean tags: - Query + /zeta-chain/crosschain/pendingCctx: + get: + summary: Queries a list of pending cctxs. + operationId: Query_ListPendingCctx + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/crosschainQueryListPendingCctxResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: chain_id + in: query + required: false + type: string + format: int64 + - name: limit + in: query + required: false + type: integer + format: int64 + tags: + - Query + /zeta-chain/crosschain/pendingCctxWithinRateLimit: + get: + summary: Queries a list of pending cctxs within rate limit. + operationId: Query_ListPendingCctxWithinRateLimit + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/crosschainQueryListPendingCctxWithinRateLimitResponse' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/googlerpcStatus' + parameters: + - name: limit + in: query + required: false + type: integer + format: int64 + tags: + - Query /zeta-chain/crosschain/protocolFee: get: operationId: Query_ProtocolFee @@ -53970,7 +53991,7 @@ definitions: Height: type: string format: int64 - crosschainQueryListCctxPendingResponse: + crosschainQueryListPendingCctxResponse: type: object properties: CrossChainTx: @@ -53981,6 +54002,19 @@ definitions: totalPending: type: string format: uint64 + crosschainQueryListPendingCctxWithinRateLimitResponse: + type: object + properties: + cross_chain_tx: + type: array + items: + type: object + $ref: '#/definitions/crosschainCrossChainTx' + total_pending: + type: string + format: uint64 + rate_limit_exceeded: + type: boolean crosschainQueryMessagePassingProtocolFeeResponse: type: object properties: diff --git a/proto/crosschain/query.proto b/proto/crosschain/query.proto index 326b615560..b017e2c523 100644 --- a/proto/crosschain/query.proto +++ b/proto/crosschain/query.proto @@ -95,8 +95,13 @@ service Query { } // Queries a list of pending cctxs. - rpc CctxListPending(QueryListCctxPendingRequest) returns (QueryListCctxPendingResponse) { - option (google.api.http).get = "/zeta-chain/crosschain/cctxPending"; + rpc ListPendingCctx(QueryListPendingCctxRequest) returns (QueryListPendingCctxResponse) { + option (google.api.http).get = "/zeta-chain/crosschain/pendingCctx"; + } + + // Queries a list of pending cctxs within rate limit. + rpc ListPendingCctxWithinRateLimit(QueryListPendingCctxWithinRateLimitRequest) returns (QueryListPendingCctxWithinRateLimitResponse) { + option (google.api.http).get = "/zeta-chain/crosschain/pendingCctxWithinRateLimit"; } rpc ZetaAccounting(QueryZetaAccountingRequest) returns (QueryZetaAccountingResponse) { @@ -248,16 +253,26 @@ message QueryAllCctxResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } -message QueryListCctxPendingRequest { +message QueryListPendingCctxRequest { int64 chain_id = 1; uint32 limit = 2; } -message QueryListCctxPendingResponse { +message QueryListPendingCctxResponse { repeated CrossChainTx CrossChainTx = 1; uint64 totalPending = 2; } +message QueryListPendingCctxWithinRateLimitRequest { + uint32 limit = 1; +} + +message QueryListPendingCctxWithinRateLimitResponse { + repeated CrossChainTx cross_chain_tx = 1; + uint64 total_pending = 2; + bool rate_limit_exceeded = 3; +} + message QueryLastZetaHeightRequest {} message QueryLastZetaHeightResponse { diff --git a/testutil/keeper/mocks/crosschain/fungible.go b/testutil/keeper/mocks/crosschain/fungible.go index 1380308910..587c1676a6 100644 --- a/testutil/keeper/mocks/crosschain/fungible.go +++ b/testutil/keeper/mocks/crosschain/fungible.go @@ -254,6 +254,26 @@ func (_m *CrosschainFungibleKeeper) GetAllForeignCoinsForChain(ctx types.Context return r0 } +// GetAllForeignERC20CoinMap provides a mock function with given fields: ctx +func (_m *CrosschainFungibleKeeper) GetAllForeignERC20CoinMap(ctx types.Context) map[int64]map[string]fungibletypes.ForeignCoins { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetAllForeignERC20CoinMap") + } + + var r0 map[int64]map[string]fungibletypes.ForeignCoins + if rf, ok := ret.Get(0).(func(types.Context) map[int64]map[string]fungibletypes.ForeignCoins); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[int64]map[string]fungibletypes.ForeignCoins) + } + } + + return r0 +} + // GetForeignCoinFromAsset provides a mock function with given fields: ctx, asset, chainID func (_m *CrosschainFungibleKeeper) GetForeignCoinFromAsset(ctx types.Context, asset string, chainID int64) (fungibletypes.ForeignCoins, bool) { ret := _m.Called(ctx, asset, chainID) diff --git a/testutil/keeper/mocks/crosschain/observer.go b/testutil/keeper/mocks/crosschain/observer.go index aa05e13226..37b8ea2720 100644 --- a/testutil/keeper/mocks/crosschain/observer.go +++ b/testutil/keeper/mocks/crosschain/observer.go @@ -596,6 +596,26 @@ func (_m *CrosschainObserverKeeper) GetSupportedChains(ctx types.Context) []*cha return r0 } +// GetSupportedForeignChains provides a mock function with given fields: ctx +func (_m *CrosschainObserverKeeper) GetSupportedForeignChains(ctx types.Context) []*chains.Chain { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetSupportedForeignChains") + } + + var r0 []*chains.Chain + if rf, ok := ret.Get(0).(func(types.Context) []*chains.Chain); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*chains.Chain) + } + } + + return r0 +} + // GetTSS provides a mock function with given fields: ctx func (_m *CrosschainObserverKeeper) GetTSS(ctx types.Context) (observertypes.TSS, bool) { ret := _m.Called(ctx) diff --git a/testutil/sample/fungible.go b/testutil/sample/fungible.go index 73fdc2b2e3..3be91d06a3 100644 --- a/testutil/sample/fungible.go +++ b/testutil/sample/fungible.go @@ -3,6 +3,7 @@ package sample import ( "testing" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -22,6 +23,35 @@ func ForeignCoins(t *testing.T, address string) types.ForeignCoins { } } +func ForeignCoinList(t *testing.T, zrc20ETH, zrc20BTC, zrc20ERC20, erc20Asset string) []types.ForeignCoins { + // eth and btc chain id + ethChainID := chains.GoerliLocalnetChain().ChainId + btcChainID := chains.BtcRegtestChain().ChainId + + // add zrc20 ETH + fcGas := ForeignCoins(t, zrc20ETH) + fcGas.Asset = "" + fcGas.ForeignChainId = ethChainID + fcGas.Decimals = 18 + fcGas.CoinType = coin.CoinType_Gas + + // add zrc20 BTC + fcBTC := ForeignCoins(t, zrc20BTC) + fcBTC.Asset = "" + fcBTC.ForeignChainId = btcChainID + fcBTC.Decimals = 8 + fcBTC.CoinType = coin.CoinType_Gas + + // add zrc20 ERC20 + fcERC20 := ForeignCoins(t, zrc20ERC20) + fcERC20.Asset = erc20Asset + fcERC20.ForeignChainId = ethChainID + fcERC20.Decimals = 6 + fcERC20.CoinType = coin.CoinType_ERC20 + + return []types.ForeignCoins{fcGas, fcBTC, fcERC20} +} + func SystemContract() *types.SystemContract { return &types.SystemContract{ SystemContract: EthAddress().String(), diff --git a/typescript/crosschain/query_pb.d.ts b/typescript/crosschain/query_pb.d.ts index e73ef4394d..34b4a44f38 100644 --- a/typescript/crosschain/query_pb.d.ts +++ b/typescript/crosschain/query_pb.d.ts @@ -814,9 +814,9 @@ export declare class QueryAllCctxResponse extends Message } /** - * @generated from message zetachain.zetacore.crosschain.QueryListCctxPendingRequest + * @generated from message zetachain.zetacore.crosschain.QueryListPendingCctxRequest */ -export declare class QueryListCctxPendingRequest extends Message { +export declare class QueryListPendingCctxRequest extends Message { /** * @generated from field: int64 chain_id = 1; */ @@ -827,25 +827,25 @@ export declare class QueryListCctxPendingRequest extends Message); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.crosschain.QueryListCctxPendingRequest"; + static readonly typeName = "zetachain.zetacore.crosschain.QueryListPendingCctxRequest"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): QueryListCctxPendingRequest; + static fromBinary(bytes: Uint8Array, options?: Partial): QueryListPendingCctxRequest; - static fromJson(jsonValue: JsonValue, options?: Partial): QueryListCctxPendingRequest; + static fromJson(jsonValue: JsonValue, options?: Partial): QueryListPendingCctxRequest; - static fromJsonString(jsonString: string, options?: Partial): QueryListCctxPendingRequest; + static fromJsonString(jsonString: string, options?: Partial): QueryListPendingCctxRequest; - static equals(a: QueryListCctxPendingRequest | PlainMessage | undefined, b: QueryListCctxPendingRequest | PlainMessage | undefined): boolean; + static equals(a: QueryListPendingCctxRequest | PlainMessage | undefined, b: QueryListPendingCctxRequest | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.crosschain.QueryListCctxPendingResponse + * @generated from message zetachain.zetacore.crosschain.QueryListPendingCctxResponse */ -export declare class QueryListCctxPendingResponse extends Message { +export declare class QueryListPendingCctxResponse extends Message { /** * @generated from field: repeated zetachain.zetacore.crosschain.CrossChainTx CrossChainTx = 1; */ @@ -856,19 +856,77 @@ export declare class QueryListCctxPendingResponse extends Message); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.crosschain.QueryListCctxPendingResponse"; + static readonly typeName = "zetachain.zetacore.crosschain.QueryListPendingCctxResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): QueryListCctxPendingResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): QueryListPendingCctxResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): QueryListCctxPendingResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): QueryListPendingCctxResponse; - static fromJsonString(jsonString: string, options?: Partial): QueryListCctxPendingResponse; + static fromJsonString(jsonString: string, options?: Partial): QueryListPendingCctxResponse; - static equals(a: QueryListCctxPendingResponse | PlainMessage | undefined, b: QueryListCctxPendingResponse | PlainMessage | undefined): boolean; + static equals(a: QueryListPendingCctxResponse | PlainMessage | undefined, b: QueryListPendingCctxResponse | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.crosschain.QueryListPendingCctxWithinRateLimitRequest + */ +export declare class QueryListPendingCctxWithinRateLimitRequest extends Message { + /** + * @generated from field: uint32 limit = 1; + */ + limit: number; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.QueryListPendingCctxWithinRateLimitRequest"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryListPendingCctxWithinRateLimitRequest; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryListPendingCctxWithinRateLimitRequest; + + static fromJsonString(jsonString: string, options?: Partial): QueryListPendingCctxWithinRateLimitRequest; + + static equals(a: QueryListPendingCctxWithinRateLimitRequest | PlainMessage | undefined, b: QueryListPendingCctxWithinRateLimitRequest | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.crosschain.QueryListPendingCctxWithinRateLimitResponse + */ +export declare class QueryListPendingCctxWithinRateLimitResponse extends Message { + /** + * @generated from field: repeated zetachain.zetacore.crosschain.CrossChainTx cross_chain_tx = 1; + */ + crossChainTx: CrossChainTx[]; + + /** + * @generated from field: uint64 total_pending = 2; + */ + totalPending: bigint; + + /** + * @generated from field: bool rate_limit_exceeded = 3; + */ + rateLimitExceeded: boolean; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.QueryListPendingCctxWithinRateLimitResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): QueryListPendingCctxWithinRateLimitResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): QueryListPendingCctxWithinRateLimitResponse; + + static fromJsonString(jsonString: string, options?: Partial): QueryListPendingCctxWithinRateLimitResponse; + + static equals(a: QueryListPendingCctxWithinRateLimitResponse | PlainMessage | undefined, b: QueryListPendingCctxWithinRateLimitResponse | PlainMessage | undefined): boolean; } /** diff --git a/x/crosschain/client/cli/cli_cctx.go b/x/crosschain/client/cli/cli_cctx.go index 87991442d1..b5add8610b 100644 --- a/x/crosschain/client/cli/cli_cctx.go +++ b/x/crosschain/client/cli/cli_cctx.go @@ -69,13 +69,13 @@ func CmdPendingCctx() *cobra.Command { return err } - params := &types.QueryListCctxPendingRequest{ + params := &types.QueryListPendingCctxRequest{ ChainId: chainID, // #nosec G701 bit size verified Limit: uint32(limit), } - res, err := queryClient.CctxListPending(context.Background(), params) + res, err := queryClient.ListPendingCctx(context.Background(), params) if err != nil { return err } diff --git a/x/crosschain/keeper/abci.go b/x/crosschain/keeper/abci.go index 5a02c53676..f893e795bb 100644 --- a/x/crosschain/keeper/abci.go +++ b/x/crosschain/keeper/abci.go @@ -51,7 +51,7 @@ IterateChains: for _, chain := range chains { // support only external evm chains if zetachains.IsEVMChain(chain.ChainId) && !zetachains.IsZetaChain(chain.ChainId) { - res, err := k.CctxListPending(sdk.UnwrapSDKContext(ctx), &types.QueryListCctxPendingRequest{ + res, err := k.ListPendingCctx(sdk.UnwrapSDKContext(ctx), &types.QueryListPendingCctxRequest{ ChainId: chain.ChainId, Limit: gasPriceIncreaseFlags.MaxPendingCctxs, }) diff --git a/x/crosschain/keeper/cctx_utils.go b/x/crosschain/keeper/cctx_utils.go index 6ae826f9ed..6f9651967a 100644 --- a/x/crosschain/keeper/cctx_utils.go +++ b/x/crosschain/keeper/cctx_utils.go @@ -86,7 +86,7 @@ func (k Keeper) GetRevertGasLimit(ctx sdk.Context, cctx types.CrossChainTx) (uin return 0, nil } -func IsPending(cctx types.CrossChainTx) bool { +func IsPending(cctx *types.CrossChainTx) bool { // pending inbound is not considered a "pending" state because it has not reached consensus yet return cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert } diff --git a/x/crosschain/keeper/cctx_utils_test.go b/x/crosschain/keeper/cctx_utils_test.go index 1c807a97c1..af6445744c 100644 --- a/x/crosschain/keeper/cctx_utils_test.go +++ b/x/crosschain/keeper/cctx_utils_test.go @@ -42,7 +42,7 @@ func TestGetRevertGasLimit(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) gas := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foo", "FOO") @@ -63,7 +63,7 @@ func TestGetRevertGasLimit(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) asset := sample.EthAddress().String() zrc20Addr := deployZRC20( @@ -107,7 +107,7 @@ func TestGetRevertGasLimit(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() zk.FungibleKeeper.SetForeignCoins(ctx, fungibletypes.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), @@ -141,7 +141,7 @@ func TestGetRevertGasLimit(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() asset := sample.EthAddress().String() zk.FungibleKeeper.SetForeignCoins(ctx, fungibletypes.ForeignCoins{ @@ -215,7 +215,7 @@ func Test_IsPending(t *testing.T) { } for _, tc := range tt { t.Run(fmt.Sprintf("status %s", tc.status), func(t *testing.T) { - require.Equal(t, tc.expected, crosschainkeeper.IsPending(types.CrossChainTx{CctxStatus: &types.Status{Status: tc.status}})) + require.Equal(t, tc.expected, crosschainkeeper.IsPending(&types.CrossChainTx{CctxStatus: &types.Status{Status: tc.status}})) }) } } diff --git a/x/crosschain/keeper/evm_deposit_test.go b/x/crosschain/keeper/evm_deposit_test.go index 1f6cd4fad4..d30424697c 100644 --- a/x/crosschain/keeper/evm_deposit_test.go +++ b/x/crosschain/keeper/evm_deposit_test.go @@ -84,7 +84,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -127,7 +127,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -186,7 +186,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -273,7 +273,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -317,7 +317,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -361,7 +361,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -404,7 +404,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -447,7 +447,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -487,7 +487,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() cctx := sample.CrossChainTx(t, "foo") cctx.GetCurrentOutTxParam().Receiver = sample.EthAddress().String() @@ -509,7 +509,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() @@ -555,7 +555,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { UseFungibleMock: true, }) - senderChain := getValidEthChainID(t) + senderChain := getValidEthChainID() fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() diff --git a/x/crosschain/keeper/foreign_coins.go b/x/crosschain/keeper/foreign_coins.go index 1ceeb39bf7..15ecd54260 100644 --- a/x/crosschain/keeper/foreign_coins.go +++ b/x/crosschain/keeper/foreign_coins.go @@ -5,11 +5,11 @@ import ( fungibleModuleTypes "github.com/zeta-chain/zetacore/x/fungible/types" ) -func (k Keeper) GetAllForeignCoins(ctx sdk.Context) ([]fungibleModuleTypes.ForeignCoins, error) { +func (k Keeper) GetAllForeignCoins(ctx sdk.Context) []fungibleModuleTypes.ForeignCoins { chains := k.zetaObserverKeeper.GetSupportedChains(ctx) var fCoins []fungibleModuleTypes.ForeignCoins for _, chain := range chains { fCoins = append(fCoins, k.fungibleKeeper.GetAllForeignCoinsForChain(ctx, chain.ChainId)...) } - return fCoins, nil + return fCoins } diff --git a/x/crosschain/keeper/foreign_coins_test.go b/x/crosschain/keeper/foreign_coins_test.go index 5d145b08f1..aaa359cd72 100644 --- a/x/crosschain/keeper/foreign_coins_test.go +++ b/x/crosschain/keeper/foreign_coins_test.go @@ -14,7 +14,6 @@ func TestKeeper_GetAllForeignCoins(t *testing.T) { fc.ForeignChainId = 101 k.GetFungibleKeeper().SetForeignCoins(ctx, fc) - res, err := k.GetAllForeignCoins(ctx) - require.NoError(t, err) + res := k.GetAllForeignCoins(ctx) require.Equal(t, 1, len(res)) } diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index 569a360327..8079c3c67a 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -30,7 +30,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -72,7 +72,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { t.Run("should fail if not coin type gas", func(t *testing.T) { k, ctx, _, _ := testkeeper.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ CoinType: coin.CoinType_Zeta, @@ -98,7 +98,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") @@ -127,7 +127,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") @@ -170,7 +170,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin, erc20 and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) assetAddress := sample.EthAddress().String() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -236,7 +236,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { t.Run("should fail if not coin type erc20", func(t *testing.T) { k, ctx, _, _ := testkeeper.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ CoinType: coin.CoinType_Gas, @@ -262,7 +262,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") @@ -291,7 +291,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin, erc20 and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) assetAddress := sample.EthAddress().String() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -333,7 +333,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin, erc20 and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) assetAddress := sample.EthAddress().String() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -385,7 +385,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin, erc20 and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) assetAddress := sample.EthAddress().String() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -453,7 +453,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") @@ -514,7 +514,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { t.Run("should fail if pay gas in zeta with coin type other than zeta", func(t *testing.T) { k, ctx, _, _ := testkeeper.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ CoinType: coin.CoinType_Gas, @@ -540,7 +540,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") @@ -571,7 +571,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) // deploy gas coin and set fee params - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") diff --git a/x/crosschain/keeper/grpc_query_cctx.go b/x/crosschain/keeper/grpc_query_cctx.go index 66e809b6b7..8e96757b44 100644 --- a/x/crosschain/keeper/grpc_query_cctx.go +++ b/x/crosschain/keeper/grpc_query_cctx.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/zeta-chain/zetacore/x/crosschain/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -78,42 +79,32 @@ func (k Keeper) CctxByNonce(c context.Context, req *types.QueryGetCctxByNonceReq return nil, status.Error(codes.Internal, "tss not found") } // #nosec G701 always in range - res, found := k.GetObserverKeeper().GetNonceToCctx(ctx, tss.TssPubkey, req.ChainID, int64(req.Nonce)) - if !found { - return nil, status.Error(codes.Internal, fmt.Sprintf("nonceToCctx not found: nonce %d, chainid %d", req.Nonce, req.ChainID)) - } - val, found := k.GetCrossChainTx(ctx, res.CctxIndex) - if !found { - return nil, status.Error(codes.Internal, fmt.Sprintf("cctx not found: index %s", res.CctxIndex)) + cctx, err := getCctxByChainIDAndNonce(k, ctx, tss.TssPubkey, req.ChainID, int64(req.Nonce)) + if err != nil { + return nil, err } - return &types.QueryGetCctxResponse{CrossChainTx: &val}, nil + return &types.QueryGetCctxResponse{CrossChainTx: cctx}, nil } -// CctxListPending returns a list of pending cctxs and the total number of pending cctxs -// a limit for the number of cctxs to return can be specified -// if no limit is specified, the default is MaxPendingCctxs -func (k Keeper) CctxListPending(c context.Context, req *types.QueryListCctxPendingRequest) (*types.QueryListCctxPendingResponse, error) { +// ListPendingCctx returns a list of pending cctxs and the total number of pending cctxs +// a limit for the number of cctxs to return can be specified or the default is MaxPendingCctxs +func (k Keeper) ListPendingCctx(c context.Context, req *types.QueryListPendingCctxRequest) (*types.QueryListPendingCctxResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } - // check limit - // if no limit specified, default to MaxPendingCctxs - if req.Limit > MaxPendingCctxs { - return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("limit exceeds max limit of %d", MaxPendingCctxs)) - } + // use default MaxPendingCctxs if not specified or too high limit := req.Limit - if limit == 0 { + if limit == 0 || limit > MaxPendingCctxs { limit = MaxPendingCctxs } - ctx := sdk.UnwrapSDKContext(c) // query the nonces that are pending tss, found := k.zetaObserverKeeper.GetTSS(ctx) if !found { - return nil, status.Error(codes.Internal, "tss not found") + return nil, observertypes.ErrTssNotFound } pendingNonces, found := k.GetObserverKeeper().GetPendingNonces(ctx, tss.TssPubkey, req.ChainId) if !found { @@ -136,21 +127,16 @@ func (k Keeper) CctxListPending(c context.Context, req *types.QueryListCctxPendi startNonce = 0 } for i := startNonce; i < pendingNonces.NonceLow; i++ { - nonceToCctx, found := k.GetObserverKeeper().GetNonceToCctx(ctx, tss.TssPubkey, req.ChainId, i) - if !found { - return nil, status.Error(codes.Internal, fmt.Sprintf("nonceToCctx not found: nonce %d, chainid %d", i, req.ChainId)) - } - cctx, found := k.GetCrossChainTx(ctx, nonceToCctx.CctxIndex) - if !found { - return nil, status.Error(codes.Internal, fmt.Sprintf("cctx not found: index %s", nonceToCctx.CctxIndex)) + cctx, err := getCctxByChainIDAndNonce(k, ctx, tss.TssPubkey, req.ChainId, i) + if err != nil { + return nil, err } - if cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert { - totalPending++ - // we check here if max cctxs is reached because we want to return the total pending cctxs - // even if we have reached the limit + // only take a `limit` number of pending cctxs as result but still count the total pending cctxs + if IsPending(cctx) { + totalPending++ if !maxCCTXsReached() { - cctxs = append(cctxs, &cctx) + cctxs = append(cctxs, cctx) } } } @@ -161,19 +147,28 @@ func (k Keeper) CctxListPending(c context.Context, req *types.QueryListCctxPendi // now query the pending nonces that we know are pending for i := pendingNonces.NonceLow; i < pendingNonces.NonceHigh && !maxCCTXsReached(); i++ { - nonceToCctx, found := k.GetObserverKeeper().GetNonceToCctx(ctx, tss.TssPubkey, req.ChainId, i) - if !found { - return nil, status.Error(codes.Internal, "nonceToCctx not found") - } - cctx, found := k.GetCrossChainTx(ctx, nonceToCctx.CctxIndex) - if !found { - return nil, status.Error(codes.Internal, "cctxIndex not found") + cctx, err := getCctxByChainIDAndNonce(k, ctx, tss.TssPubkey, req.ChainId, i) + if err != nil { + return nil, err } - cctxs = append(cctxs, &cctx) + cctxs = append(cctxs, cctx) } - return &types.QueryListCctxPendingResponse{ + return &types.QueryListPendingCctxResponse{ CrossChainTx: cctxs, TotalPending: totalPending, }, nil } + +// getCctxByChainIDAndNonce returns the cctx by chainID and nonce +func getCctxByChainIDAndNonce(k Keeper, ctx sdk.Context, tssPubkey string, chainID int64, nonce int64) (*types.CrossChainTx, error) { + nonceToCctx, found := k.GetObserverKeeper().GetNonceToCctx(ctx, tssPubkey, chainID, nonce) + if !found { + return nil, status.Error(codes.Internal, fmt.Sprintf("nonceToCctx not found: chainid %d, nonce %d", chainID, nonce)) + } + cctx, found := k.GetCrossChainTx(ctx, nonceToCctx.CctxIndex) + if !found { + return nil, status.Error(codes.Internal, fmt.Sprintf("cctx not found: index %s", nonceToCctx.CctxIndex)) + } + return &cctx, nil +} diff --git a/x/crosschain/keeper/grpc_query_cctx_rate_limit.go b/x/crosschain/keeper/grpc_query_cctx_rate_limit.go new file mode 100644 index 0000000000..b3b30ca939 --- /dev/null +++ b/x/crosschain/keeper/grpc_query_cctx_rate_limit.go @@ -0,0 +1,259 @@ +package keeper + +import ( + "context" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/x/crosschain/types" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// ListPendingCctxWithinRateLimit returns a list of pending cctxs that do not exceed the outbound rate limit +// a limit for the number of cctxs to return can be specified or the default is MaxPendingCctxs +func (k Keeper) ListPendingCctxWithinRateLimit(c context.Context, req *types.QueryListPendingCctxWithinRateLimitRequest) (*types.QueryListPendingCctxWithinRateLimitResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + // use default MaxPendingCctxs if not specified or too high + limit := req.Limit + if limit == 0 || limit > MaxPendingCctxs { + limit = MaxPendingCctxs + } + ctx := sdk.UnwrapSDKContext(c) + + // define a few variables to be used in the query loops + limitExceeded := false + totalPending := uint64(0) + totalCctxValueInZeta := sdk.NewDec(0) + cctxs := make([]*types.CrossChainTx, 0) + chains := k.zetaObserverKeeper.GetSupportedForeignChains(ctx) + + // check rate limit flags to decide if we should apply rate limit + applyLimit := true + rateLimitFlags, found := k.GetRateLimiterFlags(ctx) + if !found || !rateLimitFlags.Enabled { + applyLimit = false + } + + // fallback to non-rate-limited query if rate limiter is disabled + if !applyLimit { + for _, chain := range chains { + resp, err := k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{ChainId: chain.ChainId, Limit: limit}) + if err == nil { + cctxs = append(cctxs, resp.CrossChainTx...) + totalPending += resp.TotalPending + } + } + return &types.QueryListPendingCctxWithinRateLimitResponse{ + CrossChainTx: cctxs, + TotalPending: totalPending, + RateLimitExceeded: false, + }, nil + } + + // get current height and tss + height := ctx.BlockHeight() + if height <= 0 { + return nil, status.Error(codes.OutOfRange, "height out of range") + } + tss, found := k.zetaObserverKeeper.GetTSS(ctx) + if !found { + return nil, observertypes.ErrTssNotFound + } + + // calculate the rate limiter sliding window left boundary (inclusive) + leftWindowBoundary := height - rateLimitFlags.Window + if leftWindowBoundary < 0 { + leftWindowBoundary = 0 + } + + // get the conversion rates for all foreign coins + var gasCoinRates map[int64]sdk.Dec + var erc20CoinRates map[int64]map[string]sdk.Dec + var erc20Coins map[int64]map[string]fungibletypes.ForeignCoins + var rateLimitInZeta sdk.Dec + if applyLimit { + gasCoinRates, erc20CoinRates = k.GetRateLimiterRates(ctx) + erc20Coins = k.fungibleKeeper.GetAllForeignERC20CoinMap(ctx) + rateLimitInZeta = sdk.NewDecFromBigInt(rateLimitFlags.Rate.BigInt()) + } + + // the criteria to stop adding cctxs to the rpc response + maxCCTXsReached := func() bool { + // #nosec G701 len always positive + return uint32(len(cctxs)) >= limit + } + + // query pending nonces for each foreign chain + // Note: The pending nonces could change during the RPC call, so query them beforehand + pendingNoncesMap := make(map[int64]*observertypes.PendingNonces) + for _, chain := range chains { + pendingNonces, found := k.GetObserverKeeper().GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) + if !found { + return nil, status.Error(codes.Internal, "pending nonces not found") + } + pendingNoncesMap[chain.ChainId] = &pendingNonces + } + + // query backwards for potential missed pending cctxs for each foreign chain +LoopBackwards: + for _, chain := range chains { + // we should at least query 1000 prior to find any pending cctx that we might have missed + // this logic is needed because a confirmation of higher nonce will automatically update the p.NonceLow + // therefore might mask some lower nonce cctx that is still pending. + pendingNonces := pendingNoncesMap[chain.ChainId] + startNonce := pendingNonces.NonceLow - 1 + endNonce := pendingNonces.NonceLow - 1000 + if endNonce < 0 { + endNonce = 0 + } + + // query cctx by nonce backwards to the left boundary of the rate limit sliding window + for nonce := startNonce; nonce >= 0; nonce-- { + cctx, err := getCctxByChainIDAndNonce(k, ctx, tss.TssPubkey, chain.ChainId, nonce) + if err != nil { + return nil, err + } + + // We should at least go backwards by 1000 nonces to pick up missed pending cctxs + // We might go even further back if rate limiter is enabled and the endNonce hasn't hit the left window boundary yet + // There are two criteria to stop scanning backwards: + // criteria #1: we'll stop at the left window boundary if the `endNonce` hasn't hit it yet + // #nosec G701 always positive + if nonce < endNonce && cctx.InboundTxParams.InboundTxObservedExternalHeight < uint64(leftWindowBoundary) { + break + } + // criteria #2: we should finish the RPC call if the rate limit is exceeded + if rateLimitExceeded(chain.ChainId, cctx, gasCoinRates, erc20CoinRates, erc20Coins, &totalCctxValueInZeta, rateLimitInZeta) { + limitExceeded = true + break LoopBackwards + } + + // only take a `limit` number of pending cctxs as result but still count the total pending cctxs + if IsPending(cctx) { + totalPending++ + if !maxCCTXsReached() { + cctxs = append(cctxs, cctx) + } + } + } + + // add the pending nonces to the total pending + // Note: the `totalPending` may not be accurate only if the rate limiter triggers early exit + // `totalPending` is now used for metrics only and it's okay to trade off accuracy for performance + // #nosec G701 always in range + totalPending += uint64(pendingNonces.NonceHigh - pendingNonces.NonceLow) + } + + // query forwards for pending cctxs for each foreign chain +LoopForwards: + for _, chain := range chains { + // query the pending cctxs in range [NonceLow, NonceHigh) + pendingNonces := pendingNoncesMap[chain.ChainId] + for nonce := pendingNonces.NonceLow; nonce < pendingNonces.NonceHigh; nonce++ { + cctx, err := getCctxByChainIDAndNonce(k, ctx, tss.TssPubkey, chain.ChainId, nonce) + if err != nil { + return nil, err + } + + // only take a `limit` number of pending cctxs as result + if maxCCTXsReached() { + break LoopForwards + } + // criteria #2: we should finish the RPC call if the rate limit is exceeded + if rateLimitExceeded(chain.ChainId, cctx, gasCoinRates, erc20CoinRates, erc20Coins, &totalCctxValueInZeta, rateLimitInZeta) { + limitExceeded = true + break LoopForwards + } + cctxs = append(cctxs, cctx) + } + } + + return &types.QueryListPendingCctxWithinRateLimitResponse{ + CrossChainTx: cctxs, + TotalPending: totalPending, + RateLimitExceeded: limitExceeded, + }, nil +} + +// convertCctxValue converts the value of the cctx in ZETA using given conversion rates +func convertCctxValue( + chainID int64, + cctx *types.CrossChainTx, + gasCoinRates map[int64]sdk.Dec, + erc20CoinRates map[int64]map[string]sdk.Dec, + erc20Coins map[int64]map[string]fungibletypes.ForeignCoins, +) sdk.Dec { + var rate sdk.Dec + var decimals uint64 + switch cctx.InboundTxParams.CoinType { + case coin.CoinType_Zeta: + // no conversion needed for ZETA + rate = sdk.NewDec(1) + case coin.CoinType_Gas: + rate = gasCoinRates[chainID] + case coin.CoinType_ERC20: + // get the ERC20 coin decimals + _, found := erc20Coins[chainID] + if !found { + // skip if no coin found for this chainID + return sdk.NewDec(0) + } + fCoin, found := erc20Coins[chainID][strings.ToLower(cctx.InboundTxParams.Asset)] + if !found { + // skip if no coin found for this Asset + return sdk.NewDec(0) + } + // #nosec G701 always in range + decimals = uint64(fCoin.Decimals) + + // get the ERC20 coin rate + _, found = erc20CoinRates[chainID] + if !found { + // skip if no rate found for this chainID + return sdk.NewDec(0) + } + rate = erc20CoinRates[chainID][strings.ToLower(cctx.InboundTxParams.Asset)] + default: + // skip CoinType_Cmd + return sdk.NewDec(0) + } + + // should not happen, return 0 to skip if it happens + if rate.LTE(sdk.NewDec(0)) { + return sdk.NewDec(0) + } + + // the reciprocal of `rate` is the amount of zrc20 needed to buy 1 ZETA + // for example, given rate = 0.8, the reciprocal is 1.25, which means 1.25 ZRC20 can buy 1 ZETA + // given decimals = 6, the `oneZeta` amount will be 1.25 * 10^6 = 1250000 + oneZrc20 := sdk.NewDec(1).Power(decimals) + oneZeta := oneZrc20.Quo(rate) + + // convert asset amount into ZETA + amountCctx := sdk.NewDecFromBigInt(cctx.GetCurrentOutTxParam().Amount.BigInt()) + amountZeta := amountCctx.Quo(oneZeta) + return amountZeta +} + +// rateLimitExceeded accumulates the cctx value and then checks if the rate limit is exceeded +// returns true if the rate limit is exceeded +func rateLimitExceeded( + chainID int64, + cctx *types.CrossChainTx, + gasCoinRates map[int64]sdk.Dec, + erc20CoinRates map[int64]map[string]sdk.Dec, + erc20Coins map[int64]map[string]fungibletypes.ForeignCoins, + currentCctxValue *sdk.Dec, + rateLimitValue sdk.Dec, +) bool { + amountZeta := convertCctxValue(chainID, cctx, gasCoinRates, erc20CoinRates, erc20Coins) + *currentCctxValue = currentCctxValue.Add(amountZeta) + return currentCctxValue.GT(rateLimitValue) +} diff --git a/x/crosschain/keeper/grpc_query_cctx_rate_limit_test.go b/x/crosschain/keeper/grpc_query_cctx_rate_limit_test.go new file mode 100644 index 0000000000..31939862b5 --- /dev/null +++ b/x/crosschain/keeper/grpc_query_cctx_rate_limit_test.go @@ -0,0 +1,182 @@ +package keeper_test + +import ( + "fmt" + "sort" + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/coin" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/keeper" + "github.com/zeta-chain/zetacore/x/crosschain/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +// createTestRateLimiterFlags creates a custom rate limiter flags +func createTestRateLimiterFlags( + zrc20ETH string, + zrc20BTC string, + zrc20USDT string, + ethRate string, + btcRate string, + usdtRate string, +) types.RateLimiterFlags { + var rateLimiterFlags = types.RateLimiterFlags{ + Enabled: true, + Window: 100, // 100 zeta blocks, 10 minutes + Rate: math.NewUint(1000), // 1000 ZETA + Conversions: []types.Conversion{ + // ETH + { + Zrc20: zrc20ETH, + Rate: sdk.MustNewDecFromStr(ethRate), + }, + // BTC + { + Zrc20: zrc20BTC, + Rate: sdk.MustNewDecFromStr(btcRate), + }, + // USDT + { + Zrc20: zrc20USDT, + Rate: sdk.MustNewDecFromStr(usdtRate), + }, + }, + } + return rateLimiterFlags +} + +// createCctxWithCopyTypeAndBlockRange +// - create 1 cctx per block from lowBlock to highBlock (inclusive) +// +// return created cctxs +func createCctxWithCopyTypeAndHeightRange( + t *testing.T, + ctx sdk.Context, + k keeper.Keeper, + zk keepertest.ZetaKeepers, + tss observertypes.TSS, + lowBlock uint64, + highBlock uint64, + chainID int64, + coinType coin.CoinType, + asset string, + amount uint64, + status types.CctxStatus, +) (cctxs []*types.CrossChainTx) { + // create 1 pending cctxs per block + for i := lowBlock; i <= highBlock; i++ { + nonce := i - 1 + cctx := sample.CrossChainTx(t, fmt.Sprintf("%d-%d", chainID, nonce)) + cctx.CctxStatus.Status = status + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = coinType + cctx.InboundTxParams.Asset = asset + cctx.InboundTxParams.InboundTxObservedExternalHeight = i + cctx.GetCurrentOutTxParam().Amount = sdk.NewUint(amount) + cctx.GetCurrentOutTxParam().OutboundTxTssNonce = nonce + k.SetCrossChainTx(ctx, *cctx) + zk.ObserverKeeper.SetNonceToCctx(ctx, observertypes.NonceToCctx{ + ChainId: chainID, + // #nosec G701 always in range for tests + Nonce: int64(nonce), + CctxIndex: cctx.Index, + Tss: tss.TssPubkey, + }) + cctxs = append(cctxs, cctx) + } + return cctxs +} + +// setPendingNonces sets the pending nonces for the given chainID +func setPendingNonces( + ctx sdk.Context, + zk keepertest.ZetaKeepers, + chainID int64, + nonceLow int64, + nonceHigh int64, + tssPubKey string, +) { + zk.ObserverKeeper.SetPendingNonces(ctx, observertypes.PendingNonces{ + ChainId: chainID, + NonceLow: nonceLow, + NonceHigh: nonceHigh, + Tss: tssPubKey, + }) +} + +// setupForeignCoins adds ETH, BTC, USDT to the foreign coins store +func setupForeignCoins( + t *testing.T, + ctx sdk.Context, + zk keepertest.ZetaKeepers, + zrc20ETH, zrc20BTC, zrc20USDT, assetUSDT string, +) { + // set foreign coins + fCoins := sample.ForeignCoinList(t, zrc20ETH, zrc20BTC, zrc20USDT, assetUSDT) + for _, fc := range fCoins { + zk.FungibleKeeper.SetForeignCoins(ctx, fc) + } +} + +func TestKeeper_ListPendingCctxWithinRateLimit(t *testing.T) { + // chain IDs + ethChainID := getValidEthChainID() + + // define cctx status + statusPending := types.CctxStatus_PendingOutbound + statusMined := types.CctxStatus_OutboundMined + + t.Run("should fail for empty req", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + _, err := k.ListPendingCctxWithinRateLimit(ctx, nil) + require.ErrorContains(t, err, "invalid request") + }) + t.Run("should use fallback query", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + + // Set TSS + tss := sample.Tss() + zk.ObserverKeeper.SetTSS(ctx, tss) + + // Set rate limiter flags as disabled + rateLimiterFlags := sample.RateLimiterFlags() + rateLimiterFlags.Enabled = false + k.SetRateLimiterFlags(ctx, rateLimiterFlags) + + // Create cctxs [0~999] and [1000~1199] for Eth chain, 0.001 ETH per cctx + _ = createCctxWithCopyTypeAndHeightRange(t, ctx, *k, zk, tss, 1, 1000, ethChainID, coin.CoinType_Gas, "", uint64(1e15), statusMined) + cctxETH := createCctxWithCopyTypeAndHeightRange(t, ctx, *k, zk, tss, 1001, 1200, ethChainID, coin.CoinType_Gas, "", uint64(1e15), statusPending) + + // Set Eth chain pending nonces which contains 100 missing cctxs + setPendingNonces(ctx, zk, ethChainID, 1100, 1200, tss.TssPubkey) + + // Query pending cctxs use small limit + res, err := k.ListPendingCctxWithinRateLimit(ctx, &types.QueryListPendingCctxWithinRateLimitRequest{Limit: 100}) + require.NoError(t, err) + require.Equal(t, 100, len(res.CrossChainTx)) + + // sort res.CrossChainTx by outbound nonce ascending so that we can compare with cctxETH + sort.Slice(res.CrossChainTx, func(i, j int) bool { + return res.CrossChainTx[i].GetCurrentOutTxParam().OutboundTxTssNonce < res.CrossChainTx[j].GetCurrentOutTxParam().OutboundTxTssNonce + }) + require.EqualValues(t, cctxETH[:100], res.CrossChainTx) + require.EqualValues(t, uint64(200), res.TotalPending) + + // Query pending cctxs use max limit + res, err = k.ListPendingCctxWithinRateLimit(ctx, &types.QueryListPendingCctxWithinRateLimitRequest{Limit: keeper.MaxPendingCctxs}) + require.NoError(t, err) + require.Equal(t, 200, len(res.CrossChainTx)) + + // sort res.CrossChainTx by outbound nonce ascending so that we can compare with cctxETH + sort.Slice(res.CrossChainTx, func(i, j int) bool { + return res.CrossChainTx[i].GetCurrentOutTxParam().OutboundTxTssNonce < res.CrossChainTx[j].GetCurrentOutTxParam().OutboundTxTssNonce + }) + require.EqualValues(t, cctxETH, res.CrossChainTx) + require.EqualValues(t, uint64(200), res.TotalPending) + }) +} diff --git a/x/crosschain/keeper/grpc_query_cctx_test.go b/x/crosschain/keeper/grpc_query_cctx_test.go index 59b0b68863..f530ef305b 100644 --- a/x/crosschain/keeper/grpc_query_cctx_test.go +++ b/x/crosschain/keeper/grpc_query_cctx_test.go @@ -66,19 +66,19 @@ func createCctxWithNonceRange( func TestKeeper_CctxListPending(t *testing.T) { t.Run("should fail for empty req", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) - _, err := k.CctxListPending(ctx, nil) + _, err := k.ListPendingCctx(ctx, nil) require.ErrorContains(t, err, "invalid request") }) - t.Run("should fail if limit is too high", func(t *testing.T) { + t.Run("should use max limit if limit is too high", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) - _, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{Limit: keeper.MaxPendingCctxs + 1}) - require.ErrorContains(t, err, "limit exceeds max limit of") + _, err := k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{Limit: keeper.MaxPendingCctxs + 1}) + require.ErrorContains(t, err, "tss not found") }) t.Run("should fail if no TSS", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) - _, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{Limit: 1}) + _, err := k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{Limit: 1}) require.ErrorContains(t, err, "tss not found") }) @@ -88,24 +88,24 @@ func TestKeeper_CctxListPending(t *testing.T) { // set TSS zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) - _, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{Limit: 1}) + _, err := k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{Limit: 1}) require.ErrorContains(t, err, "pending nonces not found") }) t.Run("can retrieve pending cctx in range", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) cctxs := createCctxWithNonceRange(t, ctx, *k, 1000, 2000, chainID, tss, zk) - res, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID, Limit: 100}) + res, err := k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{ChainId: chainID, Limit: 100}) require.NoError(t, err) require.Equal(t, 100, len(res.CrossChainTx)) require.EqualValues(t, cctxs[0:100], res.CrossChainTx) require.EqualValues(t, uint64(1000), res.TotalPending) - res, err = k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID}) + res, err = k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{ChainId: chainID}) require.NoError(t, err) require.Equal(t, keeper.MaxPendingCctxs, len(res.CrossChainTx)) require.EqualValues(t, cctxs[0:keeper.MaxPendingCctxs], res.CrossChainTx) @@ -114,12 +114,12 @@ func TestKeeper_CctxListPending(t *testing.T) { t.Run("can retrieve pending cctx with range smaller than max", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) cctxs := createCctxWithNonceRange(t, ctx, *k, 1000, 1100, chainID, tss, zk) - res, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID}) + res, err := k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{ChainId: chainID}) require.NoError(t, err) require.Equal(t, 100, len(res.CrossChainTx)) require.EqualValues(t, cctxs, res.CrossChainTx) @@ -128,7 +128,7 @@ func TestKeeper_CctxListPending(t *testing.T) { t.Run("can retrieve pending cctx with pending cctx below nonce low", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) cctxs := createCctxWithNonceRange(t, ctx, *k, 1000, 2000, chainID, tss, zk) @@ -144,7 +144,7 @@ func TestKeeper_CctxListPending(t *testing.T) { cctx2.CctxStatus.Status = types.CctxStatus_PendingOutbound k.SetCrossChainTx(ctx, cctx2) - res, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID, Limit: 100}) + res, err := k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{ChainId: chainID, Limit: 100}) require.NoError(t, err) require.Equal(t, 100, len(res.CrossChainTx)) @@ -157,7 +157,7 @@ func TestKeeper_CctxListPending(t *testing.T) { t.Run("error if some before low nonce are missing", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) cctxs := createCctxWithNonceRange(t, ctx, *k, 1000, 2000, chainID, tss, zk) @@ -173,7 +173,7 @@ func TestKeeper_CctxListPending(t *testing.T) { cctx2.CctxStatus.Status = types.CctxStatus_PendingOutbound k.SetCrossChainTx(ctx, cctx2) - res, err := k.CctxListPending(ctx, &types.QueryListCctxPendingRequest{ChainId: chainID, Limit: 100}) + res, err := k.ListPendingCctx(ctx, &types.QueryListPendingCctxRequest{ChainId: chainID, Limit: 100}) require.NoError(t, err) require.Equal(t, 100, len(res.CrossChainTx)) @@ -226,7 +226,7 @@ func TestKeeper_CctxByNonce(t *testing.T) { t.Run("should error if nonce to cctx not found", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) @@ -239,7 +239,7 @@ func TestKeeper_CctxByNonce(t *testing.T) { t.Run("should error if crosschain tx not found", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) nonce := 1000 @@ -262,7 +262,7 @@ func TestKeeper_CctxByNonce(t *testing.T) { t.Run("should return if crosschain tx found", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) nonce := 1000 diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go index a18d7e737a..9c0547e9fb 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go @@ -36,7 +36,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) txHash := "string" - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: nonAdmin, @@ -63,7 +63,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { observerMock.On("GetSupportedChainFromChainID", mock.Anything, mock.Anything).Return(nil) txHash := "string" - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: sample.AccAddress(), @@ -95,7 +95,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(false) txHash := "string" - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ @@ -128,7 +128,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { observerMock.On("IsNonTombstonedObserver", mock.Anything, mock.Anything).Return(true) txHash := "string" - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: admin, @@ -163,7 +163,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, errors.New("error")) txHash := "string" - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: admin, @@ -197,7 +197,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { observerMock.On("GetChainParamsByChainID", mock.Anything, mock.Anything).Return(nil, false) txHash := "string" - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ Creator: admin, @@ -232,7 +232,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { observerMock.On("GetTssAddress", mock.Anything, mock.Anything).Return(nil, errors.New("error")) txHash := "string" - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ @@ -272,7 +272,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { lightclientMock.On("VerifyProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]byte("invalid"), nil) txHash := "string" - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) _, err := msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ diff --git a/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go b/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go index 9031d0bfe5..4f149a901f 100644 --- a/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go +++ b/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go @@ -41,7 +41,7 @@ func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToO } // tracker submission is only allowed when the cctx is pending - if !IsPending(*cctx.CrossChainTx) { + if !IsPending(cctx.CrossChainTx) { // garbage tracker (for any reason) is harmful to outTx observation and should be removed if it exists // it if does not exist, RemoveOutTxTracker is a no-op k.RemoveOutTxTracker(ctx, msg.ChainId, msg.Nonce) diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go index f13a0065ae..5865c6ccca 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go @@ -89,7 +89,7 @@ func TestKeeper_MigrateTSSFundsForChain(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") indexString, _ := setupTssMigrationParams(zk, k, ctx, *chain, amount, true, true) gp, found := k.GetMedianGasPriceInUint(ctx, chain.ChainId) @@ -149,7 +149,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, false) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ Creator: admin, @@ -172,7 +172,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) observerMock.On("IsInboundEnabled", mock.Anything).Return(true) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ Creator: admin, @@ -197,7 +197,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { observerMock.On("GetTSS", mock.Anything).Return(observertypes.TSS{}, false) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ Creator: admin, @@ -223,7 +223,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { observerMock.On("GetAllTSS", mock.Anything).Return([]observertypes.TSS{}) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ Creator: admin, @@ -250,7 +250,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { observerMock.On("GetAllTSS", mock.Anything).Return([]observertypes.TSS{tss}) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ Creator: admin, @@ -280,7 +280,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { observerMock.On("GetAllTSS", mock.Anything).Return([]observertypes.TSS{tss2}) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ Creator: admin, @@ -311,7 +311,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { observerMock.On("GetPendingNonces", mock.Anything, mock.Anything, mock.Anything).Return(observertypes.PendingNonces{}, false) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ Creator: admin, @@ -331,7 +331,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") indexString, _ := setupTssMigrationParams(zk, k, ctx, *chain, amount, true, true) _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ @@ -359,7 +359,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("100") indexString, _ := setupTssMigrationParams(zk, k, ctx, *chain, amount, true, true) _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ @@ -384,7 +384,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") indexString, _ := setupTssMigrationParams(zk, k, ctx, *chain, amount, false, true) _, err := msgServer.MigrateTssFunds(ctx, &crosschaintypes.MsgMigrateTssFunds{ @@ -409,7 +409,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") indexString, tssPubkey := setupTssMigrationParams(zk, k, ctx, *chain, amount, true, true) k.GetObserverKeeper().SetPendingNonces(ctx, observertypes.PendingNonces{ @@ -441,7 +441,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") indexString, tssPubkey := setupTssMigrationParams(zk, k, ctx, *chain, amount, true, true) k.GetObserverKeeper().SetPendingNonces(ctx, observertypes.PendingNonces{ @@ -482,7 +482,7 @@ func TestMsgServer_MigrateTssFunds(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) msgServer := keeper.NewMsgServerImpl(*k) - chain := getValidEthChain(t) + chain := getValidEthChain() amount := sdkmath.NewUintFromString("10000000000000000000") indexString, _ := setupTssMigrationParams(zk, k, ctx, *chain, amount, false, false) currentTss, found := k.GetObserverKeeper().GetTSS(ctx) diff --git a/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go b/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go index f5615c8963..0b54a93c69 100644 --- a/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go +++ b/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go @@ -42,7 +42,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -81,7 +81,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -120,7 +120,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -160,7 +160,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -192,7 +192,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -224,7 +224,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -263,7 +263,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() asset := sample.EthAddress().String() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -352,7 +352,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -383,7 +383,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -414,7 +414,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -447,7 +447,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -507,7 +507,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) @@ -537,7 +537,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { }) admin := sample.AccAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go index f8d6a4bcb8..379f24741b 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -312,7 +312,7 @@ func TestKeeper_SaveInbound(t *testing.T) { zk.ObserverKeeper.SetTSS(ctx, sample.Tss()) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() cctx := GetERC20Cctx(t, receiver, *senderChain, "", amount) eventIndex := sample.Uint64InRange(1, 100) k.SaveInbound(ctx, cctx, eventIndex) @@ -326,7 +326,7 @@ func TestKeeper_SaveInbound(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() cctx := GetERC20Cctx(t, receiver, *senderChain, "", amount) hash := sample.Hash() cctx.InboundTxParams.InboundTxObservedHash = hash.String() diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go index fa9884f25a..11ea50a514 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx_test.go @@ -129,7 +129,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" observer := sample.AccAddress() tss := sample.Tss() @@ -180,7 +180,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" observer := sample.AccAddress() tss := sample.Tss() @@ -239,7 +239,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" observer := sample.AccAddress() tss := sample.Tss() @@ -302,7 +302,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" observer := sample.AccAddress() tss := sample.Tss() @@ -354,7 +354,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { // Setup mock data receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" r := rand.New(rand.NewSource(42)) validator := sample.Validator(t, r) @@ -401,7 +401,7 @@ func TestKeeper_VoteOnObservedOutboundTx(t *testing.T) { // Setup mock data receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" r := rand.New(rand.NewSource(42)) validator := sample.Validator(t, r) diff --git a/x/crosschain/keeper/msg_server_whitelist_erc20_test.go b/x/crosschain/keeper/msg_server_whitelist_erc20_test.go index 2d193e8f5b..6db8243405 100644 --- a/x/crosschain/keeper/msg_server_whitelist_erc20_test.go +++ b/x/crosschain/keeper/msg_server_whitelist_erc20_test.go @@ -26,7 +26,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { msgServer := crosschainkeeper.NewMsgServerImpl(*k) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() setSupportedChain(ctx, zk, chainID) admin := sample.AccAddress() @@ -104,7 +104,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { _, err := msgServer.WhitelistERC20(ctx, &types.MsgWhitelistERC20{ Creator: admin, Erc20Address: sample.EthAddress().Hex(), - ChainId: getValidEthChainID(t), + ChainId: getValidEthChainID(), Name: "foo", Symbol: "FOO", Decimals: 18, @@ -128,7 +128,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { _, err := msgServer.WhitelistERC20(ctx, &types.MsgWhitelistERC20{ Creator: admin, Erc20Address: "invalid", - ChainId: getValidEthChainID(t), + ChainId: getValidEthChainID(), Name: "foo", Symbol: "FOO", Decimals: 18, @@ -149,7 +149,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() asset := sample.EthAddress().Hex() fc := sample.ForeignCoins(t, sample.EthAddress().Hex()) fc.Asset = asset @@ -176,7 +176,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) { msgServer := crosschainkeeper.NewMsgServerImpl(*k) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() admin := sample.AccAddress() authorityMock := keepertest.GetCrosschainAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) diff --git a/x/crosschain/keeper/process_inbound_test.go b/x/crosschain/keeper/process_inbound_test.go index ec3bcaea94..3e86cd68c5 100644 --- a/x/crosschain/keeper/process_inbound_test.go +++ b/x/crosschain/keeper/process_inbound_test.go @@ -83,7 +83,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() errDeposit := fmt.Errorf("deposit failed") // Setup expected calls @@ -113,7 +113,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" errDeposit := fmt.Errorf("deposit failed") @@ -145,7 +145,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" // Setup expected calls @@ -182,7 +182,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" // Setup expected calls @@ -220,7 +220,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" errDeposit := fmt.Errorf("deposit failed") @@ -260,7 +260,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" errDeposit := fmt.Errorf("deposit failed") @@ -299,7 +299,7 @@ func TestKeeper_ProcessInboundZEVMDeposit(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" errDeposit := fmt.Errorf("deposit failed") @@ -335,7 +335,7 @@ func TestKeeper_ProcessInboundProcessCrosschainMsgPassing(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - receiverChain := getValidEthChain(t) + receiverChain := getValidEthChain() // mock successful PayGasAndUpdateCctx keepertest.MockPayGasAndUpdateCCTX(fungibleMock, observerMock, ctx, *k, *receiverChain, "") @@ -360,7 +360,7 @@ func TestKeeper_ProcessInboundProcessCrosschainMsgPassing(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - receiverChain := getValidEthChain(t) + receiverChain := getValidEthChain() // mock unsuccessful PayGasAndUpdateCctx observerMock.On("GetSupportedChainFromChainID", mock.Anything, receiverChain.ChainId). @@ -384,7 +384,7 @@ func TestKeeper_ProcessInboundProcessCrosschainMsgPassing(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - receiverChain := getValidEthChain(t) + receiverChain := getValidEthChain() // mock successful PayGasAndUpdateCctx keepertest.MockPayGasAndUpdateCCTX(fungibleMock, observerMock, ctx, *k, *receiverChain, "") diff --git a/x/crosschain/keeper/process_outbound_test.go b/x/crosschain/keeper/process_outbound_test.go index 2bd17818c6..b4dbbef200 100644 --- a/x/crosschain/keeper/process_outbound_test.go +++ b/x/crosschain/keeper/process_outbound_test.go @@ -137,7 +137,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" // mock successful GetRevertGasLimit for ERC20 @@ -169,7 +169,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" // mock successful GetRevertGasLimit for ERC20 @@ -201,7 +201,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" // mock successful GetRevertGasLimit for ERC20 @@ -232,7 +232,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" // mock successful GetRevertGasLimit for ERC20 @@ -258,7 +258,7 @@ func TestKeeper_ProcessFailedOutbound(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" // mock failed GetRevertGasLimit for ERC20 @@ -324,7 +324,7 @@ func TestKeeper_ProcessOutbound(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) @@ -353,7 +353,7 @@ func TestKeeper_ProcessOutbound(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) @@ -381,7 +381,7 @@ func TestKeeper_ProcessOutbound(t *testing.T) { observerMock := keepertest.GetCrosschainObserverMock(t, k) receiver := sample.EthAddress() amount := big.NewInt(42) - senderChain := getValidEthChain(t) + senderChain := getValidEthChain() asset := "" cctx := GetERC20Cctx(t, receiver, *senderChain, asset, amount) diff --git a/x/crosschain/keeper/rate_limiter_flags.go b/x/crosschain/keeper/rate_limiter_flags.go index d0d7e2febc..324c636f93 100644 --- a/x/crosschain/keeper/rate_limiter_flags.go +++ b/x/crosschain/keeper/rate_limiter_flags.go @@ -1,8 +1,11 @@ package keeper import ( + "strings" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -25,3 +28,34 @@ func (k Keeper) GetRateLimiterFlags(ctx sdk.Context) (val types.RateLimiterFlags k.cdc.MustUnmarshal(b, &val) return val, true } + +// GetRateLimiterRates returns two maps of foreign coins and their rates +// The 1st map: foreign chain id -> gas coin rate +// The 2nd map: foreign chain id -> erc20 asset -> erc20 coin rate +func (k Keeper) GetRateLimiterRates(ctx sdk.Context) (map[int64]sdk.Dec, map[int64]map[string]sdk.Dec) { + rateLimiterFlags, _ := k.GetRateLimiterFlags(ctx) + + // the result maps + gasCoinRates := make(map[int64]sdk.Dec) + erc20CoinRates := make(map[int64]map[string]sdk.Dec) + + // loop through the rate limiter flags to get the rate + for _, conversion := range rateLimiterFlags.Conversions { + fCoin, found := k.fungibleKeeper.GetForeignCoins(ctx, conversion.Zrc20) + if !found { + continue + } + + chainID := fCoin.ForeignChainId + switch fCoin.CoinType { + case coin.CoinType_Gas: + gasCoinRates[chainID] = conversion.Rate + case coin.CoinType_ERC20: + if _, found := erc20CoinRates[chainID]; !found { + erc20CoinRates[chainID] = make(map[string]sdk.Dec) + } + erc20CoinRates[chainID][strings.ToLower(fCoin.Asset)] = conversion.Rate + } + } + return gasCoinRates, erc20CoinRates +} diff --git a/x/crosschain/keeper/rate_limiter_flags_test.go b/x/crosschain/keeper/rate_limiter_flags_test.go index 044d02bc67..0b8010031d 100644 --- a/x/crosschain/keeper/rate_limiter_flags_test.go +++ b/x/crosschain/keeper/rate_limiter_flags_test.go @@ -1,11 +1,16 @@ package keeper_test import ( + "strings" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/types" ) func TestKeeper_GetRateLimiterFlags(t *testing.T) { @@ -22,3 +27,65 @@ func TestKeeper_GetRateLimiterFlags(t *testing.T) { require.True(t, found) require.Equal(t, flags, r) } + +func TestKeeper_GetRateLimiterRates(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + + // create test flags + zrc20GasAddr := sample.EthAddress().Hex() + zrc20ERC20Addr1 := sample.EthAddress().Hex() + zrc20ERC20Addr2 := sample.EthAddress().Hex() + flags := types.RateLimiterFlags{ + Rate: sdk.NewUint(100), + Conversions: []types.Conversion{ + { + Zrc20: zrc20GasAddr, + Rate: sdk.NewDec(1), + }, + { + Zrc20: zrc20ERC20Addr1, + Rate: sdk.NewDec(2), + }, + { + Zrc20: zrc20ERC20Addr2, + Rate: sdk.NewDec(3), + }, + }, + } + + chainID := chains.GoerliLocalnetChain().ChainId + + // add gas coin + fcGas := sample.ForeignCoins(t, zrc20GasAddr) + fcGas.CoinType = coin.CoinType_Gas + fcGas.ForeignChainId = chainID + zk.FungibleKeeper.SetForeignCoins(ctx, fcGas) + + // add two erc20 coins + asset1 := sample.EthAddress().Hex() + fcERC20 := sample.ForeignCoins(t, zrc20ERC20Addr1) + fcERC20.Asset = asset1 + fcERC20.ForeignChainId = chainID + zk.FungibleKeeper.SetForeignCoins(ctx, fcERC20) + + asset2 := sample.EthAddress().Hex() + fcERC20 = sample.ForeignCoins(t, zrc20ERC20Addr2) + fcERC20.Asset = asset2 + fcERC20.ForeignChainId = chainID + zk.FungibleKeeper.SetForeignCoins(ctx, fcERC20) + + // set flags + k.SetRateLimiterFlags(ctx, flags) + r, found := k.GetRateLimiterFlags(ctx) + require.True(t, found) + require.Equal(t, flags, r) + + // get rates + gasRates, erc20Rates := k.GetRateLimiterRates(ctx) + require.Equal(t, 1, len(gasRates)) + require.Equal(t, 1, len(erc20Rates)) + require.Equal(t, sdk.NewDec(1), gasRates[chainID]) + require.Equal(t, 2, len(erc20Rates[chainID])) + require.Equal(t, sdk.NewDec(2), erc20Rates[chainID][strings.ToLower(asset1)]) + require.Equal(t, sdk.NewDec(3), erc20Rates[chainID][strings.ToLower(asset2)]) +} diff --git a/x/crosschain/keeper/refund_test.go b/x/crosschain/keeper/refund_test.go index 09732bd23a..5f00310be3 100644 --- a/x/crosschain/keeper/refund_test.go +++ b/x/crosschain/keeper/refund_test.go @@ -23,7 +23,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") @@ -54,7 +54,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() fungibleMock.On("GetGasCoinForForeignCoin", mock.Anything, mock.Anything).Return(fungibletypes.ForeignCoins{ Zrc20ContractAddress: "0x", @@ -84,7 +84,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() fungibleMock.On("GetGasCoinForForeignCoin", mock.Anything, mock.Anything).Return(fungibletypes.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().Hex(), @@ -113,7 +113,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") @@ -137,7 +137,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -160,7 +160,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) _ = setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") @@ -188,7 +188,7 @@ func TestKeeper_RefundAmountOnZetaChainZeta(t *testing.T) { k, ctx, sdkk, _ := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -240,7 +240,7 @@ func TestKeeper_RefundAmountOnZetaChainZeta(t *testing.T) { fungibleMock.On("DepositCoinZeta", mock.Anything, mock.Anything, mock.Anything).Return(errors.New("err")) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -263,7 +263,7 @@ func TestKeeper_RefundAmountOnZetaChainZeta(t *testing.T) { k, ctx, sdkk, _ := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -284,7 +284,7 @@ func TestKeeper_RefundAmountOnZetaChainZeta(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -310,7 +310,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) asset := sample.EthAddress().String() sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() // deploy zrc20 deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -376,7 +376,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) asset := sample.EthAddress().String() sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() err := k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ @@ -403,7 +403,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) asset := sample.EthAddress().String() sender := sample.EthAddress() - chainID := getValidEthChainID(t) + chainID := getValidEthChainID() fungibleMock.On("GetForeignCoinFromAsset", mock.Anything, mock.Anything, mock.Anything).Return(fungibletypes.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().Hex(), @@ -462,7 +462,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ CoinType: coin.CoinType_ERC20, - SenderChainId: getValidEthChainID(t), + SenderChainId: getValidEthChainID(), Sender: sample.EthAddress().String(), Amount: math.Uint{}, }}, @@ -473,7 +473,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ CoinType: coin.CoinType_ERC20, - SenderChainId: getValidEthChainID(t), + SenderChainId: getValidEthChainID(), Sender: sample.EthAddress().String(), Amount: math.ZeroUint(), }}, @@ -485,7 +485,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ CoinType: coin.CoinType_ERC20, - SenderChainId: getValidEthChainID(t), + SenderChainId: getValidEthChainID(), Sender: sample.EthAddress().String(), Asset: sample.EthAddress().String(), Amount: math.NewUint(42), diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index 732ec5d0bd..3b3ab6967c 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -22,12 +22,12 @@ import ( ) // getValidEthChainID get a valid eth chain id -func getValidEthChainID(t *testing.T) int64 { - return getValidEthChain(t).ChainId +func getValidEthChainID() int64 { + return getValidEthChain().ChainId } // getValidEthChain get a valid eth chain -func getValidEthChain(_ *testing.T) *chains.Chain { +func getValidEthChain() *chains.Chain { goerli := chains.GoerliLocalnetChain() return &goerli } diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index ed5aacb267..af4f580794 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -90,11 +90,13 @@ type ObserverKeeper interface { ) (bool, bool, observertypes.Ballot, string, error) GetSupportedChainFromChainID(ctx sdk.Context, chainID int64) *chains.Chain GetSupportedChains(ctx sdk.Context) []*chains.Chain + GetSupportedForeignChains(ctx sdk.Context) []*chains.Chain } type FungibleKeeper interface { GetForeignCoins(ctx sdk.Context, zrc20Addr string) (val fungibletypes.ForeignCoins, found bool) GetAllForeignCoins(ctx sdk.Context) (list []fungibletypes.ForeignCoins) + GetAllForeignERC20CoinMap(ctx sdk.Context) map[int64]map[string]fungibletypes.ForeignCoins SetForeignCoins(ctx sdk.Context, foreignCoins fungibletypes.ForeignCoins) GetAllForeignCoinsForChain(ctx sdk.Context, foreignChainID int64) (list []fungibletypes.ForeignCoins) GetForeignCoinFromAsset(ctx sdk.Context, asset string, chainID int64) (fungibletypes.ForeignCoins, bool) diff --git a/x/crosschain/types/query.pb.go b/x/crosschain/types/query.pb.go index 2add2ae2ae..879dcce901 100644 --- a/x/crosschain/types/query.pb.go +++ b/x/crosschain/types/query.pb.go @@ -1483,23 +1483,23 @@ func (m *QueryAllCctxResponse) GetPagination() *query.PageResponse { return nil } -type QueryListCctxPendingRequest struct { +type QueryListPendingCctxRequest struct { ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` Limit uint32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` } -func (m *QueryListCctxPendingRequest) Reset() { *m = QueryListCctxPendingRequest{} } -func (m *QueryListCctxPendingRequest) String() string { return proto.CompactTextString(m) } -func (*QueryListCctxPendingRequest) ProtoMessage() {} -func (*QueryListCctxPendingRequest) Descriptor() ([]byte, []int) { +func (m *QueryListPendingCctxRequest) Reset() { *m = QueryListPendingCctxRequest{} } +func (m *QueryListPendingCctxRequest) String() string { return proto.CompactTextString(m) } +func (*QueryListPendingCctxRequest) ProtoMessage() {} +func (*QueryListPendingCctxRequest) Descriptor() ([]byte, []int) { return fileDescriptor_65a992045e92a606, []int{31} } -func (m *QueryListCctxPendingRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryListPendingCctxRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListCctxPendingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPendingCctxRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListCctxPendingRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPendingCctxRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1509,49 +1509,49 @@ func (m *QueryListCctxPendingRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryListCctxPendingRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListCctxPendingRequest.Merge(m, src) +func (m *QueryListPendingCctxRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPendingCctxRequest.Merge(m, src) } -func (m *QueryListCctxPendingRequest) XXX_Size() int { +func (m *QueryListPendingCctxRequest) XXX_Size() int { return m.Size() } -func (m *QueryListCctxPendingRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListCctxPendingRequest.DiscardUnknown(m) +func (m *QueryListPendingCctxRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPendingCctxRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryListCctxPendingRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryListPendingCctxRequest proto.InternalMessageInfo -func (m *QueryListCctxPendingRequest) GetChainId() int64 { +func (m *QueryListPendingCctxRequest) GetChainId() int64 { if m != nil { return m.ChainId } return 0 } -func (m *QueryListCctxPendingRequest) GetLimit() uint32 { +func (m *QueryListPendingCctxRequest) GetLimit() uint32 { if m != nil { return m.Limit } return 0 } -type QueryListCctxPendingResponse struct { +type QueryListPendingCctxResponse struct { CrossChainTx []*CrossChainTx `protobuf:"bytes,1,rep,name=CrossChainTx,proto3" json:"CrossChainTx,omitempty"` TotalPending uint64 `protobuf:"varint,2,opt,name=totalPending,proto3" json:"totalPending,omitempty"` } -func (m *QueryListCctxPendingResponse) Reset() { *m = QueryListCctxPendingResponse{} } -func (m *QueryListCctxPendingResponse) String() string { return proto.CompactTextString(m) } -func (*QueryListCctxPendingResponse) ProtoMessage() {} -func (*QueryListCctxPendingResponse) Descriptor() ([]byte, []int) { +func (m *QueryListPendingCctxResponse) Reset() { *m = QueryListPendingCctxResponse{} } +func (m *QueryListPendingCctxResponse) String() string { return proto.CompactTextString(m) } +func (*QueryListPendingCctxResponse) ProtoMessage() {} +func (*QueryListPendingCctxResponse) Descriptor() ([]byte, []int) { return fileDescriptor_65a992045e92a606, []int{32} } -func (m *QueryListCctxPendingResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryListPendingCctxResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryListCctxPendingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryListPendingCctxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryListCctxPendingResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryListPendingCctxResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1561,32 +1561,144 @@ func (m *QueryListCctxPendingResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryListCctxPendingResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryListCctxPendingResponse.Merge(m, src) +func (m *QueryListPendingCctxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPendingCctxResponse.Merge(m, src) } -func (m *QueryListCctxPendingResponse) XXX_Size() int { +func (m *QueryListPendingCctxResponse) XXX_Size() int { return m.Size() } -func (m *QueryListCctxPendingResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryListCctxPendingResponse.DiscardUnknown(m) +func (m *QueryListPendingCctxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPendingCctxResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryListCctxPendingResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryListPendingCctxResponse proto.InternalMessageInfo -func (m *QueryListCctxPendingResponse) GetCrossChainTx() []*CrossChainTx { +func (m *QueryListPendingCctxResponse) GetCrossChainTx() []*CrossChainTx { if m != nil { return m.CrossChainTx } return nil } -func (m *QueryListCctxPendingResponse) GetTotalPending() uint64 { +func (m *QueryListPendingCctxResponse) GetTotalPending() uint64 { if m != nil { return m.TotalPending } return 0 } +type QueryListPendingCctxWithinRateLimitRequest struct { + Limit uint32 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` +} + +func (m *QueryListPendingCctxWithinRateLimitRequest) Reset() { + *m = QueryListPendingCctxWithinRateLimitRequest{} +} +func (m *QueryListPendingCctxWithinRateLimitRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryListPendingCctxWithinRateLimitRequest) ProtoMessage() {} +func (*QueryListPendingCctxWithinRateLimitRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_65a992045e92a606, []int{33} +} +func (m *QueryListPendingCctxWithinRateLimitRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListPendingCctxWithinRateLimitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListPendingCctxWithinRateLimitRequest.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 *QueryListPendingCctxWithinRateLimitRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPendingCctxWithinRateLimitRequest.Merge(m, src) +} +func (m *QueryListPendingCctxWithinRateLimitRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryListPendingCctxWithinRateLimitRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPendingCctxWithinRateLimitRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListPendingCctxWithinRateLimitRequest proto.InternalMessageInfo + +func (m *QueryListPendingCctxWithinRateLimitRequest) GetLimit() uint32 { + if m != nil { + return m.Limit + } + return 0 +} + +type QueryListPendingCctxWithinRateLimitResponse struct { + CrossChainTx []*CrossChainTx `protobuf:"bytes,1,rep,name=cross_chain_tx,json=crossChainTx,proto3" json:"cross_chain_tx,omitempty"` + TotalPending uint64 `protobuf:"varint,2,opt,name=total_pending,json=totalPending,proto3" json:"total_pending,omitempty"` + RateLimitExceeded bool `protobuf:"varint,3,opt,name=rate_limit_exceeded,json=rateLimitExceeded,proto3" json:"rate_limit_exceeded,omitempty"` +} + +func (m *QueryListPendingCctxWithinRateLimitResponse) Reset() { + *m = QueryListPendingCctxWithinRateLimitResponse{} +} +func (m *QueryListPendingCctxWithinRateLimitResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryListPendingCctxWithinRateLimitResponse) ProtoMessage() {} +func (*QueryListPendingCctxWithinRateLimitResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_65a992045e92a606, []int{34} +} +func (m *QueryListPendingCctxWithinRateLimitResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryListPendingCctxWithinRateLimitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryListPendingCctxWithinRateLimitResponse.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 *QueryListPendingCctxWithinRateLimitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryListPendingCctxWithinRateLimitResponse.Merge(m, src) +} +func (m *QueryListPendingCctxWithinRateLimitResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryListPendingCctxWithinRateLimitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryListPendingCctxWithinRateLimitResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryListPendingCctxWithinRateLimitResponse proto.InternalMessageInfo + +func (m *QueryListPendingCctxWithinRateLimitResponse) GetCrossChainTx() []*CrossChainTx { + if m != nil { + return m.CrossChainTx + } + return nil +} + +func (m *QueryListPendingCctxWithinRateLimitResponse) GetTotalPending() uint64 { + if m != nil { + return m.TotalPending + } + return 0 +} + +func (m *QueryListPendingCctxWithinRateLimitResponse) GetRateLimitExceeded() bool { + if m != nil { + return m.RateLimitExceeded + } + return false +} + type QueryLastZetaHeightRequest struct { } @@ -1594,7 +1706,7 @@ func (m *QueryLastZetaHeightRequest) Reset() { *m = QueryLastZetaHeightR func (m *QueryLastZetaHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryLastZetaHeightRequest) ProtoMessage() {} func (*QueryLastZetaHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{33} + return fileDescriptor_65a992045e92a606, []int{35} } func (m *QueryLastZetaHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1631,7 +1743,7 @@ func (m *QueryLastZetaHeightResponse) Reset() { *m = QueryLastZetaHeight func (m *QueryLastZetaHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryLastZetaHeightResponse) ProtoMessage() {} func (*QueryLastZetaHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{34} + return fileDescriptor_65a992045e92a606, []int{36} } func (m *QueryLastZetaHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1676,7 +1788,7 @@ func (m *QueryConvertGasToZetaRequest) Reset() { *m = QueryConvertGasToZ func (m *QueryConvertGasToZetaRequest) String() string { return proto.CompactTextString(m) } func (*QueryConvertGasToZetaRequest) ProtoMessage() {} func (*QueryConvertGasToZetaRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{35} + return fileDescriptor_65a992045e92a606, []int{37} } func (m *QueryConvertGasToZetaRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1729,7 +1841,7 @@ func (m *QueryConvertGasToZetaResponse) Reset() { *m = QueryConvertGasTo func (m *QueryConvertGasToZetaResponse) String() string { return proto.CompactTextString(m) } func (*QueryConvertGasToZetaResponse) ProtoMessage() {} func (*QueryConvertGasToZetaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{36} + return fileDescriptor_65a992045e92a606, []int{38} } func (m *QueryConvertGasToZetaResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1786,7 +1898,7 @@ func (m *QueryMessagePassingProtocolFeeRequest) Reset() { *m = QueryMess func (m *QueryMessagePassingProtocolFeeRequest) String() string { return proto.CompactTextString(m) } func (*QueryMessagePassingProtocolFeeRequest) ProtoMessage() {} func (*QueryMessagePassingProtocolFeeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{37} + return fileDescriptor_65a992045e92a606, []int{39} } func (m *QueryMessagePassingProtocolFeeRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1825,7 +1937,7 @@ func (m *QueryMessagePassingProtocolFeeResponse) Reset() { func (m *QueryMessagePassingProtocolFeeResponse) String() string { return proto.CompactTextString(m) } func (*QueryMessagePassingProtocolFeeResponse) ProtoMessage() {} func (*QueryMessagePassingProtocolFeeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{38} + return fileDescriptor_65a992045e92a606, []int{40} } func (m *QueryMessagePassingProtocolFeeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1868,7 +1980,7 @@ func (m *QueryRateLimiterFlagsRequest) Reset() { *m = QueryRateLimiterFl func (m *QueryRateLimiterFlagsRequest) String() string { return proto.CompactTextString(m) } func (*QueryRateLimiterFlagsRequest) ProtoMessage() {} func (*QueryRateLimiterFlagsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{39} + return fileDescriptor_65a992045e92a606, []int{41} } func (m *QueryRateLimiterFlagsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1905,7 +2017,7 @@ func (m *QueryRateLimiterFlagsResponse) Reset() { *m = QueryRateLimiterF func (m *QueryRateLimiterFlagsResponse) String() string { return proto.CompactTextString(m) } func (*QueryRateLimiterFlagsResponse) ProtoMessage() {} func (*QueryRateLimiterFlagsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_65a992045e92a606, []int{40} + return fileDescriptor_65a992045e92a606, []int{42} } func (m *QueryRateLimiterFlagsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1973,8 +2085,10 @@ func init() { proto.RegisterType((*QueryGetCctxResponse)(nil), "zetachain.zetacore.crosschain.QueryGetCctxResponse") proto.RegisterType((*QueryAllCctxRequest)(nil), "zetachain.zetacore.crosschain.QueryAllCctxRequest") proto.RegisterType((*QueryAllCctxResponse)(nil), "zetachain.zetacore.crosschain.QueryAllCctxResponse") - proto.RegisterType((*QueryListCctxPendingRequest)(nil), "zetachain.zetacore.crosschain.QueryListCctxPendingRequest") - proto.RegisterType((*QueryListCctxPendingResponse)(nil), "zetachain.zetacore.crosschain.QueryListCctxPendingResponse") + proto.RegisterType((*QueryListPendingCctxRequest)(nil), "zetachain.zetacore.crosschain.QueryListPendingCctxRequest") + proto.RegisterType((*QueryListPendingCctxResponse)(nil), "zetachain.zetacore.crosschain.QueryListPendingCctxResponse") + proto.RegisterType((*QueryListPendingCctxWithinRateLimitRequest)(nil), "zetachain.zetacore.crosschain.QueryListPendingCctxWithinRateLimitRequest") + proto.RegisterType((*QueryListPendingCctxWithinRateLimitResponse)(nil), "zetachain.zetacore.crosschain.QueryListPendingCctxWithinRateLimitResponse") proto.RegisterType((*QueryLastZetaHeightRequest)(nil), "zetachain.zetacore.crosschain.QueryLastZetaHeightRequest") proto.RegisterType((*QueryLastZetaHeightResponse)(nil), "zetachain.zetacore.crosschain.QueryLastZetaHeightResponse") proto.RegisterType((*QueryConvertGasToZetaRequest)(nil), "zetachain.zetacore.crosschain.QueryConvertGasToZetaRequest") @@ -1988,120 +2102,126 @@ func init() { func init() { proto.RegisterFile("crosschain/query.proto", fileDescriptor_65a992045e92a606) } var fileDescriptor_65a992045e92a606 = []byte{ - // 1796 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x59, 0xcf, 0x6f, 0x14, 0xc7, - 0x12, 0x76, 0x7b, 0x31, 0x98, 0xb6, 0xc1, 0xd0, 0xf8, 0xf1, 0xfc, 0x16, 0x7b, 0x0d, 0xe3, 0x07, - 0xf6, 0x83, 0xe7, 0x1d, 0x30, 0x60, 0x1e, 0x60, 0x9e, 0xb2, 0x36, 0xb1, 0x41, 0x31, 0xe0, 0xac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0xcb, 0x78, 0x24, 0x88, 0xae, 0xde, 0x96, 0xd7, 0xa8, 0x53, 0x59, 0xb6, 0xe7, 0x34, - 0x77, 0x3d, 0x30, 0x53, 0x16, 0xf7, 0x1a, 0x30, 0x01, 0x21, 0xbf, 0x3e, 0x56, 0xb6, 0x70, 0x2e, - 0x4d, 0x18, 0xb8, 0xbf, 0x8b, 0xf7, 0x1b, 0xa1, 0x19, 0x30, 0xf4, 0xa4, 0x04, 0xfd, 0x86, 0x10, - 0x58, 0x20, 0xa2, 0x4a, 0x99, 0x81, 0xed, 0xc3, 0x8b, 0xaf, 0x52, 0x97, 0xca, 0x80, 0x7f, 0x80, - 0x47, 0x53, 0xa5, 0x01, 0xfd, 0xdb, 0x78, 0xdf, 0x9c, 0x87, 0x89, 0x3b, 0xfd, 0xf2, 0xba, 0x23, - 0x19, 0x2f, 0x44, 0x19, 0x80, 0x1e, 0xd6, 0xa3, 0xe8, 0x60, 0x75, 0x70, 0x99, 0xb8, 0xd5, 0x3b, - 0xe5, 0x9c, 0x4f, 0x10, 0xd8, 0x28, 0x61, 0xa7, 0x26, 0x47, 0x94, 0xe9, 0xd0, 0x11, 0x75, 0xce, - 0x4f, 0x55, 0xfc, 0xcf, 0xc0, 0xd5, 0x16, 0xa8, 0xb3, 0xe4, 0xa5, 0x6f, 0xc2, 0xd3, 0x62, 0x58, - 0x65, 0xb6, 0x0e, 0x27, 0xec, 0x0f, 0x94, 0x12, 0x1e, 0x8a, 0x0b, 0x00, 0xe5, 0x39, 0xdc, 0x1b, - 0x7c, 0x03, 0xdb, 0x8e, 0xb7, 0x20, 0x5b, 0x57, 0x51, 0x17, 0x54, 0x28, 0x20, 0x2a, 0x98, 0x66, - 0x14, 0x51, 0xa7, 0x4e, 0xef, 0x53, 0x04, 0x24, 0x42, 0x7b, 0x24, 0x92, 0xc8, 0xb4, 0x45, 0xa2, - 0x73, 0xe7, 0x33, 0xdd, 0x08, 0x05, 0x8b, 0xd4, 0x71, 0x67, 0xbd,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 0x89, 0x4d, 0x0d, - 0x39, 0xe0, 0xc9, 0x1d, 0x8f, 0x96, 0xc0, 0xcd, 0x30, 0x4a, 0xef, 0xd5, 0x8c, 0x56, 0xc8, 0x72, - 0xaf, 0x66, 0x4a, 0x2d, 0x2f, 0xf7, 0x6a, 0xa6, 0xd5, 0xf9, 0x2d, 0x5f, 0xcd, 0x68, 0xd5, 0x3e, - 0xfb, 0xc6, 0xd3, 0xe7, 0x39, 0xf4, 0xec, 0x79, 0x0e, 0xfd, 0xf9, 0x3c, 0x87, 0x3e, 0x78, 0x91, - 0xeb, 0x7a, 0xf6, 0x22, 0xd7, 0xf5, 0xeb, 0x8b, 0x5c, 0xd7, 0xed, 0x33, 0xba, 0xe1, 0x56, 0x6a, - 0x2b, 0x79, 0xcd, 0x5e, 0x15, 0x95, 0x05, 0x98, 0xd4, 0x75, 0x51, 0xaf, 0xbb, 0xb1, 0xc6, 0x9c, - 0x95, 0xdd, 0xfc, 0x19, 0x3b, 0xfb, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x51, 0x5a, 0xb9, - 0x1b, 0x23, 0x00, 0x00, + // 1901 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5a, 0xc1, 0x6f, 0xdc, 0x4a, + 0x19, 0xcf, 0x64, 0x9b, 0xf7, 0xd2, 0x49, 0xda, 0xbc, 0xcc, 0x0b, 0x25, 0xf8, 0x25, 0x9b, 0xd6, + 0xa1, 0x4d, 0x48, 0xc8, 0xfa, 0x25, 0x7d, 0xcd, 0xa3, 0x6d, 0x1e, 0x62, 0x93, 0xbe, 0xa4, 0x81, + 0xb4, 0x4d, 0x57, 0x41, 0x45, 0x45, 0xc8, 0x9a, 0x78, 0xa7, 0x5e, 0xab, 0x8e, 0x9d, 0xae, 0xbd, + 0xd5, 0xa6, 0x51, 0x2e, 0x3d, 0x70, 0x46, 0xea, 0x81, 0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xff, 0xff, 0x25, 0x12, 0xcf, 0x1a, 0x2c, 0x25, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2146,7 +2266,9 @@ type QueryClient interface { // Queries a list of send items. CctxAll(ctx context.Context, in *QueryAllCctxRequest, opts ...grpc.CallOption) (*QueryAllCctxResponse, error) // Queries a list of pending cctxs. - CctxListPending(ctx context.Context, in *QueryListCctxPendingRequest, opts ...grpc.CallOption) (*QueryListCctxPendingResponse, error) + ListPendingCctx(ctx context.Context, in *QueryListPendingCctxRequest, opts ...grpc.CallOption) (*QueryListPendingCctxResponse, error) + // Queries a list of pending cctxs within rate limit. + ListPendingCctxWithinRateLimit(ctx context.Context, in *QueryListPendingCctxWithinRateLimitRequest, opts ...grpc.CallOption) (*QueryListPendingCctxWithinRateLimitResponse, error) ZetaAccounting(ctx context.Context, in *QueryZetaAccountingRequest, opts ...grpc.CallOption) (*QueryZetaAccountingResponse, error) // Queries a list of lastMetaHeight items. LastZetaHeight(ctx context.Context, in *QueryLastZetaHeightRequest, opts ...grpc.CallOption) (*QueryLastZetaHeightResponse, error) @@ -2315,9 +2437,18 @@ func (c *queryClient) CctxAll(ctx context.Context, in *QueryAllCctxRequest, opts return out, nil } -func (c *queryClient) CctxListPending(ctx context.Context, in *QueryListCctxPendingRequest, opts ...grpc.CallOption) (*QueryListCctxPendingResponse, error) { - out := new(QueryListCctxPendingResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Query/CctxListPending", in, out, opts...) +func (c *queryClient) ListPendingCctx(ctx context.Context, in *QueryListPendingCctxRequest, opts ...grpc.CallOption) (*QueryListPendingCctxResponse, error) { + out := new(QueryListPendingCctxResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Query/ListPendingCctx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) ListPendingCctxWithinRateLimit(ctx context.Context, in *QueryListPendingCctxWithinRateLimitRequest, opts ...grpc.CallOption) (*QueryListPendingCctxWithinRateLimitResponse, error) { + out := new(QueryListPendingCctxWithinRateLimitResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Query/ListPendingCctxWithinRateLimit", in, out, opts...) if err != nil { return nil, err } @@ -2383,7 +2514,9 @@ type QueryServer interface { // Queries a list of send items. CctxAll(context.Context, *QueryAllCctxRequest) (*QueryAllCctxResponse, error) // Queries a list of pending cctxs. - CctxListPending(context.Context, *QueryListCctxPendingRequest) (*QueryListCctxPendingResponse, error) + ListPendingCctx(context.Context, *QueryListPendingCctxRequest) (*QueryListPendingCctxResponse, error) + // Queries a list of pending cctxs within rate limit. + ListPendingCctxWithinRateLimit(context.Context, *QueryListPendingCctxWithinRateLimitRequest) (*QueryListPendingCctxWithinRateLimitResponse, error) ZetaAccounting(context.Context, *QueryZetaAccountingRequest) (*QueryZetaAccountingResponse, error) // Queries a list of lastMetaHeight items. LastZetaHeight(context.Context, *QueryLastZetaHeightRequest) (*QueryLastZetaHeightResponse, error) @@ -2446,8 +2579,11 @@ func (*UnimplementedQueryServer) CctxByNonce(ctx context.Context, req *QueryGetC func (*UnimplementedQueryServer) CctxAll(ctx context.Context, req *QueryAllCctxRequest) (*QueryAllCctxResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CctxAll not implemented") } -func (*UnimplementedQueryServer) CctxListPending(ctx context.Context, req *QueryListCctxPendingRequest) (*QueryListCctxPendingResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CctxListPending not implemented") +func (*UnimplementedQueryServer) ListPendingCctx(ctx context.Context, req *QueryListPendingCctxRequest) (*QueryListPendingCctxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPendingCctx not implemented") +} +func (*UnimplementedQueryServer) ListPendingCctxWithinRateLimit(ctx context.Context, req *QueryListPendingCctxWithinRateLimitRequest) (*QueryListPendingCctxWithinRateLimitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPendingCctxWithinRateLimit not implemented") } func (*UnimplementedQueryServer) ZetaAccounting(ctx context.Context, req *QueryZetaAccountingRequest) (*QueryZetaAccountingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ZetaAccounting not implemented") @@ -2769,20 +2905,38 @@ func _Query_CctxAll_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } -func _Query_CctxListPending_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryListCctxPendingRequest) +func _Query_ListPendingCctx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListPendingCctxRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).CctxListPending(ctx, in) + return srv.(QueryServer).ListPendingCctx(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.crosschain.Query/CctxListPending", + FullMethod: "/zetachain.zetacore.crosschain.Query/ListPendingCctx", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).CctxListPending(ctx, req.(*QueryListCctxPendingRequest)) + return srv.(QueryServer).ListPendingCctx(ctx, req.(*QueryListPendingCctxRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_ListPendingCctxWithinRateLimit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryListPendingCctxWithinRateLimitRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ListPendingCctxWithinRateLimit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.crosschain.Query/ListPendingCctxWithinRateLimit", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ListPendingCctxWithinRateLimit(ctx, req.(*QueryListPendingCctxWithinRateLimitRequest)) } return interceptor(ctx, in, info, handler) } @@ -2914,8 +3068,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_CctxAll_Handler, }, { - MethodName: "CctxListPending", - Handler: _Query_CctxListPending_Handler, + MethodName: "ListPendingCctx", + Handler: _Query_ListPendingCctx_Handler, + }, + { + MethodName: "ListPendingCctxWithinRateLimit", + Handler: _Query_ListPendingCctxWithinRateLimit_Handler, }, { MethodName: "ZetaAccounting", @@ -4093,7 +4251,7 @@ func (m *QueryAllCctxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryListCctxPendingRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryListPendingCctxRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4103,12 +4261,12 @@ func (m *QueryListCctxPendingRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryListCctxPendingRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryListPendingCctxRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListCctxPendingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryListPendingCctxRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -4126,7 +4284,77 @@ func (m *QueryListCctxPendingRequest) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryListCctxPendingResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryListPendingCctxResponse) 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 *QueryListPendingCctxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListPendingCctxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TotalPending != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.TotalPending)) + i-- + dAtA[i] = 0x10 + } + if len(m.CrossChainTx) > 0 { + for iNdEx := len(m.CrossChainTx) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CrossChainTx[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryListPendingCctxWithinRateLimitRequest) 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 *QueryListPendingCctxWithinRateLimitRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryListPendingCctxWithinRateLimitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Limit != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Limit)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryListPendingCctxWithinRateLimitResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4136,16 +4364,26 @@ func (m *QueryListCctxPendingResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryListCctxPendingResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryListPendingCctxWithinRateLimitResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryListCctxPendingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryListPendingCctxWithinRateLimitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.RateLimitExceeded { + i-- + if m.RateLimitExceeded { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } if m.TotalPending != 0 { i = encodeVarintQuery(dAtA, i, uint64(m.TotalPending)) i-- @@ -4871,7 +5109,7 @@ func (m *QueryAllCctxResponse) Size() (n int) { return n } -func (m *QueryListCctxPendingRequest) Size() (n int) { +func (m *QueryListPendingCctxRequest) Size() (n int) { if m == nil { return 0 } @@ -4886,7 +5124,37 @@ func (m *QueryListCctxPendingRequest) Size() (n int) { return n } -func (m *QueryListCctxPendingResponse) Size() (n int) { +func (m *QueryListPendingCctxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CrossChainTx) > 0 { + for _, e := range m.CrossChainTx { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.TotalPending != 0 { + n += 1 + sovQuery(uint64(m.TotalPending)) + } + return n +} + +func (m *QueryListPendingCctxWithinRateLimitRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Limit != 0 { + n += 1 + sovQuery(uint64(m.Limit)) + } + return n +} + +func (m *QueryListPendingCctxWithinRateLimitResponse) Size() (n int) { if m == nil { return 0 } @@ -4901,6 +5169,9 @@ func (m *QueryListCctxPendingResponse) Size() (n int) { if m.TotalPending != 0 { n += 1 + sovQuery(uint64(m.TotalPending)) } + if m.RateLimitExceeded { + n += 2 + } return n } @@ -7921,7 +8192,7 @@ func (m *QueryAllCctxResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListCctxPendingRequest) Unmarshal(dAtA []byte) error { +func (m *QueryListPendingCctxRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7944,10 +8215,10 @@ func (m *QueryListCctxPendingRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListCctxPendingRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListPendingCctxRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListCctxPendingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListPendingCctxRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8009,7 +8280,7 @@ func (m *QueryListCctxPendingRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryListCctxPendingResponse) Unmarshal(dAtA []byte) error { +func (m *QueryListPendingCctxResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8032,10 +8303,10 @@ func (m *QueryListCctxPendingResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryListCctxPendingResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryListPendingCctxResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryListCctxPendingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryListPendingCctxResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8112,6 +8383,198 @@ func (m *QueryListCctxPendingResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryListPendingCctxWithinRateLimitRequest) 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 ErrIntOverflowQuery + } + 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: QueryListPendingCctxWithinRateLimitRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListPendingCctxWithinRateLimitRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryListPendingCctxWithinRateLimitResponse) 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 ErrIntOverflowQuery + } + 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: QueryListPendingCctxWithinRateLimitResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryListPendingCctxWithinRateLimitResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CrossChainTx", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CrossChainTx = append(m.CrossChainTx, &CrossChainTx{}) + if err := m.CrossChainTx[len(m.CrossChainTx)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalPending", wireType) + } + m.TotalPending = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TotalPending |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RateLimitExceeded", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.RateLimitExceeded = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryLastZetaHeightRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/crosschain/types/query.pb.gw.go b/x/crosschain/types/query.pb.gw.go index e25a590184..6a4aa48cdd 100644 --- a/x/crosschain/types/query.pb.gw.go +++ b/x/crosschain/types/query.pb.gw.go @@ -870,37 +870,73 @@ func local_request_Query_CctxAll_0(ctx context.Context, marshaler runtime.Marsha } var ( - filter_Query_CctxListPending_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_ListPendingCctx_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_CctxListPending_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryListCctxPendingRequest +func request_Query_ListPendingCctx_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListPendingCctxRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CctxListPending_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListPendingCctx_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.CctxListPending(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.ListPendingCctx(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_CctxListPending_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryListCctxPendingRequest +func local_request_Query_ListPendingCctx_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListPendingCctxRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_CctxListPending_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListPendingCctx_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.CctxListPending(ctx, &protoReq) + msg, err := server.ListPendingCctx(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_ListPendingCctxWithinRateLimit_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_ListPendingCctxWithinRateLimit_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListPendingCctxWithinRateLimitRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListPendingCctxWithinRateLimit_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListPendingCctxWithinRateLimit(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ListPendingCctxWithinRateLimit_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryListPendingCctxWithinRateLimitRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ListPendingCctxWithinRateLimit_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListPendingCctxWithinRateLimit(ctx, &protoReq) return msg, metadata, err } @@ -1356,7 +1392,30 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_CctxListPending_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_ListPendingCctx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ListPendingCctx_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListPendingCctx_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListPendingCctxWithinRateLimit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -1367,7 +1426,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_CctxListPending_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_ListPendingCctxWithinRateLimit_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -1375,7 +1434,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_CctxListPending_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_ListPendingCctxWithinRateLimit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1829,7 +1888,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_CctxListPending_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_ListPendingCctx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -1838,14 +1897,34 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_CctxListPending_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_ListPendingCctx_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_CctxListPending_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_ListPendingCctx_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_ListPendingCctxWithinRateLimit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ListPendingCctxWithinRateLimit_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ListPendingCctxWithinRateLimit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1947,7 +2026,9 @@ var ( pattern_Query_CctxAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "cctx"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_CctxListPending_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "cctxPending"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_ListPendingCctx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "pendingCctx"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_ListPendingCctxWithinRateLimit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "pendingCctxWithinRateLimit"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_ZetaAccounting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"zeta-chain", "crosschain", "zetaAccounting"}, "", runtime.AssumeColonVerbOpt(false))) @@ -1991,7 +2072,9 @@ var ( forward_Query_CctxAll_0 = runtime.ForwardResponseMessage - forward_Query_CctxListPending_0 = runtime.ForwardResponseMessage + forward_Query_ListPendingCctx_0 = runtime.ForwardResponseMessage + + forward_Query_ListPendingCctxWithinRateLimit_0 = runtime.ForwardResponseMessage forward_Query_ZetaAccounting_0 = runtime.ForwardResponseMessage diff --git a/x/fungible/keeper/foreign_coins.go b/x/fungible/keeper/foreign_coins.go index ee424e92c1..5f0a31da4a 100644 --- a/x/fungible/keeper/foreign_coins.go +++ b/x/fungible/keeper/foreign_coins.go @@ -1,6 +1,8 @@ package keeper import ( + "strings" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" @@ -79,6 +81,22 @@ func (k Keeper) GetAllForeignCoins(ctx sdk.Context) (list []types.ForeignCoins) return } +// GetAllForeignERC20CoinMap returns all foreign ERC20 coins in a map of chainID -> asset -> coin +func (k Keeper) GetAllForeignERC20CoinMap(ctx sdk.Context) map[int64]map[string]types.ForeignCoins { + allForeignCoins := k.GetAllForeignCoins(ctx) + + erc20CoinMap := make(map[int64]map[string]types.ForeignCoins) + for _, c := range allForeignCoins { + if c.CoinType == coin.CoinType_ERC20 { + if _, found := erc20CoinMap[c.ForeignChainId]; !found { + erc20CoinMap[c.ForeignChainId] = make(map[string]types.ForeignCoins) + } + erc20CoinMap[c.ForeignChainId][strings.ToLower(c.Asset)] = c + } + } + return erc20CoinMap +} + // GetGasCoinForForeignCoin returns the gas coin for a given chain func (k Keeper) GetGasCoinForForeignCoin(ctx sdk.Context, chainID int64) (types.ForeignCoins, bool) { foreignCoinList := k.GetAllForeignCoinsForChain(ctx, chainID) diff --git a/x/observer/keeper/chain_params.go b/x/observer/keeper/chain_params.go index 7b5e0a246e..8c4d7301fb 100644 --- a/x/observer/keeper/chain_params.go +++ b/x/observer/keeper/chain_params.go @@ -71,3 +71,16 @@ func (k Keeper) GetSupportedChains(ctx sdk.Context) []*chains.Chain { } return c } + +// GetSupportedForeignChains returns the list of supported foreign chains +func (k Keeper) GetSupportedForeignChains(ctx sdk.Context) []*chains.Chain { + allChains := k.GetSupportedChains(ctx) + + foreignChains := make([]*chains.Chain, 0) + for _, chain := range allChains { + if !chain.IsZetaChain() { + foreignChains = append(foreignChains, chain) + } + } + return foreignChains +} diff --git a/zetaclient/evm/evm_signer.go b/zetaclient/evm/evm_signer.go index c0de8ea40b..d9b6eb25dd 100644 --- a/zetaclient/evm/evm_signer.go +++ b/zetaclient/evm/evm_signer.go @@ -567,7 +567,7 @@ func (signer *Signer) reportToOutTxTracker(zetaBridge interfaces.ZetaCoreBridger cctx, err := zetaBridge.GetCctxByNonce(chainID, nonce) if err != nil { logger.Err(err).Msgf("reportToOutTxTracker: error getting cctx for chain %d nonce %d outTxHash %s", chainID, nonce, outTxHash) - } else if !crosschainkeeper.IsPending(*cctx) { + } else if !crosschainkeeper.IsPending(cctx) { logger.Info().Msgf("reportToOutTxTracker: cctx already finalized for chain %d nonce %d outTxHash %s", chainID, nonce, outTxHash) break } diff --git a/zetaclient/interfaces/interfaces.go b/zetaclient/interfaces/interfaces.go index 387e764688..0fbaba26b3 100644 --- a/zetaclient/interfaces/interfaces.go +++ b/zetaclient/interfaces/interfaces.go @@ -98,6 +98,7 @@ type ZetaCoreBridger interface { GetZetaBlockHeight() (int64, error) GetLastBlockHeightByChain(chain chains.Chain) (*crosschaintypes.LastBlockHeight, error) ListPendingCctx(chainID int64) ([]*crosschaintypes.CrossChainTx, uint64, error) + ListPendingCctxWithinRatelimit() ([]*crosschaintypes.CrossChainTx, uint64, bool, error) GetPendingNoncesByChain(chainID int64) (observertypes.PendingNonces, error) GetCctxByNonce(chainID int64, nonce uint64) (*crosschaintypes.CrossChainTx, error) GetOutTxTracker(chain chains.Chain, nonce uint64) (*crosschaintypes.OutTxTracker, error) diff --git a/zetaclient/testutils/stub/core_bridge.go b/zetaclient/testutils/stub/core_bridge.go index 2f0ddaa732..e66c309cc6 100644 --- a/zetaclient/testutils/stub/core_bridge.go +++ b/zetaclient/testutils/stub/core_bridge.go @@ -121,6 +121,13 @@ func (z *MockZetaCoreBridge) ListPendingCctx(_ int64) ([]*cctxtypes.CrossChainTx return []*cctxtypes.CrossChainTx{}, 0, nil } +func (z *MockZetaCoreBridge) ListPendingCctxWithinRatelimit() ([]*cctxtypes.CrossChainTx, uint64, bool, error) { + if z.paused { + return nil, 0, false, errors.New(ErrMsgPaused) + } + return []*cctxtypes.CrossChainTx{}, 0, false, nil +} + func (z *MockZetaCoreBridge) GetPendingNoncesByChain(_ int64) (observerTypes.PendingNonces, error) { if z.paused { return observerTypes.PendingNonces{}, errors.New(ErrMsgPaused) diff --git a/zetaclient/zetabridge/query.go b/zetaclient/zetabridge/query.go index b9e08bef56..09d3b20e82 100644 --- a/zetaclient/zetabridge/query.go +++ b/zetaclient/zetabridge/query.go @@ -121,18 +121,38 @@ func (b *ZetaCoreBridge) GetObserverList() ([]string, error) { } // ListPendingCctx returns a list of pending cctxs for a given chainID -// the returned list has a limited size of crosschainkeeper.MaxPendingCctxs -// the total number of pending cctxs is returned +// - The max size of the list is crosschainkeeper.MaxPendingCctxs func (b *ZetaCoreBridge) ListPendingCctx(chainID int64) ([]*types.CrossChainTx, uint64, error) { client := types.NewQueryClient(b.grpcConn) maxSizeOption := grpc.MaxCallRecvMsgSize(32 * 1024 * 1024) - resp, err := client.CctxListPending(context.Background(), &types.QueryListCctxPendingRequest{ChainId: chainID}, maxSizeOption) + resp, err := client.ListPendingCctx( + context.Background(), + &types.QueryListPendingCctxRequest{ChainId: chainID}, + maxSizeOption, + ) if err != nil { return nil, 0, err } return resp.CrossChainTx, resp.TotalPending, nil } +// ListPendingCctxWithinRatelimit returns a list of pending cctxs that do not exceed the outbound rate limit +// - The max size of the list is crosschainkeeper.MaxPendingCctxs +// - The returned `rateLimitExceeded` flag indicates if the rate limit is exceeded or not +func (b *ZetaCoreBridge) ListPendingCctxWithinRatelimit() ([]*types.CrossChainTx, uint64, bool, error) { + client := types.NewQueryClient(b.grpcConn) + maxSizeOption := grpc.MaxCallRecvMsgSize(32 * 1024 * 1024) + resp, err := client.ListPendingCctxWithinRateLimit( + context.Background(), + &types.QueryListPendingCctxWithinRateLimitRequest{}, + maxSizeOption, + ) + if err != nil { + return nil, 0, false, err + } + return resp.CrossChainTx, resp.TotalPending, resp.RateLimitExceeded, nil +} + func (b *ZetaCoreBridge) GetAbortedZetaAmount() (string, error) { client := types.NewQueryClient(b.grpcConn) resp, err := client.ZetaAccounting(context.Background(), &types.QueryZetaAccountingRequest{}) diff --git a/zetaclient/zetabridge/query_test.go b/zetaclient/zetabridge/query_test.go index 3844482dd3..ea76fa78fd 100644 --- a/zetaclient/zetabridge/query_test.go +++ b/zetaclient/zetabridge/query_test.go @@ -267,7 +267,7 @@ func TestZetaCoreBridge_GetObserverList(t *testing.T) { } func TestZetaCoreBridge_ListPendingCctx(t *testing.T) { - expectedOutput := crosschainTypes.QueryListCctxPendingResponse{ + expectedOutput := crosschainTypes.QueryListPendingCctxResponse{ CrossChainTx: []*crosschainTypes.CrossChainTx{ { Index: "cross-chain4456", @@ -275,8 +275,8 @@ func TestZetaCoreBridge_ListPendingCctx(t *testing.T) { }, TotalPending: 1, } - input := crosschainTypes.QueryListCctxPendingRequest{ChainId: 7000} - method := "/zetachain.zetacore.crosschain.Query/CctxListPending" + input := crosschainTypes.QueryListPendingCctxRequest{ChainId: 7000} + method := "/zetachain.zetacore.crosschain.Query/ListPendingCctx" server := setupMockServer(t, crosschainTypes.RegisterQueryServer, method, input, expectedOutput) server.Serve() defer closeMockServer(t, server) diff --git a/zetaclient/zetacore_observer.go b/zetaclient/zetacore_observer.go index 48771bc9bc..c66f15f50a 100644 --- a/zetaclient/zetacore_observer.go +++ b/zetaclient/zetacore_observer.go @@ -130,16 +130,29 @@ func (co *CoreObserver) startCctxScheduler(appContext *appcontext.AppContext) { } } - // Set Current Hot key burn rate + // set current hot key burn rate metrics.HotKeyBurnRate.Set(float64(co.ts.HotKeyBurnRate.GetBurnRate().Int64())) + // query pending cctxs across all foreign chains with rate limit + cctxMap, err := co.getAllPendingCctxWithRatelimit() + if err != nil { + co.logger.ZetaChainWatcher.Error().Err(err).Msgf("startCctxScheduler: queryPendingCctxWithRatelimit failed") + } + // schedule keysign for pending cctxs on each chain coreContext := appContext.ZetaCoreContext() supportedChains := coreContext.GetEnabledChains() for _, c := range supportedChains { - if c.ChainId == co.bridge.ZetaChain().ChainId { + if c.IsZetaChain() { + continue + } + // get cctxs from map and set pending transactions prometheus gauge + cctxList := cctxMap[c.ChainId] + metrics.PendingTxsPerChain.WithLabelValues(c.ChainName.String()).Set(float64(len(cctxList))) + if len(cctxList) == 0 { continue } + // update chain parameters for signer and chain client signer, err := co.GetUpdatedSigner(coreContext, c.ChainId) if err != nil { @@ -155,14 +168,6 @@ func (co *CoreObserver) startCctxScheduler(appContext *appcontext.AppContext) { continue } - cctxList, totalPending, err := co.bridge.ListPendingCctx(c.ChainId) - if err != nil { - co.logger.ZetaChainWatcher.Error().Err(err).Msgf("startCctxScheduler: ListPendingCctx failed for chain %d", c.ChainId) - continue - } - // Set Pending transactions prometheus gauge - metrics.PendingTxsPerChain.WithLabelValues(c.ChainName.String()).Set(float64(totalPending)) - // #nosec G701 range is verified zetaHeight := uint64(bn) if chains.IsEVMChain(c.ChainId) { @@ -184,6 +189,29 @@ func (co *CoreObserver) startCctxScheduler(appContext *appcontext.AppContext) { } } +// getAllPendingCctxWithRatelimit get pending cctxs across all foreign chains with rate limit +func (co *CoreObserver) getAllPendingCctxWithRatelimit() (map[int64][]*types.CrossChainTx, error) { + cctxList, totalPending, rateLimitExceeded, err := co.bridge.ListPendingCctxWithinRatelimit() + if err != nil { + return nil, err + } + if rateLimitExceeded { + co.logger.ZetaChainWatcher.Warn().Msgf("rate limit exceeded, fetched %d cctxs out of %d", len(cctxList), totalPending) + } + + // classify pending cctxs by chain id + cctxMap := make(map[int64][]*types.CrossChainTx) + for _, cctx := range cctxList { + chainID := cctx.GetCurrentOutTxParam().ReceiverChainId + if _, found := cctxMap[chainID]; !found { + cctxMap[chainID] = make([]*types.CrossChainTx, 0) + } + cctxMap[chainID] = append(cctxMap[chainID], cctx) + } + + return cctxMap, nil +} + // scheduleCctxEVM schedules evm outtx keysign on each ZetaChain block (the ticker) func (co *CoreObserver) scheduleCctxEVM( outTxMan *outtxprocessor.Processor, From a124ffbd6b043a436a417fe7b30779681f64802b Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 22 Apr 2024 01:49:51 -0400 Subject: [PATCH 10/11] refactor: fix lint issues (#2059) * add script to modify genesis * fix unit tests * copy only nonce to cctx and ballot list while importing genesis state * skip copying group data * generate files * use constant for max items * generate files 2 * undate sample genesis * remove unused params * fix all lint issues * add changelog --- app/setup_handlers.go | 2 +- changelog.md | 1 + cmd/zetaclientd/debug.go | 2 +- cmd/zetacored/addr_converter.go | 2 +- cmd/zetacored/collect_observer_info.go | 2 +- docs/openapi/openapi.go | 2 +- rpc/websockets.go | 2 +- x/authority/client/cli/query_policies.go | 2 +- x/crosschain/client/cli/cli_cctx.go | 2 +- x/crosschain/client/cli/cli_gas_price.go | 2 +- x/crosschain/client/cli/cli_in_tx_tracker.go | 2 +- x/crosschain/client/cli/cli_last_block_height.go | 2 +- x/crosschain/client/cli/cli_out_tx_tracker.go | 2 +- x/crosschain/client/cli/cli_zeta_height.go | 2 +- x/crosschain/client/cli/query_in_tx_hash_to_cctx.go | 2 +- x/crosschain/client/cli/query_rate_limiter_flags.go | 2 +- x/crosschain/client/cli/query_zeta_accounting.go | 2 +- x/crosschain/keeper/grpc_query_cctx.go | 2 +- x/crosschain/keeper/grpc_query_gas_price.go | 2 +- x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go | 2 +- x/crosschain/keeper/grpc_query_last_block_height.go | 2 +- x/crosschain/keeper/grpc_query_out_tx_tracker.go | 4 ++-- x/crosschain/keeper/in_tx_tracker.go | 4 ++-- x/emissions/client/cli/query_get_emmisons_factors.go | 2 +- x/emissions/client/cli/query_list_balances.go | 2 +- x/emissions/client/cli/query_params.go | 2 +- x/fungible/client/cli/query_foreign_coins.go | 2 +- x/fungible/client/cli/query_gas_stability_pool.go | 4 ++-- x/fungible/client/cli/query_system_contract.go | 2 +- x/fungible/client/cli/tx_deploy_system_contracts.go | 2 +- x/fungible/keeper/grpc_query_foreign_coins.go | 2 +- x/lightclient/client/cli/query_block_header.go | 2 +- x/lightclient/client/cli/query_chain_state.go | 2 +- x/lightclient/client/cli/query_verification_flags.go | 2 +- x/lightclient/keeper/grpc_query_block_header.go | 2 +- x/lightclient/keeper/grpc_query_chain_state.go | 2 +- x/observer/client/cli/query_blame.go | 2 +- x/observer/client/cli/query_chain_nonce.go | 2 +- x/observer/client/cli/query_chain_params.go | 2 +- x/observer/client/cli/query_keygen.go | 2 +- x/observer/client/cli/query_node_account.go | 2 +- x/observer/client/cli/query_observers.go | 2 +- x/observer/client/cli/query_params.go | 2 +- x/observer/client/cli/query_pending_nonces.go | 2 +- x/observer/client/cli/query_permission_flags.go | 2 +- x/observer/client/cli/query_show_observer_count.go | 2 +- x/observer/client/cli/query_supported_chains.go | 2 +- x/observer/client/cli/query_tss.go | 4 ++-- x/observer/client/cli/tx_add_blame_vote.go | 2 +- x/observer/keeper/blame.go | 2 +- x/observer/keeper/grpc_query_node_account.go | 2 +- x/observer/keeper/grpc_query_nonces.go | 2 +- x/observer/keeper/pending_nonces.go | 2 +- x/observer/keeper/tss.go | 2 +- 54 files changed, 58 insertions(+), 57 deletions(-) diff --git a/app/setup_handlers.go b/app/setup_handlers.go index 5501a5b6cc..19fcc96860 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -13,7 +13,7 @@ import ( const releaseVersion = "v15" func SetupHandlers(app *App) { - app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) { + app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) { app.Logger().Info("Running upgrade handler for " + releaseVersion) // Updated version map to the latest consensus versions from each module for m, mb := range app.mm.Modules { diff --git a/changelog.md b/changelog.md index ede402b460..61b85985bf 100644 --- a/changelog.md +++ b/changelog.md @@ -43,6 +43,7 @@ * [2001](https://github.com/zeta-chain/node/pull/2001) - replace broadcast mode block with sync and remove fungible params * [1989](https://github.com/zeta-chain/node/pull/1989) - simplify `IsSendOutTxProcessed` method and add unit tests * [2013](https://github.com/zeta-chain/node/pull/2013) - rename `GasPriceVoter` message to `VoteGasPrice` +* [2059](https://github.com/zeta-chain/node/pull/2059) - Remove unused params from all functions in zetanode ### Features diff --git a/cmd/zetaclientd/debug.go b/cmd/zetaclientd/debug.go index b784488ee0..d3d04d1387 100644 --- a/cmd/zetaclientd/debug.go +++ b/cmd/zetaclientd/debug.go @@ -47,7 +47,7 @@ func DebugCmd() *cobra.Command { cmd := &cobra.Command{ Use: "get-ballot-from-intx [txHash] [chainID]", Short: "provide txHash and chainID to get the ballot status for the txHash", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { cobra.ExactArgs(2) cfg, err := config.Load(debugArgs.zetaCoreHome) if err != nil { diff --git a/cmd/zetacored/addr_converter.go b/cmd/zetacored/addr_converter.go index 63d66e6f86..557b4cc9c2 100644 --- a/cmd/zetacored/addr_converter.go +++ b/cmd/zetacored/addr_converter.go @@ -18,7 +18,7 @@ it always outputs three lines; the first line is the zeta1xxx address, the secon and the third line is the ethereum address. `, Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { addr, err := sdk.AccAddressFromBech32(args[0]) if err == nil { valAddr := sdk.ValAddress(addr.Bytes()) diff --git a/cmd/zetacored/collect_observer_info.go b/cmd/zetacored/collect_observer_info.go index f9c351636c..420b82eb6e 100644 --- a/cmd/zetacored/collect_observer_info.go +++ b/cmd/zetacored/collect_observer_info.go @@ -14,7 +14,7 @@ func CollectObserverInfoCmd() *cobra.Command { Use: "collect-observer-info [folder]", Short: "collect observer info from a folder , default path is ~/.zetacored/os_info/ \n", Args: cobra.MaximumNArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { defaultHome := app.DefaultNodeHome defaultFile := filepath.Join(defaultHome, "os_info") if len(args) == 0 { diff --git a/docs/openapi/openapi.go b/docs/openapi/openapi.go index 11f4e40b72..187dbbe7ce 100644 --- a/docs/openapi/openapi.go +++ b/docs/openapi/openapi.go @@ -30,7 +30,7 @@ func openAPIHandler() http.HandlerFunc { panic(err) } - return func(w http.ResponseWriter, req *http.Request) { + return func(w http.ResponseWriter, _ *http.Request) { err := tmpl.Execute(w, struct { URL string }{ diff --git a/rpc/websockets.go b/rpc/websockets.go index 3c64bfdb8a..0eec84127e 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -148,7 +148,7 @@ func (s *websocketsServer) Start() { func (s *websocketsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { upgrader := websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { + CheckOrigin: func(_ *http.Request) bool { return true }, } diff --git a/x/authority/client/cli/query_policies.go b/x/authority/client/cli/query_policies.go index 66ad4e5644..723dfcf71b 100644 --- a/x/authority/client/cli/query_policies.go +++ b/x/authority/client/cli/query_policies.go @@ -15,7 +15,7 @@ func CmdShowPolicies() *cobra.Command { Use: "show-policies", Short: "show the policies", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/crosschain/client/cli/cli_cctx.go b/x/crosschain/client/cli/cli_cctx.go index b5add8610b..3990387941 100644 --- a/x/crosschain/client/cli/cli_cctx.go +++ b/x/crosschain/client/cli/cli_cctx.go @@ -21,7 +21,7 @@ func CmdListSend() *cobra.Command { cmd := &cobra.Command{ Use: "list-cctx", Short: "list all CCTX", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/cli_gas_price.go b/x/crosschain/client/cli/cli_gas_price.go index 1ad48ee8c0..9de219aefb 100644 --- a/x/crosschain/client/cli/cli_gas_price.go +++ b/x/crosschain/client/cli/cli_gas_price.go @@ -15,7 +15,7 @@ func CmdListGasPrice() *cobra.Command { cmd := &cobra.Command{ Use: "list-gas-price", Short: "list all gasPrice", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/cli_in_tx_tracker.go b/x/crosschain/client/cli/cli_in_tx_tracker.go index 5afcec7ec8..d31257a257 100644 --- a/x/crosschain/client/cli/cli_in_tx_tracker.go +++ b/x/crosschain/client/cli/cli_in_tx_tracker.go @@ -86,7 +86,7 @@ func CmdListInTxTrackers() *cobra.Command { Use: "list-all-in-tx-trackers", Short: "shows all inTxTrackers", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) params := &types.QueryAllInTxTrackersRequest{} diff --git a/x/crosschain/client/cli/cli_last_block_height.go b/x/crosschain/client/cli/cli_last_block_height.go index b3e693dc31..3f1dfb54a9 100644 --- a/x/crosschain/client/cli/cli_last_block_height.go +++ b/x/crosschain/client/cli/cli_last_block_height.go @@ -13,7 +13,7 @@ func CmdListLastBlockHeight() *cobra.Command { cmd := &cobra.Command{ Use: "list-last-block-height", Short: "list all lastBlockHeight", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/cli_out_tx_tracker.go b/x/crosschain/client/cli/cli_out_tx_tracker.go index 109a07d52a..143f237169 100644 --- a/x/crosschain/client/cli/cli_out_tx_tracker.go +++ b/x/crosschain/client/cli/cli_out_tx_tracker.go @@ -15,7 +15,7 @@ func CmdListOutTxTracker() *cobra.Command { cmd := &cobra.Command{ Use: "list-out-tx-tracker", Short: "list all OutTxTracker", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/cli_zeta_height.go b/x/crosschain/client/cli/cli_zeta_height.go index 8f855cd46e..4287d561c0 100644 --- a/x/crosschain/client/cli/cli_zeta_height.go +++ b/x/crosschain/client/cli/cli_zeta_height.go @@ -12,7 +12,7 @@ func CmdLastZetaHeight() *cobra.Command { Use: "last-zeta-height", Short: "Query last Zeta Height", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/crosschain/client/cli/query_in_tx_hash_to_cctx.go b/x/crosschain/client/cli/query_in_tx_hash_to_cctx.go index e34d52886b..4e9444d6b6 100644 --- a/x/crosschain/client/cli/query_in_tx_hash_to_cctx.go +++ b/x/crosschain/client/cli/query_in_tx_hash_to_cctx.go @@ -13,7 +13,7 @@ func CmdListInTxHashToCctx() *cobra.Command { cmd := &cobra.Command{ Use: "list-in-tx-hash-to-cctx", Short: "list all inTxHashToCctx", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/crosschain/client/cli/query_rate_limiter_flags.go b/x/crosschain/client/cli/query_rate_limiter_flags.go index 43377e8b50..acb2cf4f91 100644 --- a/x/crosschain/client/cli/query_rate_limiter_flags.go +++ b/x/crosschain/client/cli/query_rate_limiter_flags.go @@ -13,7 +13,7 @@ func CmdShowUpdateRateLimiterFlags() *cobra.Command { cmd := &cobra.Command{ Use: "update_rate_limit_flags", Short: "shows the rate limiter flags", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/crosschain/client/cli/query_zeta_accounting.go b/x/crosschain/client/cli/query_zeta_accounting.go index aece6e6f37..29f35cdc4b 100644 --- a/x/crosschain/client/cli/query_zeta_accounting.go +++ b/x/crosschain/client/cli/query_zeta_accounting.go @@ -12,7 +12,7 @@ func CmdGetZetaAccounting() *cobra.Command { Use: "get-zeta-accounting", Short: "Query zeta accounting", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_cctx.go b/x/crosschain/keeper/grpc_query_cctx.go index 8e96757b44..2aeab7007a 100644 --- a/x/crosschain/keeper/grpc_query_cctx.go +++ b/x/crosschain/keeper/grpc_query_cctx.go @@ -39,7 +39,7 @@ func (k Keeper) CctxAll(c context.Context, req *types.QueryAllCctxRequest) (*typ store := ctx.KVStore(k.storeKey) sendStore := prefix.NewStore(store, types.KeyPrefix(types.SendKey)) - pageRes, err := query.Paginate(sendStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(sendStore, req.Pagination, func(_ []byte, value []byte) error { var send types.CrossChainTx if err := k.cdc.Unmarshal(value, &send); err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_gas_price.go b/x/crosschain/keeper/grpc_query_gas_price.go index b703ff44a2..311bdc1d6b 100644 --- a/x/crosschain/keeper/grpc_query_gas_price.go +++ b/x/crosschain/keeper/grpc_query_gas_price.go @@ -23,7 +23,7 @@ func (k Keeper) GasPriceAll(c context.Context, req *types.QueryAllGasPriceReques store := ctx.KVStore(k.storeKey) gasPriceStore := prefix.NewStore(store, types.KeyPrefix(types.GasPriceKey)) - pageRes, err := query.Paginate(gasPriceStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(gasPriceStore, req.Pagination, func(_ []byte, value []byte) error { var gasPrice types.GasPrice if err := k.cdc.Unmarshal(value, &gasPrice); err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go index 2d3fe05be9..a30c33edf8 100644 --- a/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go +++ b/x/crosschain/keeper/grpc_query_in_tx_hash_to_cctx.go @@ -22,7 +22,7 @@ func (k Keeper) InTxHashToCctxAll(c context.Context, req *types.QueryAllInTxHash store := ctx.KVStore(k.storeKey) inTxHashToCctxStore := prefix.NewStore(store, types.KeyPrefix(types.InTxHashToCctxKeyPrefix)) - pageRes, err := query.Paginate(inTxHashToCctxStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(inTxHashToCctxStore, req.Pagination, func(_ []byte, value []byte) error { var inTxHashToCctx types.InTxHashToCctx if err := k.cdc.Unmarshal(value, &inTxHashToCctx); err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_last_block_height.go b/x/crosschain/keeper/grpc_query_last_block_height.go index 633c440dc9..875a5facf2 100644 --- a/x/crosschain/keeper/grpc_query_last_block_height.go +++ b/x/crosschain/keeper/grpc_query_last_block_height.go @@ -23,7 +23,7 @@ func (k Keeper) LastBlockHeightAll(c context.Context, req *types.QueryAllLastBlo store := ctx.KVStore(k.storeKey) lastBlockHeightStore := prefix.NewStore(store, types.KeyPrefix(types.LastBlockHeightKey)) - pageRes, err := query.Paginate(lastBlockHeightStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(lastBlockHeightStore, req.Pagination, func(_ []byte, value []byte) error { var lastBlockHeight types.LastBlockHeight if err := k.cdc.Unmarshal(value, &lastBlockHeight); err != nil { return err diff --git a/x/crosschain/keeper/grpc_query_out_tx_tracker.go b/x/crosschain/keeper/grpc_query_out_tx_tracker.go index 0eac4d35b1..0170953eb2 100644 --- a/x/crosschain/keeper/grpc_query_out_tx_tracker.go +++ b/x/crosschain/keeper/grpc_query_out_tx_tracker.go @@ -22,7 +22,7 @@ func (k Keeper) OutTxTrackerAll(c context.Context, req *types.QueryAllOutTxTrack store := ctx.KVStore(k.storeKey) outTxTrackerStore := prefix.NewStore(store, types.KeyPrefix(types.OutTxTrackerKeyPrefix)) - pageRes, err := query.Paginate(outTxTrackerStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(outTxTrackerStore, req.Pagination, func(_ []byte, value []byte) error { var outTxTracker types.OutTxTracker if err := k.cdc.Unmarshal(value, &outTxTracker); err != nil { return err @@ -49,7 +49,7 @@ func (k Keeper) OutTxTrackerAllByChain(c context.Context, req *types.QueryAllOut store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OutTxTrackerKeyPrefix)) chainStore := prefix.NewStore(store, types.KeyPrefix(fmt.Sprintf("%d-", req.Chain))) - pageRes, err := query.Paginate(chainStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(chainStore, req.Pagination, func(_ []byte, value []byte) error { var outTxTracker types.OutTxTracker if err := k.cdc.Unmarshal(value, &outTxTracker); err != nil { return err diff --git a/x/crosschain/keeper/in_tx_tracker.go b/x/crosschain/keeper/in_tx_tracker.go index d53c56c57f..2d7849ee49 100644 --- a/x/crosschain/keeper/in_tx_tracker.go +++ b/x/crosschain/keeper/in_tx_tracker.go @@ -44,7 +44,7 @@ func (k Keeper) GetAllInTxTrackerPaginated(ctx sdk.Context, pagination *query.Pa store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.InTxTrackerKeyPrefix)) iterator := sdk.KVStorePrefixIterator(store, []byte{}) defer iterator.Close() - pageRes, err = query.Paginate(store, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(store, pagination, func(_ []byte, value []byte) error { var inTxTracker types.InTxTracker if err := k.cdc.Unmarshal(value, &inTxTracker); err != nil { return err @@ -82,7 +82,7 @@ func (k Keeper) GetAllInTxTrackerForChain(ctx sdk.Context, chainID int64) (list func (k Keeper) GetAllInTxTrackerForChainPaginated(ctx sdk.Context, chainID int64, pagination *query.PageRequest) (inTxTrackers []types.InTxTracker, pageRes *query.PageResponse, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(fmt.Sprintf("%s", types.InTxTrackerKeyPrefix))) chainStore := prefix.NewStore(store, types.KeyPrefix(fmt.Sprintf("%d-", chainID))) - pageRes, err = query.Paginate(chainStore, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(chainStore, pagination, func(_ []byte, value []byte) error { var inTxTracker types.InTxTracker if err := k.cdc.Unmarshal(value, &inTxTracker); err != nil { return err diff --git a/x/emissions/client/cli/query_get_emmisons_factors.go b/x/emissions/client/cli/query_get_emmisons_factors.go index 0749d33218..304f7760dc 100644 --- a/x/emissions/client/cli/query_get_emmisons_factors.go +++ b/x/emissions/client/cli/query_get_emmisons_factors.go @@ -12,7 +12,7 @@ func CmdGetEmmisonsFactors() *cobra.Command { Use: "get-emmisons-factors", Short: "Query GetEmmisonsFactors", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/emissions/client/cli/query_list_balances.go b/x/emissions/client/cli/query_list_balances.go index c20ca85500..83e4609fa2 100644 --- a/x/emissions/client/cli/query_list_balances.go +++ b/x/emissions/client/cli/query_list_balances.go @@ -12,7 +12,7 @@ func CmdListPoolAddresses() *cobra.Command { Use: "list-pool-addresses", Short: "Query list-pool-addresses", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/emissions/client/cli/query_params.go b/x/emissions/client/cli/query_params.go index 55b2067c40..82d3ef153a 100644 --- a/x/emissions/client/cli/query_params.go +++ b/x/emissions/client/cli/query_params.go @@ -14,7 +14,7 @@ func CmdQueryParams() *cobra.Command { Use: "params", Short: "shows the parameters of the module", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/fungible/client/cli/query_foreign_coins.go b/x/fungible/client/cli/query_foreign_coins.go index 7410077321..e115fbd65b 100644 --- a/x/fungible/client/cli/query_foreign_coins.go +++ b/x/fungible/client/cli/query_foreign_coins.go @@ -13,7 +13,7 @@ func CmdListForeignCoins() *cobra.Command { cmd := &cobra.Command{ Use: "list-foreign-coins", Short: "list all ForeignCoins", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/fungible/client/cli/query_gas_stability_pool.go b/x/fungible/client/cli/query_gas_stability_pool.go index 46e2fa3ae8..516353daae 100644 --- a/x/fungible/client/cli/query_gas_stability_pool.go +++ b/x/fungible/client/cli/query_gas_stability_pool.go @@ -15,7 +15,7 @@ func CmdGasStabilityPoolAddress() *cobra.Command { Use: "gas-stability-pool-address", Short: "query the address of a gas stability pool", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) @@ -74,7 +74,7 @@ func CmdGasStabilityPoolBalances() *cobra.Command { Use: "gas-stability-pool-balances", Short: "query all gas stability pool balances", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/fungible/client/cli/query_system_contract.go b/x/fungible/client/cli/query_system_contract.go index df79e833d9..f4fe29cc59 100644 --- a/x/fungible/client/cli/query_system_contract.go +++ b/x/fungible/client/cli/query_system_contract.go @@ -13,7 +13,7 @@ func CmdSystemContract() *cobra.Command { cmd := &cobra.Command{ Use: "system-contract", Short: "query system contract", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/fungible/client/cli/tx_deploy_system_contracts.go b/x/fungible/client/cli/tx_deploy_system_contracts.go index b8ed9dd9d2..c57e68f65e 100644 --- a/x/fungible/client/cli/tx_deploy_system_contracts.go +++ b/x/fungible/client/cli/tx_deploy_system_contracts.go @@ -13,7 +13,7 @@ func CmdDeploySystemContracts() *cobra.Command { Use: "deploy-system-contracts", Short: "Broadcast message SystemContracts", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err diff --git a/x/fungible/keeper/grpc_query_foreign_coins.go b/x/fungible/keeper/grpc_query_foreign_coins.go index 2688dc6d6b..20c661d7d1 100644 --- a/x/fungible/keeper/grpc_query_foreign_coins.go +++ b/x/fungible/keeper/grpc_query_foreign_coins.go @@ -22,7 +22,7 @@ func (k Keeper) ForeignCoinsAll(c context.Context, req *types.QueryAllForeignCoi store := ctx.KVStore(k.storeKey) foreignCoinsStore := prefix.NewStore(store, types.KeyPrefix(types.ForeignCoinsKeyPrefix)) - pageRes, err := query.Paginate(foreignCoinsStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(foreignCoinsStore, req.Pagination, func(_ []byte, value []byte) error { var foreignCoins types.ForeignCoins if err := k.cdc.Unmarshal(value, &foreignCoins); err != nil { return err diff --git a/x/lightclient/client/cli/query_block_header.go b/x/lightclient/client/cli/query_block_header.go index a183d295e5..99b54fbdfc 100644 --- a/x/lightclient/client/cli/query_block_header.go +++ b/x/lightclient/client/cli/query_block_header.go @@ -12,7 +12,7 @@ func CmdListBlockHeader() *cobra.Command { Use: "list-block-header", Short: "List all the block headers", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err diff --git a/x/lightclient/client/cli/query_chain_state.go b/x/lightclient/client/cli/query_chain_state.go index 888f15b012..672152c737 100644 --- a/x/lightclient/client/cli/query_chain_state.go +++ b/x/lightclient/client/cli/query_chain_state.go @@ -14,7 +14,7 @@ func CmdListChainState() *cobra.Command { Use: "list-chain-state", Short: "List all the chain states", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err diff --git a/x/lightclient/client/cli/query_verification_flags.go b/x/lightclient/client/cli/query_verification_flags.go index 19b5cd3691..5b4962c8e5 100644 --- a/x/lightclient/client/cli/query_verification_flags.go +++ b/x/lightclient/client/cli/query_verification_flags.go @@ -12,7 +12,7 @@ func CmdShowVerificationFlags() *cobra.Command { Use: "show-verification-flags", Short: "Show the verification flags", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err diff --git a/x/lightclient/keeper/grpc_query_block_header.go b/x/lightclient/keeper/grpc_query_block_header.go index d862ee3036..a17b4ef9d7 100644 --- a/x/lightclient/keeper/grpc_query_block_header.go +++ b/x/lightclient/keeper/grpc_query_block_header.go @@ -21,7 +21,7 @@ func (k Keeper) BlockHeaderAll(c context.Context, req *types.QueryAllBlockHeader blockHeaderStore := prefix.NewStore(store, types.KeyPrefix(types.BlockHeaderKey)) var blockHeaders []proofs.BlockHeader - pageRes, err := query.Paginate(blockHeaderStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(blockHeaderStore, req.Pagination, func(_ []byte, value []byte) error { var blockHeader proofs.BlockHeader if err := k.cdc.Unmarshal(value, &blockHeader); err != nil { return err diff --git a/x/lightclient/keeper/grpc_query_chain_state.go b/x/lightclient/keeper/grpc_query_chain_state.go index 2fe168d536..bc428bd91c 100644 --- a/x/lightclient/keeper/grpc_query_chain_state.go +++ b/x/lightclient/keeper/grpc_query_chain_state.go @@ -22,7 +22,7 @@ func (k Keeper) ChainStateAll(c context.Context, req *types.QueryAllChainStateRe chainStateStore := prefix.NewStore(store, types.KeyPrefix(types.ChainStateKey)) var chainStates []types.ChainState - pageRes, err := query.Paginate(chainStateStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(chainStateStore, req.Pagination, func(_ []byte, value []byte) error { var chainState types.ChainState if err := k.cdc.Unmarshal(value, &chainState); err != nil { return err diff --git a/x/observer/client/cli/query_blame.go b/x/observer/client/cli/query_blame.go index 462c442279..efe7945a73 100644 --- a/x/observer/client/cli/query_blame.go +++ b/x/observer/client/cli/query_blame.go @@ -47,7 +47,7 @@ func CmdGetAllBlameRecords() *cobra.Command { Use: "list-blame", Short: "Query AllBlameRecords", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/observer/client/cli/query_chain_nonce.go b/x/observer/client/cli/query_chain_nonce.go index 8a0a443fca..a5a1ec1cb6 100644 --- a/x/observer/client/cli/query_chain_nonce.go +++ b/x/observer/client/cli/query_chain_nonce.go @@ -13,7 +13,7 @@ func CmdListChainNonces() *cobra.Command { cmd := &cobra.Command{ Use: "list-chain-nonces", Short: "list all chainNonces", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/observer/client/cli/query_chain_params.go b/x/observer/client/cli/query_chain_params.go index 6733c7d5c7..68433ef75e 100644 --- a/x/observer/client/cli/query_chain_params.go +++ b/x/observer/client/cli/query_chain_params.go @@ -46,7 +46,7 @@ func CmdGetChainParams() *cobra.Command { Use: "list-chain-params", Short: "Query GetChainParams", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/observer/client/cli/query_keygen.go b/x/observer/client/cli/query_keygen.go index d48fefc34d..85ec112bbe 100644 --- a/x/observer/client/cli/query_keygen.go +++ b/x/observer/client/cli/query_keygen.go @@ -14,7 +14,7 @@ func CmdShowKeygen() *cobra.Command { Use: "show-keygen", Short: "shows keygen", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_node_account.go b/x/observer/client/cli/query_node_account.go index 199cf87e70..51113aaac4 100644 --- a/x/observer/client/cli/query_node_account.go +++ b/x/observer/client/cli/query_node_account.go @@ -13,7 +13,7 @@ func CmdListNodeAccount() *cobra.Command { cmd := &cobra.Command{ Use: "list-node-account", Short: "list all NodeAccount", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) pageReq, err := client.ReadPageRequest(cmd.Flags()) diff --git a/x/observer/client/cli/query_observers.go b/x/observer/client/cli/query_observers.go index e2c25d2fb0..688b32c6da 100644 --- a/x/observer/client/cli/query_observers.go +++ b/x/observer/client/cli/query_observers.go @@ -12,7 +12,7 @@ func CmdObserverSet() *cobra.Command { Use: "list-observer-set", Short: "Query observer set", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/observer/client/cli/query_params.go b/x/observer/client/cli/query_params.go index cb2af7efdf..78508a9443 100644 --- a/x/observer/client/cli/query_params.go +++ b/x/observer/client/cli/query_params.go @@ -14,7 +14,7 @@ func CmdQueryParams() *cobra.Command { Use: "params", Short: "shows the parameters of the module", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_pending_nonces.go b/x/observer/client/cli/query_pending_nonces.go index 0afff149fd..e15abbb893 100644 --- a/x/observer/client/cli/query_pending_nonces.go +++ b/x/observer/client/cli/query_pending_nonces.go @@ -14,7 +14,7 @@ func CmdListPendingNonces() *cobra.Command { Use: "list-pending-nonces", Short: "shows a chainNonces", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_permission_flags.go b/x/observer/client/cli/query_permission_flags.go index 917b47897c..fbd3f3adb5 100644 --- a/x/observer/client/cli/query_permission_flags.go +++ b/x/observer/client/cli/query_permission_flags.go @@ -14,7 +14,7 @@ func CmdShowCrosschainFlags() *cobra.Command { Use: "show-crosschain-flags", Short: "shows the crosschain flags", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_show_observer_count.go b/x/observer/client/cli/query_show_observer_count.go index 84ad22dde1..47240e7a74 100644 --- a/x/observer/client/cli/query_show_observer_count.go +++ b/x/observer/client/cli/query_show_observer_count.go @@ -12,7 +12,7 @@ func CmdShowObserverCount() *cobra.Command { Use: "show-observer-count", Short: "Query show-observer-count", Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/observer/client/cli/query_supported_chains.go b/x/observer/client/cli/query_supported_chains.go index b4c0181d8c..913a2869ec 100644 --- a/x/observer/client/cli/query_supported_chains.go +++ b/x/observer/client/cli/query_supported_chains.go @@ -13,7 +13,7 @@ func CmdGetSupportedChains() *cobra.Command { cmd := &cobra.Command{ Use: "list-chains", Short: "list all SupportedChains", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/query_tss.go b/x/observer/client/cli/query_tss.go index 865303d423..aa917125c0 100644 --- a/x/observer/client/cli/query_tss.go +++ b/x/observer/client/cli/query_tss.go @@ -14,7 +14,7 @@ func CmdShowTSS() *cobra.Command { Use: "show-tss", Short: "shows a TSS", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) @@ -40,7 +40,7 @@ func CmdListTssHistory() *cobra.Command { Use: "list-tss-history", Short: "show historical list of TSS", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) queryClient := types.NewQueryClient(clientCtx) diff --git a/x/observer/client/cli/tx_add_blame_vote.go b/x/observer/client/cli/tx_add_blame_vote.go index 95d3b0d5da..ea2272332a 100644 --- a/x/observer/client/cli/tx_add_blame_vote.go +++ b/x/observer/client/cli/tx_add_blame_vote.go @@ -71,7 +71,7 @@ func CmdEncode() *cobra.Command { Use: "encode [file.json]", Short: "Encode a json string into hex", Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(_ *cobra.Command, args []string) (err error) { fp := args[0] file, err := filepath.Abs(fp) if err != nil { diff --git a/x/observer/keeper/blame.go b/x/observer/keeper/blame.go index adbbfb0436..63e4c84809 100644 --- a/x/observer/keeper/blame.go +++ b/x/observer/keeper/blame.go @@ -37,7 +37,7 @@ func (k Keeper) GetAllBlame(ctx sdk.Context) (BlameRecords []types.Blame) { func (k Keeper) GetAllBlamePaginated(ctx sdk.Context, pagination *query.PageRequest) (blameRecords []types.Blame, pageRes *query.PageResponse, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlameKey)) - pageRes, err = query.Paginate(store, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(store, pagination, func(_ []byte, value []byte) error { var blame types.Blame if err := k.cdc.Unmarshal(value, &blame); err != nil { return err diff --git a/x/observer/keeper/grpc_query_node_account.go b/x/observer/keeper/grpc_query_node_account.go index 2528754448..44aa499757 100644 --- a/x/observer/keeper/grpc_query_node_account.go +++ b/x/observer/keeper/grpc_query_node_account.go @@ -22,7 +22,7 @@ func (k Keeper) NodeAccountAll(c context.Context, req *types.QueryAllNodeAccount store := ctx.KVStore(k.storeKey) nodeAccountStore := prefix.NewStore(store, types.KeyPrefix(types.NodeAccountKey)) - pageRes, err := query.Paginate(nodeAccountStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(nodeAccountStore, req.Pagination, func(_ []byte, value []byte) error { var nodeAccount types.NodeAccount if err := k.cdc.Unmarshal(value, &nodeAccount); err != nil { return err diff --git a/x/observer/keeper/grpc_query_nonces.go b/x/observer/keeper/grpc_query_nonces.go index 7c0b6d481a..80ff3a23b2 100644 --- a/x/observer/keeper/grpc_query_nonces.go +++ b/x/observer/keeper/grpc_query_nonces.go @@ -25,7 +25,7 @@ func (k Keeper) ChainNoncesAll(c context.Context, req *types.QueryAllChainNonces store := ctx.KVStore(k.storeKey) chainNoncesStore := prefix.NewStore(store, types.KeyPrefix(types.ChainNoncesKey)) - pageRes, err := query.Paginate(chainNoncesStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(chainNoncesStore, req.Pagination, func(_ []byte, value []byte) error { var chainNonces types.ChainNonces if err := k.cdc.Unmarshal(value, &chainNonces); err != nil { return err diff --git a/x/observer/keeper/pending_nonces.go b/x/observer/keeper/pending_nonces.go index 198a1219b5..34f241a10e 100644 --- a/x/observer/keeper/pending_nonces.go +++ b/x/observer/keeper/pending_nonces.go @@ -35,7 +35,7 @@ func (k Keeper) GetAllPendingNoncesPaginated(ctx sdk.Context, pagination *query. iterator := sdk.KVStorePrefixIterator(store, []byte{}) defer iterator.Close() - pageRes, err = query.Paginate(store, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(store, pagination, func(_ []byte, value []byte) error { var val types.PendingNonces if err := k.cdc.Unmarshal(value, &val); err != nil { return err diff --git a/x/observer/keeper/tss.go b/x/observer/keeper/tss.go index 0b389d2643..43eaed47c5 100644 --- a/x/observer/keeper/tss.go +++ b/x/observer/keeper/tss.go @@ -81,7 +81,7 @@ func (k Keeper) GetAllTSS(ctx sdk.Context) (list []types.TSS) { func (k Keeper) GetAllTSSPaginated(ctx sdk.Context, pagination *query.PageRequest) (list []types.TSS, pageRes *query.PageResponse, err error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TSSHistoryKey)) - pageRes, err = query.Paginate(store, pagination, func(key []byte, value []byte) error { + pageRes, err = query.Paginate(store, pagination, func(_ []byte, value []byte) error { var tss types.TSS if err := k.cdc.Unmarshal(value, &tss); err != nil { return err From f4f5cd6509a9c18c101b5a36ed9e1bb1556a80a7 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Tue, 23 Apr 2024 10:06:31 +0200 Subject: [PATCH 11/11] test(e2e): fix liquidity cap advanced test (#2047) * remove * fix test * changelog --- changelog.md | 1 + e2e/e2etests/test_eth_deposit.go | 105 -------------- .../test_eth_deposit_liquidity_cap.go | 130 ++++++++++++++++++ 3 files changed, 131 insertions(+), 105 deletions(-) create mode 100644 e2e/e2etests/test_eth_deposit_liquidity_cap.go diff --git a/changelog.md b/changelog.md index 61b85985bf..19c08aebc9 100644 --- a/changelog.md +++ b/changelog.md @@ -82,6 +82,7 @@ * [1985](https://github.com/zeta-chain/node/pull/1985) - improve fungible module coverage * [1992](https://github.com/zeta-chain/node/pull/1992) - remove setupKeeper from crosschain module * [2008](https://github.com/zeta-chain/node/pull/2008) - add test for connector bytecode update +* [2047](https://github.com/zeta-chain/node/pull/2047) - fix liquidity cap advanced test ### Fixes diff --git a/e2e/e2etests/test_eth_deposit.go b/e2e/e2etests/test_eth_deposit.go index 65a79f9c15..472a344423 100644 --- a/e2e/e2etests/test_eth_deposit.go +++ b/e2e/e2etests/test_eth_deposit.go @@ -6,8 +6,6 @@ import ( "math/big" "strings" - "cosmossdk.io/math" - "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -16,7 +14,6 @@ import ( "github.com/zeta-chain/zetacore/e2e/utils" testcontract "github.com/zeta-chain/zetacore/testutil/contracts" "github.com/zeta-chain/zetacore/x/crosschain/types" - fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" ) // TestEtherDeposit tests deposit of ethers @@ -254,105 +251,3 @@ func TestDepositAndCallRefund(r *runner.E2ERunner, args []string) { r.Logger.Info(" block num: %d", receipt.BlockNumber) }() } - -// TestDepositEtherLiquidityCap tests depositing Ethers in a context where a liquidity cap is set -func TestDepositEtherLiquidityCap(r *runner.E2ERunner, args []string) { - if len(args) != 1 { - panic("TestDepositEtherLiquidityCap requires exactly one argument for the liquidity cap.") - } - - liquidityCapArg := math.NewUintFromString(args[0]) - supply, err := r.ETHZRC20.TotalSupply(&bind.CallOpts{}) - if err != nil { - panic(err) - } - - liquidityCap := math.NewUintFromBigInt(supply).Add(liquidityCapArg) - amountLessThanCap := liquidityCap.BigInt().Div(liquidityCap.BigInt(), big.NewInt(10)) // 1/10 of the cap - amountMoreThanCap := liquidityCap.BigInt().Mul(liquidityCap.BigInt(), big.NewInt(10)) // 10 times the cap - msg := fungibletypes.NewMsgUpdateZRC20LiquidityCap( - r.ZetaTxServer.GetAccountAddress(0), - r.ETHZRC20Addr.Hex(), - liquidityCap, - ) - res, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) - if err != nil { - panic(err) - } - r.Logger.Info("set liquidity cap tx hash: %s", res.TxHash) - - r.Logger.Info("Depositing more than liquidity cap should make cctx reverted") - signedTx, err := r.SendEther(r.TSSAddress, amountMoreThanCap, nil) - if err != nil { - panic(err) - } - receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout) - if receipt.Status == 0 { - panic("deposit eth tx failed") - } - cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) - if cctx.CctxStatus.Status != types.CctxStatus_Reverted { - panic(fmt.Sprintf("expected cctx status to be Reverted; got %s", cctx.CctxStatus.Status)) - } - r.Logger.Info("CCTX has been reverted") - - r.Logger.Info("Depositing less than liquidity cap should still succeed") - initialBal, err := r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) - if err != nil { - panic(err) - } - signedTx, err = r.SendEther(r.TSSAddress, amountLessThanCap, nil) - if err != nil { - panic(err) - } - receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout) - if receipt.Status == 0 { - panic("deposit eth tx failed") - } - utils.WaitCctxMinedByInTxHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) - expectedBalance := big.NewInt(0).Add(initialBal, amountLessThanCap) - - bal, err := r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) - if err != nil { - panic(err) - } - if bal.Cmp(expectedBalance) != 0 { - panic(fmt.Sprintf("expected balance to be %s; got %s", expectedBalance.String(), bal.String())) - } - r.Logger.Info("Deposit succeeded") - - r.Logger.Info("Removing the liquidity cap") - msg = fungibletypes.NewMsgUpdateZRC20LiquidityCap( - r.ZetaTxServer.GetAccountAddress(0), - r.ETHZRC20Addr.Hex(), - math.ZeroUint(), - ) - res, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) - if err != nil { - panic(err) - } - r.Logger.Info("remove liquidity cap tx hash: %s", res.TxHash) - initialBal, err = r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) - if err != nil { - panic(err) - } - signedTx, err = r.SendEther(r.TSSAddress, amountMoreThanCap, nil) - if err != nil { - panic(err) - } - receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout) - if receipt.Status == 0 { - panic("deposit eth tx failed") - } - utils.WaitCctxMinedByInTxHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) - expectedBalance = big.NewInt(0).Add(initialBal, amountMoreThanCap) - - bal, err = r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) - if err != nil { - panic(err) - } - if bal.Cmp(expectedBalance) != 0 { - panic(fmt.Sprintf("expected balance to be %s; got %s", expectedBalance.String(), bal.String())) - } - r.Logger.Info("New deposit succeeded") -} diff --git a/e2e/e2etests/test_eth_deposit_liquidity_cap.go b/e2e/e2etests/test_eth_deposit_liquidity_cap.go new file mode 100644 index 0000000000..47c1000c73 --- /dev/null +++ b/e2e/e2etests/test_eth_deposit_liquidity_cap.go @@ -0,0 +1,130 @@ +package e2etests + +import ( + "fmt" + "math/big" + + "cosmossdk.io/math" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/zeta-chain/zetacore/e2e/runner" + "github.com/zeta-chain/zetacore/e2e/utils" + "github.com/zeta-chain/zetacore/x/crosschain/types" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" +) + +// TestDepositEtherLiquidityCap tests depositing Ethers in a context where a liquidity cap is set +func TestDepositEtherLiquidityCap(r *runner.E2ERunner, args []string) { + if len(args) != 1 { + panic("TestDepositEtherLiquidityCap requires exactly one argument for the liquidity cap.") + } + + liquidityCapArg := math.NewUintFromString(args[0]) + supply, err := r.ETHZRC20.TotalSupply(&bind.CallOpts{}) + if err != nil { + panic(err) + } + + liquidityCap := math.NewUintFromBigInt(supply).Add(liquidityCapArg) + amountLessThanCap := liquidityCapArg.BigInt().Div(liquidityCapArg.BigInt(), big.NewInt(10)) // 1/10 of the cap + amountMoreThanCap := liquidityCapArg.BigInt().Mul(liquidityCapArg.BigInt(), big.NewInt(10)) // 10 times the cap + msg := fungibletypes.NewMsgUpdateZRC20LiquidityCap( + r.ZetaTxServer.GetAccountAddress(0), + r.ETHZRC20Addr.Hex(), + liquidityCap, + ) + res, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) + if err != nil { + panic(err) + } + r.Logger.Info("set liquidity cap tx hash: %s", res.TxHash) + + r.Logger.Info("Depositing more than liquidity cap should make cctx reverted") + signedTx, err := r.SendEther(r.TSSAddress, amountMoreThanCap, nil) + if err != nil { + panic(err) + } + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic("deposit eth tx failed") + } + cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != types.CctxStatus_Reverted { + panic(fmt.Sprintf("expected cctx status to be Reverted; got %s", cctx.CctxStatus.Status)) + } + r.Logger.Info("CCTX has been reverted") + + r.Logger.Info("Depositing less than liquidity cap should still succeed") + initialBal, err := r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + if err != nil { + panic(err) + } + signedTx, err = r.SendEther(r.TSSAddress, amountLessThanCap, nil) + if err != nil { + panic(err) + } + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic("deposit eth tx failed") + } + cctx = utils.WaitCctxMinedByInTxHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) + if cctx.CctxStatus.Status != types.CctxStatus_OutboundMined { + + panic(fmt.Sprintf( + "expected cctx status to be Success; got %s; message: %s; supply: %s; liquidity cap: %s, amountLessThanCap: %s, amountMoreThanCap: %s", + cctx.CctxStatus.Status, + cctx.CctxStatus.StatusMessage, + supply.String(), + liquidityCap.String(), + amountLessThanCap.String(), + amountMoreThanCap.String(), + )) + } + + expectedBalance := big.NewInt(0).Add(initialBal, amountLessThanCap) + + bal, err := r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + if err != nil { + panic(err) + } + if bal.Cmp(expectedBalance) != 0 { + + panic(fmt.Sprintf("expected balance to be %s; got %s", expectedBalance.String(), bal.String())) + } + r.Logger.Info("Deposit succeeded") + + r.Logger.Info("Removing the liquidity cap") + msg = fungibletypes.NewMsgUpdateZRC20LiquidityCap( + r.ZetaTxServer.GetAccountAddress(0), + r.ETHZRC20Addr.Hex(), + math.ZeroUint(), + ) + res, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) + if err != nil { + panic(err) + } + r.Logger.Info("remove liquidity cap tx hash: %s", res.TxHash) + initialBal, err = r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + if err != nil { + panic(err) + } + signedTx, err = r.SendEther(r.TSSAddress, amountMoreThanCap, nil) + if err != nil { + panic(err) + } + receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout) + if receipt.Status == 0 { + panic("deposit eth tx failed") + } + utils.WaitCctxMinedByInTxHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) + expectedBalance = big.NewInt(0).Add(initialBal, amountMoreThanCap) + + bal, err = r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.DeployerAddress) + if err != nil { + panic(err) + } + if bal.Cmp(expectedBalance) != 0 { + panic(fmt.Sprintf("expected balance to be %s; got %s", expectedBalance.String(), bal.String())) + } + r.Logger.Info("New deposit succeeded") +}