diff --git a/app/ante/ante.go b/app/ante/ante.go index ef38309429..18947d01fa 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -168,12 +168,12 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool { } } switch innerMsg.(type) { - case *cctxtypes.MsgGasPriceVoter, + case *cctxtypes.MsgVoteGasPrice, *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 f013784285..790930d175 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -32,12 +32,12 @@ func (mah *MockAnteHandler) AnteHandle(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.C func TestIsSystemTx(t *testing.T) { // system tx types: - // *cctxtypes.MsgGasPriceVoter, + // *cctxtypes.MsgVoteGasPrice, // *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 b30335c128..79e91fa3b8 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 @@ -419,7 +434,6 @@ func New( appCodec, keys[fungibletypes.StoreKey], keys[fungibletypes.MemStoreKey], - app.GetSubspace(fungibletypes.ModuleName), app.AccountKeeper, app.EvmKeeper, app.BankKeeper, @@ -432,12 +446,12 @@ func New( keys[crosschaintypes.StoreKey], keys[crosschaintypes.MemStoreKey], &stakingKeeper, - app.GetSubspace(crosschaintypes.ModuleName), app.AccountKeeper, app.BankKeeper, 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. @@ -509,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), @@ -543,6 +558,7 @@ func New( emissionstypes.ModuleName, authz.ModuleName, authoritytypes.ModuleName, + lightclienttypes.ModuleName, ) app.mm.SetOrderEndBlockers( banktypes.ModuleName, @@ -566,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 diff --git a/app/init_genesis.go b/app/init_genesis.go index f5d12a0746..7f424ee5bc 100644 --- a/app/init_genesis.go +++ b/app/init_genesis.go @@ -21,6 +21,7 @@ import ( 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" ) @@ -47,5 +48,6 @@ func InitGenesisModuleList() []string { emissionsModuleTypes.ModuleName, authz.ModuleName, authoritytypes.ModuleName, + lightclienttypes.ModuleName, } } 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 a3ae5e2cb2..6cbd8d8f85 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,18 @@ * 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`. +* 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. @@ -26,17 +38,23 @@ * [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` ### Features * [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 * [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 ### Tests @@ -60,6 +78,7 @@ * [1941](https://github.com/zeta-chain/node/pull/1941) - add unit tests for zetabridge package * [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 ### Fixes diff --git a/cmd/zetaclientd/debug.go b/cmd/zetaclientd/debug.go index 32cb32c772..b784488ee0 100644 --- a/cmd/zetaclientd/debug.go +++ b/cmd/zetaclientd/debug.go @@ -100,7 +100,7 @@ func DebugCmd() *cobra.Command { ob := evm.ChainClient{ Mu: &sync.Mutex{}, } - ob.WithZetaClient(bridge) + ob.WithZetaBridge(bridge) ob.WithLogger(chainLogger) var ethRPC *ethrpc.EthRPC var client *ethclient.Client diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 56d77e0950..de1633ad6f 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -124,7 +124,7 @@ func start(_ *cobra.Command, _ []string) error { // Initialize core parameters from zetacore appContext := appcontext.NewAppContext(corecontext.NewZetaCoreContext(cfg), cfg) - err = zetaBridge.UpdateZetaCoreContext(appContext.ZetaCoreContext(), true) + err = zetaBridge.UpdateZetaCoreContext(appContext.ZetaCoreContext(), true, startLogger) if err != nil { startLogger.Error().Err(err).Msg("Error getting core parameters") return err diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 7c14d1bfcb..a79bf2d111 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/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 d3ddca09a7..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() @@ -287,7 +292,8 @@ func localE2ETest(cmd *cobra.Command, _ []string) { if testAdmin { eg.Go(adminTestRoutine(conf, deployerRunner, verbose, e2etests.TestPauseZRC20Name, - e2etests.TestUpdateBytecodeName, + e2etests.TestUpdateBytecodeZRC20Name, + e2etests.TestUpdateBytecodeConnectorName, e2etests.TestDepositEtherLiquidityCapName, // TestMigrateChainSupportName tests EVM chain migration. Currently this test doesn't work with Anvil because pre-EIP1559 txs are not supported 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/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" diff --git a/contrib/localnet/zetacored/zetacored_zetacore0/config/genesis.json b/contrib/localnet/zetacored/zetacored_zetacore0/config/genesis.json index 87916c2d09..ab30faef7a 100644 --- a/contrib/localnet/zetacored/zetacored_zetacore0/config/genesis.json +++ b/contrib/localnet/zetacored/zetacored_zetacore0/config/genesis.json @@ -675,7 +675,7 @@ "grantee": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", "authorization": { "@type": "/cosmos.authz.v1beta1.GenericAuthorization", - "msg": "/zetachain.zetacore.crosschain.MsgGasPriceVoter" + "msg": "/zetachain.zetacore.crosschain.MsgVoteGasPrice" }, "expiration": null }, @@ -738,7 +738,7 @@ "grantee": "zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50", "authorization": { "@type": "/cosmos.authz.v1beta1.GenericAuthorization", - "msg": "/zetachain.zetacore.crosschain.MsgGasPriceVoter" + "msg": "/zetachain.zetacore.crosschain.MsgVoteGasPrice" }, "expiration": null }, diff --git a/contrib/localnet/zetacored/zetacored_zetacore1/config/genesis.json b/contrib/localnet/zetacored/zetacored_zetacore1/config/genesis.json index 87916c2d09..ab30faef7a 100644 --- a/contrib/localnet/zetacored/zetacored_zetacore1/config/genesis.json +++ b/contrib/localnet/zetacored/zetacored_zetacore1/config/genesis.json @@ -675,7 +675,7 @@ "grantee": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", "authorization": { "@type": "/cosmos.authz.v1beta1.GenericAuthorization", - "msg": "/zetachain.zetacore.crosschain.MsgGasPriceVoter" + "msg": "/zetachain.zetacore.crosschain.MsgVoteGasPrice" }, "expiration": null }, @@ -738,7 +738,7 @@ "grantee": "zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50", "authorization": { "@type": "/cosmos.authz.v1beta1.GenericAuthorization", - "msg": "/zetachain.zetacore.crosschain.MsgGasPriceVoter" + "msg": "/zetachain.zetacore.crosschain.MsgVoteGasPrice" }, "expiration": null }, 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_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/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_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_fungible_params.md b/docs/cli/zetacored/zetacored_query_lightclient_list-chain-state.md similarity index 74% rename from docs/cli/zetacored/zetacored_query_fungible_params.md rename to docs/cli/zetacored/zetacored_query_lightclient_list-chain-state.md index 9845c39cf3..eead2bf7a0 100644 --- a/docs/cli/zetacored/zetacored_query_fungible_params.md +++ b/docs/cli/zetacored/zetacored_query_lightclient_list-chain-state.md @@ -1,9 +1,9 @@ -# query fungible params +# query lightclient list-chain-state -shows the parameters of the module +List all the chain states ``` -zetacored query fungible params [flags] +zetacored query lightclient list-chain-state [flags] ``` ### Options @@ -12,7 +12,7 @@ zetacored query fungible params [flags] --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 + -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) ``` @@ -29,5 +29,5 @@ zetacored query fungible params [flags] ### SEE ALSO -* [zetacored query fungible](zetacored_query_fungible.md) - Querying commands for the fungible module +* [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_crosschain.md b/docs/cli/zetacored/zetacored_tx_crosschain.md index 40582875aa..902172ce59 100644 --- a/docs/cli/zetacored/zetacored_tx_crosschain.md +++ b/docs/cli/zetacored/zetacored_tx_crosschain.md @@ -29,12 +29,12 @@ zetacored tx crosschain [flags] * [zetacored tx crosschain add-to-in-tx-tracker](zetacored_tx_crosschain_add-to-in-tx-tracker.md) - Add a in-tx-tracker Use 0:Zeta,1:Gas,2:ERC20 * [zetacored tx crosschain add-to-out-tx-tracker](zetacored_tx_crosschain_add-to-out-tx-tracker.md) - Add a out-tx-tracker -* [zetacored tx crosschain gas-price-voter](zetacored_tx_crosschain_gas-price-voter.md) - Broadcast message gasPriceVoter * [zetacored tx crosschain inbound-voter](zetacored_tx_crosschain_inbound-voter.md) - Broadcast message sendVoter * [zetacored tx crosschain migrate-tss-funds](zetacored_tx_crosschain_migrate-tss-funds.md) - Migrate TSS funds to the latest TSS address * [zetacored tx crosschain outbound-voter](zetacored_tx_crosschain_outbound-voter.md) - Broadcast message receiveConfirmation * [zetacored tx crosschain refund-aborted](zetacored_tx_crosschain_refund-aborted.md) - Refund an aborted tx , the refund address is optional, if not provided, the refund will be sent to the sender/tx origin of the cctx. * [zetacored tx crosschain remove-from-out-tx-tracker](zetacored_tx_crosschain_remove-from-out-tx-tracker.md) - Remove a out-tx-tracker * [zetacored tx crosschain update-tss-address](zetacored_tx_crosschain_update-tss-address.md) - Create a new TSSVoter +* [zetacored tx crosschain vote-gas-price](zetacored_tx_crosschain_vote-gas-price.md) - Broadcast message to vote gas price * [zetacored tx crosschain whitelist-erc20](zetacored_tx_crosschain_whitelist-erc20.md) - Add a new erc20 token to whitelist diff --git a/docs/cli/zetacored/zetacored_tx_crosschain_gas-price-voter.md b/docs/cli/zetacored/zetacored_tx_crosschain_vote-gas-price.md similarity index 93% rename from docs/cli/zetacored/zetacored_tx_crosschain_gas-price-voter.md rename to docs/cli/zetacored/zetacored_tx_crosschain_vote-gas-price.md index e3804f9615..26387a22b5 100644 --- a/docs/cli/zetacored/zetacored_tx_crosschain_gas-price-voter.md +++ b/docs/cli/zetacored/zetacored_tx_crosschain_vote-gas-price.md @@ -1,9 +1,9 @@ -# tx crosschain gas-price-voter +# tx crosschain vote-gas-price -Broadcast message gasPriceVoter +Broadcast message to vote gas price ``` -zetacored tx crosschain gas-price-voter [chain] [price] [supply] [blockNumber] [flags] +zetacored tx crosschain vote-gas-price [chain] [price] [supply] [blockNumber] [flags] ``` ### Options @@ -21,7 +21,7 @@ zetacored tx crosschain gas-price-voter [chain] [price] [supply] [blockNumber] [ --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 gas-price-voter + -h, --help help for vote-gas-price --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 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 faf3e60692..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 @@ -27401,30 +27416,249 @@ paths: format: int64 tags: - Query - /zeta-chain/fungible/params: + /zeta-chain/fungible/system_contract: get: - summary: Parameters queries the parameters of the module. - operationId: Query_Params + summary: Queries SystemContract + operationId: Query_SystemContract responses: "200": description: A successful response. schema: - $ref: '#/definitions/zetacorefungibleQueryParamsResponse' + $ref: '#/definitions/fungibleQueryGetSystemContractResponse' default: description: An unexpected error response. schema: $ref: '#/definitions/googlerpcStatus' tags: - Query - /zeta-chain/fungible/system_contract: + /zeta-chain/lightclient/block_headers: get: - summary: Queries SystemContract - operationId: Query_SystemContract + operationId: Query_BlockHeaderAll responses: "200": description: A successful response. schema: - $ref: '#/definitions/fungibleQueryGetSystemContractResponse' + $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: @@ -27664,104 +27898,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. @@ -28070,71 +28206,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 @@ -53519,13 +53590,8 @@ definitions: - sepolia_testnet - goerli_localnet - btc_regtest + - amoy_testnet default: empty - title: |- - - goerli_testnet: Testnet - - goerli_localnet: LocalNet - zeta_localnet = 13; - - btc_regtest: Athens - zeta_athensnet=15; chainsReceiveStatus: type: string enum: @@ -53563,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: @@ -53686,16 +53759,18 @@ definitions: is_removed: type: boolean title: if the tx was removed from the tracker due to no pending cctx - crosschainMsgGasPriceVoterResponse: - type: object crosschainMsgMigrateTssFundsResponse: type: object crosschainMsgRefundAbortedCCTXResponse: type: object crosschainMsgRemoveFromOutTxTrackerResponse: type: object + crosschainMsgUpdateRateLimiterFlagsResponse: + type: object crosschainMsgUpdateTssAddressResponse: type: object + crosschainMsgVoteGasPriceResponse: + type: object crosschainMsgVoteOnObservedInboundTxResponse: type: object crosschainMsgVoteOnObservedOutboundTxResponse: @@ -53911,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: @@ -54111,6 +54209,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: @@ -54138,21 +54302,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: @@ -54160,6 +54309,7 @@ definitions: type: boolean isBtcTypeChainEnabled: type: boolean + title: 'Deprecated(v16): Use VerificationFlags in the lightclient module instead' observerChainNonces: type: object properties: @@ -54238,6 +54388,7 @@ definitions: $ref: '#/definitions/observerGasPriceIncreaseFlags' blockHeaderVerificationFlags: $ref: '#/definitions/observerBlockHeaderVerificationFlags' + title: 'Deprecated(v16): Use VerificationFlags in the lightclient module instead' observerGasPriceIncreaseFlags: type: object properties: @@ -54291,8 +54442,6 @@ definitions: format: int64 observerMsgAddBlameVoteResponse: type: object - observerMsgAddBlockHeaderResponse: - type: object observerMsgAddObserverResponse: type: object observerMsgRemoveChainParamsResponse: @@ -54307,6 +54456,13 @@ definitions: type: object observerMsgUpdateObserverResponse: type: object + observerMsgVoteBlockHeaderResponse: + type: object + properties: + ballot_created: + type: boolean + vote_finalized: + type: boolean observerMsgVoteTSSResponse: type: object properties: @@ -54408,16 +54564,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: @@ -54475,16 +54621,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: @@ -54551,11 +54687,6 @@ definitions: properties: pending_nonces: $ref: '#/definitions/observerPendingNonces' - observerQueryProveResponse: - type: object - properties: - valid: - type: boolean observerQueryShowObserverCountResponse: type: object properties: @@ -54764,16 +54895,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/docs/spec/crosschain/messages.md b/docs/spec/crosschain/messages.md index e64f4bb99a..549b719407 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; @@ -52,16 +48,16 @@ message MsgRemoveFromOutTxTracker { } ``` -## MsgGasPriceVoter +## MsgVoteGasPrice -GasPriceVoter submits information about the connected chain's gas price at a specific block +VoteGasPrice submits information about the connected chain's gas price at a specific block height. Gas price submitted by each validator is recorded separately and a median index is updated. Only observer validators are authorized to broadcast this message. ```proto -message MsgGasPriceVoter { +message MsgVoteGasPrice { string creator = 1; int64 chain_id = 2; uint64 price = 3; @@ -264,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/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/contracts/testconnectorzevm/TestZetaConnectorZEVM.abi b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.abi new file mode 100644 index 0000000000..e268708d01 --- /dev/null +++ b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.abi @@ -0,0 +1,202 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "wzeta_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "FailedZetaSent", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyFungibleModule", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyWZETA", + "type": "error" + }, + { + "inputs": [], + "name": "WZETATransferFailed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "wzeta_", + "type": "address" + } + ], + "name": "SetWZETA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sourceTxOriginAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "zetaTxSenderAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "destinationChainId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "destinationAddress", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "zetaValueAndGas", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "destinationGasLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "message", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "zetaParams", + "type": "bytes" + } + ], + "name": "ZetaSent", + "type": "event" + }, + { + "inputs": [], + "name": "FUNGIBLE_MODULE_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "foo", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "destinationChainId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "destinationAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "destinationGasLimit", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "zetaValueAndGas", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "zetaParams", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.SendInput", + "name": "input", + "type": "tuple" + } + ], + "name": "send", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wzeta_", + "type": "address" + } + ], + "name": "setWzetaAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "wzeta", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] diff --git a/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.bin b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.bin new file mode 100644 index 0000000000..ee9d42e7b5 --- /dev/null +++ b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b50604051610b56380380610b56833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b610a3f806101176000396000f3fe60806040526004361061004d5760003560e01c8062173d46146100de5780633ce4a5bc14610109578063c298557814610134578063eb3bacbd1461015f578063ec02690114610188576100d9565b366100d95760008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146100d7576040517f6e6b6de700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b005b600080fd5b3480156100ea57600080fd5b506100f36101b1565b604051610100919061061b565b60405180910390f35b34801561011557600080fd5b5061011e6101d5565b60405161012b919061061b565b60405180910390f35b34801561014057600080fd5b506101496101ed565b60405161015691906106c6565b60405180910390f35b34801561016b57600080fd5b506101866004803603810190610181919061071e565b61022a565b005b34801561019457600080fd5b506101af60048036038101906101aa919061076f565b61031d565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b73735b14bb79463307aacbed86daf3322b1e6226ab81565b60606040518060400160405280600381526020017f666f6f0000000000000000000000000000000000000000000000000000000000815250905090565b73735b14bb79463307aacbed86daf3322b1e6226ab73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102a3576040517fea02b3f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f7325870b05f8f3412c318a35fc6a74feca51ea15811ec7a257676ca4db9d417681604051610312919061061b565b60405180910390a150565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd333084608001356040518463ffffffff1660e01b815260040161037e939291906107d1565b6020604051808303816000875af115801561039d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103c19190610840565b6103f7576040517fa8c6fd4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d82608001356040518263ffffffff1660e01b8152600401610454919061086d565b600060405180830381600087803b15801561046e57600080fd5b505af1158015610482573d6000803e3d6000fd5b50505050600073735b14bb79463307aacbed86daf3322b1e6226ab73ffffffffffffffffffffffffffffffffffffffff1682608001356040516104c4906108b9565b60006040518083038185875af1925050503d8060008114610501576040519150601f19603f3d011682016040523d82523d6000602084013e610506565b606091505b5050905080610541576040517fc7ffc47b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600001353373ffffffffffffffffffffffffffffffffffffffff167f7ec1c94701e09b1652f3e1d307e60c4b9ebf99aff8c2079fd1d8c585e031c4e43285806020019061058f91906108dd565b876080013588604001358980606001906105a991906108dd565b8b8060a001906105b991906108dd565b6040516105ce9998979695949392919061098d565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610605826105da565b9050919050565b610615816105fa565b82525050565b6000602082019050610630600083018461060c565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610670578082015181840152602081019050610655565b60008484015250505050565b6000601f19601f8301169050919050565b600061069882610636565b6106a28185610641565b93506106b2818560208601610652565b6106bb8161067c565b840191505092915050565b600060208201905081810360008301526106e0818461068d565b905092915050565b600080fd5b600080fd5b6106fb816105fa565b811461070657600080fd5b50565b600081359050610718816106f2565b92915050565b600060208284031215610734576107336106e8565b5b600061074284828501610709565b91505092915050565b600080fd5b600060c082840312156107665761076561074b565b5b81905092915050565b600060208284031215610785576107846106e8565b5b600082013567ffffffffffffffff8111156107a3576107a26106ed565b5b6107af84828501610750565b91505092915050565b6000819050919050565b6107cb816107b8565b82525050565b60006060820190506107e6600083018661060c565b6107f3602083018561060c565b61080060408301846107c2565b949350505050565b60008115159050919050565b61081d81610808565b811461082857600080fd5b50565b60008151905061083a81610814565b92915050565b600060208284031215610856576108556106e8565b5b60006108648482850161082b565b91505092915050565b600060208201905061088260008301846107c2565b92915050565b600081905092915050565b50565b60006108a3600083610888565b91506108ae82610893565b600082019050919050565b60006108c482610896565b9150819050919050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126108fa576108f96108ce565b5b80840192508235915067ffffffffffffffff82111561091c5761091b6108d3565b5b602083019250600182023603831315610938576109376108d8565b5b509250929050565b600082825260208201905092915050565b82818337600083830152505050565b600061096c8385610940565b9350610979838584610951565b6109828361067c565b840190509392505050565b600060c0820190506109a2600083018c61060c565b81810360208301526109b5818a8c610960565b90506109c460408301896107c2565b6109d160608301886107c2565b81810360808301526109e4818688610960565b905081810360a08301526109f9818486610960565b90509a995050505050505050505056fea26469706673582212206647922040def2c6972690c7b621d67ba2619c6888ae0b5c33ce88c440cebffa64736f6c63430008170033 diff --git a/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.go b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.go new file mode 100644 index 0000000000..af4a0eb968 --- /dev/null +++ b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.go @@ -0,0 +1,662 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package testconnectorzevm + +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 + _ = abi.ConvertType +) + +// ZetaInterfacesSendInput is an auto generated low-level Go binding around an user-defined struct. +type ZetaInterfacesSendInput struct { + DestinationChainId *big.Int + DestinationAddress []byte + DestinationGasLimit *big.Int + Message []byte + ZetaValueAndGas *big.Int + ZetaParams []byte +} + +// TestZetaConnectorZEVMMetaData contains all meta data concerning the TestZetaConnectorZEVM contract. +var TestZetaConnectorZEVMMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wzeta_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"FailedZetaSent\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyFungibleModule\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"OnlyWZETA\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"WZETATransferFailed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"wzeta_\",\"type\":\"address\"}],\"name\":\"SetWZETA\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sourceTxOriginAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"zetaTxSenderAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"destinationChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"destinationAddress\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"zetaValueAndGas\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"destinationGasLimit\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"zetaParams\",\"type\":\"bytes\"}],\"name\":\"ZetaSent\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"FUNGIBLE_MODULE_ADDRESS\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"foo\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"destinationChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"destinationAddress\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"destinationGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"zetaValueAndGas\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"zetaParams\",\"type\":\"bytes\"}],\"internalType\":\"structZetaInterfaces.SendInput\",\"name\":\"input\",\"type\":\"tuple\"}],\"name\":\"send\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wzeta_\",\"type\":\"address\"}],\"name\":\"setWzetaAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"wzeta\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x608060405234801561001057600080fd5b50604051610b56380380610b56833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b610a3f806101176000396000f3fe60806040526004361061004d5760003560e01c8062173d46146100de5780633ce4a5bc14610109578063c298557814610134578063eb3bacbd1461015f578063ec02690114610188576100d9565b366100d95760008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146100d7576040517f6e6b6de700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b005b600080fd5b3480156100ea57600080fd5b506100f36101b1565b604051610100919061061b565b60405180910390f35b34801561011557600080fd5b5061011e6101d5565b60405161012b919061061b565b60405180910390f35b34801561014057600080fd5b506101496101ed565b60405161015691906106c6565b60405180910390f35b34801561016b57600080fd5b506101866004803603810190610181919061071e565b61022a565b005b34801561019457600080fd5b506101af60048036038101906101aa919061076f565b61031d565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b73735b14bb79463307aacbed86daf3322b1e6226ab81565b60606040518060400160405280600381526020017f666f6f0000000000000000000000000000000000000000000000000000000000815250905090565b73735b14bb79463307aacbed86daf3322b1e6226ab73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102a3576040517fea02b3f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f7325870b05f8f3412c318a35fc6a74feca51ea15811ec7a257676ca4db9d417681604051610312919061061b565b60405180910390a150565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd333084608001356040518463ffffffff1660e01b815260040161037e939291906107d1565b6020604051808303816000875af115801561039d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103c19190610840565b6103f7576040517fa8c6fd4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d82608001356040518263ffffffff1660e01b8152600401610454919061086d565b600060405180830381600087803b15801561046e57600080fd5b505af1158015610482573d6000803e3d6000fd5b50505050600073735b14bb79463307aacbed86daf3322b1e6226ab73ffffffffffffffffffffffffffffffffffffffff1682608001356040516104c4906108b9565b60006040518083038185875af1925050503d8060008114610501576040519150601f19603f3d011682016040523d82523d6000602084013e610506565b606091505b5050905080610541576040517fc7ffc47b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600001353373ffffffffffffffffffffffffffffffffffffffff167f7ec1c94701e09b1652f3e1d307e60c4b9ebf99aff8c2079fd1d8c585e031c4e43285806020019061058f91906108dd565b876080013588604001358980606001906105a991906108dd565b8b8060a001906105b991906108dd565b6040516105ce9998979695949392919061098d565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610605826105da565b9050919050565b610615816105fa565b82525050565b6000602082019050610630600083018461060c565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610670578082015181840152602081019050610655565b60008484015250505050565b6000601f19601f8301169050919050565b600061069882610636565b6106a28185610641565b93506106b2818560208601610652565b6106bb8161067c565b840191505092915050565b600060208201905081810360008301526106e0818461068d565b905092915050565b600080fd5b600080fd5b6106fb816105fa565b811461070657600080fd5b50565b600081359050610718816106f2565b92915050565b600060208284031215610734576107336106e8565b5b600061074284828501610709565b91505092915050565b600080fd5b600060c082840312156107665761076561074b565b5b81905092915050565b600060208284031215610785576107846106e8565b5b600082013567ffffffffffffffff8111156107a3576107a26106ed565b5b6107af84828501610750565b91505092915050565b6000819050919050565b6107cb816107b8565b82525050565b60006060820190506107e6600083018661060c565b6107f3602083018561060c565b61080060408301846107c2565b949350505050565b60008115159050919050565b61081d81610808565b811461082857600080fd5b50565b60008151905061083a81610814565b92915050565b600060208284031215610856576108556106e8565b5b60006108648482850161082b565b91505092915050565b600060208201905061088260008301846107c2565b92915050565b600081905092915050565b50565b60006108a3600083610888565b91506108ae82610893565b600082019050919050565b60006108c482610896565b9150819050919050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126108fa576108f96108ce565b5b80840192508235915067ffffffffffffffff82111561091c5761091b6108d3565b5b602083019250600182023603831315610938576109376108d8565b5b509250929050565b600082825260208201905092915050565b82818337600083830152505050565b600061096c8385610940565b9350610979838584610951565b6109828361067c565b840190509392505050565b600060c0820190506109a2600083018c61060c565b81810360208301526109b5818a8c610960565b90506109c460408301896107c2565b6109d160608301886107c2565b81810360808301526109e4818688610960565b905081810360a08301526109f9818486610960565b90509a995050505050505050505056fea26469706673582212206647922040def2c6972690c7b621d67ba2619c6888ae0b5c33ce88c440cebffa64736f6c63430008170033", +} + +// TestZetaConnectorZEVMABI is the input ABI used to generate the binding from. +// Deprecated: Use TestZetaConnectorZEVMMetaData.ABI instead. +var TestZetaConnectorZEVMABI = TestZetaConnectorZEVMMetaData.ABI + +// TestZetaConnectorZEVMBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use TestZetaConnectorZEVMMetaData.Bin instead. +var TestZetaConnectorZEVMBin = TestZetaConnectorZEVMMetaData.Bin + +// DeployTestZetaConnectorZEVM deploys a new Ethereum contract, binding an instance of TestZetaConnectorZEVM to it. +func DeployTestZetaConnectorZEVM(auth *bind.TransactOpts, backend bind.ContractBackend, wzeta_ common.Address) (common.Address, *types.Transaction, *TestZetaConnectorZEVM, error) { + parsed, err := TestZetaConnectorZEVMMetaData.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(TestZetaConnectorZEVMBin), backend, wzeta_) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &TestZetaConnectorZEVM{TestZetaConnectorZEVMCaller: TestZetaConnectorZEVMCaller{contract: contract}, TestZetaConnectorZEVMTransactor: TestZetaConnectorZEVMTransactor{contract: contract}, TestZetaConnectorZEVMFilterer: TestZetaConnectorZEVMFilterer{contract: contract}}, nil +} + +// TestZetaConnectorZEVM is an auto generated Go binding around an Ethereum contract. +type TestZetaConnectorZEVM struct { + TestZetaConnectorZEVMCaller // Read-only binding to the contract + TestZetaConnectorZEVMTransactor // Write-only binding to the contract + TestZetaConnectorZEVMFilterer // Log filterer for contract events +} + +// TestZetaConnectorZEVMCaller is an auto generated read-only Go binding around an Ethereum contract. +type TestZetaConnectorZEVMCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TestZetaConnectorZEVMTransactor is an auto generated write-only Go binding around an Ethereum contract. +type TestZetaConnectorZEVMTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TestZetaConnectorZEVMFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TestZetaConnectorZEVMFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// TestZetaConnectorZEVMSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type TestZetaConnectorZEVMSession struct { + Contract *TestZetaConnectorZEVM // 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 +} + +// TestZetaConnectorZEVMCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type TestZetaConnectorZEVMCallerSession struct { + Contract *TestZetaConnectorZEVMCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// TestZetaConnectorZEVMTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type TestZetaConnectorZEVMTransactorSession struct { + Contract *TestZetaConnectorZEVMTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// TestZetaConnectorZEVMRaw is an auto generated low-level Go binding around an Ethereum contract. +type TestZetaConnectorZEVMRaw struct { + Contract *TestZetaConnectorZEVM // Generic contract binding to access the raw methods on +} + +// TestZetaConnectorZEVMCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TestZetaConnectorZEVMCallerRaw struct { + Contract *TestZetaConnectorZEVMCaller // Generic read-only contract binding to access the raw methods on +} + +// TestZetaConnectorZEVMTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TestZetaConnectorZEVMTransactorRaw struct { + Contract *TestZetaConnectorZEVMTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewTestZetaConnectorZEVM creates a new instance of TestZetaConnectorZEVM, bound to a specific deployed contract. +func NewTestZetaConnectorZEVM(address common.Address, backend bind.ContractBackend) (*TestZetaConnectorZEVM, error) { + contract, err := bindTestZetaConnectorZEVM(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &TestZetaConnectorZEVM{TestZetaConnectorZEVMCaller: TestZetaConnectorZEVMCaller{contract: contract}, TestZetaConnectorZEVMTransactor: TestZetaConnectorZEVMTransactor{contract: contract}, TestZetaConnectorZEVMFilterer: TestZetaConnectorZEVMFilterer{contract: contract}}, nil +} + +// NewTestZetaConnectorZEVMCaller creates a new read-only instance of TestZetaConnectorZEVM, bound to a specific deployed contract. +func NewTestZetaConnectorZEVMCaller(address common.Address, caller bind.ContractCaller) (*TestZetaConnectorZEVMCaller, error) { + contract, err := bindTestZetaConnectorZEVM(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &TestZetaConnectorZEVMCaller{contract: contract}, nil +} + +// NewTestZetaConnectorZEVMTransactor creates a new write-only instance of TestZetaConnectorZEVM, bound to a specific deployed contract. +func NewTestZetaConnectorZEVMTransactor(address common.Address, transactor bind.ContractTransactor) (*TestZetaConnectorZEVMTransactor, error) { + contract, err := bindTestZetaConnectorZEVM(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &TestZetaConnectorZEVMTransactor{contract: contract}, nil +} + +// NewTestZetaConnectorZEVMFilterer creates a new log filterer instance of TestZetaConnectorZEVM, bound to a specific deployed contract. +func NewTestZetaConnectorZEVMFilterer(address common.Address, filterer bind.ContractFilterer) (*TestZetaConnectorZEVMFilterer, error) { + contract, err := bindTestZetaConnectorZEVM(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &TestZetaConnectorZEVMFilterer{contract: contract}, nil +} + +// bindTestZetaConnectorZEVM binds a generic wrapper to an already deployed contract. +func bindTestZetaConnectorZEVM(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := TestZetaConnectorZEVMMetaData.GetAbi() + 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 (_TestZetaConnectorZEVM *TestZetaConnectorZEVMRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TestZetaConnectorZEVM.Contract.TestZetaConnectorZEVMCaller.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 (_TestZetaConnectorZEVM *TestZetaConnectorZEVMRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.TestZetaConnectorZEVMTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.TestZetaConnectorZEVMTransactor.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 (_TestZetaConnectorZEVM *TestZetaConnectorZEVMCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _TestZetaConnectorZEVM.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 (_TestZetaConnectorZEVM *TestZetaConnectorZEVMTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.contract.Transact(opts, method, params...) +} + +// FUNGIBLEMODULEADDRESS is a free data retrieval call binding the contract method 0x3ce4a5bc. +// +// Solidity: function FUNGIBLE_MODULE_ADDRESS() view returns(address) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMCaller) FUNGIBLEMODULEADDRESS(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _TestZetaConnectorZEVM.contract.Call(opts, &out, "FUNGIBLE_MODULE_ADDRESS") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// FUNGIBLEMODULEADDRESS is a free data retrieval call binding the contract method 0x3ce4a5bc. +// +// Solidity: function FUNGIBLE_MODULE_ADDRESS() view returns(address) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMSession) FUNGIBLEMODULEADDRESS() (common.Address, error) { + return _TestZetaConnectorZEVM.Contract.FUNGIBLEMODULEADDRESS(&_TestZetaConnectorZEVM.CallOpts) +} + +// FUNGIBLEMODULEADDRESS is a free data retrieval call binding the contract method 0x3ce4a5bc. +// +// Solidity: function FUNGIBLE_MODULE_ADDRESS() view returns(address) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMCallerSession) FUNGIBLEMODULEADDRESS() (common.Address, error) { + return _TestZetaConnectorZEVM.Contract.FUNGIBLEMODULEADDRESS(&_TestZetaConnectorZEVM.CallOpts) +} + +// Foo is a free data retrieval call binding the contract method 0xc2985578. +// +// Solidity: function foo() pure returns(string) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMCaller) Foo(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _TestZetaConnectorZEVM.contract.Call(opts, &out, "foo") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Foo is a free data retrieval call binding the contract method 0xc2985578. +// +// Solidity: function foo() pure returns(string) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMSession) Foo() (string, error) { + return _TestZetaConnectorZEVM.Contract.Foo(&_TestZetaConnectorZEVM.CallOpts) +} + +// Foo is a free data retrieval call binding the contract method 0xc2985578. +// +// Solidity: function foo() pure returns(string) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMCallerSession) Foo() (string, error) { + return _TestZetaConnectorZEVM.Contract.Foo(&_TestZetaConnectorZEVM.CallOpts) +} + +// Wzeta is a free data retrieval call binding the contract method 0x00173d46. +// +// Solidity: function wzeta() view returns(address) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMCaller) Wzeta(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _TestZetaConnectorZEVM.contract.Call(opts, &out, "wzeta") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Wzeta is a free data retrieval call binding the contract method 0x00173d46. +// +// Solidity: function wzeta() view returns(address) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMSession) Wzeta() (common.Address, error) { + return _TestZetaConnectorZEVM.Contract.Wzeta(&_TestZetaConnectorZEVM.CallOpts) +} + +// Wzeta is a free data retrieval call binding the contract method 0x00173d46. +// +// Solidity: function wzeta() view returns(address) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMCallerSession) Wzeta() (common.Address, error) { + return _TestZetaConnectorZEVM.Contract.Wzeta(&_TestZetaConnectorZEVM.CallOpts) +} + +// Send is a paid mutator transaction binding the contract method 0xec026901. +// +// Solidity: function send((uint256,bytes,uint256,bytes,uint256,bytes) input) returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMTransactor) Send(opts *bind.TransactOpts, input ZetaInterfacesSendInput) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.contract.Transact(opts, "send", input) +} + +// Send is a paid mutator transaction binding the contract method 0xec026901. +// +// Solidity: function send((uint256,bytes,uint256,bytes,uint256,bytes) input) returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMSession) Send(input ZetaInterfacesSendInput) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.Send(&_TestZetaConnectorZEVM.TransactOpts, input) +} + +// Send is a paid mutator transaction binding the contract method 0xec026901. +// +// Solidity: function send((uint256,bytes,uint256,bytes,uint256,bytes) input) returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMTransactorSession) Send(input ZetaInterfacesSendInput) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.Send(&_TestZetaConnectorZEVM.TransactOpts, input) +} + +// SetWzetaAddress is a paid mutator transaction binding the contract method 0xeb3bacbd. +// +// Solidity: function setWzetaAddress(address wzeta_) returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMTransactor) SetWzetaAddress(opts *bind.TransactOpts, wzeta_ common.Address) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.contract.Transact(opts, "setWzetaAddress", wzeta_) +} + +// SetWzetaAddress is a paid mutator transaction binding the contract method 0xeb3bacbd. +// +// Solidity: function setWzetaAddress(address wzeta_) returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMSession) SetWzetaAddress(wzeta_ common.Address) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.SetWzetaAddress(&_TestZetaConnectorZEVM.TransactOpts, wzeta_) +} + +// SetWzetaAddress is a paid mutator transaction binding the contract method 0xeb3bacbd. +// +// Solidity: function setWzetaAddress(address wzeta_) returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMTransactorSession) SetWzetaAddress(wzeta_ common.Address) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.SetWzetaAddress(&_TestZetaConnectorZEVM.TransactOpts, wzeta_) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _TestZetaConnectorZEVM.contract.RawTransact(opts, nil) // calldata is disallowed for receive function +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMSession) Receive() (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.Receive(&_TestZetaConnectorZEVM.TransactOpts) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMTransactorSession) Receive() (*types.Transaction, error) { + return _TestZetaConnectorZEVM.Contract.Receive(&_TestZetaConnectorZEVM.TransactOpts) +} + +// TestZetaConnectorZEVMSetWZETAIterator is returned from FilterSetWZETA and is used to iterate over the raw logs and unpacked data for SetWZETA events raised by the TestZetaConnectorZEVM contract. +type TestZetaConnectorZEVMSetWZETAIterator struct { + Event *TestZetaConnectorZEVMSetWZETA // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TestZetaConnectorZEVMSetWZETAIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TestZetaConnectorZEVMSetWZETA) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TestZetaConnectorZEVMSetWZETA) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TestZetaConnectorZEVMSetWZETAIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TestZetaConnectorZEVMSetWZETAIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TestZetaConnectorZEVMSetWZETA represents a SetWZETA event raised by the TestZetaConnectorZEVM contract. +type TestZetaConnectorZEVMSetWZETA struct { + Wzeta common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSetWZETA is a free log retrieval operation binding the contract event 0x7325870b05f8f3412c318a35fc6a74feca51ea15811ec7a257676ca4db9d4176. +// +// Solidity: event SetWZETA(address wzeta_) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMFilterer) FilterSetWZETA(opts *bind.FilterOpts) (*TestZetaConnectorZEVMSetWZETAIterator, error) { + + logs, sub, err := _TestZetaConnectorZEVM.contract.FilterLogs(opts, "SetWZETA") + if err != nil { + return nil, err + } + return &TestZetaConnectorZEVMSetWZETAIterator{contract: _TestZetaConnectorZEVM.contract, event: "SetWZETA", logs: logs, sub: sub}, nil +} + +// WatchSetWZETA is a free log subscription operation binding the contract event 0x7325870b05f8f3412c318a35fc6a74feca51ea15811ec7a257676ca4db9d4176. +// +// Solidity: event SetWZETA(address wzeta_) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMFilterer) WatchSetWZETA(opts *bind.WatchOpts, sink chan<- *TestZetaConnectorZEVMSetWZETA) (event.Subscription, error) { + + logs, sub, err := _TestZetaConnectorZEVM.contract.WatchLogs(opts, "SetWZETA") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TestZetaConnectorZEVMSetWZETA) + if err := _TestZetaConnectorZEVM.contract.UnpackLog(event, "SetWZETA", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSetWZETA is a log parse operation binding the contract event 0x7325870b05f8f3412c318a35fc6a74feca51ea15811ec7a257676ca4db9d4176. +// +// Solidity: event SetWZETA(address wzeta_) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMFilterer) ParseSetWZETA(log types.Log) (*TestZetaConnectorZEVMSetWZETA, error) { + event := new(TestZetaConnectorZEVMSetWZETA) + if err := _TestZetaConnectorZEVM.contract.UnpackLog(event, "SetWZETA", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// TestZetaConnectorZEVMZetaSentIterator is returned from FilterZetaSent and is used to iterate over the raw logs and unpacked data for ZetaSent events raised by the TestZetaConnectorZEVM contract. +type TestZetaConnectorZEVMZetaSentIterator struct { + Event *TestZetaConnectorZEVMZetaSent // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *TestZetaConnectorZEVMZetaSentIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(TestZetaConnectorZEVMZetaSent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(TestZetaConnectorZEVMZetaSent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *TestZetaConnectorZEVMZetaSentIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *TestZetaConnectorZEVMZetaSentIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// TestZetaConnectorZEVMZetaSent represents a ZetaSent event raised by the TestZetaConnectorZEVM contract. +type TestZetaConnectorZEVMZetaSent struct { + SourceTxOriginAddress common.Address + ZetaTxSenderAddress common.Address + DestinationChainId *big.Int + DestinationAddress []byte + ZetaValueAndGas *big.Int + DestinationGasLimit *big.Int + Message []byte + ZetaParams []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterZetaSent is a free log retrieval operation binding the contract event 0x7ec1c94701e09b1652f3e1d307e60c4b9ebf99aff8c2079fd1d8c585e031c4e4. +// +// Solidity: event ZetaSent(address sourceTxOriginAddress, address indexed zetaTxSenderAddress, uint256 indexed destinationChainId, bytes destinationAddress, uint256 zetaValueAndGas, uint256 destinationGasLimit, bytes message, bytes zetaParams) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMFilterer) FilterZetaSent(opts *bind.FilterOpts, zetaTxSenderAddress []common.Address, destinationChainId []*big.Int) (*TestZetaConnectorZEVMZetaSentIterator, error) { + + var zetaTxSenderAddressRule []interface{} + for _, zetaTxSenderAddressItem := range zetaTxSenderAddress { + zetaTxSenderAddressRule = append(zetaTxSenderAddressRule, zetaTxSenderAddressItem) + } + var destinationChainIdRule []interface{} + for _, destinationChainIdItem := range destinationChainId { + destinationChainIdRule = append(destinationChainIdRule, destinationChainIdItem) + } + + logs, sub, err := _TestZetaConnectorZEVM.contract.FilterLogs(opts, "ZetaSent", zetaTxSenderAddressRule, destinationChainIdRule) + if err != nil { + return nil, err + } + return &TestZetaConnectorZEVMZetaSentIterator{contract: _TestZetaConnectorZEVM.contract, event: "ZetaSent", logs: logs, sub: sub}, nil +} + +// WatchZetaSent is a free log subscription operation binding the contract event 0x7ec1c94701e09b1652f3e1d307e60c4b9ebf99aff8c2079fd1d8c585e031c4e4. +// +// Solidity: event ZetaSent(address sourceTxOriginAddress, address indexed zetaTxSenderAddress, uint256 indexed destinationChainId, bytes destinationAddress, uint256 zetaValueAndGas, uint256 destinationGasLimit, bytes message, bytes zetaParams) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMFilterer) WatchZetaSent(opts *bind.WatchOpts, sink chan<- *TestZetaConnectorZEVMZetaSent, zetaTxSenderAddress []common.Address, destinationChainId []*big.Int) (event.Subscription, error) { + + var zetaTxSenderAddressRule []interface{} + for _, zetaTxSenderAddressItem := range zetaTxSenderAddress { + zetaTxSenderAddressRule = append(zetaTxSenderAddressRule, zetaTxSenderAddressItem) + } + var destinationChainIdRule []interface{} + for _, destinationChainIdItem := range destinationChainId { + destinationChainIdRule = append(destinationChainIdRule, destinationChainIdItem) + } + + logs, sub, err := _TestZetaConnectorZEVM.contract.WatchLogs(opts, "ZetaSent", zetaTxSenderAddressRule, destinationChainIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(TestZetaConnectorZEVMZetaSent) + if err := _TestZetaConnectorZEVM.contract.UnpackLog(event, "ZetaSent", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseZetaSent is a log parse operation binding the contract event 0x7ec1c94701e09b1652f3e1d307e60c4b9ebf99aff8c2079fd1d8c585e031c4e4. +// +// Solidity: event ZetaSent(address sourceTxOriginAddress, address indexed zetaTxSenderAddress, uint256 indexed destinationChainId, bytes destinationAddress, uint256 zetaValueAndGas, uint256 destinationGasLimit, bytes message, bytes zetaParams) +func (_TestZetaConnectorZEVM *TestZetaConnectorZEVMFilterer) ParseZetaSent(log types.Log) (*TestZetaConnectorZEVMZetaSent, error) { + event := new(TestZetaConnectorZEVMZetaSent) + if err := _TestZetaConnectorZEVM.contract.UnpackLog(event, "ZetaSent", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.json b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.json new file mode 100644 index 0000000000..f8e2ec7acc --- /dev/null +++ b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.json @@ -0,0 +1,205 @@ +{ + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "wzeta_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "FailedZetaSent", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyFungibleModule", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyWZETA", + "type": "error" + }, + { + "inputs": [], + "name": "WZETATransferFailed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "wzeta_", + "type": "address" + } + ], + "name": "SetWZETA", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sourceTxOriginAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "zetaTxSenderAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "destinationChainId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "destinationAddress", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "zetaValueAndGas", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "destinationGasLimit", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "message", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "zetaParams", + "type": "bytes" + } + ], + "name": "ZetaSent", + "type": "event" + }, + { + "inputs": [], + "name": "FUNGIBLE_MODULE_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "foo", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "destinationChainId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "destinationAddress", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "destinationGasLimit", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "zetaValueAndGas", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "zetaParams", + "type": "bytes" + } + ], + "internalType": "struct ZetaInterfaces.SendInput", + "name": "input", + "type": "tuple" + } + ], + "name": "send", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "wzeta_", + "type": "address" + } + ], + "name": "setWzetaAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "wzeta", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "bin": "608060405234801561001057600080fd5b50604051610b56380380610b56833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b610a3f806101176000396000f3fe60806040526004361061004d5760003560e01c8062173d46146100de5780633ce4a5bc14610109578063c298557814610134578063eb3bacbd1461015f578063ec02690114610188576100d9565b366100d95760008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146100d7576040517f6e6b6de700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b005b600080fd5b3480156100ea57600080fd5b506100f36101b1565b604051610100919061061b565b60405180910390f35b34801561011557600080fd5b5061011e6101d5565b60405161012b919061061b565b60405180910390f35b34801561014057600080fd5b506101496101ed565b60405161015691906106c6565b60405180910390f35b34801561016b57600080fd5b506101866004803603810190610181919061071e565b61022a565b005b34801561019457600080fd5b506101af60048036038101906101aa919061076f565b61031d565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b73735b14bb79463307aacbed86daf3322b1e6226ab81565b60606040518060400160405280600381526020017f666f6f0000000000000000000000000000000000000000000000000000000000815250905090565b73735b14bb79463307aacbed86daf3322b1e6226ab73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102a3576040517fea02b3f300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f7325870b05f8f3412c318a35fc6a74feca51ea15811ec7a257676ca4db9d417681604051610312919061061b565b60405180910390a150565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd333084608001356040518463ffffffff1660e01b815260040161037e939291906107d1565b6020604051808303816000875af115801561039d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103c19190610840565b6103f7576040517fa8c6fd4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d82608001356040518263ffffffff1660e01b8152600401610454919061086d565b600060405180830381600087803b15801561046e57600080fd5b505af1158015610482573d6000803e3d6000fd5b50505050600073735b14bb79463307aacbed86daf3322b1e6226ab73ffffffffffffffffffffffffffffffffffffffff1682608001356040516104c4906108b9565b60006040518083038185875af1925050503d8060008114610501576040519150601f19603f3d011682016040523d82523d6000602084013e610506565b606091505b5050905080610541576040517fc7ffc47b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600001353373ffffffffffffffffffffffffffffffffffffffff167f7ec1c94701e09b1652f3e1d307e60c4b9ebf99aff8c2079fd1d8c585e031c4e43285806020019061058f91906108dd565b876080013588604001358980606001906105a991906108dd565b8b8060a001906105b991906108dd565b6040516105ce9998979695949392919061098d565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610605826105da565b9050919050565b610615816105fa565b82525050565b6000602082019050610630600083018461060c565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610670578082015181840152602081019050610655565b60008484015250505050565b6000601f19601f8301169050919050565b600061069882610636565b6106a28185610641565b93506106b2818560208601610652565b6106bb8161067c565b840191505092915050565b600060208201905081810360008301526106e0818461068d565b905092915050565b600080fd5b600080fd5b6106fb816105fa565b811461070657600080fd5b50565b600081359050610718816106f2565b92915050565b600060208284031215610734576107336106e8565b5b600061074284828501610709565b91505092915050565b600080fd5b600060c082840312156107665761076561074b565b5b81905092915050565b600060208284031215610785576107846106e8565b5b600082013567ffffffffffffffff8111156107a3576107a26106ed565b5b6107af84828501610750565b91505092915050565b6000819050919050565b6107cb816107b8565b82525050565b60006060820190506107e6600083018661060c565b6107f3602083018561060c565b61080060408301846107c2565b949350505050565b60008115159050919050565b61081d81610808565b811461082857600080fd5b50565b60008151905061083a81610814565b92915050565b600060208284031215610856576108556106e8565b5b60006108648482850161082b565b91505092915050565b600060208201905061088260008301846107c2565b92915050565b600081905092915050565b50565b60006108a3600083610888565b91506108ae82610893565b600082019050919050565b60006108c482610896565b9150819050919050565b600080fd5b600080fd5b600080fd5b600080833560016020038436030381126108fa576108f96108ce565b5b80840192508235915067ffffffffffffffff82111561091c5761091b6108d3565b5b602083019250600182023603831315610938576109376108d8565b5b509250929050565b600082825260208201905092915050565b82818337600083830152505050565b600061096c8385610940565b9350610979838584610951565b6109828361067c565b840190509392505050565b600060c0820190506109a2600083018c61060c565b81810360208301526109b5818a8c610960565b90506109c460408301896107c2565b6109d160608301886107c2565b81810360808301526109e4818688610960565b905081810360a08301526109f9818486610960565b90509a995050505050505050505056fea26469706673582212206647922040def2c6972690c7b621d67ba2619c6888ae0b5c33ce88c440cebffa64736f6c63430008170033" +} diff --git a/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.sol b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.sol new file mode 100644 index 0000000000..2f9f1b1a1c --- /dev/null +++ b/e2e/contracts/testconnectorzevm/TestZetaConnectorZEVM.sol @@ -0,0 +1,123 @@ +// 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; + } +} + +interface WZETA { + function transferFrom(address src, address dst, uint wad) external returns (bool); + + function withdraw(uint wad) external; +} + +contract TestZetaConnectorZEVM is ZetaInterfaces { + /// @notice Contract custom errors. + error OnlyWZETA(); + error WZETATransferFailed(); + error OnlyFungibleModule(); + error FailedZetaSent(); + + /// @notice Fungible module address. + address public constant FUNGIBLE_MODULE_ADDRESS = payable(0x735b14BB79463307AAcBED86DAf3322B1e6226aB); + /// @notice WZETA token address. + address public wzeta; + + event ZetaSent( + address sourceTxOriginAddress, + address indexed zetaTxSenderAddress, + uint256 indexed destinationChainId, + bytes destinationAddress, + uint256 zetaValueAndGas, + uint256 destinationGasLimit, + bytes message, + bytes zetaParams + ); + event SetWZETA(address wzeta_); + + constructor(address wzeta_) { + wzeta = wzeta_; + } + + /// @dev Receive function to receive ZETA from WETH9.withdraw(). + receive() external payable { + if (msg.sender != wzeta) revert OnlyWZETA(); + } + + /** + * @dev Sends ZETA and bytes messages (to execute it) crosschain. + * @param input, SendInput struct, checkout above. + */ + function send(ZetaInterfaces.SendInput calldata input) external { + // Transfer wzeta to "fungible" module, which will be burnt by the protocol post processing via hooks. + if (!WZETA(wzeta).transferFrom(msg.sender, address(this), input.zetaValueAndGas)) revert WZETATransferFailed(); + WZETA(wzeta).withdraw(input.zetaValueAndGas); + (bool sent, ) = FUNGIBLE_MODULE_ADDRESS.call{value: input.zetaValueAndGas}(""); + if (!sent) revert FailedZetaSent(); + emit ZetaSent( + tx.origin, + msg.sender, + input.destinationChainId, + input.destinationAddress, + input.zetaValueAndGas, + input.destinationGasLimit, + input.message, + input.zetaParams + ); + } + + /** + * @dev Sends ZETA and bytes messages (to execute it) crosschain. + * @param wzeta_, new WZETA address. + */ + function setWzetaAddress(address wzeta_) external { + if (msg.sender != FUNGIBLE_MODULE_ADDRESS) revert OnlyFungibleModule(); + wzeta = wzeta_; + emit SetWZETA(wzeta_); + } + + function foo() external pure returns (string memory) { + return "foo"; + } +} \ No newline at end of file diff --git a/e2e/contracts/testconnectorzevm/bindings.go b/e2e/contracts/testconnectorzevm/bindings.go new file mode 100644 index 0000000000..11332c8440 --- /dev/null +++ b/e2e/contracts/testconnectorzevm/bindings.go @@ -0,0 +1,6 @@ +//go:generate sh -c "solc --evm-version paris TestZetaConnectorZEVM.sol --combined-json abi,bin | jq '.contracts.\"TestZetaConnectorZEVM.sol:TestZetaConnectorZEVM\"' > TestZetaConnectorZEVM.json" +//go:generate sh -c "cat TestZetaConnectorZEVM.json | jq .abi > TestZetaConnectorZEVM.abi" +//go:generate sh -c "cat TestZetaConnectorZEVM.json | jq .bin | tr -d '\"' > TestZetaConnectorZEVM.bin" +//go:generate sh -c "abigen --abi TestZetaConnectorZEVM.abi --bin TestZetaConnectorZEVM.bin --pkg testconnectorzevm --type TestZetaConnectorZEVM --out TestZetaConnectorZEVM.go" + +package testconnectorzevm diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 404616535f..765194c425 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -49,9 +49,10 @@ const ( TestStressBTCDepositName = "stress_btc_deposit" // Admin test - TestMigrateChainSupportName = "migrate_chain_support" - TestPauseZRC20Name = "pause_zrc20" - TestUpdateBytecodeName = "update_bytecode" + TestMigrateChainSupportName = "migrate_chain_support" + TestPauseZRC20Name = "pause_zrc20" + TestUpdateBytecodeZRC20Name = "update_bytecode_zrc20" + TestUpdateBytecodeConnectorName = "update_bytecode_connector" ) // AllE2ETests is an ordered list of all e2e tests @@ -224,10 +225,10 @@ var AllE2ETests = []runner.E2ETest{ TestERC20DepositAndCallRefund, ), runner.NewE2ETest( - TestUpdateBytecodeName, + TestUpdateBytecodeZRC20Name, "update ZRC20 bytecode swap", []runner.ArgDefinition{}, - TestUpdateBytecode, + TestUpdateBytecodeZRC20, ), runner.NewE2ETest( TestEtherDepositAndCallName, @@ -365,4 +366,10 @@ var AllE2ETests = []runner.E2ETest{ []runner.ArgDefinition{}, TestMigrateChainSupport, ), + runner.NewE2ETest( + TestUpdateBytecodeConnectorName, + "update zevm connector bytecode", + []runner.ArgDefinition{}, + TestUpdateBytecodeConnector, + ), } 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/e2etests/test_update_bytecode_connector.go b/e2e/e2etests/test_update_bytecode_connector.go new file mode 100644 index 0000000000..0770e80dc4 --- /dev/null +++ b/e2e/e2etests/test_update_bytecode_connector.go @@ -0,0 +1,70 @@ +package e2etests + +import ( + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/zeta-chain/zetacore/e2e/contracts/testconnectorzevm" + "github.com/zeta-chain/zetacore/e2e/runner" + "github.com/zeta-chain/zetacore/e2e/utils" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" +) + +// TestUpdateBytecodeConnector tests updating the bytecode of a connector and interact with it +func TestUpdateBytecodeConnector(r *runner.E2ERunner, _ []string) { + // Can withdraw 0.1ZETA + TestZetaWithdraw(r, []string{"10000000000000000000"}) + + // Deploy the test contract + newTestConnectorAddr, tx, _, err := testconnectorzevm.DeployTestZetaConnectorZEVM( + r.ZEVMAuth, + r.ZEVMClient, + r.WZetaAddr, + ) + if err != nil { + panic(err) + } + + // Wait for the contract to be deployed + receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + if receipt.Status != 1 { + panic("contract deployment failed") + } + + // Get the code hash of the new contract + codeHashRes, err := r.FungibleClient.CodeHash(r.Ctx, &fungibletypes.QueryCodeHashRequest{ + Address: newTestConnectorAddr.String(), + }) + if err != nil { + panic(err) + } + r.Logger.Info("New contract code hash: %s", codeHashRes.CodeHash) + + r.Logger.Info("Updating the bytecode of the Connector") + msg := fungibletypes.NewMsgUpdateContractBytecode( + r.ZetaTxServer.GetAccountAddress(0), + r.ConnectorZEVMAddr.Hex(), + codeHashRes.CodeHash, + ) + res, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) + if err != nil { + panic(err) + } + r.Logger.Info("Update connector bytecode tx hash: %s", res.TxHash) + + r.Logger.Info("Can interact with the new code of the contract") + testConnectorContract, err := testconnectorzevm.NewTestZetaConnectorZEVM(r.ConnectorZEVMAddr, r.ZEVMClient) + if err != nil { + panic(err) + } + + response, err := testConnectorContract.Foo(&bind.CallOpts{}) + if err != nil { + panic(err) + } + + if response != "foo" { + panic("unexpected response") + } + + // Can continue to interact with the connector: withdraw 0.1ZETA + TestZetaWithdraw(r, []string{"10000000000000000000"}) +} diff --git a/e2e/e2etests/test_update_bytecode.go b/e2e/e2etests/test_update_bytecode_zrc20.go similarity index 97% rename from e2e/e2etests/test_update_bytecode.go rename to e2e/e2etests/test_update_bytecode_zrc20.go index a36af1db7c..d5730415bf 100644 --- a/e2e/e2etests/test_update_bytecode.go +++ b/e2e/e2etests/test_update_bytecode_zrc20.go @@ -12,8 +12,8 @@ import ( fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" ) -// TestUpdateBytecode tests updating the bytecode of a zrc20 and interact with it -func TestUpdateBytecode(r *runner.E2ERunner, _ []string) { +// TestUpdateBytecodeZRC20 tests updating the bytecode of a zrc20 and interact with it +func TestUpdateBytecodeZRC20(r *runner.E2ERunner, _ []string) { // Random approval approved := sample.EthAddress() tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, approved, big.NewInt(1e10)) 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 f3d946ff5c..d6d804c81e 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,12 +35,15 @@ 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" + 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" ) @@ -48,11 +53,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 +108,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 +164,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 +196,79 @@ 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 { + return mkTxResult(zts.clientCtx, resTx) + } + } + } +} + +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 +} + +// 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 @@ -352,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 } @@ -373,7 +454,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/pkg/chains/chain.go b/pkg/chains/chain.go index 9d24216272..b86d54a176 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -90,6 +90,7 @@ func IsZetaChain(chainID int64) bool { // https://github.com/zeta-chain/node-private/issues/63 func IsEVMChain(chainID int64) bool { return chainID == 5 || // Goerli + chainID == AmoyChain().ChainId || chainID == SepoliaChain().ChainId || // Sepolia chainID == 80001 || // Polygon mumbai chainID == 97 || // BSC testnet diff --git a/pkg/chains/chains.go b/pkg/chains/chains.go index ef1ffc9caf..651051da3c 100644 --- a/pkg/chains/chains.go +++ b/pkg/chains/chains.go @@ -99,6 +99,13 @@ func MumbaiChain() Chain { } } +func AmoyChain() Chain { + return Chain{ + ChainName: ChainName_amoy_testnet, + ChainId: 80002, + } +} + // Privnet chains func BtcRegtestChain() Chain { @@ -127,6 +134,7 @@ func DefaultChainsList() []*Chain { EthChain(), BtcTestNetChain(), MumbaiChain(), + AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), @@ -155,6 +163,7 @@ func TestnetChainList() []*Chain { ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), + AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), @@ -178,6 +187,7 @@ func ExternalChainList() []*Chain { EthChain(), BtcTestNetChain(), MumbaiChain(), + AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), diff --git a/pkg/chains/chains.pb.go b/pkg/chains/chains.pb.go index a305e7adbd..27e8736dac 100644 --- a/pkg/chains/chains.pb.go +++ b/pkg/chains/chains.pb.go @@ -61,7 +61,6 @@ const ( ChainName_btc_mainnet ChainName = 3 ChainName_polygon_mainnet ChainName = 4 ChainName_bsc_mainnet ChainName = 5 - // Testnet ChainName_goerli_testnet ChainName = 6 ChainName_mumbai_testnet ChainName = 7 ChainName_ganache_testnet ChainName = 8 @@ -70,10 +69,9 @@ const ( ChainName_zeta_testnet ChainName = 11 ChainName_btc_testnet ChainName = 12 ChainName_sepolia_testnet ChainName = 13 - // LocalNet - // zeta_localnet = 13; ChainName_goerli_localnet ChainName = 14 ChainName_btc_regtest ChainName = 15 + ChainName_amoy_testnet ChainName = 16 ) var ChainName_name = map[int32]string{ @@ -93,6 +91,7 @@ var ChainName_name = map[int32]string{ 13: "sepolia_testnet", 14: "goerli_localnet", 15: "btc_regtest", + 16: "amoy_testnet", } var ChainName_value = map[string]int32{ @@ -112,6 +111,7 @@ var ChainName_value = map[string]int32{ "sepolia_testnet": 13, "goerli_localnet": 14, "btc_regtest": 15, + "amoy_testnet": 16, } func (x ChainName) String() string { @@ -183,32 +183,32 @@ func init() { func init() { proto.RegisterFile("pkg/chains/chains.proto", fileDescriptor_37ad35e0488e8bbc) } var fileDescriptor_37ad35e0488e8bbc = []byte{ - // 390 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x92, 0x31, 0xaf, 0xd3, 0x30, - 0x10, 0x80, 0xe3, 0xbc, 0xd7, 0xf4, 0xe5, 0xfa, 0x5e, 0x1b, 0x0c, 0x12, 0xa5, 0x43, 0x54, 0x31, - 0x95, 0x4a, 0x34, 0x08, 0x46, 0x36, 0x2a, 0x21, 0xb1, 0x30, 0xb4, 0x4c, 0x2c, 0x95, 0xe3, 0x9c, - 0x1c, 0x8b, 0x24, 0x8e, 0x12, 0x07, 0xa9, 0xfc, 0x0a, 0x7e, 0x04, 0x03, 0xbf, 0x80, 0xdf, 0xc0, - 0xd8, 0x91, 0x11, 0xb5, 0x7f, 0xe4, 0xc9, 0x4e, 0x93, 0x4c, 0xb9, 0xfb, 0xfc, 0xf9, 0xee, 0x14, - 0x1f, 0x3c, 0x2f, 0xbf, 0x89, 0x88, 0xa7, 0x4c, 0x16, 0xf5, 0xf5, 0xb3, 0x29, 0x2b, 0xa5, 0x15, - 0xf5, 0xda, 0x6c, 0xf1, 0x4c, 0x28, 0xa1, 0x2c, 0x8a, 0x4c, 0xd4, 0x9e, 0xbe, 0xfc, 0x02, 0xa3, - 0xad, 0x39, 0xa7, 0x6f, 0x00, 0xac, 0x78, 0x28, 0x58, 0x8e, 0x73, 0xb2, 0x24, 0xab, 0xe9, 0xdb, - 0x27, 0x9b, 0x6b, 0x25, 0xab, 0x7c, 0x66, 0x39, 0xee, 0x7c, 0xde, 0x85, 0xf4, 0x05, 0xdc, 0xb5, - 0x37, 0x64, 0x32, 0x77, 0x97, 0x64, 0x75, 0xb3, 0x1b, 0xdb, 0xfc, 0x53, 0xb2, 0x7e, 0x0f, 0x0f, - 0x3b, 0xe4, 0x28, 0xbf, 0xe3, 0x5e, 0x33, 0xdd, 0xd4, 0x74, 0x02, 0xe3, 0x6d, 0x85, 0x4c, 0x63, - 0x12, 0x38, 0x26, 0xd9, 0x37, 0x9c, 0x63, 0x5d, 0x07, 0x84, 0x02, 0x78, 0x1f, 0x99, 0xcc, 0x30, - 0x09, 0xdc, 0xc5, 0xed, 0xef, 0x5f, 0x21, 0x59, 0xff, 0x71, 0xc1, 0xef, 0x1b, 0x52, 0x1f, 0x46, - 0x98, 0x97, 0xfa, 0x18, 0x38, 0x74, 0x06, 0x13, 0xd4, 0xe9, 0x21, 0x67, 0xb2, 0x28, 0x50, 0x07, - 0x84, 0x06, 0x70, 0xff, 0x03, 0x35, 0xeb, 0x89, 0x6b, 0x94, 0x58, 0xf3, 0x1e, 0xdc, 0xd0, 0xa7, - 0x30, 0x2b, 0x55, 0x76, 0x14, 0xaa, 0xe8, 0xe1, 0xad, 0xb5, 0xea, 0xc1, 0x1a, 0x51, 0x0a, 0x53, - 0xa1, 0xb0, 0xca, 0xe4, 0x41, 0x63, 0xad, 0x0d, 0xf3, 0x0c, 0xcb, 0x9b, 0x3c, 0x66, 0x03, 0x1b, - 0x9b, 0x6a, 0x82, 0x15, 0x8c, 0xa7, 0xd8, 0xc3, 0x3b, 0x23, 0xc6, 0x4c, 0xc5, 0x2c, 0xee, 0x99, - 0xdf, 0x75, 0xe8, 0x00, 0xf4, 0xa3, 0x76, 0x64, 0xd2, 0x8d, 0xda, 0x81, 0x7b, 0x53, 0xbc, 0xc6, - 0x52, 0x65, 0x72, 0xb0, 0x1e, 0x6c, 0xc7, 0x76, 0xb2, 0x4c, 0x71, 0x96, 0x19, 0x38, 0xed, 0xae, - 0x56, 0x28, 0x8c, 0x18, 0xcc, 0xda, 0x1f, 0xf7, 0x61, 0xfb, 0xf7, 0x1c, 0x92, 0xd3, 0x39, 0x24, - 0xff, 0xcf, 0x21, 0xf9, 0x79, 0x09, 0x9d, 0xd3, 0x25, 0x74, 0xfe, 0x5d, 0x42, 0xe7, 0xeb, 0x2b, - 0x21, 0x75, 0xda, 0xc4, 0x1b, 0xae, 0xf2, 0xc8, 0x8c, 0xf1, 0xda, 0x3e, 0x94, 0x0d, 0xb9, 0xaa, - 0x30, 0x1a, 0x76, 0x27, 0xf6, 0xec, 0x5e, 0xbc, 0x7b, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xad, 0x5e, - 0x66, 0xdc, 0x50, 0x02, 0x00, 0x00, + // 396 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x92, 0x4f, 0x6f, 0xd3, 0x30, + 0x14, 0xc0, 0xe3, 0x6e, 0x6d, 0x97, 0xd7, 0xad, 0x35, 0x06, 0x89, 0xb1, 0x43, 0x34, 0x71, 0x1a, + 0x93, 0x68, 0x10, 0x1c, 0xb9, 0x51, 0x09, 0x89, 0x0b, 0x87, 0x8e, 0x13, 0x97, 0xca, 0x71, 0x9e, + 0x1c, 0x8b, 0x38, 0x8e, 0x12, 0x07, 0xa9, 0x7c, 0x0a, 0x3e, 0x04, 0x07, 0x3e, 0xca, 0x8e, 0x3b, + 0x72, 0x44, 0xed, 0x17, 0x99, 0xec, 0x2c, 0xce, 0x29, 0xef, 0xfd, 0xfc, 0x7b, 0x7f, 0x14, 0x1b, + 0x5e, 0xd6, 0x3f, 0x64, 0x2a, 0x0a, 0xae, 0xaa, 0xf6, 0xe9, 0xb3, 0xae,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, 0x49, 0x5e, 0x71, 0x51, 0x60, 0x80, 0x67, 0x4e, 0xcc, 0xb8, 0xc9, 0x78, 0x16, 0x58, 0x3c, + 0x4c, 0x18, 0x00, 0x84, 0x55, 0x07, 0xb2, 0x18, 0x56, 0x1d, 0xc0, 0xb9, 0x6b, 0xde, 0x62, 0x6d, + 0x4a, 0x35, 0x5a, 0x17, 0x7e, 0x62, 0xbf, 0x59, 0x69, 0x04, 0x2f, 0x1d, 0x5c, 0x0e, 0xa5, 0x0d, + 0x4a, 0x27, 0xd2, 0x95, 0xeb, 0xce, 0xb5, 0xd9, 0x87, 0x3a, 0xda, 0xff, 0xca, 0x4f, 0x9b, 0xfb, + 0x43, 0x42, 0x1e, 0x0e, 0x09, 0xf9, 0x7f, 0x48, 0xc8, 0xef, 0x63, 0x12, 0x3d, 0x1c, 0x93, 0xe8, + 0xdf, 0x31, 0x89, 0xbe, 0xbf, 0x91, 0xca, 0x16, 0x5d, 0xb6, 0x16, 0x46, 0xa7, 0x6e, 0xb1, 0xb7, + 0xfe, 0xea, 0x7c, 0x28, 0x4c, 0x83, 0xe9, 0xf8, 0x9a, 0xb2, 0x99, 0x7f, 0x29, 0x1f, 0x1e, 0x03, + 0x00, 0x00, 0xff, 0xff, 0xda, 0x8f, 0xd7, 0xf3, 0x62, 0x02, 0x00, 0x00, } func (m *Chain) Marshal() (dAtA []byte, err error) { diff --git a/pkg/chains/chains_test.go b/pkg/chains/chains_test.go index 070cb5922e..51e22e85fd 100644 --- a/pkg/chains/chains_test.go +++ b/pkg/chains/chains_test.go @@ -25,6 +25,7 @@ func TestChainRetrievalFunctions(t *testing.T) { {"BscTestnetChain", BscTestnetChain, Chain{ChainName: ChainName_bsc_testnet, ChainId: 97}}, {"BtcTestNetChain", BtcTestNetChain, Chain{ChainName: ChainName_btc_testnet, ChainId: 18332}}, {"MumbaiChain", MumbaiChain, Chain{ChainName: ChainName_mumbai_testnet, ChainId: 80001}}, + {"AmoyChain", AmoyChain, Chain{ChainName: ChainName_amoy_testnet, ChainId: 80002}}, {"BtcRegtestChain", BtcRegtestChain, Chain{ChainName: ChainName_btc_regtest, ChainId: 18444}}, {"GoerliLocalnetChain", GoerliLocalnetChain, Chain{ChainName: ChainName_goerli_localnet, ChainId: 1337}}, } @@ -43,11 +44,11 @@ func TestChainListFunctions(t *testing.T) { function func() []*Chain expected []Chain }{ - {"DefaultChainsList", DefaultChainsList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain(), ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain()}}, + {"DefaultChainsList", DefaultChainsList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain(), ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain()}}, {"MainnetChainList", MainnetChainList, []Chain{ZetaChainMainnet(), BtcMainnetChain(), BscMainnetChain(), EthChain()}}, - {"TestnetChainList", TestnetChainList, []Chain{ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), BscTestnetChain(), GoerliChain(), SepoliaChain()}}, + {"TestnetChainList", TestnetChainList, []Chain{ZetaTestnetChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain()}}, {"PrivnetChainList", PrivnetChainList, []Chain{ZetaPrivnetChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, - {"ExternalChainList", ExternalChainList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, + {"ExternalChainList", ExternalChainList, []Chain{BtcMainnetChain(), BscMainnetChain(), EthChain(), BtcTestNetChain(), MumbaiChain(), AmoyChain(), BscTestnetChain(), GoerliChain(), SepoliaChain(), BtcRegtestChain(), GoerliLocalnetChain()}}, {"ZetaChainList", ZetaChainList, []Chain{ZetaChainMainnet(), ZetaTestnetChain(), ZetaMocknetChain(), ZetaPrivnetChain()}}, } 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/crosschain/genesis.proto b/proto/crosschain/genesis.proto index 87c3875b14..9213a128a5 100644 --- a/proto/crosschain/genesis.proto +++ b/proto/crosschain/genesis.proto @@ -7,18 +7,20 @@ 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"; // 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; + 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 7e668d6325..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"; @@ -14,7 +15,7 @@ service Msg { rpc AddToInTxTracker(MsgAddToInTxTracker) returns (MsgAddToInTxTrackerResponse); rpc RemoveFromOutTxTracker(MsgRemoveFromOutTxTracker) returns (MsgRemoveFromOutTxTrackerResponse); - rpc GasPriceVoter(MsgGasPriceVoter) returns (MsgGasPriceVoterResponse); + rpc VoteGasPrice(MsgVoteGasPrice) returns (MsgVoteGasPriceResponse); rpc VoteOnObservedOutboundTx(MsgVoteOnObservedOutboundTx) returns (MsgVoteOnObservedOutboundTxResponse); rpc VoteOnObservedInboundTx(MsgVoteOnObservedInboundTx) returns (MsgVoteOnObservedInboundTxResponse); rpc WhitelistERC20(MsgWhitelistERC20) returns (MsgWhitelistERC20Response); @@ -23,6 +24,8 @@ service Msg { rpc AbortStuckCCTX(MsgAbortStuckCCTX) returns (MsgAbortStuckCCTXResponse); rpc RefundAbortedCCTX(MsgRefundAbortedCCTX) returns (MsgRefundAbortedCCTXResponse); + + rpc UpdateRateLimiterFlags(MsgUpdateRateLimiterFlags) returns (MsgUpdateRateLimiterFlagsResponse); } message MsgMigrateTssFunds { @@ -91,7 +94,7 @@ message MsgRemoveFromOutTxTracker { message MsgRemoveFromOutTxTrackerResponse {} -message MsgGasPriceVoter { +message MsgVoteGasPrice { string creator = 1; int64 chain_id = 2; uint64 price = 3; @@ -99,7 +102,7 @@ message MsgGasPriceVoter { string supply = 5; } -message MsgGasPriceVoterResponse {} +message MsgVoteGasPriceResponse {} message MsgVoteOnObservedOutboundTx { string creator = 1; @@ -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/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/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/proto/pkg/chains/chains.proto b/proto/pkg/chains/chains.proto index fa9e9e49db..49305d4f16 100644 --- a/proto/pkg/chains/chains.proto +++ b/proto/pkg/chains/chains.proto @@ -21,7 +21,6 @@ enum ChainName { btc_mainnet = 3; polygon_mainnet = 4; bsc_mainnet = 5; - // Testnet goerli_testnet = 6; mumbai_testnet = 7; ganache_testnet = 8; @@ -30,12 +29,9 @@ enum ChainName { zeta_testnet = 11; btc_testnet = 12; sepolia_testnet = 13; - // LocalNet - // zeta_localnet = 13; goerli_localnet = 14; btc_regtest = 15; - // Athens - // zeta_athensnet=15; + amoy_testnet = 16; } message Chain { diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index 3fb8f81823..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,12 +73,12 @@ func CrosschainKeeperWithMocks( sdkKeepers.SlashingKeeper, sdkKeepers.ParamsKeeper, authorityKeeperTmp, + lightclientKeeperTmp, ) fungibleKeeperTmp := initFungibleKeeper( cdc, db, stateStore, - sdkKeepers.ParamsKeeper, sdkKeepers.AuthKeeper, sdkKeepers.BankKeeper, sdkKeepers.EvmKeeper, @@ -87,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 @@ -128,18 +132,21 @@ func CrosschainKeeperWithMocks( if mockOptions.UseFungibleMock { fungibleKeeper = crosschainmocks.NewCrosschainFungibleKeeper(t) } + if mockOptions.UseLightclientMock { + lightclientKeeper = crosschainmocks.NewCrosschainLightclientKeeper(t) + } k := keeper.NewKeeper( cdc, storeKey, memStoreKey, stakingKeeper, - sdkKeepers.ParamsKeeper.Subspace(types.ModuleName), authKeeper, bankKeeper, observerKeeper, fungibleKeeper, authorityKeeper, + lightclientKeeper, ) return k, ctx, sdkKeepers, zetaKeepers @@ -156,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) @@ -299,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 5097a208d2..ff5f79192a 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, @@ -89,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, @@ -98,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 @@ -145,7 +152,6 @@ func FungibleKeeperWithMocks(t testing.TB, mockOptions FungibleMockOptions) (*ke cdc, storeKey, memStoreKey, - sdkKeepers.ParamsKeeper.Subspace(types.ModuleName), authKeeper, evmKeeper, bankKeeper, 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/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/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 4ed1f9ce60..7dae4b7dd2 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -8,6 +8,8 @@ import ( "strconv" "testing" + "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" @@ -15,13 +17,9 @@ import ( "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") @@ -43,35 +41,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())) @@ -83,38 +52,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())) @@ -179,3 +116,17 @@ func GenDoc(t *testing.T) *types.GenesisDoc { require.NoError(t, err) return genDoc } + +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/crosschain/genesis_pb.d.ts b/typescript/crosschain/genesis_pb.d.ts index bec622e2af..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. @@ -19,45 +20,50 @@ 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[]; + /** + * @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 eec35c2dc8..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 @@ -400,9 +401,9 @@ export declare class MsgRemoveFromOutTxTrackerResponse extends Message { +export declare class MsgVoteGasPrice extends Message { /** * @generated from field: string creator = 1; */ @@ -428,38 +429,38 @@ export declare class MsgGasPriceVoter extends Message { */ supply: string; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.crosschain.MsgGasPriceVoter"; + static readonly typeName = "zetachain.zetacore.crosschain.MsgVoteGasPrice"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgGasPriceVoter; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgVoteGasPrice; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgGasPriceVoter; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgVoteGasPrice; - static fromJsonString(jsonString: string, options?: Partial): MsgGasPriceVoter; + static fromJsonString(jsonString: string, options?: Partial): MsgVoteGasPrice; - static equals(a: MsgGasPriceVoter | PlainMessage | undefined, b: MsgGasPriceVoter | PlainMessage | undefined): boolean; + static equals(a: MsgVoteGasPrice | PlainMessage | undefined, b: MsgVoteGasPrice | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.crosschain.MsgGasPriceVoterResponse + * @generated from message zetachain.zetacore.crosschain.MsgVoteGasPriceResponse */ -export declare class MsgGasPriceVoterResponse extends Message { - constructor(data?: PartialMessage); +export declare class MsgVoteGasPriceResponse extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.crosschain.MsgGasPriceVoterResponse"; + static readonly typeName = "zetachain.zetacore.crosschain.MsgVoteGasPriceResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgGasPriceVoterResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgVoteGasPriceResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgGasPriceVoterResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgVoteGasPriceResponse; - static fromJsonString(jsonString: string, options?: Partial): MsgGasPriceVoterResponse; + static fromJsonString(jsonString: string, options?: Partial): MsgVoteGasPriceResponse; - static equals(a: MsgGasPriceVoterResponse | PlainMessage | undefined, b: MsgGasPriceVoterResponse | PlainMessage | undefined): boolean; + static equals(a: MsgVoteGasPriceResponse | PlainMessage | undefined, b: MsgVoteGasPriceResponse | PlainMessage | undefined): boolean; } /** @@ -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/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/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/typescript/pkg/chains/chains_pb.d.ts b/typescript/pkg/chains/chains_pb.d.ts index 0a04c14420..4a2efde10d 100644 --- a/typescript/pkg/chains/chains_pb.d.ts +++ b/typescript/pkg/chains/chains_pb.d.ts @@ -63,8 +63,6 @@ export declare enum ChainName { bsc_mainnet = 5, /** - * Testnet - * * @generated from enum value: goerli_testnet = 6; */ goerli_testnet = 6, @@ -105,20 +103,19 @@ export declare enum ChainName { sepolia_testnet = 13, /** - * LocalNet - * zeta_localnet = 13; - * * @generated from enum value: goerli_localnet = 14; */ goerli_localnet = 14, /** - * Athens - * zeta_athensnet=15; - * * @generated from enum value: btc_regtest = 15; */ btc_regtest = 15, + + /** + * @generated from enum value: amoy_testnet = 16; + */ + amoy_testnet = 16, } /** diff --git a/x/crosschain/client/cli/cli_gas_price.go b/x/crosschain/client/cli/cli_gas_price.go index b46897b36c..1ad48ee8c0 100644 --- a/x/crosschain/client/cli/cli_gas_price.go +++ b/x/crosschain/client/cli/cli_gas_price.go @@ -74,10 +74,10 @@ func CmdShowGasPrice() *cobra.Command { // Transaction CLI ///////////////////////// -func CmdGasPriceVoter() *cobra.Command { +func CmdVoteGasPrice() *cobra.Command { cmd := &cobra.Command{ - Use: "gas-price-voter [chain] [price] [supply] [blockNumber]", - Short: "Broadcast message gasPriceVoter", + Use: "vote-gas-price [chain] [price] [supply] [blockNumber]", + Short: "Broadcast message to vote gas price", Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { argsChain, err := strconv.ParseInt(args[0], 10, 64) @@ -99,7 +99,7 @@ func CmdGasPriceVoter() *cobra.Command { return err } - msg := types.NewMsgGasPriceVoter(clientCtx.GetFromAddress().String(), argsChain, argsPrice, argsSupply, argsBlockNumber) + msg := types.NewMsgVoteGasPrice(clientCtx.GetFromAddress().String(), argsChain, argsPrice, argsSupply, argsBlockNumber) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, 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/fungible/client/cli/query_params.go b/x/crosschain/client/cli/query_rate_limiter_flags.go similarity index 61% rename from x/fungible/client/cli/query_params.go rename to x/crosschain/client/cli/query_rate_limiter_flags.go index fad97be7dd..43377e8b50 100644 --- a/x/fungible/client/cli/query_params.go +++ b/x/crosschain/client/cli/query_rate_limiter_flags.go @@ -6,20 +6,19 @@ import ( "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" + "github.com/zeta-chain/zetacore/x/crosschain/types" ) -func CmdQueryParams() *cobra.Command { +func CmdShowUpdateRateLimiterFlags() *cobra.Command { cmd := &cobra.Command{ - Use: "params", - Short: "shows the parameters of the module", - Args: cobra.NoArgs, + 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.Params(context.Background(), &types.QueryParamsRequest{}) + res, err := queryClient.RateLimiterFlags(context.Background(), &types.QueryRateLimiterFlagsRequest{}) if err != nil { return err } diff --git a/x/crosschain/client/cli/tx.go b/x/crosschain/client/cli/tx.go index c82c55f8fd..55bcabb31f 100644 --- a/x/crosschain/client/cli/tx.go +++ b/x/crosschain/client/cli/tx.go @@ -22,7 +22,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand( CmdAddToWatchList(), - CmdGasPriceVoter(), + CmdVoteGasPrice(), CmdCCTXOutboundVoter(), CmdCCTXInboundVoter(), CmdRemoveFromWatchList(), 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_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/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/keeper.go b/x/crosschain/keeper/keeper.go index 5ed6084983..0bdad4fb06 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,12 +17,12 @@ type ( memKey storetypes.StoreKey stakingKeeper types.StakingKeeper - paramstore paramtypes.Subspace authKeeper types.AccountKeeper bankKeeper types.BankKeeper zetaObserverKeeper types.ObserverKeeper fungibleKeeper types.FungibleKeeper authorityKeeper types.AuthorityKeeper + lightclientKeeper types.LightclientKeeper } ) @@ -32,12 +31,12 @@ func NewKeeper( storeKey, memKey storetypes.StoreKey, stakingKeeper types.StakingKeeper, // custom - paramstore paramtypes.Subspace, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, 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) @@ -50,12 +49,12 @@ func NewKeeper( storeKey: storeKey, memKey: memKey, stakingKeeper: stakingKeeper, - paramstore: paramstore, authKeeper: authKeeper, bankKeeper: bankKeeper, zetaObserverKeeper: zetaObserverKeeper, fungibleKeeper: fungibleKeeper, authorityKeeper: authorityKeeper, + lightclientKeeper: lightclientKeeper, } } @@ -87,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/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/msg_server_gas_price_voter.go b/x/crosschain/keeper/msg_server_vote_gas_price.go similarity index 91% rename from x/crosschain/keeper/msg_server_gas_price_voter.go rename to x/crosschain/keeper/msg_server_vote_gas_price.go index 52532c206f..77df7eaf48 100644 --- a/x/crosschain/keeper/msg_server_gas_price_voter.go +++ b/x/crosschain/keeper/msg_server_vote_gas_price.go @@ -15,12 +15,12 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) -// GasPriceVoter submits information about the connected chain's gas price at a specific block +// VoteGasPrice submits information about the connected chain's gas price at a specific block // height. Gas price submitted by each validator is recorded separately and a // median index is updated. // // Only observer validators are authorized to broadcast this message. -func (k msgServer) GasPriceVoter(goCtx context.Context, msg *types.MsgGasPriceVoter) (*types.MsgGasPriceVoterResponse, error) { +func (k msgServer) VoteGasPrice(goCtx context.Context, msg *types.MsgVoteGasPrice) (*types.MsgVoteGasPriceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) chain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, msg.ChainId) @@ -78,7 +78,7 @@ func (k msgServer) GasPriceVoter(goCtx context.Context, msg *types.MsgGasPriceVo // reset the gas count k.ResetGasMeterAndConsumeGas(ctx, gasUsed) - return &types.MsgGasPriceVoterResponse{}, nil + return &types.MsgVoteGasPriceResponse{}, nil } type indexValue struct { diff --git a/x/crosschain/keeper/msg_server_gas_price_voter_test.go b/x/crosschain/keeper/msg_server_vote_gas_price_test.go similarity index 93% rename from x/crosschain/keeper/msg_server_gas_price_voter_test.go rename to x/crosschain/keeper/msg_server_vote_gas_price_test.go index 50c11dbaa9..85b5b26c46 100644 --- a/x/crosschain/keeper/msg_server_gas_price_voter_test.go +++ b/x/crosschain/keeper/msg_server_vote_gas_price_test.go @@ -13,7 +13,7 @@ import ( "github.com/zeta-chain/zetacore/x/crosschain/types" ) -func TestMsgServer_GasPriceVoter(t *testing.T) { +func TestMsgServer_VoteGasPrice(t *testing.T) { t.Run("should error if unsupported chain", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseObserverMock: true, @@ -24,7 +24,7 @@ func TestMsgServer_GasPriceVoter(t *testing.T) { msgServer := keeper.NewMsgServerImpl(*k) - res, err := msgServer.GasPriceVoter(ctx, &types.MsgGasPriceVoter{ + res, err := msgServer.VoteGasPrice(ctx, &types.MsgVoteGasPrice{ ChainId: 5, }) require.Error(t, err) @@ -42,7 +42,7 @@ func TestMsgServer_GasPriceVoter(t *testing.T) { msgServer := keeper.NewMsgServerImpl(*k) - res, err := msgServer.GasPriceVoter(ctx, &types.MsgGasPriceVoter{ + res, err := msgServer.VoteGasPrice(ctx, &types.MsgVoteGasPrice{ ChainId: 5, }) require.Error(t, err) @@ -65,7 +65,7 @@ func TestMsgServer_GasPriceVoter(t *testing.T) { fungibleMock.On("SetGasPrice", mock.Anything, mock.Anything, mock.Anything).Return(uint64(0), errors.New("err")) msgServer := keeper.NewMsgServerImpl(*k) - res, err := msgServer.GasPriceVoter(ctx, &types.MsgGasPriceVoter{ + res, err := msgServer.VoteGasPrice(ctx, &types.MsgVoteGasPrice{ ChainId: 5, }) require.Error(t, err) @@ -90,7 +90,7 @@ func TestMsgServer_GasPriceVoter(t *testing.T) { fungibleMock.On("SetGasPrice", mock.Anything, mock.Anything, mock.Anything).Return(uint64(1), nil) msgServer := keeper.NewMsgServerImpl(*k) creator := sample.AccAddress() - res, err := msgServer.GasPriceVoter(ctx, &types.MsgGasPriceVoter{ + res, err := msgServer.VoteGasPrice(ctx, &types.MsgVoteGasPrice{ Creator: creator, ChainId: 5, Price: 1, @@ -136,7 +136,7 @@ func TestMsgServer_GasPriceVoter(t *testing.T) { Prices: []uint64{1}, }) - res, err := msgServer.GasPriceVoter(ctx, &types.MsgGasPriceVoter{ + res, err := msgServer.VoteGasPrice(ctx, &types.MsgVoteGasPrice{ Creator: creator, ChainId: 5, BlockNumber: 2, @@ -181,7 +181,7 @@ func TestMsgServer_GasPriceVoter(t *testing.T) { Prices: []uint64{1}, }) - res, err := msgServer.GasPriceVoter(ctx, &types.MsgGasPriceVoter{ + res, err := msgServer.VoteGasPrice(ctx, &types.MsgVoteGasPrice{ Creator: creator, ChainId: 5, BlockNumber: 2, 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/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/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 6ee58171ff..6b27c1fd40 100644 --- a/x/crosschain/types/authz.go +++ b/x/crosschain/types/authz.go @@ -8,12 +8,12 @@ import ( // GetAllAuthzZetaclientTxTypes returns all the authz types for required for zetaclient func GetAllAuthzZetaclientTxTypes() []string { return []string{ - sdk.MsgTypeURL(&MsgGasPriceVoter{}), + sdk.MsgTypeURL(&MsgVoteGasPrice{}), sdk.MsgTypeURL(&MsgVoteOnObservedInboundTx{}), sdk.MsgTypeURL(&MsgVoteOnObservedOutboundTx{}), 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 7c615d7c6b..d8a581bd07 100644 --- a/x/crosschain/types/authz_test.go +++ b/x/crosschain/types/authz_test.go @@ -8,12 +8,12 @@ import ( ) func TestGetAllAuthzZetaclientTxTypes(t *testing.T) { - require.Equal(t, []string{"/zetachain.zetacore.crosschain.MsgGasPriceVoter", + require.Equal(t, []string{"/zetachain.zetacore.crosschain.MsgVoteGasPrice", "/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx", "/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx", "/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/codec.go b/x/crosschain/types/codec.go index 7fcbc0cc0c..2f0bcc0eb0 100644 --- a/x/crosschain/types/codec.go +++ b/x/crosschain/types/codec.go @@ -11,13 +11,14 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgAddToOutTxTracker{}, "crosschain/AddToOutTxTracker", nil) cdc.RegisterConcrete(&MsgAddToInTxTracker{}, "crosschain/AddToInTxTracker", nil) cdc.RegisterConcrete(&MsgRemoveFromOutTxTracker{}, "crosschain/RemoveFromOutTxTracker", nil) - cdc.RegisterConcrete(&MsgGasPriceVoter{}, "crosschain/GasPriceVoter", nil) + cdc.RegisterConcrete(&MsgVoteGasPrice{}, "crosschain/VoteGasPrice", nil) cdc.RegisterConcrete(&MsgVoteOnObservedOutboundTx{}, "crosschain/VoteOnObservedOutboundTx", nil) cdc.RegisterConcrete(&MsgVoteOnObservedInboundTx{}, "crosschain/VoteOnObservedInboundTx", nil) cdc.RegisterConcrete(&MsgWhitelistERC20{}, "crosschain/WhitelistERC20", nil) 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) { @@ -25,13 +26,14 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgAddToOutTxTracker{}, &MsgAddToInTxTracker{}, &MsgRemoveFromOutTxTracker{}, - &MsgGasPriceVoter{}, + &MsgVoteGasPrice{}, &MsgVoteOnObservedOutboundTx{}, &MsgVoteOnObservedInboundTx{}, &MsgWhitelistERC20{}, &MsgMigrateTssFunds{}, &MsgUpdateTssAddress{}, &MsgAbortStuckCCTX{}, + &MsgUpdateRateLimiterFlags{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index 62720aaf66..1b80e4fe19 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -41,4 +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") + 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/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.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 c6358ad693..8045b2d098 100644 --- a/x/crosschain/types/genesis.pb.go +++ b/x/crosschain/types/genesis.pb.go @@ -26,14 +26,15 @@ 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"` + 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, 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, 0x76, 0x84, 0xb6, 0x24, 0xb6, 0x26, 0x50, 0xd5, 0xfa, 0xc1, 0xc0, 0x25, 0x53, - 0x4d, 0xa6, 0x85, 0x60, 0xbc, 0xe9, 0x3d, 0x73, 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 0x4d, 0xc8, - 0xd7, 0xe0, 0xf0, 0xa9, 0x31, 0x71, 0xfe, 0x01, 0x92, 0x1b, 0x93, 0x0d, 0x6b, 0xf2, 0x62, 0x05, - 0x93, 0xf6, 0x35, 0x6e, 0x09, 0xd9, 0xbe, 0xc5, 0x2f, 0x68, 0xcb, 0x28, 0x09, 0x65, 0x4c, 0x95, - 0x12, 0x84, 0x4c, 0xfd, 0xdb, 0x43, 0x6f, 0x85, 0x0f, 0x38, 0xe1, 0x40, 0xdf, 0x5d, 0x89, 0x1a, - 0xfc, 0x83, 0x59, 0xeb, 0x14, 0xbf, 0x42, 0x8f, 0xde, 0x0b, 0x49, 0x73, 0x31, 0xe3, 0x67, 0x87, - 0x32, 0x51, 0xa5, 0x3c, 0xd3, 0xfe, 0x9d, 0x61, 0x7f, 0xf7, 0x6e, 0xdc, 0x6d, 0x8c, 0x8e, 0x2e, - 0xe6, 0x81, 0x77, 0x39, 0x0f, 0xbc, 0x3f, 0xf3, 0xc0, 0xfb, 0xb1, 0x08, 0x7a, 0x97, 0x8b, 0xa0, - 0xf7, 0x6b, 0x11, 0xf4, 0x4e, 0x5e, 0xa7, 0x02, 0xb2, 0x32, 0x09, 0x99, 0xfa, 0x16, 0x19, 0x8b, - 0xbd, 0xfa, 0x75, 0xfc, 0xdb, 0x2b, 0xaa, 0x22, 0xe7, 0xcd, 0xc0, 0xf7, 0x29, 0xd7, 0xc9, 0x86, - 0x7d, 0x15, 0x6f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x9d, 0xe1, 0x07, 0xea, 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, 0x1f, 0xad, 0x12, 0x10, 0x7a, 0x35, 0x31, 0x19, 0xd7, + 0x33, 0x89, 0xb5, 0x2c, 0xae, 0xec, 0x13, 0x29, 0xf4, 0x29, 0x78, 0x08, 0x1e, 0x66, 0x97, 0xbb, + 0xe4, 0x0a, 0xa1, 0xf6, 0x45, 0x90, 0x9d, 0x6c, 0x38, 0xa4, 0xa2, 0xbd, 0x3b, 0xf2, 0x39, 0xdf, + 0xef, 0x3b, 0x3e, 0xc7, 0x46, 0x1e, 0x53, 0x52, 0x6b, 0x96, 0x50, 0x91, 0x85, 0x31, 0xcf, 0xb8, + 0x16, 0x3a, 0x18, 0x2b, 0x09, 0x12, 0x3f, 0x9d, 0x70, 0xa0, 0x36, 0x11, 0xd8, 0x48, 0x2a, 0x1e, + 0xfc, 0x2d, 0xee, 0x6e, 0x3b, 0x42, 0x1b, 0x12, 0x1b, 0x13, 0x28, 0x4a, 0x7d, 0xb7, 0xeb, 0x92, + 0xa9, 0x26, 0x63, 0x25, 0x18, 0xaf, 0x72, 0xcf, 0x9c, 0x9c, 0xd5, 0x90, 0x84, 0xea, 0x84, 0x80, + 0x24, 0x8c, 0xdd, 0x02, 0xfc, 0x46, 0x11, 0x28, 0xca, 0x2e, 0xb8, 0xaa, 0xf2, 0x3b, 0x4e, 0x3e, + 0xa5, 0x1a, 0xc8, 0x28, 0x95, 0xec, 0x82, 0x24, 0x5c, 0xc4, 0x09, 0x54, 0x35, 0x6e, 0x97, 0x32, + 0x87, 0x26, 0xc4, 0xed, 0x44, 0x51, 0xe0, 0x24, 0x15, 0x97, 0x02, 0xb8, 0x22, 0x5f, 0x53, 0x1a, + 0x57, 0xa3, 0xe8, 0x3e, 0x89, 0x65, 0x2c, 0x6d, 0x18, 0x9a, 0xa8, 0x3c, 0xdd, 0xf9, 0xb1, 0x8a, + 0x3a, 0x87, 0xe5, 0xc8, 0x3e, 0x01, 0x05, 0x8e,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c5, 0x84, + 0x9f, 0x1f, 0x67, 0x23, 0x99, 0x67, 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,13 +195,27 @@ 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]) 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 +227,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 +239,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 +253,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 +267,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 +281,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 +295,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 +309,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,9 +373,11 @@ 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)) } } + l = m.RateLimiterFlags.Size() + n += 2 + l + sovGenesis(uint64(l)) return n } @@ -390,7 +416,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 +450,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 +484,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 +518,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 +552,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 +586,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 +620,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 +653,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) } @@ -659,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 d84d811bd9..1d09c26488 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", @@ -53,6 +43,7 @@ func TestGenesisState_Validate(t *testing.T) { sample.GasPrice(t, "1"), sample.GasPrice(t, "2"), }, + RateLimiterFlags: sample.RateLimiterFlags(), }, valid: true, }, @@ -70,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/message_gas_price_voter.go b/x/crosschain/types/message_vote_gas_price.go similarity index 66% rename from x/crosschain/types/message_gas_price_voter.go rename to x/crosschain/types/message_vote_gas_price.go index 89dc8030c4..31ae0479ea 100644 --- a/x/crosschain/types/message_gas_price_voter.go +++ b/x/crosschain/types/message_vote_gas_price.go @@ -7,10 +7,10 @@ import ( "github.com/zeta-chain/zetacore/pkg/authz" ) -var _ sdk.Msg = &MsgGasPriceVoter{} +var _ sdk.Msg = &MsgVoteGasPrice{} -func NewMsgGasPriceVoter(creator string, chain int64, price uint64, supply string, blockNumber uint64) *MsgGasPriceVoter { - return &MsgGasPriceVoter{ +func NewMsgVoteGasPrice(creator string, chain int64, price uint64, supply string, blockNumber uint64) *MsgVoteGasPrice { + return &MsgVoteGasPrice{ Creator: creator, ChainId: chain, Price: price, @@ -19,15 +19,15 @@ func NewMsgGasPriceVoter(creator string, chain int64, price uint64, supply strin } } -func (msg *MsgGasPriceVoter) Route() string { +func (msg *MsgVoteGasPrice) Route() string { return RouterKey } -func (msg *MsgGasPriceVoter) Type() string { +func (msg *MsgVoteGasPrice) Type() string { return authz.GasPriceVoter.String() } -func (msg *MsgGasPriceVoter) GetSigners() []sdk.AccAddress { +func (msg *MsgVoteGasPrice) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -35,12 +35,12 @@ func (msg *MsgGasPriceVoter) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{creator} } -func (msg *MsgGasPriceVoter) GetSignBytes() []byte { +func (msg *MsgVoteGasPrice) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgGasPriceVoter) ValidateBasic() error { +func (msg *MsgVoteGasPrice) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) diff --git a/x/crosschain/types/message_gas_price_voter_test.go b/x/crosschain/types/message_vote_gas_price_test.go similarity index 75% rename from x/crosschain/types/message_gas_price_voter_test.go rename to x/crosschain/types/message_vote_gas_price_test.go index 10ce98a1bd..295d8b6342 100644 --- a/x/crosschain/types/message_gas_price_voter_test.go +++ b/x/crosschain/types/message_vote_gas_price_test.go @@ -11,15 +11,15 @@ import ( "github.com/zeta-chain/zetacore/x/crosschain/types" ) -func TestMsgGasPriceVoter_ValidateBasic(t *testing.T) { +func TestMsgVoteGasPrice_ValidateBasic(t *testing.T) { tests := []struct { name string - msg *types.MsgGasPriceVoter + msg *types.MsgVoteGasPrice err error }{ { name: "invalid address", - msg: types.NewMsgGasPriceVoter( + msg: types.NewMsgVoteGasPrice( "invalid", 1, 1, @@ -30,7 +30,7 @@ func TestMsgGasPriceVoter_ValidateBasic(t *testing.T) { }, { name: "invalid chain id", - msg: types.NewMsgGasPriceVoter( + msg: types.NewMsgVoteGasPrice( sample.AccAddress(), -1, 1, @@ -41,7 +41,7 @@ func TestMsgGasPriceVoter_ValidateBasic(t *testing.T) { }, { name: "valid address", - msg: types.NewMsgGasPriceVoter( + msg: types.NewMsgVoteGasPrice( sample.AccAddress(), 1, 1, @@ -62,23 +62,23 @@ func TestMsgGasPriceVoter_ValidateBasic(t *testing.T) { } } -func TestMsgGasPriceVoter_GetSigners(t *testing.T) { +func TestMsgVoteGasPrice_GetSigners(t *testing.T) { signer := sample.AccAddress() tests := []struct { name string - msg types.MsgGasPriceVoter + msg types.MsgVoteGasPrice panics bool }{ { name: "valid signer", - msg: types.MsgGasPriceVoter{ + msg: types.MsgVoteGasPrice{ Creator: signer, }, panics: false, }, { name: "invalid signer", - msg: types.MsgGasPriceVoter{ + msg: types.MsgVoteGasPrice{ Creator: "invalid", }, panics: true, @@ -99,22 +99,22 @@ func TestMsgGasPriceVoter_GetSigners(t *testing.T) { } } -func TestMsgGasPriceVoter_Type(t *testing.T) { - msg := types.MsgGasPriceVoter{ +func TestMsgVoteGasPricer_Type(t *testing.T) { + msg := types.MsgVoteGasPrice{ Creator: sample.AccAddress(), } require.Equal(t, authz.GasPriceVoter.String(), msg.Type()) } -func TestMsgGasPriceVoter_Route(t *testing.T) { - msg := types.MsgGasPriceVoter{ +func TestMsgVoteGasPrice_Route(t *testing.T) { + msg := types.MsgVoteGasPrice{ Creator: sample.AccAddress(), } require.Equal(t, types.RouterKey, msg.Route()) } -func TestMsgGasPriceVoter_GetSignBytes(t *testing.T) { - msg := types.MsgGasPriceVoter{ +func TestMsgVoteGasPrice_GetSignBytes(t *testing.T) { + msg := types.MsgVoteGasPrice{ Creator: sample.AccAddress(), } require.NotPanics(t, func() { 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, 0x7a, 0xbb, 0x33, 0xdf, 0x37, 0xbf, 0xdf, 0x6f, - 0xbe, 0xf9, 0xf6, 0xfb, 0xa6, 0xf8, 0x80, 0x5e, 0x61, 0xae, 0xab, 0x97, 0xa9, 0xe5, 0x68, 0xb7, - 0xab, 0x46, 0x65, 0x3d, 0xb7, 0x5a, 0x61, 0x1e, 0x23, 0x23, 0x77, 0x0d, 0x8f, 0xf2, 0xd7, 0x39, - 0xfe, 0x8b, 0x55, 0x8c, 0x5c, 0x7d, 0xaa, 0x72, 0x4c, 0x67, 0xee, 0x0a, 0x73, 0xb5, 0x65, 0xea, - 0x1a, 0x81, 0x9d, 0x76, 0xe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ad, 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, 0x01, 0xa6, 0x08, 0x81, 0x7b, 0x08, 0xab, 0x49, 0x04, - 0x66, 0xd7, 0xe7, 0x7c, 0x24, 0xa1, 0x5e, 0x83, 0xb8, 0x87, 0x23, 0x83, 0x3d, 0x0f, 0x1e, 0x62, - 0x2a, 0x76, 0xb7, 0xad, 0xe2, 0x2f, 0x08, 0x8f, 0x35, 0x05, 0xf1, 0x9c, 0x88, 0xf9, 0x31, 0xc2, - 0x87, 0x43, 0x1e, 0x57, 0x9d, 0x34, 0x2d, 0x5f, 0xc6, 0xbd, 0x41, 0xe6, 0xb2, 0x4a, 0xd1, 0x23, - 0x54, 0xea, 0x98, 0xa0, 0x3f, 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2, 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, 0x16, 0x7b, 0x0d, 0xe3, 0x07, + 0xf6, 0x83, 0xe7, 0x1d, 0x30, 0x60, 0x1e, 0x60, 0x9e, 0xb2, 0x36, 0xb1, 0x41, 0x31, 0xe0, 0xac, + 0x1c, 0x25, 0x22, 0x8a, 0x56, 0xed, 0xd9, 0x66, 0x76, 0xc4, 0x78, 0xc6, 0xec, 0xcc, 0x22, 0x1b, + 0xcb, 0x17, 0x0e, 0x39, 0x47, 0xe2, 0x90, 0x4b, 0xae, 0x51, 0x72, 0xc8, 0x21, 0x52, 0xa2, 0xe4, + 0x10, 0x89, 0x28, 0x4a, 0x42, 0x38, 0x22, 0x45, 0x8a, 0xa2,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, 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, 0xec, 0xf7, 0x1a, 0x4f, 0x7e, + 0x9b, 0x1f, 0xd3, 0x26, 0xdc, 0xc2, 0x24, 0x39, 0x20, 0xfa, 0x0e, 0x1e, 0x88, 0x4c, 0x81, 0x49, + 0xf3, 0x2d, 0xf8, 0x46, 0x15, 0x46, 0xd5, 0x28, 0x95, 0xc6, 0xe5, 0x48, 0x01, 0xdd, 0xa9, 0x93, + 0xfc, 0x01, 0x01, 0xcf,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39, 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, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0x4e, 0x32, 0x31, + 0x14, 0x85, 0xa7, 0xc0, 0xcf, 0x2f, 0x65, 0x63, 0x1a, 0x62, 0x26, 0x26, 0x0e, 0x13, 0x4c, 0x74, + 0x5c, 0xd0, 0x2a, 0xbe, 0xc1, 0x60, 0xdc, 0xe8, 0xc6, 0x49, 0xdc, 0xb8, 0x21, 0x43, 0x29, 0x43, + 0x23, 0xb4, 0xa4, 0xad, 0xa2, 0x3c, 0x85, 0x8f, 0xc5, 0x92, 0xa5, 0x31, 0x86, 0x18, 0x78, 0x11, + 0x33, 0x9d, 0x41, 0x66, 0x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6f, 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 076bcecaec..f7fa9790e4 100644 --- a/x/crosschain/types/tx.pb.go +++ b/x/crosschain/types/tx.pb.go @@ -714,7 +714,7 @@ func (m *MsgRemoveFromOutTxTrackerResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveFromOutTxTrackerResponse proto.InternalMessageInfo -type MsgGasPriceVoter struct { +type MsgVoteGasPrice 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"` Price uint64 `protobuf:"varint,3,opt,name=price,proto3" json:"price,omitempty"` @@ -722,18 +722,18 @@ type MsgGasPriceVoter struct { Supply string `protobuf:"bytes,5,opt,name=supply,proto3" json:"supply,omitempty"` } -func (m *MsgGasPriceVoter) Reset() { *m = MsgGasPriceVoter{} } -func (m *MsgGasPriceVoter) String() string { return proto.CompactTextString(m) } -func (*MsgGasPriceVoter) ProtoMessage() {} -func (*MsgGasPriceVoter) Descriptor() ([]byte, []int) { +func (m *MsgVoteGasPrice) Reset() { *m = MsgVoteGasPrice{} } +func (m *MsgVoteGasPrice) String() string { return proto.CompactTextString(m) } +func (*MsgVoteGasPrice) ProtoMessage() {} +func (*MsgVoteGasPrice) Descriptor() ([]byte, []int) { return fileDescriptor_81d6d611190b7635, []int{12} } -func (m *MsgGasPriceVoter) XXX_Unmarshal(b []byte) error { +func (m *MsgVoteGasPrice) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgGasPriceVoter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgVoteGasPrice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgGasPriceVoter.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgVoteGasPrice.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -743,68 +743,68 @@ func (m *MsgGasPriceVoter) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *MsgGasPriceVoter) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgGasPriceVoter.Merge(m, src) +func (m *MsgVoteGasPrice) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteGasPrice.Merge(m, src) } -func (m *MsgGasPriceVoter) XXX_Size() int { +func (m *MsgVoteGasPrice) XXX_Size() int { return m.Size() } -func (m *MsgGasPriceVoter) XXX_DiscardUnknown() { - xxx_messageInfo_MsgGasPriceVoter.DiscardUnknown(m) +func (m *MsgVoteGasPrice) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteGasPrice.DiscardUnknown(m) } -var xxx_messageInfo_MsgGasPriceVoter proto.InternalMessageInfo +var xxx_messageInfo_MsgVoteGasPrice proto.InternalMessageInfo -func (m *MsgGasPriceVoter) GetCreator() string { +func (m *MsgVoteGasPrice) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgGasPriceVoter) GetChainId() int64 { +func (m *MsgVoteGasPrice) GetChainId() int64 { if m != nil { return m.ChainId } return 0 } -func (m *MsgGasPriceVoter) GetPrice() uint64 { +func (m *MsgVoteGasPrice) GetPrice() uint64 { if m != nil { return m.Price } return 0 } -func (m *MsgGasPriceVoter) GetBlockNumber() uint64 { +func (m *MsgVoteGasPrice) GetBlockNumber() uint64 { if m != nil { return m.BlockNumber } return 0 } -func (m *MsgGasPriceVoter) GetSupply() string { +func (m *MsgVoteGasPrice) GetSupply() string { if m != nil { return m.Supply } return "" } -type MsgGasPriceVoterResponse struct { +type MsgVoteGasPriceResponse struct { } -func (m *MsgGasPriceVoterResponse) Reset() { *m = MsgGasPriceVoterResponse{} } -func (m *MsgGasPriceVoterResponse) String() string { return proto.CompactTextString(m) } -func (*MsgGasPriceVoterResponse) ProtoMessage() {} -func (*MsgGasPriceVoterResponse) Descriptor() ([]byte, []int) { +func (m *MsgVoteGasPriceResponse) Reset() { *m = MsgVoteGasPriceResponse{} } +func (m *MsgVoteGasPriceResponse) String() string { return proto.CompactTextString(m) } +func (*MsgVoteGasPriceResponse) ProtoMessage() {} +func (*MsgVoteGasPriceResponse) Descriptor() ([]byte, []int) { return fileDescriptor_81d6d611190b7635, []int{13} } -func (m *MsgGasPriceVoterResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgVoteGasPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgGasPriceVoterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgVoteGasPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgGasPriceVoterResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgVoteGasPriceResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -814,17 +814,17 @@ func (m *MsgGasPriceVoterResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgGasPriceVoterResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgGasPriceVoterResponse.Merge(m, src) +func (m *MsgVoteGasPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVoteGasPriceResponse.Merge(m, src) } -func (m *MsgGasPriceVoterResponse) XXX_Size() int { +func (m *MsgVoteGasPriceResponse) XXX_Size() int { return m.Size() } -func (m *MsgGasPriceVoterResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgGasPriceVoterResponse.DiscardUnknown(m) +func (m *MsgVoteGasPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVoteGasPriceResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgGasPriceVoterResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgVoteGasPriceResponse proto.InternalMessageInfo type MsgVoteOnObservedOutboundTx struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` @@ -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") @@ -1357,8 +1445,8 @@ func init() { proto.RegisterType((*MsgAddToOutTxTrackerResponse)(nil), "zetachain.zetacore.crosschain.MsgAddToOutTxTrackerResponse") proto.RegisterType((*MsgRemoveFromOutTxTracker)(nil), "zetachain.zetacore.crosschain.MsgRemoveFromOutTxTracker") proto.RegisterType((*MsgRemoveFromOutTxTrackerResponse)(nil), "zetachain.zetacore.crosschain.MsgRemoveFromOutTxTrackerResponse") - proto.RegisterType((*MsgGasPriceVoter)(nil), "zetachain.zetacore.crosschain.MsgGasPriceVoter") - proto.RegisterType((*MsgGasPriceVoterResponse)(nil), "zetachain.zetacore.crosschain.MsgGasPriceVoterResponse") + proto.RegisterType((*MsgVoteGasPrice)(nil), "zetachain.zetacore.crosschain.MsgVoteGasPrice") + proto.RegisterType((*MsgVoteGasPriceResponse)(nil), "zetachain.zetacore.crosschain.MsgVoteGasPriceResponse") proto.RegisterType((*MsgVoteOnObservedOutboundTx)(nil), "zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx") proto.RegisterType((*MsgVoteOnObservedOutboundTxResponse)(nil), "zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTxResponse") proto.RegisterType((*MsgVoteOnObservedInboundTx)(nil), "zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx") @@ -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{ - // 1451 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0x5d, 0x6b, 0xdb, 0x56, - 0x3b, 0x7a, 0x93, 0x38, 0xf6, 0x93, 0xd8, 0x69, 0x95, 0xb4, 0x71, 0x95, 0xc6, 0x49, 0x95, 0xb7, - 0x7d, 0x03, 0x2f, 0xb5, 0x5b, 0x97, 0x97, 0xb7, 0xed, 0x36, 0x58, 0x12, 0xfa, 0x91, 0xad, 0x69, - 0x8a, 0xea, 0x6e, 0x63, 0x37, 0x42, 0x96, 0x4e, 0x64, 0x11, 0x5b, 0xc7, 0xe8, 0x1c, 0x05, 0x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 0x2d, 0xf6, 0xdf, 0x0a, 0x80, 0xc7, 0xcc, 0x80, 0x34, 0xe8, 0x21, 0x71, 0xd0, 0xca, 0xb4, - 0x91, 0xf1, 0x98, 0x21, 0x10, 0xfa, 0x3e, 0xfa, 0x5e, 0x40, 0x0f, 0x03, 0xda, 0x78, 0x47, 0xee, - 0xd1, 0xd7, 0xe1, 0xda, 0x40, 0x39, 0x71, 0x76, 0xff, 0xa8, 0xc0, 0x85, 0x5d, 0xe6, 0x3e, 0xb2, - 0xd8, 0xb3, 0xc0, 0xb3, 0xc9, 0x27, 0x94, 0x9f, 0x43, 0x89, 0x66, 0xc4, 0xa2, 0xa3, 0x04, 0x02, - 0xea, 0x35, 0x98, 0x13, 0x5e, 0xf6, 0xc3, 0x46, 0x95, 0x04, 0x18, 0xa8, 0x29, 0x63, 0x16, 0x71, - 0x4f, 0x11, 0x85, 0xc9, 0x1d, 0x36, 0x9b, 0xf5, 0x76, 0x9c, 0xdc, 0x08, 0xe9, 0x1a, 0xe4, 0x7b, - 0x35, 0x8b, 0xd5, 0xfe, 0x65, 0x1a, 0x8b, 0x36, 0x42, 0xee, 0xf9, 0x7b, 0x55, 0x46, 0x82, 0x43, - 0xe2, 0xec, 0x85, 0xbc, 0x4a, 0x43, 0xdf, 0xa9, 0xb4, 0x86, 0x58, 0xb0, 0x0c, 0x98, 0xa5, 0x22, - 0xea, 0x22, 0x6d, 0xd3, 0x11, 0x02, 0x83, 0x5e, 0x84, 0x05, 0x2a, 0x99, 0x99, 0x34, 0x72, 0x57, - 0x77, 0xef, 0xba, 0x48, 0x8f, 0xe5, 0x54, 0xc4, 0xfd, 0xf7, 0x41, 0xeb, 0xb9, 0x2f, 0x12, 0x88, - 0x78, 0x6e, 0x8d, 0x4b, 0x5b, 0xf3, 0x09, 0xb2, 0xad, 0xe3, 0x73, 0xf5, 0x7f, 0xb0, 0xd4, 0x43, - 0x1d, 0x15, 0x6c, 0xc8, 0x88, 0x93, 0x07, 0x24, 0x5d, 0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f, 0xfa, 0x0e, 0x5e, 0x21, 0xce, 0xb9, 0xa4, 0x89, 0x7c, - 0x8a, 0xb8, 0xc5, 0x9b, 0x88, 0xe8, 0xc4, 0x59, 0x81, 0x95, 0xab, 0x88, 0x5e, 0xc0, 0x79, 0xdc, - 0x27, 0xb7, 0xa3, 0x57, 0xf9, 0xcf, 0x59, 0x98, 0xdc, 0x65, 0xae, 0xfa, 0x8d, 0x02, 0x17, 0xfb, - 0x17, 0x92, 0x3b, 0xc5, 0xa1, 0xef, 0x23, 0xc5, 0x93, 0x46, 0xbd, 0xf6, 0xde, 0x19, 0x88, 0xe2, - 0xfd, 0xe0, 0x6b, 0x05, 0x2e, 0xf4, 0xed, 0xd7, 0xe5, 0x31, 0x39, 0x76, 0xd1, 0x68, 0xf7, 0x4f, - 0x4f, 0x13, 0x2b, 0xf1, 0xbd, 0x02, 0x97, 0x07, 0xec, 0x20, 0x77, 0x47, 0xb3, 0x3d, 0x99, 0x52, - 0xfb, 0xf0, 0xac, 0x94, 0xb1, 0x5a, 0x6d, 0xc8, 0x26, 0x77, 0x91, 0xd2, 0x68, 0x96, 0x09, 0x02, - 0xed, 0xff, 0xa7, 0x24, 0x88, 0x45, 0xff, 0xa4, 0x40, 0x7e, 0xe0, 0x42, 0x31, 0x86, 0xab, 0x07, - 0xd1, 0x6a, 0x5b, 0x67, 0xa7, 0x8d, 0x95, 0xfb, 0x41, 0x81, 0xa5, 0x41, 0xcd, 0xfe, 0xde, 0x69, - 0xf9, 0xc7, 0xa4, 0xda, 0xe6, 0x99, 0x49, 0x63, 0xcd, 0xbe, 0x80, 0x5c, 0xcf, 0xbb, 0xd1, 0xad, - 0xd1, 0x4c, 0x93, 0x14, 0xda, 0xdd, 0xd3, 0x52, 0x24, 0x6a, 0xa9, 0xef, 0xdd, 0x78, 0x8c, 0x5a, - 0xea, 0xa5, 0x19, 0xa7, 0x96, 0x06, 0xbd, 0x33, 0xab, 0x5f, 0xc2, 0x7c, 0xef, 0x17, 0x85, 0xdb, - 0xa3, 0xd9, 0xf5, 0x90, 0x68, 0xf7, 0x4e, 0x4d, 0xd2, 0x1d, 0x83, 0x9e, 0x0e, 0x3f, 0x46, 0x0c, - 0x92, 0x14, 0xe3, 0xc4, 0xe0, 0xe4, 0xbe, 0x8f, 0x7d, 0xb5, 0xbf, 0xeb, 0xdf, 0x19, 0xa7, 0x17, - 0xf4, 0x10, 0x8d, 0xd3, 0x57, 0x07, 0xf6, 0xf9, 0xad, 0x8f, 0x5f, 0xbe, 0x29, 0x28, 0xaf, 0xde, - 0x14, 0x94, 0x3f, 0xde, 0x14, 0x94, 0x6f, 0xdf, 0x16, 0x26, 0x5e, 0xbd, 0x2d, 0x4c, 0xfc, 0xfa, - 0xb6, 0x30, 0xf1, 0xf9, 0xed, 0xae, 0xcd, 0x22, 0x62, 0x7b, 0x53, 0x7c, 0x92, 0xea, 0x48, 0x28, - 0xb5, 0x4a, 0xdd, 0x1f, 0xaa, 0xa2, 0x45, 0xa3, 0x9a, 0xc2, 0x0f, 0x46, 0x77, 0xfe, 0x09, 0x00, - 0x00, 0xff, 0xff, 0xef, 0x61, 0xc8, 0xd2, 0xc3, 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, 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x06, 0x97, 0xba, 0x99, 0x16, 0xf9, 0x6f, + 0x19, 0xc0, 0x63, 0x66, 0x40, 0xea, 0xf4, 0x90, 0x38, 0x68, 0x65, 0xca, 0x48, 0x7b, 0xcc, 0x90, + 0x88, 0xc2, 0x1e, 0xfa, 0x5e, 0x42, 0xf7, 0x02, 0x5a, 0x7f, 0x47, 0xee, 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, 0x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 0xb7, 0x4f, 0xcb, 0x3f, 0x22, + 0xcd, 0x6d, 0x9c, 0x99, 0x34, 0xd2, 0xec, 0x3b, 0x98, 0x49, 0xbc, 0xd8, 0x5d, 0x1f, 0xcc, 0x34, + 0x4e, 0x91, 0xbb, 0x75, 0x5a, 0x8a, 0x58, 0x21, 0x75, 0xbc, 0xd8, 0x0f, 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. @@ -1481,7 +1576,7 @@ type MsgClient interface { AddToOutTxTracker(ctx context.Context, in *MsgAddToOutTxTracker, opts ...grpc.CallOption) (*MsgAddToOutTxTrackerResponse, error) AddToInTxTracker(ctx context.Context, in *MsgAddToInTxTracker, opts ...grpc.CallOption) (*MsgAddToInTxTrackerResponse, error) RemoveFromOutTxTracker(ctx context.Context, in *MsgRemoveFromOutTxTracker, opts ...grpc.CallOption) (*MsgRemoveFromOutTxTrackerResponse, error) - GasPriceVoter(ctx context.Context, in *MsgGasPriceVoter, opts ...grpc.CallOption) (*MsgGasPriceVoterResponse, error) + VoteGasPrice(ctx context.Context, in *MsgVoteGasPrice, opts ...grpc.CallOption) (*MsgVoteGasPriceResponse, error) VoteOnObservedOutboundTx(ctx context.Context, in *MsgVoteOnObservedOutboundTx, opts ...grpc.CallOption) (*MsgVoteOnObservedOutboundTxResponse, error) VoteOnObservedInboundTx(ctx context.Context, in *MsgVoteOnObservedInboundTx, opts ...grpc.CallOption) (*MsgVoteOnObservedInboundTxResponse, error) WhitelistERC20(ctx context.Context, in *MsgWhitelistERC20, opts ...grpc.CallOption) (*MsgWhitelistERC20Response, error) @@ -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 { @@ -1526,9 +1622,9 @@ func (c *msgClient) RemoveFromOutTxTracker(ctx context.Context, in *MsgRemoveFro return out, nil } -func (c *msgClient) GasPriceVoter(ctx context.Context, in *MsgGasPriceVoter, opts ...grpc.CallOption) (*MsgGasPriceVoterResponse, error) { - out := new(MsgGasPriceVoterResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Msg/GasPriceVoter", in, out, opts...) +func (c *msgClient) VoteGasPrice(ctx context.Context, in *MsgVoteGasPrice, opts ...grpc.CallOption) (*MsgVoteGasPriceResponse, error) { + out := new(MsgVoteGasPriceResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Msg/VoteGasPrice", in, out, opts...) if err != nil { return nil, err } @@ -1598,12 +1694,21 @@ 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) AddToInTxTracker(context.Context, *MsgAddToInTxTracker) (*MsgAddToInTxTrackerResponse, error) RemoveFromOutTxTracker(context.Context, *MsgRemoveFromOutTxTracker) (*MsgRemoveFromOutTxTrackerResponse, error) - GasPriceVoter(context.Context, *MsgGasPriceVoter) (*MsgGasPriceVoterResponse, error) + VoteGasPrice(context.Context, *MsgVoteGasPrice) (*MsgVoteGasPriceResponse, error) VoteOnObservedOutboundTx(context.Context, *MsgVoteOnObservedOutboundTx) (*MsgVoteOnObservedOutboundTxResponse, error) VoteOnObservedInboundTx(context.Context, *MsgVoteOnObservedInboundTx) (*MsgVoteOnObservedInboundTxResponse, error) WhitelistERC20(context.Context, *MsgWhitelistERC20) (*MsgWhitelistERC20Response, 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. @@ -1626,8 +1732,8 @@ func (*UnimplementedMsgServer) AddToInTxTracker(ctx context.Context, req *MsgAdd func (*UnimplementedMsgServer) RemoveFromOutTxTracker(ctx context.Context, req *MsgRemoveFromOutTxTracker) (*MsgRemoveFromOutTxTrackerResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RemoveFromOutTxTracker not implemented") } -func (*UnimplementedMsgServer) GasPriceVoter(ctx context.Context, req *MsgGasPriceVoter) (*MsgGasPriceVoterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GasPriceVoter not implemented") +func (*UnimplementedMsgServer) VoteGasPrice(ctx context.Context, req *MsgVoteGasPrice) (*MsgVoteGasPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VoteGasPrice not implemented") } func (*UnimplementedMsgServer) VoteOnObservedOutboundTx(ctx context.Context, req *MsgVoteOnObservedOutboundTx) (*MsgVoteOnObservedOutboundTxResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method VoteOnObservedOutboundTx not implemented") @@ -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) @@ -1709,20 +1818,20 @@ func _Msg_RemoveFromOutTxTracker_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } -func _Msg_GasPriceVoter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgGasPriceVoter) +func _Msg_VoteGasPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgVoteGasPrice) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).GasPriceVoter(ctx, in) + return srv.(MsgServer).VoteGasPrice(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.crosschain.Msg/GasPriceVoter", + FullMethod: "/zetachain.zetacore.crosschain.Msg/VoteGasPrice", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).GasPriceVoter(ctx, req.(*MsgGasPriceVoter)) + return srv.(MsgServer).VoteGasPrice(ctx, req.(*MsgVoteGasPrice)) } return interceptor(ctx, in, info, handler) } @@ -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), @@ -1870,8 +1997,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_RemoveFromOutTxTracker_Handler, }, { - MethodName: "GasPriceVoter", - Handler: _Msg_GasPriceVoter_Handler, + MethodName: "VoteGasPrice", + Handler: _Msg_VoteGasPrice_Handler, }, { MethodName: "VoteOnObservedOutboundTx", @@ -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", @@ -2398,7 +2529,7 @@ func (m *MsgRemoveFromOutTxTrackerResponse) MarshalToSizedBuffer(dAtA []byte) (i return len(dAtA) - i, nil } -func (m *MsgGasPriceVoter) Marshal() (dAtA []byte, err error) { +func (m *MsgVoteGasPrice) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2408,12 +2539,12 @@ func (m *MsgGasPriceVoter) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgGasPriceVoter) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgVoteGasPrice) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgGasPriceVoter) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgVoteGasPrice) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2450,7 +2581,7 @@ func (m *MsgGasPriceVoter) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgGasPriceVoterResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgVoteGasPriceResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2460,12 +2591,12 @@ func (m *MsgGasPriceVoterResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgGasPriceVoterResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgVoteGasPriceResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgGasPriceVoterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgVoteGasPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -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 @@ -3089,7 +3283,7 @@ func (m *MsgRemoveFromOutTxTrackerResponse) Size() (n int) { return n } -func (m *MsgGasPriceVoter) Size() (n int) { +func (m *MsgVoteGasPrice) Size() (n int) { if m == nil { return 0 } @@ -3115,7 +3309,7 @@ func (m *MsgGasPriceVoter) Size() (n int) { return n } -func (m *MsgGasPriceVoterResponse) Size() (n int) { +func (m *MsgVoteGasPriceResponse) Size() (n int) { if m == nil { return 0 } @@ -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 } @@ -4773,7 +4991,7 @@ func (m *MsgRemoveFromOutTxTrackerResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgGasPriceVoter) Unmarshal(dAtA []byte) error { +func (m *MsgVoteGasPrice) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4796,10 +5014,10 @@ func (m *MsgGasPriceVoter) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgGasPriceVoter: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteGasPrice: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgGasPriceVoter: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteGasPrice: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -4944,7 +5162,7 @@ func (m *MsgGasPriceVoter) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgGasPriceVoterResponse) Unmarshal(dAtA []byte) error { +func (m *MsgVoteGasPriceResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4967,10 +5185,10 @@ func (m *MsgGasPriceVoterResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgGasPriceVoterResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgVoteGasPriceResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgGasPriceVoterResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgVoteGasPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -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 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/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/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, 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, 0x32, 0x56, - 0x17, 0x6c, 0x83, 0x3e, 0xcc, 0x06, 0xfd, 0x0a, 0x7d, 0x78, 0xb0, 0x97, 0x54, 0x16, 0xa4, 0x16, - 0x27, 0xb1, 0x81, 0xc3, 0xd5, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xf8, 0xb7, 0xd4, 0xf9, - 0x01, 0x00, 0x00, + 0xf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, 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, 0x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, 0x18, 0xa2, 0xe7, 0x14, 0x36, 0x65, - 0x7f, 0x74, 0x5f, 0x09, 0xdb, 0x23, 0xbb, 0x65, 0x85, 0xa1, 0xbf, 0x39, 0x43, 0x6d, 0x89, 0x67, - 0x64, 0x64, 0x80, 0x99, 0x53, 0x67, 0xfc, 0xb3, 0xd9, 0xbb, 0x8c, 0x4f, 0x97, 0x91, 0x59, 0xec, - 0xf2, 0xf4, 0x53, 0x25, 0x73, 0x97, 0x3c, 0x9e, 0x94, 0xa9, 0xd3, 0x95, 0xd1, 0x4b, 0x7e, 0x34, - 0x60, 0x45, 0x3b, 0x33, 0xd9, 0x2e, 0x26, 0x35, 0xe5, 0xfb, 0xe6, 0xce, 0xff, 0x81, 0x20, 0xeb, - 0x2d, 0xc5, 0x7a, 0x93, 0x3c, 0xc8, 0xbc, 0x9c, 0xe4, 0x4d, 0x70, 0x86, 0x38, 0x6d, 0x67, 0xfb, - 0x4f, 0x5f, 0x8c, 0x2c, 0xe3, 0xe5, 0xc8, 0x32, 0xfe, 0x1a, 0x59, 0xc6, 0xf3, 0x73, 0x6b, 0xe1, - 0xe5, 0xb9, 0xb5, 0xf0, 0xfb, 0xb9, 0xb5, 0xf0, 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, 0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0xb8, 0xac, 0x21, 0xe7, 0x54, 0xb7, 0xc0, 0xd2, 0xe3, 0x9e, 0xa6, 0x3d, + 0xec, 0xee, 0x7a, 0x2d, 0x8b, 0xbd, 0x8e, 0x25, 0x7c, 0xdc, 0xc2, 0xd4, 0x85, 0x49, 0x30, 0x63, + 0x39, 0x55, 0x7c, 0xba, 0x28, 0xfd, 0x23, 0xad, 0xcf, 0x96, 0xbc, 0x85, 0x4a, 0xc1, 0x72, 0x30, + 0x88, 0x36, 0x88, 0x43, 0x31, 0x3c, 0x04, 0xf3, 0x47, 0x7d, 0xef, 0x19, 0x78, 0x2e, 0xfb, 0xbf, + 0x36, 0x62, 0x4c, 0x5a, 0x3f, 0x51, 0xe1, 0x97, 0xf3, 0x4f, 0xa9, 0x58, 0x69, 0x80, 0x44, 0xc5, + 0x5c, 0x69, 0xde, 0xb6, 0x83, 0x94, 0xee, 0x02, 0x70, 0x35, 0x4e, 0xde, 0x71, 0x55, 0xf3, 0x66, + 0xaf, 0xf5, 0x66, 0xaf, 0x79, 0x27, 0xc6, 0x67, 0xaf, 0x1d, 0x20, 0x13, 0x73, 0x6c, 0xa9, 0x0f, + 0xa9, 0xbe, 0x95, 0xb8, 0xb9, 0x1f, 0xfa, 0x84, 0x9a, 0x9b, 0xbe, 0xb6, 0x39, 0xb8, 0x37, 0xa0, + 0x7e, 0x8a, 0xa9, 0x5f, 0x1b, 0xab, 0xde, 0x53, 0x34, 0x20, 0x3f, 0x05, 0xfe, 0x16, 0x47, 0x73, + 0xc8, 0x2e, 0x49, 0x91, 0xdf, 0x11, 0xee, 0x55, 0xed, 0x00, 0x25, 0xac, 0x80, 0x1b, 0x7c, 0x02, + 0x16, 0x06, 0x77, 0xf8, 0x34, 0x6f, 0x8c, 0xb4, 0x38, 0x08, 0xe1, 0x26, 0x87, 0x88, 0xd4, 0x7f, + 0x41, 0x4a, 0x34, 0xdf, 0x43, 0xf4, 0xd0, 0x45, 0x15, 0xcb, 0xb6, 0xdc, 0xf6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f0, 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 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,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 0x7f, 0xfd, 0x0a, 0x7d, 0xe4, 0x30, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, + 0x7b, 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, 0x9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0x16, 0xb5, + 0x06, 0xfd, 0x3f, 0xc9, 0x6a, 0xed, 0xd4, 0x48, 0x3d, 0x06, 0x1b, 0x9a, 0x86, 0x23, 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, 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 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,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, + 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x74, 0x5d, 0xb0, 0x45, 0xfa, 0x30, 0x8b, 0xf4, 0x2b, 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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 0xaf, 0x2e, 0x97, 0xff, + 0x1f, 0x00, 0x00, 0xff, 0xff, 0x06, 0x38, 0x4f, 0x59, 0xb3, 0x24, 0x00, 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, 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 0x6a, 0xc4, 0x0f, 0xc7, 0x84, 0xa4, 0x46, 0x8c, 0xf7, 0x70, 0xcd, 0xd2, - 0x5d, 0x20, 0xd5, 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, 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f3, 0x67, 0xb3, 0xda, 0x17, 0xcf, 0x66, 0xb5, 0x2f, - 0x9f, 0xcd, 0x6a, 0x1f, 0x3f, 0x9f, 0xdd, 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, 0xc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x7c, 0x44, 0x39, 0xbe, - 0x5d, 0xeb, 0x6e, 0x27, 0xad, 0x8b, 0xea, 0xd8, 0x09, 0x49, 0x8d, 0x8a, 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, 0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0x5c, 0x14, 0x8d, 0x7f, 0x2e, 0x8a, 0xc6, 0x2f, 0x97, 0xc5, 0xa1, 0x37, 0x97, 0xc5, 0xa1, 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, + 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 0x61, 0xa2, 0x65, 0x1d, 0xad, 0xf5, 0x51, 0xc6, 0x04, 0x9d, 0x7b, 0x7f, + 0x10, 0x74, 0xe2, 0xf3, 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 110c89c474..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) @@ -504,15 +504,15 @@ func (ob *BTCChainClient) ConfirmationsThreshold(amount *big.Int) int64 { return int64(ob.GetChainParams().ConfirmationCount) } -// IsSendOutTxProcessed returns isIncluded(or inMempool), isConfirmed, Error -func (ob *BTCChainClient) IsSendOutTxProcessed(cctx *types.CrossChainTx, logger zerolog.Logger) (bool, bool, error) { +// IsOutboundProcessed returns isIncluded(or inMempool), isConfirmed, Error +func (ob *BTCChainClient) IsOutboundProcessed(cctx *types.CrossChainTx, logger zerolog.Logger) (bool, bool, error) { params := *cctx.GetCurrentOutTxParam() sendHash := cctx.Index nonce := cctx.GetCurrentOutTxParam().OutboundTxTssNonce // get broadcasted outtx and tx result outTxID := ob.GetTxID(nonce) - logger.Info().Msgf("IsSendOutTxProcessed %s", outTxID) + logger.Info().Msgf("IsOutboundProcessed %s", outTxID) ob.Mu.Lock() txnHash, broadcasted := ob.broadcastedTx[outTxID] @@ -537,7 +537,7 @@ func (ob *BTCChainClient) IsSendOutTxProcessed(cctx *types.CrossChainTx, logger if txResult == nil { // check failed, try again next time return false, false, nil } else if inMempool { // still in mempool (should avoid unnecessary Tss keysign) - ob.logger.OutTx.Info().Msgf("IsSendOutTxProcessed: outTx %s is still in mempool", outTxID) + ob.logger.OutTx.Info().Msgf("IsOutboundProcessed: outTx %s is still in mempool", outTxID) return true, false, nil } // included @@ -548,7 +548,7 @@ func (ob *BTCChainClient) IsSendOutTxProcessed(cctx *types.CrossChainTx, logger if res == nil { return false, false, nil } - ob.logger.OutTx.Info().Msgf("IsSendOutTxProcessed: setIncludedTx succeeded for outTx %s", outTxID) + ob.logger.OutTx.Info().Msgf("IsOutboundProcessed: setIncludedTx succeeded for outTx %s", outTxID) } // It's safe to use cctx's amount to post confirmation because it has already been verified in observeOutTx() @@ -573,9 +573,9 @@ func (ob *BTCChainClient) IsSendOutTxProcessed(cctx *types.CrossChainTx, logger coin.CoinType_Gas, ) if err != nil { - logger.Error().Err(err).Msgf("IsSendOutTxProcessed: error confirming bitcoin outTx %s, nonce %d ballot %s", res.TxID, nonce, ballot) + logger.Error().Err(err).Msgf("IsOutboundProcessed: error confirming bitcoin outTx %s, nonce %d ballot %s", res.TxID, nonce, ballot) } else if zetaHash != "" { - logger.Info().Msgf("IsSendOutTxProcessed: confirmed Bitcoin outTx %s, zeta tx hash %s nonce %d ballot %s", res.TxID, zetaHash, nonce, ballot) + logger.Info().Msgf("IsOutboundProcessed: confirmed Bitcoin outTx %s, zeta tx hash %s nonce %d ballot %s", res.TxID, zetaHash, nonce, ballot) } return true, true, nil } diff --git a/zetaclient/compliance/compliance_test.go b/zetaclient/compliance/compliance_test.go index 001e5d9e0d..c88e3b5da8 100644 --- a/zetaclient/compliance/compliance_test.go +++ b/zetaclient/compliance/compliance_test.go @@ -1,20 +1,19 @@ package compliance import ( - "path" "testing" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" - crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/zetaclient/config" "github.com/zeta-chain/zetacore/zetaclient/testutils" ) func TestCctxRestricted(t *testing.T) { // load archived cctx - var cctx crosschaintypes.CrossChainTx - testutils.LoadObjectFromJSONFile(t, &cctx, path.Join("../", testutils.TestDataPathCctx, "cctx_1_6270.json")) + chain := chains.EthChain() + cctx := testutils.LoadCctxByNonce(t, chain.ChainId, 6270) // create config cfg := config.Config{ @@ -24,29 +23,29 @@ func TestCctxRestricted(t *testing.T) { t.Run("should return true if sender is restricted", func(t *testing.T) { cfg.ComplianceConfig.RestrictedAddresses = []string{cctx.InboundTxParams.Sender} config.LoadComplianceConfig(cfg) - require.True(t, IsCctxRestricted(&cctx)) + require.True(t, IsCctxRestricted(cctx)) }) t.Run("should return true if receiver is restricted", func(t *testing.T) { cfg.ComplianceConfig.RestrictedAddresses = []string{cctx.GetCurrentOutTxParam().Receiver} config.LoadComplianceConfig(cfg) - require.True(t, IsCctxRestricted(&cctx)) + require.True(t, IsCctxRestricted(cctx)) }) t.Run("should return false if sender and receiver are not restricted", func(t *testing.T) { // restrict other address cfg.ComplianceConfig.RestrictedAddresses = []string{"0x27104b8dB4aEdDb054fCed87c346C0758Ff5dFB1"} config.LoadComplianceConfig(cfg) - require.False(t, IsCctxRestricted(&cctx)) + require.False(t, IsCctxRestricted(cctx)) }) t.Run("should be able to restrict coinbase address", func(t *testing.T) { cfg.ComplianceConfig.RestrictedAddresses = []string{ethcommon.Address{}.String()} config.LoadComplianceConfig(cfg) cctx.InboundTxParams.Sender = ethcommon.Address{}.String() - require.True(t, IsCctxRestricted(&cctx)) + require.True(t, IsCctxRestricted(cctx)) }) t.Run("should ignore empty address", func(t *testing.T) { cfg.ComplianceConfig.RestrictedAddresses = []string{""} config.LoadComplianceConfig(cfg) cctx.InboundTxParams.Sender = "" - require.False(t, IsCctxRestricted(&cctx)) + require.False(t, IsCctxRestricted(cctx)) }) } 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 450176df90..63e8da7d7c 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -31,11 +31,9 @@ import ( "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/pkg/proofs" - crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" - "github.com/zeta-chain/zetacore/zetaclient/compliance" "github.com/zeta-chain/zetacore/zetaclient/config" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" "github.com/zeta-chain/zetacore/zetaclient/interfaces" @@ -72,7 +70,7 @@ type ChainClient struct { chain chains.Chain evmClient interfaces.EVMRPCClient evmJSONRPC interfaces.EVMJSONRPCClient - zetaClient interfaces.ZetaCoreBridger + zetaBridge interfaces.ZetaCoreBridger Tss interfaces.TSSSigner lastBlockScanned uint64 lastBlock uint64 @@ -123,7 +121,7 @@ func NewEVMChainClient( ob.stop = make(chan struct{}) ob.chain = evmCfg.Chain ob.Mu = &sync.Mutex{} - ob.zetaClient = bridge + ob.zetaBridge = bridge ob.txWatchList = make(map[ethcommon.Hash]string) ob.Tss = tss ob.outTxPendingTransactions = make(map[string]*ethtypes.Transaction) @@ -160,11 +158,15 @@ func NewEVMChainClient( return &ob, nil } + +// WithChain attaches a new chain to the chain client func (ob *ChainClient) WithChain(chain chains.Chain) { ob.Mu.Lock() defer ob.Mu.Unlock() ob.chain = chain } + +// WithLogger attaches a new logger to the chain client func (ob *ChainClient) WithLogger(logger zerolog.Logger) { ob.Mu.Lock() defer ob.Mu.Unlock() @@ -176,36 +178,42 @@ func (ob *ChainClient) WithLogger(logger zerolog.Logger) { } } +// WithEvmClient attaches a new evm client to the chain client func (ob *ChainClient) WithEvmClient(client interfaces.EVMRPCClient) { ob.Mu.Lock() defer ob.Mu.Unlock() ob.evmClient = client } +// WithEvmJSONRPC attaches a new evm json rpc client to the chain client func (ob *ChainClient) WithEvmJSONRPC(client interfaces.EVMJSONRPCClient) { ob.Mu.Lock() defer ob.Mu.Unlock() ob.evmJSONRPC = client } -func (ob *ChainClient) WithZetaClient(bridge interfaces.ZetaCoreBridger) { +// WithZetaBridge attaches a new bridge to interact with ZetaCore to the chain client +func (ob *ChainClient) WithZetaBridge(bridge interfaces.ZetaCoreBridger) { ob.Mu.Lock() defer ob.Mu.Unlock() - ob.zetaClient = bridge + ob.zetaBridge = bridge } +// WithBlockCache attaches a new block cache to the chain client func (ob *ChainClient) WithBlockCache(cache *lru.Cache) { ob.Mu.Lock() defer ob.Mu.Unlock() ob.blockCache = cache } +// SetChainParams sets the chain params for the chain client func (ob *ChainClient) SetChainParams(params observertypes.ChainParams) { ob.Mu.Lock() defer ob.Mu.Unlock() ob.chainParams = params } +// GetChainParams returns the chain params for the chain client func (ob *ChainClient) GetChainParams() observertypes.ChainParams { ob.Mu.Lock() defer ob.Mu.Unlock() @@ -317,300 +325,6 @@ func (ob *ChainClient) Stop() { ob.logger.Chain.Info().Msgf("%s observer stopped", ob.chain.String()) } -// returns: isIncluded, isConfirmed, Error -// If isConfirmed, it also post to ZetaCore -func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, logger zerolog.Logger) (bool, bool, error) { - sendHash := cctx.Index - cointype := cctx.InboundTxParams.CoinType - nonce := cctx.GetCurrentOutTxParam().OutboundTxTssNonce - - // skip if outtx is not confirmed - params := ob.GetChainParams() - receipt, transaction := ob.GetTxNReceipt(nonce) - if receipt == nil || transaction == nil { // not confirmed yet - return false, false, nil - } - - sendID := fmt.Sprintf("%s-%d", ob.chain.String(), nonce) - logger = logger.With().Str("sendID", sendID).Logger() - - // compliance check, special handling the cancelled cctx - if compliance.IsCctxRestricted(cctx) { - recvStatus := chains.ReceiveStatus_Failed - if receipt.Status == 1 { - recvStatus = chains.ReceiveStatus_Success - } - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - // use cctx's amount to bypass the amount check in zetacore - cctx.GetCurrentOutTxParam().Amount.BigInt(), - recvStatus, - ob.chain, - nonce, - coin.CoinType_Cmd, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - - if cointype == coin.CoinType_Cmd { - recvStatus := chains.ReceiveStatus_Failed - if receipt.Status == 1 { - recvStatus = chains.ReceiveStatus_Success - } - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - transaction.Value(), - recvStatus, - ob.chain, - nonce, - coin.CoinType_Cmd, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - - } else if cointype == coin.CoinType_Gas { // the outbound is a regular Ether/BNB/Matic transfer; no need to check events - if receipt.Status == 1 { - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - transaction.Value(), - chains.ReceiveStatus_Success, - ob.chain, - nonce, - coin.CoinType_Gas, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } else if receipt.Status == 0 { // the same as below events flow - logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex()) - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - big.NewInt(0), - chains.ReceiveStatus_Failed, - ob.chain, - nonce, - coin.CoinType_Gas, - ) - if err != nil { - logger.Error().Err(err).Msgf("PostVoteOutbound error in WatchTxHashWithTimeout; zeta tx hash %s cctx %s nonce %d", zetaTxHash, sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - } else if cointype == coin.CoinType_Zeta { // the outbound is a Zeta transfer; need to check events ZetaReceived - if receipt.Status == 1 { - logs := receipt.Logs - for _, vLog := range logs { - confHeight := vLog.BlockNumber + params.ConfirmationCount - // TODO rewrite this to return early if not confirmed - connectorAddr, connector, err := ob.GetConnectorContract() - if err != nil { - return false, false, fmt.Errorf("error getting connector contract: %w", err) - } - receivedLog, err := connector.ZetaConnectorNonEthFilterer.ParseZetaReceived(*vLog) - if err == nil { - logger.Info().Msgf("Found (outTx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), vLog.TxHash.Hex()) - if confHeight <= ob.GetLastBlockHeight() { - logger.Info().Msg("Confirmed! Sending PostConfirmation to zetabridge...") - // sanity check tx event - err = ValidateEvmTxLog(vLog, connectorAddr, transaction.Hash().Hex(), TopicsZetaReceived) - if err != nil { - logger.Error().Err(err).Msgf("CheckEvmTxLog error on ZetaReceived event, chain %d nonce %d txhash %s", ob.chain.ChainId, nonce, transaction.Hash().Hex()) - return false, false, err - } - sendhash := vLog.Topics[3].Hex() - //var rxAddress string = ethcommon.HexToAddress(vLog.Topics[1].Hex()).Hex() - mMint := receivedLog.ZetaValue - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendhash, - vLog.TxHash.Hex(), - vLog.BlockNumber, - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - mMint, - chains.ReceiveStatus_Success, - ob.chain, - nonce, - coin.CoinType_Zeta, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - continue - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - logger.Info().Msgf("Included; %d blocks before confirmed! chain %s nonce %d", confHeight-ob.GetLastBlockHeight(), ob.chain.String(), nonce) - return true, false, nil - } - revertedLog, err := connector.ZetaConnectorNonEthFilterer.ParseZetaReverted(*vLog) - if err == nil { - logger.Info().Msgf("Found (revertTx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), vLog.TxHash.Hex()) - if confHeight <= ob.GetLastBlockHeight() { - logger.Info().Msg("Confirmed! Sending PostConfirmation to zetabridge...") - // sanity check tx event - err = ValidateEvmTxLog(vLog, connectorAddr, transaction.Hash().Hex(), TopicsZetaReverted) - if err != nil { - logger.Error().Err(err).Msgf("CheckEvmTxLog error on ZetaReverted event, chain %d nonce %d txhash %s", ob.chain.ChainId, nonce, transaction.Hash().Hex()) - return false, false, err - } - sendhash := vLog.Topics[2].Hex() - mMint := revertedLog.RemainingZetaValue - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendhash, - vLog.TxHash.Hex(), - vLog.BlockNumber, - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - mMint, - chains.ReceiveStatus_Success, - ob.chain, - nonce, - coin.CoinType_Zeta, - ) - if err != nil { - logger.Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - continue - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - logger.Info().Msgf("Included; %d blocks before confirmed! chain %s nonce %d", confHeight-ob.GetLastBlockHeight(), ob.chain.String(), nonce) - return true, false, nil - } - } - } else if receipt.Status == 0 { - //FIXME: check nonce here by getTransaction RPC - logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex()) - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - big.NewInt(0), - chains.ReceiveStatus_Failed, - ob.chain, - nonce, - coin.CoinType_Zeta, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - } else if cointype == coin.CoinType_ERC20 { - if receipt.Status == 1 { - logs := receipt.Logs - addrCustody, ERC20Custody, err := ob.GetERC20CustodyContract() - if err != nil { - logger.Warn().Msgf("NewERC20Custody err: %s", err) - } - for _, vLog := range logs { - event, err := ERC20Custody.ParseWithdrawn(*vLog) - confHeight := vLog.BlockNumber + params.ConfirmationCount - if err == nil { - logger.Info().Msgf("Found (ERC20Custody.Withdrawn Event) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), vLog.TxHash.Hex()) - // sanity check tx event - err = ValidateEvmTxLog(vLog, addrCustody, transaction.Hash().Hex(), TopicsWithdrawn) - if err != nil { - logger.Error().Err(err).Msgf("CheckEvmTxLog error on Withdrawn event, chain %d nonce %d txhash %s", ob.chain.ChainId, nonce, transaction.Hash().Hex()) - return false, false, err - } - if confHeight <= ob.GetLastBlockHeight() { - logger.Info().Msg("Confirmed! Sending PostConfirmation to zetabridge...") - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - vLog.TxHash.Hex(), - vLog.BlockNumber, - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - event.Amount, - chains.ReceiveStatus_Success, - ob.chain, - nonce, - coin.CoinType_ERC20, - ) - if err != nil { - logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) - continue - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - logger.Info().Msgf("Included; %d blocks before confirmed! chain %s nonce %d", confHeight-ob.GetLastBlockHeight(), ob.chain.String(), nonce) - return true, false, nil - } - } - } else { - logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex()) - zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( - sendHash, - receipt.TxHash.Hex(), - receipt.BlockNumber.Uint64(), - receipt.GasUsed, - transaction.GasPrice(), - transaction.Gas(), - big.NewInt(0), - chains.ReceiveStatus_Failed, - ob.chain, - nonce, - coin.CoinType_ERC20, - ) - if err != nil { - logger.Error().Err(err).Msgf("PostVoteOutbound error in WatchTxHashWithTimeout; zeta tx hash %s", zetaTxHash) - } else if zetaTxHash != "" { - logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot) - } - return true, true, nil - } - } - - return false, false, nil -} - // WatchOutTx watches evm chain for outgoing txs status func (ob *ChainClient) WatchOutTx() { ticker, err := clienttypes.NewDynamicTicker(fmt.Sprintf("EVM_WatchOutTx_%d", ob.chain.ChainId), ob.GetChainParams().OutTxTicker) @@ -629,13 +343,13 @@ func (ob *ChainClient) WatchOutTx() { sampledLogger.Info().Msgf("WatchOutTx: outbound observation is disabled for chain %d", ob.chain.ChainId) continue } - trackers, err := ob.zetaClient.GetAllOutTxTrackerByChain(ob.chain.ChainId, interfaces.Ascending) + trackers, err := ob.zetaBridge.GetAllOutTxTrackerByChain(ob.chain.ChainId, interfaces.Ascending) if err != nil { continue } for _, tracker := range trackers { nonceInt := tracker.Nonce - if ob.isTxConfirmed(nonceInt) { // Go to next tracker if this one already has a confirmed tx + if ob.IsTxConfirmed(nonceInt) { // Go to next tracker if this one already has a confirmed tx continue } txCount := 0 @@ -699,8 +413,8 @@ func (ob *ChainClient) GetTxNReceipt(nonce uint64) (*ethtypes.Receipt, *ethtypes return receipt, transaction } -// isTxConfirmed returns true if there is a confirmed tx for 'nonce' -func (ob *ChainClient) isTxConfirmed(nonce uint64) bool { +// IsTxConfirmed returns true if there is a confirmed tx for 'nonce' +func (ob *ChainClient) IsTxConfirmed(nonce uint64) bool { ob.Mu.Lock() defer ob.Mu.Unlock() return ob.outTXConfirmedReceipts[ob.GetTxID(nonce)] != nil && ob.outTXConfirmedTransactions[ob.GetTxID(nonce)] != nil @@ -870,10 +584,10 @@ func (ob *ChainClient) calcBlockRangeToScan(latestConfirmed, lastScanned, batchS func (ob *ChainClient) postBlockHeader(tip uint64) error { bn := tip - res, err := ob.zetaClient.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 { @@ -891,7 +605,7 @@ func (ob *ChainClient) postBlockHeader(tip uint64) error { return err } - _, err = ob.zetaClient.PostAddBlockHeader( + _, err = ob.zetaBridge.PostVoteBlockHeader( ob.chain.ChainId, header.Hash().Bytes(), header.Number.Int64(), @@ -1125,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") @@ -1199,7 +912,7 @@ func (ob *ChainClient) PostGasPrice() error { // SUPPLY supply := "100" // lockedAmount on ETH, totalSupply on other chains - zetaHash, err := ob.zetaClient.PostGasPrice(ob.chain, gasPrice.Uint64(), supply, blockNum) + zetaHash, err := ob.zetaBridge.PostGasPrice(ob.chain, gasPrice.Uint64(), supply, blockNum) if err != nil { ob.logger.GasPrice.Err(err).Msg("PostGasPrice to zetabridge failed") return err diff --git a/zetaclient/evm/evm_client_test.go b/zetaclient/evm/evm_client_test.go index 7596931f3e..e71bfd49ed 100644 --- a/zetaclient/evm/evm_client_test.go +++ b/zetaclient/evm/evm_client_test.go @@ -5,16 +5,87 @@ import ( "testing" "cosmossdk.io/math" + lru "github.com/hashicorp/golang-lru" "github.com/onrik/ethrpc" + "github.com/rs/zerolog" "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" + appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" + "github.com/zeta-chain/zetacore/zetaclient/common" + "github.com/zeta-chain/zetacore/zetaclient/config" + corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" "github.com/zeta-chain/zetacore/zetaclient/evm" + "github.com/zeta-chain/zetacore/zetaclient/interfaces" "github.com/zeta-chain/zetacore/zetaclient/testutils" + "github.com/zeta-chain/zetacore/zetaclient/testutils/stub" ) +// getAppContext creates an app context for unit tests +func getAppContext(evmChain chains.Chain, evmChainParams *observertypes.ChainParams) (*appcontext.AppContext, config.EVMConfig) { + // create config + cfg := config.NewConfig() + cfg.EVMChainConfigs[evmChain.ChainId] = config.EVMConfig{ + Chain: evmChain, + Endpoint: "http://localhost:8545", + } + // create core context + coreCtx := corecontext.NewZetaCoreContext(cfg) + evmChainParamsMap := make(map[int64]*observertypes.ChainParams) + evmChainParamsMap[evmChain.ChainId] = evmChainParams + + // feed chain params + coreCtx.Update( + &observertypes.Keygen{}, + []chains.Chain{evmChain}, + evmChainParamsMap, + nil, + "", + *sample.CrosschainFlags(), + sample.VerificationFlags(), + true, + zerolog.Logger{}, + ) + // create app context + appCtx := appcontext.NewAppContext(coreCtx, cfg) + return appCtx, cfg.EVMChainConfigs[evmChain.ChainId] +} + +// MockEVMClient creates a mock ChainClient with custom chain, TSS, params etc +func MockEVMClient( + t *testing.T, + chain chains.Chain, + evmClient interfaces.EVMRPCClient, + evmJSONRPC interfaces.EVMJSONRPCClient, + zetaBridge interfaces.ZetaCoreBridger, + tss interfaces.TSSSigner, + lastBlock uint64, + params observertypes.ChainParams) *evm.ChainClient { + // use default mock bridge if not provided + if zetaBridge == nil { + zetaBridge = stub.NewMockZetaCoreBridge() + } + // use default mock tss if not provided + if tss == nil { + tss = stub.NewTSSMainnet() + } + // create app context + appCtx, evmCfg := getAppContext(chain, ¶ms) + + // create chain client + client, err := evm.NewEVMChainClient(appCtx, zetaBridge, tss, "", common.ClientLogger{}, evmCfg, nil) + require.NoError(t, err) + client.WithEvmClient(evmClient) + client.WithEvmJSONRPC(evmJSONRPC) + client.SetLastBlockHeight(lastBlock) + + return client +} + func TestEVM_BlockCache(t *testing.T) { // create client blockCache, err := lru.New(1000) diff --git a/zetaclient/evm/evm_signer_test.go b/zetaclient/evm/evm_signer_test.go index eace105ff2..03e014adde 100644 --- a/zetaclient/evm/evm_signer_test.go +++ b/zetaclient/evm/evm_signer_test.go @@ -1,7 +1,6 @@ package evm import ( - "path" "testing" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -67,15 +66,14 @@ func getNewOutTxProcessor() *outtxprocessor.Processor { } func getCCTX(t *testing.T) *crosschaintypes.CrossChainTx { - var cctx crosschaintypes.CrossChainTx - testutils.LoadObjectFromJSONFile(t, &cctx, path.Join("../", testutils.TestDataPathCctx, "cctx_56_68270.json")) - return &cctx + return testutils.LoadCctxByNonce(t, 56, 68270) } func getInvalidCCTX(t *testing.T) *crosschaintypes.CrossChainTx { - var cctx crosschaintypes.CrossChainTx - testutils.LoadObjectFromJSONFile(t, &cctx, path.Join("../", testutils.TestDataPathCctx, "cctx_56_68270_invalidChainID.json")) - return &cctx + cctx := getCCTX(t) + // modify receiver chain id to make it invalid + cctx.GetCurrentOutTxParam().ReceiverChainId = 13378337 + return cctx } func TestSigner_SetGetConnectorAddress(t *testing.T) { diff --git a/zetaclient/evm/inbounds.go b/zetaclient/evm/inbounds.go index 819ab09f77..0ee0e0457f 100644 --- a/zetaclient/evm/inbounds.go +++ b/zetaclient/evm/inbounds.go @@ -60,7 +60,7 @@ func (ob *ChainClient) WatchIntxTracker() { // ObserveIntxTrackers observes the inbound trackers for the chain func (ob *ChainClient) ObserveIntxTrackers() error { - trackers, err := ob.zetaClient.GetInboundTrackersForChain(ob.chain.ChainId) + trackers, err := ob.zetaBridge.GetInboundTrackersForChain(ob.chain.ChainId) if err != nil { return err } @@ -206,7 +206,7 @@ func (ob *ChainClient) CheckAndVoteInboundTokenGas(tx *ethrpc.Transaction, recei func (ob *ChainClient) PostVoteInbound(msg *types.MsgVoteOnObservedInboundTx, coinType coin.CoinType, retryGasLimit uint64) (string, error) { txHash := msg.InTxHash chainID := ob.chain.ChainId - zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(zetabridge.PostVoteInboundGasLimit, retryGasLimit, msg) + zetaHash, ballot, err := ob.zetaBridge.PostVoteInbound(zetabridge.PostVoteInboundGasLimit, retryGasLimit, msg) if err != nil { ob.logger.InTx.Err(err).Msgf("intx detected: error posting vote for chain %d token %s intx %s", chainID, coinType, txHash) return "", err @@ -252,7 +252,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForDepositedEvent(event *erc20custody. ob.chain.ChainId, "", clienttypes.BytesToEthHex(event.Recipient), - ob.zetaClient.ZetaChain().ChainId, + ob.zetaBridge.ZetaChain().ChainId, sdkmath.NewUintFromBigInt(event.Amount), hex.EncodeToString(event.Message), event.Raw.TxHash.Hex(), @@ -260,7 +260,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForDepositedEvent(event *erc20custody. 1_500_000, coin.CoinType_ERC20, event.Asset.String(), - ob.zetaClient.GetKeys().GetOperatorAddress().String(), + ob.zetaBridge.GetKeys().GetOperatorAddress().String(), event.Raw.Index, ) } @@ -311,7 +311,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForZetaSentEvent(event *zetaconnector. event.DestinationGasLimit.Uint64(), coin.CoinType_Zeta, "", - ob.zetaClient.GetKeys().GetOperatorAddress().String(), + ob.zetaBridge.GetKeys().GetOperatorAddress().String(), event.Raw.Index, ) } @@ -347,7 +347,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForTokenSentToTSS(tx *ethrpc.Transacti ob.chain.ChainId, sender.Hex(), sender.Hex(), - ob.zetaClient.ZetaChain().ChainId, + ob.zetaBridge.ZetaChain().ChainId, sdkmath.NewUintFromBigInt(&tx.Value), message, tx.Hash, @@ -355,7 +355,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForTokenSentToTSS(tx *ethrpc.Transacti 90_000, coin.CoinType_Gas, "", - ob.zetaClient.GetKeys().GetOperatorAddress().String(), + ob.zetaBridge.GetKeys().GetOperatorAddress().String(), 0, // not a smart contract call ) } diff --git a/zetaclient/evm/inbounds_test.go b/zetaclient/evm/inbounds_test.go index e24c66b4d5..645a87d108 100644 --- a/zetaclient/evm/inbounds_test.go +++ b/zetaclient/evm/inbounds_test.go @@ -2,55 +2,22 @@ package evm_test import ( "encoding/hex" - "sync" "testing" ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - lru "github.com/hashicorp/golang-lru" "github.com/onrik/ethrpc" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/pkg/constant" - observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/config" "github.com/zeta-chain/zetacore/zetaclient/evm" - "github.com/zeta-chain/zetacore/zetaclient/interfaces" "github.com/zeta-chain/zetacore/zetaclient/testutils" "github.com/zeta-chain/zetacore/zetaclient/testutils/stub" clienttypes "github.com/zeta-chain/zetacore/zetaclient/types" ) -// MockEVMClient creates a mock ChainClient with custom chain, TSS, params etc -func MockEVMClient( - chain chains.Chain, - evmClient interfaces.EVMRPCClient, - evmJSONRPC interfaces.EVMJSONRPCClient, - zetClient interfaces.ZetaCoreBridger, - tss interfaces.TSSSigner, - lastBlock uint64, - params observertypes.ChainParams) *evm.ChainClient { - client := &evm.ChainClient{ - Tss: tss, - Mu: &sync.Mutex{}, - } - client.WithChain(chain) - client.WithEvmClient(evmClient) - client.WithEvmJSONRPC(evmJSONRPC) - if zetClient != nil { - client.WithZetaClient(zetClient) - } else { - client.WithZetaClient(stub.NewMockZetaCoreBridge()) - } - client.SetLastBlockHeight(lastBlock) - client.SetChainParams(params) - blockCache, _ := lru.New(1000) - client.WithBlockCache(blockCache) - - return client -} - func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { // load archived ZetaSent intx, receipt and cctx // https://etherscan.io/tx/0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76 @@ -65,7 +32,7 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) ballot, err := ob.CheckAndVoteInboundTokenZeta(tx, receipt, false) require.NoError(t, err) require.Equal(t, cctx.InboundTxParams.InboundTxBallotIndex, ballot) @@ -75,7 +42,7 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - 1 - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) _, err := ob.CheckAndVoteInboundTokenZeta(tx, receipt, false) require.ErrorContains(t, err, "not been confirmed") }) @@ -85,7 +52,7 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) ballot, err := ob.CheckAndVoteInboundTokenZeta(tx, receipt, true) require.NoError(t, err) require.Equal(t, "", ballot) @@ -96,7 +63,7 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { lastBlock := receipt.BlockNumber.Uint64() + confirmation chainID = 56 // use BSC chain connector - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, stub.MockChainParams(chainID, confirmation)) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, stub.MockChainParams(chainID, confirmation)) _, err := ob.CheckAndVoteInboundTokenZeta(tx, receipt, true) require.ErrorContains(t, err, "emitter address mismatch") }) @@ -116,7 +83,7 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) ballot, err := ob.CheckAndVoteInboundTokenERC20(tx, receipt, false) require.NoError(t, err) require.Equal(t, cctx.InboundTxParams.InboundTxBallotIndex, ballot) @@ -126,7 +93,7 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - 1 - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) _, err := ob.CheckAndVoteInboundTokenERC20(tx, receipt, false) require.ErrorContains(t, err, "not been confirmed") }) @@ -136,7 +103,7 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) ballot, err := ob.CheckAndVoteInboundTokenERC20(tx, receipt, true) require.NoError(t, err) require.Equal(t, "", ballot) @@ -147,7 +114,7 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { lastBlock := receipt.BlockNumber.Uint64() + confirmation chainID = 56 // use BSC chain ERC20 custody - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, stub.MockChainParams(chainID, confirmation)) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, stub.MockChainParams(chainID, confirmation)) _, err := ob.CheckAndVoteInboundTokenERC20(tx, receipt, true) require.ErrorContains(t, err, "emitter address mismatch") }) @@ -167,7 +134,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) ballot, err := ob.CheckAndVoteInboundTokenGas(tx, receipt, false) require.NoError(t, err) require.Equal(t, cctx.InboundTxParams.InboundTxBallotIndex, ballot) @@ -177,7 +144,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - 1 - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) _, err := ob.CheckAndVoteInboundTokenGas(tx, receipt, false) require.ErrorContains(t, err, "not been confirmed") }) @@ -187,7 +154,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) ballot, err := ob.CheckAndVoteInboundTokenGas(tx, receipt, false) require.ErrorContains(t, err, "not TSS address") require.Equal(t, "", ballot) @@ -198,7 +165,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) ballot, err := ob.CheckAndVoteInboundTokenGas(tx, receipt, false) require.ErrorContains(t, err, "not a successful tx") require.Equal(t, "", ballot) @@ -209,7 +176,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - ob := MockEVMClient(chain, nil, nil, nil, stub.NewTSSMainnet(), lastBlock, chainParam) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, lastBlock, chainParam) ballot, err := ob.CheckAndVoteInboundTokenGas(tx, receipt, false) require.NoError(t, err) require.Equal(t, "", ballot) @@ -223,10 +190,10 @@ func TestEVM_BuildInboundVoteMsgForZetaSentEvent(t *testing.T) { chain := chains.EthChain() intxHash := "0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76" receipt := testutils.LoadEVMIntxReceipt(t, chainID, intxHash, coin.CoinType_Zeta) - cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, coin.CoinType_Zeta) + cctx := testutils.LoadCctxByIntx(t, chainID, coin.CoinType_Zeta, intxHash) // parse ZetaSent event - ob := MockEVMClient(chain, nil, nil, nil, nil, 1, stub.MockChainParams(1, 1)) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, 1, stub.MockChainParams(1, 1)) connector := stub.MockConnectorNonEth(chainID) event := testutils.ParseReceiptZetaSent(receipt, connector) @@ -270,10 +237,10 @@ func TestEVM_BuildInboundVoteMsgForDepositedEvent(t *testing.T) { chainID := chain.ChainId intxHash := "0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da" tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, coin.CoinType_ERC20) - cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, coin.CoinType_ERC20) + cctx := testutils.LoadCctxByIntx(t, chainID, coin.CoinType_ERC20, intxHash) // parse Deposited event - ob := MockEVMClient(chain, nil, nil, nil, nil, 1, stub.MockChainParams(1, 1)) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, 1, stub.MockChainParams(1, 1)) custody := stub.MockERC20Custody(chainID) event := testutils.ParseReceiptERC20Deposited(receipt, custody) sender := ethcommon.HexToAddress(tx.From) @@ -316,7 +283,7 @@ func TestEVM_BuildInboundVoteMsgForTokenSentToTSS(t *testing.T) { intxHash := "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532" tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, coin.CoinType_Gas) require.NoError(t, evm.ValidateEvmTransaction(tx)) - cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, coin.CoinType_Gas) + cctx := testutils.LoadCctxByIntx(t, chainID, coin.CoinType_Gas, intxHash) // load archived gas token donation to TSS // https://etherscan.io/tx/0x52f214cf7b10be71f4d274193287d47bc9632b976e69b9d2cdeb527c2ba32155 @@ -325,7 +292,7 @@ func TestEVM_BuildInboundVoteMsgForTokenSentToTSS(t *testing.T) { require.NoError(t, evm.ValidateEvmTransaction(txDonation)) // create test compliance config - ob := MockEVMClient(chain, nil, nil, nil, nil, 1, stub.MockChainParams(1, 1)) + ob := MockEVMClient(t, chain, nil, nil, nil, nil, 1, stub.MockChainParams(1, 1)) cfg := config.Config{ ComplianceConfig: config.ComplianceConfig{}, } @@ -378,12 +345,12 @@ func TestEVM_ObserveTSSReceiveInBlock(t *testing.T) { // create mock client evmClient := stub.NewMockEvmClient() evmJSONRPC := stub.NewMockJSONRPCClient() - zetaClient := stub.NewMockZetaCoreBridge() + zetaBridge := stub.NewMockZetaCoreBridge() tss := stub.NewTSSMainnet() lastBlock := receipt.BlockNumber.Uint64() + confirmation t.Run("should observe TSS receive in block", func(t *testing.T) { - ob := MockEVMClient(chain, evmClient, evmJSONRPC, zetaClient, tss, lastBlock, chainParam) + ob := MockEVMClient(t, chain, evmClient, evmJSONRPC, zetaBridge, tss, lastBlock, chainParam) // feed archived block and receipt evmJSONRPC.WithBlock(block) @@ -392,25 +359,25 @@ func TestEVM_ObserveTSSReceiveInBlock(t *testing.T) { require.NoError(t, err) }) t.Run("should not observe on error getting block", func(t *testing.T) { - ob := MockEVMClient(chain, evmClient, evmJSONRPC, zetaClient, tss, lastBlock, chainParam) + ob := MockEVMClient(t, chain, evmClient, evmJSONRPC, zetaBridge, tss, lastBlock, chainParam) err := ob.ObserveTSSReceiveInBlock(blockNumber) // error getting block is expected because the mock JSONRPC contains no block require.ErrorContains(t, err, "error getting block") }) t.Run("should not observe on error getting receipt", func(t *testing.T) { - ob := MockEVMClient(chain, evmClient, evmJSONRPC, zetaClient, tss, lastBlock, chainParam) + ob := MockEVMClient(t, chain, evmClient, evmJSONRPC, zetaBridge, tss, lastBlock, chainParam) evmJSONRPC.WithBlock(block) err := ob.ObserveTSSReceiveInBlock(blockNumber) // error getting block is expected because the mock evmClient contains no receipt require.ErrorContains(t, err, "error getting receipt") }) t.Run("should not observe on error posting vote", func(t *testing.T) { - ob := MockEVMClient(chain, evmClient, evmJSONRPC, zetaClient, tss, lastBlock, chainParam) + ob := MockEVMClient(t, chain, evmClient, evmJSONRPC, zetaBridge, tss, lastBlock, chainParam) // feed archived block and pause zeta bridge evmJSONRPC.WithBlock(block) evmClient.WithReceipt(receipt) - zetaClient.Pause() + zetaBridge.Pause() err := ob.ObserveTSSReceiveInBlock(blockNumber) // error posting vote is expected because the mock zetaClient is paused require.ErrorContains(t, err, "error checking and voting") diff --git a/zetaclient/evm/outbound_transaction_data.go b/zetaclient/evm/outbound_transaction_data.go index 6734926f0d..47a7333197 100644 --- a/zetaclient/evm/outbound_transaction_data.go +++ b/zetaclient/evm/outbound_transaction_data.go @@ -135,9 +135,9 @@ func NewOutBoundTransactionData( // Get nonce, Early return if the cctx is already processed nonce := cctx.GetCurrentOutTxParam().OutboundTxTssNonce - included, confirmed, err := evmClient.IsSendOutTxProcessed(cctx, logger) + included, confirmed, err := evmClient.IsOutboundProcessed(cctx, logger) if err != nil { - return nil, true, errors.New("IsSendOutTxProcessed failed") + return nil, true, errors.New("IsOutboundProcessed failed") } if included || confirmed { logger.Info().Msgf("CCTX already processed; exit signer") diff --git a/zetaclient/evm/outbounds.go b/zetaclient/evm/outbounds.go new file mode 100644 index 0000000000..081616256e --- /dev/null +++ b/zetaclient/evm/outbounds.go @@ -0,0 +1,244 @@ +package evm + +import ( + "encoding/hex" + "fmt" + "math/big" + "strings" + + ethcommon "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/pkg/errors" + "github.com/rs/zerolog" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.non-eth.sol" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + "github.com/zeta-chain/zetacore/zetaclient/compliance" +) + +// PostVoteOutbound posts vote to zetacore for the confirmed outtx +func (ob *ChainClient) PostVoteOutbound( + cctxIndex string, + receipt *ethtypes.Receipt, + transaction *ethtypes.Transaction, + receiveValue *big.Int, + receiveStatus chains.ReceiveStatus, + nonce uint64, + cointype coin.CoinType, + logger zerolog.Logger, +) { + chainID := ob.chain.ChainId + zetaTxHash, ballot, err := ob.zetaBridge.PostVoteOutbound( + cctxIndex, + receipt.TxHash.Hex(), + receipt.BlockNumber.Uint64(), + receipt.GasUsed, + transaction.GasPrice(), + transaction.Gas(), + receiveValue, + receiveStatus, + ob.chain, + nonce, + cointype, + ) + if err != nil { + logger.Error().Err(err).Msgf("PostVoteOutbound: error posting vote for chain %d nonce %d outtx %s ", chainID, nonce, receipt.TxHash) + } else if zetaTxHash != "" { + logger.Info().Msgf("PostVoteOutbound: posted vote for chain %d nonce %d outtx %s vote %s ballot %s", chainID, nonce, receipt.TxHash, zetaTxHash, ballot) + } +} + +// IsOutboundProcessed checks outtx status and returns (isIncluded, isConfirmed, error) +// It also posts vote to zetacore if the tx is confirmed +func (ob *ChainClient) IsOutboundProcessed(cctx *crosschaintypes.CrossChainTx, logger zerolog.Logger) (bool, bool, error) { + // skip if outtx is not confirmed + nonce := cctx.GetCurrentOutTxParam().OutboundTxTssNonce + if !ob.IsTxConfirmed(nonce) { + return false, false, nil + } + receipt, transaction := ob.GetTxNReceipt(nonce) + sendID := fmt.Sprintf("%d-%d", ob.chain.ChainId, nonce) + logger = logger.With().Str("sendID", sendID).Logger() + + // get connector and erce20Custody contracts + connectorAddr, connector, err := ob.GetConnectorContract() + if err != nil { + return false, false, errors.Wrapf(err, "error getting zeta connector for chain %d", ob.chain.ChainId) + } + custodyAddr, custody, err := ob.GetERC20CustodyContract() + if err != nil { + return false, false, errors.Wrapf(err, "error getting erc20 custody for chain %d", ob.chain.ChainId) + } + + // define a few common variables + var receiveValue *big.Int + var receiveStatus chains.ReceiveStatus + cointype := cctx.InboundTxParams.CoinType + + // compliance check, special handling the cancelled cctx + if compliance.IsCctxRestricted(cctx) { + // use cctx's amount to bypass the amount check in zetacore + receiveValue = cctx.GetCurrentOutTxParam().Amount.BigInt() + receiveStatus := chains.ReceiveStatus_Failed + if receipt.Status == ethtypes.ReceiptStatusSuccessful { + receiveStatus = chains.ReceiveStatus_Success + } + ob.PostVoteOutbound(cctx.Index, receipt, transaction, receiveValue, receiveStatus, nonce, cointype, logger) + return true, true, nil + } + + // parse the received value from the outtx receipt + receiveValue, receiveStatus, err = ParseOuttxReceivedValue(cctx, receipt, transaction, cointype, connectorAddr, connector, custodyAddr, custody) + if err != nil { + logger.Error().Err(err).Msgf("IsOutboundProcessed: error parsing outtx event for chain %d txhash %s", ob.chain.ChainId, receipt.TxHash) + return false, false, err + } + + // post vote to zetacore + ob.PostVoteOutbound(cctx.Index, receipt, transaction, receiveValue, receiveStatus, nonce, cointype, logger) + return true, true, nil +} + +// ParseAndCheckZetaEvent parses and checks ZetaReceived/ZetaReverted event from the outtx receipt +// It either returns an ZetaReceived or an ZetaReverted event, or an error if no event found +func ParseAndCheckZetaEvent( + cctx *crosschaintypes.CrossChainTx, + receipt *ethtypes.Receipt, + connectorAddr ethcommon.Address, + connector *zetaconnector.ZetaConnectorNonEth, +) (*zetaconnector.ZetaConnectorNonEthZetaReceived, *zetaconnector.ZetaConnectorNonEthZetaReverted, error) { + params := cctx.GetCurrentOutTxParam() + for _, vLog := range receipt.Logs { + // try parsing ZetaReceived event + received, err := connector.ZetaConnectorNonEthFilterer.ParseZetaReceived(*vLog) + if err == nil { + err = ValidateEvmTxLog(vLog, connectorAddr, receipt.TxHash.Hex(), TopicsZetaReceived) + if err != nil { + return nil, nil, errors.Wrap(err, "error validating ZetaReceived event") + } + if !strings.EqualFold(received.DestinationAddress.Hex(), params.Receiver) { + return nil, nil, fmt.Errorf("receiver address mismatch in ZetaReceived event, want %s got %s", + params.Receiver, received.DestinationAddress.Hex()) + } + if received.ZetaValue.Cmp(params.Amount.BigInt()) != 0 { + return nil, nil, fmt.Errorf("amount mismatch in ZetaReceived event, want %s got %s", + params.Amount.String(), received.ZetaValue.String()) + } + if ethcommon.BytesToHash(received.InternalSendHash[:]).Hex() != cctx.Index { + return nil, nil, fmt.Errorf("cctx index mismatch in ZetaReceived event, want %s got %s", + cctx.Index, hex.EncodeToString(received.InternalSendHash[:])) + } + return received, nil, nil + } + // try parsing ZetaReverted event + reverted, err := connector.ZetaConnectorNonEthFilterer.ParseZetaReverted(*vLog) + if err == nil { + err = ValidateEvmTxLog(vLog, connectorAddr, receipt.TxHash.Hex(), TopicsZetaReverted) + if err != nil { + return nil, nil, errors.Wrap(err, "error validating ZetaReverted event") + } + if !strings.EqualFold(ethcommon.BytesToAddress(reverted.DestinationAddress[:]).Hex(), cctx.InboundTxParams.Sender) { + return nil, nil, fmt.Errorf("receiver address mismatch in ZetaReverted event, want %s got %s", + cctx.InboundTxParams.Sender, ethcommon.BytesToAddress(reverted.DestinationAddress[:]).Hex()) + } + if reverted.RemainingZetaValue.Cmp(params.Amount.BigInt()) != 0 { + return nil, nil, fmt.Errorf("amount mismatch in ZetaReverted event, want %s got %s", + params.Amount.String(), reverted.RemainingZetaValue.String()) + } + if ethcommon.BytesToHash(reverted.InternalSendHash[:]).Hex() != cctx.Index { + return nil, nil, fmt.Errorf("cctx index mismatch in ZetaReverted event, want %s got %s", + cctx.Index, hex.EncodeToString(reverted.InternalSendHash[:])) + } + return nil, reverted, nil + } + } + return nil, nil, errors.New("no ZetaReceived/ZetaReverted event found") +} + +// ParseAndCheckWithdrawnEvent parses and checks erc20 Withdrawn event from the outtx receipt +func ParseAndCheckWithdrawnEvent( + cctx *crosschaintypes.CrossChainTx, + receipt *ethtypes.Receipt, + custodyAddr ethcommon.Address, + custody *erc20custody.ERC20Custody, +) (*erc20custody.ERC20CustodyWithdrawn, error) { + params := cctx.GetCurrentOutTxParam() + for _, vLog := range receipt.Logs { + withdrawn, err := custody.ParseWithdrawn(*vLog) + if err == nil { + err = ValidateEvmTxLog(vLog, custodyAddr, receipt.TxHash.Hex(), TopicsWithdrawn) + if err != nil { + return nil, errors.Wrap(err, "error validating Withdrawn event") + } + if !strings.EqualFold(withdrawn.Recipient.Hex(), params.Receiver) { + return nil, fmt.Errorf("receiver address mismatch in Withdrawn event, want %s got %s", + params.Receiver, withdrawn.Recipient.Hex()) + } + if !strings.EqualFold(withdrawn.Asset.Hex(), cctx.InboundTxParams.Asset) { + return nil, fmt.Errorf("asset mismatch in Withdrawn event, want %s got %s", + cctx.InboundTxParams.Asset, withdrawn.Asset.Hex()) + } + if withdrawn.Amount.Cmp(params.Amount.BigInt()) != 0 { + return nil, fmt.Errorf("amount mismatch in Withdrawn event, want %s got %s", + params.Amount.String(), withdrawn.Amount.String()) + } + return withdrawn, nil + } + } + return nil, errors.New("no ERC20 Withdrawn event found") +} + +// ParseOuttxReceivedValue parses the received value and status from the outtx receipt +// The receivd value is the amount of Zeta/ERC20/Gas token (released from connector/custody/TSS) sent to the receiver +func ParseOuttxReceivedValue( + cctx *crosschaintypes.CrossChainTx, + receipt *ethtypes.Receipt, + transaction *ethtypes.Transaction, + cointype coin.CoinType, + connectorAddress ethcommon.Address, + connector *zetaconnector.ZetaConnectorNonEth, + custodyAddress ethcommon.Address, + custody *erc20custody.ERC20Custody, +) (*big.Int, chains.ReceiveStatus, error) { + // determine the receive status and value + // https://docs.nethereum.com/en/latest/nethereum-receipt-status/ + receiveValue := big.NewInt(0) + receiveStatus := chains.ReceiveStatus_Failed + if receipt.Status == ethtypes.ReceiptStatusSuccessful { + receiveValue = transaction.Value() + receiveStatus = chains.ReceiveStatus_Success + } + + // parse receive value from the outtx receipt for Zeta and ERC20 + switch cointype { + case coin.CoinType_Zeta: + if receipt.Status == ethtypes.ReceiptStatusSuccessful { + receivedLog, revertedLog, err := ParseAndCheckZetaEvent(cctx, receipt, connectorAddress, connector) + if err != nil { + return nil, chains.ReceiveStatus_Failed, err + } + // use the value in ZetaReceived/ZetaReverted event for vote message + if receivedLog != nil { + receiveValue = receivedLog.ZetaValue + } else if revertedLog != nil { + receiveValue = revertedLog.RemainingZetaValue + } + } + case coin.CoinType_ERC20: + if receipt.Status == ethtypes.ReceiptStatusSuccessful { + withdrawn, err := ParseAndCheckWithdrawnEvent(cctx, receipt, custodyAddress, custody) + if err != nil { + return nil, chains.ReceiveStatus_Failed, err + } + // use the value in Withdrawn event for vote message + receiveValue = withdrawn.Amount + } + case coin.CoinType_Gas, coin.CoinType_Cmd: + // nothing to do for CoinType_Gas/CoinType_Cmd, no need to parse event + default: + return nil, chains.ReceiveStatus_Failed, fmt.Errorf("unknown coin type %s", cointype) + } + return receiveValue, receiveStatus, nil +} diff --git a/zetaclient/evm/outbounds_test.go b/zetaclient/evm/outbounds_test.go new file mode 100644 index 0000000000..30f523614f --- /dev/null +++ b/zetaclient/evm/outbounds_test.go @@ -0,0 +1,434 @@ +package evm_test + +import ( + "testing" + + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/rs/zerolog" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.non-eth.sol" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/testutil/sample" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" + "github.com/zeta-chain/zetacore/zetaclient/config" + "github.com/zeta-chain/zetacore/zetaclient/evm" + "github.com/zeta-chain/zetacore/zetaclient/testutils" + "github.com/zeta-chain/zetacore/zetaclient/testutils/stub" +) + +// getContractsByChainID is a helper func to get contracts and addresses by chainID +func getContractsByChainID(chainID int64) (*zetaconnector.ZetaConnectorNonEth, ethcommon.Address, *erc20custody.ERC20Custody, ethcommon.Address) { + connector := stub.MockConnectorNonEth(chainID) + connectorAddress := testutils.ConnectorAddresses[chainID] + custody := stub.MockERC20Custody(chainID) + custodyAddress := testutils.CustodyAddresses[chainID] + return connector, connectorAddress, custody, custodyAddress +} + +func Test_IsOutboundProcessed(t *testing.T) { + // load archived outtx receipt that contains ZetaReceived event + // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f + chain := chains.EthChain() + chainID := chains.EthChain().ChainId + nonce := uint64(9718) + chainParam := stub.MockChainParams(chain.ChainId, 1) + outtxHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" + cctx := testutils.LoadCctxByNonce(t, chainID, nonce) + receipt := testutils.LoadEVMOuttxReceipt(t, chainID, outtxHash, coin.CoinType_Zeta, testutils.EventZetaReceived) + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chainID, nonce, testutils.EventZetaReceived) + + t.Run("should post vote and return true if outtx is processed", func(t *testing.T) { + // create evm client and set outtx and receipt + client := MockEVMClient(t, chain, nil, nil, nil, nil, 1, chainParam) + client.SetTxNReceipt(nonce, receipt, outtx) + // post outbound vote + isIncluded, isConfirmed, err := client.IsOutboundProcessed(cctx, zerolog.Logger{}) + require.NoError(t, err) + require.True(t, isIncluded) + require.True(t, isConfirmed) + }) + t.Run("should post vote and return true on restricted address", func(t *testing.T) { + // load cctx and modify sender address to arbitrary address + // Note: other tests cases will fail if we use the original sender address because the + // compliance config is globally set and will impact other tests when running in parallel + cctx := testutils.LoadCctxByNonce(t, chainID, nonce) + cctx.InboundTxParams.Sender = sample.EthAddress().Hex() + + // create evm client and set outtx and receipt + client := MockEVMClient(t, chain, nil, nil, nil, nil, 1, chainParam) + client.SetTxNReceipt(nonce, receipt, outtx) + + // modify compliance config to restrict sender address + cfg := config.Config{ + ComplianceConfig: config.ComplianceConfig{}, + } + cfg.ComplianceConfig.RestrictedAddresses = []string{cctx.InboundTxParams.Sender} + config.LoadComplianceConfig(cfg) + + // post outbound vote + isIncluded, isConfirmed, err := client.IsOutboundProcessed(cctx, zerolog.Logger{}) + require.NoError(t, err) + require.True(t, isIncluded) + require.True(t, isConfirmed) + }) + t.Run("should return false if outtx is not confirmed", func(t *testing.T) { + // create evm client and DO NOT set outtx as confirmed + client := MockEVMClient(t, chain, nil, nil, nil, nil, 1, chainParam) + isIncluded, isConfirmed, err := client.IsOutboundProcessed(cctx, zerolog.Logger{}) + require.NoError(t, err) + require.False(t, isIncluded) + require.False(t, isConfirmed) + }) + t.Run("should fail if unable to parse ZetaReceived event", func(t *testing.T) { + // create evm client and set outtx and receipt + client := MockEVMClient(t, chain, nil, nil, nil, nil, 1, chainParam) + client.SetTxNReceipt(nonce, receipt, outtx) + + // set connector contract address to an arbitrary address to make event parsing fail + chainParamsNew := client.GetChainParams() + chainParamsNew.ConnectorContractAddress = sample.EthAddress().Hex() + client.SetChainParams(chainParamsNew) + isIncluded, isConfirmed, err := client.IsOutboundProcessed(cctx, zerolog.Logger{}) + require.Error(t, err) + require.False(t, isIncluded) + require.False(t, isConfirmed) + }) +} + +func Test_IsOutboundProcessed_ContractError(t *testing.T) { + // Note: this test is skipped because it will cause CI failure. + // The only way to replicate a contract error is to use an invalid ABI. + // See the code: https://github.com/ethereum/go-ethereum/blob/v1.10.26/accounts/abi/bind/base.go#L97 + // The ABI is hardcoded in the protocol-contracts package and initialized the 1st time it binds the contract. + // Any subsequent modification to the ABI will not work and therefor fail the unit test. + t.Skip("uncomment this line to run this test separately, otherwise it will fail CI") + + // load archived outtx receipt that contains ZetaReceived event + // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f + chain := chains.EthChain() + chainID := chains.EthChain().ChainId + nonce := uint64(9718) + chainParam := stub.MockChainParams(chain.ChainId, 1) + outtxHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" + cctx := testutils.LoadCctxByNonce(t, chainID, nonce) + receipt := testutils.LoadEVMOuttxReceipt(t, chainID, outtxHash, coin.CoinType_Zeta, testutils.EventZetaReceived) + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chainID, nonce, testutils.EventZetaReceived) + + t.Run("should fail if unable to get connector/custody contract", func(t *testing.T) { + // create evm client and set outtx and receipt + client := MockEVMClient(t, chain, nil, nil, nil, nil, 1, chainParam) + client.SetTxNReceipt(nonce, receipt, outtx) + abiConnector := zetaconnector.ZetaConnectorNonEthMetaData.ABI + abiCustody := erc20custody.ERC20CustodyMetaData.ABI + + // set invalid connector ABI + zetaconnector.ZetaConnectorNonEthMetaData.ABI = "invalid abi" + isIncluded, isConfirmed, err := client.IsOutboundProcessed(cctx, zerolog.Logger{}) + zetaconnector.ZetaConnectorNonEthMetaData.ABI = abiConnector // reset connector ABI + require.ErrorContains(t, err, "error getting zeta connector") + require.False(t, isIncluded) + require.False(t, isConfirmed) + + // set invalid custody ABI + erc20custody.ERC20CustodyMetaData.ABI = "invalid abi" + isIncluded, isConfirmed, err = client.IsOutboundProcessed(cctx, zerolog.Logger{}) + require.ErrorContains(t, err, "error getting erc20 custody") + require.False(t, isIncluded) + require.False(t, isConfirmed) + erc20custody.ERC20CustodyMetaData.ABI = abiCustody // reset custody ABI + }) +} + +func Test_PostVoteOutbound(t *testing.T) { + // Note: outtx of Gas/ERC20 token can also be used for this test + // load archived cctx, outtx and receipt for a ZetaReceived event + // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f + chain := chains.EthChain() + nonce := uint64(9718) + coinType := coin.CoinType_Zeta + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chain.ChainId, nonce, testutils.EventZetaReceived) + + t.Run("post vote outbound successfully", func(t *testing.T) { + // the amount and status to be used for vote + receiveValue := cctx.GetCurrentOutTxParam().Amount.BigInt() + receiveStatus := chains.ReceiveStatus_Success + + // create evm client using mock zetaBridge and post outbound vote + zetaBridge := stub.NewMockZetaCoreBridge() + client := MockEVMClient(t, chain, nil, nil, zetaBridge, nil, 1, observertypes.ChainParams{}) + client.PostVoteOutbound(cctx.Index, receipt, outtx, receiveValue, receiveStatus, nonce, coinType, zerolog.Logger{}) + + // pause the mock zetaBridge to simulate error posting vote + zetaBridge.Pause() + client.PostVoteOutbound(cctx.Index, receipt, outtx, receiveValue, receiveStatus, nonce, coinType, zerolog.Logger{}) + }) +} + +func Test_ParseZetaReceived(t *testing.T) { + // load archived outtx receipt that contains ZetaReceived event + // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f + chainID := chains.EthChain().ChainId + nonce := uint64(9718) + outtxHash := "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" + connector := stub.MockConnectorNonEth(chainID) + connectorAddress := testutils.ConnectorAddresses[chainID] + cctx := testutils.LoadCctxByNonce(t, chainID, nonce) + receipt := testutils.LoadEVMOuttxReceipt(t, chainID, outtxHash, coin.CoinType_Zeta, testutils.EventZetaReceived) + + t.Run("should parse ZetaReceived event from archived outtx receipt", func(t *testing.T) { + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(cctx, receipt, connectorAddress, connector) + require.NoError(t, err) + require.NotNil(t, receivedLog) + require.Nil(t, revertedLog) + }) + t.Run("should fail on connector address mismatch", func(t *testing.T) { + // use an arbitrary address to make validation fail + fakeConnectorAddress := sample.EthAddress() + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(cctx, receipt, fakeConnectorAddress, connector) + require.ErrorContains(t, err, "error validating ZetaReceived event") + require.Nil(t, revertedLog) + require.Nil(t, receivedLog) + }) + t.Run("should fail on receiver address mismatch", func(t *testing.T) { + // load cctx and set receiver address to an arbitrary address + fakeCctx := testutils.LoadCctxByNonce(t, chainID, nonce) + fakeCctx.GetCurrentOutTxParam().Receiver = sample.EthAddress().Hex() + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(fakeCctx, receipt, connectorAddress, connector) + require.ErrorContains(t, err, "receiver address mismatch") + require.Nil(t, revertedLog) + require.Nil(t, receivedLog) + }) + t.Run("should fail on amount mismatch", func(t *testing.T) { + // load cctx and set amount to an arbitrary wrong value + fakeCctx := testutils.LoadCctxByNonce(t, chainID, nonce) + fakeAmount := sample.UintInRange(0, fakeCctx.GetCurrentOutTxParam().Amount.Uint64()-1) + fakeCctx.GetCurrentOutTxParam().Amount = fakeAmount + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(fakeCctx, receipt, connectorAddress, connector) + require.ErrorContains(t, err, "amount mismatch") + require.Nil(t, revertedLog) + require.Nil(t, receivedLog) + }) + t.Run("should fail on cctx index mismatch", func(t *testing.T) { + cctx.Index = sample.Hash().Hex() // use an arbitrary index + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(cctx, receipt, connectorAddress, connector) + require.ErrorContains(t, err, "cctx index mismatch") + require.Nil(t, revertedLog) + require.Nil(t, receivedLog) + }) + t.Run("should fail if no event found in receipt", func(t *testing.T) { + // load receipt and remove ZetaReceived event from logs + receipt := testutils.LoadEVMOuttxReceipt(t, chainID, outtxHash, coin.CoinType_Zeta, testutils.EventZetaReceived) + receipt.Logs = receipt.Logs[:1] // the 2nd log is ZetaReceived event + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(cctx, receipt, connectorAddress, connector) + require.ErrorContains(t, err, "no ZetaReceived/ZetaReverted event") + require.Nil(t, revertedLog) + require.Nil(t, receivedLog) + }) +} + +func Test_ParseZetaReverted(t *testing.T) { + // load archived outtx receipt that contains ZetaReverted event + chainID := chains.GoerliLocalnetChain().ChainId + nonce := uint64(14) + outtxHash := "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7" + connector := stub.MockConnectorNonEth(chainID) + connectorAddress := testutils.ConnectorAddresses[chainID] + cctx := testutils.LoadCctxByNonce(t, chainID, nonce) + receipt := testutils.LoadEVMOuttxReceipt(t, chainID, outtxHash, coin.CoinType_Zeta, testutils.EventZetaReverted) + + t.Run("should parse ZetaReverted event from archived outtx receipt", func(t *testing.T) { + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(cctx, receipt, connectorAddress, connector) + require.NoError(t, err) + require.Nil(t, receivedLog) + require.NotNil(t, revertedLog) + }) + t.Run("should fail on connector address mismatch", func(t *testing.T) { + // use an arbitrary address to make validation fail + fakeConnectorAddress := sample.EthAddress() + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(cctx, receipt, fakeConnectorAddress, connector) + require.ErrorContains(t, err, "error validating ZetaReverted event") + require.Nil(t, receivedLog) + require.Nil(t, revertedLog) + }) + t.Run("should fail on receiver address mismatch", func(t *testing.T) { + // load cctx and set receiver address to an arbitrary address + fakeCctx := testutils.LoadCctxByNonce(t, chainID, nonce) + fakeCctx.InboundTxParams.Sender = sample.EthAddress().Hex() // the receiver is the sender for reverted ccxt + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(fakeCctx, receipt, connectorAddress, connector) + require.ErrorContains(t, err, "receiver address mismatch") + require.Nil(t, revertedLog) + require.Nil(t, receivedLog) + }) + t.Run("should fail on amount mismatch", func(t *testing.T) { + // load cctx and set amount to an arbitrary wrong value + fakeCctx := testutils.LoadCctxByNonce(t, chainID, nonce) + fakeAmount := sample.UintInRange(0, fakeCctx.GetCurrentOutTxParam().Amount.Uint64()-1) + fakeCctx.GetCurrentOutTxParam().Amount = fakeAmount + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(fakeCctx, receipt, connectorAddress, connector) + require.ErrorContains(t, err, "amount mismatch") + require.Nil(t, revertedLog) + require.Nil(t, receivedLog) + }) + t.Run("should fail on cctx index mismatch", func(t *testing.T) { + cctx.Index = sample.Hash().Hex() // use an arbitrary index to make validation fail + receivedLog, revertedLog, err := evm.ParseAndCheckZetaEvent(cctx, receipt, connectorAddress, connector) + require.ErrorContains(t, err, "cctx index mismatch") + require.Nil(t, receivedLog) + require.Nil(t, revertedLog) + }) +} + +func Test_ParseERC20WithdrawnEvent(t *testing.T) { + // load archived outtx receipt that contains ERC20 Withdrawn event + chainID := chains.EthChain().ChainId + nonce := uint64(8014) + outtxHash := "0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146" + custody := stub.MockERC20Custody(chainID) + custodyAddress := testutils.CustodyAddresses[chainID] + cctx := testutils.LoadCctxByNonce(t, chainID, nonce) + receipt := testutils.LoadEVMOuttxReceipt(t, chainID, outtxHash, coin.CoinType_ERC20, testutils.EventERC20Withdraw) + + t.Run("should parse ERC20 Withdrawn event from archived outtx receipt", func(t *testing.T) { + withdrawn, err := evm.ParseAndCheckWithdrawnEvent(cctx, receipt, custodyAddress, custody) + require.NoError(t, err) + require.NotNil(t, withdrawn) + }) + t.Run("should fail on erc20 custody address mismatch", func(t *testing.T) { + // use an arbitrary address to make validation fail + fakeCustodyAddress := sample.EthAddress() + withdrawn, err := evm.ParseAndCheckWithdrawnEvent(cctx, receipt, fakeCustodyAddress, custody) + require.ErrorContains(t, err, "error validating Withdrawn event") + require.Nil(t, withdrawn) + }) + t.Run("should fail on receiver address mismatch", func(t *testing.T) { + // load cctx and set receiver address to an arbitrary address + fakeCctx := testutils.LoadCctxByNonce(t, chainID, nonce) + fakeCctx.GetCurrentOutTxParam().Receiver = sample.EthAddress().Hex() + withdrawn, err := evm.ParseAndCheckWithdrawnEvent(fakeCctx, receipt, custodyAddress, custody) + require.ErrorContains(t, err, "receiver address mismatch") + require.Nil(t, withdrawn) + }) + t.Run("should fail on asset mismatch", func(t *testing.T) { + // load cctx and set asset to an arbitrary address + fakeCctx := testutils.LoadCctxByNonce(t, chainID, nonce) + fakeCctx.InboundTxParams.Asset = sample.EthAddress().Hex() + withdrawn, err := evm.ParseAndCheckWithdrawnEvent(fakeCctx, receipt, custodyAddress, custody) + require.ErrorContains(t, err, "asset mismatch") + require.Nil(t, withdrawn) + }) + t.Run("should fail on amount mismatch", func(t *testing.T) { + // load cctx and set amount to an arbitrary wrong value + fakeCctx := testutils.LoadCctxByNonce(t, chainID, nonce) + fakeAmount := sample.UintInRange(0, fakeCctx.GetCurrentOutTxParam().Amount.Uint64()-1) + fakeCctx.GetCurrentOutTxParam().Amount = fakeAmount + withdrawn, err := evm.ParseAndCheckWithdrawnEvent(fakeCctx, receipt, custodyAddress, custody) + require.ErrorContains(t, err, "amount mismatch") + require.Nil(t, withdrawn) + }) + t.Run("should fail if no Withdrawn event found in receipt", func(t *testing.T) { + // load receipt and remove Withdrawn event from logs + receipt := testutils.LoadEVMOuttxReceipt(t, chainID, outtxHash, coin.CoinType_ERC20, testutils.EventERC20Withdraw) + receipt.Logs = receipt.Logs[:1] // the 2nd log is Withdrawn event + withdrawn, err := evm.ParseAndCheckWithdrawnEvent(cctx, receipt, custodyAddress, custody) + require.ErrorContains(t, err, "no ERC20 Withdrawn event") + require.Nil(t, withdrawn) + }) +} + +func Test_ParseOuttxReceivedValue(t *testing.T) { + chainID := chains.EthChain().ChainId + connector, connectorAddr, custody, custodyAddr := getContractsByChainID(chainID) + + t.Run("should parse and check ZetaReceived event from archived outtx receipt", func(t *testing.T) { + // load archived outtx receipt that contains ZetaReceived event + // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f + nonce := uint64(9718) + coinType := coin.CoinType_Zeta + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chainID, nonce, testutils.EventZetaReceived) + params := cctx.GetCurrentOutTxParam() + value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, custodyAddr, custody) + require.NoError(t, err) + require.True(t, params.Amount.BigInt().Cmp(value) == 0) + require.Equal(t, chains.ReceiveStatus_Success, status) + }) + t.Run("should parse and check ZetaReverted event from archived outtx receipt", func(t *testing.T) { + // load archived outtx receipt that contains ZetaReverted event + // use local network tx: 0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7 + localChainID := chains.GoerliLocalnetChain().ChainId + nonce := uint64(14) + coinType := coin.CoinType_Zeta + connectorLocal, connectorAddrLocal, custodyLocal, custodyAddrLocal := getContractsByChainID(localChainID) + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, localChainID, nonce, testutils.EventZetaReverted) + params := cctx.GetCurrentOutTxParam() + value, status, err := evm.ParseOuttxReceivedValue( + cctx, receipt, outtx, coinType, connectorAddrLocal, connectorLocal, custodyAddrLocal, custodyLocal) + require.NoError(t, err) + require.True(t, params.Amount.BigInt().Cmp(value) == 0) + require.Equal(t, chains.ReceiveStatus_Success, status) + }) + t.Run("should parse and check ERC20 Withdrawn event from archived outtx receipt", func(t *testing.T) { + // load archived outtx receipt that contains ERC20 Withdrawn event + // https://etherscan.io/tx/0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146 + nonce := uint64(8014) + coinType := coin.CoinType_ERC20 + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chainID, nonce, testutils.EventERC20Withdraw) + params := cctx.GetCurrentOutTxParam() + value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, custodyAddr, custody) + require.NoError(t, err) + require.True(t, params.Amount.BigInt().Cmp(value) == 0) + require.Equal(t, chains.ReceiveStatus_Success, status) + }) + t.Run("nothing to parse if coinType is Gas", func(t *testing.T) { + // load archived outtx receipt of Gas token transfer + // https://etherscan.io/tx/0xd13b593eb62b5500a00e288cc2fb2c8af1339025c0e6bc6183b8bef2ebbed0d3 + nonce := uint64(7260) + coinType := coin.CoinType_Gas + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chainID, nonce, "") + params := cctx.GetCurrentOutTxParam() + value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, custodyAddr, custody) + require.NoError(t, err) + require.True(t, params.Amount.BigInt().Cmp(value) == 0) + require.Equal(t, chains.ReceiveStatus_Success, status) + }) + t.Run("should fail on unknown coin type", func(t *testing.T) { + // load archived outtx receipt that contains ZetaReceived event + // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f + nonce := uint64(9718) + coinType := coin.CoinType(5) // unknown coin type + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chainID, nonce, testutils.EventZetaReceived) + value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, custodyAddr, custody) + require.ErrorContains(t, err, "unknown coin type") + require.Nil(t, value) + require.Equal(t, chains.ReceiveStatus_Failed, status) + }) + t.Run("should fail if unable to parse ZetaReceived event", func(t *testing.T) { + // load archived outtx receipt that contains ZetaReceived event + // https://etherscan.io/tx/0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f + nonce := uint64(9718) + coinType := coin.CoinType_Zeta + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chainID, nonce, testutils.EventZetaReceived) + + // use an arbitrary address to make event parsing fail + fakeConnectorAddress := sample.EthAddress() + value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, fakeConnectorAddress, connector, custodyAddr, custody) + require.Error(t, err) + require.Nil(t, value) + require.Equal(t, chains.ReceiveStatus_Failed, status) + }) + t.Run("should fail if unable to parse ERC20 Withdrawn event", func(t *testing.T) { + // load archived outtx receipt that contains ERC20 Withdrawn event + // https://etherscan.io/tx/0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146 + nonce := uint64(8014) + coinType := coin.CoinType_ERC20 + cctx, outtx, receipt := testutils.LoadEVMCctxNOuttxNReceipt(t, chainID, nonce, testutils.EventERC20Withdraw) + + // use an arbitrary address to make event parsing fail + fakeCustodyAddress := sample.EthAddress() + value, status, err := evm.ParseOuttxReceivedValue(cctx, receipt, outtx, coinType, connectorAddr, connector, fakeCustodyAddress, custody) + require.Error(t, err) + require.Nil(t, value) + require.Equal(t, chains.ReceiveStatus_Failed, status) + }) +} diff --git a/zetaclient/interfaces/interfaces.go b/zetaclient/interfaces/interfaces.go index 1c01b7e486..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" @@ -39,7 +41,7 @@ const ( type ChainClient interface { Start() Stop() - IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, logger zerolog.Logger) (bool, bool, error) + IsOutboundProcessed(cctx *crosschaintypes.CrossChainTx, logger zerolog.Logger) (bool, bool, error) SetChainParams(observertypes.ChainParams) GetChainParams() observertypes.ChainParams GetTxID(nonce uint64) string @@ -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/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() } diff --git a/zetaclient/testdata/cctx/all_cctxs.go b/zetaclient/testdata/cctx/all_cctxs.go new file mode 100644 index 0000000000..359a10c8dd --- /dev/null +++ b/zetaclient/testdata/cctx/all_cctxs.go @@ -0,0 +1,49 @@ +package cctx + +import ( + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// CCtxByNonceMap maps the [chainID, nonce] to the cross chain transaction +var CCtxByNonceMap = map[int64]map[uint64]*crosschaintypes.CrossChainTx{ + // Ethereum mainnet + 1: { + chain_1_cctx_6270.GetCurrentOutTxParam().OutboundTxTssNonce: chain_1_cctx_6270, + chain_1_cctx_7260.GetCurrentOutTxParam().OutboundTxTssNonce: chain_1_cctx_7260, + chain_1_cctx_8014.GetCurrentOutTxParam().OutboundTxTssNonce: chain_1_cctx_8014, + chain_1_cctx_9718.GetCurrentOutTxParam().OutboundTxTssNonce: chain_1_cctx_9718, + }, + // BSC mainnet + 56: { + chain_56_cctx_68270.GetCurrentOutTxParam().OutboundTxTssNonce: chain_56_cctx_68270, + }, + // local goerli testnet + 1337: { + chain_1337_cctx_14.GetCurrentOutTxParam().OutboundTxTssNonce: chain_1337_cctx_14, + }, + // Bitcoin mainnet + 8332: { + chain_8332_cctx_148.GetCurrentOutTxParam().OutboundTxTssNonce: chain_8332_cctx_148, + }, +} + +// CctxByIntxMap maps the [chainID, coinType, intxHash] to the cross chain transaction +var CctxByIntxMap = map[int64]map[coin.CoinType]map[string]*crosschaintypes.CrossChainTx{ + // Ethereum mainnet + 1: { + coin.CoinType_Zeta: { + chain_1_cctx_intx_Zeta_0xf393520.InboundTxParams.InboundTxObservedHash: chain_1_cctx_intx_Zeta_0xf393520, + }, + coin.CoinType_ERC20: { + chain_1_cctx_intx_ERC20_0x4ea69a0.InboundTxParams.InboundTxObservedHash: chain_1_cctx_intx_ERC20_0x4ea69a0, + }, + coin.CoinType_Gas: { + chain_1_cctx_intx_Gas_0xeaec67d.InboundTxParams.InboundTxObservedHash: chain_1_cctx_intx_Gas_0xeaec67d, + }, + }, + // BSC mainnet + 56: {}, + // Bitcoin mainnet + 8332: {}, +} diff --git a/zetaclient/testdata/cctx/cctx_1_6270.json b/zetaclient/testdata/cctx/cctx_1_6270.json deleted file mode 100644 index 3797b52c3c..0000000000 --- a/zetaclient/testdata/cctx/cctx_1_6270.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "index": "0xe930f363591b348a07e0a6d309b4301b84f702e3e81e0d0902340c7f7da4b5af", - "zeta_fees": "0", - "cctx_status": { "status": 3, "lastUpdate_timestamp": 1708464433 }, - "inbound_tx_params": { - "sender": "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", - "sender_chain_id": 7000, - "tx_origin": "0x18D0E2c38b4188D8Ae07008C3BeeB1c80748b41c", - "coin_type": 1, - "amount": "9831832641427386", - "inbound_tx_observed_hash": "0x8bd0df31e512c472e3162a41281b740b518216cc8eb787c2eb59c81e0cffbe89", - "inbound_tx_observed_external_height": 1846989, - "inbound_tx_ballot_index": "0xe930f363591b348a07e0a6d309b4301b84f702e3e81e0d0902340c7f7da4b5af" - }, - "outbound_tx_params": [ - { - "receiver": "0x18D0E2c38b4188D8Ae07008C3BeeB1c80748b41c", - "receiver_chainId": 1, - "coin_type": 1, - "amount": "9831832641427386", - "outbound_tx_tss_nonce": 6270, - "outbound_tx_gas_limit": 21000, - "outbound_tx_gas_price": "69197693654", - "outbound_tx_hash": "0x20104d41e042db754cf7908c5441914e581b498eedbca40979c9853f4b7f8460", - "outbound_tx_ballot_index": "0x346a1d00a4d26a2065fe1dc7d5af59a49ad6a8af25853ae2ec976c07349f48c1", - "outbound_tx_observed_external_height": 19271550, - "outbound_tx_gas_used": 21000, - "outbound_tx_effective_gas_price": "69197693654", - "outbound_tx_effective_gas_limit": 21000, - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", - "tx_finalization_status": 2 - } - ] -} diff --git a/zetaclient/testdata/cctx/cctx_1_7260.json b/zetaclient/testdata/cctx/cctx_1_7260.json deleted file mode 100644 index 46cb2e2a3a..0000000000 --- a/zetaclient/testdata/cctx/cctx_1_7260.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "index": "0xbebecbf1d8c12016e38c09d095290df503fe29731722d939433fa47e3ed1f986", - "zeta_fees": "0", - "cctx_status": { "status": 3, "lastUpdate_timestamp": 1709574082 }, - "inbound_tx_params": { - "sender": "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", - "sender_chain_id": 7000, - "tx_origin": "0x8E62e3e6FbFF3E21F725395416A20EA4E2DeF015", - "coin_type": 1, - "amount": "42635427434588308", - "inbound_tx_observed_hash": "0x2720e3a98f18c288f4197d412bfce57e58f00dc4f8b31e335ffc0bf7208dd3c5", - "inbound_tx_observed_external_height": 2031411, - "inbound_tx_ballot_index": "0xbebecbf1d8c12016e38c09d095290df503fe29731722d939433fa47e3ed1f986" - }, - "outbound_tx_params": [ - { - "receiver": "0x8E62e3e6FbFF3E21F725395416A20EA4E2DeF015", - "receiver_chainId": 1, - "coin_type": 1, - "amount": "42635427434588308", - "outbound_tx_tss_nonce": 7260, - "outbound_tx_gas_limit": 21000, - "outbound_tx_gas_price": "236882693686", - "outbound_tx_hash": "0xd13b593eb62b5500a00e288cc2fb2c8af1339025c0e6bc6183b8bef2ebbed0d3", - "outbound_tx_ballot_index": "0x689d894606642a2a7964fa906ebf4998c22a00708544fa88e9c56b86c955066b", - "outbound_tx_observed_external_height": 19363323, - "outbound_tx_gas_used": 21000, - "outbound_tx_effective_gas_price": "236882693686", - "outbound_tx_effective_gas_limit": 21000, - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", - "tx_finalization_status": 2 - } - ] -} diff --git a/zetaclient/testdata/cctx/cctx_1_intx_Gas_0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098.json b/zetaclient/testdata/cctx/cctx_1_intx_Gas_0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098.json deleted file mode 100644 index a167134b35..0000000000 --- a/zetaclient/testdata/cctx/cctx_1_intx_Gas_0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "creator": "zeta1hjct6q7npsspsg3dgvzk3sdf89spmlpf7rqmnw", - "index": "0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098", - "zeta_fees": "0", - "cctx_status": { - "status": 3, - "status_message": "Remote omnichain contract call completed", - "lastUpdate_timestamp": 1709177431 - }, - "inbound_tx_params": { - "sender": "0xF829fa7069680b8C37A8086b37d4a24697E5003b", - "sender_chain_id": 1, - "tx_origin": "0xF829fa7069680b8C37A8086b37d4a24697E5003b", - "coin_type": 1, - "amount": "4000000000000000", - "inbound_tx_observed_hash": "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532", - "inbound_tx_observed_external_height": 19330473, - "inbound_tx_ballot_index": "0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098", - "inbound_tx_finalized_zeta_height": 1965579, - "tx_finalization_status": 2 - }, - "outbound_tx_params": [ - { - "receiver": "0xF829fa7069680b8C37A8086b37d4a24697E5003b", - "receiver_chainId": 7000, - "coin_type": 1, - "amount": "0", - "outbound_tx_gas_limit": 90000, - "outbound_tx_hash": "0x3b8c1dab5aa21ff90ddb569f2f962ff2d4aa8d914c9177900102e745955e6f35", - "outbound_tx_observed_external_height": 1965579, - "outbound_tx_effective_gas_price": "0", - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc" - } - ] -} diff --git a/zetaclient/testdata/cctx/cctx_56_68270.json b/zetaclient/testdata/cctx/cctx_56_68270.json deleted file mode 100644 index 1c0ae6b762..0000000000 --- a/zetaclient/testdata/cctx/cctx_56_68270.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "creator": "", - "index": "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", - "zeta_fees": "0", - "relayed_message": "", - "cctx_status": { - "status": 1, - "status_message": "", - "lastUpdate_timestamp": 1709145057 - }, - "inbound_tx_params": { - "sender": "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", - "sender_chain_id": 7000, - "tx_origin": "0xb0C04e07A301927672A8A7a874DB6930576C90B8", - "coin_type": 1, - "asset": "", - "amount": "657177295293237048", - "inbound_tx_observed_hash": "0x093f4ca4c1884df0fd9dd59b75979342ded29d3c9b6861644287a2e1417b9a39", - "inbound_tx_observed_external_height": 1960153, - "inbound_tx_ballot_index": "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", - "inbound_tx_finalized_zeta_height": 0, - "tx_finalization_status": 0 - }, - "outbound_tx_params": [ - { - "receiver": "0xb0C04e07A301927672A8A7a874DB6930576C90B8", - "receiver_chainId": 56, - "coin_type": 1, - "amount": "657177295293237048", - "outbound_tx_tss_nonce": 68270, - "outbound_tx_gas_limit": 21000, - "outbound_tx_gas_price": "6000000000", - "outbound_tx_hash": "", - "outbound_tx_ballot_index": "", - "outbound_tx_observed_external_height": 0, - "outbound_tx_gas_used": 0, - "outbound_tx_effective_gas_price": "0", - "outbound_tx_effective_gas_limit": 0, - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", - "tx_finalization_status": 0 - } - ] -} diff --git a/zetaclient/testdata/cctx/cctx_56_68270_invalidChainID.json b/zetaclient/testdata/cctx/cctx_56_68270_invalidChainID.json deleted file mode 100644 index 2e4cc4d97a..0000000000 --- a/zetaclient/testdata/cctx/cctx_56_68270_invalidChainID.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "creator": "", - "index": "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", - "zeta_fees": "0", - "relayed_message": "", - "cctx_status": { - "status": 1, - "status_message": "", - "lastUpdate_timestamp": 1709145057 - }, - "inbound_tx_params": { - "sender": "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", - "sender_chain_id": 7000, - "tx_origin": "0xb0C04e07A301927672A8A7a874DB6930576C90B8", - "coin_type": 1, - "asset": "", - "amount": "657177295293237048", - "inbound_tx_observed_hash": "0x093f4ca4c1884df0fd9dd59b75979342ded29d3c9b6861644287a2e1417b9a39", - "inbound_tx_observed_external_height": 1960153, - "inbound_tx_ballot_index": "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", - "inbound_tx_finalized_zeta_height": 0, - "tx_finalization_status": 0 - }, - "outbound_tx_params": [ - { - "receiver": "0xb0C04e07A301927672A8A7a874DB6930576C90B8", - "receiver_chainId": 13378337, - "coin_type": 1, - "amount": "657177295293237048", - "outbound_tx_tss_nonce": 68270, - "outbound_tx_gas_limit": 21000, - "outbound_tx_gas_price": "6000000000", - "outbound_tx_hash": "", - "outbound_tx_ballot_index": "", - "outbound_tx_observed_external_height": 0, - "outbound_tx_gas_used": 0, - "outbound_tx_effective_gas_price": "0", - "outbound_tx_effective_gas_limit": 0, - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", - "tx_finalization_status": 0 - } - ] -} diff --git a/zetaclient/testdata/cctx/cctx_8332_148.json b/zetaclient/testdata/cctx/cctx_8332_148.json deleted file mode 100644 index 4564858f58..0000000000 --- a/zetaclient/testdata/cctx/cctx_8332_148.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "index": "0xb3f5f3cf2ed2e0c3fa64c8297c9e50fbc07351fb2d26d8eae4cfbbd45e47a524", - "zeta_fees": "0", - "cctx_status": { "status": 3, "lastUpdate_timestamp": 1708608895 }, - "inbound_tx_params": { - "sender": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", - "sender_chain_id": 7000, - "tx_origin": "0xe99174F08e1186134830f8511De06bd010978533", - "coin_type": 1, - "amount": "12000", - "inbound_tx_observed_hash": "0x06455013319acb1b027461134853c77b003d8eab162b1f37673da5ad8a50b74f", - "inbound_tx_observed_external_height": 1870408, - "inbound_tx_ballot_index": "0xb3f5f3cf2ed2e0c3fa64c8297c9e50fbc07351fb2d26d8eae4cfbbd45e47a524" - }, - "outbound_tx_params": [ - { - "receiver": "bc1qpsdlklfcmlcfgm77c43x65ddtrt7n0z57hsyjp", - "receiver_chainId": 8332, - "coin_type": 1, - "amount": "12000", - "outbound_tx_tss_nonce": 148, - "outbound_tx_gas_limit": 254, - "outbound_tx_gas_price": "46", - "outbound_tx_hash": "030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0", - "outbound_tx_ballot_index": "0x43845693f799b7a5e84dcf11321ae681ec018d709ecc919773968018f93e21c1", - "outbound_tx_observed_external_height": 150, - "outbound_tx_effective_gas_price": "0", - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", - "tx_finalization_status": 2 - } - ] -} diff --git a/zetaclient/testdata/cctx/cctx_intx_1_ERC20_0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da.json b/zetaclient/testdata/cctx/cctx_intx_1_ERC20_0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da.json deleted file mode 100644 index 6df7bcfe3e..0000000000 --- a/zetaclient/testdata/cctx/cctx_intx_1_ERC20_0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "creator": "zeta1hjct6q7npsspsg3dgvzk3sdf89spmlpf7rqmnw", - "index": "0xd326700a1931f28853f44f8462f72588f94b1f248214d59a23c3e1b141ff5ede", - "zeta_fees": "0", - "cctx_status": { - "status": 3, - "status_message": "Remote omnichain contract call completed", - "lastUpdate_timestamp": 1709052990 - }, - "inbound_tx_params": { - "sender": "0x56BF8D4a6E7b59D2C0E40Cba2409a4a30ab4FbE2", - "sender_chain_id": 1, - "tx_origin": "0x56BF8D4a6E7b59D2C0E40Cba2409a4a30ab4FbE2", - "coin_type": 2, - "asset": "0xdAC17F958D2ee523a2206206994597C13D831ec7", - "amount": "9992000000", - "inbound_tx_observed_hash": "0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da", - "inbound_tx_observed_external_height": 19320188, - "inbound_tx_ballot_index": "0xd326700a1931f28853f44f8462f72588f94b1f248214d59a23c3e1b141ff5ede", - "inbound_tx_finalized_zeta_height": 1944675, - "tx_finalization_status": 2 - }, - "outbound_tx_params": [ - { - "receiver": "0x56bf8d4a6e7b59d2c0e40cba2409a4a30ab4fbe2", - "receiver_chainId": 7000, - "coin_type": 2, - "amount": "0", - "outbound_tx_gas_limit": 1500000, - "outbound_tx_hash": "0xf63eaa3e01af477673aa9e86fb634df15d30a00734dab7450cb0fc28dbc9d11b", - "outbound_tx_observed_external_height": 1944675, - "outbound_tx_effective_gas_price": "0", - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc" - } - ] -} diff --git a/zetaclient/testdata/cctx/cctx_intx_1_Gas_0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532.json b/zetaclient/testdata/cctx/cctx_intx_1_Gas_0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532.json deleted file mode 100644 index a167134b35..0000000000 --- a/zetaclient/testdata/cctx/cctx_intx_1_Gas_0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "creator": "zeta1hjct6q7npsspsg3dgvzk3sdf89spmlpf7rqmnw", - "index": "0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098", - "zeta_fees": "0", - "cctx_status": { - "status": 3, - "status_message": "Remote omnichain contract call completed", - "lastUpdate_timestamp": 1709177431 - }, - "inbound_tx_params": { - "sender": "0xF829fa7069680b8C37A8086b37d4a24697E5003b", - "sender_chain_id": 1, - "tx_origin": "0xF829fa7069680b8C37A8086b37d4a24697E5003b", - "coin_type": 1, - "amount": "4000000000000000", - "inbound_tx_observed_hash": "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532", - "inbound_tx_observed_external_height": 19330473, - "inbound_tx_ballot_index": "0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098", - "inbound_tx_finalized_zeta_height": 1965579, - "tx_finalization_status": 2 - }, - "outbound_tx_params": [ - { - "receiver": "0xF829fa7069680b8C37A8086b37d4a24697E5003b", - "receiver_chainId": 7000, - "coin_type": 1, - "amount": "0", - "outbound_tx_gas_limit": 90000, - "outbound_tx_hash": "0x3b8c1dab5aa21ff90ddb569f2f962ff2d4aa8d914c9177900102e745955e6f35", - "outbound_tx_observed_external_height": 1965579, - "outbound_tx_effective_gas_price": "0", - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc" - } - ] -} diff --git a/zetaclient/testdata/cctx/cctx_intx_1_Zeta_0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76.json b/zetaclient/testdata/cctx/cctx_intx_1_Zeta_0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76.json deleted file mode 100644 index b31c759c5f..0000000000 --- a/zetaclient/testdata/cctx/cctx_intx_1_Zeta_0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "creator": "zeta1p0uwsq4naus5r4l7l744upy0k8ezzj84mn40nf", - "index": "0x477544c4b8c8be544b23328b21286125c89cd6bb5d1d6d388d91eea8ea1a6f1f", - "zeta_fees": "0", - "cctx_status": { - "status": 3, - "status_message": "Remote omnichain contract call completed", - "lastUpdate_timestamp": 1708490549 - }, - "inbound_tx_params": { - "sender": "0x2f993766e8e1Ef9288B1F33F6aa244911A0A77a7", - "sender_chain_id": 1, - "tx_origin": "0x2f993766e8e1Ef9288B1F33F6aa244911A0A77a7", - "amount": "20000000000000000000", - "inbound_tx_observed_hash": "0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76", - "inbound_tx_observed_external_height": 19273702, - "inbound_tx_ballot_index": "0x477544c4b8c8be544b23328b21286125c89cd6bb5d1d6d388d91eea8ea1a6f1f", - "inbound_tx_finalized_zeta_height": 1851403, - "tx_finalization_status": 2 - }, - "outbound_tx_params": [ - { - "receiver": "0x2f993766e8e1ef9288b1f33f6aa244911a0a77a7", - "receiver_chainId": 7000, - "amount": "0", - "outbound_tx_gas_limit": 100000, - "outbound_tx_hash": "0x947434364da7c74d7e896a389aa8cb3122faf24bbcba64b141cb5acd7838209c", - "outbound_tx_observed_external_height": 1851403, - "outbound_tx_effective_gas_price": "0", - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc" - } - ] -} diff --git a/zetaclient/testdata/cctx/chain_1337_cctx_14.go b/zetaclient/testdata/cctx/chain_1337_cctx_14.go new file mode 100644 index 0000000000..ec4fafd8c4 --- /dev/null +++ b/zetaclient/testdata/cctx/chain_1337_cctx_14.go @@ -0,0 +1,122 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// This cctx was generated in local e2e tests, see original json text attached at end of file +var chain_1337_cctx_14 = &crosschaintypes.CrossChainTx{ + Creator: "zeta1plfrp7ejn0s9tmwufuxvsyn8nlf6a7u9ndgk9m", + Index: "0x85d06ac908823d125a919164f0596e3496224b206ebe8125ffe7b4ab766f85df", + ZetaFees: sdkmath.NewUintFromString("4000000000009027082"), + RelayedMessage: "bgGCGUux3roBhJr9PgNaC3DOfLBp5ILuZjUZx2z1abQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ==", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_Reverted, + StatusMessage: "Outbound failed, start revert : Outbound succeeded, revert executed", + LastUpdateTimestamp: 1712705995, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed", + SenderChainId: 1337, + TxOrigin: "0x5cC2fBb200A929B372e3016F1925DcF988E081fd", + Amount: sdkmath.NewUintFromString("10000000000000000000"), + InboundTxObservedHash: "0xa5589bf24eca8f108ca35048adc9d5582a303d416c01319391159269ae7e4e6f", + InboundTxObservedExternalHeight: 177, + InboundTxBallotIndex: "0x85d06ac908823d125a919164f0596e3496224b206ebe8125ffe7b4ab766f85df", + InboundTxFinalizedZetaHeight: 150, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0xbff76e77d56b3c1202107f059425d56f0aef87ed", + ReceiverChainId: 1337, + Amount: sdkmath.NewUintFromString("7999999999995486459"), + OutboundTxTssNonce: 13, + OutboundTxGasLimit: 250000, + OutboundTxGasPrice: "18", + OutboundTxHash: "0x19f99459da6cb08f917f9b0ee2dac94a7be328371dff788ad46e64a24e8c06c9", + OutboundTxObservedExternalHeight: 187, + OutboundTxGasUsed: 67852, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(18), + OutboundTxEffectiveGasLimit: 250000, + TssPubkey: "zetapub1addwnpepqggky6z958k7hhxs6k5quuvs27uv5vtmlv330ppt2362p8ejct88w4g64jv", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + { + Receiver: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed", + ReceiverChainId: 1337, + Amount: sdkmath.NewUintFromString("5999999999990972918"), + OutboundTxTssNonce: 14, + OutboundTxGasLimit: 250000, + OutboundTxGasPrice: "18", + OutboundTxHash: "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7", + OutboundTxBallotIndex: "0xc36c689fdaf09a9b80a614420cd4fea4fec15044790df60080cdefca0090a9dc", + OutboundTxObservedExternalHeight: 201, + OutboundTxGasUsed: 76128, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(18), + OutboundTxEffectiveGasLimit: 250000, + TssPubkey: "zetapub1addwnpepqggky6z958k7hhxs6k5quuvs27uv5vtmlv330ppt2362p8ejct88w4g64jv", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + }, +} + +// Here is the original cctx json data used to create above chain_1337_cctx_14 +/* +{ + "creator": "zeta1plfrp7ejn0s9tmwufuxvsyn8nlf6a7u9ndgk9m", + "index": "0x85d06ac908823d125a919164f0596e3496224b206ebe8125ffe7b4ab766f85df", + "zeta_fees": "4000000000009027082", + "relayed_message": "bgGCGUux3roBhJr9PgNaC3DOfLBp5ILuZjUZx2z1abQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQ==", + "cctx_status": { + "status": 5, + "status_message": "Outbound failed, start revert : Outbound succeeded, revert executed", + "lastUpdate_timestamp": 1712705995 + }, + "inbound_tx_params": { + "sender": "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed", + "sender_chain_id": 1337, + "tx_origin": "0x5cC2fBb200A929B372e3016F1925DcF988E081fd", + "amount": "10000000000000000000", + "inbound_tx_observed_hash": "0xa5589bf24eca8f108ca35048adc9d5582a303d416c01319391159269ae7e4e6f", + "inbound_tx_observed_external_height": 177, + "inbound_tx_ballot_index": "0x85d06ac908823d125a919164f0596e3496224b206ebe8125ffe7b4ab766f85df", + "inbound_tx_finalized_zeta_height": 150, + "tx_finalization_status": 2 + }, + "outbound_tx_params": [ + { + "receiver": "0xbff76e77d56b3c1202107f059425d56f0aef87ed", + "receiver_chainId": 1337, + "amount": "7999999999995486459", + "outbound_tx_tss_nonce": 13, + "outbound_tx_gas_limit": 250000, + "outbound_tx_gas_price": "18", + "outbound_tx_hash": "0x19f99459da6cb08f917f9b0ee2dac94a7be328371dff788ad46e64a24e8c06c9", + "outbound_tx_observed_external_height": 187, + "outbound_tx_gas_used": 67852, + "outbound_tx_effective_gas_price": "18", + "outbound_tx_effective_gas_limit": 250000, + "tss_pubkey": "zetapub1addwnpepqggky6z958k7hhxs6k5quuvs27uv5vtmlv330ppt2362p8ejct88w4g64jv", + "tx_finalization_status": 2 + }, + { + "receiver": "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed", + "receiver_chainId": 1337, + "amount": "5999999999990972918", + "outbound_tx_tss_nonce": 14, + "outbound_tx_gas_limit": 250000, + "outbound_tx_gas_price": "18", + "outbound_tx_hash": "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7", + "outbound_tx_ballot_index": "0xc36c689fdaf09a9b80a614420cd4fea4fec15044790df60080cdefca0090a9dc", + "outbound_tx_observed_external_height": 201, + "outbound_tx_gas_used": 76128, + "outbound_tx_effective_gas_price": "18", + "outbound_tx_effective_gas_limit": 250000, + "tss_pubkey": "zetapub1addwnpepqggky6z958k7hhxs6k5quuvs27uv5vtmlv330ppt2362p8ejct88w4g64jv", + "tx_finalization_status": 2 + } + ] +} +*/ diff --git a/zetaclient/testdata/cctx/chain_1_cctx_6270.go b/zetaclient/testdata/cctx/chain_1_cctx_6270.go new file mode 100644 index 0000000000..31c8158f42 --- /dev/null +++ b/zetaclient/testdata/cctx/chain_1_cctx_6270.go @@ -0,0 +1,53 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/1/6270 +var chain_1_cctx_6270 = &crosschaintypes.CrossChainTx{ + Creator: "", + Index: "0xe930f363591b348a07e0a6d309b4301b84f702e3e81e0d0902340c7f7da4b5af", + ZetaFees: sdkmath.ZeroUint(), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_OutboundMined, + StatusMessage: "", + LastUpdateTimestamp: 1708464433, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", + SenderChainId: 7000, + TxOrigin: "0x18D0E2c38b4188D8Ae07008C3BeeB1c80748b41c", + CoinType: coin.CoinType_Gas, + Asset: "", + Amount: sdkmath.NewUint(9831832641427386), + InboundTxObservedHash: "0x8bd0df31e512c472e3162a41281b740b518216cc8eb787c2eb59c81e0cffbe89", + InboundTxObservedExternalHeight: 1846989, + InboundTxBallotIndex: "0xe930f363591b348a07e0a6d309b4301b84f702e3e81e0d0902340c7f7da4b5af", + InboundTxFinalizedZetaHeight: 0, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0x18D0E2c38b4188D8Ae07008C3BeeB1c80748b41c", + ReceiverChainId: 1, + CoinType: coin.CoinType_Gas, + Amount: sdkmath.NewUint(9831832641427386), + OutboundTxTssNonce: 6270, + OutboundTxGasLimit: 21000, + OutboundTxGasPrice: "69197693654", + OutboundTxHash: "0x20104d41e042db754cf7908c5441914e581b498eedbca40979c9853f4b7f8460", + OutboundTxBallotIndex: "0x346a1d00a4d26a2065fe1dc7d5af59a49ad6a8af25853ae2ec976c07349f48c1", + OutboundTxObservedExternalHeight: 19271550, + OutboundTxGasUsed: 21000, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(69197693654), + OutboundTxEffectiveGasLimit: 21000, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + }, +} diff --git a/zetaclient/testdata/cctx/chain_1_cctx_7260.go b/zetaclient/testdata/cctx/chain_1_cctx_7260.go new file mode 100644 index 0000000000..b7e00b954f --- /dev/null +++ b/zetaclient/testdata/cctx/chain_1_cctx_7260.go @@ -0,0 +1,53 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/1/7260 +var chain_1_cctx_7260 = &crosschaintypes.CrossChainTx{ + Creator: "", + Index: "0xbebecbf1d8c12016e38c09d095290df503fe29731722d939433fa47e3ed1f986", + ZetaFees: sdkmath.ZeroUint(), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_OutboundMined, + StatusMessage: "", + LastUpdateTimestamp: 1709574082, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", + SenderChainId: 7000, + TxOrigin: "0x8E62e3e6FbFF3E21F725395416A20EA4E2DeF015", + CoinType: coin.CoinType_Gas, + Asset: "", + Amount: sdkmath.NewUint(42635427434588308), + InboundTxObservedHash: "0x2720e3a98f18c288f4197d412bfce57e58f00dc4f8b31e335ffc0bf7208dd3c5", + InboundTxObservedExternalHeight: 2031411, + InboundTxBallotIndex: "0xbebecbf1d8c12016e38c09d095290df503fe29731722d939433fa47e3ed1f986", + InboundTxFinalizedZetaHeight: 0, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0x8E62e3e6FbFF3E21F725395416A20EA4E2DeF015", + ReceiverChainId: 1, + CoinType: coin.CoinType_Gas, + Amount: sdkmath.NewUint(42635427434588308), + OutboundTxTssNonce: 7260, + OutboundTxGasLimit: 21000, + OutboundTxGasPrice: "236882693686", + OutboundTxHash: "0xd13b593eb62b5500a00e288cc2fb2c8af1339025c0e6bc6183b8bef2ebbed0d3", + OutboundTxBallotIndex: "0x689d894606642a2a7964fa906ebf4998c22a00708544fa88e9c56b86c955066b", + OutboundTxObservedExternalHeight: 19363323, + OutboundTxGasUsed: 21000, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(236882693686), + OutboundTxEffectiveGasLimit: 21000, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + }, +} diff --git a/zetaclient/testdata/cctx/chain_1_cctx_8014.go b/zetaclient/testdata/cctx/chain_1_cctx_8014.go new file mode 100644 index 0000000000..cc6c201b67 --- /dev/null +++ b/zetaclient/testdata/cctx/chain_1_cctx_8014.go @@ -0,0 +1,53 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/1/8014 +var chain_1_cctx_8014 = &crosschaintypes.CrossChainTx{ + Creator: "", + Index: "0x5a100fdb426da35ad4c95520d7a4f1fd2f38c88067c9e80ba209d3a655c6e06e", + ZetaFees: sdkmath.ZeroUint(), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_OutboundMined, + StatusMessage: "", + LastUpdateTimestamp: 1710834402, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", + SenderChainId: 7000, + TxOrigin: "0x8d8D67A8B71c141492825CAE5112Ccd8581073f2", + CoinType: coin.CoinType_ERC20, + Asset: "0xdac17f958d2ee523a2206206994597c13d831ec7", + Amount: sdkmath.NewUint(23726342442), + InboundTxObservedHash: "0x114ed9d327b6afc068c3fa891b82f7c7f2d42ae25a571f7dc004c05e77af592a", + InboundTxObservedExternalHeight: 2241077, + InboundTxBallotIndex: "0x5a100fdb426da35ad4c95520d7a4f1fd2f38c88067c9e80ba209d3a655c6e06e", + InboundTxFinalizedZetaHeight: 0, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0x8d8D67A8B71c141492825CAE5112Ccd8581073f2", + ReceiverChainId: 1, + CoinType: coin.CoinType_ERC20, + Amount: sdkmath.NewUint(23726342442), + OutboundTxTssNonce: 8014, + OutboundTxGasLimit: 100000, + OutboundTxGasPrice: "58619665744", + OutboundTxHash: "0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146", + OutboundTxBallotIndex: "0x4213f2c335758301b8bbb09d9891949ed6ffeea5dd95e5d9eaa8d410baaa0884", + OutboundTxObservedExternalHeight: 19467367, + OutboundTxGasUsed: 60625, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(58619665744), + OutboundTxEffectiveGasLimit: 100000, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + }, +} diff --git a/zetaclient/testdata/cctx/chain_1_cctx_9718.go b/zetaclient/testdata/cctx/chain_1_cctx_9718.go new file mode 100644 index 0000000000..8c42dbdb33 --- /dev/null +++ b/zetaclient/testdata/cctx/chain_1_cctx_9718.go @@ -0,0 +1,53 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/1/9718 +var chain_1_cctx_9718 = &crosschaintypes.CrossChainTx{ + Creator: "", + Index: "0xbf7a214cf9868e1c618123ab4df0081da87bade74eeb5aef37843e35f25e67b7", + ZetaFees: sdkmath.NewUintFromString("19525506001302763608"), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_OutboundMined, + StatusMessage: "", + LastUpdateTimestamp: 1712336965, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0xF0a3F93Ed1B126142E61423F9546bf1323Ff82DF", + SenderChainId: 7000, + TxOrigin: "0x87257C910a19a3fe64AfFAbFe8cF9AAF2ab148BF", + CoinType: coin.CoinType_Zeta, + Asset: "", + Amount: sdkmath.NewUintFromString("20000000000000000000"), + InboundTxObservedHash: "0xb136652cd58fb6a537b0a1677965983059a2004d98919cdacd52551f877cc44f", + InboundTxObservedExternalHeight: 2492552, + InboundTxBallotIndex: "0xbf7a214cf9868e1c618123ab4df0081da87bade74eeb5aef37843e35f25e67b7", + InboundTxFinalizedZetaHeight: 0, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0x30735c88fa430f11499b0edcfcc25246fb9182e3", + ReceiverChainId: 1, + CoinType: coin.CoinType_Zeta, + Amount: sdkmath.NewUint(474493998697236392), + OutboundTxTssNonce: 9718, + OutboundTxGasLimit: 90000, + OutboundTxGasPrice: "112217884384", + OutboundTxHash: "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f", + OutboundTxBallotIndex: "0xff07eaa34ca02a08bca1558e5f6220cbfc734061f083622b24923e032f0c480f", + OutboundTxObservedExternalHeight: 19590894, + OutboundTxGasUsed: 64651, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(112217884384), + OutboundTxEffectiveGasLimit: 100000, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + }, +} diff --git a/zetaclient/testdata/cctx/chain_1_cctx_intx_ERC20_0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da.go b/zetaclient/testdata/cctx/chain_1_cctx_intx_ERC20_0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da.go new file mode 100644 index 0000000000..3fcc564b22 --- /dev/null +++ b/zetaclient/testdata/cctx/chain_1_cctx_intx_ERC20_0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da.go @@ -0,0 +1,53 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/0xd326700a1931f28853f44f8462f72588f94b1f248214d59a23c3e1b141ff5ede +var chain_1_cctx_intx_ERC20_0x4ea69a0 = &crosschaintypes.CrossChainTx{ + Creator: "zeta1hjct6q7npsspsg3dgvzk3sdf89spmlpf7rqmnw", + Index: "0xd326700a1931f28853f44f8462f72588f94b1f248214d59a23c3e1b141ff5ede", + ZetaFees: sdkmath.NewUintFromString("0"), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_OutboundMined, + StatusMessage: "Remote omnichain contract call completed", + LastUpdateTimestamp: 1709052990, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0x56BF8D4a6E7b59D2C0E40Cba2409a4a30ab4FbE2", + SenderChainId: 1, + TxOrigin: "0x56BF8D4a6E7b59D2C0E40Cba2409a4a30ab4FbE2", + CoinType: coin.CoinType_ERC20, + Asset: "0xdAC17F958D2ee523a2206206994597C13D831ec7", + Amount: sdkmath.NewUintFromString("9992000000"), + InboundTxObservedHash: "0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da", + InboundTxObservedExternalHeight: 19320188, + InboundTxBallotIndex: "0xd326700a1931f28853f44f8462f72588f94b1f248214d59a23c3e1b141ff5ede", + InboundTxFinalizedZetaHeight: 1944675, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0x56bf8d4a6e7b59d2c0e40cba2409a4a30ab4fbe2", + ReceiverChainId: 7000, + CoinType: coin.CoinType_ERC20, + Amount: sdkmath.NewUintFromString("0"), + OutboundTxTssNonce: 0, + OutboundTxGasLimit: 1500000, + OutboundTxGasPrice: "", + OutboundTxHash: "0xf63eaa3e01af477673aa9e86fb634df15d30a00734dab7450cb0fc28dbc9d11b", + OutboundTxBallotIndex: "", + OutboundTxObservedExternalHeight: 1944675, + OutboundTxGasUsed: 0, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(0), + OutboundTxEffectiveGasLimit: 0, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + }, +} diff --git a/zetaclient/testdata/cctx/chain_1_cctx_intx_Gas_0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532.go b/zetaclient/testdata/cctx/chain_1_cctx_intx_Gas_0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532.go new file mode 100644 index 0000000000..d281302309 --- /dev/null +++ b/zetaclient/testdata/cctx/chain_1_cctx_intx_Gas_0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532.go @@ -0,0 +1,53 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098 +var chain_1_cctx_intx_Gas_0xeaec67d = &crosschaintypes.CrossChainTx{ + Creator: "zeta1hjct6q7npsspsg3dgvzk3sdf89spmlpf7rqmnw", + Index: "0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098", + ZetaFees: sdkmath.NewUint(0), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_OutboundMined, + StatusMessage: "Remote omnichain contract call completed", + LastUpdateTimestamp: 1709177431, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0xF829fa7069680b8C37A8086b37d4a24697E5003b", + SenderChainId: 1, + TxOrigin: "0xF829fa7069680b8C37A8086b37d4a24697E5003b", + CoinType: coin.CoinType_Gas, + Asset: "", + Amount: sdkmath.NewUintFromString("4000000000000000"), + InboundTxObservedHash: "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532", + InboundTxObservedExternalHeight: 19330473, + InboundTxBallotIndex: "0x0210925c7dceeff563e6e240d6d650a5f0e8fca6f5b76044a6cf106d21f27098", + InboundTxFinalizedZetaHeight: 1965579, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0xF829fa7069680b8C37A8086b37d4a24697E5003b", + ReceiverChainId: 7000, + CoinType: coin.CoinType_Gas, + Amount: sdkmath.NewUint(0), + OutboundTxTssNonce: 0, + OutboundTxGasLimit: 90000, + OutboundTxGasPrice: "", + OutboundTxHash: "0x3b8c1dab5aa21ff90ddb569f2f962ff2d4aa8d914c9177900102e745955e6f35", + OutboundTxBallotIndex: "", + OutboundTxObservedExternalHeight: 1965579, + OutboundTxGasUsed: 0, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(0), + OutboundTxEffectiveGasLimit: 0, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + }, +} diff --git a/zetaclient/testdata/cctx/chain_1_cctx_intx_Zeta_0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76.go b/zetaclient/testdata/cctx/chain_1_cctx_intx_Zeta_0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76.go new file mode 100644 index 0000000000..22162d8ab7 --- /dev/null +++ b/zetaclient/testdata/cctx/chain_1_cctx_intx_Zeta_0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76.go @@ -0,0 +1,53 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/0x477544c4b8c8be544b23328b21286125c89cd6bb5d1d6d388d91eea8ea1a6f1f +var chain_1_cctx_intx_Zeta_0xf393520 = &crosschaintypes.CrossChainTx{ + Creator: "zeta1p0uwsq4naus5r4l7l744upy0k8ezzj84mn40nf", + Index: "0x477544c4b8c8be544b23328b21286125c89cd6bb5d1d6d388d91eea8ea1a6f1f", + ZetaFees: sdkmath.NewUintFromString("0"), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_OutboundMined, + StatusMessage: "Remote omnichain contract call completed", + LastUpdateTimestamp: 1708490549, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0x2f993766e8e1Ef9288B1F33F6aa244911A0A77a7", + SenderChainId: 1, + TxOrigin: "0x2f993766e8e1Ef9288B1F33F6aa244911A0A77a7", + CoinType: coin.CoinType_Zeta, + Asset: "", + Amount: sdkmath.NewUintFromString("20000000000000000000"), + InboundTxObservedHash: "0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76", + InboundTxObservedExternalHeight: 19273702, + InboundTxBallotIndex: "0x477544c4b8c8be544b23328b21286125c89cd6bb5d1d6d388d91eea8ea1a6f1f", + InboundTxFinalizedZetaHeight: 1851403, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0x2f993766e8e1ef9288b1f33f6aa244911a0a77a7", + ReceiverChainId: 7000, + CoinType: coin.CoinType_Zeta, + Amount: sdkmath.ZeroUint(), + OutboundTxTssNonce: 0, + OutboundTxGasLimit: 100000, + OutboundTxGasPrice: "", + OutboundTxHash: "0x947434364da7c74d7e896a389aa8cb3122faf24bbcba64b141cb5acd7838209c", + OutboundTxBallotIndex: "", + OutboundTxObservedExternalHeight: 1851403, + OutboundTxGasUsed: 0, + OutboundTxEffectiveGasPrice: sdkmath.ZeroInt(), + OutboundTxEffectiveGasLimit: 0, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + }, +} diff --git a/zetaclient/testdata/cctx/chain_56_cctx_68270.go b/zetaclient/testdata/cctx/chain_56_cctx_68270.go new file mode 100644 index 0000000000..d39ddc17f1 --- /dev/null +++ b/zetaclient/testdata/cctx/chain_56_cctx_68270.go @@ -0,0 +1,53 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/56/68270 +var chain_56_cctx_68270 = &crosschaintypes.CrossChainTx{ + Creator: "", + Index: "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", + ZetaFees: sdkmath.ZeroUint(), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_PendingOutbound, + StatusMessage: "", + LastUpdateTimestamp: 1709145183, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", + SenderChainId: 7000, + TxOrigin: "0xb0C04e07A301927672A8A7a874DB6930576C90B8", + CoinType: coin.CoinType_Gas, + Asset: "", + Amount: sdkmath.NewUint(657177295293237048), + InboundTxObservedHash: "0x093f4ca4c1884df0fd9dd59b75979342ded29d3c9b6861644287a2e1417b9a39", + InboundTxObservedExternalHeight: 1960153, + InboundTxBallotIndex: "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", + InboundTxFinalizedZetaHeight: 0, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "0xb0C04e07A301927672A8A7a874DB6930576C90B8", + ReceiverChainId: 56, + CoinType: coin.CoinType_Gas, + Amount: sdkmath.NewUint(657177295293237048), + OutboundTxTssNonce: 68270, + OutboundTxGasLimit: 21000, + OutboundTxGasPrice: "6000000000", + OutboundTxHash: "0xeb2b183ece6638688b9df9223180b13a67208cd744bbdadeab8de0482d7f4e3c", + OutboundTxBallotIndex: "0xa4600c952934f797e162d637d70859a611757407908d96bc53e45a81c80b006b", + OutboundTxObservedExternalHeight: 36537856, + OutboundTxGasUsed: 21000, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(6000000000), + OutboundTxEffectiveGasLimit: 21000, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + }, +} diff --git a/zetaclient/testdata/cctx/chain_8332_cctx_148.go b/zetaclient/testdata/cctx/chain_8332_cctx_148.go new file mode 100644 index 0000000000..f679164bda --- /dev/null +++ b/zetaclient/testdata/cctx/chain_8332_cctx_148.go @@ -0,0 +1,52 @@ +package cctx + +import ( + sdkmath "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// https://zetachain-mainnet-archive.allthatnode.com:1317/zeta-chain/crosschain/cctx/8332/148 +var chain_8332_cctx_148 = &crosschaintypes.CrossChainTx{ + Creator: "", + Index: "0xb3f5f3cf2ed2e0c3fa64c8297c9e50fbc07351fb2d26d8eae4cfbbd45e47a524", + ZetaFees: sdkmath.ZeroUint(), + RelayedMessage: "", + CctxStatus: &crosschaintypes.Status{ + Status: crosschaintypes.CctxStatus_OutboundMined, + StatusMessage: "", + LastUpdateTimestamp: 1708608895, + IsAbortRefunded: false, + }, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Sender: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", + SenderChainId: 7000, + TxOrigin: "0xe99174F08e1186134830f8511De06bd010978533", + CoinType: coin.CoinType_Gas, + Asset: "", + Amount: sdkmath.NewUint(12000), + InboundTxObservedHash: "0x06455013319acb1b027461134853c77b003d8eab162b1f37673da5ad8a50b74f", + InboundTxObservedExternalHeight: 1870408, + InboundTxBallotIndex: "0xb3f5f3cf2ed2e0c3fa64c8297c9e50fbc07351fb2d26d8eae4cfbbd45e47a524", + InboundTxFinalizedZetaHeight: 0, + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_NotFinalized, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{ + { + Receiver: "bc1qpsdlklfcmlcfgm77c43x65ddtrt7n0z57hsyjp", + ReceiverChainId: 8332, + CoinType: coin.CoinType_Gas, + Amount: sdkmath.NewUint(12000), + OutboundTxTssNonce: 148, + OutboundTxGasLimit: 254, + OutboundTxGasPrice: "46", + OutboundTxHash: "030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0", + OutboundTxObservedExternalHeight: 150, + OutboundTxGasUsed: 0, + OutboundTxEffectiveGasPrice: sdkmath.NewInt(0), + OutboundTxEffectiveGasLimit: 0, + TssPubkey: "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + TxFinalizationStatus: crosschaintypes.TxFinalizationStatus_Executed, + }, + }, +} diff --git a/zetaclient/testdata/evm/chain_1337_outtx_Zeta_0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7.json b/zetaclient/testdata/evm/chain_1337_outtx_Zeta_0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7.json new file mode 100644 index 0000000000..69fad53b1f --- /dev/null +++ b/zetaclient/testdata/evm/chain_1337_outtx_Zeta_0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7.json @@ -0,0 +1,15 @@ +{ + "type": "0x0", + "nonce": "0xe", + "gasPrice": "0x12", + "maxPriorityFeePerGas": null, + "maxFeePerGas": null, + "gas": "0x3d090", + "value": "0x0", + "input": "0x942a5e16000000000000000000000000bff76e77d56b3c1202107f059425d56f0aef87ed000000000000000000000000000000000000000000000000000000000000053900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000053900000000000000000000000000000000000000000000000053444835ebce41f6000000000000000000000000000000000000000000000000000000000000012085d06ac908823d125a919164f0596e3496224b206ebe8125ffe7b4ab766f85df0000000000000000000000000000000000000000000000000000000000000014bff76e77d56b3c1202107f059425d56f0aef87ed00000000000000000000000000000000000000000000000000000000000000000000000000000000000000406e0182194bb1deba01849afd3e035a0b70ce7cb069e482ee663519c76cf569b40000000000000000000000000000000000000000000000000000000000000001", + "v": "0xa95", + "r": "0x79f72c2cbd8a0ce55d1130f11ea175c8fd02e93e6063f747ef70ac3cc74c3777", + "s": "0x6131d906f55dc4e6ca9a6f795307d75e9447b740a04fd32cdb4f7865e4521822", + "to": "0xd28d6a0b8189305551a0a8bd247a6eca9ce781ca", + "hash": "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7" +} diff --git a/zetaclient/testdata/evm/chain_1337_outtx_receipt_Zeta_ZetaReverted_0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7.json b/zetaclient/testdata/evm/chain_1337_outtx_receipt_Zeta_ZetaReverted_0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7.json new file mode 100644 index 0000000000..6e07f707bf --- /dev/null +++ b/zetaclient/testdata/evm/chain_1337_outtx_receipt_Zeta_ZetaReverted_0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7.json @@ -0,0 +1,57 @@ +{ + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0x12960", + "logsBloom": "0x00000000000000000000000010400000000010000000000000000000000000000000200000200000000100000040000000020000000000800000000000000000000000000000000008000008000000000000000000000000000000000000000000000100000020000000000000000000000000000004020000000010000000000000000000000000020800000000010400800000000000000400000000000000000000000000000001000000000000000000000000000000000020000000000000000006000000000000000000002000000000000800000000000000000000004000001000000000000000000000000000000000000000000000000000000000", + "logs": [ + { + "address": "0x733ab8b06dddef27eaa72294b0d7c9cef7f12db9", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x000000000000000000000000d28d6a0b8189305551a0a8bd247a6eca9ce781ca", + "0x000000000000000000000000bff76e77d56b3c1202107f059425d56f0aef87ed" + ], + "data": "0x00000000000000000000000000000000000000000000000053444835ebce41f6", + "blockNumber": "0xc9", + "transactionHash": "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7", + "transactionIndex": "0x0", + "blockHash": "0x4d34bc01ece5cf216cb9817ba3e99a8383434aa4a3f20eef8bc19f6b691eed2b", + "logIndex": "0x0", + "removed": false + }, + { + "address": "0xbff76e77d56b3c1202107f059425d56f0aef87ed", + "topics": [ + "0x4f30bf4846ce4cde02361b3232cd2287313384a7b8e60161a1b2818b6905a521" + ], + "data": "0x", + "blockNumber": "0xc9", + "transactionHash": "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7", + "transactionIndex": "0x0", + "blockHash": "0x4d34bc01ece5cf216cb9817ba3e99a8383434aa4a3f20eef8bc19f6b691eed2b", + "logIndex": "0x1", + "removed": false + }, + { + "address": "0xd28d6a0b8189305551a0a8bd247a6eca9ce781ca", + "topics": [ + "0x521fb0b407c2eb9b1375530e9b9a569889992140a688bc076aa72c1712012c88", + "0x0000000000000000000000000000000000000000000000000000000000000539", + "0x85d06ac908823d125a919164f0596e3496224b206ebe8125ffe7b4ab766f85df" + ], + "data": "0x000000000000000000000000bff76e77d56b3c1202107f059425d56f0aef87ed000000000000000000000000000000000000000000000000000000000000053900000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000053444835ebce41f600000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000014bff76e77d56b3c1202107f059425d56f0aef87ed00000000000000000000000000000000000000000000000000000000000000000000000000000000000000406e0182194bb1deba01849afd3e035a0b70ce7cb069e482ee663519c76cf569b40000000000000000000000000000000000000000000000000000000000000001", + "blockNumber": "0xc9", + "transactionHash": "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7", + "transactionIndex": "0x0", + "blockHash": "0x4d34bc01ece5cf216cb9817ba3e99a8383434aa4a3f20eef8bc19f6b691eed2b", + "logIndex": "0x2", + "removed": false + } + ], + "transactionHash": "0x1487e6a31dd430306667250b72bf15b8390b73108b69f3de5c1b2efe456036a7", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0x12960", + "blockHash": "0x4d34bc01ece5cf216cb9817ba3e99a8383434aa4a3f20eef8bc19f6b691eed2b", + "blockNumber": "0xc9", + "transactionIndex": "0x0" +} diff --git a/zetaclient/testdata/evm/chain_1_outtx_ERC20_0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146.json b/zetaclient/testdata/evm/chain_1_outtx_ERC20_0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146.json new file mode 100644 index 0000000000..88141e8967 --- /dev/null +++ b/zetaclient/testdata/evm/chain_1_outtx_ERC20_0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146.json @@ -0,0 +1,15 @@ +{ + "type": "0x0", + "nonce": "0x1f4e", + "gasPrice": "0xda6011d50", + "maxPriorityFeePerGas": null, + "maxFeePerGas": null, + "gas": "0x186a0", + "value": "0x0", + "input": "0xd9caed120000000000000000000000008d8d67a8b71c141492825cae5112ccd8581073f2000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000000000000000000000000000000000058633412a", + "v": "0x25", + "r": "0x7e05da110efc400146318c287f630812117eab9225baa7181f783861f088ab83", + "s": "0x560380aacfe105b0922483594c9f5e046c372dc266c54b61e37168a956b7d42b", + "to": "0x0000030ec64df25301d8414ee5a29588c4b0de10", + "hash": "0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146" +} diff --git a/zetaclient/testdata/evm/chain_1_outtx_Zeta_0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f.json b/zetaclient/testdata/evm/chain_1_outtx_Zeta_0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f.json new file mode 100644 index 0000000000..662139e1d7 --- /dev/null +++ b/zetaclient/testdata/evm/chain_1_outtx_Zeta_0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f.json @@ -0,0 +1,15 @@ +{ + "type": "0x0", + "nonce": "0x25f6", + "gasPrice": "0x1a20b506e0", + "maxPriorityFeePerGas": null, + "maxFeePerGas": null, + "gas": "0x186a0", + "value": "0x0", + "input": "0x29dd214d00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000001b5800000000000000000000000030735c88fa430f11499b0edcfcc25246fb9182e30000000000000000000000000000000000000000000000000695bdc7206747a80000000000000000000000000000000000000000000000000000000000000100bf7a214cf9868e1c618123ab4df0081da87bade74eeb5aef37843e35f25e67b70000000000000000000000000000000000000000000000000000000000000014f0a3f93ed1b126142e61423f9546bf1323ff82df0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "v": "0x26", + "r": "0x4691ef5c56d90ae924c07505da70eae69bf172c885b7cd6fbe660f8d0d679f49", + "s": "0x47cd582bf871d63e3ef93924ec45a94a9077721dc1a470dc6aa04c93496c5841", + "to": "0x000007cf399229b2f5a4d043f20e90c9c98b7c6a", + "hash": "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f" +} diff --git a/zetaclient/testdata/evm/chain_1_outtx_receipt_ERC20_Withdrawn_0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146.json b/zetaclient/testdata/evm/chain_1_outtx_receipt_ERC20_Withdrawn_0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146.json new file mode 100644 index 0000000000..02da3f6ae9 --- /dev/null +++ b/zetaclient/testdata/evm/chain_1_outtx_receipt_ERC20_Withdrawn_0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146.json @@ -0,0 +1,44 @@ +{ + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0x26b5b5", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000010000000000000000000000400000000000000000000000000000000008000000000000000000000000000002001000000000000000000000000000800000000000000000200000000000000010000000000000000020000000000000000000000000000000000000000000000200100000000000000000000002000080000000000000000000000000040000000000004000000002000000000000000000000000000000020000000010000000000000000000000800000000000000080000000000000000000000000000000000000000", + "logs": [ + { + "address": "0xdac17f958d2ee523a2206206994597c13d831ec7", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x0000000000000000000000000000030ec64df25301d8414ee5a29588c4b0de10", + "0x0000000000000000000000008d8d67a8b71c141492825cae5112ccd8581073f2" + ], + "data": "0x000000000000000000000000000000000000000000000000000000058633412a", + "blockNumber": "0x1290c67", + "transactionHash": "0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146", + "transactionIndex": "0x15", + "blockHash": "0x599baa79442ea7b4958fc9c24f71269fd7a9dfe7bef8c7f7b6f382afacf06164", + "logIndex": "0x55", + "removed": false + }, + { + "address": "0x0000030ec64df25301d8414ee5a29588c4b0de10", + "topics": [ + "0xd1c19fbcd4551a5edfb66d43d2e337c04837afda3482b42bdf569a8fccdae5fb", + "0x0000000000000000000000008d8d67a8b71c141492825cae5112ccd8581073f2", + "0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7" + ], + "data": "0x000000000000000000000000000000000000000000000000000000058633412a", + "blockNumber": "0x1290c67", + "transactionHash": "0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146", + "transactionIndex": "0x15", + "blockHash": "0x599baa79442ea7b4958fc9c24f71269fd7a9dfe7bef8c7f7b6f382afacf06164", + "logIndex": "0x56", + "removed": false + } + ], + "transactionHash": "0xd2eba7ac3da1b62800165414ea4bcaf69a3b0fb9b13a0fc32f4be11bfef79146", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0xecd1", + "blockHash": "0x599baa79442ea7b4958fc9c24f71269fd7a9dfe7bef8c7f7b6f382afacf06164", + "blockNumber": "0x1290c67", + "transactionIndex": "0x15" +} diff --git a/zetaclient/testdata/evm/chain_1_outtx_receipt_Zeta_ZetaReceived_0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f.json b/zetaclient/testdata/evm/chain_1_outtx_receipt_Zeta_ZetaReceived_0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f.json new file mode 100644 index 0000000000..b0b3070c3a --- /dev/null +++ b/zetaclient/testdata/evm/chain_1_outtx_receipt_Zeta_ZetaReceived_0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f.json @@ -0,0 +1,45 @@ +{ + "root": "0x", + "status": "0x1", + "cumulativeGasUsed": "0x18d886", + "logsBloom": "0x00000000000000000000000000000000001000000000000000000000080000000000000000000000000000000000002008041000000000000000000000000000800000008000000000000008000000000000000000000000000000000000080000000000100000000000040000000000000000000000000000000010000000000000000000000100000000010000000000000002000000000000000000000000000000000000000000000000000000000000000000000002000000000000200000000002000000000000000000000080000000000000000000200000000000000000100000000000080000000000000000000000000000000000002000000000", + "logs": [ + { + "address": "0xf091867ec603a6628ed83d274e835539d82e9cc8", + "topics": [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x000000000000000000000000000007cf399229b2f5a4d043f20e90c9c98b7c6a", + "0x00000000000000000000000030735c88fa430f11499b0edcfcc25246fb9182e3" + ], + "data": "0x0000000000000000000000000000000000000000000000000695bdc7206747a8", + "blockNumber": "0x12aeeee", + "transactionHash": "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f", + "transactionIndex": "0xc", + "blockHash": "0xd27850dcfe8026052a2d89122c910a909062458374c870a3f3b3dbf7d5f5e6a0", + "logIndex": "0x3d", + "removed": false + }, + { + "address": "0x000007cf399229b2f5a4d043f20e90c9c98b7c6a", + "topics": [ + "0xf1302855733b40d8acb467ee990b6d56c05c80e28ebcabfa6e6f3f57cb50d698", + "0x0000000000000000000000000000000000000000000000000000000000001b58", + "0x00000000000000000000000030735c88fa430f11499b0edcfcc25246fb9182e3", + "0xbf7a214cf9868e1c618123ab4df0081da87bade74eeb5aef37843e35f25e67b7" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000695bdc7206747a800000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000014f0a3f93ed1b126142e61423f9546bf1323ff82df0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockNumber": "0x12aeeee", + "transactionHash": "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f", + "transactionIndex": "0xc", + "blockHash": "0xd27850dcfe8026052a2d89122c910a909062458374c870a3f3b3dbf7d5f5e6a0", + "logIndex": "0x3e", + "removed": false + } + ], + "transactionHash": "0x81342051b8a85072d3e3771c1a57c7bdb5318e8caf37f5a687b7a91e50a7257f", + "contractAddress": "0x0000000000000000000000000000000000000000", + "gasUsed": "0xfc8b", + "blockHash": "0xd27850dcfe8026052a2d89122c910a909062458374c870a3f3b3dbf7d5f5e6a0", + "blockNumber": "0x12aeeee", + "transactionIndex": "0xc" +} diff --git a/zetaclient/testutils/constant.go b/zetaclient/testutils/constant.go index 05cab82256..380c3ab501 100644 --- a/zetaclient/testutils/constant.go +++ b/zetaclient/testutils/constant.go @@ -16,6 +16,13 @@ const ( OtherAddress1 = "0x21248Decd0B7EcB0F30186297766b8AB6496265b" OtherAddress2 = "0x33A351C90aF486AebC35042Bb0544123cAed26AB" OtherAddress3 = "0x86B77E4fBd07CFdCc486cAe4F2787fB5C5a62cd3" + + // evm event names for test data naming + EventZetaSent = "ZetaSent" + EventZetaReceived = "ZetaReceived" + EventZetaReverted = "ZetaReverted" + EventERC20Deposit = "Deposited" + EventERC20Withdraw = "Withdrawn" ) // ConnectorAddresses contains constants ERC20 connector addresses for testing @@ -25,8 +32,12 @@ var ConnectorAddresses = map[int64]ethcommon.Address{ 56: ethcommon.HexToAddress("0x000063A6e758D9e2f438d430108377564cf4077D"), // testnet - 5: ethcommon.HexToAddress("0x00005E3125aBA53C5652f9F0CE1a4Cf91D8B15eA"), - 97: ethcommon.HexToAddress("0x0000ecb8cdd25a18F12DAA23f6422e07fBf8B9E1"), + 5: ethcommon.HexToAddress("0x00005E3125aBA53C5652f9F0CE1a4Cf91D8B15eA"), + 97: ethcommon.HexToAddress("0x0000ecb8cdd25a18F12DAA23f6422e07fBf8B9E1"), + 11155111: ethcommon.HexToAddress("0x3963341dad121c9CD33046089395D66eBF20Fb03"), + + // localnet + 1337: ethcommon.HexToAddress("0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca"), } // CustodyAddresses contains constants ERC20 custody addresses for testing @@ -36,6 +47,7 @@ var CustodyAddresses = map[int64]ethcommon.Address{ 56: ethcommon.HexToAddress("0x00000fF8fA992424957F97688015814e707A0115"), // testnet - 5: ethcommon.HexToAddress("0x000047f11C6E42293F433C82473532E869Ce4Ec5"), - 97: ethcommon.HexToAddress("0x0000a7Db254145767262C6A81a7eE1650684258e"), + 5: ethcommon.HexToAddress("0x000047f11C6E42293F433C82473532E869Ce4Ec5"), + 97: ethcommon.HexToAddress("0x0000a7Db254145767262C6A81a7eE1650684258e"), + 11155111: ethcommon.HexToAddress("0x84725b70a239d3Faa7C6EF0C6C8E8b6c8e28338b"), } diff --git a/zetaclient/testutils/stub/chain_client.go b/zetaclient/testutils/stub/chain_client.go index f5a5368511..a79cc3f731 100644 --- a/zetaclient/testutils/stub/chain_client.go +++ b/zetaclient/testutils/stub/chain_client.go @@ -29,7 +29,7 @@ func (s *EVMClient) Start() { func (s *EVMClient) Stop() { } -func (s *EVMClient) IsSendOutTxProcessed(_ *crosschaintypes.CrossChainTx, _ zerolog.Logger) (bool, bool, error) { +func (s *EVMClient) IsOutboundProcessed(_ *crosschaintypes.CrossChainTx, _ zerolog.Logger) (bool, bool, error) { return false, false, nil } @@ -70,7 +70,7 @@ func (s *BTCClient) Start() { func (s *BTCClient) Stop() { } -func (s *BTCClient) IsSendOutTxProcessed(_ *crosschaintypes.CrossChainTx, _ zerolog.Logger) (bool, bool, error) { +func (s *BTCClient) IsOutboundProcessed(_ *crosschaintypes.CrossChainTx, _ zerolog.Logger) (bool, bool, error) { return false, false, nil } diff --git a/zetaclient/testutils/stub/core_bridge.go b/zetaclient/testutils/stub/core_bridge.go index 111d73983a..2f0ddaa732 100644 --- a/zetaclient/testutils/stub/core_bridge.go +++ b/zetaclient/testutils/stub/core_bridge.go @@ -4,12 +4,15 @@ 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" "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/testutil/sample" cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types" observerTypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/interfaces" @@ -48,7 +51,7 @@ func (z *MockZetaCoreBridge) PostVoteOutbound(_ string, _ string, _ uint64, _ ui if z.paused { return "", "", errors.New(ErrMsgPaused) } - return "", "", nil + return sample.Hash().Hex(), "", nil } func (z *MockZetaCoreBridge) PostGasPrice(_ chains.Chain, _ uint64, _ string, _ uint64) (string, error) { @@ -58,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/testutils/testdata.go b/zetaclient/testutils/testdata.go index 37b6cbab14..001ca2b07b 100644 --- a/zetaclient/testutils/testdata.go +++ b/zetaclient/testutils/testdata.go @@ -14,6 +14,7 @@ import ( "github.com/zeta-chain/zetacore/pkg/coin" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/zetaclient/config" + testcctx "github.com/zeta-chain/zetacore/zetaclient/testdata/cctx" ) const ( @@ -24,6 +25,16 @@ const ( RestrictedBtcAddressTest = "bcrt1qzp4gt6fc7zkds09kfzaf9ln9c5rvrzxmy6qmpp" ) +// cloneCctx returns a deep copy of the cctx +func cloneCctx(t *testing.T, cctx *crosschaintypes.CrossChainTx) *crosschaintypes.CrossChainTx { + data, err := cctx.Marshal() + require.NoError(t, err) + cloned := &crosschaintypes.CrossChainTx{} + err = cloned.Unmarshal(data) + require.NoError(t, err) + return cloned +} + // SaveObjectToJSONFile saves an object to a file in JSON format func SaveObjectToJSONFile(obj interface{}, filename string) error { file, err := os.Create(filepath.Clean(filename)) @@ -76,6 +87,48 @@ func SaveBTCBlockTrimTx(blockVb *btcjson.GetBlockVerboseTxResult, filename strin return SaveObjectToJSONFile(blockVb, filename) } +// LoadCctxByIntx loads archived cctx by intx +func LoadCctxByIntx( + t *testing.T, + chainID int64, + coinType coin.CoinType, + intxHash string, +) *crosschaintypes.CrossChainTx { + // nameCctx := path.Join("../", TestDataPathCctx, FileNameCctxByIntx(chainID, intxHash, coinType)) + + // cctx := &crosschaintypes.CrossChainTx{} + // LoadObjectFromJSONFile(t, &cctx, nameCctx) + // return cctx + + // get cctx + cctx, found := testcctx.CctxByIntxMap[chainID][coinType][intxHash] + require.True(t, found) + + // clone cctx for each individual test + cloned := cloneCctx(t, cctx) + return cloned +} + +// LoadCctxByNonce loads archived cctx by nonce +func LoadCctxByNonce( + t *testing.T, + chainID int64, + nonce uint64, +) *crosschaintypes.CrossChainTx { + // nameCctx := path.Join("../", TestDataPathCctx, FileNameCctxByNonce(chainID, nonce)) + + // cctx := &crosschaintypes.CrossChainTx{} + // LoadObjectFromJSONFile(t, &cctx, nameCctx) + + // get cctx + cctx, found := testcctx.CCtxByNonceMap[chainID][nonce] + require.True(t, found) + + // clone cctx for each individual test + cloned := cloneCctx(t, cctx) + return cloned +} + // LoadEVMBlock loads archived evm block from file func LoadEVMBlock(t *testing.T, chainID int64, blockNumber uint64, trimmed bool) *ethrpc.Block { name := path.Join("../", TestDataPathEVM, FileNameEVMBlock(chainID, blockNumber, trimmed)) @@ -99,9 +152,7 @@ func LoadBTCTxRawResultNCctx(t *testing.T, chainID int64, nonce uint64) (*btcjso rawResult := &btcjson.TxRawResult{} LoadObjectFromJSONFile(t, rawResult, nameTx) - nameCctx := path.Join("../", TestDataPathCctx, FileNameCctxByNonce(chainID, nonce)) - cctx := &crosschaintypes.CrossChainTx{} - LoadObjectFromJSONFile(t, cctx, nameCctx) + cctx := LoadCctxByNonce(t, chainID, nonce) return rawResult, cctx } @@ -131,31 +182,6 @@ func LoadEVMIntxReceipt( return receipt } -// LoadEVMIntxCctx loads archived intx cctx from file -func LoadEVMIntxCctx( - t *testing.T, - chainID int64, - intxHash string, - coinType coin.CoinType) *crosschaintypes.CrossChainTx { - nameCctx := path.Join("../", TestDataPathCctx, FileNameEVMIntxCctx(chainID, intxHash, coinType)) - - cctx := &crosschaintypes.CrossChainTx{} - LoadObjectFromJSONFile(t, &cctx, nameCctx) - return cctx -} - -// LoadCctxByNonce loads archived cctx by nonce from file -func LoadCctxByNonce( - t *testing.T, - chainID int64, - nonce uint64) *crosschaintypes.CrossChainTx { - nameCctx := path.Join("../", TestDataPathCctx, FileNameCctxByNonce(chainID, nonce)) - - cctx := &crosschaintypes.CrossChainTx{} - LoadObjectFromJSONFile(t, &cctx, nameCctx) - return cctx -} - // LoadEVMIntxNReceipt loads archived intx and receipt from file func LoadEVMIntxNReceipt( t *testing.T, @@ -217,7 +243,7 @@ func LoadEVMIntxNReceiptNCctx( // load archived intx, receipt and cctx tx := LoadEVMIntx(t, chainID, intxHash, coinType) receipt := LoadEVMIntxReceipt(t, chainID, intxHash, coinType) - cctx := LoadEVMIntxCctx(t, chainID, intxHash, coinType) + cctx := LoadCctxByIntx(t, chainID, coinType, intxHash) return tx, receipt, cctx } @@ -226,9 +252,9 @@ func LoadEVMIntxNReceiptNCctx( func LoadEVMOuttx( t *testing.T, chainID int64, - intxHash string, + txHash string, coinType coin.CoinType) *ethtypes.Transaction { - nameTx := path.Join("../", TestDataPathEVM, FileNameEVMOuttx(chainID, intxHash, coinType)) + nameTx := path.Join("../", TestDataPathEVM, FileNameEVMOuttx(chainID, txHash, coinType)) tx := ðtypes.Transaction{} LoadObjectFromJSONFile(t, &tx, nameTx) @@ -239,9 +265,10 @@ func LoadEVMOuttx( func LoadEVMOuttxReceipt( t *testing.T, chainID int64, - intxHash string, - coinType coin.CoinType) *ethtypes.Receipt { - nameReceipt := path.Join("../", TestDataPathEVM, FileNameEVMOuttxReceipt(chainID, intxHash, coinType)) + txHash string, + coinType coin.CoinType, + eventName string) *ethtypes.Receipt { + nameReceipt := path.Join("../", TestDataPathEVM, FileNameEVMOuttxReceipt(chainID, txHash, coinType, eventName)) receipt := ðtypes.Receipt{} LoadObjectFromJSONFile(t, &receipt, nameReceipt) @@ -252,11 +279,25 @@ func LoadEVMOuttxReceipt( func LoadEVMOuttxNReceipt( t *testing.T, chainID int64, - intxHash string, + txHash string, coinType coin.CoinType) (*ethtypes.Transaction, *ethtypes.Receipt) { // load archived evm outtx and receipt - tx := LoadEVMOuttx(t, chainID, intxHash, coinType) - receipt := LoadEVMOuttxReceipt(t, chainID, intxHash, coinType) + tx := LoadEVMOuttx(t, chainID, txHash, coinType) + receipt := LoadEVMOuttxReceipt(t, chainID, txHash, coinType, "") return tx, receipt } + +// LoadEVMOuttxNReceiptNEvent loads archived cctx, outtx and receipt from file +func LoadEVMCctxNOuttxNReceipt( + t *testing.T, + chainID int64, + nonce uint64, + eventName string) (*crosschaintypes.CrossChainTx, *ethtypes.Transaction, *ethtypes.Receipt) { + cctx := LoadCctxByNonce(t, chainID, nonce) + coinType := cctx.GetCurrentOutTxParam().CoinType + txHash := cctx.GetCurrentOutTxParam().OutboundTxHash + outtx := LoadEVMOuttx(t, chainID, txHash, coinType) + receipt := LoadEVMOuttxReceipt(t, chainID, txHash, coinType, eventName) + return cctx, outtx, receipt +} diff --git a/zetaclient/testutils/testdata_naming.go b/zetaclient/testutils/testdata_naming.go index a920680335..675a1a7b0b 100644 --- a/zetaclient/testutils/testdata_naming.go +++ b/zetaclient/testutils/testdata_naming.go @@ -14,6 +14,16 @@ func FileNameEVMBlock(chainID int64, blockNumber uint64, trimmed bool) string { return fmt.Sprintf("chain_%d_block_ethrpc_trimmed_%d.json", chainID, blockNumber) } +// FileNameCctxByIntx returns unified archive cctx file name by intx +func FileNameCctxByIntx(chainID int64, intxHash string, coinType coin.CoinType) string { + return fmt.Sprintf("cctx_intx_%d_%s_%s.json", chainID, coinType, intxHash) +} + +// FileNameCctxByNonce returns unified archive cctx file name by nonce +func FileNameCctxByNonce(chainID int64, nonce uint64) string { + return fmt.Sprintf("chain_%d_cctx_%d.json", chainID, nonce) +} + // FileNameEVMIntx returns unified archive file name for inbound tx func FileNameEVMIntx(chainID int64, intxHash string, coinType coin.CoinType, donation bool) string { if !donation { @@ -30,11 +40,6 @@ func FileNameEVMIntxReceipt(chainID int64, intxHash string, coinType coin.CoinTy return fmt.Sprintf("chain_%d_intx_receipt_donation_%s_%s.json", chainID, coinType, intxHash) } -// FileNameEVMIntxCctx returns unified archive file name for inbound cctx -func FileNameEVMIntxCctx(chainID int64, intxHash string, coinType coin.CoinType) string { - return fmt.Sprintf("cctx_intx_%d_%s_%s.json", chainID, coinType, intxHash) -} - // FileNameBTCIntx returns unified archive file name for inbound tx func FileNameBTCIntx(chainID int64, intxHash string, donation bool) string { if !donation { @@ -59,17 +64,16 @@ func FileNameBTCMsgTx(chainID int64, txHash string) string { return fmt.Sprintf("chain_%d_msgtx_%s.json", chainID, txHash) } -// FileNameCctxByNonce returns unified archive file name for cctx by nonce -func FileNameCctxByNonce(chainID int64, nonce uint64) string { - return fmt.Sprintf("cctx_%d_%d.json", chainID, nonce) -} - // FileNameEVMOuttx returns unified archive file name for outbound tx func FileNameEVMOuttx(chainID int64, txHash string, coinType coin.CoinType) string { return fmt.Sprintf("chain_%d_outtx_%s_%s.json", chainID, coinType, txHash) } // FileNameEVMOuttxReceipt returns unified archive file name for outbound tx receipt -func FileNameEVMOuttxReceipt(chainID int64, txHash string, coinType coin.CoinType) string { - return fmt.Sprintf("chain_%d_outtx_receipt_%s_%s.json", chainID, coinType, txHash) +func FileNameEVMOuttxReceipt(chainID int64, txHash string, coinType coin.CoinType, eventName string) string { + // empty eventName is for regular transfer receipt, no event + if eventName == "" { + return fmt.Sprintf("chain_%d_outtx_receipt_%s_%s.json", chainID, coinType, txHash) + } + return fmt.Sprintf("chain_%d_outtx_receipt_%s_%s_%s.json", chainID, coinType, eventName, txHash) } 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 e7cbebd06a..b76996e79a 100644 --- a/zetaclient/zetabridge/tx.go +++ b/zetaclient/zetabridge/tx.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" "github.com/pkg/errors" + "github.com/rs/zerolog" "github.com/zeta-chain/go-tss/blame" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/coin" @@ -53,7 +54,7 @@ func (b *ZetaCoreBridge) PostGasPrice(chain chains.Chain, gasPrice uint64, suppl // #nosec G701 always in range gasPrice = uint64(float64(gasPrice) * multiplier) signerAddress := b.keys.GetOperatorAddress().String() - msg := types.NewMsgGasPriceVoter(signerAddress, chain.ChainId, gasPrice, supply, blockNum) + msg := types.NewMsgVoteGasPrice(signerAddress, chain.ChainId, gasPrice, supply, blockNum) authzMsg, authzSigner, err := b.WrapMessageWithAuthz(msg) if err != nil { @@ -130,11 +131,12 @@ func (b *ZetaCoreBridge) SetTSS(tssPubkey string, keyGenZetaHeight int64, status func (b *ZetaCoreBridge) CoreContextUpdater(appContext *appcontext.AppContext) { b.logger.Info().Msg("CoreContextUpdater started") ticker := time.NewTicker(time.Duration(appContext.Config().ConfigUpdateTicker) * time.Second) + sampledLogger := b.logger.Sample(&zerolog.BasicSampler{N: 10}) for { select { case <-ticker.C: b.logger.Debug().Msg("Running Updater") - err := b.UpdateZetaCoreContext(appContext.ZetaCoreContext(), false) + err := b.UpdateZetaCoreContext(appContext.ZetaCoreContext(), false, sampledLogger) if err != nil { b.logger.Err(err).Msg("CoreContextUpdater failed to update config") } @@ -172,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 { @@ -188,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) @@ -281,7 +283,7 @@ func (b *ZetaCoreBridge) MonitorVoteInboundTxResult(zetaTxHash string, retryGasL // PostVoteOutbound posts a vote on an observed outbound tx func (b *ZetaCoreBridge) PostVoteOutbound( - sendHash string, + cctxIndex string, outTxHash string, outBlockHeight uint64, outTxGasUsed uint64, @@ -296,7 +298,7 @@ func (b *ZetaCoreBridge) PostVoteOutbound( signerAddress := b.keys.GetOperatorAddress().String() msg := types.NewMsgVoteOnObservedOutboundTx( signerAddress, - sendHash, + cctxIndex, outTxHash, outBlockHeight, outTxGasUsed, diff --git a/zetaclient/zetabridge/tx_test.go b/zetaclient/zetabridge/tx_test.go index 20da71f1d2..4fd2ee19fb 100644 --- a/zetaclient/zetabridge/tx_test.go +++ b/zetaclient/zetabridge/tx_test.go @@ -13,12 +13,14 @@ import ( sdktypes "github.com/cosmos/cosmos-sdk/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" "github.com/zeta-chain/go-tss/blame" "github.com/zeta-chain/zetacore/pkg/chains" "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" @@ -204,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) { @@ -286,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) @@ -302,7 +314,7 @@ func TestZetaCoreBridge_UpdateZetaCoreContext(t *testing.T) { cfg := config.NewConfig() coreCtx := corecontext.NewZetaCoreContext(cfg) zetaBridgeBroadcast = ZetaBridgeBroadcastTest - err := zetabridge.UpdateZetaCoreContext(coreCtx, false) + err := zetabridge.UpdateZetaCoreContext(coreCtx, false, zerolog.Logger{}) require.NoError(t, err) }) } @@ -329,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()) @@ -339,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 0de3f994b0..3899d51d82 100644 --- a/zetaclient/zetabridge/zetacore_bridge.go +++ b/zetaclient/zetabridge/zetacore_bridge.go @@ -197,7 +197,7 @@ func (b *ZetaCoreBridge) GetKeys() *keys.Keys { // UpdateZetaCoreContext updates core context // zetacore stores core context for all clients -func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCoreContext, init bool) error { +func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCoreContext, init bool, sampledLogger zerolog.Logger) error { bn, err := b.GetZetaBlockHeight() if err != nil { return err @@ -222,7 +222,6 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore var newBTCParams *observertypes.ChainParams // check and update chain params for each chain - sampledLogger := b.logger.Sample(&zerolog.BasicSampler{N: 10}) for _, chainParam := range chainParams { if !chainParam.GetIsSupported() { sampledLogger.Info().Msgf("Chain %d is not supported yet", chainParam.ChainId) @@ -267,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.go b/zetaclient/zetacore_observer.go index 415b5d5d21..48771bc9bc 100644 --- a/zetaclient/zetacore_observer.go +++ b/zetaclient/zetacore_observer.go @@ -218,9 +218,9 @@ func (co *CoreObserver) scheduleCctxEVM( } // try confirming the outtx - included, _, err := ob.IsSendOutTxProcessed(cctx, co.logger.ZetaChainWatcher) + included, _, err := ob.IsOutboundProcessed(cctx, co.logger.ZetaChainWatcher) if err != nil { - co.logger.ZetaChainWatcher.Error().Err(err).Msgf("scheduleCctxEVM: IsSendOutTxProcessed faild for chain %d nonce %d", chainID, nonce) + co.logger.ZetaChainWatcher.Error().Err(err).Msgf("scheduleCctxEVM: IsOutboundProcessed faild for chain %d nonce %d", chainID, nonce) continue } if included { @@ -298,9 +298,9 @@ func (co *CoreObserver) scheduleCctxBTC( continue } // try confirming the outtx - included, confirmed, err := btcClient.IsSendOutTxProcessed(cctx, co.logger.ZetaChainWatcher) + included, confirmed, err := btcClient.IsOutboundProcessed(cctx, co.logger.ZetaChainWatcher) if err != nil { - co.logger.ZetaChainWatcher.Error().Err(err).Msgf("scheduleCctxBTC: IsSendOutTxProcessed faild for chain %d nonce %d", chainID, nonce) + co.logger.ZetaChainWatcher.Error().Err(err).Msgf("scheduleCctxBTC: IsOutboundProcessed faild for chain %d nonce %d", chainID, nonce) continue } if included || confirmed { 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{}, )