From b5c3e0301840b90f8d55dd892963acd3908d7e79 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Mon, 18 Nov 2024 09:51:39 -0800 Subject: [PATCH 01/15] fix(zetaclient): lock pingRTT for writing (#3181) --- cmd/zetaclientd/start.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 46d204fa34..b9722c9213 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -231,6 +231,7 @@ func Start(_ *cobra.Command, _ []string) error { go func() { host := tssServer.GetP2PHost() pingRTT := make(map[peer.ID]int64) + pingRTTLock := sync.Mutex{} for { var wg sync.WaitGroup for _, p := range whitelistedPeers { @@ -240,6 +241,8 @@ func Start(_ *cobra.Command, _ []string) error { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() result := <-ping.Ping(ctx, host, p) + pingRTTLock.Lock() + defer pingRTTLock.Unlock() if result.Error != nil { masterLogger.Error().Err(result.Error).Msg("ping error") pingRTT[p] = -1 // RTT -1 indicate ping error From 9d299f05c94e9b3d781f6385578cd474cb7bb411 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Mon, 18 Nov 2024 13:07:19 -0800 Subject: [PATCH 02/15] fix(ci): move skip_checks to step (#3163) --- .github/workflows/publish-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 924706af29..02977127ff 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -44,11 +44,11 @@ jobs: echo "${{ github.ref }}" check-goreleaser: - if: inputs.skip_checks != true runs-on: ${{ vars.RELEASE_RUNNER }} steps: - uses: actions/checkout@v4 - name: Build release snapshot + if: inputs.skip_checks != true run: | make release-snapshot From 85d508a89a5bdd8a28f3561f246cf2c552b6e7da Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Wed, 20 Nov 2024 13:09:33 +0100 Subject: [PATCH 03/15] fix: support tracker processing for v2 inbounds (#3179) * add tracker processing for v2 inbound * fmt * add inbound tracker e2e test * successful test * changelgo * add comment to PR * fix tests * add back ton sidecar config * comments --- changelog.md | 4 + cmd/zetae2e/config/local.yml | 4 +- cmd/zetae2e/run.go | 26 ++++++ e2e/e2etests/e2etests.go | 13 ++- e2e/e2etests/test_inbound_trackers.go | 87 ++++++++++++++++++ e2e/runner/zeta.go | 18 ++++ zetaclient/chains/base/observer.go | 2 +- zetaclient/chains/evm/observer/inbound.go | 52 +++++++---- .../chains/evm/observer/v2_inbound_tracker.go | 88 +++++++++++++++++++ 9 files changed, 272 insertions(+), 22 deletions(-) create mode 100644 e2e/e2etests/test_inbound_trackers.go create mode 100644 zetaclient/chains/evm/observer/v2_inbound_tracker.go diff --git a/changelog.md b/changelog.md index 184790d68f..2d1b39ead5 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## Unreleased ### Features + * [2984](https://github.com/zeta-chain/node/pull/2984) - add Whitelist message ability to whitelist SPL tokens on Solana * [3091](https://github.com/zeta-chain/node/pull/3091) - improve build reproducability. `make release{,-build-only}` checksums should now be stable. * [3124](https://github.com/zeta-chain/node/pull/3124) - integrate SPL deposits @@ -15,6 +16,7 @@ * [3154](https://github.com/zeta-chain/node/pull/3154) - configure Solana gateway program id for E2E tests ### Refactor + * [3118](https://github.com/zeta-chain/node/pull/3118) - zetaclient: remove hsm signer * [3122](https://github.com/zeta-chain/node/pull/3122) - improve & refactor zetaclientd cli * [3125](https://github.com/zeta-chain/node/pull/3125) - drop support for header proofs @@ -22,6 +24,7 @@ * [3137](https://github.com/zeta-chain/node/pull/3137) - remove chain.Chain from zetaclientd config ### Fixes + * [3117](https://github.com/zeta-chain/node/pull/3117) - register messages for emissions module to legacy amino codec. * [3041](https://github.com/zeta-chain/node/pull/3041) - replace libp2p public DHT with private gossip peer discovery and connection gater for inbound connections * [3106](https://github.com/zeta-chain/node/pull/3106) - prevent blocked CCTX on out of gas during omnichain calls @@ -29,6 +32,7 @@ * [3149](https://github.com/zeta-chain/node/pull/3149) - abort the cctx if dust amount is detected in the revert outbound * [3155](https://github.com/zeta-chain/node/pull/3155) - fix potential panic in the Bitcoin inscription parsing * [3162](https://github.com/zeta-chain/node/pull/3162) - skip depositor fee calculation if transaction does not involve TSS address +* [3179](https://github.com/zeta-chain/node/pull/3179) - support inbound trackers for v2 cctx ## v21.0.0 diff --git a/cmd/zetae2e/config/local.yml b/cmd/zetae2e/config/local.yml index e4ec147e49..aed44fc155 100644 --- a/cmd/zetae2e/config/local.yml +++ b/cmd/zetae2e/config/local.yml @@ -110,13 +110,15 @@ contracts: wzeta: "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf" test_dapp: "0xA8D5060feb6B456e886F023709A2795373691E63" gateway: "0xa825eAa55b497AF892faca73a3797046C10B7c23" + test_dapp_v2: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed" evm: zeta_eth: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9" connector_eth: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca" - custody: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a" + custody: "0x784aE8B474aebabB74526701146a708734f6931c" erc20: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564" test_dapp: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed" gateway: "0xF0deebCB0E9C829519C4baa794c5445171973826" + test_dapp_v2: "0xa825eAa55b497AF892faca73a3797046C10B7c23" solana: gateway_program_id: "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d" spl: "" \ No newline at end of file diff --git a/cmd/zetae2e/run.go b/cmd/zetae2e/run.go index fe52f056d5..91116f234c 100644 --- a/cmd/zetae2e/run.go +++ b/cmd/zetae2e/run.go @@ -16,6 +16,8 @@ import ( "github.com/zeta-chain/node/e2e/config" "github.com/zeta-chain/node/e2e/e2etests" "github.com/zeta-chain/node/e2e/runner" + "github.com/zeta-chain/node/e2e/txserver" + "github.com/zeta-chain/node/e2e/utils" fungibletypes "github.com/zeta-chain/node/x/fungible/types" observertypes "github.com/zeta-chain/node/x/observer/types" ) @@ -104,6 +106,29 @@ func runE2ETest(cmd *cobra.Command, args []string) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + var runnerOpts []runner.E2ERunnerOption + + // if keys are defined for all policy accounts, we initialize a ZETA tx server allowing to send admin actions + emergencyKey := conf.PolicyAccounts.EmergencyPolicyAccount.RawPrivateKey.String() + operationalKey := conf.PolicyAccounts.OperationalPolicyAccount.RawPrivateKey.String() + adminKey := conf.PolicyAccounts.AdminPolicyAccount.RawPrivateKey.String() + if emergencyKey != "" && operationalKey != "" && adminKey != "" { + zetaTxServer, err := txserver.NewZetaTxServer( + conf.RPCs.ZetaCoreRPC, + []string{utils.EmergencyPolicyName, utils.OperationalPolicyName, utils.AdminPolicyName}, + []string{ + emergencyKey, + operationalKey, + adminKey, + }, + conf.ZetaChainID, + ) + if err != nil { + return err + } + runnerOpts = append(runnerOpts, runner.WithZetaTxServer(zetaTxServer)) + } + // initialize deployer runner with config testRunner, err := zetae2econfig.RunnerFromConfig( ctx, @@ -112,6 +137,7 @@ func runE2ETest(cmd *cobra.Command, args []string) error { conf, conf.DefaultAccount, logger, + runnerOpts..., ) if err != nil { return err diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 52c7022be5..53c145372d 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -110,9 +110,10 @@ const ( Miscellaneous tests Test various functionalities not related to assets */ - TestContextUpgradeName = "context_upgrade" - TestMyTestName = "my_test" - TestDonationEtherName = "donation_ether" + TestContextUpgradeName = "context_upgrade" + TestMyTestName = "my_test" + TestDonationEtherName = "donation_ether" + TestInboundTrackersName = "inbound_trackers" /* Stress tests @@ -737,6 +738,12 @@ var AllE2ETests = []runner.E2ETest{ }, TestDonationEther, ), + runner.NewE2ETest( + TestInboundTrackersName, + "test processing inbound trackers for observation", + []runner.ArgDefinition{}, + TestInboundTrackers, + ), /* Stress tests */ diff --git a/e2e/e2etests/test_inbound_trackers.go b/e2e/e2etests/test_inbound_trackers.go new file mode 100644 index 0000000000..b26b505cf1 --- /dev/null +++ b/e2e/e2etests/test_inbound_trackers.go @@ -0,0 +1,87 @@ +package e2etests + +import ( + "math/big" + + "github.com/stretchr/testify/require" + "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol" + + "github.com/zeta-chain/node/e2e/runner" + "github.com/zeta-chain/node/e2e/utils" + "github.com/zeta-chain/node/pkg/coin" + crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" +) + +// TestInboundTrackers tests inbound trackers processing in ZetaClient +// It run deposits, send inbound trackers and check cctxs are mined +// IMPORTANT: the test requires inbound observation to be disabled, the following line should be uncommented: +// https://github.com/zeta-chain/node/blob/9dcb42729653e033f5ba60a77dc37e5e19b092ad/zetaclient/chains/evm/observer/inbound.go#L210 +func TestInboundTrackers(r *runner.E2ERunner, args []string) { + require.Len(r, args, 0) + + amount := big.NewInt(1e17) + + addTrackerAndWaitForCCTX := func(coinType coin.CoinType, txHash string) { + r.AddInboundTracker(coinType, txHash) + cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, txHash, r.CctxClient, r.Logger, r.CctxTimeout) + require.EqualValues(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) + r.Logger.CCTX(*cctx, "cctx") + } + + // send v1 eth deposit + r.Logger.Print("🏃test v1 eth deposit") + txHash := r.DepositEtherWithAmount(amount) + addTrackerAndWaitForCCTX(coin.CoinType_Gas, txHash.Hex()) + r.Logger.Print("🍾v1 eth deposit observed") + + // send v1 erc20 deposit + r.Logger.Print("🏃test v1 erc20 deposit") + txHash = r.DepositERC20WithAmountAndMessage(r.EVMAddress(), amount, []byte{}) + addTrackerAndWaitForCCTX(coin.CoinType_ERC20, txHash.Hex()) + r.Logger.Print("🍾v1 erc20 deposit observed") + + // send v2 eth deposit + r.Logger.Print("🏃test v2 eth deposit") + tx := r.V2ETHDeposit(r.EVMAddress(), amount, gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}) + addTrackerAndWaitForCCTX(coin.CoinType_Gas, tx.Hash().Hex()) + r.Logger.Print("🍾v2 eth deposit observed") + + // send v2 eth deposit and call + r.Logger.Print("🏃test v2 eth eposit and call") + tx = r.V2ETHDepositAndCall( + r.TestDAppV2ZEVMAddr, + amount, + []byte(randomPayload(r)), + gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, + ) + addTrackerAndWaitForCCTX(coin.CoinType_Gas, tx.Hash().Hex()) + r.Logger.Print("🍾v2 eth deposit and call observed") + + // send v2 erc20 deposit + r.Logger.Print("🏃test v2 erc20 deposit") + r.ApproveERC20OnEVM(r.GatewayEVMAddr) + tx = r.V2ERC20Deposit(r.EVMAddress(), amount, gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}) + addTrackerAndWaitForCCTX(coin.CoinType_Gas, tx.Hash().Hex()) + r.Logger.Print("🍾v2 erc20 deposit observed") + + // send v2 erc20 deposit and call + r.Logger.Print("🏃test v2 erc20 deposit and call") + tx = r.V2ERC20DepositAndCall( + r.TestDAppV2ZEVMAddr, + amount, + []byte(randomPayload(r)), + gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, + ) + addTrackerAndWaitForCCTX(coin.CoinType_Gas, tx.Hash().Hex()) + r.Logger.Print("🍾v2 erc20 deposit and call observed") + + // send v2 call + r.Logger.Print("🏃test v2 call") + tx = r.V2EVMToZEMVCall( + r.TestDAppV2ZEVMAddr, + []byte(randomPayload(r)), + gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, + ) + addTrackerAndWaitForCCTX(coin.CoinType_NoAssetCall, tx.Hash().Hex()) + r.Logger.Print("🍾v2 call observed") +} diff --git a/e2e/runner/zeta.go b/e2e/runner/zeta.go index d59ef85645..fe55c3946c 100644 --- a/e2e/runner/zeta.go +++ b/e2e/runner/zeta.go @@ -15,6 +15,7 @@ import ( "github.com/zeta-chain/node/e2e/utils" "github.com/zeta-chain/node/pkg/chains" + "github.com/zeta-chain/node/pkg/coin" "github.com/zeta-chain/node/pkg/retry" "github.com/zeta-chain/node/x/crosschain/types" observertypes "github.com/zeta-chain/node/x/observer/types" @@ -332,3 +333,20 @@ func (r *E2ERunner) skipChainOperations(chainID int64) bool { return skip } + +// AddInboundTracker adds an inbound tracker from the tx hash +func (r *E2ERunner) AddInboundTracker(coinType coin.CoinType, txHash string) { + require.NotNil(r, r.ZetaTxServer) + + chainID, err := r.EVMClient.ChainID(r.Ctx) + require.NoError(r, err) + + msg := types.NewMsgAddInboundTracker( + r.ZetaTxServer.MustGetAccountAddressFromName(utils.EmergencyPolicyName), + chainID.Int64(), + coinType, + txHash, + ) + _, err = r.ZetaTxServer.BroadcastTx(utils.EmergencyPolicyName, msg) + require.NoError(r, err) +} diff --git a/zetaclient/chains/base/observer.go b/zetaclient/chains/base/observer.go index 67f38e627a..9056e3aa1d 100644 --- a/zetaclient/chains/base/observer.go +++ b/zetaclient/chains/base/observer.go @@ -211,7 +211,7 @@ func (ob *Observer) WithZetacoreClient(client interfaces.ZetacoreClient) *Observ return ob } -// Tss returns the tss signer for the observer. +// TSS returns the tss signer for the observer. func (ob *Observer) TSS() interfaces.TSSSigner { return ob.tss } diff --git a/zetaclient/chains/evm/observer/inbound.go b/zetaclient/chains/evm/observer/inbound.go index cb409f408e..d7632ac192 100644 --- a/zetaclient/chains/evm/observer/inbound.go +++ b/zetaclient/chains/evm/observer/inbound.go @@ -121,6 +121,7 @@ func (ob *Observer) ProcessInboundTrackers(ctx context.Context) error { if err != nil { return err } + for _, tracker := range trackers { // query tx and receipt tx, _, err := ob.TransactionByHash(tracker.TxHash) @@ -144,24 +145,35 @@ func (ob *Observer) ProcessInboundTrackers(ctx context.Context) error { } ob.Logger().Inbound.Info().Msgf("checking tracker for inbound %s chain %d", tracker.TxHash, ob.Chain().ChainId) - // check and vote on inbound tx - switch tracker.CoinType { - case coin.CoinType_Zeta: - _, err = ob.CheckAndVoteInboundTokenZeta(ctx, tx, receipt, true) - case coin.CoinType_ERC20: - _, err = ob.CheckAndVoteInboundTokenERC20(ctx, tx, receipt, true) - case coin.CoinType_Gas: - _, err = ob.CheckAndVoteInboundTokenGas(ctx, tx, receipt, true) - default: - return fmt.Errorf( - "unknown coin type %s for inbound %s chain %d", - tracker.CoinType, - tx.Hash, - ob.Chain().ChainId, - ) - } + // if the transaction is sent to the gateway, this is a v2 inbound + gatewayAddr, gateway, err := ob.GetGatewayContract() if err != nil { - return errors.Wrapf(err, "error checking and voting for inbound %s chain %d", tx.Hash, ob.Chain().ChainId) + ob.Logger().Inbound.Debug().Err(err).Msg("error getting gateway contract for processing inbound tracker") + } + if err == nil && tx != nil && ethcommon.HexToAddress(tx.To) == gatewayAddr { + if err := ob.ProcessInboundTrackerV2(ctx, gateway, tx, receipt); err != nil { + return err + } + } else { + // check and vote on inbound tx + switch tracker.CoinType { + case coin.CoinType_Zeta: + _, err = ob.CheckAndVoteInboundTokenZeta(ctx, tx, receipt, true) + case coin.CoinType_ERC20: + _, err = ob.CheckAndVoteInboundTokenERC20(ctx, tx, receipt, true) + case coin.CoinType_Gas: + _, err = ob.CheckAndVoteInboundTokenGas(ctx, tx, receipt, true) + default: + return fmt.Errorf( + "unknown coin type %s for inbound %s chain %d", + tracker.CoinType, + tx.Hash, + ob.Chain().ChainId, + ) + } + if err != nil { + return errors.Wrapf(err, "error checking and voting for inbound %s chain %d", tx.Hash, ob.Chain().ChainId) + } } } return nil @@ -186,6 +198,12 @@ func (ob *Observer) ObserveInbound(ctx context.Context, sampledLogger zerolog.Lo // increment prom counter metrics.GetBlockByNumberPerChain.WithLabelValues(ob.Chain().Name).Inc() + // uncomment this line to stop observing inbound and test observation with inbound trackers + // https://github.com/zeta-chain/node/blob/3879b5ef8b418542c82a4383263604222f0605c6/e2e/e2etests/test_inbound_trackers.go#L19 + // TODO: implement a better way to disable inbound observation + // https://github.com/zeta-chain/node/issues/3186 + //return nil + // skip if current height is too low if blockNumber < ob.ChainParams().ConfirmationCount { return fmt.Errorf("observeInbound: skipping observer, current block number %d is too low", blockNumber) diff --git a/zetaclient/chains/evm/observer/v2_inbound_tracker.go b/zetaclient/chains/evm/observer/v2_inbound_tracker.go new file mode 100644 index 0000000000..11f39fe2a5 --- /dev/null +++ b/zetaclient/chains/evm/observer/v2_inbound_tracker.go @@ -0,0 +1,88 @@ +package observer + +import ( + "context" + "fmt" + + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/onrik/ethrpc" + "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol" + + "github.com/zeta-chain/node/zetaclient/zetacore" +) + +// ProcessInboundTrackerV2 processes inbound tracker events from the gateway +func (ob *Observer) ProcessInboundTrackerV2( + ctx context.Context, + gateway *gatewayevm.GatewayEVM, + tx *ethrpc.Transaction, + receipt *ethtypes.Receipt, +) error { + // check confirmations + if confirmed := ob.HasEnoughConfirmations(receipt, ob.LastBlock()); !confirmed { + return fmt.Errorf( + "inbound %s has not been confirmed yet: receipt block %d", + tx.Hash, + receipt.BlockNumber.Uint64(), + ) + } + + for _, log := range receipt.Logs { + if log == nil { + continue + } + + // try parsing deposit + eventDeposit, err := gateway.ParseDeposited(*log) + if err == nil { + // check if the event is processable + if !ob.checkEventProcessability( + eventDeposit.Sender, + eventDeposit.Receiver, + eventDeposit.Raw.TxHash, + eventDeposit.Payload, + ) { + return fmt.Errorf("event from inbound tracker %s is not processable", tx.Hash) + } + msg := ob.newDepositInboundVote(eventDeposit) + _, err = ob.PostVoteInbound(ctx, &msg, zetacore.PostVoteInboundExecutionGasLimit) + return err + } + + // try parsing deposit and call + eventDepositAndCall, err := gateway.ParseDepositedAndCalled(*log) + if err == nil { + // check if the event is processable + if !ob.checkEventProcessability( + eventDepositAndCall.Sender, + eventDepositAndCall.Receiver, + eventDepositAndCall.Raw.TxHash, + eventDepositAndCall.Payload, + ) { + return fmt.Errorf("event from inbound tracker %s is not processable", tx.Hash) + } + msg := ob.newDepositAndCallInboundVote(eventDepositAndCall) + _, err = ob.PostVoteInbound(ctx, &msg, zetacore.PostVoteInboundExecutionGasLimit) + return err + } + + // try parsing call + eventCall, err := gateway.ParseCalled(*log) + if err == nil { + // check if the event is processable + if !ob.checkEventProcessability( + eventCall.Sender, + eventCall.Receiver, + eventCall.Raw.TxHash, + eventCall.Payload, + ) { + return fmt.Errorf("event from inbound tracker %s is not processable", tx.Hash) + } + msg := ob.newCallInboundVote(eventCall) + _, err = ob.PostVoteInbound(ctx, &msg, zetacore.PostVoteInboundExecutionGasLimit) + return err + } + } + + return fmt.Errorf("no gateway event found in inbound tracker %s", tx.Hash) +} From f5e5adb7b72a8b38b18b07f0c642c16f21fbfa57 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 20 Nov 2024 09:43:24 -0800 Subject: [PATCH 04/15] feat(zetaclient): enable pprof http server (#3182) * feat(zetaclient): enable pprof http server * changelog * fmt --- changelog.md | 1 + cmd/zetaclientd/start.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/changelog.md b/changelog.md index 2d1b39ead5..378991ce1a 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,7 @@ * [3091](https://github.com/zeta-chain/node/pull/3091) - improve build reproducability. `make release{,-build-only}` checksums should now be stable. * [3124](https://github.com/zeta-chain/node/pull/3124) - integrate SPL deposits * [3134](https://github.com/zeta-chain/node/pull/3134) - integrate SPL tokens withdraw to Solana +* [3182](https://github.com/zeta-chain/node/pull/3182) - enable zetaclient pprof server on port 6061 ### Tests diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index b9722c9213..0ac52f0690 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -5,6 +5,8 @@ import ( "encoding/json" "fmt" "io" + "net/http" + _ "net/http/pprof" // #nosec G108 -- pprof enablement is intentional "os" "os/signal" "path/filepath" @@ -256,6 +258,15 @@ func Start(_ *cobra.Command, _ []string) error { time.Sleep(30 * time.Second) } }() + // pprof http server + // zetacored/cometbft is already listening for pprof on 6060 (by default) + go func() { + // #nosec G114 -- timeouts uneeded + err := http.ListenAndServe("localhost:6061", nil) + if err != nil { + log.Error().Err(err).Msg("pprof http server error") + } + }() // Generate a new TSS if keygen is set and add it into the tss server // If TSS has already been generated, and keygen was successful ; we use the existing TSS From 495235ea84580acb2229596f8da6eac589f2ed93 Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 21 Nov 2024 10:56:13 +0000 Subject: [PATCH 05/15] test(e2e): add e2e test for v2 deposit and call with swap (#3188) * add v2 deposit and call with swap test * changelog * PR comments --- changelog.md | 1 + cmd/zetae2e/local/v2.go | 1 + e2e/contracts/zevmswap/ZEVMSwapApp.abi | 45 ++++++++++ e2e/contracts/zevmswap/ZEVMSwapApp.bin | 2 +- e2e/contracts/zevmswap/ZEVMSwapApp.go | 25 +++++- e2e/contracts/zevmswap/ZEVMSwapApp.json | 47 +++++++++- e2e/contracts/zevmswap/ZEVMSwapApp.sol | 24 +++++ e2e/e2etests/e2etests.go | 7 ++ e2e/e2etests/test_v2_deposit_and_call_swap.go | 88 +++++++++++++++++++ 9 files changed, 236 insertions(+), 4 deletions(-) create mode 100644 e2e/e2etests/test_v2_deposit_and_call_swap.go diff --git a/changelog.md b/changelog.md index 378991ce1a..6992b9a706 100644 --- a/changelog.md +++ b/changelog.md @@ -15,6 +15,7 @@ * [3075](https://github.com/zeta-chain/node/pull/3075) - ton: withdraw concurrent, deposit & revert. * [3105](https://github.com/zeta-chain/node/pull/3105) - split Bitcoin E2E tests into two runners for deposit and withdraw * [3154](https://github.com/zeta-chain/node/pull/3154) - configure Solana gateway program id for E2E tests +* [3188](https://github.com/zeta-chain/node/pull/3188) - add e2e test for v2 deposit and call with swap ### Refactor diff --git a/cmd/zetae2e/local/v2.go b/cmd/zetae2e/local/v2.go index 770d7201ef..88423b9742 100644 --- a/cmd/zetae2e/local/v2.go +++ b/cmd/zetae2e/local/v2.go @@ -40,6 +40,7 @@ func startV2Tests(eg *errgroup.Group, conf config.Config, deployerRunner *runner e2etests.TestV2ERC20WithdrawAndCallName, e2etests.TestV2ERC20DepositAndCallNoMessageName, e2etests.TestV2ERC20WithdrawAndCallNoMessageName, + e2etests.TestV2DepositAndCallSwapName, )) // Test revert cases for gas token workflow diff --git a/e2e/contracts/zevmswap/ZEVMSwapApp.abi b/e2e/contracts/zevmswap/ZEVMSwapApp.abi index 50bf177b93..39b360e605 100644 --- a/e2e/contracts/zevmswap/ZEVMSwapApp.abi +++ b/e2e/contracts/zevmswap/ZEVMSwapApp.abi @@ -73,6 +73,51 @@ "stateMutability": "pure", "type": "function" }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + } + ], + "internalType": "struct Context", + "name": "", + "type": "tuple" + }, + { + "internalType": "address", + "name": "zrc20", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "name": "onCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { diff --git a/e2e/contracts/zevmswap/ZEVMSwapApp.bin b/e2e/contracts/zevmswap/ZEVMSwapApp.bin index f512145bdd..8b208b65b3 100644 --- a/e2e/contracts/zevmswap/ZEVMSwapApp.bin +++ b/e2e/contracts/zevmswap/ZEVMSwapApp.bin @@ -1 +1 @@ -60c06040523480156200001157600080fd5b50604051620012ee380380620012ee833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161115b62000193600039600081816101b101526101f90152600081816101d50152818161039b0152610420015261115b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107bc565b610115565b6040516100849291906108da565b60405180910390f35b6100956101af565b6040516100a2919061090a565b60405180910390f35b6100b36101d3565b6040516100c0919061090a565b60405180910390f35b6100e360048036038101906100de91906109ab565b6101f7565b005b6100ff60048036038101906100fa9190610a4f565b610714565b60405161010c9190610aaf565b60405180910390f35b6000606080600080868690509150868660009060149261013793929190610adb565b906101429190610b5a565b60601c90508686601490809261015a93929190610adb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027c576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061028b8585610115565b8093508194505050600267ffffffffffffffff8111156102ae576102ad610bb9565b5b6040519080825280602002602001820160405280156102dc5781602001602082028036833780820191505090505b50905086816000815181106102f4576102f3610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034357610342610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103d8929190610c26565b6020604051808303816000875af11580156103f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b9190610c87565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b8152600401610489959493929190610db7565b6000604051808303816000875af11580156104a8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d19190610f35565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610520573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105449190610f93565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610583929190610c26565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c69190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106105fa576105f9610be8565b5b602002602001015161060c9190611002565b6040518363ffffffff1660e01b8152600401610629929190610c26565b6020604051808303816000875af1158015610648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066c9190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069e5761069d610be8565b5b60200260200101516040518363ffffffff1660e01b81526004016106c3929190611044565b6020604051808303816000875af11580156106e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107069190610c87565b505050505050505050505050565b606083838360405160200161072b939291906110fb565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261077c5761077b610757565b5b8235905067ffffffffffffffff8111156107995761079861075c565b5b6020830191508360018202830111156107b5576107b4610761565b5b9250929050565b600080602083850312156107d3576107d261074d565b5b600083013567ffffffffffffffff8111156107f1576107f0610752565b5b6107fd85828601610766565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061083482610809565b9050919050565b61084481610829565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610884578082015181840152602081019050610869565b60008484015250505050565b6000601f19601f8301169050919050565b60006108ac8261084a565b6108b68185610855565b93506108c6818560208601610866565b6108cf81610890565b840191505092915050565b60006040820190506108ef600083018561083b565b818103602083015261090181846108a1565b90509392505050565b600060208201905061091f600083018461083b565b92915050565b600080fd5b6000606082840312156109405761093f610925565b5b81905092915050565b61095281610829565b811461095d57600080fd5b50565b60008135905061096f81610949565b92915050565b6000819050919050565b61098881610975565b811461099357600080fd5b50565b6000813590506109a58161097f565b92915050565b6000806000806000608086880312156109c7576109c661074d565b5b600086013567ffffffffffffffff8111156109e5576109e4610752565b5b6109f18882890161092a565b9550506020610a0288828901610960565b9450506040610a1388828901610996565b935050606086013567ffffffffffffffff811115610a3457610a33610752565b5b610a4088828901610766565b92509250509295509295909350565b600080600060408486031215610a6857610a6761074d565b5b6000610a7686828701610960565b935050602084013567ffffffffffffffff811115610a9757610a96610752565b5b610aa386828701610766565b92509250509250925092565b60006020820190508181036000830152610ac981846108a1565b905092915050565b600080fd5b600080fd5b60008085851115610aef57610aee610ad1565b5b83861115610b0057610aff610ad6565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b668383610b16565b82610b718135610b21565b92506014821015610bb157610bac7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610b4d565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610c2081610975565b82525050565b6000604082019050610c3b600083018561083b565b610c486020830184610c17565b9392505050565b60008115159050919050565b610c6481610c4f565b8114610c6f57600080fd5b50565b600081519050610c8181610c5b565b92915050565b600060208284031215610c9d57610c9c61074d565b5b6000610cab84828501610c72565b91505092915050565b6000819050919050565b6000819050919050565b6000610ce3610cde610cd984610cb4565b610cbe565b610975565b9050919050565b610cf381610cc8565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610d2e81610829565b82525050565b6000610d408383610d25565b60208301905092915050565b6000602082019050919050565b6000610d6482610cf9565b610d6e8185610d04565b9350610d7983610d15565b8060005b83811015610daa578151610d918882610d34565b9750610d9c83610d4c565b925050600181019050610d7d565b5085935050505092915050565b600060a082019050610dcc6000830188610c17565b610dd96020830187610cea565b8181036040830152610deb8186610d59565b9050610dfa606083018561083b565b610e076080830184610c17565b9695505050505050565b610e1a82610890565b810181811067ffffffffffffffff82111715610e3957610e38610bb9565b5b80604052505050565b6000610e4c610743565b9050610e588282610e11565b919050565b600067ffffffffffffffff821115610e7857610e77610bb9565b5b602082029050602081019050919050565b600081519050610e988161097f565b92915050565b6000610eb1610eac84610e5d565b610e42565b90508083825260208201905060208402830185811115610ed457610ed3610761565b5b835b81811015610efd5780610ee98882610e89565b845260208401935050602081019050610ed6565b5050509392505050565b600082601f830112610f1c57610f1b610757565b5b8151610f2c848260208601610e9e565b91505092915050565b600060208284031215610f4b57610f4a61074d565b5b600082015167ffffffffffffffff811115610f6957610f68610752565b5b610f7584828501610f07565b91505092915050565b600081519050610f8d81610949565b92915050565b60008060408385031215610faa57610fa961074d565b5b6000610fb885828601610f7e565b9250506020610fc985828601610e89565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061100d82610975565b915061101883610975565b925082820261102681610975565b9150828204841483151761103d5761103c610fd3565b5b5092915050565b6000604082019050818103600083015261105e81856108a1565b905061106d6020830184610c17565b9392505050565b60008160601b9050919050565b600061108c82611074565b9050919050565b600061109e82611081565b9050919050565b6110b66110b182610829565b611093565b82525050565b600081905092915050565b82818337600083830152505050565b60006110e283856110bc565b93506110ef8385846110c7565b82840190509392505050565b600061110782866110a5565b6014820191506111188284866110d6565b915081905094935050505056fea2646970667358221220e59a6599851c1ec787995687e8a35035524f5024bc92edd5c91793d9c6e77adf64736f6c63430008170033 +60c060405234801561001057600080fd5b506040516117a63803806117a683398181016040528101906100329190610104565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250505050610144565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d1826100a6565b9050919050565b6100e1816100c6565b81146100ec57600080fd5b50565b6000815190506100fe816100d8565b92915050565b6000806040838503121561011b5761011a6100a1565b5b6000610129858286016100ef565b925050602061013a858286016100ef565b9150509250929050565b60805160a05161161a61018c6000396000818161067001526106b801526000818161025b015281816102e0015281816106940152818161085a01526108df015261161a6000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80635bcfd61614610067578063a06ea8bc14610083578063bb88b769146100b4578063bd00c9c4146100d2578063de43156e146100f0578063df73044e1461010c575b600080fd5b610081600480360381019061007c9190610d33565b61013c565b005b61009d60048036038101906100989190610dd7565b6105d4565b6040516100ab929190610ec3565b60405180910390f35b6100bc61066e565b6040516100c99190610ef3565b60405180910390f35b6100da610692565b6040516100e79190610ef3565b60405180910390f35b61010a60048036038101906101059190610d33565b6106b6565b005b61012660048036038101906101219190610f0e565b610bd3565b6040516101339190610f6e565b60405180910390f35b600060608061014b85856105d4565b8093508194505050600267ffffffffffffffff81111561016e5761016d610f90565b5b60405190808252806020026020018201604052801561019c5781602001602082028036833780820191505090505b50905086816000815181106101b4576101b3610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061020357610202610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b8152600401610298929190610ffd565b6020604051808303816000875af11580156102b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102db919061105e565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161034995949392919061118e565b6000604051808303816000875af1158015610368573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610391919061130c565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa1580156103e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610404919061136a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610443929190610ffd565b6020604051808303816000875af1158015610462573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610486919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106104ba576104b9610fbf565b5b60200260200101516104cc91906113d9565b6040518363ffffffff1660e01b81526004016104e9929190610ffd565b6020604051808303816000875af1158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061055e5761055d610fbf565b5b60200260200101516040518363ffffffff1660e01b815260040161058392919061141b565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c6919061105e565b505050505050505050505050565b600060608060008086869050915086866000906014926105f693929190611455565b9061060191906114d4565b60601c90508686601490809261061993929190611455565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461073b576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061074a85856105d4565b8093508194505050600267ffffffffffffffff81111561076d5761076c610f90565b5b60405190808252806020026020018201604052801561079b5781602001602082028036833780820191505090505b50905086816000815181106107b3576107b2610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061080257610801610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b8152600401610897929190610ffd565b6020604051808303816000875af11580156108b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108da919061105e565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161094895949392919061118e565b6000604051808303816000875af1158015610967573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610990919061130c565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa1580156109df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a03919061136a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610a42929190610ffd565b6020604051808303816000875af1158015610a61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a85919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a86600181518110610ab957610ab8610fbf565b5b6020026020010151610acb91906113d9565b6040518363ffffffff1660e01b8152600401610ae8929190610ffd565b6020604051808303816000875af1158015610b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268685600181518110610b5d57610b5c610fbf565b5b60200260200101516040518363ffffffff1660e01b8152600401610b8292919061141b565b6020604051808303816000875af1158015610ba1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc5919061105e565b505050505050505050505050565b6060838383604051602001610bea939291906115ba565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600060608284031215610c3157610c30610c16565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610c6582610c3a565b9050919050565b610c7581610c5a565b8114610c8057600080fd5b50565b600081359050610c9281610c6c565b92915050565b6000819050919050565b610cab81610c98565b8114610cb657600080fd5b50565b600081359050610cc881610ca2565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112610cf357610cf2610cce565b5b8235905067ffffffffffffffff811115610d1057610d0f610cd3565b5b602083019150836001820283011115610d2c57610d2b610cd8565b5b9250929050565b600080600080600060808688031215610d4f57610d4e610c0c565b5b600086013567ffffffffffffffff811115610d6d57610d6c610c11565b5b610d7988828901610c1b565b9550506020610d8a88828901610c83565b9450506040610d9b88828901610cb9565b935050606086013567ffffffffffffffff811115610dbc57610dbb610c11565b5b610dc888828901610cdd565b92509250509295509295909350565b60008060208385031215610dee57610ded610c0c565b5b600083013567ffffffffffffffff811115610e0c57610e0b610c11565b5b610e1885828601610cdd565b92509250509250929050565b610e2d81610c5a565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610e6d578082015181840152602081019050610e52565b60008484015250505050565b6000601f19601f8301169050919050565b6000610e9582610e33565b610e9f8185610e3e565b9350610eaf818560208601610e4f565b610eb881610e79565b840191505092915050565b6000604082019050610ed86000830185610e24565b8181036020830152610eea8184610e8a565b90509392505050565b6000602082019050610f086000830184610e24565b92915050565b600080600060408486031215610f2757610f26610c0c565b5b6000610f3586828701610c83565b935050602084013567ffffffffffffffff811115610f5657610f55610c11565b5b610f6286828701610cdd565b92509250509250925092565b60006020820190508181036000830152610f888184610e8a565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610ff781610c98565b82525050565b60006040820190506110126000830185610e24565b61101f6020830184610fee565b9392505050565b60008115159050919050565b61103b81611026565b811461104657600080fd5b50565b60008151905061105881611032565b92915050565b60006020828403121561107457611073610c0c565b5b600061108284828501611049565b91505092915050565b6000819050919050565b6000819050919050565b60006110ba6110b56110b08461108b565b611095565b610c98565b9050919050565b6110ca8161109f565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61110581610c5a565b82525050565b600061111783836110fc565b60208301905092915050565b6000602082019050919050565b600061113b826110d0565b61114581856110db565b9350611150836110ec565b8060005b83811015611181578151611168888261110b565b975061117383611123565b925050600181019050611154565b5085935050505092915050565b600060a0820190506111a36000830188610fee565b6111b060208301876110c1565b81810360408301526111c28186611130565b90506111d16060830185610e24565b6111de6080830184610fee565b9695505050505050565b6111f182610e79565b810181811067ffffffffffffffff821117156112105761120f610f90565b5b80604052505050565b6000611223610c02565b905061122f82826111e8565b919050565b600067ffffffffffffffff82111561124f5761124e610f90565b5b602082029050602081019050919050565b60008151905061126f81610ca2565b92915050565b600061128861128384611234565b611219565b905080838252602082019050602084028301858111156112ab576112aa610cd8565b5b835b818110156112d457806112c08882611260565b8452602084019350506020810190506112ad565b5050509392505050565b600082601f8301126112f3576112f2610cce565b5b8151611303848260208601611275565b91505092915050565b60006020828403121561132257611321610c0c565b5b600082015167ffffffffffffffff8111156113405761133f610c11565b5b61134c848285016112de565b91505092915050565b60008151905061136481610c6c565b92915050565b6000806040838503121561138157611380610c0c565b5b600061138f85828601611355565b92505060206113a085828601611260565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006113e482610c98565b91506113ef83610c98565b92508282026113fd81610c98565b91508282048414831517611414576114136113aa565b5b5092915050565b600060408201905081810360008301526114358185610e8a565b90506114446020830184610fee565b9392505050565b600080fd5b600080fd5b600080858511156114695761146861144b565b5b8386111561147a57611479611450565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b60006114e08383611490565b826114eb813561149b565b9250601482101561152b576115267fffffffffffffffffffffffffffffffffffffffff000000000000000000000000836014036008026114c7565b831692505b505092915050565b60008160601b9050919050565b600061154b82611533565b9050919050565b600061155d82611540565b9050919050565b61157561157082610c5a565b611552565b82525050565b600081905092915050565b82818337600083830152505050565b60006115a1838561157b565b93506115ae838584611586565b82840190509392505050565b60006115c68286611564565b6014820191506115d7828486611595565b915081905094935050505056fea2646970667358221220154bbadb87b49f8568829220c413c264d9405e5acb49ef710acf293adbd4f01564736f6c634300081a0033 diff --git a/e2e/contracts/zevmswap/ZEVMSwapApp.go b/e2e/contracts/zevmswap/ZEVMSwapApp.go index b02a69f878..ecf0ef8dc2 100644 --- a/e2e/contracts/zevmswap/ZEVMSwapApp.go +++ b/e2e/contracts/zevmswap/ZEVMSwapApp.go @@ -38,8 +38,8 @@ type Context struct { // ZEVMSwapAppMetaData contains all meta data concerning the ZEVMSwapApp contract. var ZEVMSwapAppMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"router02_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"systemContract_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSender\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LowAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeMemo\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"targetZRC20\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"}],\"name\":\"encodeMemo\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structContext\",\"name\":\"\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"router02\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"systemContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x60c06040523480156200001157600080fd5b50604051620012ee380380620012ee833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161115b62000193600039600081816101b101526101f90152600081816101d50152818161039b0152610420015261115b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107bc565b610115565b6040516100849291906108da565b60405180910390f35b6100956101af565b6040516100a2919061090a565b60405180910390f35b6100b36101d3565b6040516100c0919061090a565b60405180910390f35b6100e360048036038101906100de91906109ab565b6101f7565b005b6100ff60048036038101906100fa9190610a4f565b610714565b60405161010c9190610aaf565b60405180910390f35b6000606080600080868690509150868660009060149261013793929190610adb565b906101429190610b5a565b60601c90508686601490809261015a93929190610adb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027c576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061028b8585610115565b8093508194505050600267ffffffffffffffff8111156102ae576102ad610bb9565b5b6040519080825280602002602001820160405280156102dc5781602001602082028036833780820191505090505b50905086816000815181106102f4576102f3610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034357610342610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103d8929190610c26565b6020604051808303816000875af11580156103f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b9190610c87565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b8152600401610489959493929190610db7565b6000604051808303816000875af11580156104a8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d19190610f35565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610520573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105449190610f93565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610583929190610c26565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c69190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106105fa576105f9610be8565b5b602002602001015161060c9190611002565b6040518363ffffffff1660e01b8152600401610629929190610c26565b6020604051808303816000875af1158015610648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066c9190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069e5761069d610be8565b5b60200260200101516040518363ffffffff1660e01b81526004016106c3929190611044565b6020604051808303816000875af11580156106e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107069190610c87565b505050505050505050505050565b606083838360405160200161072b939291906110fb565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261077c5761077b610757565b5b8235905067ffffffffffffffff8111156107995761079861075c565b5b6020830191508360018202830111156107b5576107b4610761565b5b9250929050565b600080602083850312156107d3576107d261074d565b5b600083013567ffffffffffffffff8111156107f1576107f0610752565b5b6107fd85828601610766565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061083482610809565b9050919050565b61084481610829565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610884578082015181840152602081019050610869565b60008484015250505050565b6000601f19601f8301169050919050565b60006108ac8261084a565b6108b68185610855565b93506108c6818560208601610866565b6108cf81610890565b840191505092915050565b60006040820190506108ef600083018561083b565b818103602083015261090181846108a1565b90509392505050565b600060208201905061091f600083018461083b565b92915050565b600080fd5b6000606082840312156109405761093f610925565b5b81905092915050565b61095281610829565b811461095d57600080fd5b50565b60008135905061096f81610949565b92915050565b6000819050919050565b61098881610975565b811461099357600080fd5b50565b6000813590506109a58161097f565b92915050565b6000806000806000608086880312156109c7576109c661074d565b5b600086013567ffffffffffffffff8111156109e5576109e4610752565b5b6109f18882890161092a565b9550506020610a0288828901610960565b9450506040610a1388828901610996565b935050606086013567ffffffffffffffff811115610a3457610a33610752565b5b610a4088828901610766565b92509250509295509295909350565b600080600060408486031215610a6857610a6761074d565b5b6000610a7686828701610960565b935050602084013567ffffffffffffffff811115610a9757610a96610752565b5b610aa386828701610766565b92509250509250925092565b60006020820190508181036000830152610ac981846108a1565b905092915050565b600080fd5b600080fd5b60008085851115610aef57610aee610ad1565b5b83861115610b0057610aff610ad6565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b668383610b16565b82610b718135610b21565b92506014821015610bb157610bac7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610b4d565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610c2081610975565b82525050565b6000604082019050610c3b600083018561083b565b610c486020830184610c17565b9392505050565b60008115159050919050565b610c6481610c4f565b8114610c6f57600080fd5b50565b600081519050610c8181610c5b565b92915050565b600060208284031215610c9d57610c9c61074d565b5b6000610cab84828501610c72565b91505092915050565b6000819050919050565b6000819050919050565b6000610ce3610cde610cd984610cb4565b610cbe565b610975565b9050919050565b610cf381610cc8565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610d2e81610829565b82525050565b6000610d408383610d25565b60208301905092915050565b6000602082019050919050565b6000610d6482610cf9565b610d6e8185610d04565b9350610d7983610d15565b8060005b83811015610daa578151610d918882610d34565b9750610d9c83610d4c565b925050600181019050610d7d565b5085935050505092915050565b600060a082019050610dcc6000830188610c17565b610dd96020830187610cea565b8181036040830152610deb8186610d59565b9050610dfa606083018561083b565b610e076080830184610c17565b9695505050505050565b610e1a82610890565b810181811067ffffffffffffffff82111715610e3957610e38610bb9565b5b80604052505050565b6000610e4c610743565b9050610e588282610e11565b919050565b600067ffffffffffffffff821115610e7857610e77610bb9565b5b602082029050602081019050919050565b600081519050610e988161097f565b92915050565b6000610eb1610eac84610e5d565b610e42565b90508083825260208201905060208402830185811115610ed457610ed3610761565b5b835b81811015610efd5780610ee98882610e89565b845260208401935050602081019050610ed6565b5050509392505050565b600082601f830112610f1c57610f1b610757565b5b8151610f2c848260208601610e9e565b91505092915050565b600060208284031215610f4b57610f4a61074d565b5b600082015167ffffffffffffffff811115610f6957610f68610752565b5b610f7584828501610f07565b91505092915050565b600081519050610f8d81610949565b92915050565b60008060408385031215610faa57610fa961074d565b5b6000610fb885828601610f7e565b9250506020610fc985828601610e89565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061100d82610975565b915061101883610975565b925082820261102681610975565b9150828204841483151761103d5761103c610fd3565b5b5092915050565b6000604082019050818103600083015261105e81856108a1565b905061106d6020830184610c17565b9392505050565b60008160601b9050919050565b600061108c82611074565b9050919050565b600061109e82611081565b9050919050565b6110b66110b182610829565b611093565b82525050565b600081905092915050565b82818337600083830152505050565b60006110e283856110bc565b93506110ef8385846110c7565b82840190509392505050565b600061110782866110a5565b6014820191506111188284866110d6565b915081905094935050505056fea2646970667358221220e59a6599851c1ec787995687e8a35035524f5024bc92edd5c91793d9c6e77adf64736f6c63430008170033", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"router02_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"systemContract_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSender\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LowAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeMemo\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"targetZRC20\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"}],\"name\":\"encodeMemo\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structContext\",\"name\":\"\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structContext\",\"name\":\"\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"router02\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"systemContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + Bin: "0x60c060405234801561001057600080fd5b506040516117a63803806117a683398181016040528101906100329190610104565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250505050610144565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d1826100a6565b9050919050565b6100e1816100c6565b81146100ec57600080fd5b50565b6000815190506100fe816100d8565b92915050565b6000806040838503121561011b5761011a6100a1565b5b6000610129858286016100ef565b925050602061013a858286016100ef565b9150509250929050565b60805160a05161161a61018c6000396000818161067001526106b801526000818161025b015281816102e0015281816106940152818161085a01526108df015261161a6000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80635bcfd61614610067578063a06ea8bc14610083578063bb88b769146100b4578063bd00c9c4146100d2578063de43156e146100f0578063df73044e1461010c575b600080fd5b610081600480360381019061007c9190610d33565b61013c565b005b61009d60048036038101906100989190610dd7565b6105d4565b6040516100ab929190610ec3565b60405180910390f35b6100bc61066e565b6040516100c99190610ef3565b60405180910390f35b6100da610692565b6040516100e79190610ef3565b60405180910390f35b61010a60048036038101906101059190610d33565b6106b6565b005b61012660048036038101906101219190610f0e565b610bd3565b6040516101339190610f6e565b60405180910390f35b600060608061014b85856105d4565b8093508194505050600267ffffffffffffffff81111561016e5761016d610f90565b5b60405190808252806020026020018201604052801561019c5781602001602082028036833780820191505090505b50905086816000815181106101b4576101b3610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061020357610202610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b8152600401610298929190610ffd565b6020604051808303816000875af11580156102b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102db919061105e565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161034995949392919061118e565b6000604051808303816000875af1158015610368573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610391919061130c565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa1580156103e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610404919061136a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610443929190610ffd565b6020604051808303816000875af1158015610462573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610486919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106104ba576104b9610fbf565b5b60200260200101516104cc91906113d9565b6040518363ffffffff1660e01b81526004016104e9929190610ffd565b6020604051808303816000875af1158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061055e5761055d610fbf565b5b60200260200101516040518363ffffffff1660e01b815260040161058392919061141b565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c6919061105e565b505050505050505050505050565b600060608060008086869050915086866000906014926105f693929190611455565b9061060191906114d4565b60601c90508686601490809261061993929190611455565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461073b576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061074a85856105d4565b8093508194505050600267ffffffffffffffff81111561076d5761076c610f90565b5b60405190808252806020026020018201604052801561079b5781602001602082028036833780820191505090505b50905086816000815181106107b3576107b2610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061080257610801610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b8152600401610897929190610ffd565b6020604051808303816000875af11580156108b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108da919061105e565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161094895949392919061118e565b6000604051808303816000875af1158015610967573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610990919061130c565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa1580156109df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a03919061136a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610a42929190610ffd565b6020604051808303816000875af1158015610a61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a85919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a86600181518110610ab957610ab8610fbf565b5b6020026020010151610acb91906113d9565b6040518363ffffffff1660e01b8152600401610ae8929190610ffd565b6020604051808303816000875af1158015610b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268685600181518110610b5d57610b5c610fbf565b5b60200260200101516040518363ffffffff1660e01b8152600401610b8292919061141b565b6020604051808303816000875af1158015610ba1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc5919061105e565b505050505050505050505050565b6060838383604051602001610bea939291906115ba565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600060608284031215610c3157610c30610c16565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610c6582610c3a565b9050919050565b610c7581610c5a565b8114610c8057600080fd5b50565b600081359050610c9281610c6c565b92915050565b6000819050919050565b610cab81610c98565b8114610cb657600080fd5b50565b600081359050610cc881610ca2565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112610cf357610cf2610cce565b5b8235905067ffffffffffffffff811115610d1057610d0f610cd3565b5b602083019150836001820283011115610d2c57610d2b610cd8565b5b9250929050565b600080600080600060808688031215610d4f57610d4e610c0c565b5b600086013567ffffffffffffffff811115610d6d57610d6c610c11565b5b610d7988828901610c1b565b9550506020610d8a88828901610c83565b9450506040610d9b88828901610cb9565b935050606086013567ffffffffffffffff811115610dbc57610dbb610c11565b5b610dc888828901610cdd565b92509250509295509295909350565b60008060208385031215610dee57610ded610c0c565b5b600083013567ffffffffffffffff811115610e0c57610e0b610c11565b5b610e1885828601610cdd565b92509250509250929050565b610e2d81610c5a565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610e6d578082015181840152602081019050610e52565b60008484015250505050565b6000601f19601f8301169050919050565b6000610e9582610e33565b610e9f8185610e3e565b9350610eaf818560208601610e4f565b610eb881610e79565b840191505092915050565b6000604082019050610ed86000830185610e24565b8181036020830152610eea8184610e8a565b90509392505050565b6000602082019050610f086000830184610e24565b92915050565b600080600060408486031215610f2757610f26610c0c565b5b6000610f3586828701610c83565b935050602084013567ffffffffffffffff811115610f5657610f55610c11565b5b610f6286828701610cdd565b92509250509250925092565b60006020820190508181036000830152610f888184610e8a565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610ff781610c98565b82525050565b60006040820190506110126000830185610e24565b61101f6020830184610fee565b9392505050565b60008115159050919050565b61103b81611026565b811461104657600080fd5b50565b60008151905061105881611032565b92915050565b60006020828403121561107457611073610c0c565b5b600061108284828501611049565b91505092915050565b6000819050919050565b6000819050919050565b60006110ba6110b56110b08461108b565b611095565b610c98565b9050919050565b6110ca8161109f565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61110581610c5a565b82525050565b600061111783836110fc565b60208301905092915050565b6000602082019050919050565b600061113b826110d0565b61114581856110db565b9350611150836110ec565b8060005b83811015611181578151611168888261110b565b975061117383611123565b925050600181019050611154565b5085935050505092915050565b600060a0820190506111a36000830188610fee565b6111b060208301876110c1565b81810360408301526111c28186611130565b90506111d16060830185610e24565b6111de6080830184610fee565b9695505050505050565b6111f182610e79565b810181811067ffffffffffffffff821117156112105761120f610f90565b5b80604052505050565b6000611223610c02565b905061122f82826111e8565b919050565b600067ffffffffffffffff82111561124f5761124e610f90565b5b602082029050602081019050919050565b60008151905061126f81610ca2565b92915050565b600061128861128384611234565b611219565b905080838252602082019050602084028301858111156112ab576112aa610cd8565b5b835b818110156112d457806112c08882611260565b8452602084019350506020810190506112ad565b5050509392505050565b600082601f8301126112f3576112f2610cce565b5b8151611303848260208601611275565b91505092915050565b60006020828403121561132257611321610c0c565b5b600082015167ffffffffffffffff8111156113405761133f610c11565b5b61134c848285016112de565b91505092915050565b60008151905061136481610c6c565b92915050565b6000806040838503121561138157611380610c0c565b5b600061138f85828601611355565b92505060206113a085828601611260565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006113e482610c98565b91506113ef83610c98565b92508282026113fd81610c98565b91508282048414831517611414576114136113aa565b5b5092915050565b600060408201905081810360008301526114358185610e8a565b90506114446020830184610fee565b9392505050565b600080fd5b600080fd5b600080858511156114695761146861144b565b5b8386111561147a57611479611450565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b60006114e08383611490565b826114eb813561149b565b9250601482101561152b576115267fffffffffffffffffffffffffffffffffffffffff000000000000000000000000836014036008026114c7565b831692505b505092915050565b60008160601b9050919050565b600061154b82611533565b9050919050565b600061155d82611540565b9050919050565b61157561157082610c5a565b611552565b82525050565b600081905092915050565b82818337600083830152505050565b60006115a1838561157b565b93506115ae838584611586565b82840190509392505050565b60006115c68286611564565b6014820191506115d7828486611595565b915081905094935050505056fea2646970667358221220154bbadb87b49f8568829220c413c264d9405e5acb49ef710acf293adbd4f01564736f6c634300081a0033", } // ZEVMSwapAppABI is the input ABI used to generate the binding from. @@ -334,6 +334,27 @@ func (_ZEVMSwapApp *ZEVMSwapAppCallerSession) SystemContract() (common.Address, return _ZEVMSwapApp.Contract.SystemContract(&_ZEVMSwapApp.CallOpts) } +// OnCall is a paid mutator transaction binding the contract method 0x5bcfd616. +// +// Solidity: function onCall((bytes,address,uint256) , address zrc20, uint256 amount, bytes message) returns() +func (_ZEVMSwapApp *ZEVMSwapAppTransactor) OnCall(opts *bind.TransactOpts, arg0 Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ZEVMSwapApp.contract.Transact(opts, "onCall", arg0, zrc20, amount, message) +} + +// OnCall is a paid mutator transaction binding the contract method 0x5bcfd616. +// +// Solidity: function onCall((bytes,address,uint256) , address zrc20, uint256 amount, bytes message) returns() +func (_ZEVMSwapApp *ZEVMSwapAppSession) OnCall(arg0 Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ZEVMSwapApp.Contract.OnCall(&_ZEVMSwapApp.TransactOpts, arg0, zrc20, amount, message) +} + +// OnCall is a paid mutator transaction binding the contract method 0x5bcfd616. +// +// Solidity: function onCall((bytes,address,uint256) , address zrc20, uint256 amount, bytes message) returns() +func (_ZEVMSwapApp *ZEVMSwapAppTransactorSession) OnCall(arg0 Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ZEVMSwapApp.Contract.OnCall(&_ZEVMSwapApp.TransactOpts, arg0, zrc20, amount, message) +} + // OnCrossChainCall is a paid mutator transaction binding the contract method 0xde43156e. // // Solidity: function onCrossChainCall((bytes,address,uint256) , address zrc20, uint256 amount, bytes message) returns() diff --git a/e2e/contracts/zevmswap/ZEVMSwapApp.json b/e2e/contracts/zevmswap/ZEVMSwapApp.json index 5c803781fa..b8898c7994 100644 --- a/e2e/contracts/zevmswap/ZEVMSwapApp.json +++ b/e2e/contracts/zevmswap/ZEVMSwapApp.json @@ -74,6 +74,51 @@ "stateMutability": "pure", "type": "function" }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + } + ], + "internalType": "struct Context", + "name": "", + "type": "tuple" + }, + { + "internalType": "address", + "name": "zrc20", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "name": "onCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -146,5 +191,5 @@ "type": "function" } ], - "bin": "60c06040523480156200001157600080fd5b50604051620012ee380380620012ee833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161115b62000193600039600081816101b101526101f90152600081816101d50152818161039b0152610420015261115b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107bc565b610115565b6040516100849291906108da565b60405180910390f35b6100956101af565b6040516100a2919061090a565b60405180910390f35b6100b36101d3565b6040516100c0919061090a565b60405180910390f35b6100e360048036038101906100de91906109ab565b6101f7565b005b6100ff60048036038101906100fa9190610a4f565b610714565b60405161010c9190610aaf565b60405180910390f35b6000606080600080868690509150868660009060149261013793929190610adb565b906101429190610b5a565b60601c90508686601490809261015a93929190610adb565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027c576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061028b8585610115565b8093508194505050600267ffffffffffffffff8111156102ae576102ad610bb9565b5b6040519080825280602002602001820160405280156102dc5781602001602082028036833780820191505090505b50905086816000815181106102f4576102f3610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034357610342610be8565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103d8929190610c26565b6020604051808303816000875af11580156103f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041b9190610c87565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b8152600401610489959493929190610db7565b6000604051808303816000875af11580156104a8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d19190610f35565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610520573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105449190610f93565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610583929190610c26565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c69190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106105fa576105f9610be8565b5b602002602001015161060c9190611002565b6040518363ffffffff1660e01b8152600401610629929190610c26565b6020604051808303816000875af1158015610648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066c9190610c87565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069e5761069d610be8565b5b60200260200101516040518363ffffffff1660e01b81526004016106c3929190611044565b6020604051808303816000875af11580156106e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107069190610c87565b505050505050505050505050565b606083838360405160200161072b939291906110fb565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261077c5761077b610757565b5b8235905067ffffffffffffffff8111156107995761079861075c565b5b6020830191508360018202830111156107b5576107b4610761565b5b9250929050565b600080602083850312156107d3576107d261074d565b5b600083013567ffffffffffffffff8111156107f1576107f0610752565b5b6107fd85828601610766565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061083482610809565b9050919050565b61084481610829565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610884578082015181840152602081019050610869565b60008484015250505050565b6000601f19601f8301169050919050565b60006108ac8261084a565b6108b68185610855565b93506108c6818560208601610866565b6108cf81610890565b840191505092915050565b60006040820190506108ef600083018561083b565b818103602083015261090181846108a1565b90509392505050565b600060208201905061091f600083018461083b565b92915050565b600080fd5b6000606082840312156109405761093f610925565b5b81905092915050565b61095281610829565b811461095d57600080fd5b50565b60008135905061096f81610949565b92915050565b6000819050919050565b61098881610975565b811461099357600080fd5b50565b6000813590506109a58161097f565b92915050565b6000806000806000608086880312156109c7576109c661074d565b5b600086013567ffffffffffffffff8111156109e5576109e4610752565b5b6109f18882890161092a565b9550506020610a0288828901610960565b9450506040610a1388828901610996565b935050606086013567ffffffffffffffff811115610a3457610a33610752565b5b610a4088828901610766565b92509250509295509295909350565b600080600060408486031215610a6857610a6761074d565b5b6000610a7686828701610960565b935050602084013567ffffffffffffffff811115610a9757610a96610752565b5b610aa386828701610766565b92509250509250925092565b60006020820190508181036000830152610ac981846108a1565b905092915050565b600080fd5b600080fd5b60008085851115610aef57610aee610ad1565b5b83861115610b0057610aff610ad6565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b668383610b16565b82610b718135610b21565b92506014821015610bb157610bac7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610b4d565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610c2081610975565b82525050565b6000604082019050610c3b600083018561083b565b610c486020830184610c17565b9392505050565b60008115159050919050565b610c6481610c4f565b8114610c6f57600080fd5b50565b600081519050610c8181610c5b565b92915050565b600060208284031215610c9d57610c9c61074d565b5b6000610cab84828501610c72565b91505092915050565b6000819050919050565b6000819050919050565b6000610ce3610cde610cd984610cb4565b610cbe565b610975565b9050919050565b610cf381610cc8565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610d2e81610829565b82525050565b6000610d408383610d25565b60208301905092915050565b6000602082019050919050565b6000610d6482610cf9565b610d6e8185610d04565b9350610d7983610d15565b8060005b83811015610daa578151610d918882610d34565b9750610d9c83610d4c565b925050600181019050610d7d565b5085935050505092915050565b600060a082019050610dcc6000830188610c17565b610dd96020830187610cea565b8181036040830152610deb8186610d59565b9050610dfa606083018561083b565b610e076080830184610c17565b9695505050505050565b610e1a82610890565b810181811067ffffffffffffffff82111715610e3957610e38610bb9565b5b80604052505050565b6000610e4c610743565b9050610e588282610e11565b919050565b600067ffffffffffffffff821115610e7857610e77610bb9565b5b602082029050602081019050919050565b600081519050610e988161097f565b92915050565b6000610eb1610eac84610e5d565b610e42565b90508083825260208201905060208402830185811115610ed457610ed3610761565b5b835b81811015610efd5780610ee98882610e89565b845260208401935050602081019050610ed6565b5050509392505050565b600082601f830112610f1c57610f1b610757565b5b8151610f2c848260208601610e9e565b91505092915050565b600060208284031215610f4b57610f4a61074d565b5b600082015167ffffffffffffffff811115610f6957610f68610752565b5b610f7584828501610f07565b91505092915050565b600081519050610f8d81610949565b92915050565b60008060408385031215610faa57610fa961074d565b5b6000610fb885828601610f7e565b9250506020610fc985828601610e89565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061100d82610975565b915061101883610975565b925082820261102681610975565b9150828204841483151761103d5761103c610fd3565b5b5092915050565b6000604082019050818103600083015261105e81856108a1565b905061106d6020830184610c17565b9392505050565b60008160601b9050919050565b600061108c82611074565b9050919050565b600061109e82611081565b9050919050565b6110b66110b182610829565b611093565b82525050565b600081905092915050565b82818337600083830152505050565b60006110e283856110bc565b93506110ef8385846110c7565b82840190509392505050565b600061110782866110a5565b6014820191506111188284866110d6565b915081905094935050505056fea2646970667358221220e59a6599851c1ec787995687e8a35035524f5024bc92edd5c91793d9c6e77adf64736f6c63430008170033" + "bin": "60c060405234801561001057600080fd5b506040516117a63803806117a683398181016040528101906100329190610104565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250505050610144565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100d1826100a6565b9050919050565b6100e1816100c6565b81146100ec57600080fd5b50565b6000815190506100fe816100d8565b92915050565b6000806040838503121561011b5761011a6100a1565b5b6000610129858286016100ef565b925050602061013a858286016100ef565b9150509250929050565b60805160a05161161a61018c6000396000818161067001526106b801526000818161025b015281816102e0015281816106940152818161085a01526108df015261161a6000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80635bcfd61614610067578063a06ea8bc14610083578063bb88b769146100b4578063bd00c9c4146100d2578063de43156e146100f0578063df73044e1461010c575b600080fd5b610081600480360381019061007c9190610d33565b61013c565b005b61009d60048036038101906100989190610dd7565b6105d4565b6040516100ab929190610ec3565b60405180910390f35b6100bc61066e565b6040516100c99190610ef3565b60405180910390f35b6100da610692565b6040516100e79190610ef3565b60405180910390f35b61010a60048036038101906101059190610d33565b6106b6565b005b61012660048036038101906101219190610f0e565b610bd3565b6040516101339190610f6e565b60405180910390f35b600060608061014b85856105d4565b8093508194505050600267ffffffffffffffff81111561016e5761016d610f90565b5b60405190808252806020026020018201604052801561019c5781602001602082028036833780820191505090505b50905086816000815181106101b4576101b3610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061020357610202610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b8152600401610298929190610ffd565b6020604051808303816000875af11580156102b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102db919061105e565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161034995949392919061118e565b6000604051808303816000875af1158015610368573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610391919061130c565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa1580156103e0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610404919061136a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610443929190610ffd565b6020604051808303816000875af1158015610462573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610486919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a866001815181106104ba576104b9610fbf565b5b60200260200101516104cc91906113d9565b6040518363ffffffff1660e01b81526004016104e9929190610ffd565b6020604051808303816000875af1158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061055e5761055d610fbf565b5b60200260200101516040518363ffffffff1660e01b815260040161058392919061141b565b6020604051808303816000875af11580156105a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c6919061105e565b505050505050505050505050565b600060608060008086869050915086866000906014926105f693929190611455565b9061060191906114d4565b60601c90508686601490809261061993929190611455565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461073b576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060608061074a85856105d4565b8093508194505050600267ffffffffffffffff81111561076d5761076c610f90565b5b60405190808252806020026020018201604052801561079b5781602001602082028036833780820191505090505b50905086816000815181106107b3576107b2610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061080257610801610fbf565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b8152600401610897929190610ffd565b6020604051808303816000875af11580156108b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108da919061105e565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161094895949392919061118e565b6000604051808303816000875af1158015610967573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610990919061130c565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa1580156109df573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a03919061136a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610a42929190610ffd565b6020604051808303816000875af1158015610a61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a85919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387600a86600181518110610ab957610ab8610fbf565b5b6020026020010151610acb91906113d9565b6040518363ffffffff1660e01b8152600401610ae8929190610ffd565b6020604051808303816000875af1158015610b07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b919061105e565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268685600181518110610b5d57610b5c610fbf565b5b60200260200101516040518363ffffffff1660e01b8152600401610b8292919061141b565b6020604051808303816000875af1158015610ba1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc5919061105e565b505050505050505050505050565b6060838383604051602001610bea939291906115ba565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600060608284031215610c3157610c30610c16565b5b81905092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610c6582610c3a565b9050919050565b610c7581610c5a565b8114610c8057600080fd5b50565b600081359050610c9281610c6c565b92915050565b6000819050919050565b610cab81610c98565b8114610cb657600080fd5b50565b600081359050610cc881610ca2565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112610cf357610cf2610cce565b5b8235905067ffffffffffffffff811115610d1057610d0f610cd3565b5b602083019150836001820283011115610d2c57610d2b610cd8565b5b9250929050565b600080600080600060808688031215610d4f57610d4e610c0c565b5b600086013567ffffffffffffffff811115610d6d57610d6c610c11565b5b610d7988828901610c1b565b9550506020610d8a88828901610c83565b9450506040610d9b88828901610cb9565b935050606086013567ffffffffffffffff811115610dbc57610dbb610c11565b5b610dc888828901610cdd565b92509250509295509295909350565b60008060208385031215610dee57610ded610c0c565b5b600083013567ffffffffffffffff811115610e0c57610e0b610c11565b5b610e1885828601610cdd565b92509250509250929050565b610e2d81610c5a565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610e6d578082015181840152602081019050610e52565b60008484015250505050565b6000601f19601f8301169050919050565b6000610e9582610e33565b610e9f8185610e3e565b9350610eaf818560208601610e4f565b610eb881610e79565b840191505092915050565b6000604082019050610ed86000830185610e24565b8181036020830152610eea8184610e8a565b90509392505050565b6000602082019050610f086000830184610e24565b92915050565b600080600060408486031215610f2757610f26610c0c565b5b6000610f3586828701610c83565b935050602084013567ffffffffffffffff811115610f5657610f55610c11565b5b610f6286828701610cdd565b92509250509250925092565b60006020820190508181036000830152610f888184610e8a565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610ff781610c98565b82525050565b60006040820190506110126000830185610e24565b61101f6020830184610fee565b9392505050565b60008115159050919050565b61103b81611026565b811461104657600080fd5b50565b60008151905061105881611032565b92915050565b60006020828403121561107457611073610c0c565b5b600061108284828501611049565b91505092915050565b6000819050919050565b6000819050919050565b60006110ba6110b56110b08461108b565b611095565b610c98565b9050919050565b6110ca8161109f565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61110581610c5a565b82525050565b600061111783836110fc565b60208301905092915050565b6000602082019050919050565b600061113b826110d0565b61114581856110db565b9350611150836110ec565b8060005b83811015611181578151611168888261110b565b975061117383611123565b925050600181019050611154565b5085935050505092915050565b600060a0820190506111a36000830188610fee565b6111b060208301876110c1565b81810360408301526111c28186611130565b90506111d16060830185610e24565b6111de6080830184610fee565b9695505050505050565b6111f182610e79565b810181811067ffffffffffffffff821117156112105761120f610f90565b5b80604052505050565b6000611223610c02565b905061122f82826111e8565b919050565b600067ffffffffffffffff82111561124f5761124e610f90565b5b602082029050602081019050919050565b60008151905061126f81610ca2565b92915050565b600061128861128384611234565b611219565b905080838252602082019050602084028301858111156112ab576112aa610cd8565b5b835b818110156112d457806112c08882611260565b8452602084019350506020810190506112ad565b5050509392505050565b600082601f8301126112f3576112f2610cce565b5b8151611303848260208601611275565b91505092915050565b60006020828403121561132257611321610c0c565b5b600082015167ffffffffffffffff8111156113405761133f610c11565b5b61134c848285016112de565b91505092915050565b60008151905061136481610c6c565b92915050565b6000806040838503121561138157611380610c0c565b5b600061138f85828601611355565b92505060206113a085828601611260565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006113e482610c98565b91506113ef83610c98565b92508282026113fd81610c98565b91508282048414831517611414576114136113aa565b5b5092915050565b600060408201905081810360008301526114358185610e8a565b90506114446020830184610fee565b9392505050565b600080fd5b600080fd5b600080858511156114695761146861144b565b5b8386111561147a57611479611450565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b60006114e08383611490565b826114eb813561149b565b9250601482101561152b576115267fffffffffffffffffffffffffffffffffffffffff000000000000000000000000836014036008026114c7565b831692505b505092915050565b60008160601b9050919050565b600061154b82611533565b9050919050565b600061155d82611540565b9050919050565b61157561157082610c5a565b611552565b82525050565b600081905092915050565b82818337600083830152505050565b60006115a1838561157b565b93506115ae838584611586565b82840190509392505050565b60006115c68286611564565b6014820191506115d7828486611595565b915081905094935050505056fea2646970667358221220154bbadb87b49f8568829220c413c264d9405e5acb49ef710acf293adbd4f01564736f6c634300081a0033" } diff --git a/e2e/contracts/zevmswap/ZEVMSwapApp.sol b/e2e/contracts/zevmswap/ZEVMSwapApp.sol index e9f098699d..a25e6a3bd1 100644 --- a/e2e/contracts/zevmswap/ZEVMSwapApp.sol +++ b/e2e/contracts/zevmswap/ZEVMSwapApp.sol @@ -96,4 +96,28 @@ contract ZEVMSwapApp is zContract { IZRC20(targetZRC20).approve(address(targetZRC20), amounts[1]*10); IZRC20(targetZRC20).withdraw(recipient, amounts[1]); } + + // used with v2 contracts + function onCall(Context calldata, address zrc20, uint256 amount, bytes calldata message) external { + address targetZRC20; + bytes memory recipient; + address[] memory path; + + (targetZRC20, recipient) = decodeMemo(message); + path = new address[](2); + path[0] = zrc20; + path[1] = targetZRC20; + + // approve the usage of this token by router02 + IZRC20(zrc20).approve(address(router02), amount); + + // swap for target token + uint256[] memory amounts = IUniswapV2Router02(router02).swapExactTokensForTokens(amount, 0, path, address(this), _DEADLINE); + + // perform withdrawal with the target token + (address gasZRC20Addr,uint256 gasFee) = IZRC20(targetZRC20).withdrawGasFee(); + IZRC20(gasZRC20Addr).approve(address(targetZRC20), gasFee); + IZRC20(targetZRC20).approve(address(targetZRC20), amounts[1]*10); + IZRC20(targetZRC20).withdraw(recipient, amounts[1]); + } } \ No newline at end of file diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index 53c145372d..db99a5ce0d 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -172,6 +172,7 @@ const ( TestV2ZEVMToEVMCallName = "v2_zevm_to_evm_call" TestV2ZEVMToEVMCallThroughContractName = "v2_zevm_to_evm_call_through_contract" TestV2EVMToZEVMCallName = "v2_evm_to_zevm_call" + TestV2DepositAndCallSwapName = "v2_deposit_and_call_swap" /* Operational tests @@ -1073,6 +1074,12 @@ var AllE2ETests = []runner.E2ETest{ []runner.ArgDefinition{}, TestV2EVMToZEVMCall, ), + runner.NewE2ETest( + TestV2DepositAndCallSwapName, + "evm -> zevm deposit and call with swap and withdraw back to evm", + []runner.ArgDefinition{}, + TestV2DepositAndCallSwap, + ), /* Special tests */ diff --git a/e2e/e2etests/test_v2_deposit_and_call_swap.go b/e2e/e2etests/test_v2_deposit_and_call_swap.go new file mode 100644 index 0000000000..ed71ed3c53 --- /dev/null +++ b/e2e/e2etests/test_v2_deposit_and_call_swap.go @@ -0,0 +1,88 @@ +package e2etests + +import ( + "math/big" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/stretchr/testify/require" + "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol" + + "github.com/zeta-chain/node/e2e/runner" + "github.com/zeta-chain/node/e2e/utils" + crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" +) + +// TODO: This test is similar to TestCrosschainSwap +// purpose is to test similar scenario with v2 contracts where there is swap + withdraw in onCall +// to showcase that it's not reverting with gas limit issues +// this test should be removed when this issue is completed: https://github.com/zeta-chain/node/issues/2711 +func TestV2DepositAndCallSwap(r *runner.E2ERunner, _ []string) { + // create tokens pair (erc20 and eth) + tx, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.ETHZRC20Addr) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + + // approve router to spend tokens being swapped + tx, err = r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + + tx, err = r.ETHZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + + // fund ZEVMSwapApp with gas ZRC20s for withdraw + tx, err = r.ETHZRC20.Transfer(r.ZEVMAuth, r.ZEVMSwapAppAddr, big.NewInt(1e10)) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + + tx, err = r.ERC20ZRC20.Transfer(r.ZEVMAuth, r.ZEVMSwapAppAddr, big.NewInt(1e6)) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + + // temporarily increase gas limit to 400000 + previousGasLimit := r.ZEVMAuth.GasLimit + defer func() { + r.ZEVMAuth.GasLimit = previousGasLimit + }() + + // add liquidity for swap + r.ZEVMAuth.GasLimit = 400000 + tx, err = r.UniswapV2Router.AddLiquidity( + r.ZEVMAuth, + r.ERC20ZRC20Addr, + r.ETHZRC20Addr, + big.NewInt(1e8), + big.NewInt(1e8), + big.NewInt(1e8), + big.NewInt(1e5), + r.EVMAddress(), + big.NewInt(time.Now().Add(10*time.Minute).Unix()), + ) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + + // memobytes is dApp specific; see the contracts/ZEVMSwapApp.sol for details + // it is [targetZRC20, receiver] + memobytes, err := r.ZEVMSwapApp.EncodeMemo( + &bind.CallOpts{}, + r.ETHZRC20Addr, + r.EVMAddress().Bytes(), + ) + require.NoError(r, err) + + // perform the deposit and call + r.ApproveERC20OnEVM(r.GatewayEVMAddr) + tx = r.V2ERC20DepositAndCall( + r.ZEVMSwapAppAddr, + big.NewInt(8e7), + memobytes, + gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)}, + ) + + // wait for the cctx to be mined + cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout) + r.Logger.CCTX(*cctx, "deposit_and_call") + require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status) +} From eaacc09b276ffd0856b10d48123e34c89cc9bdb3 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 22 Nov 2024 04:50:26 -0500 Subject: [PATCH 06/15] test: fix upgrade tests (#3196) * stop e2e test from erroring out if uniswap pair already exists * print error for pair exists revert * match pending revert for v21 dtc dust amount withdraw * remove dust withdraw from v21 previous version tests * remove dust withdraw from v21 previous version tests * add comment for v23 * adjust code format * make generate * revert skip btc dust * remove flag name * newline * lint --------- Co-authored-by: lumtis --- cmd/zetae2e/local/local.go | 6 +++++- contrib/localnet/orchestrator/start-zetae2e.sh | 3 ++- .../test_bitcoin_deposit_and_call_revert_with_dust.go | 3 +++ e2e/e2etests/test_crosschain_swap.go | 2 +- e2e/e2etests/test_v2_deposit_and_call_swap.go | 7 +++++-- e2e/e2etests/test_zrc20_swap.go | 2 +- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index a752c0e388..fa190a07a7 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -121,6 +121,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { logger := runner.NewLogger(verbose, color.FgWhite, "setup") testStartTime := time.Now() + logger.Print("starting E2E tests") if testAdmin { @@ -323,7 +324,6 @@ func localE2ETest(cmd *cobra.Command, _ []string) { e2etests.TestBitcoinDepositName, e2etests.TestBitcoinDepositAndCallName, e2etests.TestBitcoinDepositAndCallRevertName, - e2etests.TestBitcoinDepositAndCallRevertWithDustName, e2etests.TestBitcoinStdMemoDepositName, e2etests.TestBitcoinStdMemoDepositAndCallName, e2etests.TestBitcoinStdMemoDepositAndCallRevertName, @@ -331,6 +331,9 @@ func localE2ETest(cmd *cobra.Command, _ []string) { e2etests.TestBitcoinStdMemoInscribedDepositAndCallName, e2etests.TestCrosschainSwapName, } + bitcoinDepositTestsAdvanced := []string{ + e2etests.TestBitcoinDepositAndCallRevertWithDustName, + } bitcoinWithdrawTests := []string{ e2etests.TestBitcoinWithdrawSegWitName, e2etests.TestBitcoinWithdrawInvalidAddressName, @@ -375,6 +378,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { erc20Tests = append(erc20Tests, erc20AdvancedTests...) zetaTests = append(zetaTests, zetaAdvancedTests...) zevmMPTests = append(zevmMPTests, zevmMPAdvancedTests...) + bitcoinDepositTests = append(bitcoinDepositTests, bitcoinDepositTestsAdvanced...) bitcoinWithdrawTests = append(bitcoinWithdrawTests, bitcoinWithdrawTestsAdvanced...) ethereumTests = append(ethereumTests, ethereumAdvancedTests...) } diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index 5d8c9c5586..c9c3d26c55 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -222,7 +222,8 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then echo "running E2E command to setup the networks and populate the state..." # Use light flag to ensure tests can complete before the upgrade height - zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light --skip-precompiles ${COMMON_ARGS} + # skip-bitcoin-dust-withdraw flag can be removed after v23 is released + zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light --skip-precompiles ${COMMON_ARGS} if [ $? -ne 0 ]; then echo "first e2e failed" exit 1 diff --git a/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go b/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go index cc5f5451dc..9e3606759b 100644 --- a/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go +++ b/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go @@ -47,7 +47,10 @@ func TestBitcoinDepositAndCallRevertWithDust(r *runner.E2ERunner, args []string) // ASSERT // Now we want to make sure the cctx is aborted with expected error message + + // cctx status would be pending revert if using v21 or before cctx := utils.WaitCctxAbortedByInboundHash(r.Ctx, r, txHash.String(), r.CctxClient) + require.True(r, cctx.GetCurrentOutboundParam().Amount.Uint64() < constant.BTCWithdrawalDustAmount) require.True(r, strings.Contains(cctx.CctxStatus.ErrorMessage, crosschaintypes.ErrInvalidWithdrawalAmount.Error())) } diff --git a/e2e/e2etests/test_crosschain_swap.go b/e2e/e2etests/test_crosschain_swap.go index 813f2d76ed..b8ec437972 100644 --- a/e2e/e2etests/test_crosschain_swap.go +++ b/e2e/e2etests/test_crosschain_swap.go @@ -25,7 +25,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) { // if the tx fails due to already initialized, it will be ignored _, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.BTCZRC20Addr) if err != nil { - r.Logger.Print("ℹ️ create pair error") + r.Logger.Print("ℹ️ create pair error %s", err.Error()) } txERC20ZRC20Approve, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) diff --git a/e2e/e2etests/test_v2_deposit_and_call_swap.go b/e2e/e2etests/test_v2_deposit_and_call_swap.go index ed71ed3c53..fb0aafed4b 100644 --- a/e2e/e2etests/test_v2_deposit_and_call_swap.go +++ b/e2e/e2etests/test_v2_deposit_and_call_swap.go @@ -20,8 +20,11 @@ import ( func TestV2DepositAndCallSwap(r *runner.E2ERunner, _ []string) { // create tokens pair (erc20 and eth) tx, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.ETHZRC20Addr) - require.NoError(r, err) - utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + if err != nil { + r.Logger.Print("ℹ️ create pair error %s", err.Error()) + } else { + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + } // approve router to spend tokens being swapped tx, err = r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18)) diff --git a/e2e/e2etests/test_zrc20_swap.go b/e2e/e2etests/test_zrc20_swap.go index 72819aabf8..dcf1a312c2 100644 --- a/e2e/e2etests/test_zrc20_swap.go +++ b/e2e/e2etests/test_zrc20_swap.go @@ -19,7 +19,7 @@ func TestZRC20Swap(r *runner.E2ERunner, _ []string) { // if the tx fails due to already initialized, it will be ignored tx, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.ETHZRC20Addr) if err != nil { - r.Logger.Print("ℹ️ create pair error") + r.Logger.Print("ℹ️ create pair error %s", err.Error()) } else { utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) } From 64edb401f22a80ef11baa01185d4f31bf782cfd1 Mon Sep 17 00:00:00 2001 From: Charlie Chen <34498985+ws4charlie@users.noreply.github.com> Date: Fri, 22 Nov 2024 04:11:47 -0600 Subject: [PATCH 07/15] fix: fix Bitcoin incorrect 'origin' in zContext caused by revertAddress option (#3192) * fix incorrect zContext origin caused by the replacement of sender address on BTC inbound revert * add changelog entry * fix unit test failure * check btc sender address in the CCTX struct --- changelog.md | 1 + ...d_deposit_and_call_revert_other_address.go | 4 ++ testutil/sample/crosschain.go | 16 +++++++ x/crosschain/types/cctx.go | 14 +++++- x/crosschain/types/cctx_test.go | 35 ++++++++++++++ x/crosschain/types/revert_options.go | 14 ++++++ x/crosschain/types/revert_options_test.go | 46 ++++++++++++++++++- zetaclient/chains/bitcoin/observer/event.go | 12 ++--- .../chains/bitcoin/observer/event_test.go | 6 ++- 9 files changed, 138 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 6992b9a706..4e145b2114 100644 --- a/changelog.md +++ b/changelog.md @@ -35,6 +35,7 @@ * [3155](https://github.com/zeta-chain/node/pull/3155) - fix potential panic in the Bitcoin inscription parsing * [3162](https://github.com/zeta-chain/node/pull/3162) - skip depositor fee calculation if transaction does not involve TSS address * [3179](https://github.com/zeta-chain/node/pull/3179) - support inbound trackers for v2 cctx +* [3192](https://github.com/zeta-chain/node/pull/3192) - fix incorrect zContext origin caused by the replacement of 'sender' with 'revertAddress' ## v21.0.0 diff --git a/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go b/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go index 8ecb3b0d5f..19e9893b95 100644 --- a/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go +++ b/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go @@ -45,6 +45,10 @@ func TestBitcoinStdMemoDepositAndCallRevertOtherAddress(r *runner.E2ERunner, arg // Now we want to make sure revert TX is completed. cctx := utils.WaitCctxRevertedByInboundHash(r.Ctx, r, txHash.String(), r.CctxClient) + // Make sure inbound sender and revert address are correct + assert.Equal(r, cctx.InboundParams.Sender, r.BTCDeployerAddress.EncodeAddress()) + assert.Equal(r, cctx.GetCurrentOutboundParam().Receiver, revertAddress) + // Check revert tx receiver address and amount receiver, value := r.QueryOutboundReceiverAndAmount(cctx.OutboundParams[1].Hash) assert.Equal(r, revertAddress, receiver) diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index 25733e1fef..4ac29ec697 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -217,6 +217,22 @@ func CrossChainTx(t *testing.T, index string) *types.CrossChainTx { } } +func CrossChainTxV2(t *testing.T, index string) *types.CrossChainTx { + r := newRandFromStringSeed(t, index) + + return &types.CrossChainTx{ + Creator: AccAddress(), + Index: GetCctxIndexFromString(index), + ZetaFees: math.NewUint(uint64(r.Int63())), + RelayedMessage: StringRandom(r, 32), + CctxStatus: Status(t, index), + InboundParams: InboundParams(r), + OutboundParams: []*types.OutboundParams{OutboundParams(r), OutboundParams(r)}, + ProtocolContractVersion: types.ProtocolContractVersion_V2, + RevertOptions: types.NewEmptyRevertOptions(), + } +} + // CustomCctxsInBlockRange create 1 cctx per block in block range [lowBlock, highBlock] (inclusive) func CustomCctxsInBlockRange( t *testing.T, diff --git a/x/crosschain/types/cctx.go b/x/crosschain/types/cctx.go index 2b84b5f26c..b2354a79e1 100644 --- a/x/crosschain/types/cctx.go +++ b/x/crosschain/types/cctx.go @@ -10,6 +10,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/zeta-chain/node/pkg/chains" observertypes "github.com/zeta-chain/node/x/observer/types" ) @@ -114,10 +115,21 @@ func (m *CrossChainTx) AddRevertOutbound(gasLimit uint64) error { return fmt.Errorf("cannot revert before trying to process an outbound tx") } + // in protocol contract V1, developers can specify a revert address for Bitcoin chains + // TODO: remove this V1 logic after switching Bitcoin to V2 architecture + // https://github.com/zeta-chain/node/issues/2711 + revertReceiver := m.InboundParams.Sender + if m.ProtocolContractVersion == ProtocolContractVersion_V1 && + chains.IsBitcoinChain(m.InboundParams.SenderChainId, []chains.Chain{}) { + revertAddress, valid := m.RevertOptions.GetBTCRevertAddress(m.InboundParams.SenderChainId) + if valid { + revertReceiver = revertAddress + } + } + // in protocol contract V2, developers can specify a specific address to receive the revert // if not specified, the sender address is used // note: this option is current only support for EVM type chains - revertReceiver := m.InboundParams.Sender if m.ProtocolContractVersion == ProtocolContractVersion_V2 { revertAddress, valid := m.RevertOptions.GetEVMRevertAddress() if valid { diff --git a/x/crosschain/types/cctx_test.go b/x/crosschain/types/cctx_test.go index f49768f8a0..1369e2dee0 100644 --- a/x/crosschain/types/cctx_test.go +++ b/x/crosschain/types/cctx_test.go @@ -4,8 +4,10 @@ import ( "math/rand" "testing" + "github.com/btcsuite/btcd/chaincfg" "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/testutil/sample" "github.com/zeta-chain/node/x/crosschain/types" ) @@ -134,6 +136,39 @@ func Test_SetRevertOutboundValues(t *testing.T) { require.Equal(t, types.TxFinalizationStatus_Executed, cctx.OutboundParams[0].TxFinalizationStatus) }) + t.Run("successfully set BTC revert address V1", func(t *testing.T) { + cctx := sample.CrossChainTx(t, "test") + cctx.InboundParams.SenderChainId = chains.BitcoinTestnet.ChainId + cctx.OutboundParams = cctx.OutboundParams[:1] + cctx.RevertOptions.RevertAddress = sample.BtcAddressP2WPKH(t, &chaincfg.TestNet3Params) + + err := cctx.AddRevertOutbound(100) + require.NoError(t, err) + require.Len(t, cctx.OutboundParams, 2) + require.Equal(t, cctx.GetCurrentOutboundParam().Receiver, cctx.RevertOptions.RevertAddress) + require.Equal(t, cctx.GetCurrentOutboundParam().ReceiverChainId, cctx.InboundParams.SenderChainId) + require.Equal(t, cctx.GetCurrentOutboundParam().Amount, cctx.OutboundParams[0].Amount) + require.Equal(t, cctx.GetCurrentOutboundParam().CallOptions.GasLimit, uint64(100)) + require.Equal(t, cctx.GetCurrentOutboundParam().TssPubkey, cctx.OutboundParams[0].TssPubkey) + require.Equal(t, types.TxFinalizationStatus_Executed, cctx.OutboundParams[0].TxFinalizationStatus) + }) + + t.Run("successfully set EVM revert address V2", func(t *testing.T) { + cctx := sample.CrossChainTxV2(t, "test") + cctx.OutboundParams = cctx.OutboundParams[:1] + cctx.RevertOptions.RevertAddress = sample.EthAddress().Hex() + + err := cctx.AddRevertOutbound(100) + require.NoError(t, err) + require.Len(t, cctx.OutboundParams, 2) + require.Equal(t, cctx.GetCurrentOutboundParam().Receiver, cctx.RevertOptions.RevertAddress) + require.Equal(t, cctx.GetCurrentOutboundParam().ReceiverChainId, cctx.InboundParams.SenderChainId) + require.Equal(t, cctx.GetCurrentOutboundParam().Amount, cctx.OutboundParams[0].Amount) + require.Equal(t, cctx.GetCurrentOutboundParam().CallOptions.GasLimit, uint64(100)) + require.Equal(t, cctx.GetCurrentOutboundParam().TssPubkey, cctx.OutboundParams[0].TssPubkey) + require.Equal(t, types.TxFinalizationStatus_Executed, cctx.OutboundParams[0].TxFinalizationStatus) + }) + t.Run("failed to set revert outbound values if revert outbound already exists", func(t *testing.T) { cctx := sample.CrossChainTx(t, "test") err := cctx.AddRevertOutbound(100) diff --git a/x/crosschain/types/revert_options.go b/x/crosschain/types/revert_options.go index 6cdb3040bf..4893b19ad3 100644 --- a/x/crosschain/types/revert_options.go +++ b/x/crosschain/types/revert_options.go @@ -6,6 +6,7 @@ import ( "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol" "github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayzevm.sol" + "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/pkg/crypto" ) @@ -75,6 +76,19 @@ func (r RevertOptions) GetEVMRevertAddress() (ethcommon.Address, bool) { return addr, !crypto.IsEmptyAddress(addr) } +// GetBTCRevertAddress validates and returns the BTC revert address +func (r RevertOptions) GetBTCRevertAddress(chainID int64) (string, bool) { + btcAddress, err := chains.DecodeBtcAddress(r.RevertAddress, chainID) + if err != nil { + return "", false + } + if !chains.IsBtcAddressSupported(btcAddress) { + return "", false + } + + return btcAddress.EncodeAddress(), true +} + // GetEVMAbortAddress returns the EVM abort address // if the abort address is not a valid address, it returns false func (r RevertOptions) GetEVMAbortAddress() (ethcommon.Address, bool) { diff --git a/x/crosschain/types/revert_options_test.go b/x/crosschain/types/revert_options_test.go index 46981855ea..c91927dd86 100644 --- a/x/crosschain/types/revert_options_test.go +++ b/x/crosschain/types/revert_options_test.go @@ -1,11 +1,14 @@ package types_test import ( + "testing" + + "github.com/btcsuite/btcd/chaincfg" "github.com/stretchr/testify/require" + "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/pkg/constant" "github.com/zeta-chain/node/testutil/sample" "github.com/zeta-chain/node/x/crosschain/types" - "testing" ) func TestRevertOptions_GetEVMRevertAddress(t *testing.T) { @@ -44,6 +47,47 @@ func TestRevertOptions_GetEVMRevertAddress(t *testing.T) { }) } +func TestRevertOptions_GetBTCRevertAddress(t *testing.T) { + t.Run("valid Bitcoin revert address", func(t *testing.T) { + addr := sample.BtcAddressP2WPKH(t, &chaincfg.TestNet3Params) + actualAddr, valid := types.RevertOptions{ + RevertAddress: addr, + }.GetBTCRevertAddress(chains.BitcoinTestnet.ChainId) + + require.True(t, valid) + require.Equal(t, addr, actualAddr) + }) + + t.Run("invalid Bitcoin revert address", func(t *testing.T) { + actualAddr, valid := types.RevertOptions{ + // it's a regnet address, not testnet + RevertAddress: "bcrt1qy9pqmk2pd9sv63g27jt8r657wy0d9uee4x2dt2", + }.GetBTCRevertAddress(chains.BitcoinTestnet.ChainId) + + require.False(t, valid) + require.Empty(t, actualAddr) + }) + + t.Run("empty revert address", func(t *testing.T) { + actualAddr, valid := types.RevertOptions{ + RevertAddress: "", + }.GetBTCRevertAddress(chains.BitcoinTestnet.ChainId) + + require.False(t, valid) + require.Empty(t, actualAddr) + }) + + t.Run("unsupported Bitcoin revert address", func(t *testing.T) { + actualAddr, valid := types.RevertOptions{ + // address not supported + RevertAddress: "035e4ae279bd416b5da724972c9061ec6298dac020d1e3ca3f06eae715135cdbec", + }.GetBTCRevertAddress(chains.BitcoinTestnet.ChainId) + + require.False(t, valid) + require.Empty(t, actualAddr) + }) +} + func TestRevertOptions_GetEVMAbortAddress(t *testing.T) { t.Run("valid abort address", func(t *testing.T) { addr := sample.EthAddress() diff --git a/zetaclient/chains/bitcoin/observer/event.go b/zetaclient/chains/bitcoin/observer/event.go index 69657d29f1..7cd581a1cc 100644 --- a/zetaclient/chains/bitcoin/observer/event.go +++ b/zetaclient/chains/bitcoin/observer/event.go @@ -221,11 +221,10 @@ func (ob *Observer) NewInboundVoteFromStdMemo( event *BTCInboundEvent, amountSats *big.Int, ) *crosschaintypes.MsgVoteInbound { - // replace 'sender' with 'revertAddress' if specified in the memo, so that - // zetacore will refund to the address specified by the user in the revert options. - sender := event.FromAddress - if event.MemoStd.RevertOptions.RevertAddress != "" { - sender = event.MemoStd.RevertOptions.RevertAddress + // inject the 'revertAddress' specified in the memo, so that + // zetacore will create a revert outbound that points to the custom revert address. + revertOptions := crosschaintypes.RevertOptions{ + RevertAddress: event.MemoStd.RevertOptions.RevertAddress, } // make a legacy message so that zetacore can process it as V1 @@ -234,7 +233,7 @@ func (ob *Observer) NewInboundVoteFromStdMemo( return crosschaintypes.NewMsgVoteInbound( ob.ZetacoreClient().GetKeys().GetOperatorAddress().String(), - sender, + event.FromAddress, ob.Chain().ChainId, event.FromAddress, event.ToAddress, @@ -249,5 +248,6 @@ func (ob *Observer) NewInboundVoteFromStdMemo( 0, crosschaintypes.ProtocolContractVersion_V1, false, // not relevant for v1 + crosschaintypes.WithRevertOptions(revertOptions), ) } diff --git a/zetaclient/chains/bitcoin/observer/event_test.go b/zetaclient/chains/bitcoin/observer/event_test.go index 5ed8e9b103..80566b55cd 100644 --- a/zetaclient/chains/bitcoin/observer/event_test.go +++ b/zetaclient/chains/bitcoin/observer/event_test.go @@ -423,7 +423,7 @@ func Test_NewInboundVoteFromStdMemo(t *testing.T) { // expected vote memoBytesExpected := append(event.MemoStd.Receiver.Bytes(), event.MemoStd.Payload...) expectedVote := crosschaintypes.MsgVoteInbound{ - Sender: revertOptions.RevertAddress, // should be overridden by revert address + Sender: event.FromAddress, SenderChainId: chain.ChainId, TxOrigin: event.FromAddress, Receiver: event.ToAddress, @@ -437,7 +437,9 @@ func Test_NewInboundVoteFromStdMemo(t *testing.T) { }, CoinType: coin.CoinType_Gas, ProtocolContractVersion: crosschaintypes.ProtocolContractVersion_V1, - RevertOptions: crosschaintypes.NewEmptyRevertOptions(), // ignored by V1 + RevertOptions: crosschaintypes.RevertOptions{ + RevertAddress: revertOptions.RevertAddress, // should be overridden by revert address + }, } // create new inbound vote V1 with standard memo From 8998ccf0cfedc5287e51dd04489a675bbe069a8d Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 22 Nov 2024 05:12:05 -0500 Subject: [PATCH 08/15] test: `e2e` add withdraw emissions (#3151) * add withdraw emissions to e2e * add changelog and minor refactors * Update e2e/runner/emissions.go Co-authored-by: Lucas Bertrand --------- Co-authored-by: Lucas Bertrand --- changelog.md | 1 + cmd/zetae2e/config/local.yml | 4 + cmd/zetae2e/config/localnet.yml | 4 + cmd/zetae2e/local/local.go | 9 +- .../localnet/orchestrator/start-zetae2e.sh | 3 + contrib/localnet/scripts/start-zetacored.sh | 58 ++++++++++++ e2e/config/config.go | 36 ++++---- e2e/runner/emissions.go | 89 +++++++++++++++++++ e2e/runner/runner.go | 3 + e2e/runner/setup_zeta.go | 7 -- e2e/txserver/zeta_tx_server.go | 23 +++++ e2e/utils/zetacore.go | 8 +- pkg/rpc/clients.go | 4 + 13 files changed, 223 insertions(+), 26 deletions(-) create mode 100644 e2e/runner/emissions.go diff --git a/changelog.md b/changelog.md index 4e145b2114..d237016e62 100644 --- a/changelog.md +++ b/changelog.md @@ -16,6 +16,7 @@ * [3105](https://github.com/zeta-chain/node/pull/3105) - split Bitcoin E2E tests into two runners for deposit and withdraw * [3154](https://github.com/zeta-chain/node/pull/3154) - configure Solana gateway program id for E2E tests * [3188](https://github.com/zeta-chain/node/pull/3188) - add e2e test for v2 deposit and call with swap +* [3151](https://github.com/zeta-chain/node/pull/3151) - add withdraw emissions to e2e tests ### Refactor diff --git a/cmd/zetae2e/config/local.yml b/cmd/zetae2e/config/local.yml index aed44fc155..15de10ceda 100644 --- a/cmd/zetae2e/config/local.yml +++ b/cmd/zetae2e/config/local.yml @@ -65,6 +65,10 @@ additional_accounts: bech32_address: "zeta1nry9yeg6njhjrp2ctppa8558vqxal9fxk69zxg" evm_address: "0x98c852651A9CAF2185585843d3D287600Ddf9526" private_key: "bf9456c679bb5a952a9a137fcfc920e0413efdb97c36de1e57455763084230cb" + user_emissions_withdraw: + bech32_address: "zeta1n9zhyn4unvaee3ey40k7x7f5nmj7zet6qr5kl7" + evm_address: "0x9945724EBc9B3B9cc724abedE379349EE5E1657a" + private_key: "9d524fe318c0eb5f80d8b246993a9f15f924db24d4b8b873839b13bc30040d03" policy_accounts: emergency_policy_account: bech32_address: "zeta16m2cnrdwtgweq4njc6t470vl325gw4kp6s7tap" diff --git a/cmd/zetae2e/config/localnet.yml b/cmd/zetae2e/config/localnet.yml index 15f1e332f6..6e1c2b392c 100644 --- a/cmd/zetae2e/config/localnet.yml +++ b/cmd/zetae2e/config/localnet.yml @@ -65,6 +65,10 @@ additional_accounts: bech32_address: "zeta1nry9yeg6njhjrp2ctppa8558vqxal9fxk69zxg" evm_address: "0x98c852651A9CAF2185585843d3D287600Ddf9526" private_key: "bf9456c679bb5a952a9a137fcfc920e0413efdb97c36de1e57455763084230cb" + user_emissions_withdraw: + bech32_address: "zeta1n9zhyn4unvaee3ey40k7x7f5nmj7zet6qr5kl7" + evm_address: "0x9945724EBc9B3B9cc724abedE379349EE5E1657a" + private_key: "9d524fe318c0eb5f80d8b246993a9f15f924db24d4b8b873839b13bc30040d03" policy_accounts: emergency_policy_account: bech32_address: "zeta16m2cnrdwtgweq4njc6t470vl325gw4kp6s7tap" diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index fa190a07a7..4c3a1f0717 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -161,11 +161,17 @@ func localE2ETest(cmd *cobra.Command, _ []string) { zetaTxServer, err := txserver.NewZetaTxServer( conf.RPCs.ZetaCoreRPC, - []string{utils.EmergencyPolicyName, utils.OperationalPolicyName, utils.AdminPolicyName}, + []string{ + utils.EmergencyPolicyName, + utils.OperationalPolicyName, + utils.AdminPolicyName, + utils.UserEmissionsWithdrawName, + }, []string{ conf.PolicyAccounts.EmergencyPolicyAccount.RawPrivateKey.String(), conf.PolicyAccounts.OperationalPolicyAccount.RawPrivateKey.String(), conf.PolicyAccounts.AdminPolicyAccount.RawPrivateKey.String(), + conf.AdditionalAccounts.UserEmissionsWithdraw.RawPrivateKey.String(), }, conf.ZetaChainID, ) @@ -492,6 +498,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { logger.Print("❌ e2e tests failed after %s", time.Since(testStartTime).String()) os.Exit(1) } + noError(deployerRunner.WithdrawEmissions()) // if all tests pass, cancel txs priority monitoring and check if tx priority is not correct in some blocks logger.Print("⏳ e2e tests passed, checking tx priority") diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index c9c3d26c55..99ab61d700 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -134,6 +134,9 @@ fund_eth_from_config '.additional_accounts.user_v2_ether_revert.evm_address' 100 # unlock v2 erc20 revert tests accounts fund_eth_from_config '.additional_accounts.user_v2_erc20_revert.evm_address' 10000 "V2 ERC20 revert tester" +# unlock emissions withdraw tests accounts +fund_eth_from_config '.additional_accounts.user_emissions_withdraw.evm_address' 10000 "emissions withdraw tester" + # unlock local solana relayer accounts if host solana > /dev/null; then solana_url=$(config_str '.rpcs.solana') diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 38047a6b46..56e30358c1 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -67,6 +67,55 @@ add_v17_message_authorizations() { ' $json_file > temp.json && mv temp.json $json_file } + +add_emissions_withdraw_authorizations() { + + config_file="/root/config.yml" + json_file="/root/.zetacored/config/genesis.json" + + # Check if config file exists + if [[ ! -f "$config_file" ]]; then + echo "Error: Config file not found at $config_file" + return 1 + fi + # Address to add emissions withdraw authorizations + address=$(yq -r '.additional_accounts.user_emissions_withdraw.bech32_address' "$config_file") + + # Check if genesis file exists + if [[ ! -f "$json_file" ]]; then + echo "Error: Genesis file not found at $json_file" + return 1 + fi + + echo "Adding emissions withdraw authorizations for address: $address" + + + # Using jq to parse JSON, create new entries, and append them to the authorization array + if ! jq --arg address "$address" ' + # Store the nodeAccountList array + .app_state.observer.nodeAccountList as $list | + # Iterate over the stored list to construct new objects and append to the authorization array + .app_state.authz.authorization += [ + $list[] | + { + "granter": .operator, + "grantee": $address, + "authorization": { + "@type": "/cosmos.authz.v1beta1.GenericAuthorization", + "msg": "/zetachain.zetacore.emissions.MsgWithdrawEmission" + }, + "expiration": null + } + ] + ' "$json_file" > temp.json; then + echo "Error: Failed to update genesis file" + return 1 + fi + mv temp.json "$json_file" +} + + + # create keys CHAINID="athens_101-1" KEYRING="test" @@ -191,6 +240,12 @@ then zetacored collect-observer-info zetacored add-observer-list --keygen-block 25 + # Add emissions withdraw authorizations + if ! add_emissions_withdraw_authorizations; then + echo "Error: Failed to add emissions withdraw authorizations" + exit 1 + fi + # Check for the existence of "AddToOutTxTracker" string in the genesis file # If this message is found in the genesis, it means add-observer-list has been run with the v16 binary for upgrade tests # In this case, we need to add authorizations for the new v17 messages to the genesis file @@ -272,6 +327,9 @@ then # v2 erc20 revert tester address=$(yq -r '.additional_accounts.user_v2_erc20_revert.bech32_address' /root/config.yml) zetacored add-genesis-account "$address" 100000000000000000000000000azeta +# emissions withdraw tester + address=$(yq -r '.additional_accounts.user_emissions_withdraw.bech32_address' /root/config.yml) + zetacored add-genesis-account "$address" 100000000000000000000000000azeta # 3. Copy the genesis.json to all the nodes .And use it to create a gentx for every node zetacored gentx operator 1000000000000000000000azeta --chain-id=$CHAINID --keyring-backend=$KEYRING --gas-prices 20000000000azeta diff --git a/e2e/config/config.go b/e2e/config/config.go index 22382c1fa1..1ae7d4109a 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -61,21 +61,22 @@ type Account struct { // AdditionalAccounts are extra accounts required to run specific tests type AdditionalAccounts struct { - UserERC20 Account `yaml:"user_erc20"` - UserZetaTest Account `yaml:"user_zeta_test"` - UserZEVMMPTest Account `yaml:"user_zevm_mp_test"` - UserBitcoinDeposit Account `yaml:"user_bitcoin_deposit"` - UserBitcoinWithdraw Account `yaml:"user_bitcoin_withdraw"` - UserSolana Account `yaml:"user_solana"` - UserEther Account `yaml:"user_ether"` - UserMisc Account `yaml:"user_misc"` - UserAdmin Account `yaml:"user_admin"` - UserMigration Account `yaml:"user_migration"` // used for TSS migration, TODO: rename (https://github.com/zeta-chain/node/issues/2780) - UserPrecompile Account `yaml:"user_precompile"` - UserV2Ether Account `yaml:"user_v2_ether"` - UserV2ERC20 Account `yaml:"user_v2_erc20"` - UserV2EtherRevert Account `yaml:"user_v2_ether_revert"` - UserV2ERC20Revert Account `yaml:"user_v2_erc20_revert"` + UserERC20 Account `yaml:"user_erc20"` + UserZetaTest Account `yaml:"user_zeta_test"` + UserZEVMMPTest Account `yaml:"user_zevm_mp_test"` + UserBitcoinDeposit Account `yaml:"user_bitcoin_deposit"` + UserBitcoinWithdraw Account `yaml:"user_bitcoin_withdraw"` + UserSolana Account `yaml:"user_solana"` + UserEther Account `yaml:"user_ether"` + UserMisc Account `yaml:"user_misc"` + UserAdmin Account `yaml:"user_admin"` + UserMigration Account `yaml:"user_migration"` // used for TSS migration, TODO: rename (https://github.com/zeta-chain/node/issues/2780) + UserPrecompile Account `yaml:"user_precompile"` + UserV2Ether Account `yaml:"user_v2_ether"` + UserV2ERC20 Account `yaml:"user_v2_erc20"` + UserV2EtherRevert Account `yaml:"user_v2_ether_revert"` + UserV2ERC20Revert Account `yaml:"user_v2_erc20_revert"` + UserEmissionsWithdraw Account `yaml:"user_emissions_withdraw"` } type PolicyAccounts struct { @@ -248,6 +249,7 @@ func (a AdditionalAccounts) AsSlice() []Account { a.UserV2ERC20, a.UserV2EtherRevert, a.UserV2ERC20Revert, + a.UserEmissionsWithdraw, } } @@ -364,6 +366,10 @@ func (c *Config) GenerateKeys() error { if err != nil { return err } + c.AdditionalAccounts.UserEmissionsWithdraw, err = generateAccount() + if err != nil { + return err + } c.PolicyAccounts.EmergencyPolicyAccount, err = generateAccount() if err != nil { diff --git a/e2e/runner/emissions.go b/e2e/runner/emissions.go new file mode 100644 index 0000000000..c950cf854c --- /dev/null +++ b/e2e/runner/emissions.go @@ -0,0 +1,89 @@ +package runner + +import ( + "fmt" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/zeta-chain/node/cmd/zetacored/config" + "github.com/zeta-chain/node/e2e/txserver" + e2eutils "github.com/zeta-chain/node/e2e/utils" + emissionstypes "github.com/zeta-chain/node/x/emissions/types" + observertypes "github.com/zeta-chain/node/x/observer/types" +) + +// FundEmissionsPool funds the emissions pool on ZetaChain with the same value as used originally on mainnet (20M ZETA) +func (r *E2ERunner) FundEmissionsPool() error { + r.Logger.Print("⚙️ funding the emissions pool on ZetaChain with 20M ZETA (%s)", txserver.EmissionsPoolAddress) + + return r.ZetaTxServer.FundEmissionsPool(e2eutils.OperationalPolicyName, EmissionsPoolFunding) +} + +// WithdrawEmissions withdraws emissions from the emission pool on ZetaChain for all observers +// This functions uses the UserEmissionsWithdrawName to create the withdraw tx. +// UserEmissionsWithdraw can sign the authz transactions because the necessary permissions are granted in the genesis file +func (r *E2ERunner) WithdrawEmissions() error { + observerSet, err := r.ObserverClient.ObserverSet(r.Ctx, &observertypes.QueryObserverSet{}) + if err != nil { + return err + } + + for _, observer := range observerSet.Observers { + r.Logger.Print("🏃 Withdrawing emissions for observer %s", observer) + var ( + baseDenom = config.BaseDenom + queryObserverBalance = &banktypes.QueryBalanceRequest{ + Address: observer, + Denom: baseDenom, + } + ) + + balanceBefore, err := r.BankClient.Balance(r.Ctx, queryObserverBalance) + if err != nil { + return errors.Wrapf(err, "failed to get balance for observer before withdrawing emissions %s", observer) + } + + availableAmount, err := r.EmissionsClient.ShowAvailableEmissions( + r.Ctx, + &emissionstypes.QueryShowAvailableEmissionsRequest{ + Address: observer, + }, + ) + if err != nil { + return fmt.Errorf("failed to get available emissions for observer %s: %w", observer, err) + } + + availableCoin, err := sdk.ParseCoinNormalized(availableAmount.Amount) + if err != nil { + return fmt.Errorf("failed to parse coin amount: %w", err) + } + + if availableCoin.Amount.IsZero() { + r.Logger.Print("no emissions to withdraw for observer %s", observer) + continue + } + + if err := r.ZetaTxServer.WithdrawAllEmissions(availableCoin.Amount, e2eutils.UserEmissionsWithdrawName, observer); err != nil { + return err + } + + balanceAfter, err := r.BankClient.Balance(r.Ctx, queryObserverBalance) + if err != nil { + return errors.Wrapf(err, "failed to get balance for observer after withdrawing emissions %s", observer) + } + + changeInBalance := balanceAfter.Balance.Sub(*balanceBefore.Balance).Amount + if !changeInBalance.Equal(availableCoin.Amount) { + return fmt.Errorf( + "invalid balance change for observer %s, expected %s, got %s", + observer, + availableCoin.Amount, + changeInBalance, + ) + } + } + + return nil +} diff --git a/e2e/runner/runner.go b/e2e/runner/runner.go index f117758c28..9e75c6fcd7 100644 --- a/e2e/runner/runner.go +++ b/e2e/runner/runner.go @@ -45,6 +45,7 @@ import ( toncontracts "github.com/zeta-chain/node/pkg/contracts/ton" authoritytypes "github.com/zeta-chain/node/x/authority/types" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" + emissionstypes "github.com/zeta-chain/node/x/emissions/types" fungibletypes "github.com/zeta-chain/node/x/fungible/types" lightclienttypes "github.com/zeta-chain/node/x/lightclient/types" observertypes "github.com/zeta-chain/node/x/observer/types" @@ -99,6 +100,7 @@ type E2ERunner struct { ObserverClient observertypes.QueryClient LightclientClient lightclienttypes.QueryClient DistributionClient distributiontypes.QueryClient + EmissionsClient emissionstypes.QueryClient // optional zeta (cosmos) client // typically only in test runners that need it @@ -210,6 +212,7 @@ func NewE2ERunner( ObserverClient: clients.Zetacore.Observer, LightclientClient: clients.Zetacore.Lightclient, DistributionClient: clients.Zetacore.Distribution, + EmissionsClient: clients.Zetacore.Emissions, EVMAuth: clients.EvmAuth, ZEVMAuth: clients.ZevmAuth, diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index 072957346c..56c803a376 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -276,10 +276,3 @@ func (r *E2ERunner) EnableHeaderVerification(chainIDList []int64) error { return r.ZetaTxServer.EnableHeaderVerification(e2eutils.AdminPolicyName, chainIDList) } - -// FundEmissionsPool funds the emissions pool on ZetaChain with the same value as used originally on mainnet (20M ZETA) -func (r *E2ERunner) FundEmissionsPool() error { - r.Logger.Print("⚙️ funding the emissions pool on ZetaChain with 20M ZETA (%s)", txserver.EmissionsPoolAddress) - - return r.ZetaTxServer.FundEmissionsPool(e2eutils.OperationalPolicyName, EmissionsPoolFunding) -} diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index 146dda4cf2..e83d6a0d71 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -10,6 +10,7 @@ import ( "strings" "time" + sdkmath "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" rpchttp "github.com/cometbft/cometbft/rpc/client/http" coretypes "github.com/cometbft/cometbft/rpc/core/types" @@ -585,6 +586,28 @@ func (zts ZetaTxServer) FundEmissionsPool(account string, amount *big.Int) error return err } +func (zts ZetaTxServer) WithdrawAllEmissions(withdrawAmount sdkmath.Int, account, observer string) error { + // retrieve account + acc, err := zts.clientCtx.Keyring.Key(account) + if err != nil { + return fmt.Errorf("failed to get withdrawer account: %w", err) + } + withdrawerAddress, err := acc.GetAddress() + if err != nil { + return fmt.Errorf("failed to get withdrawer account address: %w", err) + } + + msg := emissionstypes.MsgWithdrawEmission{ + Creator: observer, + Amount: withdrawAmount, + } + + authzMessage := authz.NewMsgExec(withdrawerAddress, []sdktypes.Msg{&msg}) + + _, err = zts.BroadcastTx(account, &authzMessage) + return err +} + // UpdateKeygen sets a new keygen height . The new height is the current height + 30 func (zts ZetaTxServer) UpdateKeygen(height int64) error { keygenHeight := height + 30 diff --git a/e2e/utils/zetacore.go b/e2e/utils/zetacore.go index 34e53e61b0..bf01d79ec8 100644 --- a/e2e/utils/zetacore.go +++ b/e2e/utils/zetacore.go @@ -16,9 +16,11 @@ import ( type CCTXClient = crosschaintypes.QueryClient const ( - EmergencyPolicyName = "emergency" - AdminPolicyName = "admin" - OperationalPolicyName = "operational" + EmergencyPolicyName = "emergency" + AdminPolicyName = "admin" + OperationalPolicyName = "operational" + UserEmissionsWithdrawName = "emissions_withdraw" + // The timeout was increased from 4 to 6 , which allows for a higher success in test runs // However this needs to be researched as to why the increase in timeout was needed. // https://github.com/zeta-chain/node/issues/2690 diff --git a/pkg/rpc/clients.go b/pkg/rpc/clients.go index 4d94b317e4..8ae9813b53 100644 --- a/pkg/rpc/clients.go +++ b/pkg/rpc/clients.go @@ -17,6 +17,7 @@ import ( etherminttypes "github.com/zeta-chain/node/rpc/types" authoritytypes "github.com/zeta-chain/node/x/authority/types" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" + emissionstypes "github.com/zeta-chain/node/x/emissions/types" fungibletypes "github.com/zeta-chain/node/x/fungible/types" lightclienttypes "github.com/zeta-chain/node/x/lightclient/types" observertypes "github.com/zeta-chain/node/x/observer/types" @@ -51,6 +52,8 @@ type Clients struct { Observer observertypes.QueryClient // Lightclient is a github.com/zeta-chain/zetacore/x/lightclient/types QueryClient Lightclient lightclienttypes.QueryClient + // EmissionsClient is a github.com/zeta-chain/zetacore/x/emissions/types QueryClient + Emissions emissionstypes.QueryClient // Ethermint specific clients @@ -79,6 +82,7 @@ func newClients(ctx client.Context) (Clients, error) { Fungible: fungibletypes.NewQueryClient(ctx), Observer: observertypes.NewQueryClient(ctx), Lightclient: lightclienttypes.NewQueryClient(ctx), + Emissions: emissionstypes.NewQueryClient(ctx), // Ethermint specific clients Ethermint: etherminttypes.NewQueryClient(ctx), EthermintFeeMarket: feemarkettypes.NewQueryClient(ctx), From 162753f3d6399ff075a37aeff7896145e6438414 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Fri, 22 Nov 2024 13:23:51 +0100 Subject: [PATCH 09/15] docs: changelog for v23 (#3190) --- changelog.md | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index d237016e62..01b6f7bd66 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # CHANGELOG -## Unreleased +## v23.0.0 ### Features @@ -38,6 +38,47 @@ * [3179](https://github.com/zeta-chain/node/pull/3179) - support inbound trackers for v2 cctx * [3192](https://github.com/zeta-chain/node/pull/3192) - fix incorrect zContext origin caused by the replacement of 'sender' with 'revertAddress' +## v22.1.2 + +## Fixes + +- [3181](https://github.com/zeta-chain/node/pull/3181) - add lock around pingRTT to prevent crash + +## v22.1.1 + +## Fixes + +- [3171](https://github.com/zeta-chain/node/pull/3171) - infinite discovery address leak + +## v22.1.0 + +## Features + +- [3028](https://github.com/zeta-chain/node/pull/3028) - whitelist connection gater + +## Fixes + +- [3041](https://github.com/zeta-chain/node/pull/3041) - replace DHT with private peer discovery +- [3162](https://github.com/zeta-chain/node/pull/3162) - skip depositor fee calculation on irrelevant transactions + +## v22.0.2 + +## Fixes + +- [3144](https://github.com/zeta-chain/node/pull/3145) - out of gas on ZetaClient during `onRevert` + +## v22.0.1 + +## Fixes + +- [3140](https://github.com/zeta-chain/node/pull/3140) - allow BTC revert with dust amount + +## v22.0.0 + +## Refactor + +* [3073](https://github.com/zeta-chain/node/pull/3073) - improve ZETA deposit check with max supply check + ## v21.0.0 ### Features From e9e88dbc9d2b586bdd79b962958d441e072b3eda Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Fri, 22 Nov 2024 04:52:22 -0800 Subject: [PATCH 10/15] chore: use jsdelivr for swagger css/js (#3197) --- docs/openapi/openapi.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/openapi/openapi.html b/docs/openapi/openapi.html index 37fbfb2a16..20f878256f 100644 --- a/docs/openapi/openapi.html +++ b/docs/openapi/openapi.html @@ -5,18 +5,18 @@
- +