Skip to content

Commit

Permalink
switch v2 with legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Dec 6, 2024
1 parent 24c1e3f commit 4c22ffa
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 317 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
TSS_MIGRATION_TESTS: ${{ steps.matrix-conditionals.outputs.TSS_MIGRATION_TESTS }}
SOLANA_TESTS: ${{ steps.matrix-conditionals.outputs.SOLANA_TESTS }}
TON_TESTS: ${{ steps.matrix-conditionals.outputs.TON_TESTS }}
V2_TESTS: ${{ steps.matrix-conditionals.outputs.V2_TESTS }}
LEGACY_TESTS: ${{ steps.matrix-conditionals.outputs.LEGACY_TESTS }}
ENABLE_MONITORING: ${{ steps.matrix-conditionals.outputs.ENABLE_MONITORING }}
steps:
# use api rather than event context to avoid race conditions (label added after push)
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
core.setOutput('TSS_MIGRATION_TESTS', labels.includes('TSS_MIGRATION_TESTS'));
core.setOutput('SOLANA_TESTS', labels.includes('SOLANA_TESTS'));
core.setOutput('TON_TESTS', labels.includes('TON_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('LEGACY_TESTS', labels.includes('LEGACY_TESTS'));
core.setOutput('ENABLE_MONITORING', labels.includes('ENABLE_MONITORING'));
} else if (context.eventName === 'merge_group') {
// default mergequeue tests
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
core.setOutput('TON_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('LEGACY_TESTS', true);
} else if (context.eventName === 'schedule') {
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_TESTS', true);
Expand All @@ -193,7 +193,7 @@ jobs:
core.setOutput('TSS_MIGRATION_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
core.setOutput('TON_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('LEGACY_TESTS', true);
} else if (context.eventName === 'workflow_dispatch') {
const makeTargets = context.payload.inputs['make-targets'].split(',');
core.setOutput('DEFAULT_TESTS', makeTargets.includes('default-test'));
Expand All @@ -206,7 +206,7 @@ jobs:
core.setOutput('TSS_MIGRATION_TESTS', makeTargets.includes('tss-migration-test'));
core.setOutput('SOLANA_TESTS', makeTargets.includes('solana-test'));
core.setOutput('TON_TESTS', makeTargets.includes('ton-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('LEGACY_TESTS', makeTargets.includes('legacy-test'));
core.setOutput('ENABLE_MONITORING', context.payload.inputs['enable-monitoring']);
}
Expand Down Expand Up @@ -255,9 +255,9 @@ jobs:
- make-target: "start-ton-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.TON_TESTS == 'true' }}
- make-target: "start-v2-test"
- make-target: "start-legacy-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.V2_TESTS == 'true' }}
run: ${{ needs.matrix-conditionals.outputs.LEGACY_TESTS == 'true' }}
name: ${{ matrix.make-target }}
uses: ./.github/workflows/reusable-e2e.yml
with:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ start-ton-test: e2e-images
export E2E_ARGS="--skip-regular --test-ton" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile ton up -d

start-v2-test: e2e-images
@echo "--> Starting e2e smart contracts v2 test"
export E2E_ARGS="--skip-regular --test-v2" && \
start-legacy-test: e2e-images
@echo "--> Starting e2e smart contracts legacy test"
export E2E_ARGS="--skip-regular --test-legacy" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d

###############################################################################
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/zeta-chain/node/testutil"
)

// initBitcoinTestRunners initializes Bitcoin deposit and withdraw test runners
func initBitcoinTestRunners(
// bitcoinTestRoutines returns test routines for deposit and withdraw tests
func bitcoinTestRoutines(
conf config.Config,
deployerRunner *runner.E2ERunner,
verbose bool,
Expand Down
2 changes: 2 additions & 0 deletions cmd/zetae2e/local/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func startEVMTests(eg *errgroup.Group, conf config.Config, deployerRunner *runne
e2etests.TestEVMToZEVMCallName,
e2etests.TestETHDepositAndCallNoMessageName,
e2etests.TestETHWithdrawAndCallNoMessageName,
e2etests.TestEtherWithdrawRestrictedName, // to change to use v2
))

// Test happy paths for erc20 token workflow
Expand All @@ -41,6 +42,7 @@ func startEVMTests(eg *errgroup.Group, conf config.Config, deployerRunner *runne
e2etests.TestERC20DepositAndCallNoMessageName,
e2etests.TestERC20WithdrawAndCallNoMessageName,
e2etests.TestDepositAndCallSwapName,
e2etests.TestERC20DepositRestrictedName, // to change to use v2
))

// Test revert cases for gas token workflow
Expand Down
53 changes: 53 additions & 0 deletions cmd/zetae2e/local/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,56 @@ func legacyZEVMMPTestRoutine(
return err
}
}

// legacyZETATestRoutine runs Zeta transfer and message passing related e2e tests
func legacyZETATestRoutine(
conf config.Config,
deployerRunner *runner.E2ERunner,
verbose bool,
testNames ...string,
) func() error {
return func() (err error) {
account := conf.AdditionalAccounts.UserZetaTest
// initialize runner for zeta test
zetaRunner, err := initTestRunner(
"zeta",
conf,
deployerRunner,
account,
runner.NewLogger(verbose, color.FgBlue, "zeta"),
)
if err != nil {
return err
}

zetaRunner.Logger.Print("🏃 starting Zeta tests")
startTime := time.Now()

// funding the account
txZetaSend := deployerRunner.SendZetaOnEvm(account.EVMAddress(), 1000)
zetaRunner.WaitForTxReceiptOnEvm(txZetaSend)

// depositing the necessary tokens on ZetaChain
txZetaDeposit := zetaRunner.DepositZeta()
txEtherDeposit := zetaRunner.DepositEther()
zetaRunner.WaitForMinedCCTX(txZetaDeposit)
zetaRunner.WaitForMinedCCTX(txEtherDeposit)

// run zeta test
testsToRun, err := zetaRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
testNames...,
)
if err != nil {
return fmt.Errorf("zeta tests failed: %v", err)
}

if err := zetaRunner.RunE2ETests(testsToRun); err != nil {
return fmt.Errorf("zeta tests failed: %v", err)
}

zetaRunner.Logger.Print("🍾 Zeta tests completed in %s", time.Since(startTime).String())

return err
}
}
147 changes: 61 additions & 86 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
flagTestTSSMigration = "test-tss-migration"
flagSkipBitcoinSetup = "skip-bitcoin-setup"
flagSkipHeaderProof = "skip-header-proof"
flagTestV2 = "test-v2"
flagTestLegacy = "test-legacy"
flagSkipTrackerCheck = "skip-tracker-check"
flagSkipPrecompiles = "skip-precompiles"
flagUpgradeContracts = "upgrade-contracts"
Expand Down Expand Up @@ -77,7 +77,7 @@ func NewLocalCmd() *cobra.Command {
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")
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(flagTestLegacy, false, "set to true to run legacy EVM tests")
cmd.Flags().Bool(flagSkipTrackerCheck, false, "set to true to skip tracker check at the end of the tests")
cmd.Flags().Bool(flagSkipPrecompiles, false, "set to true to skip stateful precompiled contracts test")
cmd.Flags().
Expand Down Expand Up @@ -107,7 +107,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
skipHeaderProof = must(cmd.Flags().GetBool(flagSkipHeaderProof))
skipTrackerCheck = must(cmd.Flags().GetBool(flagSkipTrackerCheck))
testTSSMigration = must(cmd.Flags().GetBool(flagTestTSSMigration))
testV2 = must(cmd.Flags().GetBool(flagTestV2))
testLegacy = must(cmd.Flags().GetBool(flagTestLegacy))
skipPrecompiles = must(cmd.Flags().GetBool(flagSkipPrecompiles))
upgradeContracts = must(cmd.Flags().GetBool(flagUpgradeContracts))
)
Expand Down Expand Up @@ -278,41 +278,18 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
os.Exit(0)
}

if upgradeContracts {
deployerRunner.UpgradeGatewaysAndERC20Custody()
}

// run tests
var eg errgroup.Group

if !skipRegular {
// defines all tests, if light is enabled, only the most basic tests are run and advanced are skipped
erc20Tests := []string{
e2etests.TestLegacyERC20WithdrawName,
e2etests.TestLegacyMultipleERC20WithdrawsName,
e2etests.TestLegacyERC20DepositAndCallRefundName,
e2etests.TestZRC20SwapName,
}
erc20AdvancedTests := []string{
e2etests.TestERC20DepositRestrictedName,
}
zetaTests := []string{
e2etests.TestZetaWithdrawName,
e2etests.TestLegacyMessagePassingExternalChainsName,
e2etests.TestLegacyMessagePassingRevertFailExternalChainsName,
e2etests.TestLegacyMessagePassingRevertSuccessExternalChainsName,
}
zetaAdvancedTests := []string{
e2etests.TestZetaDepositRestrictedName,
e2etests.TestZetaDepositName,
e2etests.TestZetaDepositNewAddressName,
}
zevmMPTests := []string{}
zevmMPAdvancedTests := []string{
e2etests.TestLegacyMessagePassingZEVMToEVMName,
e2etests.TestLegacyMessagePassingEVMtoZEVMName,
e2etests.TestLegacyMessagePassingEVMtoZEVMRevertName,
e2etests.TestLegacyMessagePassingZEVMtoEVMRevertName,
e2etests.TestLegacyMessagePassingZEVMtoEVMRevertFailName,
e2etests.TestLegacyMessagePassingEVMtoZEVMRevertFailName,
}
// start the EVM tests
startEVMTests(&eg, conf, deployerRunner, verbose)

// start the bitcoin tests
// btc withdraw tests are those that need a Bitcoin node wallet to send UTXOs
bitcoinDepositTests := []string{
e2etests.TestBitcoinDonationName,
Expand All @@ -332,7 +309,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
bitcoinWithdrawTests := []string{
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestBitcoinWithdrawInvalidAddressName,
e2etests.TestZetaWithdrawBTCRevertName,
e2etests.TestLegacyZetaWithdrawBTCRevertName,
}
bitcoinWithdrawTestsAdvanced := []string{
e2etests.TestBitcoinWithdrawTaprootName,
Expand All @@ -342,56 +319,37 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestBitcoinWithdrawMultipleName,
e2etests.TestBitcoinWithdrawRestrictedName,
}
ethereumTests := []string{
e2etests.TestLegacyEtherWithdrawName,
e2etests.TestLegacyEtherDepositAndCallName,
e2etests.TestLegacyEtherDepositAndCallRefundName,
}
ethereumAdvancedTests := []string{
e2etests.TestEtherWithdrawRestrictedName,
}
precompiledContractTests := []string{}

if !skipPrecompiles {
precompiledContractTests = []string{
e2etests.TestPrecompilesPrototypeName,
e2etests.TestPrecompilesPrototypeThroughContractName,
e2etests.TestPrecompilesStakingName,
// Disabled until further notice, check https://github.com/zeta-chain/node/issues/3005.
// e2etests.TestPrecompilesStakingThroughContractName,
e2etests.TestPrecompilesBankName,
e2etests.TestPrecompilesBankFailName,
e2etests.TestPrecompilesBankThroughContractName,
e2etests.TestPrecompilesDistributeName,
e2etests.TestPrecompilesDistributeNonZRC20Name,
e2etests.TestPrecompilesDistributeThroughContractName,
}
}

if !light {
erc20Tests = append(erc20Tests, erc20AdvancedTests...)
zetaTests = append(zetaTests, zetaAdvancedTests...)
zevmMPTests = append(zevmMPTests, zevmMPAdvancedTests...)
// if light is enabled, only the most basic tests are run and advanced are skipped
bitcoinDepositTests = append(bitcoinDepositTests, bitcoinDepositTestsAdvanced...)
bitcoinWithdrawTests = append(bitcoinWithdrawTests, bitcoinWithdrawTestsAdvanced...)
ethereumTests = append(ethereumTests, ethereumAdvancedTests...)
}

eg.Go(statefulPrecompilesTestRoutine(conf, deployerRunner, verbose, precompiledContractTests...))
eg.Go(legacyERC20TestRoutine(conf, deployerRunner, verbose, erc20Tests...))
eg.Go(zetaTestRoutine(conf, deployerRunner, verbose, zetaTests...))
eg.Go(legacyZEVMMPTestRoutine(conf, deployerRunner, verbose, zevmMPTests...))
runnerDeposit, runnerWithdraw := initBitcoinTestRunners(
bitcoinDepositTestRoutine, bitcoinWithdrawTestRoutine := bitcoinTestRoutines(
conf,
deployerRunner,
verbose,
!skipBitcoinSetup,
bitcoinDepositTests,
bitcoinWithdrawTests,
)
eg.Go(runnerDeposit)
eg.Go(runnerWithdraw)
eg.Go(legacyEthereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...))
eg.Go(bitcoinDepositTestRoutine)
eg.Go(bitcoinWithdrawTestRoutine)
}

if !skipPrecompiles {
eg.Go(statefulPrecompilesTestRoutine(conf, deployerRunner, verbose,
e2etests.TestPrecompilesPrototypeName,
e2etests.TestPrecompilesPrototypeThroughContractName,
e2etests.TestPrecompilesStakingName,
// Disabled until further notice, check https://github.com/zeta-chain/node/issues/3005.
// e2etests.TestPrecompilesStakingThroughContractName,
e2etests.TestPrecompilesBankName,
e2etests.TestPrecompilesBankFailName,
e2etests.TestPrecompilesBankThroughContractName,
e2etests.TestPrecompilesDistributeName,
e2etests.TestPrecompilesDistributeNonZRC20Name,
e2etests.TestPrecompilesDistributeThroughContractName,
))
}

if testAdmin {
Expand All @@ -405,23 +363,19 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestPauseERC20CustodyName,
e2etests.TestMigrateERC20CustodyFundsName,

// Test the rate limiter functionalities
// this test is currently incomplete and takes 10m to run
// TODO: define assertion, and make more optimized
// https://github.com/zeta-chain/node/issues/2090
//e2etests.TestRateLimiterName,

// TestMigrateChainSupportName tests EVM chain migration. Currently this test doesn't work with Anvil because pre-EIP1559 txs are not supported
// Currently this test doesn't work with Anvil because pre-EIP1559 txs are not supported
// See issue below for details
// TODO: reenable this test as per the issue below
// https://github.com/zeta-chain/node/issues/1980
// e2etests.TestMigrateChainSupportName,
))
}

if testPerformance {
eg.Go(ethereumDepositPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressEtherDepositName))
eg.Go(ethereumWithdrawPerformanceRoutine(conf, deployerRunner, verbose, e2etests.TestStressEtherWithdrawName))
}

if testSolana {
if deployerRunner.SolanaClient == nil {
logger.Print("❌ solana client is nil, maybe solana rpc is not set")
Expand Down Expand Up @@ -463,12 +417,33 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
eg.Go(tonTestRoutine(conf, deployerRunner, verbose, tonTests...))
}

if upgradeContracts {
deployerRunner.UpgradeGatewaysAndERC20Custody()
}

if testV2 {
startEVMTests(&eg, conf, deployerRunner, verbose)
if testLegacy {
eg.Go(legacyERC20TestRoutine(conf, deployerRunner, verbose,
e2etests.TestLegacyERC20WithdrawName,
e2etests.TestLegacyMultipleERC20WithdrawsName,
e2etests.TestLegacyERC20DepositAndCallRefundName))
eg.Go(legacyZETATestRoutine(conf, deployerRunner, verbose,
e2etests.TestLegacyZetaWithdrawName,
e2etests.TestLegacyMessagePassingExternalChainsName,
e2etests.TestLegacyMessagePassingRevertFailExternalChainsName,
e2etests.TestLegacyMessagePassingRevertSuccessExternalChainsName,
e2etests.TestLegacyZetaDepositRestrictedName,
e2etests.TestLegacyZetaDepositName,
e2etests.TestLegacyZetaDepositNewAddressName,
))
eg.Go(legacyZEVMMPTestRoutine(conf, deployerRunner, verbose,
e2etests.TestLegacyMessagePassingZEVMToEVMName,
e2etests.TestLegacyMessagePassingEVMtoZEVMName,
e2etests.TestLegacyMessagePassingEVMtoZEVMRevertName,
e2etests.TestLegacyMessagePassingZEVMtoEVMRevertName,
e2etests.TestLegacyMessagePassingZEVMtoEVMRevertFailName,
e2etests.TestLegacyMessagePassingEVMtoZEVMRevertFailName,
))
eg.Go(legacyEthereumTestRoutine(conf, deployerRunner, verbose,
e2etests.TestLegacyEtherWithdrawName,
e2etests.TestLegacyEtherDepositAndCallName,
e2etests.TestLegacyEtherDepositAndCallRefundName,
))
}

// while tests are executed, monitor blocks in parallel to check if system txs are on top and they have biggest priority
Expand Down
Loading

0 comments on commit 4c22ffa

Please sign in to comment.