From 62f984999fc956f4441878a817e0eaaca8e1e742 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 13 Feb 2024 14:59:19 -0500 Subject: [PATCH 1/3] feat(`crosschain`): refund aborted amount (#1728) --- Dockerfile-versioned-source | 2 +- Makefile | 2 +- app/setup_handlers.go | 4 +- changelog.md | 4 + .../smoketest/smoketests/smoketests.go | 2 + .../smoketest/smoketests/test_erc20_refund.go | 26 +- .../smoketest/txserver/zeta_tx_server.go | 5 + docs/cli/zetacored/zetacored_tx_crosschain.md | 1 + .../zetacored_tx_crosschain_refund-aborted.md | 52 ++ docs/openapi/openapi.swagger.yaml | 6 +- docs/spec/crosschain/messages.md | 16 + proto/crosschain/cross_chain_tx.proto | 3 +- proto/crosschain/tx.proto | 9 + testutil/sample/crosschain.go | 7 +- typescript/crosschain/cross_chain_tx_pb.d.ts | 7 +- typescript/crosschain/tx_pb.d.ts | 55 ++ x/crosschain/client/cli/cli_refund_aborted.go | 31 + x/crosschain/client/cli/tx.go | 1 + x/crosschain/keeper/abci_test.go | 17 +- x/crosschain/keeper/cctx.go | 3 +- x/crosschain/keeper/cctx_utils.go | 53 +- x/crosschain/keeper/cctx_utils_test.go | 169 ++--- x/crosschain/keeper/grpc_query_cctx_test.go | 4 +- x/crosschain/keeper/migrator.go | 6 + .../msg_server_abort_stuck_cctx_test.go | 18 +- .../keeper/msg_server_refund_aborted_tx.go | 98 +++ .../msg_server_refund_aborted_tx_test.go | 424 ++++++++++++ .../keeper/msg_server_update_tss_test.go | 12 +- .../keeper/msg_server_vote_inbound_tx.go | 16 - x/crosschain/keeper/refund.go | 105 +++ x/crosschain/keeper/refund_test.go | 315 +++++++++ x/crosschain/keeper/utils_test.go | 9 + x/crosschain/keeper/zeta_accounting.go | 13 + x/crosschain/keeper/zeta_accounting_test.go | 40 ++ x/crosschain/migrations/v5/migrate.go | 90 +++ x/crosschain/migrations/v5/migrate_test.go | 147 +++++ x/crosschain/module.go | 3 + x/crosschain/types/cross_chain_tx.pb.go | 164 +++-- x/crosschain/types/errors.go | 77 ++- x/crosschain/types/message_refund_aborted.go | 55 ++ .../types/message_refund_aborted_test.go | 36 + x/crosschain/types/status.go | 6 + x/crosschain/types/status_test.go | 25 + x/crosschain/types/tx.pb.go | 614 +++++++++++++++--- 44 files changed, 2339 insertions(+), 413 deletions(-) create mode 100644 docs/cli/zetacored/zetacored_tx_crosschain_refund-aborted.md create mode 100644 x/crosschain/client/cli/cli_refund_aborted.go create mode 100644 x/crosschain/keeper/msg_server_refund_aborted_tx.go create mode 100644 x/crosschain/keeper/msg_server_refund_aborted_tx_test.go create mode 100644 x/crosschain/keeper/refund.go create mode 100644 x/crosschain/keeper/refund_test.go create mode 100644 x/crosschain/migrations/v5/migrate.go create mode 100644 x/crosschain/migrations/v5/migrate_test.go create mode 100644 x/crosschain/types/message_refund_aborted.go create mode 100644 x/crosschain/types/message_refund_aborted_test.go create mode 100644 x/crosschain/types/status_test.go diff --git a/Dockerfile-versioned-source b/Dockerfile-versioned-source index 67c4ac4273..528cf3d525 100644 --- a/Dockerfile-versioned-source +++ b/Dockerfile-versioned-source @@ -17,7 +17,7 @@ WORKDIR /go/delivery/zeta-node RUN mkdir -p $GOPATH/bin/old RUN mkdir -p $GOPATH/bin/new -ENV NEW_VERSION=v12.1.0 +ENV NEW_VERSION=v12.3.0 # Build new release from the current source COPY go.mod /go/delivery/zeta-node/ diff --git a/Makefile b/Makefile index 03bb656d1d..0c00dd615a 100644 --- a/Makefile +++ b/Makefile @@ -240,7 +240,7 @@ stateful-upgrade: stateful-upgrade-source: @echo "--> Starting stateful smoketest" - $(DOCKER) build --build-arg old_version=v12.0.0 -t zetanode -f ./Dockerfile-versioned-source . + $(DOCKER) build --build-arg old_version=v12.2.1 -t zetanode -f ./Dockerfile-versioned-source . $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile-upgrade.fastbuild . cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml up -d diff --git a/app/setup_handlers.go b/app/setup_handlers.go index 0ed66638d1..da037ba1a2 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -5,9 +5,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/upgrade/types" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) -const releaseVersion = "v12.2.0" +const releaseVersion = "v12.3.0" func SetupHandlers(app *App) { app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) { @@ -16,6 +17,7 @@ func SetupHandlers(app *App) { for m, mb := range app.mm.Modules { vm[m] = mb.ConsensusVersion() } + VersionMigrator{v: vm}.TriggerMigration(crosschaintypes.ModuleName) return app.mm.RunMigrations(ctx, app.configurator, vm) }) diff --git a/changelog.md b/changelog.md index 0119174c74..cf21cc81ba 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,10 @@ * [1731](https://github.com/zeta-chain/node/pull/1731) added doc for hotkey and tss key-share password prompts. +### Features + +*[1728] (https://github.com/zeta-chain/node/pull/1728) - allow aborted transactions to be refunded by minting tokens to zEvm. + ### Refactor * [1630](https://github.com/zeta-chain/node/pull/1630) added password prompts for hotkey and tss keyshare in zetaclient diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/smoketests.go b/contrib/localnet/orchestrator/smoketest/smoketests/smoketests.go index 92d4c97030..300ec2e866 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/smoketests.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/smoketests.go @@ -2,6 +2,8 @@ package smoketests import "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner" +// TODO : Add smoke test for abort refund +// https://github.com/zeta-chain/node/issues/1745 const ( TestContextUpgradeName = "context_upgrade" TestDepositAndCallRefundName = "deposit_and_call_refund" diff --git a/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_refund.go b/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_refund.go index dcfc86acc1..e7728dda15 100644 --- a/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_refund.go +++ b/contrib/localnet/orchestrator/smoketest/smoketests/test_erc20_refund.go @@ -10,11 +10,11 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner" "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/utils" - "github.com/zeta-chain/zetacore/x/crosschain/types" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) func TestERC20DepositAndCallRefund(sm *runner.SmokeTestRunner) { - // Get the initial balance of the deployer + //Get the initial balance of the deployer initialBal, err := sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, sm.DeployerAddress) if err != nil { panic(err) @@ -33,11 +33,25 @@ func TestERC20DepositAndCallRefund(sm *runner.SmokeTestRunner) { // There is no liquidity pool, therefore the cctx should abort cctx := utils.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger, sm.CctxTimeout) sm.Logger.CCTX(*cctx, "deposit") - if cctx.CctxStatus.Status != types.CctxStatus_Aborted { + if cctx.CctxStatus.Status != crosschaintypes.CctxStatus_Aborted { panic(fmt.Sprintf("expected cctx status to be Aborted; got %s", cctx.CctxStatus.Status)) } - // Check that the erc20 in the aborted cctx was refunded on ZetaChain + if cctx.CctxStatus.IsAbortRefunded != false { + panic(fmt.Sprintf("expected cctx status to be not refunded; got %t", cctx.CctxStatus.IsAbortRefunded)) + } + + sm.Logger.Info("Refunding the cctx via admin") + msg := crosschaintypes.NewMsgRefundAbortedCCTX( + sm.ZetaTxServer.GetAccountAddress(0), + cctx.Index, + sm.DeployerAddress.String()) + _, err = sm.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) + if err != nil { + panic(err) + } + + //Check that the erc20 in the aborted cctx was refunded on ZetaChain newBalance, err := sm.USDTZRC20.BalanceOf(&bind.CallOpts{}, sm.DeployerAddress) if err != nil { panic(err) @@ -46,7 +60,7 @@ func TestERC20DepositAndCallRefund(sm *runner.SmokeTestRunner) { if newBalance.Cmp(expectedBalance) != 0 { panic(fmt.Sprintf("expected balance to be %s after refund; got %s", expectedBalance.String(), newBalance.String())) } - sm.Logger.Info("CCTX has been aborted and the erc20 has been refunded on ZetaChain") + sm.Logger.Info("CCTX has been aborted on ZetaChain") // test refund when there is a liquidity pool sm.Logger.Info("Sending a deposit that should revert with a liquidity pool") @@ -75,7 +89,7 @@ func TestERC20DepositAndCallRefund(sm *runner.SmokeTestRunner) { cctx = utils.WaitCctxMinedByInTxHash(sm.Ctx, inTxHash, sm.CctxClient, sm.Logger, sm.CctxTimeout) // the revert tx creation will fail because the sender, used as the recipient, is not defined in the cctx - if cctx.CctxStatus.Status != types.CctxStatus_Reverted { + if cctx.CctxStatus.Status != crosschaintypes.CctxStatus_Reverted { panic(fmt.Sprintf( "expected cctx status to be PendingRevert; got %s, aborted message: %s", cctx.CctxStatus.Status, diff --git a/contrib/localnet/orchestrator/smoketest/txserver/zeta_tx_server.go b/contrib/localnet/orchestrator/smoketest/txserver/zeta_tx_server.go index d43cbd7fe6..ee63851a74 100644 --- a/contrib/localnet/orchestrator/smoketest/txserver/zeta_tx_server.go +++ b/contrib/localnet/orchestrator/smoketest/txserver/zeta_tx_server.go @@ -121,6 +121,11 @@ func (zts ZetaTxServer) GetAccountAddress(index int) string { return zts.address[index] } +func (zts ZetaTxServer) GetAllAccountAddress() []string { + return zts.address + +} + // GetAccountMnemonic returns the account name from the given index // returns empty string if index is out of bound, error should be handled by caller func (zts ZetaTxServer) GetAccountMnemonic(index int) string { diff --git a/docs/cli/zetacored/zetacored_tx_crosschain.md b/docs/cli/zetacored/zetacored_tx_crosschain.md index bb8a200308..8b66894327 100644 --- a/docs/cli/zetacored/zetacored_tx_crosschain.md +++ b/docs/cli/zetacored/zetacored_tx_crosschain.md @@ -34,6 +34,7 @@ zetacored tx crosschain [flags] * [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 diff --git a/docs/cli/zetacored/zetacored_tx_crosschain_refund-aborted.md b/docs/cli/zetacored/zetacored_tx_crosschain_refund-aborted.md new file mode 100644 index 0000000000..515d85dc32 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_crosschain_refund-aborted.md @@ -0,0 +1,52 @@ +# tx crosschain refund-aborted + +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 refund-aborted [cctx-index] [refund-address] [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 refund-aborted + --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 crosschain](zetacored_tx_crosschain.md) - crosschain transactions subcommands + diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index f9a8b1cd43..a2108f73b1 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -53588,7 +53588,7 @@ definitions: - OutboundMined: the corresponding outbound tx is mined - PendingRevert: outbound cannot succeed; should revert inbound - Reverted: inbound reverted. - - Aborted: inbound tx error or invalid paramters and cannot revert; just abort + - Aborted: inbound tx error or invalid paramters and cannot revert; just abort. But the amount can be refunded to zetachain using and admin proposal crosschainCrossChainTx: type: object properties: @@ -53718,6 +53718,8 @@ definitions: type: object crosschainMsgMigrateTssFundsResponse: type: object + crosschainMsgRefundAbortedCCTXResponse: + type: object crosschainMsgRemoveFromOutTxTrackerResponse: type: object crosschainMsgUpdateTssAddressResponse: @@ -54717,6 +54719,8 @@ definitions: lastUpdate_timestamp: type: string format: int64 + isAbortRefunded: + type: boolean zetacoreemissionsParams: type: object properties: diff --git a/docs/spec/crosschain/messages.md b/docs/spec/crosschain/messages.md index 1659a95bf0..f69a931598 100644 --- a/docs/spec/crosschain/messages.md +++ b/docs/spec/crosschain/messages.md @@ -270,3 +270,19 @@ message MsgAbortStuckCCTX { } ``` +## MsgRefundAbortedCCTX + +RefundAbortedCCTX refunds the aborted CCTX. +It verifies if the CCTX is aborted and not refunded, and if the refund address is valid. +It refunds the amount to the refund address and sets the CCTX as refunded. +Refer to documentation for GetRefundAddress for the refund address logic. +Refer to documentation for GetAbortedAmount for the aborted amount logic. + +```proto +message MsgRefundAbortedCCTX { + string creator = 1; + string cctx_index = 2; + string refund_address = 3; +} +``` + diff --git a/proto/crosschain/cross_chain_tx.proto b/proto/crosschain/cross_chain_tx.proto index 28f9d92452..28aeab85db 100644 --- a/proto/crosschain/cross_chain_tx.proto +++ b/proto/crosschain/cross_chain_tx.proto @@ -13,7 +13,7 @@ enum CctxStatus { OutboundMined = 3; // the corresponding outbound tx is mined PendingRevert = 4; // outbound cannot succeed; should revert inbound Reverted = 5; // inbound reverted. - Aborted = 6; // inbound tx error or invalid paramters and cannot revert; just abort + Aborted = 6; // inbound tx error or invalid paramters and cannot revert; just abort. But the amount can be refunded to zetachain using and admin proposal } enum TxFinalizationStatus { @@ -77,6 +77,7 @@ message Status { CctxStatus status = 1; string status_message = 2; int64 lastUpdate_timestamp = 3; + bool isAbortRefunded = 4; } message CrossChainTx { diff --git a/proto/crosschain/tx.proto b/proto/crosschain/tx.proto index 3ccfba1911..5cee0f1f21 100644 --- a/proto/crosschain/tx.proto +++ b/proto/crosschain/tx.proto @@ -21,6 +21,7 @@ service Msg { rpc CreateTSSVoter(MsgCreateTSSVoter) returns (MsgCreateTSSVoterResponse); rpc AbortStuckCCTX(MsgAbortStuckCCTX) returns (MsgAbortStuckCCTXResponse); + rpc RefundAbortedCCTX(MsgRefundAbortedCCTX) returns (MsgRefundAbortedCCTXResponse); } message MsgCreateTSSVoter { @@ -162,3 +163,11 @@ message MsgAbortStuckCCTX { } message MsgAbortStuckCCTXResponse {} + +message MsgRefundAbortedCCTX { + string creator = 1; + string cctx_index = 2; + string refund_address = 3; // if not provided, the refund will be sent to the sender/txOrgin +} + +message MsgRefundAbortedCCTXResponse {} diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index 35082be7d1..b516100597 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -5,6 +5,7 @@ import ( "testing" "cosmossdk.io/math" + "github.com/ethereum/go-ethereum/crypto" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -75,12 +76,16 @@ func Status(t *testing.T, index string) *types.Status { } } +func GetCctxIndexFromString(index string) string { + return crypto.Keccak256Hash([]byte(index)).String() +} + func CrossChainTx(t *testing.T, index string) *types.CrossChainTx { r := newRandFromStringSeed(t, index) return &types.CrossChainTx{ Creator: AccAddress(), - Index: index, + Index: GetCctxIndexFromString(index), ZetaFees: math.NewUint(uint64(r.Int63())), RelayedMessage: StringRandom(r, 32), CctxStatus: Status(t, index), diff --git a/typescript/crosschain/cross_chain_tx_pb.d.ts b/typescript/crosschain/cross_chain_tx_pb.d.ts index d8216afcff..0157548d54 100644 --- a/typescript/crosschain/cross_chain_tx_pb.d.ts +++ b/typescript/crosschain/cross_chain_tx_pb.d.ts @@ -47,7 +47,7 @@ export declare enum CctxStatus { Reverted = 5, /** - * inbound tx error or invalid paramters and cannot revert; just abort + * inbound tx error or invalid paramters and cannot revert; just abort. But the amount can be refunded to zetachain using and admin proposal * * @generated from enum value: Aborted = 6; */ @@ -302,6 +302,11 @@ export declare class Status extends Message { */ lastUpdateTimestamp: bigint; + /** + * @generated from field: bool isAbortRefunded = 4; + */ + isAbortRefunded: boolean; + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; diff --git a/typescript/crosschain/tx_pb.d.ts b/typescript/crosschain/tx_pb.d.ts index b96408964c..2371a9405c 100644 --- a/typescript/crosschain/tx_pb.d.ts +++ b/typescript/crosschain/tx_pb.d.ts @@ -778,3 +778,58 @@ export declare class MsgAbortStuckCCTXResponse extends Message | undefined, b: MsgAbortStuckCCTXResponse | PlainMessage | undefined): boolean; } +/** + * @generated from message zetachain.zetacore.crosschain.MsgRefundAbortedCCTX + */ +export declare class MsgRefundAbortedCCTX extends Message { + /** + * @generated from field: string creator = 1; + */ + creator: string; + + /** + * @generated from field: string cctx_index = 2; + */ + cctxIndex: string; + + /** + * if not provided, the refund will be sent to the sender/txOrgin + * + * @generated from field: string refund_address = 3; + */ + refundAddress: string; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.MsgRefundAbortedCCTX"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgRefundAbortedCCTX; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgRefundAbortedCCTX; + + static fromJsonString(jsonString: string, options?: Partial): MsgRefundAbortedCCTX; + + static equals(a: MsgRefundAbortedCCTX | PlainMessage | undefined, b: MsgRefundAbortedCCTX | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.crosschain.MsgRefundAbortedCCTXResponse + */ +export declare class MsgRefundAbortedCCTXResponse extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.crosschain.MsgRefundAbortedCCTXResponse"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgRefundAbortedCCTXResponse; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgRefundAbortedCCTXResponse; + + static fromJsonString(jsonString: string, options?: Partial): MsgRefundAbortedCCTXResponse; + + static equals(a: MsgRefundAbortedCCTXResponse | PlainMessage | undefined, b: MsgRefundAbortedCCTXResponse | PlainMessage | undefined): boolean; +} + diff --git a/x/crosschain/client/cli/cli_refund_aborted.go b/x/crosschain/client/cli/cli_refund_aborted.go new file mode 100644 index 0000000000..12930dcbf0 --- /dev/null +++ b/x/crosschain/client/cli/cli_refund_aborted.go @@ -0,0 +1,31 @@ +package cli + +import ( + "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/crosschain/types" +) + +func CmdRefundAborted() *cobra.Command { + cmd := &cobra.Command{ + Use: "refund-aborted [cctx-index] [refund-address]", + Short: `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.`, + Args: cobra.MaximumNArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + msg := types.NewMsgRefundAbortedCCTX(clientCtx.GetFromAddress().String(), args[0], args[1]) + err = msg.ValidateBasic() + if err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + flags.AddTxFlagsToCmd(cmd) + return cmd +} diff --git a/x/crosschain/client/cli/tx.go b/x/crosschain/client/cli/tx.go index d8e6b3bc0e..f5668fae44 100644 --- a/x/crosschain/client/cli/tx.go +++ b/x/crosschain/client/cli/tx.go @@ -31,6 +31,7 @@ func GetTxCmd() *cobra.Command { CmdMigrateTssFunds(), CmdAddToInTxTracker(), CmdAbortStuckCCTX(), + CmdRefundAborted(), ) return cmd diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index ea46e70dc4..4487d7dcec 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -58,7 +58,7 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { createCctxWithNonceRange(t, ctx, *k, 40, 45, common.ZetaChainMainnet().ChainId, tss, zk) // set a cctx where the update function should fail to test that the next cctx are not updated but the next chains are - failMap["1-12"] = struct{}{} + failMap[sample.GetCctxIndexFromString("1-12")] = struct{}{} // test that the default crosschain flags are used when not set and the epoch length is not reached ctx = ctx.WithBlockHeight(observertypes.DefaultCrosschainFlags().GasPriceIncreaseFlags.EpochLength + 1) @@ -84,7 +84,6 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { require.Equal(t, customFlags, flags) // test that cctx are iterated and updated when the epoch length is reached - ctx = ctx.WithBlockHeight(observertypes.DefaultCrosschainFlags().GasPriceIncreaseFlags.EpochLength * 2) cctxCount, flags = k.IterateAndUpdateCctxGasPrice(ctx, supportedChains, updateFunc) @@ -94,14 +93,14 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { // check that the update function was called with the cctx index require.Equal(t, 7, len(updateFuncMap)) - require.Contains(t, updateFuncMap, "1-10") - require.Contains(t, updateFuncMap, "1-11") + require.Contains(t, updateFuncMap, sample.GetCctxIndexFromString("1-10")) + require.Contains(t, updateFuncMap, sample.GetCctxIndexFromString("1-11")) - require.Contains(t, updateFuncMap, "56-30") - require.Contains(t, updateFuncMap, "56-31") - require.Contains(t, updateFuncMap, "56-32") - require.Contains(t, updateFuncMap, "56-33") - require.Contains(t, updateFuncMap, "56-34") + require.Contains(t, updateFuncMap, sample.GetCctxIndexFromString("56-30")) + require.Contains(t, updateFuncMap, sample.GetCctxIndexFromString("56-31")) + require.Contains(t, updateFuncMap, sample.GetCctxIndexFromString("56-32")) + require.Contains(t, updateFuncMap, sample.GetCctxIndexFromString("56-33")) + require.Contains(t, updateFuncMap, sample.GetCctxIndexFromString("56-34")) } func TestCheckAndUpdateCctxGasPrice(t *testing.T) { diff --git a/x/crosschain/keeper/cctx.go b/x/crosschain/keeper/cctx.go index e3a2a06f71..7dad9f4197 100644 --- a/x/crosschain/keeper/cctx.go +++ b/x/crosschain/keeper/cctx.go @@ -49,7 +49,7 @@ func (k Keeper) SetCctxAndNonceToCctxAndInTxHashToCctx(ctx sdk.Context, cctx typ }) } if cctx.CctxStatus.Status == types.CctxStatus_Aborted && cctx.GetCurrentOutTxParam().CoinType == common.CoinType_Zeta { - k.AddZetaAbortedAmount(ctx, cctx.GetCurrentOutTxParam().Amount) + k.AddZetaAbortedAmount(ctx, GetAbortedAmount(cctx)) } } @@ -133,6 +133,7 @@ func (k Keeper) CreateNewCCTX(ctx sdk.Context, msg *types.MsgVoteOnObservedInbou Status: s, StatusMessage: "", LastUpdateTimestamp: ctx.BlockHeader().Time.Unix(), + IsAbortRefunded: false, } newCctx := types.CrossChainTx{ Creator: msg.Creator, diff --git a/x/crosschain/keeper/cctx_utils.go b/x/crosschain/keeper/cctx_utils.go index 7b43123cbe..8c2edd5013 100644 --- a/x/crosschain/keeper/cctx_utils.go +++ b/x/crosschain/keeper/cctx_utils.go @@ -4,7 +4,7 @@ import ( "fmt" cosmoserrors "cosmossdk.io/errors" - "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" "github.com/pkg/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -52,42 +52,6 @@ func (k Keeper) UpdateNonce(ctx sdk.Context, receiveChainID int64, cctx *types.C return nil } -// RefundAmountOnZetaChain refunds the amount of the cctx on ZetaChain in case of aborted cctx -// NOTE: GetCurrentOutTxParam should contain the last up to date cctx amount -func (k Keeper) RefundAmountOnZetaChain(ctx sdk.Context, cctx types.CrossChainTx, inputAmount math.Uint) error { - // preliminary checks - if cctx.InboundTxParams.CoinType != common.CoinType_ERC20 { - return errors.New("unsupported coin type for refund on ZetaChain") - } - if !common.IsEVMChain(cctx.InboundTxParams.SenderChainId) { - return errors.New("only EVM chains are supported for refund on ZetaChain") - } - sender := ethcommon.HexToAddress(cctx.InboundTxParams.Sender) - if sender == (ethcommon.Address{}) { - return errors.New("invalid sender address") - } - if inputAmount.IsNil() || inputAmount.IsZero() { - return errors.New("no amount to refund") - } - - // get address of the zrc20 - fc, found := k.fungibleKeeper.GetForeignCoinFromAsset(ctx, cctx.InboundTxParams.Asset, cctx.InboundTxParams.SenderChainId) - if !found { - return fmt.Errorf("asset %s zrc not found", cctx.InboundTxParams.Asset) - } - zrc20 := ethcommon.HexToAddress(fc.Zrc20ContractAddress) - if zrc20 == (ethcommon.Address{}) { - return fmt.Errorf("asset %s invalid zrc address", cctx.InboundTxParams.Asset) - } - - // deposit the amount to the sender - if _, err := k.fungibleKeeper.DepositZRC20(ctx, zrc20, sender, inputAmount.BigInt()); err != nil { - return errors.New("failed to deposit zrc20 on ZetaChain" + err.Error()) - } - - return nil -} - // GetRevertGasLimit returns the gas limit for the revert transaction in a CCTX // It returns 0 if there is no error but the gas limit can't be determined from the CCTX data func (k Keeper) GetRevertGasLimit(ctx sdk.Context, cctx types.CrossChainTx) (uint64, error) { @@ -126,3 +90,18 @@ func IsPending(cctx types.CrossChainTx) bool { // pending inbound is not considered a "pending" state because it has not reached consensus yet return cctx.CctxStatus.Status == types.CctxStatus_PendingOutbound || cctx.CctxStatus.Status == types.CctxStatus_PendingRevert } + +// GetAbortedAmount returns the amount to refund for a given CCTX . +// If the CCTX has an outbound transaction, it returns the amount of the outbound transaction. +// If OutTxParams is nil or the amount is zero, it returns the amount of the inbound transaction. +// This is because there might be a case where the transaction is set to be aborted before paying gas or creating an outbound transaction.In such a situation we can refund the entire amount that has been locked in connector or TSS +func GetAbortedAmount(cctx types.CrossChainTx) sdkmath.Uint { + if cctx.OutboundTxParams != nil && !cctx.GetCurrentOutTxParam().Amount.IsZero() { + return cctx.GetCurrentOutTxParam().Amount + } + if cctx.InboundTxParams != nil { + return cctx.InboundTxParams.Amount + } + + return sdkmath.ZeroUint() +} diff --git a/x/crosschain/keeper/cctx_utils_test.go b/x/crosschain/keeper/cctx_utils_test.go index 2d122bce7a..319ef35a54 100644 --- a/x/crosschain/keeper/cctx_utils_test.go +++ b/x/crosschain/keeper/cctx_utils_test.go @@ -4,142 +4,16 @@ import ( "math/big" "testing" - "cosmossdk.io/math" - + sdkmath "cosmossdk.io/math" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" + crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" ) -func TestKeeper_RefundAmountOnZetaChain(t *testing.T) { - t.Run("should refund amount on zeta chain", func(t *testing.T) { - k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) - k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - asset := sample.EthAddress().String() - sender := sample.EthAddress() - chainID := getValidEthChainID(t) - - // deploy zrc20 - deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) - zrc20Addr := deployZRC20( - t, - ctx, - zk.FungibleKeeper, - sdkk.EvmKeeper, - chainID, - "bar", - asset, - "bar", - ) - - err := k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_ERC20, - SenderChainId: chainID, - Sender: sender.String(), - Asset: asset, - }}, - math.NewUint(42), - ) - require.NoError(t, err) - - // check amount deposited in balance - balance, err := zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20Addr, sender) - require.NoError(t, err) - require.Equal(t, uint64(42), balance.Uint64()) - - // can refund again - err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_ERC20, - SenderChainId: chainID, - Sender: sender.String(), - Asset: asset, - }}, - math.NewUint(42), - ) - require.NoError(t, err) - balance, err = zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20Addr, sender) - require.NoError(t, err) - require.Equal(t, uint64(84), balance.Uint64()) - }) - - t.Run("should fail with invalid cctx", func(t *testing.T) { - k, ctx, _, _ := keepertest.CrosschainKeeper(t) - - err := k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_Zeta, - }}, - math.NewUint(42), - ) - require.ErrorContains(t, err, "unsupported coin type") - - err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_Gas, - }}, - math.NewUint(42), - ) - require.ErrorContains(t, err, "unsupported coin type") - - err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_ERC20, - SenderChainId: 999999, - }}, - math.NewUint(42), - ) - require.ErrorContains(t, err, "only EVM chains are supported") - - err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_ERC20, - SenderChainId: getValidEthChainID(t), - Sender: "invalid", - }}, - math.NewUint(42), - ) - require.ErrorContains(t, err, "invalid sender address") - - err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_ERC20, - SenderChainId: getValidEthChainID(t), - Sender: sample.EthAddress().String(), - }, - }, - math.Uint{}, - ) - require.ErrorContains(t, err, "no amount to refund") - - err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_ERC20, - SenderChainId: getValidEthChainID(t), - Sender: sample.EthAddress().String(), - }}, - math.ZeroUint(), - ) - require.ErrorContains(t, err, "no amount to refund") - - // the foreign coin has not been set - err = k.RefundAmountOnZetaChain(ctx, types.CrossChainTx{ - InboundTxParams: &types.InboundTxParams{ - CoinType: common.CoinType_ERC20, - SenderChainId: getValidEthChainID(t), - Sender: sample.EthAddress().String(), - Asset: sample.EthAddress().String(), - }}, - math.NewUint(42), - ) - require.ErrorContains(t, err, "zrc not found") - }) -} - func TestGetRevertGasLimit(t *testing.T) { t.Run("should return 0 if no inbound tx params", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) @@ -278,3 +152,42 @@ func TestGetRevertGasLimit(t *testing.T) { require.ErrorIs(t, err, fungibletypes.ErrContractCall) }) } + +func TestGetAbortedAmount(t *testing.T) { + amount := sdkmath.NewUint(100) + t.Run("should return the inbound amount if outbound not present", func(t *testing.T) { + cctx := types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + Amount: amount, + }, + } + a := crosschainkeeper.GetAbortedAmount(cctx) + require.Equal(t, amount, a) + }) + t.Run("should return the amount outbound amount", func(t *testing.T) { + cctx := types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + Amount: sdkmath.ZeroUint(), + }, + OutboundTxParams: []*types.OutboundTxParams{ + {Amount: amount}, + }, + } + a := crosschainkeeper.GetAbortedAmount(cctx) + require.Equal(t, amount, a) + }) + t.Run("should return the zero if outbound amount is not present and inbound is 0", func(t *testing.T) { + cctx := types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + Amount: sdkmath.ZeroUint(), + }, + } + a := crosschainkeeper.GetAbortedAmount(cctx) + require.Equal(t, sdkmath.ZeroUint(), a) + }) + t.Run("should return the zero if no amounts are present", func(t *testing.T) { + cctx := types.CrossChainTx{} + a := crosschainkeeper.GetAbortedAmount(cctx) + require.Equal(t, sdkmath.ZeroUint(), a) + }) +} diff --git a/x/crosschain/keeper/grpc_query_cctx_test.go b/x/crosschain/keeper/grpc_query_cctx_test.go index c326f41a42..6865d6d51e 100644 --- a/x/crosschain/keeper/grpc_query_cctx_test.go +++ b/x/crosschain/keeper/grpc_query_cctx_test.go @@ -135,12 +135,12 @@ func TestKeeper_CctxListPending(t *testing.T) { cctxs := createCctxWithNonceRange(t, ctx, *k, 1000, 2000, chainID, tss, zk) // set some cctxs as pending below nonce - cctx1, found := k.GetCrossChainTx(ctx, "1337-940") + cctx1, found := k.GetCrossChainTx(ctx, sample.GetCctxIndexFromString("1337-940")) require.True(t, found) cctx1.CctxStatus.Status = types.CctxStatus_PendingOutbound k.SetCrossChainTx(ctx, cctx1) - cctx2, found := k.GetCrossChainTx(ctx, "1337-955") + cctx2, found := k.GetCrossChainTx(ctx, sample.GetCctxIndexFromString("1337-955")) require.True(t, found) cctx2.CctxStatus.Status = types.CctxStatus_PendingOutbound k.SetCrossChainTx(ctx, cctx2) diff --git a/x/crosschain/keeper/migrator.go b/x/crosschain/keeper/migrator.go index cfdc1bba94..4de64140c8 100644 --- a/x/crosschain/keeper/migrator.go +++ b/x/crosschain/keeper/migrator.go @@ -5,6 +5,7 @@ import ( v2 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v2" v3 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v3" v4 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v4" + v5 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v5" ) // Migrator is a struct for handling in-place store migrations. @@ -33,3 +34,8 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error { func (m Migrator) Migrate3to4(ctx sdk.Context) error { return v4.MigrateStore(ctx, m.crossChainKeeper.zetaObserverKeeper, m.crossChainKeeper) } + +// Migrate4to5 migrates the store from consensus version 4 to 5 +func (m Migrator) Migrate4to5(ctx sdk.Context) error { + return v5.MigrateStore(ctx, m.crossChainKeeper, m.crossChainKeeper.zetaObserverKeeper) +} diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go index f9b7c380e0..fadda6b74f 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go @@ -29,11 +29,11 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { // abort the cctx _, err := msgServer.AbortStuckCCTX(ctx, &crosschaintypes.MsgAbortStuckCCTX{ Creator: admin, - CctxIndex: "cctx_index", + CctxIndex: sample.GetCctxIndexFromString("cctx_index"), }) require.NoError(t, err) - cctxFound, found := k.GetCrossChainTx(ctx, "cctx_index") + cctxFound, found := k.GetCrossChainTx(ctx, sample.GetCctxIndexFromString("cctx_index")) require.True(t, found) require.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) require.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) @@ -56,11 +56,11 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { // abort the cctx _, err := msgServer.AbortStuckCCTX(ctx, &crosschaintypes.MsgAbortStuckCCTX{ Creator: admin, - CctxIndex: "cctx_index", + CctxIndex: sample.GetCctxIndexFromString("cctx_index"), }) require.NoError(t, err) - cctxFound, found := k.GetCrossChainTx(ctx, "cctx_index") + cctxFound, found := k.GetCrossChainTx(ctx, sample.GetCctxIndexFromString("cctx_index")) require.True(t, found) require.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) require.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) @@ -83,11 +83,11 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { // abort the cctx _, err := msgServer.AbortStuckCCTX(ctx, &crosschaintypes.MsgAbortStuckCCTX{ Creator: admin, - CctxIndex: "cctx_index", + CctxIndex: sample.GetCctxIndexFromString("cctx_index"), }) require.NoError(t, err) - cctxFound, found := k.GetCrossChainTx(ctx, "cctx_index") + cctxFound, found := k.GetCrossChainTx(ctx, sample.GetCctxIndexFromString("cctx_index")) require.True(t, found) require.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status) require.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage) @@ -108,7 +108,7 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { // abort the cctx _, err := msgServer.AbortStuckCCTX(ctx, &crosschaintypes.MsgAbortStuckCCTX{ Creator: sample.AccAddress(), - CctxIndex: "cctx_index", + CctxIndex: sample.GetCctxIndexFromString("cctx_index"), }) require.ErrorIs(t, err, observertypes.ErrNotAuthorized) }) @@ -122,7 +122,7 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { // abort the cctx _, err := msgServer.AbortStuckCCTX(ctx, &crosschaintypes.MsgAbortStuckCCTX{ Creator: admin, - CctxIndex: "cctx_index", + CctxIndex: sample.GetCctxIndexFromString("cctx_index"), }) require.ErrorIs(t, err, crosschaintypes.ErrCannotFindCctx) }) @@ -144,7 +144,7 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) { // abort the cctx _, err := msgServer.AbortStuckCCTX(ctx, &crosschaintypes.MsgAbortStuckCCTX{ Creator: admin, - CctxIndex: "cctx_index", + CctxIndex: sample.GetCctxIndexFromString("cctx_index"), }) require.ErrorIs(t, err, crosschaintypes.ErrStatusNotPending) }) diff --git a/x/crosschain/keeper/msg_server_refund_aborted_tx.go b/x/crosschain/keeper/msg_server_refund_aborted_tx.go new file mode 100644 index 0000000000..b011c35163 --- /dev/null +++ b/x/crosschain/keeper/msg_server_refund_aborted_tx.go @@ -0,0 +1,98 @@ +package keeper + +import ( + "errors" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/crosschain/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" + "golang.org/x/net/context" +) + +// RefundAbortedCCTX refunds the aborted CCTX. +// It verifies if the CCTX is aborted and not refunded, and if the refund address is valid. +// It refunds the amount to the refund address and sets the CCTX as refunded. +// Refer to documentation for GetRefundAddress for the refund address logic. +// Refer to documentation for GetAbortedAmount for the aborted amount logic. +func (k msgServer) RefundAbortedCCTX(goCtx context.Context, msg *types.MsgRefundAbortedCCTX) (*types.MsgRefundAbortedCCTXResponse, error) { + + ctx := sdk.UnwrapSDKContext(goCtx) + + // check if authorized + if msg.Creator != k.zetaObserverKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_group2) { + return nil, observertypes.ErrNotAuthorized + } + + // check if the cctx exists + cctx, found := k.GetCrossChainTx(ctx, msg.CctxIndex) + if !found { + return nil, types.ErrCannotFindCctx + } + + // check if the cctx is aborted + if cctx.CctxStatus.Status != types.CctxStatus_Aborted { + return nil, errorsmod.Wrap(types.ErrInvalidStatus, "CCTX is not aborted") + } + // check if the cctx is not refunded + if cctx.CctxStatus.IsAbortRefunded { + return nil, errorsmod.Wrap(types.ErrUnableProcessRefund, "CCTX is already refunded") + } + + // Check if aborted amount is available to maintain zeta accounting + if cctx.InboundTxParams.CoinType == common.CoinType_Zeta { + err := k.RemoveZetaAbortedAmount(ctx, GetAbortedAmount(cctx)) + // if the zeta accounting is not found, it means the zeta accounting is not set yet and the refund should not be processed + if errors.Is(err, types.ErrUnableToFindZetaAccounting) { + return nil, errorsmod.Wrap(types.ErrUnableProcessRefund, err.Error()) + } + // if the zeta accounting is found but the amount is insufficient, it means the refund can be processed but the zeta accounting is not maintained properly + if errors.Is(err, types.ErrInsufficientZetaAmount) { + ctx.Logger().Error("Zeta Accounting Error: ", err) + } + } + + refundAddress, err := GetRefundAddress(msg.RefundAddress) + if err != nil { + return nil, errorsmod.Wrap(types.ErrInvalidAddress, err.Error()) + } + // refund the amount + // use temporary context to avoid gas refunding issues and side effects + tmpCtx, commit := ctx.CacheContext() + err = k.RefundAbortedAmountOnZetaChain(tmpCtx, cctx, refundAddress) + if err != nil { + return nil, errorsmod.Wrap(types.ErrUnableProcessRefund, err.Error()) + } + commit() + + // set the cctx as refunded + cctx.CctxStatus.AbortRefunded(ctx.BlockTime().Unix()) + + k.SetCrossChainTx(ctx, cctx) + + return &types.MsgRefundAbortedCCTXResponse{}, nil +} + +// GetRefundAddress gets the proper refund address. +// For BTC sender chain the refund address is the one provided in the message in the RefundAddress field. +// For EVM chain with coin type ERC20 the refund address is the sender , but can be overridden by the RefundAddress field in the message. +// For EVM chain with coin type Zeta the refund address is the tx origin, but can be overridden by the RefundAddress field in the message. +// For EVM chain with coin type Gas the refund address is the tx origin, but can be overridden by the RefundAddress field in the message. +func GetRefundAddress(refundAddress string) (ethcommon.Address, error) { + // make sure a separate refund address is provided for a bitcoin chain as we cannot refund to tx origin or sender in this case + if refundAddress == "" { + return ethcommon.Address{}, errorsmod.Wrap(types.ErrInvalidAddress, "refund address is required") + } + if !ethcommon.IsHexAddress(refundAddress) { + return ethcommon.Address{}, errorsmod.Wrap(types.ErrInvalidAddress, "invalid refund address provided") + } + ethRefundAddress := ethcommon.HexToAddress(refundAddress) + // Double check to make sure the refund address is valid + if ethRefundAddress == (ethcommon.Address{}) { + return ethcommon.Address{}, errorsmod.Wrap(types.ErrInvalidAddress, "invalid refund address") + } + return ethRefundAddress, nil + +} diff --git a/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go b/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go new file mode 100644 index 0000000000..e42360975e --- /dev/null +++ b/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go @@ -0,0 +1,424 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/cmd/zetacored/config" + "github.com/zeta-chain/zetacore/common" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/keeper" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func Test_GetRefundAddress(t *testing.T) { + t.Run("should return refund address if provided coin-type gas", func(t *testing.T) { + validEthAddress := sample.EthAddress() + address, err := keeper.GetRefundAddress(validEthAddress.String()) + require.NoError(t, err) + require.Equal(t, validEthAddress, address) + }) + t.Run("should fail if refund address is empty", func(t *testing.T) { + address, err := keeper.GetRefundAddress("") + require.ErrorIs(t, crosschaintypes.ErrInvalidAddress, err) + assert.Equal(t, ethcommon.Address{}, address) + }) + t.Run("should fail if refund address is invalid", func(t *testing.T) { + address, err := keeper.GetRefundAddress("invalid-address") + require.ErrorIs(t, crosschaintypes.ErrInvalidAddress, err) + assert.Equal(t, ethcommon.Address{}, address) + }) + +} +func TestMsgServer_RefundAbortedCCTX(t *testing.T) { + t.Run("successfully refund tx for coin-type gas", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Gas + k.SetCrossChainTx(ctx, *cctx) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, cctx.InboundTxParams.SenderChainId, "foobar", "foobar") + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: cctx.InboundTxParams.Sender, + }) + require.NoError(t, err) + + refundAddress := ethcommon.HexToAddress(cctx.InboundTxParams.TxOrigin) + balance, err := zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20, refundAddress) + require.NoError(t, err) + require.Equal(t, cctx.GetCurrentOutTxParam().Amount.Uint64(), balance.Uint64()) + c, found := k.GetCrossChainTx(ctx, cctx.Index) + require.True(t, found) + require.True(t, c.CctxStatus.IsAbortRefunded) + }) + t.Run("successfully refund tx for coin-type zeta", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Zeta + k.SetCrossChainTx(ctx, *cctx) + k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.GetCurrentOutTxParam().Amount}) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: cctx.InboundTxParams.Sender, + }) + require.NoError(t, err) + + refundAddress := ethcommon.HexToAddress(cctx.InboundTxParams.TxOrigin) + refundAddressCosmos := sdk.AccAddress(refundAddress.Bytes()) + balance := sdkk.BankKeeper.GetBalance(ctx, refundAddressCosmos, config.BaseDenom) + require.Equal(t, cctx.GetCurrentOutTxParam().Amount.Uint64(), balance.Amount.Uint64()) + c, found := k.GetCrossChainTx(ctx, cctx.Index) + require.True(t, found) + require.True(t, c.CctxStatus.IsAbortRefunded) + }) + t.Run("successfully refund tx to inbound amount if outbound is not found for coin-type zeta", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Zeta + cctx.OutboundTxParams = nil + k.SetCrossChainTx(ctx, *cctx) + k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.GetCurrentOutTxParam().Amount}) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: cctx.InboundTxParams.Sender, + }) + require.NoError(t, err) + + refundAddress := ethcommon.HexToAddress(cctx.InboundTxParams.TxOrigin) + refundAddressCosmos := sdk.AccAddress(refundAddress.Bytes()) + balance := sdkk.BankKeeper.GetBalance(ctx, refundAddressCosmos, config.BaseDenom) + require.Equal(t, cctx.InboundTxParams.Amount.Uint64(), balance.Amount.Uint64()) + c, found := k.GetCrossChainTx(ctx, cctx.Index) + require.True(t, found) + require.True(t, c.CctxStatus.IsAbortRefunded) + }) + t.Run("successfully refund to optional refund address if provided", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Zeta + k.SetCrossChainTx(ctx, *cctx) + k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.InboundTxParams.Amount}) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + + refundAddress := sample.EthAddress() + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: refundAddress.String(), + }) + require.NoError(t, err) + + refundAddressCosmos := sdk.AccAddress(refundAddress.Bytes()) + balance := sdkk.BankKeeper.GetBalance(ctx, refundAddressCosmos, config.BaseDenom) + require.Equal(t, cctx.GetCurrentOutTxParam().Amount.Uint64(), balance.Amount.Uint64()) + c, found := k.GetCrossChainTx(ctx, cctx.Index) + require.True(t, found) + require.True(t, c.CctxStatus.IsAbortRefunded) + }) + t.Run("successfully refund tx for coin-type ERC20", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + asset := sample.EthAddress().String() + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_ERC20 + cctx.InboundTxParams.Asset = asset + k.SetCrossChainTx(ctx, *cctx) + // deploy zrc20 + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + zrc20Addr := deployZRC20( + t, + ctx, + zk.FungibleKeeper, + sdkk.EvmKeeper, + chainID, + "bar", + asset, + "bar", + ) + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: cctx.InboundTxParams.Sender, + }) + require.NoError(t, err) + + refundAddress := ethcommon.HexToAddress(cctx.InboundTxParams.Sender) + balance, err := zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20Addr, refundAddress) + require.NoError(t, err) + require.Equal(t, cctx.GetCurrentOutTxParam().Amount.Uint64(), balance.Uint64()) + c, found := k.GetCrossChainTx(ctx, cctx.Index) + require.True(t, found) + require.True(t, c.CctxStatus.IsAbortRefunded) + }) + t.Run("successfully refund tx for coin-type Gas with BTC sender", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidBtcChainID() + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Gas + k.SetCrossChainTx(ctx, *cctx) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, cctx.InboundTxParams.SenderChainId, "foobar", "foobar") + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: cctx.InboundTxParams.TxOrigin, + }) + require.NoError(t, err) + + refundAddress := ethcommon.HexToAddress(cctx.InboundTxParams.TxOrigin) + balance, err := zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20, refundAddress) + require.NoError(t, err) + require.Equal(t, cctx.GetCurrentOutTxParam().Amount.Uint64(), balance.Uint64()) + c, found := k.GetCrossChainTx(ctx, cctx.Index) + require.True(t, found) + require.True(t, c.CctxStatus.IsAbortRefunded) + }) + t.Run("fail refund if address provided is invalid", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Zeta + k.SetCrossChainTx(ctx, *cctx) + k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.InboundTxParams.Amount}) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: "invalid-address", + }) + require.ErrorContains(t, err, "invalid refund address") + }) + t.Run("fail refund if address provided is null ", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Zeta + k.SetCrossChainTx(ctx, *cctx) + k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.InboundTxParams.Amount}) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: "0x0000000000000000000000000000000000000000", + }) + require.ErrorContains(t, err, "invalid refund address") + }) + t.Run("fail refund if status is not aborted", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_PendingOutbound + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Gas + k.SetCrossChainTx(ctx, *cctx) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: "", + }) + require.ErrorContains(t, err, "CCTX is not aborted") + c, found := k.GetCrossChainTx(ctx, cctx.Index) + require.True(t, found) + require.False(t, c.CctxStatus.IsAbortRefunded) + }) + t.Run("fail refund if status cctx not found", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_PendingOutbound + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Gas + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: "", + }) + require.ErrorContains(t, err, "cannot find cctx") + }) + t.Run("fail refund if refund address not provided", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidBtcChainID() + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Gas + k.SetCrossChainTx(ctx, *cctx) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + _ = setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, cctx.InboundTxParams.SenderChainId, "foobar", "foobar") + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: "", + }) + require.ErrorContains(t, err, "refund address is required") + }) + t.Run("fail refund tx for coin-type Zeta if zeta accounting object is not present", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Zeta + k.SetCrossChainTx(ctx, *cctx) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: admin, + CctxIndex: cctx.Index, + RefundAddress: cctx.InboundTxParams.Sender, + }) + require.ErrorContains(t, err, "unable to find zeta accounting") + }) + t.Run("fail refund if non admin account is the creator", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + admin := sample.AccAddress() + chainID := getValidEthChainID(t) + setAdminPolicies(ctx, zk, admin) + msgServer := keeper.NewMsgServerImpl(*k) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + + cctx := sample.CrossChainTx(t, "sample-index") + cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted + cctx.CctxStatus.IsAbortRefunded = false + cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender + cctx.InboundTxParams.SenderChainId = chainID + cctx.InboundTxParams.CoinType = common.CoinType_Gas + k.SetCrossChainTx(ctx, *cctx) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + _ = setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, cctx.InboundTxParams.SenderChainId, "foobar", "foobar") + + _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ + Creator: sample.AccAddress(), + CctxIndex: cctx.Index, + RefundAddress: cctx.InboundTxParams.Sender, + }) + require.ErrorIs(t, err, observertypes.ErrNotAuthorized) + }) +} diff --git a/x/crosschain/keeper/msg_server_update_tss_test.go b/x/crosschain/keeper/msg_server_update_tss_test.go index 9d1207d427..fbc8567d5f 100644 --- a/x/crosschain/keeper/msg_server_update_tss_test.go +++ b/x/crosschain/keeper/msg_server_update_tss_test.go @@ -28,7 +28,7 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { index := chain.ChainName.String() + "_migration_tx_index" k.GetObserverKeeper().SetFundMigrator(ctx, types.TssFundMigratorInfo{ ChainId: chain.ChainId, - MigrationCctxIndex: index, + MigrationCctxIndex: sample.GetCctxIndexFromString(index), }) cctx := sample.CrossChainTx(t, index) cctx.CctxStatus.Status = crosschaintypes.CctxStatus_OutboundMined @@ -60,7 +60,7 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { index := chain.ChainName.String() + "_migration_tx_index" k.GetObserverKeeper().SetFundMigrator(ctx, types.TssFundMigratorInfo{ ChainId: chain.ChainId, - MigrationCctxIndex: index, + MigrationCctxIndex: sample.GetCctxIndexFromString(index), }) cctx := sample.CrossChainTx(t, index) cctx.CctxStatus.Status = crosschaintypes.CctxStatus_OutboundMined @@ -91,7 +91,7 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { index := chain.ChainName.String() + "_migration_tx_index" k.GetObserverKeeper().SetFundMigrator(ctx, types.TssFundMigratorInfo{ ChainId: chain.ChainId, - MigrationCctxIndex: index, + MigrationCctxIndex: sample.GetCctxIndexFromString(index), }) cctx := sample.CrossChainTx(t, index) cctx.CctxStatus.Status = crosschaintypes.CctxStatus_OutboundMined @@ -128,7 +128,7 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { index := chain.ChainName.String() + "_migration_tx_index" k.GetObserverKeeper().SetFundMigrator(ctx, types.TssFundMigratorInfo{ ChainId: chain.ChainId, - MigrationCctxIndex: index, + MigrationCctxIndex: sample.GetCctxIndexFromString(index), }) cctx := sample.CrossChainTx(t, index) cctx.CctxStatus.Status = crosschaintypes.CctxStatus_OutboundMined @@ -165,7 +165,7 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { index := chain.ChainName.String() + "_migration_tx_index" k.GetObserverKeeper().SetFundMigrator(ctx, types.TssFundMigratorInfo{ ChainId: chain.ChainId, - MigrationCctxIndex: index, + MigrationCctxIndex: sample.GetCctxIndexFromString(index), }) cctx := sample.CrossChainTx(t, index) cctx.CctxStatus.Status = crosschaintypes.CctxStatus_PendingOutbound @@ -202,7 +202,7 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { index := chain.ChainName.String() + "_migration_tx_index" k.GetObserverKeeper().SetFundMigrator(ctx, types.TssFundMigratorInfo{ ChainId: chain.ChainId, - MigrationCctxIndex: index, + MigrationCctxIndex: sample.GetCctxIndexFromString(index), }) } assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx.go b/x/crosschain/keeper/msg_server_vote_inbound_tx.go index 57c3e54041..ef98c85bf8 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx.go @@ -188,22 +188,6 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg return k.UpdateNonce(tmpCtx, chain.ChainId, &cctx) }() if err != nil { - // do not commit anything here as the CCTX should be aborted - - // gas payment for erc20 type might fail because no liquidity pool is defined to swap the zrc20 token into the gas token - // in this gas we should refund the sender on ZetaChain - if cctx.InboundTxParams.CoinType == common.CoinType_ERC20 { - - if err := k.RefundAmountOnZetaChain(ctx, cctx, cctx.InboundTxParams.Amount); err != nil { - // log the error - k.Logger(ctx).Error("failed to refund amount of aborted cctx on ZetaChain", - "error", err, - "sender", cctx.InboundTxParams.Sender, - "amount", cctx.InboundTxParams.Amount.String(), - ) - } - } - cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, err.Error()+" deposit revert message: "+revertMessage) return &types.MsgVoteOnObservedInboundTxResponse{}, nil } diff --git a/x/crosschain/keeper/refund.go b/x/crosschain/keeper/refund.go new file mode 100644 index 0000000000..9d10b7ce13 --- /dev/null +++ b/x/crosschain/keeper/refund.go @@ -0,0 +1,105 @@ +package keeper + +import ( + "errors" + "fmt" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func (k Keeper) RefundAbortedAmountOnZetaChain(ctx sdk.Context, cctx types.CrossChainTx, refundAddress ethcommon.Address) error { + coinType := cctx.InboundTxParams.CoinType + switch coinType { + case common.CoinType_Gas: + return k.RefundAmountOnZetaChainGas(ctx, cctx, refundAddress) + case common.CoinType_Zeta: + return k.RefundAmountOnZetaChainZeta(ctx, cctx, refundAddress) + case common.CoinType_ERC20: + return k.RefundAmountOnZetaChainERC20(ctx, cctx, refundAddress) + default: + return errors.New("unsupported coin type for refund on ZetaChain") + } +} + +// RefundAmountOnZetaChainGas refunds the amount of the cctx on ZetaChain in case of aborted cctx with cointype gas +func (k Keeper) RefundAmountOnZetaChainGas(ctx sdk.Context, cctx types.CrossChainTx, refundAddress ethcommon.Address) error { + // refund in gas token to refund address + // Refund the the amount was previously + refundAmount := GetAbortedAmount(cctx) + if refundAmount.IsNil() || refundAmount.IsZero() { + return errors.New("no amount to refund") + } + chainID := cctx.InboundTxParams.SenderChainId + // get the zrc20 contract address + fcSenderChain, found := k.fungibleKeeper.GetGasCoinForForeignCoin(ctx, chainID) + if !found { + return types.ErrForeignCoinNotFound + } + zrc20 := ethcommon.HexToAddress(fcSenderChain.Zrc20ContractAddress) + if zrc20 == (ethcommon.Address{}) { + return errorsmod.Wrapf(types.ErrForeignCoinNotFound, "zrc20 contract address not found for chain %d", chainID) + } + // deposit the amount to the tx origin instead of receiver as this is a refund + if _, err := k.fungibleKeeper.DepositZRC20(ctx, zrc20, refundAddress, refundAmount.BigInt()); err != nil { + return errors.New("failed to refund zeta on ZetaChain" + err.Error()) + } + return nil +} + +// RefundAmountOnZetaChainGas refunds the amount of the cctx on ZetaChain in case of aborted cctx with cointype zeta +func (k Keeper) RefundAmountOnZetaChainZeta(ctx sdk.Context, cctx types.CrossChainTx, refundAddress ethcommon.Address) error { + // if coin type is Zeta, handle this as a deposit ZETA to zEVM. + refundAmount := GetAbortedAmount(cctx) + chainID := cctx.InboundTxParams.SenderChainId + // check if chain is an EVM chain + if !common.IsEVMChain(chainID) { + return errors.New("only EVM chains are supported for refund when coin type is Zeta") + } + if cctx.InboundTxParams.Amount.IsNil() || cctx.InboundTxParams.Amount.IsZero() { + return errors.New("no amount to refund") + } + // deposit the amount to refund address + if err := k.fungibleKeeper.DepositCoinZeta(ctx, refundAddress, refundAmount.BigInt()); err != nil { + return errors.New("failed to refund zeta on ZetaChain" + err.Error()) + } + return nil +} + +// RefundAmountOnZetaChainERC20 refunds the amount of the cctx on ZetaChain in case of aborted cctx +// NOTE: GetCurrentOutTxParam should contain the last up to date cctx amount +// Refund address should already be validated before calling this function +func (k Keeper) RefundAmountOnZetaChainERC20(ctx sdk.Context, cctx types.CrossChainTx, refundAddress ethcommon.Address) error { + refundAmount := GetAbortedAmount(cctx) + // preliminary checks + if cctx.InboundTxParams.CoinType != common.CoinType_ERC20 { + return errors.New("unsupported coin type for refund on ZetaChain") + } + if !common.IsEVMChain(cctx.InboundTxParams.SenderChainId) { + return errors.New("only EVM chains are supported for refund on ZetaChain") + } + + if refundAmount.IsNil() || refundAmount.IsZero() { + return errors.New("no amount to refund") + } + + // get address of the zrc20 + fc, found := k.fungibleKeeper.GetForeignCoinFromAsset(ctx, cctx.InboundTxParams.Asset, cctx.InboundTxParams.SenderChainId) + if !found { + return fmt.Errorf("asset %s zrc not found", cctx.InboundTxParams.Asset) + } + zrc20 := ethcommon.HexToAddress(fc.Zrc20ContractAddress) + if zrc20 == (ethcommon.Address{}) { + return fmt.Errorf("asset %s invalid zrc address", cctx.InboundTxParams.Asset) + } + + // deposit the amount to the sender + if _, err := k.fungibleKeeper.DepositZRC20(ctx, zrc20, refundAddress, refundAmount.BigInt()); err != nil { + return errors.New("failed to deposit zrc20 on ZetaChain" + err.Error()) + } + + return nil +} diff --git a/x/crosschain/keeper/refund_test.go b/x/crosschain/keeper/refund_test.go new file mode 100644 index 0000000000..e9ecfd346f --- /dev/null +++ b/x/crosschain/keeper/refund_test.go @@ -0,0 +1,315 @@ +package keeper_test + +import ( + "fmt" + "testing" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/cmd/zetacored/config" + "github.com/zeta-chain/zetacore/common" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/types" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { + t.Run("should refund amount zrc20 gas on zeta chain", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + sender := sample.EthAddress() + chainID := getValidEthChainID(t) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") + + err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Gas, + SenderChainId: chainID, + Sender: sender.String(), + TxOrigin: sender.String(), + Amount: math.NewUint(20), + }, + OutboundTxParams: []*types.OutboundTxParams{{ + Amount: math.NewUint(42), + }}, + }, + sender, + ) + require.NoError(t, err) + balance, err := zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20, sender) + require.NoError(t, err) + require.Equal(t, uint64(42), balance.Uint64()) + }) + t.Run("should refund inbound amount zrc20 gas on zeta chain", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + sender := sample.EthAddress() + chainID := getValidEthChainID(t) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") + + err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Gas, + SenderChainId: chainID, + Sender: sender.String(), + TxOrigin: sender.String(), + Amount: math.NewUint(20), + }, + }, + sender, + ) + require.NoError(t, err) + balance, err := zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20, sender) + require.NoError(t, err) + require.Equal(t, uint64(20), balance.Uint64()) + }) + t.Run("failed refund zrc20 gas on zeta chain if gas coin not found", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + sender := sample.EthAddress() + chainID := getValidEthChainID(t) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Gas, + SenderChainId: chainID, + Sender: sender.String(), + TxOrigin: sender.String(), + Amount: math.NewUint(20), + }, + OutboundTxParams: []*types.OutboundTxParams{{ + Amount: math.NewUint(42), + }}, + }, + + sender, + ) + require.ErrorContains(t, err, types.ErrForeignCoinNotFound.Error()) + }) + t.Run("failed refund amount zrc20 gas on zeta chain if amount is 0", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + sender := sample.EthAddress() + chainID := getValidEthChainID(t) + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + _ = setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") + + err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Gas, + SenderChainId: chainID, + Sender: sender.String(), + TxOrigin: sender.String(), + Amount: math.ZeroUint(), + }, + OutboundTxParams: []*types.OutboundTxParams{{ + Amount: math.ZeroUint(), + }}, + }, + sender, + ) + require.ErrorContains(t, err, "no amount to refund") + }) + +} + +func TestKeeper_RefundAmountOnZetaChainZeta(t *testing.T) { + t.Run("should refund amount on zeta chain", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.CrosschainKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + sender := sample.EthAddress() + chainID := getValidEthChainID(t) + + err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Gas, + SenderChainId: chainID, + Sender: sender.String(), + TxOrigin: sender.String(), + Amount: math.NewUint(20), + }, + OutboundTxParams: []*types.OutboundTxParams{{ + Amount: math.NewUint(42), + }}, + }, + sender, + ) + require.NoError(t, err) + coin := sdkk.BankKeeper.GetBalance(ctx, sdk.AccAddress(sender.Bytes()), config.BaseDenom) + fmt.Println(coin.Amount.String()) + require.Equal(t, "42", coin.Amount.String()) + }) + t.Run("should refund inbound amount on zeta chain if outbound is not present", func(t *testing.T) { + k, ctx, sdkk, _ := keepertest.CrosschainKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + sender := sample.EthAddress() + chainID := getValidEthChainID(t) + + err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Gas, + SenderChainId: chainID, + Sender: sender.String(), + TxOrigin: sender.String(), + Amount: math.NewUint(20), + }, + }, + sender, + ) + require.NoError(t, err) + coin := sdkk.BankKeeper.GetBalance(ctx, sdk.AccAddress(sender.Bytes()), config.BaseDenom) + require.Equal(t, "20", coin.Amount.String()) + }) + t.Run("failed refund amount on zeta chain amount is 0", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + sender := sample.EthAddress() + chainID := getValidEthChainID(t) + + err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Gas, + SenderChainId: chainID, + Sender: sender.String(), + TxOrigin: sender.String(), + Amount: math.ZeroUint(), + }, + OutboundTxParams: []*types.OutboundTxParams{{ + Amount: math.ZeroUint(), + }}, + }, + sender, + ) + require.ErrorContains(t, err, "no amount to refund") + }) +} + +func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { + t.Run("should refund amount on zeta chain", func(t *testing.T) { + k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) + k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) + asset := sample.EthAddress().String() + sender := sample.EthAddress() + chainID := getValidEthChainID(t) + + // deploy zrc20 + deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) + zrc20Addr := deployZRC20( + t, + ctx, + zk.FungibleKeeper, + sdkk.EvmKeeper, + chainID, + "bar", + asset, + "bar", + ) + + err := k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_ERC20, + SenderChainId: chainID, + Sender: sender.String(), + Asset: asset, + Amount: math.NewUint(42), + }, + OutboundTxParams: []*types.OutboundTxParams{{ + Amount: math.NewUint(42), + }}, + }, + sender, + ) + require.NoError(t, err) + + // check amount deposited in balance + balance, err := zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20Addr, sender) + require.NoError(t, err) + require.Equal(t, uint64(42), balance.Uint64()) + + // can refund again + err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_ERC20, + SenderChainId: chainID, + Sender: sender.String(), + Asset: asset, + Amount: math.NewUint(42), + }}, + sender, + ) + require.NoError(t, err) + balance, err = zk.FungibleKeeper.BalanceOfZRC4(ctx, zrc20Addr, sender) + require.NoError(t, err) + require.Equal(t, uint64(84), balance.Uint64()) + }) + + t.Run("should fail with invalid cctx", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + + err := k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Zeta, + Amount: math.NewUint(42), + }}, + sample.EthAddress(), + ) + require.ErrorContains(t, err, "unsupported coin type") + + err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_Gas, + }}, + sample.EthAddress(), + ) + require.ErrorContains(t, err, "unsupported coin type") + + err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_ERC20, + SenderChainId: 999999, + Amount: math.NewUint(42), + }}, + sample.EthAddress(), + ) + require.ErrorContains(t, err, "only EVM chains are supported") + + err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_ERC20, + SenderChainId: getValidEthChainID(t), + Sender: sample.EthAddress().String(), + Amount: math.Uint{}, + }}, + sample.EthAddress(), + ) + require.ErrorContains(t, err, "no amount to refund") + + err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_ERC20, + SenderChainId: getValidEthChainID(t), + Sender: sample.EthAddress().String(), + Amount: math.ZeroUint(), + }}, + sample.EthAddress(), + ) + require.ErrorContains(t, err, "no amount to refund") + + // the foreign coin has not been set + err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ + InboundTxParams: &types.InboundTxParams{ + CoinType: common.CoinType_ERC20, + SenderChainId: getValidEthChainID(t), + Sender: sample.EthAddress().String(), + Asset: sample.EthAddress().String(), + Amount: math.NewUint(42), + }}, + sample.EthAddress(), + ) + require.ErrorContains(t, err, "zrc not found") + }) +} diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index 83f37b2799..b5735ac0de 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -32,6 +32,15 @@ func getValidEthChain(_ *testing.T) *zetacommon.Chain { return &goerli } +func getValidBTCChain() *zetacommon.Chain { + btcRegNet := zetacommon.BtcRegtestChain() + return &btcRegNet +} + +func getValidBtcChainID() int64 { + return getValidBTCChain().ChainId +} + // getValidEthChainIDWithIndex get a valid eth chain id with index func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { switch index { diff --git a/x/crosschain/keeper/zeta_accounting.go b/x/crosschain/keeper/zeta_accounting.go index ee3184b5e3..2f9a849666 100644 --- a/x/crosschain/keeper/zeta_accounting.go +++ b/x/crosschain/keeper/zeta_accounting.go @@ -33,3 +33,16 @@ func (k Keeper) AddZetaAbortedAmount(ctx sdk.Context, amount sdkmath.Uint) { } k.SetZetaAccounting(ctx, zetaAccounting) } + +func (k Keeper) RemoveZetaAbortedAmount(ctx sdk.Context, amount sdkmath.Uint) error { + zetaAccounting, found := k.GetZetaAccounting(ctx) + if !found { + return types.ErrUnableToFindZetaAccounting + } + if zetaAccounting.AbortedZetaAmount.LT(amount) { + return types.ErrInsufficientZetaAmount + } + zetaAccounting.AbortedZetaAmount = zetaAccounting.AbortedZetaAmount.Sub(amount) + k.SetZetaAccounting(ctx, zetaAccounting) + return nil +} diff --git a/x/crosschain/keeper/zeta_accounting_test.go b/x/crosschain/keeper/zeta_accounting_test.go index 1d5e1f7921..8802fe7666 100644 --- a/x/crosschain/keeper/zeta_accounting_test.go +++ b/x/crosschain/keeper/zeta_accounting_test.go @@ -47,3 +47,43 @@ func TestKeeper_AddZetaAccounting(t *testing.T) { }) } + +func TestKeeper_RemoveZetaAbortedAmount(t *testing.T) { + t.Run("should remove aborted zeta amount", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + originalAmount := sdkmath.NewUintFromString("100000000000000000000000000000000000000000000000") + k.SetZetaAccounting(ctx, types.ZetaAccounting{ + AbortedZetaAmount: originalAmount, + }) + val, found := k.GetZetaAccounting(ctx) + require.True(t, found) + require.Equal(t, originalAmount, val.AbortedZetaAmount) + removeAmount := originalAmount.Sub(sdkmath.NewUintFromString("10000000000000000000000000000000000000000000000")) + err := k.RemoveZetaAbortedAmount(ctx, removeAmount) + require.NoError(t, err) + val, found = k.GetZetaAccounting(ctx) + require.True(t, found) + require.Equal(t, originalAmount.Sub(removeAmount), val.AbortedZetaAmount) + }) + t.Run("fail remove aborted zeta amount if accounting not set", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + err := k.RemoveZetaAbortedAmount(ctx, sdkmath.OneUint()) + require.ErrorIs(t, err, types.ErrUnableToFindZetaAccounting) + }) + t.Run("fail remove aborted zeta amount if insufficient amount", func(t *testing.T) { + k, ctx, _, _ := keepertest.CrosschainKeeper(t) + originalAmount := sdkmath.NewUint(100) + k.SetZetaAccounting(ctx, types.ZetaAccounting{ + AbortedZetaAmount: originalAmount, + }) + val, found := k.GetZetaAccounting(ctx) + require.True(t, found) + require.Equal(t, originalAmount, val.AbortedZetaAmount) + removeAmount := originalAmount.Add(sdkmath.NewUint(500)) + err := k.RemoveZetaAbortedAmount(ctx, removeAmount) + require.ErrorIs(t, err, types.ErrInsufficientZetaAmount) + val, found = k.GetZetaAccounting(ctx) + require.True(t, found) + require.Equal(t, originalAmount, val.AbortedZetaAmount) + }) +} diff --git a/x/crosschain/migrations/v5/migrate.go b/x/crosschain/migrations/v5/migrate.go new file mode 100644 index 0000000000..b5e40ceee3 --- /dev/null +++ b/x/crosschain/migrations/v5/migrate.go @@ -0,0 +1,90 @@ +package v5 + +import ( + "fmt" + + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +// crosschainKeeper is an interface to prevent cyclic dependency +type crosschainKeeper interface { + GetStoreKey() storetypes.StoreKey + GetCodec() codec.Codec + GetAllCrossChainTx(ctx sdk.Context) []types.CrossChainTx + + SetCrossChainTx(ctx sdk.Context, cctx types.CrossChainTx) + AddFinalizedInbound(ctx sdk.Context, inboundTxHash string, senderChainID int64, height uint64) + + SetZetaAccounting(ctx sdk.Context, accounting types.ZetaAccounting) +} + +// MigrateStore migrates the x/crosschain module state from the consensus version 4 to 5 +// It resets the aborted zeta amount to use the inbound tx amount instead in situations where the outbound cctx is never created. +func MigrateStore( + ctx sdk.Context, + crosschainKeeper crosschainKeeper, + observerKeeper types.ObserverKeeper, +) error { + + ccctxList := crosschainKeeper.GetAllCrossChainTx(ctx) + abortedAmountZeta := sdkmath.ZeroUint() + for _, cctx := range ccctxList { + if cctx.CctxStatus.Status == types.CctxStatus_Aborted { + + switch cctx.InboundTxParams.CoinType { + case common.CoinType_ERC20: + { + receiverChain := observerKeeper.GetSupportedChainFromChainID(ctx, cctx.GetCurrentOutTxParam().ReceiverChainId) + if receiverChain == nil { + ctx.Logger().Error(fmt.Sprintf("Error getting chain from chain id: %d , cctx index", cctx.GetCurrentOutTxParam().ReceiverChainId), cctx.Index) + continue + } + // There is a chance that this cctx has already been refunded, so we set the isRefunded flag to true. + // Even though, there is a slight possibility that the refund tx failed when doing an auto refund; there is no way for us to know. Which is why we can mark this type of cctx as non-refundable + // Auto refunds are done for ERC20 cctx's when the receiver chain is a zeta chain. + if receiverChain.IsZetaChain() { + cctx.CctxStatus.IsAbortRefunded = true + } else { + cctx.CctxStatus.IsAbortRefunded = false + } + } + case common.CoinType_Zeta: + { + // add the required amount into the zeta accounting. + // GetAbortedAmount replaces using Outbound Amount directly, to make sure we refund the amount deposited by the user if the outbound is never created and the cctx is aborted. + // For these cctx's we allow the refund to be processed later and the Aborted amount would be adjusted when the refund is processed. + abortedValue := GetAbortedAmount(cctx) + abortedAmountZeta = abortedAmountZeta.Add(abortedValue) + cctx.CctxStatus.IsAbortRefunded = false + + } + case common.CoinType_Gas: + { + // CointType gas can be processed as normal and we can issue the refund using the admin refund tx . + cctx.CctxStatus.IsAbortRefunded = false + } + } + crosschainKeeper.SetCrossChainTx(ctx, cctx) + } + + } + crosschainKeeper.SetZetaAccounting(ctx, types.ZetaAccounting{AbortedZetaAmount: abortedAmountZeta}) + + return nil +} + +func GetAbortedAmount(cctx types.CrossChainTx) sdkmath.Uint { + if cctx.OutboundTxParams != nil && !cctx.GetCurrentOutTxParam().Amount.IsZero() { + return cctx.GetCurrentOutTxParam().Amount + } + if cctx.InboundTxParams != nil { + return cctx.InboundTxParams.Amount + } + + return sdkmath.ZeroUint() +} diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go new file mode 100644 index 0000000000..8033ddc3bf --- /dev/null +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -0,0 +1,147 @@ +package v5_test + +import ( + "fmt" + "math/rand" + "testing" + + "cosmossdk.io/math" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/common" + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper" + v5 "github.com/zeta-chain/zetacore/x/crosschain/migrations/v5" + crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestMigrateStore(t *testing.T) { + t.Run("TestMigrateStore", func(t *testing.T) { + k, ctx, _, zk := keepertest.CrosschainKeeper(t) + cctxList := CrossChainTxList(100) + v5ZetaAccountingAmount := math.ZeroUint() + v4ZetaAccountingAmount := math.ZeroUint() + for _, cctx := range cctxList { + k.SetCrossChainTx(ctx, cctx) + if cctx.CctxStatus.Status != crosschaintypes.CctxStatus_Aborted || cctx.GetCurrentOutTxParam().CoinType != common.CoinType_Zeta { + continue + } + v5ZetaAccountingAmount = v5ZetaAccountingAmount.Add(crosschainkeeper.GetAbortedAmount(cctx)) + v4ZetaAccountingAmount = v4ZetaAccountingAmount.Add(cctx.GetCurrentOutTxParam().Amount) + } + + assert.True(t, v5ZetaAccountingAmount.GT(v4ZetaAccountingAmount)) + // Previously set the zeta accounting + k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{ + AbortedZetaAmount: v4ZetaAccountingAmount, + }) + err := v5.MigrateStore(ctx, k, k.GetObserverKeeper()) + require.NoError(t, err) + zetaAccounting, found := k.GetZetaAccounting(ctx) + require.True(t, found) + require.True(t, v5ZetaAccountingAmount.Equal(zetaAccounting.AbortedZetaAmount)) + cctxListUpdated := k.GetAllCrossChainTx(ctx) + // Check refund status of the cctx + for _, cctx := range cctxListUpdated { + switch cctx.InboundTxParams.CoinType { + case common.CoinType_ERC20: + receiverChain := zk.ObserverKeeper.GetSupportedChainFromChainID(ctx, cctx.GetCurrentOutTxParam().ReceiverChainId) + require.NotNil(t, receiverChain) + if receiverChain.IsZetaChain() { + require.True(t, cctx.CctxStatus.IsAbortRefunded) + } else { + require.False(t, cctx.CctxStatus.IsAbortRefunded) + } + case common.CoinType_Zeta: + require.False(t, cctx.CctxStatus.IsAbortRefunded) + case common.CoinType_Gas: + require.False(t, cctx.CctxStatus.IsAbortRefunded) + } + } + }) + +} + +func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { + cctxList := make([]crosschaintypes.CrossChainTx, count+100) + i := 0 + r := rand.New(rand.NewSource(9)) + for ; i < count/2; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount.Add(math.NewUint(uint64(r.Uint32()))), + CoinType: common.CoinType_Zeta, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: amount, + CoinType: common.CoinType_Zeta, + }}, + } + for ; i < count; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount, + CoinType: common.CoinType_Zeta, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: math.ZeroUint(), + CoinType: common.CoinType_Zeta, + }}, + } + } + for ; i < count+20; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount, + CoinType: common.CoinType_ERC20, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: math.ZeroUint(), + CoinType: common.CoinType_ERC20, + ReceiverChainId: common.ZetaPrivnetChain().ChainId, + }}, + } + } + for ; i < count+50; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount, + CoinType: common.CoinType_ERC20, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: math.ZeroUint(), + CoinType: common.CoinType_ERC20, + ReceiverChainId: common.GoerliLocalnetChain().ChainId, + }}, + } + } + for ; i < count+100; i++ { + amount := math.NewUint(uint64(r.Uint32())) + cctxList[i] = crosschaintypes.CrossChainTx{ + Index: fmt.Sprintf("%d", i), + CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, + InboundTxParams: &crosschaintypes.InboundTxParams{ + Amount: amount, + CoinType: common.CoinType_Gas, + }, + OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ + Amount: amount, + CoinType: common.CoinType_Gas, + }}, + } + } + } + return cctxList +} diff --git a/x/crosschain/module.go b/x/crosschain/module.go index 421f92c895..8821a7942e 100644 --- a/x/crosschain/module.go +++ b/x/crosschain/module.go @@ -157,6 +157,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil { panic(err) } + if err := cfg.RegisterMigration(types.ModuleName, 4, m.Migrate4to5); err != nil { + panic(err) + } } // RegisterInvariants registers the crosschain module's invariants. diff --git a/x/crosschain/types/cross_chain_tx.pb.go b/x/crosschain/types/cross_chain_tx.pb.go index f74b500a81..94f34e6e46 100644 --- a/x/crosschain/types/cross_chain_tx.pb.go +++ b/x/crosschain/types/cross_chain_tx.pb.go @@ -394,6 +394,7 @@ type Status struct { Status CctxStatus `protobuf:"varint,1,opt,name=status,proto3,enum=zetachain.zetacore.crosschain.CctxStatus" json:"status,omitempty"` StatusMessage string `protobuf:"bytes,2,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` LastUpdateTimestamp int64 `protobuf:"varint,3,opt,name=lastUpdate_timestamp,json=lastUpdateTimestamp,proto3" json:"lastUpdate_timestamp,omitempty"` + IsAbortRefunded bool `protobuf:"varint,4,opt,name=isAbortRefunded,proto3" json:"isAbortRefunded,omitempty"` } func (m *Status) Reset() { *m = Status{} } @@ -450,6 +451,13 @@ func (m *Status) GetLastUpdateTimestamp() int64 { return 0 } +func (m *Status) GetIsAbortRefunded() bool { + if m != nil { + return m.IsAbortRefunded + } + return false +} + type CrossChainTx struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Index string `protobuf:"bytes,2,opt,name=index,proto3" json:"index,omitempty"` @@ -548,76 +556,77 @@ func init() { func init() { proto.RegisterFile("crosschain/cross_chain_tx.proto", fileDescriptor_af3a0ad055343c21) } var fileDescriptor_af3a0ad055343c21 = []byte{ - // 1100 bytes of a gzipped FileDescriptorProto + // 1120 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0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0xfa, 0x70, 0x5e, 0xb5, 0x7e, 0x3b, 0xaf, 0x5a, 0xdf, 0x5d, 0x54, + 0x33, 0x1f, 0x2e, 0xaa, 0x99, 0x5f, 0x2e, 0xaa, 0x99, 0xa3, 0xd5, 0x94, 0xae, 0xe4, 0x39, 0xad, + 0xe8, 0xbf, 0xce, 0xf8, 0xc8, 0xda, 0xe3, 0x76, 0xea, 0x5f, 0x54, 0xc9, 0xac, 0x93, 0x57, 0x7f, + 0x8e, 0xcf, 0xfe, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x13, 0xc7, 0x24, 0x8d, 0xa6, 0x0a, 0x00, 0x00, } func (m *InboundTxParams) Marshal() (dAtA []byte, err error) { @@ -890,6 +899,16 @@ func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.IsAbortRefunded { + i-- + if m.IsAbortRefunded { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } if m.LastUpdateTimestamp != 0 { i = encodeVarintCrossChainTx(dAtA, i, uint64(m.LastUpdateTimestamp)) i-- @@ -1143,6 +1162,9 @@ func (m *Status) Size() (n int) { if m.LastUpdateTimestamp != 0 { n += 1 + sovCrossChainTx(uint64(m.LastUpdateTimestamp)) } + if m.IsAbortRefunded { + n += 2 + } return n } @@ -2141,6 +2163,26 @@ func (m *Status) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsAbortRefunded", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrossChainTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsAbortRefunded = bool(v != 0) default: iNdEx = preIndex skippy, err := skipCrossChainTx(dAtA[iNdEx:]) diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index 12bbd4ad84..0f7fb8341a 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -5,44 +5,43 @@ import ( ) var ( - ErrUnsupportedChain = errorsmod.Register(ModuleName, 1102, "chain parse error") - ErrInvalidChainID = errorsmod.Register(ModuleName, 1101, "chain id cannot be negative") - ErrInvalidPubKeySet = errorsmod.Register(ModuleName, 1106, "invalid pubkeyset") - ErrUnableToGetGasPrice = errorsmod.Register(ModuleName, 1107, "unable to get gas price") - ErrNotEnoughZetaBurnt = errorsmod.Register(ModuleName, 1109, "not enough zeta burnt") - ErrCannotFindReceiverNonce = errorsmod.Register(ModuleName, 1110, "cannot find receiver chain nonce") - - ErrGasCoinNotFound = errorsmod.Register(ModuleName, 1113, "gas coin not found for sender chain") - ErrUnableToParseAddress = errorsmod.Register(ModuleName, 1115, "cannot parse address and data") - ErrCannotProcessWithdrawal = errorsmod.Register(ModuleName, 1116, "cannot process withdrawal event") - ErrForeignCoinNotFound = errorsmod.Register(ModuleName, 1118, "foreign coin not found for sender chain") - ErrNotEnoughPermissions = errorsmod.Register(ModuleName, 1119, "not enough permissions for current actions") - - ErrCannotFindPendingNonces = errorsmod.Register(ModuleName, 1121, "cannot find pending nonces") - ErrCannotFindTSSKeys = errorsmod.Register(ModuleName, 1122, "cannot find TSS keys") - ErrNonceMismatch = errorsmod.Register(ModuleName, 1123, "nonce mismatch") - ErrNotFoundChainParams = errorsmod.Register(ModuleName, 1126, "not found chain chain params") - ErrUnableToSendCoinType = errorsmod.Register(ModuleName, 1127, "unable to send this coin type to a receiver chain") - - ErrInvalidAddress = errorsmod.Register(ModuleName, 1128, "invalid address") - ErrDeployContract = errorsmod.Register(ModuleName, 1129, "unable to deploy contract") - ErrUnableToUpdateTss = errorsmod.Register(ModuleName, 1130, "unable to update TSS address") - ErrNotEnoughGas = errorsmod.Register(ModuleName, 1131, "not enough gas") - ErrNotEnoughFunds = errorsmod.Register(ModuleName, 1132, "not enough funds") - - ErrProofVerificationFail = errorsmod.Register(ModuleName, 1133, "proof verification fail") - ErrCannotFindCctx = errorsmod.Register(ModuleName, 1134, "cannot find cctx") - ErrStatusNotPending = errorsmod.Register(ModuleName, 1135, "Status not pending") - - ErrCannotFindGasParams = errorsmod.Register(ModuleName, 1136, "cannot find gas params") - ErrInvalidGasAmount = errorsmod.Register(ModuleName, 1137, "invalid gas amount") - ErrNoLiquidityPool = errorsmod.Register(ModuleName, 1138, "no liquidity pool") - ErrInvalidCoinType = errorsmod.Register(ModuleName, 1139, "invalid coin type") - ErrCannotMigrateTssFunds = errorsmod.Register(ModuleName, 1140, "cannot migrate TSS funds") - ErrTxBodyVerificationFail = errorsmod.Register(ModuleName, 1141, "transaction body verification fail") - ErrReceiverIsEmpty = errorsmod.Register(ModuleName, 1142, "receiver is empty") - ErrUnsupportedStatus = errorsmod.Register(ModuleName, 1143, "unsupported status") - ErrObservedTxAlreadyFinalized = errorsmod.Register(ModuleName, 1144, "observed tx already finalized") - + ErrUnsupportedChain = errorsmod.Register(ModuleName, 1102, "chain parse error") + ErrInvalidChainID = errorsmod.Register(ModuleName, 1101, "chain id cannot be negative") + ErrInvalidPubKeySet = errorsmod.Register(ModuleName, 1106, "invalid pubkeyset") + ErrUnableToGetGasPrice = errorsmod.Register(ModuleName, 1107, "unable to get gas price") + ErrNotEnoughZetaBurnt = errorsmod.Register(ModuleName, 1109, "not enough zeta burnt") + ErrCannotFindReceiverNonce = errorsmod.Register(ModuleName, 1110, "cannot find receiver chain nonce") + ErrGasCoinNotFound = errorsmod.Register(ModuleName, 1113, "gas coin not found for sender chain") + ErrUnableToParseAddress = errorsmod.Register(ModuleName, 1115, "cannot parse address and data") + ErrCannotProcessWithdrawal = errorsmod.Register(ModuleName, 1116, "cannot process withdrawal event") + ErrForeignCoinNotFound = errorsmod.Register(ModuleName, 1118, "foreign coin not found for sender chain") + ErrNotEnoughPermissions = errorsmod.Register(ModuleName, 1119, "not enough permissions for current actions") + ErrCannotFindPendingNonces = errorsmod.Register(ModuleName, 1121, "cannot find pending nonces") + ErrCannotFindTSSKeys = errorsmod.Register(ModuleName, 1122, "cannot find TSS keys") + ErrNonceMismatch = errorsmod.Register(ModuleName, 1123, "nonce mismatch") + ErrNotFoundChainParams = errorsmod.Register(ModuleName, 1126, "not found chain chain params") + ErrUnableToSendCoinType = errorsmod.Register(ModuleName, 1127, "unable to send this coin type to a receiver chain") + ErrInvalidAddress = errorsmod.Register(ModuleName, 1128, "invalid address") + ErrDeployContract = errorsmod.Register(ModuleName, 1129, "unable to deploy contract") + ErrUnableToUpdateTss = errorsmod.Register(ModuleName, 1130, "unable to update TSS address") + ErrNotEnoughGas = errorsmod.Register(ModuleName, 1131, "not enough gas") + ErrNotEnoughFunds = errorsmod.Register(ModuleName, 1132, "not enough funds") + ErrProofVerificationFail = errorsmod.Register(ModuleName, 1133, "proof verification fail") + ErrCannotFindCctx = errorsmod.Register(ModuleName, 1134, "cannot find cctx") + ErrStatusNotPending = errorsmod.Register(ModuleName, 1135, "Status not pending") + ErrCannotFindGasParams = errorsmod.Register(ModuleName, 1136, "cannot find gas params") + ErrInvalidGasAmount = errorsmod.Register(ModuleName, 1137, "invalid gas amount") + ErrNoLiquidityPool = errorsmod.Register(ModuleName, 1138, "no liquidity pool") + ErrInvalidCoinType = errorsmod.Register(ModuleName, 1139, "invalid coin type") + ErrCannotMigrateTssFunds = errorsmod.Register(ModuleName, 1140, "cannot migrate TSS funds") + ErrTxBodyVerificationFail = errorsmod.Register(ModuleName, 1141, "transaction body verification fail") + ErrReceiverIsEmpty = errorsmod.Register(ModuleName, 1142, "receiver is empty") + ErrUnsupportedStatus = errorsmod.Register(ModuleName, 1143, "unsupported status") + ErrObservedTxAlreadyFinalized = errorsmod.Register(ModuleName, 1144, "observed tx already finalized") ErrInsufficientFundsTssMigration = errorsmod.Register(ModuleName, 1145, "insufficient funds for TSS migration") + ErrInvalidCCTXIndex = errorsmod.Register(ModuleName, 1146, "invalid cctx index") + ErrInvalidStatus = errorsmod.Register(ModuleName, 1147, "invalid cctx status") + 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") ) diff --git a/x/crosschain/types/message_refund_aborted.go b/x/crosschain/types/message_refund_aborted.go new file mode 100644 index 0000000000..698d499b09 --- /dev/null +++ b/x/crosschain/types/message_refund_aborted.go @@ -0,0 +1,55 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ethcommon "github.com/ethereum/go-ethereum/common" +) + +const RefundAborted = "RefundAbortedCCTX" + +var _ sdk.Msg = &MsgRefundAbortedCCTX{} + +func NewMsgRefundAbortedCCTX(creator string, cctxIndex string, refundAddress string) *MsgRefundAbortedCCTX { + return &MsgRefundAbortedCCTX{ + Creator: creator, + CctxIndex: cctxIndex, + RefundAddress: refundAddress, + } +} + +func (msg *MsgRefundAbortedCCTX) Route() string { + return RouterKey +} + +func (msg *MsgRefundAbortedCCTX) Type() string { + return RefundAborted +} + +func (msg *MsgRefundAbortedCCTX) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgRefundAbortedCCTX) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgRefundAbortedCCTX) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + if len(msg.CctxIndex) != 66 { + return ErrInvalidCCTXIndex + } + if msg.RefundAddress != "" && !ethcommon.IsHexAddress(msg.RefundAddress) { + return ErrInvalidAddress + } + return nil +} diff --git a/x/crosschain/types/message_refund_aborted_test.go b/x/crosschain/types/message_refund_aborted_test.go new file mode 100644 index 0000000000..7f1a0643f6 --- /dev/null +++ b/x/crosschain/types/message_refund_aborted_test.go @@ -0,0 +1,36 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestNewMsgRefundAbortedCCTX(t *testing.T) { + t.Run("successfully validate message", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + msg := types.NewMsgRefundAbortedCCTX(sample.AccAddress(), cctx.Index, "") + assert.NoError(t, msg.ValidateBasic()) + }) + t.Run("invalid creator address", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + msg := types.NewMsgRefundAbortedCCTX("invalid", cctx.Index, "") + assert.ErrorContains(t, msg.ValidateBasic(), "invalid creator address") + }) + t.Run("invalid cctx index", func(t *testing.T) { + msg := types.NewMsgRefundAbortedCCTX(sample.AccAddress(), "invalid", "") + assert.ErrorContains(t, msg.ValidateBasic(), "invalid cctx index") + }) + t.Run("invalid refund address", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + msg := types.NewMsgRefundAbortedCCTX(sample.AccAddress(), cctx.Index, "invalid") + assert.ErrorContains(t, msg.ValidateBasic(), "invalid address") + }) + t.Run("invalid refund address 2", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + msg := types.NewMsgRefundAbortedCCTX(sample.AccAddress(), cctx.Index, "0x91da5bf3F8Eb72724E6f50Ec6C3D199C6355c59") + assert.ErrorContains(t, msg.ValidateBasic(), "invalid address") + }) +} diff --git a/x/crosschain/types/status.go b/x/crosschain/types/status.go index 1364e5946c..be2b4af62e 100644 --- a/x/crosschain/types/status.go +++ b/x/crosschain/types/status.go @@ -4,6 +4,12 @@ import ( "fmt" ) +func (m *Status) AbortRefunded(timeStamp int64) { + m.IsAbortRefunded = true + m.StatusMessage = "CCTX aborted and Refunded" + m.LastUpdateTimestamp = timeStamp +} + // empty msg does not overwrite old status message func (m *Status) ChangeStatus(newStatus CctxStatus, msg string) { if len(msg) > 0 { diff --git a/x/crosschain/types/status_test.go b/x/crosschain/types/status_test.go new file mode 100644 index 0000000000..cadf64490e --- /dev/null +++ b/x/crosschain/types/status_test.go @@ -0,0 +1,25 @@ +package types_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/x/crosschain/types" +) + +func TestStatus_AbortRefunded(t *testing.T) { + t.Run("should set status to aborted and message to CCTX aborted and Refunded", func(t *testing.T) { + status := types.Status{ + Status: 0, + StatusMessage: "", + LastUpdateTimestamp: 0, + IsAbortRefunded: false, + } + timestamp := time.Now().Unix() + status.AbortRefunded(timestamp) + require.Equal(t, status.IsAbortRefunded, true) + require.Equal(t, status.StatusMessage, "CCTX aborted and Refunded") + require.Equal(t, status.LastUpdateTimestamp, timestamp) + }) +} diff --git a/x/crosschain/types/tx.pb.go b/x/crosschain/types/tx.pb.go index c784912394..650ef991dd 100644 --- a/x/crosschain/types/tx.pb.go +++ b/x/crosschain/types/tx.pb.go @@ -1350,6 +1350,102 @@ func (m *MsgAbortStuckCCTXResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAbortStuckCCTXResponse proto.InternalMessageInfo +type MsgRefundAbortedCCTX struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + CctxIndex string `protobuf:"bytes,2,opt,name=cctx_index,json=cctxIndex,proto3" json:"cctx_index,omitempty"` + RefundAddress string `protobuf:"bytes,3,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty"` +} + +func (m *MsgRefundAbortedCCTX) Reset() { *m = MsgRefundAbortedCCTX{} } +func (m *MsgRefundAbortedCCTX) String() string { return proto.CompactTextString(m) } +func (*MsgRefundAbortedCCTX) ProtoMessage() {} +func (*MsgRefundAbortedCCTX) Descriptor() ([]byte, []int) { + return fileDescriptor_81d6d611190b7635, []int{22} +} +func (m *MsgRefundAbortedCCTX) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRefundAbortedCCTX) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRefundAbortedCCTX.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 *MsgRefundAbortedCCTX) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRefundAbortedCCTX.Merge(m, src) +} +func (m *MsgRefundAbortedCCTX) XXX_Size() int { + return m.Size() +} +func (m *MsgRefundAbortedCCTX) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRefundAbortedCCTX.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRefundAbortedCCTX proto.InternalMessageInfo + +func (m *MsgRefundAbortedCCTX) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgRefundAbortedCCTX) GetCctxIndex() string { + if m != nil { + return m.CctxIndex + } + return "" +} + +func (m *MsgRefundAbortedCCTX) GetRefundAddress() string { + if m != nil { + return m.RefundAddress + } + return "" +} + +type MsgRefundAbortedCCTXResponse struct { +} + +func (m *MsgRefundAbortedCCTXResponse) Reset() { *m = MsgRefundAbortedCCTXResponse{} } +func (m *MsgRefundAbortedCCTXResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRefundAbortedCCTXResponse) ProtoMessage() {} +func (*MsgRefundAbortedCCTXResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_81d6d611190b7635, []int{23} +} +func (m *MsgRefundAbortedCCTXResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRefundAbortedCCTXResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRefundAbortedCCTXResponse.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 *MsgRefundAbortedCCTXResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRefundAbortedCCTXResponse.Merge(m, src) +} +func (m *MsgRefundAbortedCCTXResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRefundAbortedCCTXResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRefundAbortedCCTXResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRefundAbortedCCTXResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateTSSVoter)(nil), "zetachain.zetacore.crosschain.MsgCreateTSSVoter") proto.RegisterType((*MsgCreateTSSVoterResponse)(nil), "zetachain.zetacore.crosschain.MsgCreateTSSVoterResponse") @@ -1373,103 +1469,108 @@ func init() { proto.RegisterType((*MsgVoteOnObservedInboundTxResponse)(nil), "zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTxResponse") proto.RegisterType((*MsgAbortStuckCCTX)(nil), "zetachain.zetacore.crosschain.MsgAbortStuckCCTX") proto.RegisterType((*MsgAbortStuckCCTXResponse)(nil), "zetachain.zetacore.crosschain.MsgAbortStuckCCTXResponse") + proto.RegisterType((*MsgRefundAbortedCCTX)(nil), "zetachain.zetacore.crosschain.MsgRefundAbortedCCTX") + proto.RegisterType((*MsgRefundAbortedCCTXResponse)(nil), "zetachain.zetacore.crosschain.MsgRefundAbortedCCTXResponse") } func init() { proto.RegisterFile("crosschain/tx.proto", fileDescriptor_81d6d611190b7635) } var fileDescriptor_81d6d611190b7635 = []byte{ - // 1449 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0x6d, 0x4f, 0xdb, 0xd6, - 0x17, 0xc7, 0x7f, 0x20, 0x24, 0x07, 0x02, 0xd4, 0xd0, 0x36, 0x35, 0x25, 0x50, 0xf3, 0x6f, 0x87, - 0x26, 0x91, 0xb4, 0x54, 0xd3, 0xda, 0x6e, 0x93, 0x06, 0x51, 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 0x04, 0x6d, 0x99, 0x75, 0x8b, 0xd4, 0x05, 0x46, 0x46, 0x86, - 0xb6, 0x1e, 0x5a, 0xa4, 0xae, 0xae, 0x41, 0xce, 0xc6, 0x5e, 0x60, 0x32, 0x34, 0x64, 0x5a, 0x67, - 0xe3, 0xb4, 0x56, 0xb0, 0x17, 0x54, 0xdb, 0x4d, 0x64, 0x64, 0x6d, 0xb9, 0x52, 0x57, 0x60, 0xbc, - 0x19, 0x62, 0xbc, 0x5f, 0x18, 0x5f, 0x56, 0x56, 0x27, 0xd7, 0xf3, 0xf1, 0xd1, 0x27, 0x8c, 0x69, - 0x88, 0x3d, 0x16, 0x77, 0xad, 0x81, 0xed, 0x03, 0x61, 0x2f, 0x23, 0xe2, 0xe6, 0x1c, 0x6e, 0xf2, - 0x0a, 0x64, 0x69, 0xcb, 0xf4, 0x02, 0x07, 0xb5, 0x0a, 0x13, 0xc2, 0x4d, 0xda, 0xda, 0x66, 0xa4, - 0x84, 0xa4, 0x3b, 0xe4, 0x04, 0x92, 0xdf, 0x45, 0xed, 0x7f, 0x5d, 0xf7, 0x28, 0x6a, 0x78, 0x84, - 0xde, 0x37, 0x2a, 0xeb, 0x37, 0xfb, 0x00, 0xb2, 0x02, 0x79, 0x14, 0xda, 0xeb, 0x37, 0x4d, 0x4b, - 0x60, 0x2b, 0x73, 0x30, 0xc5, 0x99, 0x71, 0xfe, 0x3a, 0x51, 0x1b, 0x4d, 0xa3, 0xa6, 0xc2, 0x58, - 0x60, 0xf9, 0x02, 0x97, 0x9c, 0xc1, 0xd7, 0xea, 0x25, 0xc8, 0x90, 0xb6, 0x5f, 0xc3, 0x0d, 0x0e, - 0x41, 0xce, 0x90, 0x94, 0xaa, 0x41, 0xd6, 0x41, 0xb6, 0xe7, 0x5b, 0x0d, 0xc2, 0x43, 0xce, 0x1b, - 0x09, 0xad, 0x2e, 0x40, 0xce, 0xb5, 0x88, 0xd9, 0xf0, 0x7c, 0x8f, 0xca, 0x90, 0xb3, 0x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0x22, 0xd5, 0x4b, 0x27, 0xfe, 0x89, 0x0e, 0xd1, 0x4b, - 0xdd, 0x32, 0xc3, 0xf4, 0x52, 0xaf, 0x7f, 0xa8, 0xea, 0x77, 0x30, 0xd3, 0xfd, 0xff, 0xfd, 0xd6, - 0x60, 0x75, 0x5d, 0x22, 0xda, 0xdd, 0x33, 0x8b, 0x74, 0xe6, 0xa0, 0xeb, 0x3b, 0xc8, 0x10, 0x39, - 0x48, 0x4b, 0x0c, 0x93, 0x83, 0xd3, 0x3f, 0x61, 0x30, 0xeb, 0x5d, 0xf7, 0xf8, 0x10, 0xd6, 0xd3, - 0x12, 0xc3, 0x58, 0x3f, 0xfd, 0x76, 0xdf, 0xfc, 0xf2, 0xc5, 0x9b, 0xa2, 0xf2, 0xf2, 0x4d, 0x51, - 0xf9, 0xfb, 0x4d, 0x51, 0xf9, 0xe1, 0x6d, 0x71, 0xe4, 0xe5, 0xdb, 0xe2, 0xc8, 0x1f, 0x6f, 0x8b, - 0x23, 0xcf, 0x6e, 0x75, 0x4c, 0x6e, 0xa6, 0x73, 0x4d, 0x7c, 0x8b, 0x8a, 0xd5, 0x97, 0x5b, 0xe5, - 0xce, 0x2f, 0x54, 0x6c, 0x90, 0xd7, 0x32, 0xfc, 0xdb, 0xd2, 0xed, 0xff, 0x02, 0x00, 0x00, 0xff, - 0xff, 0x1e, 0x53, 0x7a, 0xa6, 0xbc, 0x12, 0x00, 0x00, + // 1502 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0x6f, 0x4f, 0xdb, 0x56, + 0x17, 0xc7, 0x0f, 0x10, 0x92, 0x03, 0x01, 0x6a, 0x68, 0x9b, 0x9a, 0x12, 0xa8, 0x79, 0xda, 0x07, + 0x3d, 0x12, 0x49, 0x4b, 0x35, 0xad, 0xed, 0x36, 0x69, 0x10, 0xb5, 0x94, 0xad, 0x94, 0xca, 0xa4, + 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 0x31, 0x8e, 0x7a, 0x0b, 0xe6, 0xc4, 0x01, 0x36, 0x70, 0x45, 0x03, 0xa6, 0x79, 0xe4, 0x59, 0xce, + 0x2e, 0x13, 0xf2, 0x94, 0xdf, 0x53, 0x89, 0x71, 0x97, 0x19, 0x36, 0xee, 0xf4, 0x9b, 0xb0, 0x36, + 0xa0, 0xb4, 0xe3, 0x16, 0x78, 0x39, 0xc1, 0x17, 0x87, 0xe4, 0xb9, 0x5d, 0x7f, 0x78, 0x07, 0xb0, + 0x7e, 0x43, 0xbe, 0x83, 0x02, 0x59, 0xfe, 0x92, 0x62, 0xe1, 0x88, 0x27, 0xb3, 0x6b, 0x34, 0x65, + 0x05, 0xbb, 0x24, 0x1b, 0x5d, 0x83, 0xb4, 0x84, 0x38, 0x90, 0xf7, 0x6e, 0x4c, 0xab, 0x37, 0x61, + 0x36, 0x7a, 0x96, 0xb0, 0x4d, 0x0a, 0x15, 0x11, 0x57, 0x20, 0x77, 0xba, 0x3c, 0xa5, 0xde, 0x6b, + 0x79, 0x62, 0x51, 0xd6, 0x11, 0x21, 0x96, 0x2b, 0xa0, 0xcf, 0x18, 0x11, 0xa9, 0x5e, 0x07, 0x60, + 0x90, 0xcb, 0x0e, 0xce, 0x08, 0x3f, 0x3d, 0x5f, 0x36, 0xee, 0x2d, 0x98, 0xf3, 0x7c, 0x53, 0xde, + 0xff, 0xa2, 0x5b, 0x45, 0xcb, 0x65, 0x3d, 0xbf, 0xb3, 0x45, 0x13, 0x43, 0x74, 0x9a, 0x9f, 0x88, + 0x87, 0x68, 0x32, 0xaf, 0x33, 0x43, 0xd7, 0x98, 0x25, 0xc8, 0xd0, 0x96, 0x89, 0x03, 0xcf, 0xf5, + 0xfc, 0x5c, 0x56, 0x38, 0x44, 0x5b, 0xfb, 0x9c, 0x66, 0xb7, 0xa7, 0x45, 0x08, 0xa2, 0xb9, 0x59, + 0xfe, 0x42, 0x10, 0xac, 0x04, 0x51, 0x13, 0xf9, 0x54, 0xce, 0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b5, 0xdf, + 0x75, 0x7f, 0xff, 0xbc, 0xfa, 0x63, 0x51, 0x6d, 0xeb, 0xc2, 0xa2, 0xb1, 0x67, 0xdf, 0xc2, 0x6c, + 0xd7, 0xff, 0xa3, 0xdb, 0xc3, 0x95, 0x26, 0x25, 0xb4, 0x7b, 0xe7, 0x95, 0x48, 0xf4, 0x52, 0xcf, + 0x3f, 0xe4, 0x11, 0x7a, 0xa9, 0x5b, 0x66, 0x94, 0x5e, 0xea, 0xf7, 0xcf, 0x59, 0xfd, 0x0e, 0xe6, + 0xba, 0xbf, 0x2b, 0xdc, 0x19, 0xae, 0xae, 0x4b, 0x44, 0xbb, 0x7f, 0x6e, 0x91, 0xce, 0x1c, 0x74, + 0x7d, 0x9f, 0x19, 0x21, 0x07, 0x49, 0x89, 0x51, 0x72, 0x70, 0xf6, 0xa7, 0x15, 0x66, 0xbd, 0x6b, + 0xbe, 0x8c, 0x60, 0x3d, 0x29, 0x31, 0x8a, 0xf5, 0xb3, 0xa7, 0x0e, 0xbf, 0xd5, 0x7b, 0x67, 0xce, + 0xdd, 0x51, 0x6e, 0xa2, 0x2e, 0xa1, 0x51, 0x6e, 0xf5, 0xbe, 0x53, 0x66, 0xfb, 0xcb, 0x57, 0xef, + 0xf2, 0xca, 0xeb, 0x77, 0x79, 0xe5, 0xaf, 0x77, 0x79, 0xe5, 0x87, 0x93, 0xfc, 0xd8, 0xeb, 0x93, + 0xfc, 0xd8, 0x1f, 0x27, 0xf9, 0xb1, 0x17, 0x77, 0x3a, 0x36, 0x1b, 0xa6, 0x76, 0x43, 0x7c, 0xab, + 0x8b, 0x2c, 0x14, 0x5b, 0xc5, 0xce, 0x2f, 0x78, 0x6c, 0xd1, 0xa9, 0xa4, 0xf8, 0xb7, 0xb7, 0xbb, + 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x99, 0xcd, 0x4c, 0xdc, 0x13, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1495,6 +1596,7 @@ type MsgClient interface { MigrateTssFunds(ctx context.Context, in *MsgMigrateTssFunds, opts ...grpc.CallOption) (*MsgMigrateTssFundsResponse, error) CreateTSSVoter(ctx context.Context, in *MsgCreateTSSVoter, opts ...grpc.CallOption) (*MsgCreateTSSVoterResponse, error) AbortStuckCCTX(ctx context.Context, in *MsgAbortStuckCCTX, opts ...grpc.CallOption) (*MsgAbortStuckCCTXResponse, error) + RefundAbortedCCTX(ctx context.Context, in *MsgRefundAbortedCCTX, opts ...grpc.CallOption) (*MsgRefundAbortedCCTXResponse, error) } type msgClient struct { @@ -1604,6 +1706,15 @@ func (c *msgClient) AbortStuckCCTX(ctx context.Context, in *MsgAbortStuckCCTX, o return out, nil } +func (c *msgClient) RefundAbortedCCTX(ctx context.Context, in *MsgRefundAbortedCCTX, opts ...grpc.CallOption) (*MsgRefundAbortedCCTXResponse, error) { + out := new(MsgRefundAbortedCCTXResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.crosschain.Msg/RefundAbortedCCTX", 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) @@ -1617,6 +1728,7 @@ type MsgServer interface { MigrateTssFunds(context.Context, *MsgMigrateTssFunds) (*MsgMigrateTssFundsResponse, error) CreateTSSVoter(context.Context, *MsgCreateTSSVoter) (*MsgCreateTSSVoterResponse, error) AbortStuckCCTX(context.Context, *MsgAbortStuckCCTX) (*MsgAbortStuckCCTXResponse, error) + RefundAbortedCCTX(context.Context, *MsgRefundAbortedCCTX) (*MsgRefundAbortedCCTXResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1656,6 +1768,9 @@ func (*UnimplementedMsgServer) CreateTSSVoter(ctx context.Context, req *MsgCreat func (*UnimplementedMsgServer) AbortStuckCCTX(ctx context.Context, req *MsgAbortStuckCCTX) (*MsgAbortStuckCCTXResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AbortStuckCCTX not implemented") } +func (*UnimplementedMsgServer) RefundAbortedCCTX(ctx context.Context, req *MsgRefundAbortedCCTX) (*MsgRefundAbortedCCTXResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefundAbortedCCTX not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1859,6 +1974,24 @@ func _Msg_AbortStuckCCTX_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Msg_RefundAbortedCCTX_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRefundAbortedCCTX) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RefundAbortedCCTX(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.crosschain.Msg/RefundAbortedCCTX", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RefundAbortedCCTX(ctx, req.(*MsgRefundAbortedCCTX)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.crosschain.Msg", HandlerType: (*MsgServer)(nil), @@ -1907,6 +2040,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "AbortStuckCCTX", Handler: _Msg_AbortStuckCCTX_Handler, }, + { + MethodName: "RefundAbortedCCTX", + Handler: _Msg_RefundAbortedCCTX_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "crosschain/tx.proto", @@ -2866,6 +3003,73 @@ func (m *MsgAbortStuckCCTXResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *MsgRefundAbortedCCTX) 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 *MsgRefundAbortedCCTX) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRefundAbortedCCTX) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RefundAddress) > 0 { + i -= len(m.RefundAddress) + copy(dAtA[i:], m.RefundAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.RefundAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.CctxIndex) > 0 { + i -= len(m.CctxIndex) + copy(dAtA[i:], m.CctxIndex) + i = encodeVarintTx(dAtA, i, uint64(len(m.CctxIndex))) + 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 *MsgRefundAbortedCCTXResponse) 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 *MsgRefundAbortedCCTXResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRefundAbortedCCTXResponse) 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 @@ -3312,6 +3516,36 @@ func (m *MsgAbortStuckCCTXResponse) Size() (n int) { return n } +func (m *MsgRefundAbortedCCTX) 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 = len(m.CctxIndex) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RefundAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRefundAbortedCCTXResponse) 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 } @@ -6240,6 +6474,202 @@ func (m *MsgAbortStuckCCTXResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRefundAbortedCCTX) 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: MsgRefundAbortedCCTX: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRefundAbortedCCTX: 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 CctxIndex", 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.CctxIndex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RefundAddress", 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.RefundAddress = string(dAtA[iNdEx:postIndex]) + 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 *MsgRefundAbortedCCTXResponse) 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: MsgRefundAbortedCCTXResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRefundAbortedCCTXResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 95bdb7e8730451ea0064a49402132ddfa9d4e390 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 13 Feb 2024 16:16:37 -0500 Subject: [PATCH 2/3] chore: remove standalone network (#1694) --- changelog.md | 4 + cmd/zetacored/parsers_test.go | 8 +- common/coin_test.go | 18 +-- standalone-network/add-emissions.sh | 23 ---- standalone-network/add-observer.sh | 14 --- standalone-network/authz/commands.sh | 10 -- standalone-network/authz/tx.json | 35 ------ standalone-network/cctx/cctx-creator-gas.sh | 16 --- .../cctx/cctx-creator-goerili.sh | 65 ---------- standalone-network/cctx/cctx-creator-zeta.sh | 16 --- standalone-network/cctx_authz/commands.sh | 31 ----- .../cctx_authz/gas_price_voter_zeta.json | 34 ----- .../cctx_authz/mario_inbound_vote.json | 42 ------- .../cctx_authz/mario_outbound_vote.json | 38 ------ .../cctx_authz/nonce_voter_zeta.json | 32 ----- .../cctx_authz/zeta_inbound_vote.json | 42 ------- .../cctx_authz/zeta_outbound_vote.json | 38 ------ standalone-network/change-observer-params.sh | 2 - standalone-network/evm-init | 104 --------------- standalone-network/gov/gov.sh | 0 .../gov_observer_params_supported_chains.json | 58 --------- standalone-network/group/add-observer.json | 28 ----- standalone-network/group/group.sh | 11 -- standalone-network/group/members-updated.json | 14 --- standalone-network/group/members.json | 14 --- standalone-network/group/msg.json | 31 ----- standalone-network/group/msg_fungible.json | 37 ------ standalone-network/group/policy.json | 8 -- standalone-network/group/proposal.json | 112 ----------------- .../group/proposal_add-observer.json | 14 --- standalone-network/group/proposal_group.json | 12 -- .../group/proposal_group_examples.json | 23 ---- standalone-network/group/proposal_keygen.json | 12 -- standalone-network/init-multinode.sh | 86 ------------- standalone-network/init.sh | 42 ------- standalone-network/observers-complete.json | 40 ------ standalone-network/observers.json | 14 --- standalone-network/os_info/os1.json | 5 - standalone-network/os_info/os2.json | 5 - standalone-network/proposal.json | 29 ----- standalone-network/proposal_feemarket.json | 15 --- standalone-network/run-zetaclient.sh | 2 - standalone-network/run.sh | 36 ------ .../update_core_params/new_params.json | 11 -- .../update_core_params/update-params.sh | 2 - .../update_voting_period/proposal.json | 27 ---- .../update_voting_period.sh | 17 --- .../upgrade-integration-client.sh | 117 ----------------- .../upgrade-integration-download.sh | 67 ---------- standalone-network/upgrade-integration.sh | 119 ------------------ testutil/keeper/fungible.go | 9 +- testutil/network/genesis_state.go | 36 +++--- x/crosschain/keeper/cctx_test.go | 20 ++- x/crosschain/keeper/gas_price_test.go | 10 +- .../keeper/grpc_query_gas_price_test.go | 5 +- .../grpc_query_last_block_height_test.go | 5 +- x/crosschain/keeper/last_block_height_test.go | 10 +- .../msg_server_add_to_outtx_tracker_test.go | 6 +- .../msg_server_refund_aborted_tx_test.go | 5 +- .../keeper/msg_server_update_tss_test.go | 61 +++++---- .../keeper/msg_server_vote_inbound_tx_test.go | 30 ++--- x/crosschain/keeper/utils_test.go | 2 +- x/crosschain/migrations/v4/migrate_test.go | 29 +++-- x/crosschain/migrations/v5/migrate_test.go | 3 +- .../types/message_refund_aborted_test.go | 12 +- x/emissions/abci_test.go | 14 +-- .../keeper/block_rewards_components_test.go | 6 +- x/emissions/keeper/params_test.go | 8 +- x/fungible/keeper/evm_hooks_test.go | 12 +- x/fungible/keeper/evm_test.go | 2 +- .../msg_server_update_zrc20_paused_status.go | 6 +- ..._server_update_zrc20_paused_status_test.go | 46 +++---- .../keeper/grpc_query_node_account_test.go | 5 +- x/observer/keeper/grpc_query_nonces_test.go | 5 +- x/observer/keeper/keygen_test.go | 8 +- .../msg_server_add_block_header_test.go | 15 ++- .../keeper/msg_server_update_observer_test.go | 80 ++++++------ x/observer/keeper/node_account_test.go | 10 +- x/observer/keeper/nonces_test.go | 10 +- x/observer/keeper/observer_set_test.go | 42 +++---- x/observer/keeper/tss_funds_migrator_test.go | 10 +- x/observer/keeper/tss_test.go | 11 +- x/observer/keeper/utils_test.go | 13 +- x/observer/migrations/v4/migrate_test.go | 10 +- x/observer/migrations/v5/migrate_test.go | 9 +- x/observer/migrations/v6/migrate_test.go | 22 ++-- x/observer/types/ballot_test.go | 14 +-- .../types/message_crosschain_flags_test.go | 10 +- zetaclient/bitcoin/bitcoin_signer_test.go | 15 ++- .../supplychecker/zeta_supply_checker_test.go | 8 +- zetaclient/tss/tss_signer_test.go | 10 +- 91 files changed, 330 insertions(+), 1894 deletions(-) delete mode 100644 standalone-network/add-emissions.sh delete mode 100644 standalone-network/add-observer.sh delete mode 100644 standalone-network/authz/commands.sh delete mode 100644 standalone-network/authz/tx.json delete mode 100755 standalone-network/cctx/cctx-creator-gas.sh delete mode 100755 standalone-network/cctx/cctx-creator-goerili.sh delete mode 100755 standalone-network/cctx/cctx-creator-zeta.sh delete mode 100644 standalone-network/cctx_authz/commands.sh delete mode 100644 standalone-network/cctx_authz/gas_price_voter_zeta.json delete mode 100644 standalone-network/cctx_authz/mario_inbound_vote.json delete mode 100644 standalone-network/cctx_authz/mario_outbound_vote.json delete mode 100644 standalone-network/cctx_authz/nonce_voter_zeta.json delete mode 100644 standalone-network/cctx_authz/zeta_inbound_vote.json delete mode 100644 standalone-network/cctx_authz/zeta_outbound_vote.json delete mode 100644 standalone-network/change-observer-params.sh delete mode 100644 standalone-network/evm-init delete mode 100644 standalone-network/gov/gov.sh delete mode 100644 standalone-network/gov/gov_observer_params_supported_chains.json delete mode 100644 standalone-network/group/add-observer.json delete mode 100644 standalone-network/group/group.sh delete mode 100644 standalone-network/group/members-updated.json delete mode 100644 standalone-network/group/members.json delete mode 100644 standalone-network/group/msg.json delete mode 100644 standalone-network/group/msg_fungible.json delete mode 100644 standalone-network/group/policy.json delete mode 100644 standalone-network/group/proposal.json delete mode 100644 standalone-network/group/proposal_add-observer.json delete mode 100644 standalone-network/group/proposal_group.json delete mode 100644 standalone-network/group/proposal_group_examples.json delete mode 100644 standalone-network/group/proposal_keygen.json delete mode 100755 standalone-network/init-multinode.sh delete mode 100755 standalone-network/init.sh delete mode 100644 standalone-network/observers-complete.json delete mode 100644 standalone-network/observers.json delete mode 100644 standalone-network/os_info/os1.json delete mode 100644 standalone-network/os_info/os2.json delete mode 100644 standalone-network/proposal.json delete mode 100644 standalone-network/proposal_feemarket.json delete mode 100644 standalone-network/run-zetaclient.sh delete mode 100755 standalone-network/run.sh delete mode 100644 standalone-network/update_core_params/new_params.json delete mode 100755 standalone-network/update_core_params/update-params.sh delete mode 100644 standalone-network/update_voting_period/proposal.json delete mode 100644 standalone-network/update_voting_period/update_voting_period.sh delete mode 100755 standalone-network/upgrade-integration-client.sh delete mode 100755 standalone-network/upgrade-integration-download.sh delete mode 100755 standalone-network/upgrade-integration.sh diff --git a/changelog.md b/changelog.md index cf21cc81ba..b0f89948f6 100644 --- a/changelog.md +++ b/changelog.md @@ -64,6 +64,9 @@ * [1667](https://github.com/zeta-chain/node/issues/1667) - estimate SegWit tx size in uinit of vByte * [1675](https://github.com/zeta-chain/node/issues/1675) - use chain param ConfirmationCount for bitcoin confirmation +## Chores +* [1694](https://github.com/zeta-chain/node/pull/1694) - remove standalone network, use require testing package for the entire node folder + ## Version: v12.1.0 ### Tests @@ -90,6 +93,7 @@ * [1585](https://github.com/zeta-chain/node/pull/1585) - Updated release instructions * [1615](https://github.com/zeta-chain/node/pull/1615) - Add upgrade handler for version v12.1.0 + ### Features * [1591](https://github.com/zeta-chain/node/pull/1591) - support lower gas limit for voting on inbound and outbound transactions diff --git a/cmd/zetacored/parsers_test.go b/cmd/zetacored/parsers_test.go index f3310717ef..06f0346903 100644 --- a/cmd/zetacored/parsers_test.go +++ b/cmd/zetacored/parsers_test.go @@ -6,7 +6,7 @@ import ( "os" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" "github.com/zeta-chain/zetacore/app" @@ -18,14 +18,14 @@ func TestParsefileToObserverMapper(t *testing.T) { file := "tmp.json" defer func(t *testing.T, fp string) { err := os.RemoveAll(fp) - assert.NoError(t, err) + require.NoError(t, err) }(t, file) app.SetConfig() createObserverList(file) obsListReadFromFile, err := ParsefileToObserverDetails(file) - assert.NoError(t, err) + require.NoError(t, err) for _, obs := range obsListReadFromFile { - assert.Equal(t, obs.ZetaClientGranteeAddress, sdk.AccAddress(crypto.AddressHash([]byte("ObserverGranteeAddress"))).String()) + require.Equal(t, obs.ZetaClientGranteeAddress, sdk.AccAddress(crypto.AddressHash([]byte("ObserverGranteeAddress"))).String()) } } diff --git a/common/coin_test.go b/common/coin_test.go index 4dd03fa2db..4adfbc2d8d 100644 --- a/common/coin_test.go +++ b/common/coin_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" ) @@ -12,43 +12,43 @@ func Test_GetAzetaDecFromAmountInZeta(t *testing.T) { tt := []struct { name string zetaAmount string - err assert.ErrorAssertionFunc + err require.ErrorAssertionFunc azetaAmount sdk.Dec }{ { name: "valid zeta amount", zetaAmount: "210000000", - err: assert.NoError, + err: require.NoError, azetaAmount: sdk.MustNewDecFromStr("210000000000000000000000000"), }, { name: "very high zeta amount", zetaAmount: "21000000000000000000", - err: assert.NoError, + err: require.NoError, azetaAmount: sdk.MustNewDecFromStr("21000000000000000000000000000000000000"), }, { name: "very low zeta amount", zetaAmount: "1", - err: assert.NoError, + err: require.NoError, azetaAmount: sdk.MustNewDecFromStr("1000000000000000000"), }, { name: "zero zeta amount", zetaAmount: "0", - err: assert.NoError, + err: require.NoError, azetaAmount: sdk.MustNewDecFromStr("0"), }, { name: "decimal zeta amount", zetaAmount: "0.1", - err: assert.NoError, + err: require.NoError, azetaAmount: sdk.MustNewDecFromStr("100000000000000000"), }, { name: "invalid zeta amount", zetaAmount: "%%%%%$#", - err: assert.Error, + err: require.Error, azetaAmount: sdk.MustNewDecFromStr("0"), }, } @@ -57,7 +57,7 @@ func Test_GetAzetaDecFromAmountInZeta(t *testing.T) { azeta, err := common.GetAzetaDecFromAmountInZeta(tc.zetaAmount) tc.err(t, err) if err == nil { - assert.Equal(t, tc.azetaAmount, azeta) + require.Equal(t, tc.azetaAmount, azeta) } }) } diff --git a/standalone-network/add-emissions.sh b/standalone-network/add-emissions.sh deleted file mode 100644 index 610e10e257..0000000000 --- a/standalone-network/add-emissions.sh +++ /dev/null @@ -1,23 +0,0 @@ -zetacored tx bank send zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk zeta1w43fn2ze2wyhu5hfmegr6vp52c3dgn0srdgymy 100000000000azeta --keyring-backend=test --chain-id=localnet_101-1 --fees=200000azeta --yes - -#total left in reserves -zetacored q bank balances zeta1w43fn2ze2wyhu5hfmegr6vp52c3dgn0srdgymy -#observer undistributed -zetacored q bank balances zeta1pyks89mqljlpgzenwa0g8zch0hptk6usd9vcuh -#tss undistributed -zetacored q bank balances zeta1v8v7zkyt7j3dc526k4alsu8vspvqqg342t27vu - - -#Zeta rewards self Delegation -zetacored q distribution rewards zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq - - -#Mario delegate -zetacored tx staking delegate zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq 1000000000000000000000000azeta --from=mario --keyring-backend=test --chain-id=localnet_101-1 --fees=200000azeta -zetacored q distribution rewards zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50 zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq - -#Zeta outstanding rewards (Total) -zetacored q distribution validator-outstanding-rewards zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq - -#Zeta commission rewards -zetacored q distribution commission zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq diff --git a/standalone-network/add-observer.sh b/standalone-network/add-observer.sh deleted file mode 100644 index 38d4953435..0000000000 --- a/standalone-network/add-observer.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -zetacored tx observer add-observer 5 InBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx observer add-observer 5 OutBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored q observer list-observer - -zetacored tx staking unbond zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq 99999900000000000000azeta --from zeta --gas=auto --gas-prices=0.0001azeta --gas-adjustment=1.5 --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block - - -#Add via genesis -#zetacored add-observer-list sample-observer-list.json -#zetacored add-observer Eth InBoundTx $(zetacored keys show zeta -a --keyring-backend=test) -#zetacored add-observer Eth OutBoundTx $(zetacored keys show zeta -a --keyring-backend=test) -#zetacored add-genesis-account $(zetacored keys show zetaeth -a --keyring-backend=test) 50000000000000000000000000000000azeta,500000000000000000000000000000000stake --keyring-backend=test - diff --git a/standalone-network/authz/commands.sh b/standalone-network/authz/commands.sh deleted file mode 100644 index f3083eb8e4..0000000000 --- a/standalone-network/authz/commands.sh +++ /dev/null @@ -1,10 +0,0 @@ -zetacored tx authz grant zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50 delegate --allowed-validators zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --spend-limit=100000000000azeta - -zetacored q authz grants zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50 -zetacored tx authz exec tx.json --from mario --gas=auto --gas-prices=0.1azeta --gas-adjustment=20 --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored q staking delegations-to zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq - - - -zetacored tx authz grant zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50 generic --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --msg-type=/zetachain.zetacore.crosschain.MsgGasPriceVoter - diff --git a/standalone-network/authz/tx.json b/standalone-network/authz/tx.json deleted file mode 100644 index 8e24e6c5bc..0000000000 --- a/standalone-network/authz/tx.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/cosmos.staking.v1beta1.MsgDelegate", - "delegator_address": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "validator_address": "zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq", - "amount": { - "denom": "azeta", - "amount": "100000000000" - } - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "40" - } - ], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/cctx/cctx-creator-gas.sh b/standalone-network/cctx/cctx-creator-gas.sh deleted file mode 100755 index e17a327f7e..0000000000 --- a/standalone-network/cctx/cctx-creator-gas.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -x - -zetacored tx observer add-observer 5 InBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -#zetacored tx observer add-observer 5 OutBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx observer add-observer 2374 InBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx observer add-observer 2374 OutBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx crosschain gas-price-voter 2374 10000000000 100 100 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta -zetacored tx crosschain nonce-voter Goerli 2374 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta --broadcast-mode=block - -zetacored tx crosschain inbound-voter 0x96B05C238b99768F349135de0653b687f9c13fEE 5 0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7 2374 10000000000000000000 0 "" "0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680" 100 Gas --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta -zetacored q crosschain list-cctx -exit 0 -zetacored tx crosschain outbound-voter 0x752139735699b0ffa87571bf519867ab2aaf355733316842f9941e0efe5d05c9 hashout 1 7997428181981842964 0 2374 1 1 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta - -#zetacored tx crosschain zeta-conversion-rate-voter Goerli 1 1 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta diff --git a/standalone-network/cctx/cctx-creator-goerili.sh b/standalone-network/cctx/cctx-creator-goerili.sh deleted file mode 100755 index 71f0660d97..0000000000 --- a/standalone-network/cctx/cctx-creator-goerili.sh +++ /dev/null @@ -1,65 +0,0 @@ -set -x - - -zetacored tx crosschain gas-price-voter 1337 10000000000 100 100 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta -zetacored tx crosschain create-tss-voter tsspubkey 5 0 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta -zetacored tx crosschain gas-price-voter 1337 10000000000 100 100 --from=mario --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta -zetacored tx crosschain create-tss-voter tsspubkey 5 0 --from=mario --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta - -exit 0 -zetacored tx crosschain inbound-voter \ -0x96B05C238b99768F349135de0653b687f9c13fEE \ -1337 \ -0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7 \ -0x96B05C238b99768F349135de0653b687f9c13fEE \ -1337 \ -10000000000000000000 \ -"" \ -"0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680" \ -100 \ -Gas \ -"" \ ---from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta - - -zetacored tx crosschain inbound-voter \ -0x96B05C238b99768F349135de0653b687f9c13fEE \ -1337 \ -0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7 \ -0x96B05C238b99768F349135de0653b687f9c13fEE \ -1337 \ -10000000000000000000 \ -"" \ -"0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680" \ -100 \ -Gas \ -"" \ ---from=mario --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta --output=json - -zetacored q crosschain list-cctx - -zetacored tx crosschain outbound-voter \ -0xead687de84b3969b4c18480f197d2812e0acb83f851acc2830f70e94c85cef55 \ -hashout \ -1 \ -7994721005120625032 \ -0 \ -1337 \ -1 \ -Gas \ ---from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta - -zetacored tx crosschain outbound-voter \ -0xead687de84b3969b4c18480f197d2812e0acb83f851acc2830f70e94c85cef55 \ -hashout \ -1 \ -7994721005120625032 \ -0 \ -1337 \ -1 \ -Gas \ ---from=mario --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta - - - - diff --git a/standalone-network/cctx/cctx-creator-zeta.sh b/standalone-network/cctx/cctx-creator-zeta.sh deleted file mode 100755 index 1184991bea..0000000000 --- a/standalone-network/cctx/cctx-creator-zeta.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -x - -#zetacored tx observer add-observer 5 InBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -#zetacored tx observer add-observer 5 OutBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx observer add-observer 2374 InBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx observer add-observer 2374 OutBoundTx --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx crosschain gas-price-voter 1 10000000000 100 100 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta -zetacored tx crosschain nonce-voter Goerli 2374 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta --broadcast-mode=block - -zetacored tx crosschain inbound-voter 0x96B05C238b99768F349135de0653b687f9c13fEE 5 0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7 2374 10000000000000000000 0 "" "0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680" 100 Zeta --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta -zetacored q crosschain list-cctx -exit 0 -zetacored tx crosschain outbound-voter 0x752139735699b0ffa87571bf519867ab2aaf355733316842f9941e0efe5d05c9 hashout 1 7997428181981842964 0 2374 1 1 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta - -#zetacored tx crosschain zeta-conversion-rate-voter Goerli 1 1 --from=zeta --keyring-backend=test --yes --chain-id=localnet_101-1 --broadcast-mode=block --gas=auto --gas-adjustment=2 --gas-prices=0.1azeta diff --git a/standalone-network/cctx_authz/commands.sh b/standalone-network/cctx_authz/commands.sh deleted file mode 100644 index c7d12d9753..0000000000 --- a/standalone-network/cctx_authz/commands.sh +++ /dev/null @@ -1,31 +0,0 @@ - -#Grant executer authorization to execute the GAS PRICE VOTER, NONCE VOTER for validator `zeta` -zetacored tx authz grant zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99 generic --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --msg-type=/zetachain.zetacore.crosschain.MsgGasPriceVoter -zetacored tx authz grant zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99 generic --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --msg-type=/zetachain.zetacore.crosschain.MsgNonceVoter - -#Grant executer authorization to execute the Inbound and Outbound VOTER for observers `zeta` and `mario` -#These are essentially the list of transactions that the zetaclient does to process a CCTX end to end -zetacored tx authz grant zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99 generic --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --msg-type=/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx -zetacored tx authz grant zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99 generic --from mario --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --msg-type=/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx - -zetacored tx authz grant zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99 generic --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --msg-type=/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx -zetacored tx authz grant zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99 generic --from mario --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --msg-type=/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx - - -# Check all the grants -zetacored q authz grants zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99 -zetacored q authz grants zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50 zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99 - - -# Execute all messages from executer . At this time zeta and mario keys can be offline -zetacored tx authz exec gas_price_voter_zeta.json --from executer --gas=auto --gas-prices=0.1azeta --gas-adjustment=10 --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx authz exec nonce_voter_zeta.json --from executer --gas=auto --gas-prices=0.1azeta --gas-adjustment=10 --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx authz exec mario_inbound_vote.json --from executer --gas=auto --gas-prices=0.1azeta --gas-adjustment=10 --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx authz exec zeta_inbound_vote.json --from executer --gas=auto --gas-prices=0.1azeta --gas-adjustment=10 --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx authz exec zeta_outbound_vote.json --from executer --gas=auto --gas-prices=0.1azeta --gas-adjustment=10 --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx authz exec mario_outbound_vote.json --from executer --gas=auto --gas-prices=0.1azeta --gas-adjustment=10 --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block - - - - - diff --git a/standalone-network/cctx_authz/gas_price_voter_zeta.json b/standalone-network/cctx_authz/gas_price_voter_zeta.json deleted file mode 100644 index 6f92a9fb89..0000000000 --- a/standalone-network/cctx_authz/gas_price_voter_zeta.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgGasPriceVoter", - "creator": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "chain_id": "1337", - "price": "10000000000", - "block_number": "100", - "supply": "100" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "5183" - } - ], - "gas_limit": "51828", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/cctx_authz/mario_inbound_vote.json b/standalone-network/cctx_authz/mario_inbound_vote.json deleted file mode 100644 index a54198cf19..0000000000 --- a/standalone-network/cctx_authz/mario_inbound_vote.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx", - "creator": "zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50", - "sender": "0x96B05C238b99768F349135de0653b687f9c13fEE", - "sender_chain_id": "1337", - "receiver": "0x96B05C238b99768F349135de0653b687f9c13fEE", - "receiver_chain": "1337", - "amount": "10000000000000000000", - "message": "", - "in_tx_hash": "0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680", - "in_block_height": "100", - "gas_limit": "250000", - "coin_type": "Gas", - "tx_origin": "0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7", - "asset": "" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "16968" - } - ], - "gas_limit": "169672", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/cctx_authz/mario_outbound_vote.json b/standalone-network/cctx_authz/mario_outbound_vote.json deleted file mode 100644 index d2ff9a6696..0000000000 --- a/standalone-network/cctx_authz/mario_outbound_vote.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx", - "creator": "zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50", - "cctx_hash": "0xead687de84b3969b4c18480f197d2812e0acb83f851acc2830f70e94c85cef55", - "observed_outTx_hash": "hashout", - "observed_outTx_blockHeight": "1", - "zeta_minted": "7997428181981842964", - "status": "Success", - "outTx_chain": "1337", - "outTx_tss_nonce": "1", - "coin_type": "Gas" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "22450" - } - ], - "gas_limit": "224498", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/cctx_authz/nonce_voter_zeta.json b/standalone-network/cctx_authz/nonce_voter_zeta.json deleted file mode 100644 index ebf7884740..0000000000 --- a/standalone-network/cctx_authz/nonce_voter_zeta.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgNonceVoter", - "creator": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "chain_id": "1337", - "nonce": "1" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "13236" - } - ], - "gas_limit": "132360", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/cctx_authz/zeta_inbound_vote.json b/standalone-network/cctx_authz/zeta_inbound_vote.json deleted file mode 100644 index 69fb355b28..0000000000 --- a/standalone-network/cctx_authz/zeta_inbound_vote.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgVoteOnObservedInboundTx", - "creator": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "sender": "0x96B05C238b99768F349135de0653b687f9c13fEE", - "sender_chain_id": "1337", - "receiver": "0x96B05C238b99768F349135de0653b687f9c13fEE", - "receiver_chain": "1337", - "amount": "10000000000000000000", - "message": "", - "in_tx_hash": "0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680", - "in_block_height": "100", - "gas_limit": "250000", - "coin_type": "Gas", - "tx_origin": "0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7", - "asset": "" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "16948" - } - ], - "gas_limit": "169480", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/cctx_authz/zeta_outbound_vote.json b/standalone-network/cctx_authz/zeta_outbound_vote.json deleted file mode 100644 index d595d7506f..0000000000 --- a/standalone-network/cctx_authz/zeta_outbound_vote.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgVoteOnObservedOutboundTx", - "creator": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "cctx_hash": "0xead687de84b3969b4c18480f197d2812e0acb83f851acc2830f70e94c85cef55", - "observed_outTx_hash": "hashout", - "observed_outTx_blockHeight": "1", - "zeta_minted": "7997428181981842964", - "status": "Success", - "outTx_chain": "1337", - "outTx_tss_nonce": "1", - "coin_type": "Gas" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "22431" - } - ], - "gas_limit": "224306", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/change-observer-params.sh b/standalone-network/change-observer-params.sh deleted file mode 100644 index 4df238642f..0000000000 --- a/standalone-network/change-observer-params.sh +++ /dev/null @@ -1,2 +0,0 @@ -zetacored tx gov submit-proposal proposal_feemarket.json --from zeta --keyring-backend=test -b block --chain-id=localnet_101-1 --gas=auto --gas-prices=0.1azeta --gas-adjustment=1.5 --yes -zetacored tx gov vote 1 yes --from zeta --keyring-backend test --chain-id localnet_101-1 --yes --gas=auto --gas-prices=0.1azeta --gas-adjustment=1.5 \ No newline at end of file diff --git a/standalone-network/evm-init b/standalone-network/evm-init deleted file mode 100644 index 69980fbc09..0000000000 --- a/standalone-network/evm-init +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash - -set -x - -KEY1="alice" -KEY2="bob" -CHAINID="athens_8888-2" -MONIKER="localtestnet" -KEYRING="test" -KEYALGO="eth_secp256k1" -LOGLEVEL="info" -# to trace evm -TRACE="--trace" -#TRACE="" - -# validate dependencies are installed -command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; } - -# remove existing daemon and client -rm -rf ~/.zetacored* - -make install - -zetacored config keyring-backend $KEYRING --home ~/.zetacored -zetacored config chain-id $CHAINID --home ~/.zetacored - -# if $KEY exists it should be deleted -#zetacored keys add $KEY1 --keyring-backend $KEYRING --algo $KEYALGO -echo "Generating deterministic account - alice" -echo "race draft rival universe maid cheese steel logic crowd fork comic easy truth drift tomorrow eye buddy head time cash swing swift midnight borrow" | zetacored keys add alice --recover --keyring-backend $KEYRING --algo=secp256k1 --home ~/.zetacored - -echo "Generating deterministic account - bob" -echo "hand inmate canvas head lunar naive increase recycle dog ecology inhale december wide bubble hockey dice worth gravity ketchup feed balance parent secret orchard" | zetacored keys add bob --recover --keyring-backend $KEYRING --home ~/.zetacored - - -# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer) -zetacored init $MONIKER --chain-id $CHAINID --home ~/.zetacored - -# Change parameter token denominations to aphoton -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["evm"]["params"]["evm_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json - - -# Set gas limit in genesis -cat $HOME/.zetacored/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="100000000"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json - -# disable produce empty block -if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.zetacored/config/config.toml - else - sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.zetacored/config/config.toml -fi - -if [[ $1 == "pending" ]]; then - if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.zetacored/config/config.toml - sed -i '' 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.zetacored/config/config.toml - sed -i '' 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.zetacored/config/config.toml - sed -i '' 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.zetacored/config/config.toml - sed -i '' 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.zetacored/config/config.toml - sed -i '' 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.zetacored/config/config.toml - sed -i '' 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.zetacored/config/config.toml - sed -i '' 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.zetacored/config/config.toml - sed -i '' 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.zetacored/config/config.toml - sed -i '/\[api\]/,+3 s/enable = false/enable = true/' ~/.zetacored/config/app.toml - - else - sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.zetacored/config/config.toml - sed -i 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.zetacored/config/config.toml - sed -i 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.zetacored/config/config.toml - sed -i 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.zetacored/config/config.toml - sed -i 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.zetacored/config/config.toml - sed -i 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.zetacored/config/config.toml - sed -i 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.zetacored/config/config.toml - sed -i 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.zetacored/config/config.toml - sed -i 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.zetacored/config/config.toml - sed -i '/\[api\]/,+3 s/enable = false/enable = true/' ~/.zetacored/config/app.toml - - fi -fi - -# Allocate genesis accounts (cosmos formatted addresses) -zetacored add-genesis-account $KEY1 100000000000000000000000000azeta --keyring-backend $KEYRING --home ~/.zetacored -zetacored add-genesis-account $KEY2 1000000000000000000000azeta --keyring-backend $KEYRING --home ~/.zetacored - - -# Sign genesis transaction -zetacored gentx $KEY1 1000000000000000000000azeta --keyring-backend $KEYRING --chain-id $CHAINID --home ~/.zetacored - -# Collect genesis tx -zetacored collect-gentxs --home ~/.zetacored - -# Run this to ensure everything worked and that the genesis file is setup correctly -zetacored validate-genesis --home ~/.zetacored - -if [[ $1 == "pending" ]]; then - echo "pending mode is on, please wait for the first block committed." -fi - -# Start the node (remove the --pruning=nothing flag if historical queries are not needed) -zetacored start --pruning=nothing $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001azeta --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --home ~/.zetacored diff --git a/standalone-network/gov/gov.sh b/standalone-network/gov/gov.sh deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/standalone-network/gov/gov_observer_params_supported_chains.json b/standalone-network/gov/gov_observer_params_supported_chains.json deleted file mode 100644 index 6fc8ca324b..0000000000 --- a/standalone-network/gov/gov_observer_params_supported_chains.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "title": "Observer Param Change", - "description": "Update observer params", - "changes": [ - { - "subspace": "observer", - "key": "ObserverParams", - "value": [ - { - "chain": { - "chain_name": 6, - "chain_id": 5 - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": "true" - }, - { - "chain": { - "chain_name": 11, - "chain_id": 7001 - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": "true" - }, - { - "chain": { - "chain_name": 10, - "chain_id": 97 - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": "true" - }, - { - "chain": { - "chain_name": 12, - "chain_id": 18332 - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": "true" - }, - { - "chain": { - "chain_name": 7, - "chain_id": 80001 - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": "true" - } - ] - } - ], - "deposit": "10000000azeta" -} \ No newline at end of file diff --git a/standalone-network/group/add-observer.json b/standalone-network/group/add-observer.json deleted file mode 100644 index d3a0988d0c..0000000000 --- a/standalone-network/group/add-observer.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.observer.MsgAddObserver", - "creator": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", - "observer_address": "zeta1cv5nqpay7p5r2y9apkl97zute45d5je3f06e4j", - "zetaclient_grantee_pubkey": "zetapub1addwnpepq0ss57s6hdheyfgyymyvllcd6rfyqn6jayyvkuff8mrlvrluuktrwvcjfve", - "add_node_account_only": true - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/group/group.sh b/standalone-network/group/group.sh deleted file mode 100644 index 1e678f167e..0000000000 --- a/standalone-network/group/group.sh +++ /dev/null @@ -1,11 +0,0 @@ -zetacored tx group create-group-with-policy zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax group-metadata group-policy-metadata members.json policy.json --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx group submit-proposal proposal_keygen.json --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block --exec=1 -zetacored tx group vote 2 zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax VOTE_OPTION_YES metadata --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored tx group vote 2 zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2 VOTE_OPTION_YES metadata --from mario --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored q group proposal 2 -zetacored tx group exec 2 --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -zetacored q group group-policies-by-admin zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax - - -#zetacored q group group-policy-info zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73 -#zetacored q group group-policies-by-group 1 \ No newline at end of file diff --git a/standalone-network/group/members-updated.json b/standalone-network/group/members-updated.json deleted file mode 100644 index 93473242f1..0000000000 --- a/standalone-network/group/members-updated.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "members": [ - { - "address": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "weight": "1", - "metadata": "zetadmin" - }, - { - "address": "zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50", - "weight": "0", - "metadata": "marioadmin" - } - ] -} diff --git a/standalone-network/group/members.json b/standalone-network/group/members.json deleted file mode 100644 index f536aaa959..0000000000 --- a/standalone-network/group/members.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "members": [ - { - "address": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", - "weight": "1", - "metadata": "zetadmin" - }, - { - "address": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", - "weight": "1", - "metadata": "marioadmin" - } - ] -} diff --git a/standalone-network/group/msg.json b/standalone-network/group/msg.json deleted file mode 100644 index 1e1856a1c7..0000000000 --- a/standalone-network/group/msg.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgUpdatePermissionFlags", - "creator": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "isInboundEnabled": false - }, - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "40" - } - ], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/group/msg_fungible.json b/standalone-network/group/msg_fungible.json deleted file mode 100644 index 43b84eec2c..0000000000 --- a/standalone-network/group/msg_fungible.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/zetachain.zetacore.fungible.MsgDeployFungibleCoinZRC20", - "creator": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "ERC20": "test", - "foreignChain": "test", - "decimals": 2, - "name": "test", - "symbol": "test", - "coinType": "Gas", - "gasLimit": "0" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [ - { - "denom": "azeta", - "amount": "40" - } - ], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} diff --git a/standalone-network/group/policy.json b/standalone-network/group/policy.json deleted file mode 100644 index 7f21a03e09..0000000000 --- a/standalone-network/group/policy.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "@type": "/cosmos.group.v1.ThresholdDecisionPolicy", - "threshold": "1", - "windows": { - "voting_period": "20000s", - "min_execution_period": "0s" - } -} diff --git a/standalone-network/group/proposal.json b/standalone-network/group/proposal.json deleted file mode 100644 index e9b66b624e..0000000000 --- a/standalone-network/group/proposal.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "title": "Observer Param Change", - "description": "Change observer params", - "changes": [ - { - "subspace": "observer", - "key": "ObserverParams", - "value": [ - { - "chain": { - "chain_name": 12, - "chain_id": "18332" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 3, - "chain_id": "8332" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 4, - "chain_id": "137" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 7, - "chain_id": "80001" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 9, - "chain_id": "1001" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 10, - "chain_id": "97" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 5, - "chain_id": "56" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 1, - "chain_id": "1" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 6, - "chain_id": "5" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": true - }, - { - "chain": { - "chain_name": 14, - "chain_id": "1337" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": false - }, - { - "chain": { - "chain_name": 2, - "chain_id": "101" - }, - "ballot_threshold": "0.660000000000000000", - "min_observer_delegation": "10000000000.000000000000000000", - "is_supported": false - } - ] - } - ], - "deposit": "10000zeta" -} \ No newline at end of file diff --git a/standalone-network/group/proposal_add-observer.json b/standalone-network/group/proposal_add-observer.json deleted file mode 100644 index 996e168c2f..0000000000 --- a/standalone-network/group/proposal_add-observer.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "group_policy_address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "messages": [ - { - "@type": "/zetachain.zetacore.observer.MsgAddObserver", - "creator": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "observer_address": "zeta1cv5nqpay7p5r2y9apkl97zute45d5je3f06e4j", - "zetaclient_grantee_pubkey": "zetapub1addwnpepq0ss57s6hdheyfgyymyvllcd6rfyqn6jayyvkuff8mrlvrluuktrwvcjfve", - "add_node_account_only": true - } - ], - "metadata": "", - "proposers": ["zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax"] -} diff --git a/standalone-network/group/proposal_group.json b/standalone-network/group/proposal_group.json deleted file mode 100644 index 495f15cf0a..0000000000 --- a/standalone-network/group/proposal_group.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "group_policy_address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgUpdateKeygen", - "creator": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "block": 100 - } - ], - "metadata": "", - "proposers": ["zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax"] -} diff --git a/standalone-network/group/proposal_group_examples.json b/standalone-network/group/proposal_group_examples.json deleted file mode 100644 index a45bb3a9a2..0000000000 --- a/standalone-network/group/proposal_group_examples.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "group_policy_address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "messages": [ - { - "@type": "/zetachain.zetacore.crosschain.MsgUpdatePermissionFlags", - "creator": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "isInboundEnabled": false - }, - { - "@type": "/zetachain.zetacore.fungible.MsgDeployFungibleCoinZRC20", - "creator": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "ERC20": "test", - "foreignChain": "test", - "decimals": 2, - "name": "test", - "symbol": "test", - "coinType": "Gas", - "gasLimit": "0" - } - ], - "metadata": "", - "proposers": ["zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax"] -} diff --git a/standalone-network/group/proposal_keygen.json b/standalone-network/group/proposal_keygen.json deleted file mode 100644 index a155bec515..0000000000 --- a/standalone-network/group/proposal_keygen.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "group_policy_address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "messages": [ - { - "@type": "/zetachain.zetacore.observer.MsgUpdateKeygen", - "creator": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73", - "block": 400 - } - ], - "metadata": "", - "proposers": ["zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax"] -} diff --git a/standalone-network/init-multinode.sh b/standalone-network/init-multinode.sh deleted file mode 100755 index 0d66bc3dcf..0000000000 --- a/standalone-network/init-multinode.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env bash - -### chain init script for development purposes only ### -rm -rf ~/.zetacored -kill -9 $(lsof -ti:26657) - -NODES="node0 node1 node2 node3" - -genesis_addresses=() -for NODE in $NODES; do - mkdir -p $HOME/.zetacored/$NODE - zetacored init test --chain-id=localnet_101-1 -o --home=$HOME/.zetacored/$NODE - zetacored keys add zeta --algo secp256k1 --keyring-backend=test --home=$HOME/.zetacored/$NODE - zetacored keys add mario --algo secp256k1 --keyring-backend=test --home=$HOME/.zetacored/$NODE - genesis_addresses+=$(zetacored keys show zeta -a --keyring-backend=test --home=$HOME/.zetacored/$NODE) - genesis_addresses+=" " - genesis_addresses+=$(zetacored keys show mario -a --keyring-backend=test --home=$HOME/.zetacored/$NODE) - genesis_addresses+=" " -done - -for address in $genesis_addresses; do - zetacored add-genesis-account $address 500000000000000000000000000000000azeta --keyring-backend=test --home=$HOME/.zetacored/node0 -done - -zetacored gentx zeta 10000000000000000azeta --chain-id=localnet_101-1 --keyring-backend=test --home=$HOME/.zetacored/node0 -for NODE in $NODES; do - if [ $NODE != "node0" ] - then - rm -rf $HOME/.zetacored/$NODE/config/genesis.json - cp $HOME/.zetacored/node0/config/genesis.json $HOME/.zetacored/$NODE/config/ - zetacored gentx zeta 10000000000000000azeta --chain-id=localnet_101-1 --keyring-backend=test --home=$HOME/.zetacored/$NODE - cp $HOME/.zetacored/$NODE/config/gentx/*.json $HOME/.zetacored/node0/config/gentx/ - fi -done - - -cat $HOME/.zetacored/node0/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="azeta"' > $HOME/.zetacored/node0/config/tmp_genesis.json && mv $HOME/.zetacored/node0/config/tmp_genesis.json $HOME/.zetacored/node0/config/genesis.json -cat $HOME/.zetacored/node0/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="azeta"' > $HOME/.zetacored/node0/config/tmp_genesis.json && mv $HOME/.zetacored/node0/config/tmp_genesis.json $HOME/.zetacored/node0/config/genesis.json -cat $HOME/.zetacored/node0/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="azeta"' > $HOME/.zetacored/node0/config/tmp_genesis.json && mv $HOME/.zetacored/node0/config/tmp_genesis.json $HOME/.zetacored/node0/config/genesis.json -cat $HOME/.zetacored/node0/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="azeta"' > $HOME/.zetacored/node0/config/tmp_genesis.json && mv $HOME/.zetacored/node0/config/tmp_genesis.json $HOME/.zetacored/node0/config/genesis.json -cat $HOME/.zetacored/node0/config/genesis.json | jq '.app_state["evm"]["params"]["evm_denom"]="azeta"' > $HOME/.zetacored/node0/config/tmp_genesis.json && mv $HOME/.zetacored/node0/config/tmp_genesis.json $HOME/.zetacored/node0/config/genesis.json -cat $HOME/.zetacored/node0/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME/.zetacored/node0/config/tmp_genesis.json && mv $HOME/.zetacored/node0/config/tmp_genesis.json $HOME/.zetacored/node0/config/genesis.json - -zetacored collect-gentxs --home=$HOME/.zetacored/node0 -zetacored validate-genesis --home=$HOME/.zetacored/node0 -for NODE in $NODES; do - if [ $NODE != "node0" ] - then - rm -rf $HOME/.zetacored/$NODE/config/genesis.json - cp $HOME/.zetacored/node0/config/genesis.json $HOME/.zetacored/$NODE/config/ - fi -done - -killall zetacored - - -p2p=27655 -grpc=9085 -grpcweb=9093 -tcp=27659 -rpcladdr=2665 -jsonrpc=8545 -ws=9545 - -for NODE in $NODES; do - echo "Starting $NODE" - zetacored start \ - --minimum-gas-prices=0.0001azeta \ - --home $HOME/.zetacored/$NODE \ - --p2p.laddr 0.0.0.0:$p2p \ - --grpc.address 0.0.0.0:$grpc \ - --grpc-web.address 0.0.0.0:$grpcweb \ - --address tcp://0.0.0.0:$tcp \ - --json-rpc.address 0.0.0.0:$jsonrpc \ - --json-rpc.ws-address 0.0.0.0:$ws \ - --rpc.laddr tcp://127.0.0.1:$rpcladdr >> $HOME/.zetacored/$NODE/abci.log 2>&1 & - ((p2p=p2p+1)) - ((grpc=grpc+1)) - ((grpcweb=grpcweb+1)) - ((tcp=tcp+1)) - ((rpcladdr=rpcladdr+1)) - ((jsonrpc=jsonrpc+1)) - ((ws=ws+1)) -done - -# TODO ADD peers to config \ No newline at end of file diff --git a/standalone-network/init.sh b/standalone-network/init.sh deleted file mode 100755 index ca932c2a21..0000000000 --- a/standalone-network/init.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -CHAINID="localnet_101-1" -KEYRING="test" -export DAEMON_HOME=$HOME/.zetacored -export DAEMON_NAME=zetacored - -### chain init script for development purposes only ### -rm -rf ~/.zetacored -kill -9 $(lsof -ti:26657) -zetacored config keyring-backend $KEYRING --home ~/.zetacored -zetacored config chain-id $CHAINID --home ~/.zetacored -echo "race draft rival universe maid cheese steel logic crowd fork comic easy truth drift tomorrow eye buddy head time cash swing swift midnight borrow" | zetacored keys add zeta --algo=secp256k1 --recover --keyring-backend=$KEYRING -echo "hand inmate canvas head lunar naive increase recycle dog ecology inhale december wide bubble hockey dice worth gravity ketchup feed balance parent secret orchard" | zetacored keys add mario --algo secp256k1 --recover --keyring-backend=$KEYRING -echo "lounge supply patch festival retire duck foster decline theme horror decline poverty behind clever harsh layer primary syrup depart fantasy session fossil dismiss east" | zetacored keys add executer_zeta --recover --keyring-backend=$KEYRING --algo secp256k1 -echo "debris dumb among crew celery derive judge spoon road oyster dad panic adult song attack net pole merge mystery pig actual penalty neither peasant"| zetacored keys add executer_mario --algo=secp256k1 --recover --keyring-backend=$KEYRING - -zetacored init Zetanode-Localnet --chain-id=$CHAINID - -#Set config to use azeta -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["evm"]["params"]["evm_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -contents="$(jq '.app_state.gov.voting_params.voting_period = "10s"' $DAEMON_HOME/config/genesis.json)" && \ -echo "${contents}" > $DAEMON_HOME/config/genesis.json -sed -i '/\[api\]/,+3 s/enable = false/enable = true/' ~/.zetacored/config/app.toml - - -zetacored add-observer-list standalone-network/observers.json --keygen-block=5 -zetacored gentx zeta 1000000000000000000000azeta --chain-id=$CHAINID --keyring-backend=$KEYRING - - - -echo "Collecting genesis txs..." -zetacored collect-gentxs - -echo "Validating genesis file..." -zetacored validate-genesis - diff --git a/standalone-network/observers-complete.json b/standalone-network/observers-complete.json deleted file mode 100644 index b94d885193..0000000000 --- a/standalone-network/observers-complete.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "ObserverAddress": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "ZetaClientGranteeAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "StakingGranteeAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "StakingMaxTokens": "100000000", - "StakingValidatorAllowList": [ - "zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq" - ], - "SpendGranteeAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "SpendMaxTokens": "100000000", - "GovGranteeAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "NodeAccount": { - "creator": "zeta1syavy2npfyt9tcncdtsdzf7kny9lh777heefxk", - "tssSignerAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "pubkeySet": { - "secp256k1": "zetapub1addwnpepqggtjvkmj6apcqr6ynyc5edxf2mpf5fxp2d3kwupemxtfwvg6gm7qv79fw0" - } - } - }, - { - "ObserverAddress": "zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50", - "ZetaClientGranteeAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "StakingGranteeAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "StakingMaxTokens": "100000000", - "StakingValidatorAllowList": [ - "zetavaloper1syavy2npfyt9tcncdtsdzf7kny9lh777nep4tq" - ], - "SpendGranteeAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "SpendMaxTokens": "100000000", - "GovGranteeAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "NodeAccount": { - "creator": "zeta1l7hypmqk2yc334vc6vmdwzp5sdefygj2w5yj50", - "tssSignerAddress": "zeta19wzjdtah4kl2vh77jks68cyy5gpjyurqltys99", - "pubkeySet": { - "secp256k1": "zetapub1addwnpepqggtjvkmj6apcqr6ynyc5edxf2mpf5fxp2d3kwupemxtfwvg6gm7qv79fw0" - } - } - } -] \ No newline at end of file diff --git a/standalone-network/observers.json b/standalone-network/observers.json deleted file mode 100644 index f39019ea02..0000000000 --- a/standalone-network/observers.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "IsObserver": "y", - "ObserverAddress": "zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax", - "ZetaClientGranteeAddress": "zeta10up34mvwjhjd9xkq56fwsf0k75vtg287uav69n", - "ZetaClientGranteePubKey": "zetapub1addwnpepqtlu7fykuh875xjckz4mn4x0mzc25rrqk5qne7mrwxqmatgllv3nx6lrkdp" - }, - { - "IsObserver": "y", - "ObserverAddress": "zeta1f203dypqg5jh9hqfx0gfkmmnkdfuat3jr45ep2", - "ZetaClientGranteeAddress": "zeta1unzpyll3tmutf0r8sqpxpnj46vtdr59mw8qepx", - "ZetaClientGranteePubKey": "zetapub1addwnpepqwy5pmg39regpq0gkggxehmfm8hwmxxw94sch7qzh4smava0szs07kk5045" - } -] \ No newline at end of file diff --git a/standalone-network/os_info/os1.json b/standalone-network/os_info/os1.json deleted file mode 100644 index c613e61cc7..0000000000 --- a/standalone-network/os_info/os1.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "ObserverAddress": "zeta1n48d8es90mezvc33srhgedjjuk3t69zzp7v6d4", - "ZetaClientGranteeAddress": "zeta1cjrr268h72a8fpc3870r437r5e5e8aumlwvhe0", - "ZetaClientGranteePubKey": "zetapub1addwnpepqg2l4m4n5ywn470c4qwkj3fy632rdug0hmnygy97ha5t8pcgnq78zk9fke7" -} \ No newline at end of file diff --git a/standalone-network/os_info/os2.json b/standalone-network/os_info/os2.json deleted file mode 100644 index c613e61cc7..0000000000 --- a/standalone-network/os_info/os2.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "ObserverAddress": "zeta1n48d8es90mezvc33srhgedjjuk3t69zzp7v6d4", - "ZetaClientGranteeAddress": "zeta1cjrr268h72a8fpc3870r437r5e5e8aumlwvhe0", - "ZetaClientGranteePubKey": "zetapub1addwnpepqg2l4m4n5ywn470c4qwkj3fy632rdug0hmnygy97ha5t8pcgnq78zk9fke7" -} \ No newline at end of file diff --git a/standalone-network/proposal.json b/standalone-network/proposal.json deleted file mode 100644 index da505d13cb..0000000000 --- a/standalone-network/proposal.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "title": "Observer Param Change", - "description": "Update policy address", - "changes": [ - { - "subspace": "observer", - "key": "AdminParams", - "value": [ - { - "policy_type": 0, - "address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73" - }, - { - "policy_type": 1, - "address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73" - }, - { - "policy_type": 2, - "address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73" - }, - { - "policy_type": 3, - "address": "zeta1afk9zr2hn2jsac63h4hm60vl9z3e5u69gndzf7c99cqge3vzwjzsxn0x73" - } - ] - } - ], - "deposit": "10000000azeta" -} \ No newline at end of file diff --git a/standalone-network/proposal_feemarket.json b/standalone-network/proposal_feemarket.json deleted file mode 100644 index 1ec114d19a..0000000000 --- a/standalone-network/proposal_feemarket.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "messages": [ - { - "@type": "/ethermint.feemarket.v1.MsgUpdateParams", - "authority": "zeta10d07y265gmmuvt4z0w9aw880jnsr700jvxasvr", - "params": { - "base_fee": "7", - "min_gas_price" : "100000000000000", - "base_fee_change_denominator": "8" - } - } - ], - "metadata" : "some metadata", - "deposit": "10000000azeta" -} \ No newline at end of file diff --git a/standalone-network/run-zetaclient.sh b/standalone-network/run-zetaclient.sh deleted file mode 100644 index 5ad3375ea9..0000000000 --- a/standalone-network/run-zetaclient.sh +++ /dev/null @@ -1,2 +0,0 @@ -zetaclientd init --chain-id localnet_101-1 --operator zeta13c7p3xrhd6q2rx3h235jpt8pjdwvacyw6twpax --hotkey=zeta --public-ip=0.0.0.0 -zetaclientd start \ No newline at end of file diff --git a/standalone-network/run.sh b/standalone-network/run.sh deleted file mode 100755 index 42b76cfce0..0000000000 --- a/standalone-network/run.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -CHAINID="localnet_101-1" -KEYRING="test" -HOSTNAME=$(hostname) -signer="zeta" - - -killall zetacored -zetacored start --trace \ ---minimum-gas-prices=0.0001azeta \ ---json-rpc.api eth,txpool,personal,net,debug,web3,miner \ ---api.enable >> ~/.zetacored/zetacored.log 2>&1 & \ -#>> "$HOME"/.zetacored/zetanode.log 2>&1 & \ - -#--home ~/.zetacored \ -#--p2p.laddr 0.0.0.0:27655 \ -#--grpc.address 0.0.0.0:9096 \ -#--grpc-web.address 0.0.0.0:9093 \ -#--address tcp://0.0.0.0:27659 \ -#--rpc.laddr tcp://127.0.0.1:26657 \ -#--pruning custom \ -#--pruning-keep-recent 54000 \ -#--pruning-interval 10 \ -#--min-retain-blocks 54000 \ -#--state-sync.snapshot-interval 14400 \ -#--state-sync.snapshot-keep-recent 3 - -#echo "--> Submitting proposal to update admin policies " -#sleep 7 -#zetacored tx gov submit-legacy-proposal param-change standalone-network/proposal.json --from $signer --gas=auto --gas-adjustment=1.5 --gas-prices=0.001azeta --chain-id=$CHAINID --keyring-backend=$KEYRING -y --broadcast-mode=block -#echo "--> Submitting vote for proposal" -#sleep 7 -#zetacored tx gov vote 1 yes --from $signer --keyring-backend $KEYRING --chain-id $CHAINID --yes --fees=40azeta --broadcast-mode=block -tail -f ~/.zetacored/zetacored.log - diff --git a/standalone-network/update_core_params/new_params.json b/standalone-network/update_core_params/new_params.json deleted file mode 100644 index 2acc3a571e..0000000000 --- a/standalone-network/update_core_params/new_params.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "confirmation_count" : 10, - "gas_price_ticker" : 10, - "in_tx_ticker": 10, - "out_tx_ticker": 10, - "watch_utxo_ticker": 10, - "chain_id" : 101, - "zeta_token_contract_address" : "", - "connector_contract_address" : "", - "erc20_custody_contract_address" : "" -} \ No newline at end of file diff --git a/standalone-network/update_core_params/update-params.sh b/standalone-network/update_core_params/update-params.sh deleted file mode 100755 index 3cca5583aa..0000000000 --- a/standalone-network/update_core_params/update-params.sh +++ /dev/null @@ -1,2 +0,0 @@ -zetacored tx observer update-client-params 101 new_params.json --from zeta --fees=40azeta --chain-id=localnet_101-1 --keyring-backend=test -y --broadcast-mode=block -#zetacored tx observer update-client-params 101 new_params.json --from val_grantee_observer --fees=40azeta --chain-id=athens_101-1 --keyring-backend=test -y --broadcast-mode=block \ No newline at end of file diff --git a/standalone-network/update_voting_period/proposal.json b/standalone-network/update_voting_period/proposal.json deleted file mode 100644 index 34d1c709b6..0000000000 --- a/standalone-network/update_voting_period/proposal.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "title": "Gov Param Change", - "description": "Update voting period", - "changes": [ - { - "subspace": "gov", - "key": "votingparams", - "value": { - "voting_period": "86400" - } - }, - { - "subspace": "gov", - "key": "depositparams", - "value": { - "min_deposit": [ - { - "denom": "azeta", - "amount": "1000000" - } - ], - "max_deposit_period": "86400" - } - } - ], - "deposit": "1000000zeta" -} \ No newline at end of file diff --git a/standalone-network/update_voting_period/update_voting_period.sh b/standalone-network/update_voting_period/update_voting_period.sh deleted file mode 100644 index 417b0d3737..0000000000 --- a/standalone-network/update_voting_period/update_voting_period.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -CHAINID="atheens_7001-1" -KEYRING="test" -HOSTNAME=$(hostname) -signer="operator" -proposal_count=10 - -#PID=1 - -signerAddress=$(zetacored keys show $signer -a --keyring-backend=test) -echo "signerAddress: $signerAddress" -for (( i = 0; i < proposal_count; i++ )); do - zetacored tx gov submit-legacy-proposal param-change proposal.json --from $signer --gas=auto --gas-adjustment=1.5 --gas-prices=0.001azeta --chain-id=$CHAINID --keyring-backend=$KEYRING -y --broadcast-mode=block -done - - -#zetacored tx gov vote "$PID" yes --from $signer --keyring-backend $KEYRING --chain-id $CHAINID --yes --fees=40azeta --broadcast-mode=block \ No newline at end of file diff --git a/standalone-network/upgrade-integration-client.sh b/standalone-network/upgrade-integration-client.sh deleted file mode 100755 index e3bd6f73c0..0000000000 --- a/standalone-network/upgrade-integration-client.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash - - -clibuilder() -{ - echo "" - echo "Usage: $0 -u UpgradeName -c CurrentBinary -n NewBinary" - echo -e "\t-u Name of the upgrade [Must match a handler defined in setup-handlers.go in NewBinary]" - echo -e "\t-c Branch name for old binary (Upgrade From)" - echo -e "\t-n Branch name for new binary (Upgrade To)" - exit 1 # Exit script after printing help -} - -while getopts "u:c:n:" opt -do - case "$opt" in - u ) UpgradeName="$OPTARG" ;; - c ) CurrentBinary="$OPTARG" ;; - n ) NewBinary="$OPTARG" ;; - ? ) clibuilder ;; # Print cliBuilder in case parameter is non-existent - esac -done - -if [ -z "$UpgradeName" ] || [ -z "$CurrentBinary" ] || [ -z "$NewBinary" ] -then - echo "Some or all of the parameters are empty"; - clibuilder -fi - - -export DAEMON_HOME=$HOME/.zetacore -export DAEMON_NAME=zetacored -export DAEMON_ALLOW_DOWNLOAD_BINARIES=true -export DAEMON_RESTART_AFTER_UPGRADE=true -export CLIENT_DAEMON_NAME=zetaclientd -export CLIENT_DAEMON_ARGS="-enable-chains,GOERLI,-val,zeta" - -make clean -rm -rf ~/.zetacore -rm -rf zetacore.log -rm -rf ZetaClient.log - -rm -rf $GOPATH/bin/zetacored -rm -rf $GOPATH/bin/old/zetacored -rm -rf $GOPATH/bin/new/zetacored - -# Setup old binary and start chain -mkdir -p $GOPATH/bin/old -mkdir -p $GOPATH/bin/new - -git checkout $CurrentBinary -make install -cp $GOPATH/bin/zetacored $GOPATH/bin/old/ -cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/ -zetacored init test --chain-id=localnet -o - -echo "Generating deterministic account - zeta" -echo "race draft rival universe maid cheese steel logic crowd fork comic easy truth drift tomorrow eye buddy head time cash swing swift midnight borrow" | zetacored keys add zeta --recover --keyring-backend=test - -echo "Generating deterministic account - mario" -echo "hand inmate canvas head lunar naive increase recycle dog ecology inhale december wide bubble hockey dice worth gravity ketchup feed balance parent secret orchard" | zetacored keys add mario --recover --keyring-backend=test - - -zetacored add-genesis-account $(zetacored keys show zeta -a --keyring-backend=test) 500000000000000000000000000000000stake --keyring-backend=test -zetacored add-genesis-account $(zetacored keys show mario -a --keyring-backend=test) 500000000000000000000000000000000stake --keyring-backend=test - -zetacored gentx zeta 1000000000000000000000000stake --chain-id=localnet --keyring-backend=test - -echo "Collecting genesis txs..." -zetacored collect-gentxs - -echo "Validating genesis file..." -zetacored validate-genesis - - -mkdir -p $DAEMON_HOME/cosmovisor/genesis/bin -mkdir -p $DAEMON_HOME/cosmovisor/upgrades/$UpgradeName/bin - - -# Setup new binary -git checkout $NewBinary -rm -rf $GOPATH/bin/zetacored -rm -rf $GOPATH/bin/zetaclientd - -make install -cp $GOPATH/bin/zetacored $GOPATH/bin/new/ -cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/ - - -# Setup cosmovisor -cp $GOPATH/bin/old/zetacored $DAEMON_HOME/cosmovisor/genesis/bin/ -cp $GOPATH/bin/new/zetacored $DAEMON_HOME/cosmovisor/upgrades/$UpgradeName/bin/ -cp $GOPATH/bin/old/zetaclientd $DAEMON_HOME/cosmovisor/genesis/bin/ -cp $GOPATH/bin/new/zetaclientd $DAEMON_HOME/cosmovisor/upgrades/$UpgradeName/bin/ - -chmod +x $DAEMON_HOME/cosmovisor/genesis/bin/zetacored -chmod +x $DAEMON_HOME/cosmovisor/genesis/bin/zetaclientd -chmod +x $DAEMON_HOME/cosmovisor/upgrades/$UpgradeName/bin/zetacored -chmod +x $DAEMON_HOME/cosmovisor/upgrades/$UpgradeName/bin/zetaclientd - -contents="$(jq '.app_state.gov.voting_params.voting_period = "10s"' $DAEMON_HOME/config/genesis.json)" && \ -echo "${contents}" > $DAEMON_HOME/config/genesis.json - -# Add state data here if required - -cosmovisor start --home ~/.zetacore/ --p2p.laddr 0.0.0.0:27655 --grpc.address 0.0.0.0:9096 --grpc-web.address 0.0.0.0:9093 --address tcp://0.0.0.0:27659 --rpc.laddr tcp://127.0.0.1:26657 >> zetanode.log 2>&1 & - -sleep 7 -zetacored tx gov submit-proposal software-upgrade $UpgradeName --from zeta --deposit 100000000stake --upgrade-height 10 --title $UpgradeName --description $UpgradeName --keyring-backend test --chain-id localnet --yes -sleep 7 -zetacored tx gov vote 1 yes --from zeta --keyring-backend test --chain-id localnet --yes -clear -sleep 7 -zetacored query gov proposal 1 - -tail -f zetanode.log - diff --git a/standalone-network/upgrade-integration-download.sh b/standalone-network/upgrade-integration-download.sh deleted file mode 100755 index bea2fb717e..0000000000 --- a/standalone-network/upgrade-integration-download.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -kill -9 $(lsof -ti:26657) -export DAEMON_HOME=$HOME/.zetacore -export DAEMON_NAME=zetacored -export DAEMON_ALLOW_DOWNLOAD_BINARIES=true -export DAEMON_RESTART_AFTER_UPGRADE=true -export CLIENT_DAEMON_NAME=zetaclientd -export CLIENT_DAEMON_ARGS="-enable-chains,GOERLI,-val,zeta" -export DAEMON_DATA_BACKUP_DIR=$DAEMON_HOME -export CLIENT_SKIP_UPGRADE=true -export CLIENT_START_PROCESS=true -export UNSAFE_SKIP_BACKUP=true - -rm -rf ~/.zetacore -rm -rf zetacore.log -rm -rf zetanode.log -rm -rf zetacore-debug.log -rm -rf GOERLI_debug.log -rm -rf ZetaClient.log - -make install -# Genesis -mkdir -p $DAEMON_HOME/cosmovisor/genesis/bin -#mkdir -p $DAEMON_HOME/cosmovisor/upgrades/0.2.1/bin -cp $GOPATH/bin/zetacored $DAEMON_HOME/cosmovisor/genesis/bin -cp $GOPATH/bin/zetaclientd $DAEMON_HOME/cosmovisor/genesis/bin - - -chmod +x $DAEMON_HOME/cosmovisor/genesis/bin/zetacored -chmod +x $DAEMON_HOME/cosmovisor/genesis/bin/zetaclientd - -zetacored init test --chain-id=localnet -o -echo "race draft rival universe maid cheese steel logic crowd fork comic easy truth drift tomorrow eye buddy head time cash swing swift midnight borrow" | zetacored keys add zeta --recover --keyring-backend=test -echo "hand inmate canvas head lunar naive increase recycle dog ecology inhale december wide bubble hockey dice worth gravity ketchup feed balance parent secret orchard" | zetacored keys add mario --recover --keyring-backend=test -zetacored add-genesis-account $(zetacored keys show zeta -a --keyring-backend=test) 500000000000000000000000000000000stake --keyring-backend=test -zetacored add-genesis-account $(zetacored keys show mario -a --keyring-backend=test) 500000000000000000000000000000000stake --keyring-backend=test -zetacored gentx zeta 1000000000000000000000000stake --chain-id=localnet --keyring-backend=test -zetacored collect-gentxs -zetacored validate-genesis - - -contents="$(jq '.app_state.gov.voting_params.voting_period = "10s"' $DAEMON_HOME/config/genesis.json)" && \ -echo "${contents}" > $DAEMON_HOME/config/genesis.json - - -cosmovisor start --home ~/.zetacore/ --p2p.laddr 0.0.0.0:27655 --grpc.address 0.0.0.0:9096 --grpc-web.address 0.0.0.0:9093 --address tcp://0.0.0.0:27659 --rpc.laddr tcp://127.0.0.1:26657 >> zetanode.log 2>&1 & - -sleep 7 -printf "Raising the governance proposal:\n" -zetacored tx gov submit-proposal software-upgrade 0.2.1 \ - --from zeta \ - --deposit 10000000000000000000stake \ - --upgrade-height 6 \ - --upgrade-info '{"binaries":{"zetaclientd-darwin/arm64":"https://filebin.net/4awhitgraq8eenpd/zetaclientd","zetacored-darwin/arm64":"https://filebin.net/4awhitgraq8eenpd/zetacored"}}' \ - --description "test-upgrade" \ - --title "test-upgrade" \ - --from zeta \ - --keyring-backend test \ - --chain-id localnet \ - --yes -sleep 7 -zetacored tx gov vote 1 yes --from zeta --keyring-backend test --chain-id localnet --yes -clear -sleep 10 -zetacored query gov proposal 1 -tail -f zetanode.log \ No newline at end of file diff --git a/standalone-network/upgrade-integration.sh b/standalone-network/upgrade-integration.sh deleted file mode 100755 index 9d421eeaec..0000000000 --- a/standalone-network/upgrade-integration.sh +++ /dev/null @@ -1,119 +0,0 @@ -clibuilder() -{ - echo "" - echo "Usage: $0 -u UpgradeName -c CurrentBinary -n NewBinary" - echo -e "\t-u Name of the upgrade [Must match a handler defined in setup-handlers.go in NewBinary]" - echo -e "\t-c Branch name for old binary (Upgrade From)" - echo -e "\t-n Branch name for new binary (Upgrade To)" - exit 1 # Exit script after printing help -} - -while getopts "u:c:n:" opt -do - case "$opt" in - u ) UpgradeName="$OPTARG" ;; - c ) CurrentBinary="$OPTARG" ;; - n ) NewBinary="$OPTARG" ;; - ? ) clibuilder ;; # Print cliBuilder in case parameter is non-existent - esac -done - -if [ -z "$UpgradeName" ] || [ -z "$CurrentBinary" ] || [ -z "$NewBinary" ] -then - echo "Some or all of the parameters are empty"; - clibuilder -fi - -KEYRING=test -CHAINID="localnet_101-1" -export DAEMON_HOME=$HOME/.zetacored -export DAEMON_NAME=zetacored -export DAEMON_ALLOW_DOWNLOAD_BINARIES=true -export DAEMON_RESTART_AFTER_UPGRADE=true -export CLIENT_DAEMON_NAME=zetaclientd -export CLIENT_DAEMON_ARGS="-enable-chains,GOERLI,-val,zeta" -export DAEMON_DATA_BACKUP_DIR=$DAEMON_HOME -export CLIENT_SKIP_UPGRADE=true -export CLIENT_START_PROCESS=false -export UNSAFE_SKIP_BACKUP=true - -make clean -rm -rf ~/.zetacore -rm -rf zetacore.log - -rm -rf $GOPATH/bin/zetacored -rm -rf $GOPATH/bin/old/zetacored -rm -rf $GOPATH/bin/new/zetacored - -# Setup old binary and start chain -mkdir -p $GOPATH/bin/old -mkdir -p $GOPATH/bin/new - -git checkout $CurrentBinary -git pull -make install-zetacore -cp $GOPATH/bin/zetacored $GOPATH/bin/old/ -zetacored init test --chain-id=localnet_101-1 -o -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.app_state["evm"]["params"]["evm_denom"]="azeta"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -cat $HOME/.zetacored/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json -echo "Generating deterministic account - zeta" -echo "race draft rival universe maid cheese steel logic crowd fork comic easy truth drift tomorrow eye buddy head time cash swing swift midnight borrow" | zetacored keys add zeta --algo secp256k1 --recover --keyring-backend=test -echo "Generating deterministic account - mario" -echo "hand inmate canvas head lunar naive increase recycle dog ecology inhale december wide bubble hockey dice worth gravity ketchup feed balance parent secret orchard" | zetacored keys add mario --algo secp256k1 --recover --keyring-backend=test - - - -zetacored add-observer-list standalone-network/observers.json --keygen-block=0 --tss-pubkey="tsspubkey" -zetacored gentx zeta 1000000000000000000000azeta --chain-id=$CHAINID --keyring-backend=$KEYRING - -echo "Collecting genesis txs..." -zetacored collect-gentxs - -echo "Validating genesis file..." -zetacored validate-genesis - - -mkdir -p $DAEMON_HOME/cosmovisor/genesis/bin -mkdir -p $DAEMON_HOME/cosmovisor/upgrades/$UpgradeName/bin - - -# Setup new binary -git checkout $NewBinary -git pull -rm -rf $GOPATH/bin/zetacored -make install -cp $GOPATH/bin/zetacored $GOPATH/bin/new/ - - -# Setup cosmovisor -# Genesis -cp $GOPATH/bin/old/zetacored $DAEMON_HOME/cosmovisor/genesis/bin -cp $GOPATH/bin/zetaclientd $DAEMON_HOME/cosmovisor/genesis/bin - -#Upgrades -cp $GOPATH/bin/new/zetacored $DAEMON_HOME/cosmovisor/upgrades/$UpgradeName/bin/ - -#Permissions -chmod +x $DAEMON_HOME/cosmovisor/genesis/bin/zetacored -chmod +x $DAEMON_HOME/cosmovisor/genesis/bin/zetaclientd -chmod +x $DAEMON_HOME/cosmovisor/upgrades/$UpgradeName/bin/zetacored - -contents="$(jq '.app_state.gov.voting_params.voting_period = "10s"' $DAEMON_HOME/config/genesis.json)" && \ -echo "${contents}" > $DAEMON_HOME/config/genesis.json - -# Add state data here if required - -cosmovisor start --home ~/.zetacored/ --p2p.laddr 0.0.0.0:27655 --grpc.address 0.0.0.0:9096 --grpc-web.address 0.0.0.0:9093 --address tcp://0.0.0.0:27659 --rpc.laddr tcp://127.0.0.1:26657 >> zetanode.log 2>&1 & -sleep 8 -zetacored tx gov submit-legacy-proposal software-upgrade $UpgradeName --from zeta --deposit 100000000azeta --upgrade-height 6 --title $UpgradeName --description $UpgradeName --keyring-backend test --chain-id localnet_101-1 --yes --no-validate --fees=200azeta --broadcast-mode block -sleep 8 -zetacored tx gov vote 1 yes --from zeta --keyring-backend test --chain-id localnet_101-1 --yes --fees=200azeta --broadcast-mode block -clear -sleep 7 -zetacored query gov proposal 1 - -tail -f zetanode.log diff --git a/testutil/keeper/fungible.go b/testutil/keeper/fungible.go index b4caebbc88..0ef4e981f4 100644 --- a/testutil/keeper/fungible.go +++ b/testutil/keeper/fungible.go @@ -8,7 +8,6 @@ import ( 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/stretchr/testify/assert" "github.com/stretchr/testify/require" tmdb "github.com/tendermint/tm-db" fungiblemocks "github.com/zeta-chain/zetacore/testutil/keeper/mocks/fungible" @@ -149,24 +148,24 @@ func FungibleKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, Zeta func GetFungibleAccountMock(t testing.TB, keeper *keeper.Keeper) *fungiblemocks.FungibleAccountKeeper { fak, ok := keeper.GetAuthKeeper().(*fungiblemocks.FungibleAccountKeeper) - assert.True(t, ok) + require.True(t, ok) return fak } func GetFungibleBankMock(t testing.TB, keeper *keeper.Keeper) *fungiblemocks.FungibleBankKeeper { fbk, ok := keeper.GetBankKeeper().(*fungiblemocks.FungibleBankKeeper) - assert.True(t, ok) + require.True(t, ok) return fbk } func GetFungibleObserverMock(t testing.TB, keeper *keeper.Keeper) *fungiblemocks.FungibleObserverKeeper { fok, ok := keeper.GetObserverKeeper().(*fungiblemocks.FungibleObserverKeeper) - assert.True(t, ok) + require.True(t, ok) return fok } func GetFungibleEVMMock(t testing.TB, keeper *keeper.Keeper) *fungiblemocks.FungibleEVMKeeper { fek, ok := keeper.GetEVMKeeper().(*fungiblemocks.FungibleEVMKeeper) - assert.True(t, ok) + require.True(t, ok) return fek } diff --git a/testutil/network/genesis_state.go b/testutil/network/genesis_state.go index d74b5c4c8f..12ae9f9d50 100644 --- a/testutil/network/genesis_state.go +++ b/testutil/network/genesis_state.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" cmdcfg "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/testutil/nullify" @@ -22,7 +22,7 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage // Cross-chain genesis state var crossChainGenesis types.GenesisState - assert.NoError(t, codec.UnmarshalJSON(genesisState[types.ModuleName], &crossChainGenesis)) + require.NoError(t, codec.UnmarshalJSON(genesisState[types.ModuleName], &crossChainGenesis)) nodeAccountList := make([]*observertypes.NodeAccount, len(observerList)) for i, operator := range observerList { nodeAccountList[i] = &observertypes.NodeAccount{ @@ -32,28 +32,28 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage } crossChainGenesis.Params.Enabled = true - assert.NoError(t, crossChainGenesis.Validate()) + require.NoError(t, crossChainGenesis.Validate()) crossChainGenesisBz, err := codec.MarshalJSON(&crossChainGenesis) - assert.NoError(t, err) + require.NoError(t, err) // EVM genesis state var evmGenesisState evmtypes.GenesisState - assert.NoError(t, codec.UnmarshalJSON(genesisState[evmtypes.ModuleName], &evmGenesisState)) + require.NoError(t, codec.UnmarshalJSON(genesisState[evmtypes.ModuleName], &evmGenesisState)) evmGenesisState.Params.EvmDenom = cmdcfg.BaseDenom - assert.NoError(t, evmGenesisState.Validate()) + require.NoError(t, evmGenesisState.Validate()) evmGenesisBz, err := codec.MarshalJSON(&evmGenesisState) - assert.NoError(t, err) + require.NoError(t, err) // Staking genesis state var stakingGenesisState stakingtypes.GenesisState - assert.NoError(t, codec.UnmarshalJSON(genesisState[stakingtypes.ModuleName], &stakingGenesisState)) + require.NoError(t, codec.UnmarshalJSON(genesisState[stakingtypes.ModuleName], &stakingGenesisState)) stakingGenesisState.Params.BondDenom = cmdcfg.BaseDenom stakingGenesisStateBz, err := codec.MarshalJSON(&stakingGenesisState) - assert.NoError(t, err) + require.NoError(t, err) // Observer genesis state var observerGenesis observertypes.GenesisState - assert.NoError(t, codec.UnmarshalJSON(genesisState[observertypes.ModuleName], &observerGenesis)) + require.NoError(t, codec.UnmarshalJSON(genesisState[observertypes.ModuleName], &observerGenesis)) observerSet := observertypes.ObserverSet{ ObserverList: observerList, } @@ -92,9 +92,9 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage IsInboundEnabled: true, IsOutboundEnabled: true, } - assert.NoError(t, observerGenesis.Validate()) + require.NoError(t, observerGenesis.Validate()) observerGenesisBz, err := codec.MarshalJSON(&observerGenesis) - assert.NoError(t, err) + require.NoError(t, err) genesisState[types.ModuleName] = crossChainGenesisBz genesisState[stakingtypes.ModuleName] = stakingGenesisStateBz @@ -104,7 +104,7 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage func AddObserverData(t *testing.T, n int, genesisState map[string]json.RawMessage, codec codec.Codec, ballots []*observertypes.Ballot) *observertypes.GenesisState { state := observertypes.GenesisState{} - assert.NoError(t, codec.UnmarshalJSON(genesisState[observertypes.ModuleName], &state)) + require.NoError(t, codec.UnmarshalJSON(genesisState[observertypes.ModuleName], &state)) // set chain params with chains all enabled state.ChainParamsList = observertypes.GetDefaultChainParams() @@ -155,17 +155,17 @@ func AddObserverData(t *testing.T, n int, genesisState map[string]json.RawMessag } // check genesis state validity - assert.NoError(t, state.Validate()) + require.NoError(t, state.Validate()) // marshal genesis state buf, err := codec.MarshalJSON(&state) - assert.NoError(t, err) + require.NoError(t, err) genesisState[observertypes.ModuleName] = buf return &state } func AddCrosschainData(t *testing.T, n int, genesisState map[string]json.RawMessage, codec codec.Codec) *types.GenesisState { state := types.GenesisState{} - assert.NoError(t, codec.UnmarshalJSON(genesisState[types.ModuleName], &state)) + require.NoError(t, codec.UnmarshalJSON(genesisState[types.ModuleName], &state)) // TODO : Fix add EVM balance to deploy contracts for i := 0; i < n; i++ { state.CrossChainTxs = append(state.CrossChainTxs, &types.CrossChainTx{ @@ -216,10 +216,10 @@ func AddCrosschainData(t *testing.T, n int, genesisState map[string]json.RawMess state.OutTxTrackerList = append(state.OutTxTrackerList, outTxTracker) } - assert.NoError(t, state.Validate()) + require.NoError(t, state.Validate()) buf, err := codec.MarshalJSON(&state) - assert.NoError(t, err) + require.NoError(t, err) genesisState[types.ModuleName] = buf return &state } diff --git a/x/crosschain/keeper/cctx_test.go b/x/crosschain/keeper/cctx_test.go index 13218eca13..6732ed6795 100644 --- a/x/crosschain/keeper/cctx_test.go +++ b/x/crosschain/keeper/cctx_test.go @@ -15,8 +15,6 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" - "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -125,14 +123,14 @@ func TestSends(t *testing.T) { sends = append(sends, createNCctxWithStatus(keeper, ctx, tt.Aborted, types.CctxStatus_Aborted)...) sends = append(sends, createNCctxWithStatus(keeper, ctx, tt.OutboundMined, types.CctxStatus_OutboundMined)...) sends = append(sends, createNCctxWithStatus(keeper, ctx, tt.Reverted, types.CctxStatus_Reverted)...) - //assert.Equal(t, tt.PendingOutbound, len(keeper.GetAllCctxByStatuses(ctx, []types.CctxStatus{types.CctxStatus_PendingOutbound}))) - //assert.Equal(t, tt.PendingInbound, len(keeper.GetAllCctxByStatuses(ctx, []types.CctxStatus{types.CctxStatus_PendingInbound}))) - //assert.Equal(t, tt.PendingOutbound+tt.PendingRevert, len(keeper.GetAllCctxByStatuses(ctx, []types.CctxStatus{types.CctxStatus_PendingOutbound, types.CctxStatus_PendingRevert}))) - assert.Equal(t, len(sends), len(keeper.GetAllCrossChainTx(ctx))) + //require.Equal(t, tt.PendingOutbound, len(keeper.GetAllCctxByStatuses(ctx, []types.CctxStatus{types.CctxStatus_PendingOutbound}))) + //require.Equal(t, tt.PendingInbound, len(keeper.GetAllCctxByStatuses(ctx, []types.CctxStatus{types.CctxStatus_PendingInbound}))) + //require.Equal(t, tt.PendingOutbound+tt.PendingRevert, len(keeper.GetAllCctxByStatuses(ctx, []types.CctxStatus{types.CctxStatus_PendingOutbound, types.CctxStatus_PendingRevert}))) + require.Equal(t, len(sends), len(keeper.GetAllCrossChainTx(ctx))) for _, s := range sends { send, found := keeper.GetCrossChainTx(ctx, s.Index) - assert.True(t, found) - assert.Equal(t, s, send) + require.True(t, found) + require.Equal(t, s, send) } }) @@ -148,7 +146,7 @@ func TestSendGetAll(t *testing.T) { for i, val := range cctx { c[i] = val } - assert.Equal(t, items, c) + require.Equal(t, items, c) } // Querier Tests @@ -218,7 +216,7 @@ func TestSendQueryPaginated(t *testing.T) { resp, err := keeper.CctxAll(wctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { - assert.Equal(t, &msgs[j], resp.CrossChainTx[j-i]) + require.Equal(t, &msgs[j], resp.CrossChainTx[j-i]) } } }) @@ -229,7 +227,7 @@ func TestSendQueryPaginated(t *testing.T) { resp, err := keeper.CctxAll(wctx, request(next, 0, uint64(step), false)) require.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { - assert.Equal(t, &msgs[j], resp.CrossChainTx[j-i]) + require.Equal(t, &msgs[j], resp.CrossChainTx[j-i]) } next = resp.Pagination.NextKey } diff --git a/x/crosschain/keeper/gas_price_test.go b/x/crosschain/keeper/gas_price_test.go index 9a269832c2..67aeb95cd6 100644 --- a/x/crosschain/keeper/gas_price_test.go +++ b/x/crosschain/keeper/gas_price_test.go @@ -5,7 +5,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -26,8 +26,8 @@ func TestGasPriceGet(t *testing.T) { items := createNGasPrice(keeper, ctx, 10) for _, item := range items { rst, found := keeper.GetGasPrice(ctx, item.ChainId) - assert.True(t, found) - assert.Equal(t, item, rst) + require.True(t, found) + require.Equal(t, item, rst) } } func TestGasPriceRemove(t *testing.T) { @@ -36,12 +36,12 @@ func TestGasPriceRemove(t *testing.T) { for _, item := range items { keeper.RemoveGasPrice(ctx, item.Index) _, found := keeper.GetGasPrice(ctx, item.ChainId) - assert.False(t, found) + require.False(t, found) } } func TestGasPriceGetAll(t *testing.T) { keeper, ctx := setupKeeper(t) items := createNGasPrice(keeper, ctx, 10) - assert.Equal(t, items, keeper.GetAllGasPrice(ctx)) + require.Equal(t, items, keeper.GetAllGasPrice(ctx)) } diff --git a/x/crosschain/keeper/grpc_query_gas_price_test.go b/x/crosschain/keeper/grpc_query_gas_price_test.go index 5c2d12cadd..cc48e2f3b0 100644 --- a/x/crosschain/keeper/grpc_query_gas_price_test.go +++ b/x/crosschain/keeper/grpc_query_gas_price_test.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/crosschain/types" "google.golang.org/grpc/codes" @@ -75,7 +74,7 @@ func TestGasPriceQueryPaginated(t *testing.T) { resp, err := keeper.GasPriceAll(wctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { - assert.Equal(t, &msgs[j], resp.GasPrice[j-i]) + require.Equal(t, &msgs[j], resp.GasPrice[j-i]) } } }) @@ -86,7 +85,7 @@ func TestGasPriceQueryPaginated(t *testing.T) { resp, err := keeper.GasPriceAll(wctx, request(next, 0, uint64(step), false)) require.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { - assert.Equal(t, &msgs[j], resp.GasPrice[j-i]) + require.Equal(t, &msgs[j], resp.GasPrice[j-i]) } next = resp.Pagination.NextKey } diff --git a/x/crosschain/keeper/grpc_query_last_block_height_test.go b/x/crosschain/keeper/grpc_query_last_block_height_test.go index b2fd0463cf..f2747bf7c9 100644 --- a/x/crosschain/keeper/grpc_query_last_block_height_test.go +++ b/x/crosschain/keeper/grpc_query_last_block_height_test.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/crosschain/types" "google.golang.org/grpc/codes" @@ -75,7 +74,7 @@ func TestLastBlockHeightQueryPaginated(t *testing.T) { resp, err := keeper.LastBlockHeightAll(wctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { - assert.Equal(t, &msgs[j], resp.LastBlockHeight[j-i]) + require.Equal(t, &msgs[j], resp.LastBlockHeight[j-i]) } } }) @@ -86,7 +85,7 @@ func TestLastBlockHeightQueryPaginated(t *testing.T) { resp, err := keeper.LastBlockHeightAll(wctx, request(next, 0, uint64(step), false)) require.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { - assert.Equal(t, &msgs[j], resp.LastBlockHeight[j-i]) + require.Equal(t, &msgs[j], resp.LastBlockHeight[j-i]) } next = resp.Pagination.NextKey } diff --git a/x/crosschain/keeper/last_block_height_test.go b/x/crosschain/keeper/last_block_height_test.go index 94eb087e01..8a284f6f97 100644 --- a/x/crosschain/keeper/last_block_height_test.go +++ b/x/crosschain/keeper/last_block_height_test.go @@ -5,7 +5,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -24,8 +24,8 @@ func TestLastBlockHeightGet(t *testing.T) { items := createNLastBlockHeight(keeper, ctx, 10) for _, item := range items { rst, found := keeper.GetLastBlockHeight(ctx, item.Index) - assert.True(t, found) - assert.Equal(t, item, rst) + require.True(t, found) + require.Equal(t, item, rst) } } func TestLastBlockHeightRemove(t *testing.T) { @@ -34,12 +34,12 @@ func TestLastBlockHeightRemove(t *testing.T) { for _, item := range items { keeper.RemoveLastBlockHeight(ctx, item.Index) _, found := keeper.GetLastBlockHeight(ctx, item.Index) - assert.False(t, found) + require.False(t, found) } } func TestLastBlockHeightGetAll(t *testing.T) { keeper, ctx := setupKeeper(t) items := createNLastBlockHeight(keeper, ctx, 10) - assert.Equal(t, items, keeper.GetAllLastBlockHeight(ctx)) + require.Equal(t, items, keeper.GetAllLastBlockHeight(ctx)) } 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 c2ad9d6e7a..a6dfe317eb 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 @@ -4,7 +4,6 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/common/ethereum" @@ -12,7 +11,6 @@ import ( "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" - observerTypes "github.com/zeta-chain/zetacore/x/observer/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -254,7 +252,7 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { }, }) tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - assert.True(t, found) + require.True(t, found) require.False(t, tracker.HashList[0].Proved) msgServer := keeper.NewMsgServerImpl(*k) _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ @@ -277,7 +275,7 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { func setupTssAndNonceToCctx(k *keeper.Keeper, ctx sdk.Context, chainId, nonce int64) { tssPubKey := "zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p" - k.GetObserverKeeper().SetTSS(ctx, observerTypes.TSS{ + k.GetObserverKeeper().SetTSS(ctx, observertypes.TSS{ TssPubkey: tssPubKey, }) k.GetObserverKeeper().SetPendingNonces(ctx, observertypes.PendingNonces{ diff --git a/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go b/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go index e42360975e..3cc1285863 100644 --- a/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go +++ b/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/cmd/zetacored/config" "github.com/zeta-chain/zetacore/common" @@ -27,12 +26,12 @@ func Test_GetRefundAddress(t *testing.T) { t.Run("should fail if refund address is empty", func(t *testing.T) { address, err := keeper.GetRefundAddress("") require.ErrorIs(t, crosschaintypes.ErrInvalidAddress, err) - assert.Equal(t, ethcommon.Address{}, address) + require.Equal(t, ethcommon.Address{}, address) }) t.Run("should fail if refund address is invalid", func(t *testing.T) { address, err := keeper.GetRefundAddress("invalid-address") require.ErrorIs(t, crosschaintypes.ErrInvalidAddress, err) - assert.Equal(t, ethcommon.Address{}, address) + require.Equal(t, ethcommon.Address{}, address) }) } diff --git a/x/crosschain/keeper/msg_server_update_tss_test.go b/x/crosschain/keeper/msg_server_update_tss_test.go index fbc8567d5f..6da9638343 100644 --- a/x/crosschain/keeper/msg_server_update_tss_test.go +++ b/x/crosschain/keeper/msg_server_update_tss_test.go @@ -5,7 +5,6 @@ import ( "github.com/stretchr/testify/require" - "github.com/stretchr/testify/assert" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -34,17 +33,17 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { cctx.CctxStatus.Status = crosschaintypes.CctxStatus_OutboundMined k.SetCrossChainTx(ctx, *cctx) } - assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) + require.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) _, err := msgServer.UpdateTssAddress(ctx, &crosschaintypes.MsgUpdateTssAddress{ Creator: admin, TssPubkey: tssNew.TssPubkey, }) - assert.NoError(t, err) + require.NoError(t, err) tss, found := k.GetObserverKeeper().GetTSS(ctx) - assert.True(t, found) - assert.Equal(t, tssNew, tss) + require.True(t, found) + require.Equal(t, tssNew, tss) migrators := k.GetObserverKeeper().GetAllTssFundMigrators(ctx) - assert.Equal(t, 0, len(migrators)) + require.Equal(t, 0, len(migrators)) }) t.Run("new tss has not been added to tss history", func(t *testing.T) { @@ -66,17 +65,17 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { cctx.CctxStatus.Status = crosschaintypes.CctxStatus_OutboundMined k.SetCrossChainTx(ctx, *cctx) } - assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) + require.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) _, err := msgServer.UpdateTssAddress(ctx, &crosschaintypes.MsgUpdateTssAddress{ Creator: admin, TssPubkey: tssNew.TssPubkey, }) - assert.ErrorContains(t, err, "tss pubkey has not been generated") - assert.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) + require.ErrorContains(t, err, "tss pubkey has not been generated") + require.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) tss, found := k.GetObserverKeeper().GetTSS(ctx) - assert.True(t, found) - assert.Equal(t, tssOld, tss) - assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) + require.True(t, found) + require.Equal(t, tssOld, tss) + require.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) }) t.Run("old tss pubkey provided", func(t *testing.T) { @@ -97,17 +96,17 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { cctx.CctxStatus.Status = crosschaintypes.CctxStatus_OutboundMined k.SetCrossChainTx(ctx, *cctx) } - assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) + require.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) _, err := msgServer.UpdateTssAddress(ctx, &crosschaintypes.MsgUpdateTssAddress{ Creator: admin, TssPubkey: tssOld.TssPubkey, }) - assert.ErrorContains(t, err, "no new tss address has been generated") - assert.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) + require.ErrorContains(t, err, "no new tss address has been generated") + require.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) tss, found := k.GetObserverKeeper().GetTSS(ctx) - assert.True(t, found) - assert.Equal(t, tssOld, tss) - assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) + require.True(t, found) + require.Equal(t, tssOld, tss) + require.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) }) t.Run("unable to update tss when not enough migrators are present", func(t *testing.T) { @@ -145,7 +144,7 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { require.True(t, found) require.Equal(t, tssOld, tss) migrators := k.GetObserverKeeper().GetAllTssFundMigrators(ctx) - assert.Equal(t, 1, len(migrators)) + require.Equal(t, 1, len(migrators)) }) t.Run("unable to update tss when pending cctx is present", func(t *testing.T) { @@ -171,18 +170,18 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { cctx.CctxStatus.Status = crosschaintypes.CctxStatus_PendingOutbound k.SetCrossChainTx(ctx, *cctx) } - assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) + require.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) _, err := msgServer.UpdateTssAddress(ctx, &crosschaintypes.MsgUpdateTssAddress{ Creator: admin, TssPubkey: tssNew.TssPubkey, }) - assert.ErrorContains(t, err, "cannot update tss address while there are pending migrations") - assert.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) + require.ErrorContains(t, err, "cannot update tss address while there are pending migrations") + require.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) tss, found := k.GetObserverKeeper().GetTSS(ctx) - assert.True(t, found) - assert.Equal(t, tssOld, tss) + require.True(t, found) + require.Equal(t, tssOld, tss) migrators := k.GetObserverKeeper().GetAllTssFundMigrators(ctx) - assert.Equal(t, len(k.GetObserverKeeper().GetSupportedChains(ctx)), len(migrators)) + require.Equal(t, len(k.GetObserverKeeper().GetSupportedChains(ctx)), len(migrators)) }) t.Run("unable to update tss cctx is not present", func(t *testing.T) { @@ -205,17 +204,17 @@ func TestMsgServer_UpdateTssAddress(t *testing.T) { MigrationCctxIndex: sample.GetCctxIndexFromString(index), }) } - assert.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) + require.Equal(t, len(k.GetObserverKeeper().GetAllTssFundMigrators(ctx)), len(k.GetObserverKeeper().GetSupportedChains(ctx))) _, err := msgServer.UpdateTssAddress(ctx, &crosschaintypes.MsgUpdateTssAddress{ Creator: admin, TssPubkey: tssNew.TssPubkey, }) - assert.ErrorContains(t, err, "migration cross chain tx not found") - assert.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) + require.ErrorContains(t, err, "migration cross chain tx not found") + require.ErrorIs(t, err, crosschaintypes.ErrUnableToUpdateTss) tss, found := k.GetObserverKeeper().GetTSS(ctx) - assert.True(t, found) - assert.Equal(t, tssOld, tss) + require.True(t, found) + require.Equal(t, tssOld, tss) migrators := k.GetObserverKeeper().GetAllTssFundMigrators(ctx) - assert.Equal(t, len(k.GetObserverKeeper().GetSupportedChains(ctx)), len(migrators)) + require.Equal(t, len(k.GetObserverKeeper().GetSupportedChains(ctx)), len(migrators)) }) } diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go index 32a0578ed8..c484b585d3 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -7,7 +7,7 @@ import ( //"github.com/zeta-chain/zetacore/common" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -23,9 +23,9 @@ func setObservers(t *testing.T, k *keeper.Keeper, ctx sdk.Context, zk keepertest validatorAddressListFormatted := make([]string, len(validators)) for i, validator := range validators { valAddr, err := sdk.ValAddressFromBech32(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) addressTmp, err := sdk.AccAddressFromHexUnsafe(hex.EncodeToString(valAddr.Bytes())) - assert.NoError(t, err) + require.NoError(t, err) validatorAddressListFormatted[i] = addressTmp.String() } @@ -57,14 +57,14 @@ func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { ctx, &msg, ) - assert.NoError(t, err) + require.NoError(t, err) } ballot, _, _ := zk.ObserverKeeper.FindBallot(ctx, msg.Digest(), zk.ObserverKeeper.GetSupportedChainFromChainID(ctx, msg.SenderChainId), observerTypes.ObservationType_InBoundTx) - assert.Equal(t, ballot.BallotStatus, observerTypes.BallotStatus_BallotFinalized_SuccessObservation) + require.Equal(t, ballot.BallotStatus, observerTypes.BallotStatus_BallotFinalized_SuccessObservation) cctx, found := k.GetCrossChainTx(ctx, msg.Digest()) - assert.True(t, found) - assert.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_OutboundMined) - assert.Equal(t, cctx.InboundTxParams.TxFinalizationStatus, types.TxFinalizationStatus_Executed) + require.True(t, found) + require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_OutboundMined) + require.Equal(t, cctx.InboundTxParams.TxFinalizationStatus, types.TxFinalizationStatus_Executed) }) // TODO : https://github.com/zeta-chain/node/issues/1542 } @@ -117,12 +117,12 @@ func TestNoDoubleEventProtections(t *testing.T) { ctx, msg, ) - assert.NoError(t, err) + require.NoError(t, err) // Check that the vote passed ballot, found := zk.ObserverKeeper.GetBallot(ctx, msg.Digest()) - assert.True(t, found) - assert.Equal(t, ballot.BallotStatus, observerTypes.BallotStatus_BallotFinalized_SuccessObservation) + require.True(t, found) + require.Equal(t, ballot.BallotStatus, observerTypes.BallotStatus_BallotFinalized_SuccessObservation) //Perform the SAME event. Except, this time, we resubmit the event. msg2 := &types.MsgVoteOnObservedInboundTx{ Creator: validatorAddr, @@ -145,9 +145,9 @@ func TestNoDoubleEventProtections(t *testing.T) { ctx, msg2, ) - assert.ErrorIs(t, err, types.ErrObservedTxAlreadyFinalized) + require.ErrorIs(t, err, types.ErrObservedTxAlreadyFinalized) _, found = zk.ObserverKeeper.GetBallot(ctx, msg2.Digest()) - assert.False(t, found) + require.False(t, found) } func TestStatus_StatusTransition(t *testing.T) { tt := []struct { @@ -188,9 +188,9 @@ func TestStatus_StatusTransition(t *testing.T) { t.Run(test.Name, func(t *testing.T) { test.Status.ChangeStatus(test.NonErrStatus, test.Msg) if test.IsErr { - assert.Equal(t, test.ErrStatus, test.Status.Status) + require.Equal(t, test.ErrStatus, test.Status.Status) } else { - assert.Equal(t, test.NonErrStatus, test.Status.Status) + require.Equal(t, test.NonErrStatus, test.Status.Status) } }) } diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index b5735ac0de..253e20dbb6 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -54,7 +54,7 @@ func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { return 0 } -// assert that a contract has been deployed by checking stored code is non-empty. +// require that a contract has been deployed by checking stored code is non-empty. func assertContractDeployment(t *testing.T, k *evmkeeper.Keeper, ctx sdk.Context, contractAddress common.Address) { acc := k.GetAccount(ctx, contractAddress) require.NotNil(t, acc) diff --git a/x/crosschain/migrations/v4/migrate_test.go b/x/crosschain/migrations/v4/migrate_test.go index 5ff2f9ee54..d377f1a6fa 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -9,7 +9,6 @@ import ( sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" @@ -25,10 +24,10 @@ func TestMigrateStore(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) amountZeta := SetRandomCctx(ctx, *k) err := v4.MigrateStore(ctx, k.GetObserverKeeper(), k) - assert.NoError(t, err) + require.NoError(t, err) zetaAccounting, found := k.GetZetaAccounting(ctx) - assert.True(t, found) - assert.Equal(t, amountZeta, zetaAccounting.AbortedZetaAmount) + require.True(t, found) + require.Equal(t, amountZeta, zetaAccounting.AbortedZetaAmount) }) t.Run("test migrate store move tss from cross chain to observer", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) @@ -46,15 +45,15 @@ func TestMigrateStore(t *testing.T) { store.Set(observertypes.KeyPrefix(fmt.Sprintf("%d", tss2.FinalizedZetaHeight)), tss2Bytes) err := v4.MigrateStore(ctx, k.GetObserverKeeper(), k) - assert.NoError(t, err) + require.NoError(t, err) tss, found := zk.ObserverKeeper.GetTSS(ctx) - assert.True(t, found) - assert.Equal(t, tss1, tss) + require.True(t, found) + require.Equal(t, tss1, tss) tssHistory := k.GetObserverKeeper().GetAllTSS(ctx) - assert.Equal(t, 2, len(tssHistory)) - assert.Equal(t, tss1, tssHistory[0]) - assert.Equal(t, tss2, tssHistory[1]) + require.Equal(t, 2, len(tssHistory)) + require.Equal(t, tss1, tssHistory[0]) + require.Equal(t, tss2, tssHistory[1]) }) t.Run("test migrate store move nonce from cross chain to observer", func(t *testing.T) { k, ctx, _, _ := keepertest.CrosschainKeeper(t) @@ -74,18 +73,18 @@ func TestMigrateStore(t *testing.T) { store.Set(types.KeyPrefix(fmt.Sprintf("%s-%d-%d", nonce.Tss, nonce.ChainId, nonce.Nonce)), k.GetCodec().MustMarshal(&nonce)) } err := v4.MigrateStore(ctx, k.GetObserverKeeper(), k) - assert.NoError(t, err) + require.NoError(t, err) pn, err := k.GetObserverKeeper().GetAllPendingNonces(ctx) - assert.NoError(t, err) + require.NoError(t, err) sort.Slice(pn, func(i, j int) bool { return pn[i].ChainId < pn[j].ChainId }) sort.Slice(pendingNonces, func(i, j int) bool { return pendingNonces[i].ChainId < pendingNonces[j].ChainId }) - assert.Equal(t, pendingNonces, pn) - assert.Equal(t, chainNonces, k.GetObserverKeeper().GetAllChainNonces(ctx)) - assert.Equal(t, nonceToCctxList, k.GetObserverKeeper().GetAllNonceToCctx(ctx)) + require.Equal(t, pendingNonces, pn) + require.Equal(t, chainNonces, k.GetObserverKeeper().GetAllChainNonces(ctx)) + require.Equal(t, nonceToCctxList, k.GetObserverKeeper().GetAllNonceToCctx(ctx)) }) } diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 8033ddc3bf..19fa79b3a5 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -6,7 +6,6 @@ import ( "testing" "cosmossdk.io/math" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" @@ -30,7 +29,7 @@ func TestMigrateStore(t *testing.T) { v4ZetaAccountingAmount = v4ZetaAccountingAmount.Add(cctx.GetCurrentOutTxParam().Amount) } - assert.True(t, v5ZetaAccountingAmount.GT(v4ZetaAccountingAmount)) + require.True(t, v5ZetaAccountingAmount.GT(v4ZetaAccountingAmount)) // Previously set the zeta accounting k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{ AbortedZetaAmount: v4ZetaAccountingAmount, diff --git a/x/crosschain/types/message_refund_aborted_test.go b/x/crosschain/types/message_refund_aborted_test.go index 7f1a0643f6..40c432881b 100644 --- a/x/crosschain/types/message_refund_aborted_test.go +++ b/x/crosschain/types/message_refund_aborted_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -12,25 +12,25 @@ func TestNewMsgRefundAbortedCCTX(t *testing.T) { t.Run("successfully validate message", func(t *testing.T) { cctx := sample.CrossChainTx(t, "test") msg := types.NewMsgRefundAbortedCCTX(sample.AccAddress(), cctx.Index, "") - assert.NoError(t, msg.ValidateBasic()) + require.NoError(t, msg.ValidateBasic()) }) t.Run("invalid creator address", func(t *testing.T) { cctx := sample.CrossChainTx(t, "test") msg := types.NewMsgRefundAbortedCCTX("invalid", cctx.Index, "") - assert.ErrorContains(t, msg.ValidateBasic(), "invalid creator address") + require.ErrorContains(t, msg.ValidateBasic(), "invalid creator address") }) t.Run("invalid cctx index", func(t *testing.T) { msg := types.NewMsgRefundAbortedCCTX(sample.AccAddress(), "invalid", "") - assert.ErrorContains(t, msg.ValidateBasic(), "invalid cctx index") + require.ErrorContains(t, msg.ValidateBasic(), "invalid cctx index") }) t.Run("invalid refund address", func(t *testing.T) { cctx := sample.CrossChainTx(t, "test") msg := types.NewMsgRefundAbortedCCTX(sample.AccAddress(), cctx.Index, "invalid") - assert.ErrorContains(t, msg.ValidateBasic(), "invalid address") + require.ErrorContains(t, msg.ValidateBasic(), "invalid address") }) t.Run("invalid refund address 2", func(t *testing.T) { cctx := sample.CrossChainTx(t, "test") msg := types.NewMsgRefundAbortedCCTX(sample.AccAddress(), cctx.Index, "0x91da5bf3F8Eb72724E6f50Ec6C3D199C6355c59") - assert.ErrorContains(t, msg.ValidateBasic(), "invalid address") + require.ErrorContains(t, msg.ValidateBasic(), "invalid address") }) } diff --git a/x/emissions/abci_test.go b/x/emissions/abci_test.go index 50651ca3e2..28ca327d50 100644 --- a/x/emissions/abci_test.go +++ b/x/emissions/abci_test.go @@ -142,27 +142,27 @@ package emissions_test // t.Run(tt.name, func(t *testing.T) { // app, ctx, _, minter := SetupApp(t, tt.params, getaZetaFromString(tt.startingEmissionPool)) // err := app.BankKeeper.SendCoinsFromAccountToModule(ctx, minter.GetAddress(), emissionsModuleTypes.ModuleName, getaZetaFromString(tt.startingEmissionPool)) -// assert.NoError(t, err) +// require.NoError(t, err) // GenerateTestDataMaths(app, ctx, tt.testMaxHeight, tt.inputFilename) // defer func(t *testing.T, fp string) { // err := os.RemoveAll(fp) -// assert.NoError(t, err) +// require.NoError(t, err) // }(t, tt.inputFilename) // // if tt.generateOnly { // return // } // inputTestData, err := GetInputData(tt.inputFilename) -// assert.NoError(t, err) +// require.NoError(t, err) // sort.SliceStable(inputTestData, func(i, j int) bool { return inputTestData[i].BlockHeight < inputTestData[j].BlockHeight }) // startHeight := ctx.BlockHeight() -// assert.Equal(t, startHeight, inputTestData[0].BlockHeight, "starting block height should be equal to the first block height in the input data") +// require.Equal(t, startHeight, inputTestData[0].BlockHeight, "starting block height should be equal to the first block height in the input data") // for i := startHeight; i < tt.testMaxHeight; i++ { // //The First distribution will occur only when begin-block is triggered // reservesFactor, bondFactor, durationFactor := app.EmissionsKeeper.GetBlockRewardComponents(ctx) -// assert.Equal(t, inputTestData[i-1].ReservesFactor, reservesFactor, "reserves factor should be equal to the input data"+fmt.Sprintf(" , block height: %d", i)) -// assert.Equal(t, inputTestData[i-1].BondFactor, bondFactor, "bond factor should be equal to the input data"+fmt.Sprintf(" , block height: %d", i)) -// assert.Equal(t, inputTestData[i-1].DurationFactor, durationFactor.String(), "duration factor should be equal to the input data"+fmt.Sprintf(" , block height: %d", i)) +// require.Equal(t, inputTestData[i-1].ReservesFactor, reservesFactor, "reserves factor should be equal to the input data"+fmt.Sprintf(" , block height: %d", i)) +// require.Equal(t, inputTestData[i-1].BondFactor, bondFactor, "bond factor should be equal to the input data"+fmt.Sprintf(" , block height: %d", i)) +// require.Equal(t, inputTestData[i-1].DurationFactor, durationFactor.String(), "duration factor should be equal to the input data"+fmt.Sprintf(" , block height: %d", i)) // emissionsModule.BeginBlocker(ctx, app.EmissionsKeeper) // ctx = ctx.WithBlockHeight(i + 1) // } diff --git a/x/emissions/keeper/block_rewards_components_test.go b/x/emissions/keeper/block_rewards_components_test.go index f8d206fbde..29acc7b07b 100644 --- a/x/emissions/keeper/block_rewards_components_test.go +++ b/x/emissions/keeper/block_rewards_components_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" emissionskeeper "github.com/zeta-chain/zetacore/x/emissions/keeper" ) @@ -43,8 +43,8 @@ func TestKeeper_CalculateFixedValidatorRewards(t *testing.T) { for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { blockRewards, err := emissionskeeper.CalculateFixedValidatorRewards(tc.blockTimeInSecs) - assert.NoError(t, err) - assert.Equal(t, tc.expectedBlockRewards, blockRewards) + require.NoError(t, err) + require.Equal(t, tc.expectedBlockRewards, blockRewards) }) } } diff --git a/x/emissions/keeper/params_test.go b/x/emissions/keeper/params_test.go index 159e948a55..128d9ced3e 100644 --- a/x/emissions/keeper/params_test.go +++ b/x/emissions/keeper/params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkmath "cosmossdk.io/math" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" ) @@ -235,9 +235,9 @@ func TestKeeper_GetParams(t *testing.T) { }, tt.isPanic) if tt.isPanic != "" { - assert.Equal(t, defaultParams, k.GetParams(ctx)) + require.Equal(t, defaultParams, k.GetParams(ctx)) } else { - assert.Equal(t, tt.params, k.GetParams(ctx)) + require.Equal(t, tt.params, k.GetParams(ctx)) } }) } @@ -247,7 +247,7 @@ func assertPanic(t *testing.T, f func(), errorLog string) { defer func() { r := recover() if r != nil { - assert.Contains(t, r, errorLog) + require.Contains(t, r, errorLog) } }() f() diff --git a/x/fungible/keeper/evm_hooks_test.go b/x/fungible/keeper/evm_hooks_test.go index 43e8a58326..696fbbd9cd 100644 --- a/x/fungible/keeper/evm_hooks_test.go +++ b/x/fungible/keeper/evm_hooks_test.go @@ -97,12 +97,12 @@ func TestKeeper_CheckPausedZRC20(t *testing.T) { t.Run(tc.name, func(t *testing.T) { k, ctx, _, _ := keepertest.FungibleKeeper(t) - requireUnpaused := func(zrc20 string) { + assertUnpaused := func(zrc20 string) { fc, found := k.GetForeignCoins(ctx, zrc20) require.True(t, found) require.False(t, fc.Paused) } - requirePaused := func(zrc20 string) { + assertPaused := func(zrc20 string) { fc, found := k.GetForeignCoins(ctx, zrc20) require.True(t, found) require.True(t, fc.Paused) @@ -117,10 +117,10 @@ func TestKeeper_CheckPausedZRC20(t *testing.T) { k.SetForeignCoins(ctx, pausedZRC20) // check paused status - requireUnpaused(addrUnpausedZRC20A.Hex()) - requireUnpaused(addrUnpausedZRC20B.Hex()) - requireUnpaused(addrUnpausedZRC20C.Hex()) - requirePaused(addrPausedZRC20.Hex()) + assertUnpaused(addrUnpausedZRC20A.Hex()) + assertUnpaused(addrUnpausedZRC20B.Hex()) + assertUnpaused(addrUnpausedZRC20C.Hex()) + assertPaused(addrPausedZRC20.Hex()) // process test err := k.CheckPausedZRC20(ctx, tc.receipt) diff --git a/x/fungible/keeper/evm_test.go b/x/fungible/keeper/evm_test.go index 80bd42a2f3..b6810a6998 100644 --- a/x/fungible/keeper/evm_test.go +++ b/x/fungible/keeper/evm_test.go @@ -32,7 +32,7 @@ func getValidChainID(t *testing.T) int64 { return list[0].ChainId } -// assert that a contract has been deployed by checking stored code is non-empty. +// require that a contract has been deployed by checking stored code is non-empty. func assertContractDeployment(t *testing.T, k *evmkeeper.Keeper, ctx sdk.Context, contractAddress common.Address) { acc := k.GetAccount(ctx, contractAddress) require.NotNil(t, acc) diff --git a/x/fungible/keeper/msg_server_update_zrc20_paused_status.go b/x/fungible/keeper/msg_server_update_zrc20_paused_status.go index fcbb37bfaa..e5527071ea 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_paused_status.go +++ b/x/fungible/keeper/msg_server_update_zrc20_paused_status.go @@ -28,11 +28,11 @@ func (k msgServer) UpdateZRC20PausedStatus( // check if the sender is the admin // unpausing requires group2 admin - requirePolicyAccount := zetaObserverTypes.Policy_Type_group1 + requiredPolicyAccount := zetaObserverTypes.Policy_Type_group1 if msg.Action == types.UpdatePausedStatusAction_UNPAUSE { - requirePolicyAccount = zetaObserverTypes.Policy_Type_group2 + requiredPolicyAccount = zetaObserverTypes.Policy_Type_group2 } - if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(requirePolicyAccount) { + if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(requiredPolicyAccount) { return nil, cosmoserrors.Wrap(sdkerrors.ErrUnauthorized, "Update can only be executed by the correct policy account") } diff --git a/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go b/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go index 2183cccf9c..bc4238a780 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go +++ b/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go @@ -18,12 +18,12 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { msgServer := keeper.NewMsgServerImpl(*k) admin := sample.AccAddress() - requireUnpaused := func(zrc20 string) { + assertUnpaused := func(zrc20 string) { fc, found := k.GetForeignCoins(ctx, zrc20) require.True(t, found) require.False(t, fc.Paused) } - requirePaused := func(zrc20 string) { + assertPaused := func(zrc20 string) { fc, found := k.GetForeignCoins(ctx, zrc20) require.True(t, found) require.True(t, fc.Paused) @@ -34,9 +34,9 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20A)) k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20B)) k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20C)) - requireUnpaused(zrc20A) - requireUnpaused(zrc20B) - requireUnpaused(zrc20C) + assertUnpaused(zrc20A) + assertUnpaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group1) @@ -50,9 +50,9 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { types.UpdatePausedStatusAction_PAUSE, )) require.NoError(t, err) - requirePaused(zrc20A) - requirePaused(zrc20B) - requireUnpaused(zrc20C) + assertPaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) @@ -65,9 +65,9 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { types.UpdatePausedStatusAction_UNPAUSE, )) require.NoError(t, err) - requireUnpaused(zrc20A) - requirePaused(zrc20B) - requireUnpaused(zrc20C) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group1) @@ -80,9 +80,9 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { types.UpdatePausedStatusAction_PAUSE, )) require.NoError(t, err) - requireUnpaused(zrc20A) - requirePaused(zrc20B) - requireUnpaused(zrc20C) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) @@ -95,9 +95,9 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { types.UpdatePausedStatusAction_UNPAUSE, )) require.NoError(t, err) - requireUnpaused(zrc20A) - requirePaused(zrc20B) - requireUnpaused(zrc20C) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group1) @@ -112,9 +112,9 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { types.UpdatePausedStatusAction_PAUSE, )) require.NoError(t, err) - requirePaused(zrc20A) - requirePaused(zrc20B) - requirePaused(zrc20C) + assertPaused(zrc20A) + assertPaused(zrc20B) + assertPaused(zrc20C) setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) @@ -129,9 +129,9 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { types.UpdatePausedStatusAction_UNPAUSE, )) require.NoError(t, err) - requireUnpaused(zrc20A) - requireUnpaused(zrc20B) - requireUnpaused(zrc20C) + assertUnpaused(zrc20A) + assertUnpaused(zrc20B) + assertUnpaused(zrc20C) }) t.Run("should fail if invalid message", func(t *testing.T) { diff --git a/x/observer/keeper/grpc_query_node_account_test.go b/x/observer/keeper/grpc_query_node_account_test.go index 37585214cf..03facb08b4 100644 --- a/x/observer/keeper/grpc_query_node_account_test.go +++ b/x/observer/keeper/grpc_query_node_account_test.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" @@ -75,7 +74,7 @@ func TestNodeAccountQueryPaginated(t *testing.T) { resp, err := keeper.NodeAccountAll(wctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { - assert.Equal(t, &msgs[j], resp.NodeAccount[j-i]) + require.Equal(t, &msgs[j], resp.NodeAccount[j-i]) } } }) @@ -86,7 +85,7 @@ func TestNodeAccountQueryPaginated(t *testing.T) { resp, err := keeper.NodeAccountAll(wctx, request(next, 0, uint64(step), false)) require.NoError(t, err) for j := i; j < len(msgs) && j < i+step; j++ { - assert.Equal(t, &msgs[j], resp.NodeAccount[j-i]) + require.Equal(t, &msgs[j], resp.NodeAccount[j-i]) } next = resp.Pagination.NextKey } diff --git a/x/observer/keeper/grpc_query_nonces_test.go b/x/observer/keeper/grpc_query_nonces_test.go index 584f237e7b..6ec06efd28 100644 --- a/x/observer/keeper/grpc_query_nonces_test.go +++ b/x/observer/keeper/grpc_query_nonces_test.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -83,7 +82,7 @@ func TestChainNoncesQueryPaginated(t *testing.T) { resp, err := k.ChainNoncesAll(wctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) for j := i; j < len(chainNonces) && j < i+step; j++ { - assert.Equal(t, chainNonces[j], resp.ChainNonces[j-i]) + require.Equal(t, chainNonces[j], resp.ChainNonces[j-i]) } } }) @@ -94,7 +93,7 @@ func TestChainNoncesQueryPaginated(t *testing.T) { resp, err := k.ChainNoncesAll(wctx, request(next, 0, uint64(step), false)) require.NoError(t, err) for j := i; j < len(chainNonces) && j < i+step; j++ { - assert.Equal(t, chainNonces[j], resp.ChainNonces[j-i]) + require.Equal(t, chainNonces[j], resp.ChainNonces[j-i]) } next = resp.Pagination.NextKey } diff --git a/x/observer/keeper/keygen_test.go b/x/observer/keeper/keygen_test.go index a48c769c37..f14fa3aeef 100644 --- a/x/observer/keeper/keygen_test.go +++ b/x/observer/keeper/keygen_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -22,13 +22,13 @@ func TestKeygenGet(t *testing.T) { keeper, ctx := SetupKeeper(t) item := createTestKeygen(keeper, ctx) rst, found := keeper.GetKeygen(ctx) - assert.True(t, found) - assert.Equal(t, item, rst) + require.True(t, found) + require.Equal(t, item, rst) } func TestKeygenRemove(t *testing.T) { keeper, ctx := SetupKeeper(t) createTestKeygen(keeper, ctx) keeper.RemoveKeygen(ctx) _, found := keeper.GetKeygen(ctx) - assert.False(t, found) + require.False(t, found) } diff --git a/x/observer/keeper/msg_server_add_block_header_test.go b/x/observer/keeper/msg_server_add_block_header_test.go index 7f475bad4c..34bde9c115 100644 --- a/x/observer/keeper/msg_server_add_block_header_test.go +++ b/x/observer/keeper/msg_server_add_block_header_test.go @@ -6,7 +6,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/rlp" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" @@ -17,19 +16,19 @@ import ( func TestMsgServer_AddBlockHeader(t *testing.T) { header, header2, header3, err := sample.EthHeader() - assert.NoError(t, err) + require.NoError(t, err) header1RLP, err := rlp.EncodeToBytes(header) - assert.NoError(t, err) + require.NoError(t, err) header2RLP, err := rlp.EncodeToBytes(header2) _ = header2RLP - assert.NoError(t, err) + require.NoError(t, err) header3RLP, err := rlp.EncodeToBytes(header3) - assert.NoError(t, err) + require.NoError(t, err) r := rand.New(rand.NewSource(9)) validator := sample.Validator(t, r) observerAddress, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) // Add tests for btc headers : https://github.com/zeta-chain/node/issues/1336 tt := []struct { name string @@ -66,7 +65,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsBtcTypeChainEnabled: true, validator: validator, wantErr: func(t require.TestingT, err error, i ...interface{}) { - assert.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) + require.ErrorIs(t, err, types.ErrBlockHeaderVerificationDisabled) }, }, { @@ -82,7 +81,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { IsBtcTypeChainEnabled: true, validator: validator, wantErr: func(t require.TestingT, err error, i ...interface{}) { - assert.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) + require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) }, }, { diff --git a/x/observer/keeper/msg_server_update_observer_test.go b/x/observer/keeper/msg_server_update_observer_test.go index 649ce6ca13..7fe73734d8 100644 --- a/x/observer/keeper/msg_server_update_observer_test.go +++ b/x/observer/keeper/msg_server_update_observer_test.go @@ -8,7 +8,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/stretchr/testify/assert" + "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/keeper" @@ -30,7 +30,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -40,10 +40,10 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) count := uint64(0) @@ -66,10 +66,10 @@ func TestMsgServer_UpdateObserver(t *testing.T) { NewObserverAddress: newOperatorAddress.String(), UpdateReason: types.ObserverUpdateReason_Tombstoned, }) - assert.NoError(t, err) + require.NoError(t, err) acc, found := k.GetNodeAccount(ctx, newOperatorAddress.String()) - assert.True(t, found) - assert.Equal(t, newOperatorAddress.String(), acc.Operator) + require.True(t, found) + require.Equal(t, newOperatorAddress.String(), acc.Operator) }) t.Run("unable to update to a non validator address", func(t *testing.T) { @@ -84,7 +84,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -94,10 +94,10 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) count := uint64(0) k.SetObserverSet(ctx, types.ObserverSet{ @@ -118,7 +118,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { NewObserverAddress: newOperatorAddress.String(), UpdateReason: types.ObserverUpdateReason_Tombstoned, }) - assert.ErrorIs(t, err, types.ErrUpdateObserver) + require.ErrorIs(t, err, types.ErrUpdateObserver) }) t.Run("unable to update tombstoned validator with with non operator account", func(t *testing.T) { @@ -135,7 +135,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -145,7 +145,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) count := uint64(0) k.SetObserverSet(ctx, types.ObserverSet{ @@ -162,7 +162,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ Creator: sample.AccAddress(), @@ -170,7 +170,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { NewObserverAddress: newOperatorAddress.String(), UpdateReason: types.ObserverUpdateReason_Tombstoned, }) - assert.ErrorIs(t, err, types.ErrUpdateObserver) + require.ErrorIs(t, err, types.ErrUpdateObserver) }) t.Run("unable to update non-tombstoned observer with update reason tombstoned", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -186,7 +186,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -196,7 +196,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) count := uint64(0) k.SetObserverSet(ctx, types.ObserverSet{ ObserverList: []string{accAddressOfValidator.String()}, @@ -212,7 +212,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ Creator: accAddressOfValidator.String(), @@ -220,7 +220,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { NewObserverAddress: newOperatorAddress.String(), UpdateReason: types.ObserverUpdateReason_Tombstoned, }) - assert.ErrorIs(t, err, types.ErrUpdateObserver) + require.ErrorIs(t, err, types.ErrUpdateObserver) }) t.Run("unable to update observer with no node account", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -236,7 +236,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -246,7 +246,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) count := uint64(0) k.SetObserverSet(ctx, types.ObserverSet{ ObserverList: []string{accAddressOfValidator.String()}, @@ -258,7 +258,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ Creator: accAddressOfValidator.String(), @@ -266,7 +266,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { NewObserverAddress: newOperatorAddress.String(), UpdateReason: types.ObserverUpdateReason_Tombstoned, }) - assert.ErrorIs(t, err, types.ErrNodeAccountNotFound) + require.ErrorIs(t, err, types.ErrNodeAccountNotFound) }) t.Run("unable to update observer when last observer count is missing", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -282,7 +282,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -292,7 +292,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) count := uint64(0) k.SetObserverSet(ctx, types.ObserverSet{ ObserverList: []string{accAddressOfValidator.String()}, @@ -303,7 +303,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) _, err = srv.UpdateObserver(sdk.WrapSDKContext(ctx), &types.MsgUpdateObserver{ Creator: accAddressOfValidator.String(), @@ -311,7 +311,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { NewObserverAddress: newOperatorAddress.String(), UpdateReason: types.ObserverUpdateReason_Tombstoned, }) - assert.ErrorIs(t, err, types.ErrLastObserverCountNotFound) + require.ErrorIs(t, err, types.ErrLastObserverCountNotFound) }) t.Run("update observer using admin policy", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -330,7 +330,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -340,7 +340,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) count := uint64(0) k.SetObserverSet(ctx, types.ObserverSet{ ObserverList: []string{accAddressOfValidator.String()}, @@ -351,7 +351,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) k.SetLastObserverCount(ctx, &types.LastObserverCount{ Count: count, @@ -363,10 +363,10 @@ func TestMsgServer_UpdateObserver(t *testing.T) { NewObserverAddress: newOperatorAddress.String(), UpdateReason: types.ObserverUpdateReason_AdminUpdate, }) - assert.NoError(t, err) + require.NoError(t, err) acc, found := k.GetNodeAccount(ctx, newOperatorAddress.String()) - assert.True(t, found) - assert.Equal(t, newOperatorAddress.String(), acc.Operator) + require.True(t, found) + require.Equal(t, newOperatorAddress.String(), acc.Operator) }) t.Run("fail to update observer using regular account and update type admin", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -383,7 +383,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -393,7 +393,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) count := uint64(0) k.SetObserverSet(ctx, types.ObserverSet{ ObserverList: []string{accAddressOfValidator.String()}, @@ -405,7 +405,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { }) newOperatorAddress, err := types.GetAccAddressFromOperatorAddress(validatorNew.OperatorAddress) - assert.NoError(t, err) + require.NoError(t, err) k.SetLastObserverCount(ctx, &types.LastObserverCount{ Count: count, @@ -417,7 +417,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) { NewObserverAddress: newOperatorAddress.String(), UpdateReason: types.ObserverUpdateReason_AdminUpdate, }) - assert.ErrorIs(t, err, types.ErrUpdateObserver) + require.ErrorIs(t, err, types.ErrUpdateObserver) }) } @@ -426,9 +426,9 @@ func TestUpdateObserverList(t *testing.T) { oldObserverAddress := sample.AccAddress() newObserverAddress := sample.AccAddress() list := []string{sample.AccAddress(), sample.AccAddress(), sample.AccAddress(), oldObserverAddress} - assert.Equal(t, oldObserverAddress, list[3]) + require.Equal(t, oldObserverAddress, list[3]) keeper.UpdateObserverList(list, oldObserverAddress, newObserverAddress) - assert.Equal(t, 4, len(list)) - assert.Equal(t, newObserverAddress, list[3]) + require.Equal(t, 4, len(list)) + require.Equal(t, newObserverAddress, list[3]) }) } diff --git a/x/observer/keeper/node_account_test.go b/x/observer/keeper/node_account_test.go index 034b48ba67..26a5c47d1c 100644 --- a/x/observer/keeper/node_account_test.go +++ b/x/observer/keeper/node_account_test.go @@ -5,7 +5,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -25,8 +25,8 @@ func TestNodeAccountGet(t *testing.T) { items := createNNodeAccount(keeper, ctx, 10) for _, item := range items { rst, found := keeper.GetNodeAccount(ctx, item.Operator) - assert.True(t, found) - assert.Equal(t, item, rst) + require.True(t, found) + require.Equal(t, item, rst) } } func TestNodeAccountRemove(t *testing.T) { @@ -35,12 +35,12 @@ func TestNodeAccountRemove(t *testing.T) { for _, item := range items { keeper.RemoveNodeAccount(ctx, item.Operator) _, found := keeper.GetNodeAccount(ctx, item.Operator) - assert.False(t, found) + require.False(t, found) } } func TestNodeAccountGetAll(t *testing.T) { keeper, ctx := SetupKeeper(t) items := createNNodeAccount(keeper, ctx, 10) - assert.Equal(t, items, keeper.GetAllNodeAccount(ctx)) + require.Equal(t, items, keeper.GetAllNodeAccount(ctx)) } diff --git a/x/observer/keeper/nonces_test.go b/x/observer/keeper/nonces_test.go index 2e201ae67e..aaf7369df1 100644 --- a/x/observer/keeper/nonces_test.go +++ b/x/observer/keeper/nonces_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" ) @@ -16,8 +16,8 @@ func TestChainNoncesGet(t *testing.T) { } for _, item := range items { rst, found := k.GetChainNonces(ctx, item.Index) - assert.True(t, found) - assert.Equal(t, item, rst) + require.True(t, found) + require.Equal(t, item, rst) } } func TestChainNoncesRemove(t *testing.T) { @@ -29,7 +29,7 @@ func TestChainNoncesRemove(t *testing.T) { for _, item := range items { k.RemoveChainNonces(ctx, item.Index) _, found := k.GetChainNonces(ctx, item.Index) - assert.False(t, found) + require.False(t, found) } } @@ -39,5 +39,5 @@ func TestChainNoncesGetAll(t *testing.T) { for _, item := range items { k.SetChainNonces(ctx, item) } - assert.Equal(t, items, k.GetAllChainNonces(ctx)) + require.Equal(t, items, k.GetAllChainNonces(ctx)) } diff --git a/x/observer/keeper/observer_set_test.go b/x/observer/keeper/observer_set_test.go index f1ca38fc8c..ca7212704a 100644 --- a/x/observer/keeper/observer_set_test.go +++ b/x/observer/keeper/observer_set_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" ) @@ -14,8 +14,8 @@ func TestKeeper_GetObserverSet(t *testing.T) { os := sample.ObserverSet(10) k.SetObserverSet(ctx, os) tfm, found := k.GetObserverSet(ctx) - assert.True(t, found) - assert.Equal(t, os, tfm) + require.True(t, found) + require.Equal(t, os, tfm) }) } @@ -24,8 +24,8 @@ func TestKeeper_IsAddressPartOfObserverSet(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) os := sample.ObserverSet(10) k.SetObserverSet(ctx, os) - assert.True(t, k.IsAddressPartOfObserverSet(ctx, os.ObserverList[0])) - assert.False(t, k.IsAddressPartOfObserverSet(ctx, sample.AccAddress())) + require.True(t, k.IsAddressPartOfObserverSet(ctx, os.ObserverList[0])) + require.False(t, k.IsAddressPartOfObserverSet(ctx, sample.AccAddress())) }) } @@ -36,11 +36,11 @@ func TestKeeper_AddObserverToSet(t *testing.T) { k.SetObserverSet(ctx, os) newObserver := sample.AccAddress() k.AddObserverToSet(ctx, newObserver) - assert.True(t, k.IsAddressPartOfObserverSet(ctx, newObserver)) - assert.False(t, k.IsAddressPartOfObserverSet(ctx, sample.AccAddress())) + require.True(t, k.IsAddressPartOfObserverSet(ctx, newObserver)) + require.False(t, k.IsAddressPartOfObserverSet(ctx, sample.AccAddress())) osNew, found := k.GetObserverSet(ctx) - assert.True(t, found) - assert.Len(t, osNew.ObserverList, len(os.ObserverList)+1) + require.True(t, found) + require.Len(t, osNew.ObserverList, len(os.ObserverList)+1) }) } @@ -50,10 +50,10 @@ func TestKeeper_RemoveObserverFromSet(t *testing.T) { os := sample.ObserverSet(10) k.SetObserverSet(ctx, os) k.RemoveObserverFromSet(ctx, os.ObserverList[0]) - assert.False(t, k.IsAddressPartOfObserverSet(ctx, os.ObserverList[0])) + require.False(t, k.IsAddressPartOfObserverSet(ctx, os.ObserverList[0])) osNew, found := k.GetObserverSet(ctx) - assert.True(t, found) - assert.Len(t, osNew.ObserverList, len(os.ObserverList)-1) + require.True(t, found) + require.Len(t, osNew.ObserverList, len(os.ObserverList)-1) }) } @@ -66,10 +66,10 @@ func TestKeeper_UpdateObserverAddress(t *testing.T) { observerSet.ObserverList = append(observerSet.ObserverList, oldObserverAddress) k.SetObserverSet(ctx, observerSet) err := k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress) - assert.NoError(t, err) + require.NoError(t, err) observerSet, found := k.GetObserverSet(ctx) - assert.True(t, found) - assert.Equal(t, newObserverAddress, observerSet.ObserverList[len(observerSet.ObserverList)-1]) + require.True(t, found) + require.Equal(t, newObserverAddress, observerSet.ObserverList[len(observerSet.ObserverList)-1]) }) t.Run("update observer address long observerList", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -79,10 +79,10 @@ func TestKeeper_UpdateObserverAddress(t *testing.T) { observerSet.ObserverList = append(observerSet.ObserverList, oldObserverAddress) k.SetObserverSet(ctx, observerSet) err := k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress) - assert.NoError(t, err) + require.NoError(t, err) observerMappers, found := k.GetObserverSet(ctx) - assert.True(t, found) - assert.Equal(t, newObserverAddress, observerMappers.ObserverList[len(observerMappers.ObserverList)-1]) + require.True(t, found) + require.Equal(t, newObserverAddress, observerMappers.ObserverList[len(observerMappers.ObserverList)-1]) }) t.Run("update observer address short observerList", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -92,9 +92,9 @@ func TestKeeper_UpdateObserverAddress(t *testing.T) { observerSet.ObserverList = append(observerSet.ObserverList, oldObserverAddress) k.SetObserverSet(ctx, observerSet) err := k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress) - assert.NoError(t, err) + require.NoError(t, err) observerMappers, found := k.GetObserverSet(ctx) - assert.True(t, found) - assert.Equal(t, newObserverAddress, observerMappers.ObserverList[len(observerMappers.ObserverList)-1]) + require.True(t, found) + require.Equal(t, newObserverAddress, observerMappers.ObserverList[len(observerMappers.ObserverList)-1]) }) } diff --git a/x/observer/keeper/tss_funds_migrator_test.go b/x/observer/keeper/tss_funds_migrator_test.go index b7cd45bec1..62d622e179 100644 --- a/x/observer/keeper/tss_funds_migrator_test.go +++ b/x/observer/keeper/tss_funds_migrator_test.go @@ -3,7 +3,7 @@ package keeper_test import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" ) @@ -14,8 +14,8 @@ func TestKeeper_GetTssFundMigrator(t *testing.T) { chain := sample.TssFundsMigrator(1) k.SetFundMigrator(ctx, chain) tfm, found := k.GetFundMigrator(ctx, chain.ChainId) - assert.True(t, found) - assert.Equal(t, chain, tfm) + require.True(t, found) + require.Equal(t, chain, tfm) }) t.Run("Verify only one migrator can be created for a chain", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -25,8 +25,8 @@ func TestKeeper_GetTssFundMigrator(t *testing.T) { tfm2.MigrationCctxIndex = "sampleIndex2" k.SetFundMigrator(ctx, tfm2) migratorList := k.GetAllTssFundMigrators(ctx) - assert.Equal(t, 1, len(migratorList)) - assert.Equal(t, tfm2, migratorList[0]) + require.Equal(t, 1, len(migratorList)) + require.Equal(t, tfm2, migratorList[0]) }) } diff --git a/x/observer/keeper/tss_test.go b/x/observer/keeper/tss_test.go index 37099a519b..0af8bae7f3 100644 --- a/x/observer/keeper/tss_test.go +++ b/x/observer/keeper/tss_test.go @@ -13,7 +13,6 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -22,8 +21,8 @@ func TestTSSGet(t *testing.T) { tss := sample.Tss() k.SetTSS(ctx, tss) tssQueried, found := k.GetTSS(ctx) - assert.True(t, found) - assert.Equal(t, tss, tssQueried) + require.True(t, found) + require.Equal(t, tss, tssQueried) } func TestTSSRemove(t *testing.T) { @@ -32,7 +31,7 @@ func TestTSSRemove(t *testing.T) { k.SetTSS(ctx, tss) k.RemoveTSS(ctx) _, found := k.GetTSS(ctx) - assert.False(t, found) + require.False(t, found) } func TestTSSQuerySingle(t *testing.T) { @@ -105,9 +104,9 @@ func TestTSSQueryHistory(t *testing.T) { } else { require.Equal(t, len(tssList), len(response.TssList)) prevTss, found := keeper.GetPreviousTSS(ctx) - assert.Equal(t, tc.foundPrevious, found) + require.Equal(t, tc.foundPrevious, found) if found { - assert.Equal(t, tssList[len(tssList)-2], prevTss) + require.Equal(t, tssList[len(tssList)-2], prevTss) } } }) diff --git a/x/observer/keeper/utils_test.go b/x/observer/keeper/utils_test.go index e62cc57758..6534fc6200 100644 --- a/x/observer/keeper/utils_test.go +++ b/x/observer/keeper/utils_test.go @@ -7,7 +7,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" zetacommon "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" @@ -52,7 +51,7 @@ func TestKeeper_IsAuthorized(t *testing.T) { validator := sample.Validator(t, r) k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -66,7 +65,7 @@ func TestKeeper_IsAuthorized(t *testing.T) { k.SetObserverSet(ctx, types.ObserverSet{ ObserverList: []string{accAddressOfValidator.String()}, }) - assert.True(t, k.IsAuthorized(ctx, accAddressOfValidator.String())) + require.True(t, k.IsAuthorized(ctx, accAddressOfValidator.String())) }) t.Run("not authorized for tombstoned observer", func(t *testing.T) { @@ -78,7 +77,7 @@ func TestKeeper_IsAuthorized(t *testing.T) { validator := sample.Validator(t, r) k.GetStakingKeeper().SetValidator(ctx, validator) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -92,7 +91,7 @@ func TestKeeper_IsAuthorized(t *testing.T) { ObserverList: []string{accAddressOfValidator.String()}, }) - assert.False(t, k.IsAuthorized(ctx, accAddressOfValidator.String())) + require.False(t, k.IsAuthorized(ctx, accAddressOfValidator.String())) }) t.Run("not authorized for non-validator observer", func(t *testing.T) { @@ -104,7 +103,7 @@ func TestKeeper_IsAuthorized(t *testing.T) { validator := sample.Validator(t, r) consAddress, err := validator.GetConsAddr() - assert.NoError(t, err) + require.NoError(t, err) k.GetSlashingKeeper().SetValidatorSigningInfo(ctx, consAddress, slashingtypes.ValidatorSigningInfo{ Address: consAddress.String(), StartHeight: 0, @@ -118,7 +117,7 @@ func TestKeeper_IsAuthorized(t *testing.T) { ObserverList: []string{accAddressOfValidator.String()}, }) - assert.False(t, k.IsAuthorized(ctx, accAddressOfValidator.String())) + require.False(t, k.IsAuthorized(ctx, accAddressOfValidator.String())) }) } diff --git a/x/observer/migrations/v4/migrate_test.go b/x/observer/migrations/v4/migrate_test.go index b7d025fa60..a5bfd67f56 100644 --- a/x/observer/migrations/v4/migrate_test.go +++ b/x/observer/migrations/v4/migrate_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/cosmos/cosmos-sdk/store/prefix" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" v4 "github.com/zeta-chain/zetacore/x/observer/migrations/v4" "github.com/zeta-chain/zetacore/x/observer/types" @@ -22,10 +22,10 @@ func TestMigrateCrosschainFlags(t *testing.T) { store.Set([]byte{0}, val) err := v4.MigrateCrosschainFlags(ctx, k.StoreKey(), k.Codec()) - assert.NoError(t, err) + require.NoError(t, err) flags, found := k.GetCrosschainFlags(ctx) - assert.True(t, found) - assert.True(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) - assert.True(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) + require.True(t, found) + require.True(t, flags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled) + require.True(t, flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled) } diff --git a/x/observer/migrations/v5/migrate_test.go b/x/observer/migrations/v5/migrate_test.go index d97b3dde69..8b83d5d0ed 100644 --- a/x/observer/migrations/v5/migrate_test.go +++ b/x/observer/migrations/v5/migrate_test.go @@ -5,7 +5,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" @@ -23,11 +22,11 @@ func TestMigrateObserverMapper(t *testing.T) { legacyObserverMapperStore.Set(types.KeyPrefix(legacyObserverMapper.Index), k.Codec().MustMarshal(legacyObserverMapper)) } err := v5.MigrateObserverMapper(ctx, k.StoreKey(), k.Codec()) - assert.NoError(t, err) + require.NoError(t, err) observerSet, found := k.GetObserverSet(ctx) - assert.True(t, found) + require.True(t, found) - assert.Equal(t, legacyObserverMapperList[0].ObserverList, observerSet.ObserverList) + require.Equal(t, legacyObserverMapperList[0].ObserverList, observerSet.ObserverList) iterator := sdk.KVStorePrefixIterator(legacyObserverMapperStore, []byte{}) defer iterator.Close() @@ -39,7 +38,7 @@ func TestMigrateObserverMapper(t *testing.T) { observerMappers = append(observerMappers, &val) } } - assert.Equal(t, 0, len(observerMappers)) + require.Equal(t, 0, len(observerMappers)) }) } diff --git a/x/observer/migrations/v6/migrate_test.go b/x/observer/migrations/v6/migrate_test.go index 574ece4be4..925c1b0b32 100644 --- a/x/observer/migrations/v6/migrate_test.go +++ b/x/observer/migrations/v6/migrate_test.go @@ -4,7 +4,7 @@ import ( "math" "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" v6 "github.com/zeta-chain/zetacore/x/observer/migrations/v6" "github.com/zeta-chain/zetacore/x/observer/types" @@ -49,12 +49,12 @@ func TestMigrateObserverParams(t *testing.T) { FinalizedZetaHeight: finalizedZetaHeight, }) err := v6.MigrateStore(ctx, k) - assert.NoError(t, err) + require.NoError(t, err) keygen, found := k.GetKeygen(ctx) - assert.True(t, found) - assert.Equal(t, types.KeygenStatus_KeyGenSuccess, keygen.Status) - assert.Equal(t, keygenHeight, keygenHeight) - assert.Equal(t, participantList, participantList) + require.True(t, found) + require.Equal(t, types.KeygenStatus_KeyGenSuccess, keygen.Status) + require.Equal(t, keygenHeight, keygenHeight) + require.Equal(t, participantList, participantList) }) t.Run("Migrate when keygen is not Pending", func(t *testing.T) { k, ctx := keepertest.ObserverKeeper(t) @@ -76,12 +76,12 @@ func TestMigrateObserverParams(t *testing.T) { GranteePubkeys: participantList, }) err := v6.MigrateStore(ctx, k) - assert.NoError(t, err) + require.NoError(t, err) keygen, found := k.GetKeygen(ctx) - assert.True(t, found) - assert.Equal(t, types.KeygenStatus_KeyGenSuccess, keygen.Status) - assert.Equal(t, keygen.BlockNumber, keygenHeight) - assert.Equal(t, keygen.GranteePubkeys, participantList) + require.True(t, found) + require.Equal(t, types.KeygenStatus_KeyGenSuccess, keygen.Status) + require.Equal(t, keygen.BlockNumber, keygenHeight) + require.Equal(t, keygen.GranteePubkeys, participantList) }) } diff --git a/x/observer/types/ballot_test.go b/x/observer/types/ballot_test.go index 0e087309e3..2bd6441c48 100644 --- a/x/observer/types/ballot_test.go +++ b/x/observer/types/ballot_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestBallot_AddVote(t *testing.T) { @@ -206,9 +206,9 @@ func TestBallot_AddVote(t *testing.T) { } finalBallot, isFinalized := ballot.IsFinalizingVote() - assert.Equal(t, test.finalStatus, finalBallot.BallotStatus) - assert.Equal(t, test.finalVotes, finalBallot.Votes) - assert.Equal(t, test.isFinalized, isFinalized) + require.Equal(t, test.finalStatus, finalBallot.BallotStatus) + require.Equal(t, test.finalVotes, finalBallot.Votes) + require.Equal(t, test.isFinalized, isFinalized) }) } } @@ -336,10 +336,10 @@ func TestBallot_IsFinalizingVote(t *testing.T) { ballot.Votes = append(ballot.Votes, vote) ballot, isFinalizingVote = ballot.IsFinalizingVote() if isFinalizingVote { - assert.Equal(t, test.finalizingVote, index) + require.Equal(t, test.finalizingVote, index) } } - assert.Equal(t, test.finalStatus, ballot.BallotStatus) + require.Equal(t, test.finalStatus, ballot.BallotStatus) }) } } @@ -391,7 +391,7 @@ func Test_BuildRewardsDistribution(t *testing.T) { } rewardsMap := map[string]int64{} ballot.BuildRewardsDistribution(rewardsMap) - assert.Equal(t, test.expectedMap, rewardsMap) + require.Equal(t, test.expectedMap, rewardsMap) }) } diff --git a/x/observer/types/message_crosschain_flags_test.go b/x/observer/types/message_crosschain_flags_test.go index 199b80c13a..44fab49bbf 100644 --- a/x/observer/types/message_crosschain_flags_test.go +++ b/x/observer/types/message_crosschain_flags_test.go @@ -149,7 +149,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group1, }, { - name: "updating gas price increase flags requires group 2", + name: "updating gas price increase flags asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: false, @@ -168,7 +168,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group2, }, { - name: "enabling inbound requires group 2", + name: "enabling inbound asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: true, @@ -182,7 +182,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group2, }, { - name: "enabling outbound requires group 2", + name: "enabling outbound asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: false, @@ -196,7 +196,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group2, }, { - name: "enabling eth header verification requires group 2", + name: "enabling eth header verification asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: false, @@ -210,7 +210,7 @@ func TestMsgUpdateCrosschainFlags_GetRequiredGroup(t *testing.T) { want: types.Policy_Type_group2, }, { - name: "enabling btc header verification requires group 2", + name: "enabling btc header verification asserts group 2", msg: types.MsgUpdateCrosschainFlags{ Creator: sample.AccAddress(), IsInboundEnabled: false, diff --git a/zetaclient/bitcoin/bitcoin_signer_test.go b/zetaclient/bitcoin/bitcoin_signer_test.go index f8180a92f0..bbf15c1bba 100644 --- a/zetaclient/bitcoin/bitcoin_signer_test.go +++ b/zetaclient/bitcoin/bitcoin_signer_test.go @@ -22,7 +22,6 @@ import ( "github.com/btcsuite/btcutil" "github.com/ethereum/go-ethereum/crypto" "github.com/rs/zerolog" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -501,7 +500,7 @@ func TestSelectUTXOs(t *testing.T) { // output: [0.00002001, 0.01, 0.12, 0.18, 0.24, 0.5], 1.05002001 result, amount, _, _, err = ob.SelectUTXOs(1.0, 5, 2, math.MaxUint16, true) require.Nil(t, err) - assert.InEpsilon(t, 1.05002001, amount, 1e-8) + require.InEpsilon(t, 1.05002001, amount, 1e-8) require.Equal(t, ob.utxos[0:6], result) mineTxNSetNonceMark(ob, 2, dummyTxID, 0) // mine a transaction and set nonce-mark utxo for nonce 2 @@ -510,7 +509,7 @@ func TestSelectUTXOs(t *testing.T) { // output: [0.00002002, 0.24, 0.5, 1.26, 2.97, 3.28], 8.25002002 result, amount, _, _, err = ob.SelectUTXOs(8.05, 5, 3, math.MaxUint16, true) require.Nil(t, err) - assert.InEpsilon(t, 8.25002002, amount, 1e-8) + require.InEpsilon(t, 8.25002002, amount, 1e-8) expected := append([]btcjson.ListUnspentResult{ob.utxos[0]}, ob.utxos[4:9]...) require.Equal(t, expected, result) mineTxNSetNonceMark(ob, 24105431, dummyTxID, 0) // mine a transaction and set nonce-mark utxo for nonce 24105431 @@ -520,7 +519,7 @@ func TestSelectUTXOs(t *testing.T) { // output: [0.24107432, 0.01, 0.12, 0.18, 0.24], 0.55002002 result, amount, _, _, err = ob.SelectUTXOs(0.503, 5, 24105432, math.MaxUint16, true) require.Nil(t, err) - assert.InEpsilon(t, 0.79107431, amount, 1e-8) + require.InEpsilon(t, 0.79107431, amount, 1e-8) expected = append([]btcjson.ListUnspentResult{ob.utxos[4]}, ob.utxos[0:4]...) require.Equal(t, expected, result) mineTxNSetNonceMark(ob, 24105432, dummyTxID, 4) // mine a transaction and set nonce-mark utxo for nonce 24105432 @@ -530,7 +529,7 @@ func TestSelectUTXOs(t *testing.T) { // output: [0.24107432, 0.12, 0.18, 0.24, 0.5], 1.28107432 result, amount, _, _, err = ob.SelectUTXOs(1.0, 5, 24105433, math.MaxUint16, true) require.Nil(t, err) - assert.InEpsilon(t, 1.28107432, amount, 1e-8) + require.InEpsilon(t, 1.28107432, amount, 1e-8) expected = append([]btcjson.ListUnspentResult{ob.utxos[4]}, ob.utxos[1:4]...) expected = append(expected, ob.utxos[5]) require.Equal(t, expected, result) @@ -540,7 +539,7 @@ func TestSelectUTXOs(t *testing.T) { // output: [0.24107432, 1.26, 2.97, 3.28, 5.16, 8.72], 21.63107432 result, amount, _, _, err = ob.SelectUTXOs(16.03, 5, 24105433, math.MaxUint16, true) require.Nil(t, err) - assert.InEpsilon(t, 21.63107432, amount, 1e-8) + require.InEpsilon(t, 21.63107432, amount, 1e-8) expected = append([]btcjson.ListUnspentResult{ob.utxos[4]}, ob.utxos[6:11]...) require.Equal(t, expected, result) @@ -631,7 +630,7 @@ func TestUTXOConsolidation(t *testing.T) { // output: [0.24107431, 0.01, 0.12, 1.26, 0.5, 0.24], 2.37107431 result, amount, clsdtUtxo, clsdtValue, err := ob.SelectUTXOs(0.13, 5, 24105432, 5, true) require.Nil(t, err) - assert.InEpsilon(t, 2.37107431, amount, 1e-8) + require.InEpsilon(t, 2.37107431, amount, 1e-8) expected := append([]btcjson.ListUnspentResult{ob.utxos[4]}, ob.utxos[0:2]...) expected = append(expected, ob.utxos[6]) expected = append(expected, ob.utxos[5]) @@ -649,7 +648,7 @@ func TestUTXOConsolidation(t *testing.T) { // output: [0.24107431, 0.01, 0.12, 8.72, 5.16, 3.28, 2.97, 1.26, 0.5, 0.24, 0.18], 22.68107431 result, amount, clsdtUtxo, clsdtValue, err := ob.SelectUTXOs(0.13, 12, 24105432, 1, true) require.Nil(t, err) - assert.InEpsilon(t, 22.68107431, amount, 1e-8) + require.InEpsilon(t, 22.68107431, amount, 1e-8) expected := append([]btcjson.ListUnspentResult{ob.utxos[4]}, ob.utxos[0:2]...) for i := 10; i >= 5; i-- { // append consolidated utxos in descending order expected = append(expected, ob.utxos[i]) diff --git a/zetaclient/supplychecker/zeta_supply_checker_test.go b/zetaclient/supplychecker/zeta_supply_checker_test.go index c2b788cff1..73e3afd32d 100644 --- a/zetaclient/supplychecker/zeta_supply_checker_test.go +++ b/zetaclient/supplychecker/zeta_supply_checker_test.go @@ -6,7 +6,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/rs/zerolog" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func MustNewIntFromString(val string) sdkmath.Int { @@ -25,7 +25,7 @@ func TestZetaSupplyChecker_ValidateZetaSupply(t *testing.T) { externalChainTotalSupply sdkmath.Int zetaTokenSupplyOnNode sdkmath.Int ethLockedAmount sdkmath.Int - validate assert.BoolAssertionFunc + validate require.BoolAssertionFunc }{ { name: "1 zeta cctx in progress", @@ -35,8 +35,8 @@ func TestZetaSupplyChecker_ValidateZetaSupply(t *testing.T) { genesisAmounts: MustNewIntFromString("1000000000000000000"), zetaTokenSupplyOnNode: MustNewIntFromString("1000000000000000000"), ethLockedAmount: MustNewIntFromString("10000000000000000000"), - validate: func(t assert.TestingT, b bool, i ...interface{}) bool { - return assert.True(t, b, i...) + validate: func(t require.TestingT, b bool, i ...interface{}) { + require.True(t, b, i...) }, }, // Todo add more scenarios diff --git a/zetaclient/tss/tss_signer_test.go b/zetaclient/tss/tss_signer_test.go index 3a78c4a4d0..d4cc48f7ce 100644 --- a/zetaclient/tss/tss_signer_test.go +++ b/zetaclient/tss/tss_signer_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/rs/zerolog" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/common/cosmos" ) @@ -36,17 +36,17 @@ func Test_LoadTssFilesFromDirectory(t *testing.T) { for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { tempdir, err := os.MkdirTemp("", "test-tss") - assert.NoError(t, err) + require.NoError(t, err) err = GenerateKeyshareFiles(tc.n, tempdir) - assert.NoError(t, err) + require.NoError(t, err) tss := TSS{ logger: zerolog.New(os.Stdout), Keys: map[string]*Key{}, CurrentPubkey: "", } err = tss.LoadTssFilesFromDirectory(tempdir) - assert.NoError(t, err) - assert.Equal(t, tc.n, len(tss.Keys)) + require.NoError(t, err) + require.Equal(t, tc.n, len(tss.Keys)) }) } } From 46329c0d33d989f061a446ccc88a97f686f748ba Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 14 Feb 2024 09:43:40 +0000 Subject: [PATCH 3/3] chore: add skosito to codeowners (#1751) Co-authored-by: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> Co-authored-by: Lucas Bertrand --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7c2bcf799b..40fa15acbf 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ -* @brewmaster012 @kingpinXD @kevinssgh @fadeev @lumtis @ws4charlie +* @brewmaster012 @kingpinXD @kevinssgh @fadeev @lumtis @ws4charlie @skosito .github/** @zeta-chain/devops