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