Skip to content

Commit

Permalink
chore: merge release/v16 features into develop (#2112)
Browse files Browse the repository at this point in the history
* refactor: allow zeta deposits to new zevm address (#2076)

* allow zevm coin deposit to unknow addresses

* add e2e tests

* add changelog

* add comments

* test(e2e): fix local e2e upgrade test (#2099)

* add skip header option

* use option for migration test

* move bitcoin addresses tests to advanced

* show cctx in logs

* update version

* fix verification flags error

* update version in changelog

* test: fix and unit tests for query pending cctx within rate limit (#2060)

* initial commit of grpc pending cctx query with rate limiter

* replace big.Float with sdk.Dec and update mock rate limiter flags

* split big loop into backwards loop and forwards loop to be more accurate

* adjust zetaclient code to query pending cctx with rate limit

* update change log and add one more rate limiter flag test

* use outboun amount for calculation

* some minimum code refactor

* created separate file for cctx query with rate limit

* improved a few error handlling

* use old cctx query as fallback when rate limiter is disabled; some renaming

* fixed unit test compile

* added unit test for fallback query

* added unit tests for cctx value conversion

* add changelog entry

* added unit tests for query pending cctxs within rate limit

* added total value in rate limiter window for monitoring purpose

* Update x/crosschain/keeper/grpc_query_cctx_rate_limit.go

Co-authored-by: Lucas Bertrand <[email protected]>

* change variable name fCoin to foreignCoin

* Update x/fungible/keeper/foreign_coins.go

Co-authored-by: Lucas Bertrand <[email protected]>

* Update x/crosschain/keeper/grpc_query_cctx_rate_limit_test.go

Co-authored-by: Lucas Bertrand <[email protected]>

* converted rate limiter query unit tests to table test

* handle edge case when pending cctxs span wider block range than sliding window

* added zero rate check; added comment to make unit test clearer

* added unit test and note for method GetAllForeignCoinMap

* treat Rate as average block rate; stop outbound when current rate limit exceeds Rate; updated metrics

* add commented unit tests back

* replace sdk.Dec with sdkmath.Int to represent cctx value in azeta

* test: disable header proof test in local upgrade test E2E test (#2051)

* add skip header option

* use option for migration test

* move bitcoin addresses tests to advanced

* show cctx in logs

* update version

* fix verification flags error

* test(e2e): add rate limiter admin E2E test (#2063)

* refactor and create Withdraw ZETA general function

* new rate limiter test

* use rate limiter for admin test

* fix the test: single approval and add liquidity

* make generate

* fix liquidity

* fix uniswap pool

* change localnet chain params

* fix lint

* add cli query

* add nil check

* fix nil point

* modify tests

* eliminate nil pending nonce issue

* fix query

* set flags

* Update e2e/runner/evm.go

Co-authored-by: Charlie Chen <[email protected]>

* add back other advanced tests

* make generate

* add comment

* fix eth liquidity cap test

* fix withdraw count

---------

Co-authored-by: Charlie Chen <[email protected]>
Co-authored-by: Charlie Chen <[email protected]>

* removed incorrect Note

* improved variable name

* add E2E test for rate limiter gas and erc20

* remove outdated comment

---------

Co-authored-by: Lucas Bertrand <[email protected]>

* more conflict resolution

---------

Co-authored-by: Tanmay <[email protected]>
Co-authored-by: Lucas Bertrand <[email protected]>
Co-authored-by: Alex Gartner <[email protected]>
  • Loading branch information
4 people authored May 2, 2024
1 parent 5b126b5 commit 3e298ba
Show file tree
Hide file tree
Showing 44 changed files with 1,664 additions and 479 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ start-stress-test: zetanode

zetanode-upgrade:
@echo "Building zetanode-upgrade"
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade --build-arg OLD_VERSION=v14.0.0 --build-arg NEW_VERSION=v15 .
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade --build-arg OLD_VERSION=v15.0.0 --build-arg NEW_VERSION=v16 .
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild .
.PHONY: zetanode-upgrade

Expand Down
2 changes: 1 addition & 1 deletion app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const releaseVersion = "v15"
const releaseVersion = "v16"

func SetupHandlers(app *App) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) {
Expand Down
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
## Unreleased

### CI

* [2070](https://github.com/zeta-chain/node/pull/2070) - Added commands to build binaries from the working branch as a live full node rpc to test non-governance changes.

### Refactor

* [2032](https://github.com/zeta-chain/node/pull/2032) - improve some general structure of the ZetaClient codebase

## Unreleased

## v16.0.0

### Breaking Changes

* Admin policies have been moved from `observer` to a new module `authority`.
Expand Down Expand Up @@ -53,6 +56,7 @@
* [1989](https://github.com/zeta-chain/node/pull/1989) - simplify `IsSendOutTxProcessed` method and add unit tests
* [2013](https://github.com/zeta-chain/node/pull/2013) - rename `GasPriceVoter` message to `VoteGasPrice`
* [2059](https://github.com/zeta-chain/node/pull/2059) - Remove unused params from all functions in zetanode
* [2076](https://github.com/zeta-chain/node/pull/2076) - automatically deposit native zeta to an address if it doesn't exist on ZEVM.
* [2071](https://github.com/zeta-chain/node/pull/2071) - Modify chains struct to add all chain related information

### Features
Expand Down Expand Up @@ -92,6 +96,7 @@
* [1985](https://github.com/zeta-chain/node/pull/1985) - improve fungible module coverage
* [1992](https://github.com/zeta-chain/node/pull/1992) - remove setupKeeper from crosschain module
* [2008](https://github.com/zeta-chain/node/pull/2008) - add test for connector bytecode update
* [2060](https://github.com/zeta-chain/node/pull/2060) - add unit test for rate limiter query
* [2047](https://github.com/zeta-chain/node/pull/2047) - fix liquidity cap advanced test

### Fixes
Expand Down
30 changes: 22 additions & 8 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
flagSetupOnly = "setup-only"
flagSkipSetup = "skip-setup"
flagSkipBitcoinSetup = "skip-bitcoin-setup"
flagSkipHeaderProof = "skip-header-proof"
)

var (
Expand Down Expand Up @@ -57,6 +58,7 @@ func NewLocalCmd() *cobra.Command {
cmd.Flags().String(flagConfigOut, "", "config file to write the deployed contracts from the setup")
cmd.Flags().Bool(flagSkipSetup, false, "set to true to skip setup")
cmd.Flags().Bool(flagSkipBitcoinSetup, false, "set to true to skip bitcoin wallet setup")
cmd.Flags().Bool(flagSkipHeaderProof, false, "set to true to skip header proof tests")

return cmd
}
Expand Down Expand Up @@ -111,6 +113,10 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
if err != nil {
panic(err)
}
skipHeaderProof, err := cmd.Flags().GetBool(flagSkipHeaderProof)
if err != nil {
panic(err)
}

logger := runner.NewLogger(verbose, color.FgWhite, "setup")

Expand Down Expand Up @@ -189,8 +195,10 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
logger.Print("⚙️ setting up networks")
startTime := time.Now()

if err := deployerRunner.EnableVerificationFlags(); err != nil {
panic(err)
if !skipHeaderProof {
if err := deployerRunner.EnableVerificationFlags(); err != nil {
panic(err)
}
}

deployerRunner.SetupEVM(contractsDeployed, true)
Expand Down Expand Up @@ -257,18 +265,20 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestMessagePassingEVMtoZEVMName,
e2etests.TestMessagePassingEVMtoZEVMRevertName,
e2etests.TestMessagePassingZEVMtoEVMRevertName,
e2etests.TestZetaDepositName,
e2etests.TestZetaDepositNewAddressName,
}
bitcoinTests := []string{
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestBitcoinWithdrawTaprootName,
e2etests.TestBitcoinWithdrawLegacyName,
e2etests.TestBitcoinWithdrawP2SHName,
e2etests.TestBitcoinWithdrawP2WSHName,
e2etests.TestBitcoinWithdrawInvalidAddressName,
e2etests.TestZetaWithdrawBTCRevertName,
e2etests.TestCrosschainSwapName,
}
bitcoinAdvancedTests := []string{
e2etests.TestBitcoinWithdrawTaprootName,
e2etests.TestBitcoinWithdrawLegacyName,
e2etests.TestBitcoinWithdrawP2SHName,
e2etests.TestBitcoinWithdrawP2WSHName,
e2etests.TestBitcoinWithdrawRestrictedName,
}
ethereumTests := []string{
Expand All @@ -288,13 +298,17 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
ethereumTests = append(ethereumTests, ethereumAdvancedTests...)
}

// skip the header proof test if we run light test or skipHeaderProof is enabled
testHeader := !light && !skipHeaderProof

eg.Go(erc20TestRoutine(conf, deployerRunner, verbose, erc20Tests...))
eg.Go(zetaTestRoutine(conf, deployerRunner, verbose, zetaTests...))
eg.Go(bitcoinTestRoutine(conf, deployerRunner, verbose, !skipBitcoinSetup, !light, bitcoinTests...))
eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, !light, ethereumTests...))
eg.Go(bitcoinTestRoutine(conf, deployerRunner, verbose, !skipBitcoinSetup, testHeader, bitcoinTests...))
eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, testHeader, ethereumTests...))
}
if testAdmin {
eg.Go(adminTestRoutine(conf, deployerRunner, verbose,
e2etests.TestRateLimiterName,
e2etests.TestPauseZRC20Name,
e2etests.TestUpdateBytecodeZRC20Name,
e2etests.TestUpdateBytecodeConnectorName,
Expand Down
40 changes: 20 additions & 20 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@ sleep 2
### Create the accounts and fund them with Ether on local Ethereum network

# unlock the deployer account
echo "funding deployer address 0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC", value: web3.toWei(100,"ether")})' attach http://eth:8545
echo "funding deployer address 0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC", value: web3.toWei(10000,"ether")})' attach http://eth:8545

# unlock erc20 tester accounts
echo "funding deployer address 0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6 with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6", value: web3.toWei(100,"ether")})' attach http://eth:8545
echo "funding deployer address 0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6 with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6", value: web3.toWei(10000,"ether")})' attach http://eth:8545

# unlock zeta tester accounts
echo "funding deployer address 0x5cC2fBb200A929B372e3016F1925DcF988E081fd with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x5cC2fBb200A929B372e3016F1925DcF988E081fd", value: web3.toWei(100,"ether")})' attach http://eth:8545
echo "funding deployer address 0x5cC2fBb200A929B372e3016F1925DcF988E081fd with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x5cC2fBb200A929B372e3016F1925DcF988E081fd", value: web3.toWei(10000,"ether")})' attach http://eth:8545

# unlock bitcoin tester accounts
echo "funding deployer address 0x283d810090EdF4043E75247eAeBcE848806237fD with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x283d810090EdF4043E75247eAeBcE848806237fD", value: web3.toWei(100,"ether")})' attach http://eth:8545
echo "funding deployer address 0x283d810090EdF4043E75247eAeBcE848806237fD with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x283d810090EdF4043E75247eAeBcE848806237fD", value: web3.toWei(10000,"ether")})' attach http://eth:8545

# unlock ethers tester accounts
echo "funding deployer address 0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A", value: web3.toWei(100,"ether")})' attach http://eth:8545
echo "funding deployer address 0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A", value: web3.toWei(10000,"ether")})' attach http://eth:8545

# unlock miscellaneous tests accounts
echo "funding deployer address 0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf", value: web3.toWei(100,"ether")})' attach http://eth:8545
echo "funding deployer address 0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf", value: web3.toWei(10000,"ether")})' attach http://eth:8545

# unlock admin erc20 tests accounts
echo "funding deployer address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", value: web3.toWei(100,"ether")})' attach http://eth:8545
echo "funding deployer address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", value: web3.toWei(10000,"ether")})' attach http://eth:8545

# unlock the TSS account
echo "funding TSS address 0xF421292cb0d3c97b90EEEADfcD660B893592c6A2 with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xF421292cb0d3c97b90EEEADfcD660B893592c6A2", value: web3.toWei(100,"ether")})' attach http://eth:8545
echo "funding TSS address 0xF421292cb0d3c97b90EEEADfcD660B893592c6A2 with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xF421292cb0d3c97b90EEEADfcD660B893592c6A2", value: web3.toWei(10000,"ether")})' attach http://eth:8545

### Run zetae2e command depending on the option passed

Expand All @@ -57,12 +57,12 @@ if [ "$OPTION" == "upgrade" ]; then
# Run zetae2e, if the upgrade height is lower than 100, we use the setup-only flag
if [ "$UPGRADE_HEIGHT" -lt 100 ]; then
echo "running E2E command to setup the networks..."
zetae2e "$ZETAE2E_CMD" --setup-only --config-out deployed.yml
zetae2e "$ZETAE2E_CMD" --setup-only --config-out deployed.yml --skip-header-proof
else
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 "$ZETAE2E_CMD" --config-out deployed.yml --light
zetae2e "$ZETAE2E_CMD" --config-out deployed.yml --light --skip-header-proof
fi
ZETAE2E_EXIT_CODE=$?

Expand All @@ -86,9 +86,9 @@ if [ "$OPTION" == "upgrade" ]; then
# When the upgrade height is greater than 100 for upgrade test, the Bitcoin tests have been run once, therefore the Bitcoin wallet is already set up
# Use light flag to skip advanced tests
if [ "$UPGRADE_HEIGHT" -lt 100 ]; then
zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml --light
zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml --light --skip-header-proof
else
zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml --skip-bitcoin-setup --light
zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-header-proof
fi

ZETAE2E_EXIT_CODE=$?
Expand Down
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [ $HOSTNAME == "zetaclient0" ]
then
rm ~/.tss/*
MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND"
zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND"

# check if the option is additional-evm
# in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545)
Expand Down
1 change: 1 addition & 0 deletions docs/cli/zetacored/zetacored_query_crosschain.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ zetacored query crosschain [flags]
* [zetacored query crosschain list-in-tx-tracker](zetacored_query_crosschain_list-in-tx-tracker.md) - shows a list of in tx tracker by chainId
* [zetacored query crosschain list-out-tx-tracker](zetacored_query_crosschain_list-out-tx-tracker.md) - list all OutTxTracker
* [zetacored query crosschain list-pending-cctx](zetacored_query_crosschain_list-pending-cctx.md) - shows pending CCTX
* [zetacored query crosschain list_pending_cctx_within_rate_limit](zetacored_query_crosschain_list_pending_cctx_within_rate_limit.md) - list all pending CCTX within rate limit
* [zetacored query crosschain show-cctx](zetacored_query_crosschain_show-cctx.md) - shows a CCTX
* [zetacored query crosschain show-gas-price](zetacored_query_crosschain_show-gas-price.md) - shows a gasPrice
* [zetacored query crosschain show-in-tx-hash-to-cctx](zetacored_query_crosschain_show-in-tx-hash-to-cctx.md) - shows a inTxHashToCctx
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# query crosschain list_pending_cctx_within_rate_limit

list all pending CCTX within rate limit

```
zetacored query crosschain list_pending_cctx_within_rate_limit [flags]
```

### Options

```
--grpc-addr string the gRPC endpoint to use for this chain
--grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS
--height int Use a specific height to query state at (this can error if the node is pruning state)
-h, --help help for list_pending_cctx_within_rate_limit
--node string [host]:[port] to Tendermint RPC interface for this chain
-o, --output string Output format (text|json)
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored query crosschain](zetacored_query_crosschain.md) - Querying commands for the crosschain module

5 changes: 5 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54060,6 +54060,11 @@ definitions:
total_pending:
type: string
format: uint64
current_withdraw_window:
type: string
format: int64
current_withdraw_rate:
type: string
rate_limit_exceeded:
type: boolean
crosschainQueryMessagePassingProtocolFeeResponse:
Expand Down
16 changes: 16 additions & 0 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
TestEtherWithdrawRestrictedName = "eth_withdraw_restricted"
TestBitcoinDepositName = "bitcoin_deposit"
TestZetaDepositName = "zeta_deposit"
TestZetaDepositNewAddressName = "zeta_deposit_new_address"
TestZetaDepositRestrictedName = "zeta_deposit_restricted"

TestDonationEtherName = "donation_ether"
Expand All @@ -58,6 +59,7 @@ const (
TestPauseZRC20Name = "pause_zrc20"
TestUpdateBytecodeZRC20Name = "update_bytecode_zrc20"
TestUpdateBytecodeConnectorName = "update_bytecode_connector"
TestRateLimiterName = "rate_limiter"
)

// AllE2ETests is an ordered list of all e2e tests
Expand Down Expand Up @@ -120,6 +122,14 @@ var AllE2ETests = []runner.E2ETest{
},
TestZetaDeposit,
),
runner.NewE2ETest(
TestZetaDepositNewAddressName,
"deposit ZETA from Ethereum to a new ZEVM address which does not exist yet",
[]runner.ArgDefinition{
runner.ArgDefinition{Description: "amount in azeta", DefaultValue: "1000000000000000000"},
},
TestZetaDepositNewAddress,
),
runner.NewE2ETest(
TestZetaWithdrawBTCRevertName,
"sending ZETA from ZEVM to Bitcoin with a message that should revert cctxs",
Expand Down Expand Up @@ -377,6 +387,12 @@ var AllE2ETests = []runner.E2ETest{
[]runner.ArgDefinition{},
TestUpdateBytecodeConnector,
),
runner.NewE2ETest(
TestRateLimiterName,
"test sending cctxs with rate limiter enabled and show logs when processing cctxs",
[]runner.ArgDefinition{},
TestRateLimiter,
),
runner.NewE2ETest(
TestMessagePassingZEVMToEVMName,
"zevm -> evm message passing contract call",
Expand Down
22 changes: 2 additions & 20 deletions e2e/e2etests/test_erc20_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,10 @@ func TestERC20Withdraw(r *runner.E2ERunner, args []string) {
r.Logger.Info("eth zrc20 approve receipt: status %d", receipt.Status)

// withdraw
tx, err = r.ERC20ZRC20.Withdraw(r.ZEVMAuth, r.DeployerAddress.Bytes(), withdrawalAmount)
if err != nil {
panic(err)
}
receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
r.Logger.Info("Receipt txhash %s status %d", receipt.TxHash, receipt.Status)
for _, log := range receipt.Logs {
event, err := r.ERC20ZRC20.ParseWithdrawal(*log)
if err != nil {
continue
}
r.Logger.Info(
" logs: from %s, to %x, value %d, gasfee %d",
event.From.Hex(),
event.To,
event.Value,
event.Gasfee,
)
}
tx = r.WithdrawERC20(withdrawalAmount)

// verify the withdraw value
cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
verifyTransferAmountFromCCTX(r, cctx, withdrawalAmount.Int64())
}

Expand Down
15 changes: 2 additions & 13 deletions e2e/e2etests/test_eth_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,10 @@ func TestEtherWithdraw(r *runner.E2ERunner, args []string) {
r.Logger.EVMReceipt(*receipt, "approve")

// withdraw
tx, err = r.ETHZRC20.Withdraw(r.ZEVMAuth, r.DeployerAddress.Bytes(), withdrawalAmount)
if err != nil {
panic(err)
}
r.Logger.EVMTransaction(*tx, "withdraw")

receipt = utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
if receipt.Status == 0 {
panic("withdraw failed")
}
r.Logger.EVMReceipt(*receipt, "withdraw")
r.Logger.ZRC20Withdrawal(r.ETHZRC20, *receipt, "withdraw")
tx = r.WithdrawEther(withdrawalAmount)

// verify the withdraw value
cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, receipt.TxHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
cctx := utils.WaitCctxMinedByInTxHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
r.Logger.CCTX(*cctx, "withdraw")
if cctx.CctxStatus.Status != crosschaintypes.CctxStatus_OutboundMined {
panic("cctx status is not outbound mined")
Expand Down
Loading

0 comments on commit 3e298ba

Please sign in to comment.