Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): backport protocol contract v2 migration test #2821

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 26 additions & 52 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,12 @@ on:
- cron: "0 6 * * *"
workflow_dispatch:
inputs:
default-test:
type: boolean
required: false
default: false
upgrade-light-test:
type: boolean
required: false
default: false
upgrade-test:
type: boolean
required: false
default: false
admin-test:
type: boolean
required: false
default: false
upgrade-import-mainnet-test:
type: boolean
required: false
default: false
performance-test:
type: boolean
required: false
default: false
stateful-data-test:
type: boolean
required: false
default: false
tss-migration-test:
type: boolean
required: false
default: false
solana-test:
type: boolean
required: false
default: false
v2-test:
type: boolean
required: false
default: false
make-targets:
description: 'Comma separated list of make targets to run (without the start- prefix)'
required: true
default: ''

concurrency:
concurrency:
group: e2e-${{ github.head_ref || github.sha }}
cancel-in-progress: true

Expand All @@ -74,6 +38,7 @@ jobs:
TSS_MIGRATION_TESTS: ${{ steps.matrix-conditionals.outputs.TSS_MIGRATION_TESTS }}
SOLANA_TESTS: ${{ steps.matrix-conditionals.outputs.SOLANA_TESTS }}
V2_TESTS: ${{ steps.matrix-conditionals.outputs.V2_TESTS }}
V2_MIGRATION_TESTS: ${{ steps.matrix-conditionals.outputs.V2_MIGRATION_TESTS }}
steps:
# use api rather than event context to avoid race conditions (label added after push)
- id: matrix-conditionals
Expand All @@ -98,6 +63,7 @@ jobs:
core.setOutput('TSS_MIGRATION_TESTS', labels.includes('TSS_MIGRATION_TESTS'));
core.setOutput('SOLANA_TESTS', labels.includes('SOLANA_TESTS'));
core.setOutput('V2_TESTS', labels.includes('V2_TESTS')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', labels.includes('V2_MIGRATION_TESTS')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'merge_group') {
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_LIGHT_TESTS', true);
Expand All @@ -112,6 +78,7 @@ jobs:
core.setOutput('PERFORMANCE_TESTS', true);
core.setOutput('STATEFUL_DATA_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'schedule') {
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_TESTS', true);
Expand All @@ -123,17 +90,20 @@ jobs:
core.setOutput('TSS_MIGRATION_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'workflow_dispatch') {
core.setOutput('DEFAULT_TESTS', context.payload.inputs['default-test']);
core.setOutput('UPGRADE_TESTS', context.payload.inputs['upgrade-test']);
core.setOutput('UPGRADE_LIGHT_TESTS', context.payload.inputs['upgrade-light-test']);
core.setOutput('UPGRADE_IMPORT_MAINNET_TESTS', context.payload.inputs['upgrade-import-mainnet-test']);
core.setOutput('ADMIN_TESTS', context.payload.inputs['admin-test']);
core.setOutput('PERFORMANCE_TESTS', context.payload.inputs['performance-test']);
core.setOutput('STATEFUL_DATA_TESTS', context.payload.inputs['stateful-data-test']);
core.setOutput('TSS_MIGRATION_TESTS', context.payload.inputs['tss-migration-test']);
core.setOutput('SOLANA_TESTS', context.payload.inputs['solana-test']);
core.setOutput('V2_TESTS', context.payload.inputs['v2-test']); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
const makeTargets = context.payload.inputs['make-targets'].split(',');
core.setOutput('DEFAULT_TESTS', makeTargets.includes('default-test'));
core.setOutput('UPGRADE_TESTS', makeTargets.includes('upgrade-test'));
core.setOutput('UPGRADE_LIGHT_TESTS', makeTargets.includes('upgrade-test-light'));
core.setOutput('UPGRADE_IMPORT_MAINNET_TESTS', makeTargets.includes('upgrade-import-mainnet-test'));
core.setOutput('ADMIN_TESTS', makeTargets.includes('admin-test'));
core.setOutput('PERFORMANCE_TESTS', makeTargets.includes('performance-test'));
core.setOutput('STATEFUL_DATA_TESTS', makeTargets.includes('import-mainnet-test'));
core.setOutput('TSS_MIGRATION_TESTS', makeTargets.includes('tss-migration-test'));
core.setOutput('SOLANA_TESTS', makeTargets.includes('solana-test'));
core.setOutput('V2_TESTS', makeTargets.includes('v2-test')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', makeTargets.includes('v2-migration-test')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
}

e2e:
Expand Down Expand Up @@ -168,12 +138,16 @@ jobs:
- make-target: "start-tss-migration-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.TSS_MIGRATION_TESTS == 'true' }}
timeout-minutes: 40
- make-target: "start-solana-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.SOLANA_TESTS == 'true' }}
- make-target: "start-v2-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.V2_TESTS == 'true' }}
- make-target: "start-upgrade-v2-migration-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.V2_MIGRATION_TESTS == 'true' }}
name: ${{ matrix.make-target }}
uses: ./.github/workflows/reusable-e2e.yml
with:
Expand Down Expand Up @@ -239,4 +213,4 @@ jobs:
exit 0
else
exit 1
fi
fi
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ start-e2e-admin-test: zetanode
export E2E_ARGS="--skip-regular --test-admin" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile eth2 -f docker-compose.yml up -d

# this test upgrades from v18 and execute the v2 contracts migration process
# this tests is part of upgrade test part because it should run the upgrade from v18 to fully replicate the upgrade process
start-upgrade-v2-migration-test: zetanode-upgrade
@echo "--> Starting v2 migration upgrade test"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
export E2E_ARGS="--test-v2-migration" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-e2e-performance-test: zetanode
@echo "--> Starting e2e performance test"
export E2E_ARGS="--test-performance" && \
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CHANGELOG

## Unreleased
## v20.0.0

### Features

Expand All @@ -22,6 +22,7 @@
### Tests

* [2726](https://github.com/zeta-chain/node/pull/2726) - add e2e tests for deposit and call, deposit and revert
* [2821](https://github.com/zeta-chain/node/pull/2821) - V2 protocol contracts migration e2e tests

### Fixes

Expand Down
16 changes: 16 additions & 0 deletions cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ additional_accounts:
bech32_address: "zeta1pvtxa708yvdmszn687nne6nl8qn704daf420xz"
evm_address: "0x0B166ef9e7231Bb80A7A3FA73CEA7F3827E7D5BD"
private_key: "0bcc2fa28b526f90e1d54648d612db901e860bf68248555593f91ea801c6b482"
user_v2_ether:
bech32_address: "zeta1erlqlpl5da7a9r3emzw60kax9fxc3h0r3z7c5e"
evm_address: "0xC8fe0F87f46F7Dd28e39D89Da7Dba62A4D88dde3"
private_key: "11c25af71c82602a681ce622bf76f4f0fbc3b7f23ce935db6249d1517322f436"
user_v2_erc20:
bech32_address: "zeta12wp6syndml6jd32m7f9mn2wscsxz6cff8nczl4"
evm_address: "0x5383A8126ddff526C55bF24Bb9a9D0c40c2d6129"
private_key: "77b0e4dcc29c5c47b6999dabd42abcfdf7750ccc86d6659c1373ec1ea3b4af6c"
user_v2_ether_revert:
bech32_address: "zeta1m7m5xd79x9qmlyfpqxcwuac04r3dewfpdcfw5e"
evm_address: "0xdFb74337c53141bf912101b0Ee770FA8e2DCB921"
private_key: "be7098604cc40f95d68298a3b4ae13972ac8a3df271ba19ddf169070d30e8ba8"
user_v2_erc20_revert:
bech32_address: "zeta1nry9yeg6njhjrp2ctppa8558vqxal9fxk69zxg"
evm_address: "0x98c852651A9CAF2185585843d3D287600Ddf9526"
private_key: "bf9456c679bb5a952a9a137fcfc920e0413efdb97c36de1e57455763084230cb"
policy_accounts:
emergency_policy_account:
bech32_address: "zeta16m2cnrdwtgweq4njc6t470vl325gw4kp6s7tap"
Expand Down
69 changes: 13 additions & 56 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
flagSkipBitcoinSetup = "skip-bitcoin-setup"
flagSkipHeaderProof = "skip-header-proof"
flagTestV2 = "test-v2"
flagTestV2Migration = "test-v2-migration"
flagSkipTrackerCheck = "skip-tracker-check"
)

Expand Down Expand Up @@ -76,6 +77,7 @@ func NewLocalCmd() *cobra.Command {
cmd.Flags().Bool(flagSkipHeaderProof, false, "set to true to skip header proof tests")
cmd.Flags().Bool(flagTestTSSMigration, false, "set to true to include a migration test at the end")
cmd.Flags().Bool(flagTestV2, false, "set to true to run tests for v2 contracts")
cmd.Flags().Bool(flagTestV2Migration, false, "set to true to run tests for v2 contracts migration test")
cmd.Flags().Bool(flagSkipTrackerCheck, false, "set to true to skip tracker check at the end of the tests")

return cmd
Expand All @@ -101,6 +103,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
skipTrackerCheck = must(cmd.Flags().GetBool(flagSkipTrackerCheck))
testTSSMigration = must(cmd.Flags().GetBool(flagTestTSSMigration))
testV2 = must(cmd.Flags().GetBool(flagTestV2))
testV2Migration = must(cmd.Flags().GetBool(flagTestV2Migration))
)

logger := runner.NewLogger(verbose, color.FgWhite, "setup")
Expand Down Expand Up @@ -233,6 +236,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
os.Exit(0)
}

// run the v2 migration
if testV2Migration {
deployerRunner.RunV2Migration()
}

// run tests
var eg errgroup.Group

Expand Down Expand Up @@ -355,63 +363,12 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
}
if testV2 {
// update the ERC20 custody contract for v2 tests
deployerRunner.UpdateChainParamsERC20CustodyContract()

//// Test happy paths for gas token workflow
eg.Go(v2TestRoutine(conf, "eth", conf.AdditionalAccounts.UserEther, color.FgHiGreen, deployerRunner, verbose,
e2etests.TestV2ETHDepositName,
e2etests.TestV2ETHDepositAndCallName,
e2etests.TestV2ETHWithdrawName,
e2etests.TestV2ETHWithdrawAndCallName,
e2etests.TestV2ZEVMToEVMCallName,
e2etests.TestV2EVMToZEVMCallName,
))

//// Test happy paths for erc20 token workflow
eg.Go(v2TestRoutine(conf, "erc20", conf.AdditionalAccounts.UserERC20, color.FgHiBlue, deployerRunner, verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestV2ERC20DepositName,
e2etests.TestV2ERC20DepositAndCallName,
e2etests.TestV2ERC20WithdrawName,
e2etests.TestV2ERC20WithdrawAndCallName,
))
// note: not run in testV2Migration because it is already run in the migration process
deployerRunner.UpdateChainParamsV2Contracts()
}

// Test revert cases for gas token workflow
eg.Go(
v2TestRoutine(
conf,
"eth-revert",
conf.AdditionalAccounts.UserZetaTest,
color.FgHiYellow,
deployerRunner,
verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM and withdraw
e2etests.TestV2ETHDepositAndCallRevertName,
e2etests.TestV2ETHDepositAndCallRevertWithCallName,
e2etests.TestV2ETHWithdrawAndCallRevertName,
e2etests.TestV2ETHWithdrawAndCallRevertWithCallName,
),
)

// Test revert cases for erc20 token workflow
eg.Go(
v2TestRoutine(
conf,
"erc20-revert",
conf.AdditionalAccounts.UserBitcoin,
color.FgHiRed,
deployerRunner,
verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestV2ERC20DepositName, // necessary to have assets to withdraw
e2etests.TestOperationAddLiquidityETHName, // liquidity with gas and ERC20 are necessary for reverts
e2etests.TestOperationAddLiquidityERC20Name,
e2etests.TestV2ERC20DepositAndCallRevertName,
e2etests.TestV2ERC20DepositAndCallRevertWithCallName,
e2etests.TestV2ERC20WithdrawAndCallRevertName,
e2etests.TestV2ERC20WithdrawAndCallRevertWithCallName,
),
)
if testV2 || testV2Migration {
startV2Tests(&eg, conf, deployerRunner, verbose)
}

// while tests are executed, monitor blocks in parallel to check if system txs are on top and they have biggest priority
Expand Down
62 changes: 61 additions & 1 deletion cmd/zetae2e/local/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,73 @@ import (
"time"

"github.com/fatih/color"
"golang.org/x/sync/errgroup"

"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/e2etests"
"github.com/zeta-chain/zetacore/e2e/runner"
)

// erc20TestRoutine runs v2 related e2e tests
// startV2Tests starts v2 related tests in parallel
func startV2Tests(eg *errgroup.Group, conf config.Config, deployerRunner *runner.E2ERunner, verbose bool) {
// Test happy paths for gas token workflow
eg.Go(v2TestRoutine(conf, "eth", conf.AdditionalAccounts.UserV2Ether, color.FgHiGreen, deployerRunner, verbose,
e2etests.TestV2ETHDepositName,
e2etests.TestV2ETHDepositAndCallName,
e2etests.TestV2ETHWithdrawName,
e2etests.TestV2ETHWithdrawAndCallName,
e2etests.TestV2ZEVMToEVMCallName,
e2etests.TestV2EVMToZEVMCallName,
))

// Test happy paths for erc20 token workflow
eg.Go(v2TestRoutine(conf, "erc20", conf.AdditionalAccounts.UserV2ERC20, color.FgHiBlue, deployerRunner, verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestV2ERC20DepositName,
e2etests.TestV2ERC20DepositAndCallName,
e2etests.TestV2ERC20WithdrawName,
e2etests.TestV2ERC20WithdrawAndCallName,
))

// Test revert cases for gas token workflow
eg.Go(
v2TestRoutine(
conf,
"eth-revert",
conf.AdditionalAccounts.UserV2EtherRevert,
color.FgHiYellow,
deployerRunner,
verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM and withdraw
e2etests.TestV2ETHDepositAndCallRevertName,
e2etests.TestV2ETHDepositAndCallRevertWithCallName,
e2etests.TestV2ETHWithdrawAndCallRevertName,
e2etests.TestV2ETHWithdrawAndCallRevertWithCallName,
),
)

// Test revert cases for erc20 token workflow
eg.Go(
v2TestRoutine(
conf,
"erc20-revert",
conf.AdditionalAccounts.UserV2ERC20Revert,
color.FgHiRed,
deployerRunner,
verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestV2ERC20DepositName, // necessary to have assets to withdraw
e2etests.TestOperationAddLiquidityETHName, // liquidity with gas and ERC20 are necessary for reverts
e2etests.TestOperationAddLiquidityERC20Name,
e2etests.TestV2ERC20DepositAndCallRevertName,
e2etests.TestV2ERC20DepositAndCallRevertWithCallName,
e2etests.TestV2ERC20WithdrawAndCallRevertName,
e2etests.TestV2ERC20WithdrawAndCallRevertWithCallName,
),
)
}

// v2TestRoutine runs v2 related e2e tests
// TODO: this routine will be broken down in the future and will replace most current tests
// we keep a single routine for v2 for simplicity
// https://github.com/zeta-chain/node/issues/2554
Expand Down
20 changes: 20 additions & 0 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ address=$(yq -r '.additional_accounts.user_migration.evm_address' config.yml)
echo "funding migration tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545 > /dev/null

# unlock v2 ethers tests accounts
address=$(yq -r '.additional_accounts.user_v2_ether.evm_address' config.yml)
echo "funding v2 ethers tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545 > /dev/null

# unlock v2 erc20 tests accounts
address=$(yq -r '.additional_accounts.user_v2_erc20.evm_address' config.yml)
echo "funding v2 erc20 tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545 > /dev/null

# unlock v2 ethers revert tests accounts
address=$(yq -r '.additional_accounts.user_v2_ether_revert.evm_address' config.yml)
echo "funding v2 ethers revert tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545 > /dev/null

# unlock v2 erc20 revert tests accounts
address=$(yq -r '.additional_accounts.user_v2_erc20_revert.evm_address' config.yml)
echo "funding v2 erc20 revert tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545 > /dev/null

# unlock local solana relayer accounts
if host solana > /dev/null; then
solana_url=$(yq -r '.rpcs.solana' config.yml)
Expand Down
Loading
Loading