From 8c91c989a6a26197fdaf210ef58f68f4163c5106 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 12 Sep 2024 10:36:19 -0400 Subject: [PATCH 1/5] debug test --- Makefile | 1 - cmd/zetae2e/local/local.go | 24 ++++++++++++------------ e2e/e2etests/test_admin_transactions.go | 1 + e2e/e2etests/test_precompiles_staking.go | 23 +++++++++++++++++++++++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 946c06df0a..5f8c1fea15 100644 --- a/Makefile +++ b/Makefile @@ -272,7 +272,6 @@ start-stress-test: zetanode start-tss-migration-test: zetanode @echo "--> Starting tss migration test" export LOCALNET_MODE=tss-migrate && \ - export E2E_ARGS="--test-tss-migration" && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d start-solana-test: zetanode solana diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 098d8dab5c..bbdaee0666 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -102,13 +102,13 @@ func localE2ETest(cmd *cobra.Command, _ []string) { light = must(cmd.Flags().GetBool(flagLight)) setupOnly = must(cmd.Flags().GetBool(flagSetupOnly)) skipSetup = must(cmd.Flags().GetBool(flagSkipSetup)) - skipBitcoinSetup = must(cmd.Flags().GetBool(flagSkipBitcoinSetup)) - skipHeaderProof = must(cmd.Flags().GetBool(flagSkipHeaderProof)) - skipTrackerCheck = must(cmd.Flags().GetBool(flagSkipTrackerCheck)) - testTSSMigration = must(cmd.Flags().GetBool(flagTestTSSMigration)) - testV2 = must(cmd.Flags().GetBool(flagTestV2)) - testV2Migration = must(cmd.Flags().GetBool(flagTestV2Migration)) - skipPrecompiles = must(cmd.Flags().GetBool(flagSkipPrecompiles)) + //skipBitcoinSetup = must(cmd.Flags().GetBool(flagSkipBitcoinSetup)) + skipHeaderProof = must(cmd.Flags().GetBool(flagSkipHeaderProof)) + skipTrackerCheck = must(cmd.Flags().GetBool(flagSkipTrackerCheck)) + testTSSMigration = must(cmd.Flags().GetBool(flagTestTSSMigration)) + testV2 = must(cmd.Flags().GetBool(flagTestV2)) + testV2Migration = must(cmd.Flags().GetBool(flagTestV2Migration)) + skipPrecompiles = must(cmd.Flags().GetBool(flagSkipPrecompiles)) ) logger := runner.NewLogger(verbose, color.FgWhite, "setup") @@ -325,11 +325,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) { } eg.Go(statefulPrecompilesTestRoutine(conf, deployerRunner, verbose, precompiledContractTests...)) - eg.Go(erc20TestRoutine(conf, deployerRunner, verbose, erc20Tests...)) - eg.Go(zetaTestRoutine(conf, deployerRunner, verbose, zetaTests...)) - eg.Go(zevmMPTestRoutine(conf, deployerRunner, verbose, zevmMPTests...)) - eg.Go(bitcoinTestRoutine(conf, deployerRunner, verbose, !skipBitcoinSetup, bitcoinTests...)) - eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...)) + //eg.Go(erc20TestRoutine(conf, deployerRunner, verbose, erc20Tests...)) + //eg.Go(zetaTestRoutine(conf, deployerRunner, verbose, zetaTests...)) + //eg.Go(zevmMPTestRoutine(conf, deployerRunner, verbose, zevmMPTests...)) + //eg.Go(bitcoinTestRoutine(conf, deployerRunner, verbose, !skipBitcoinSetup, bitcoinTests...)) + //eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...)) } if testAdmin { diff --git a/e2e/e2etests/test_admin_transactions.go b/e2e/e2etests/test_admin_transactions.go index c091fd0789..3ad7002612 100644 --- a/e2e/e2etests/test_admin_transactions.go +++ b/e2e/e2etests/test_admin_transactions.go @@ -66,6 +66,7 @@ func TestUpdateGasPriceIncreaseFlags(r *runner.E2ERunner) { func TestAddToInboundTracker(r *runner.E2ERunner) { chainEth := chains.GoerliLocalnet chainBtc := chains.BitcoinRegtest + msgEth := crosschaintypes.NewMsgAddInboundTracker( r.ZetaTxServer.MustGetAccountAddressFromName(utils.EmergencyPolicyName), chainEth.ChainId, diff --git a/e2e/e2etests/test_precompiles_staking.go b/e2e/e2etests/test_precompiles_staking.go index 6b847d04c8..e665bd0571 100644 --- a/e2e/e2etests/test_precompiles_staking.go +++ b/e2e/e2etests/test_precompiles_staking.go @@ -29,6 +29,8 @@ func TestPrecompilesStaking(r *runner.E2ERunner, args []string) { require.NoError(r, err) require.GreaterOrEqual(r, len(validators), 2) + CleanValidatorDelegations(r, stakingContract, validators) + // shares are 0 for both validators at the start sharesBeforeVal1, err := stakingContract.GetShares(&bind.CallOpts{}, r.ZEVMAuth.From, validators[0].OperatorAddress) require.NoError(r, err) @@ -109,3 +111,24 @@ func TestPrecompilesStaking(r *runner.E2ERunner, args []string) { require.NoError(r, err) require.Equal(r, int64(1), delegationAfterVal2.DelegationResponse.Balance.Amount.Int64()) } + +// CleanValidatorDelegations unstakes all delegations from the given validators if delegations ar present +func CleanValidatorDelegations(r *runner.E2ERunner, stakingContract *staking.IStaking, validators []staking.Validator) { + for _, validator := range validators { + delegator := sdk.AccAddress(r.ZEVMAuth.From.Bytes()).String() + delegation, err := r.StakingClient.Delegation(r.Ctx, &types.QueryDelegationRequest{ + DelegatorAddr: delegator, + ValidatorAddr: validator.OperatorAddress, + }) + if err != nil || delegation.DelegationResponse == nil { + continue + } + + delegationAmount := delegation.DelegationResponse.Balance.Amount.Int64() + if delegationAmount > 0 && err == nil { + tx, err := stakingContract.Unstake(r.ZEVMAuth, r.ZEVMAuth.From, validator.OperatorAddress, big.NewInt(delegationAmount)) + require.NoError(r, err) + utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) + } + } +} From 41abe498a6500ab6683e868a64c1f27c16db8340 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 12 Sep 2024 16:57:43 -0400 Subject: [PATCH 2/5] add function to cleanup delegation --- Makefile | 1 + cmd/zetae2e/local/local.go | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 5f8c1fea15..11eed2b732 100644 --- a/Makefile +++ b/Makefile @@ -271,6 +271,7 @@ start-stress-test: zetanode start-tss-migration-test: zetanode @echo "--> Starting tss migration test" + export E2E_ARGS="--test-tss-migration" && \ export LOCALNET_MODE=tss-migrate && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index bbdaee0666..098d8dab5c 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -102,13 +102,13 @@ func localE2ETest(cmd *cobra.Command, _ []string) { light = must(cmd.Flags().GetBool(flagLight)) setupOnly = must(cmd.Flags().GetBool(flagSetupOnly)) skipSetup = must(cmd.Flags().GetBool(flagSkipSetup)) - //skipBitcoinSetup = must(cmd.Flags().GetBool(flagSkipBitcoinSetup)) - skipHeaderProof = must(cmd.Flags().GetBool(flagSkipHeaderProof)) - skipTrackerCheck = must(cmd.Flags().GetBool(flagSkipTrackerCheck)) - testTSSMigration = must(cmd.Flags().GetBool(flagTestTSSMigration)) - testV2 = must(cmd.Flags().GetBool(flagTestV2)) - testV2Migration = must(cmd.Flags().GetBool(flagTestV2Migration)) - skipPrecompiles = must(cmd.Flags().GetBool(flagSkipPrecompiles)) + skipBitcoinSetup = must(cmd.Flags().GetBool(flagSkipBitcoinSetup)) + skipHeaderProof = must(cmd.Flags().GetBool(flagSkipHeaderProof)) + skipTrackerCheck = must(cmd.Flags().GetBool(flagSkipTrackerCheck)) + testTSSMigration = must(cmd.Flags().GetBool(flagTestTSSMigration)) + testV2 = must(cmd.Flags().GetBool(flagTestV2)) + testV2Migration = must(cmd.Flags().GetBool(flagTestV2Migration)) + skipPrecompiles = must(cmd.Flags().GetBool(flagSkipPrecompiles)) ) logger := runner.NewLogger(verbose, color.FgWhite, "setup") @@ -325,11 +325,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) { } eg.Go(statefulPrecompilesTestRoutine(conf, deployerRunner, verbose, precompiledContractTests...)) - //eg.Go(erc20TestRoutine(conf, deployerRunner, verbose, erc20Tests...)) - //eg.Go(zetaTestRoutine(conf, deployerRunner, verbose, zetaTests...)) - //eg.Go(zevmMPTestRoutine(conf, deployerRunner, verbose, zevmMPTests...)) - //eg.Go(bitcoinTestRoutine(conf, deployerRunner, verbose, !skipBitcoinSetup, bitcoinTests...)) - //eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...)) + eg.Go(erc20TestRoutine(conf, deployerRunner, verbose, erc20Tests...)) + eg.Go(zetaTestRoutine(conf, deployerRunner, verbose, zetaTests...)) + eg.Go(zevmMPTestRoutine(conf, deployerRunner, verbose, zevmMPTests...)) + eg.Go(bitcoinTestRoutine(conf, deployerRunner, verbose, !skipBitcoinSetup, bitcoinTests...)) + eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...)) } if testAdmin { From 78428133ef7619d6eb36a7b6a867fc1156d8c696 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 12 Sep 2024 17:07:41 -0400 Subject: [PATCH 3/5] add changelog --- Makefile | 2 +- changelog.md | 3 ++- e2e/e2etests/test_admin_transactions.go | 1 - e2e/e2etests/test_precompiles_staking.go | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 11eed2b732..946c06df0a 100644 --- a/Makefile +++ b/Makefile @@ -271,8 +271,8 @@ start-stress-test: zetanode start-tss-migration-test: zetanode @echo "--> Starting tss migration test" - export E2E_ARGS="--test-tss-migration" && \ export LOCALNET_MODE=tss-migrate && \ + export E2E_ARGS="--test-tss-migration" && \ cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d start-solana-test: zetanode solana diff --git a/changelog.md b/changelog.md index 2d0edbe190..c908bcb608 100644 --- a/changelog.md +++ b/changelog.md @@ -34,7 +34,8 @@ * [2726](https://github.com/zeta-chain/node/pull/2726) - add e2e tests for deposit and call, deposit and revert * [2703](https://github.com/zeta-chain/node/pull/2703) - add e2e tests for stateful precompiled contracts * [2763](https://github.com/zeta-chain/node/pull/2763) - add V2 contracts migration test -* [2830] (https://github.com/zeta-chain/node/pull/2830) - extend staking precompile tests +* [2830](https://github.com/zeta-chain/node/pull/2830) - extend staking precompile tests +* [2874](https://github.com/zeta-chain/node/pull/2874/files) - add support for multiple runs for precompile tests ### Fixes diff --git a/e2e/e2etests/test_admin_transactions.go b/e2e/e2etests/test_admin_transactions.go index 3ad7002612..c091fd0789 100644 --- a/e2e/e2etests/test_admin_transactions.go +++ b/e2e/e2etests/test_admin_transactions.go @@ -66,7 +66,6 @@ func TestUpdateGasPriceIncreaseFlags(r *runner.E2ERunner) { func TestAddToInboundTracker(r *runner.E2ERunner) { chainEth := chains.GoerliLocalnet chainBtc := chains.BitcoinRegtest - msgEth := crosschaintypes.NewMsgAddInboundTracker( r.ZetaTxServer.MustGetAccountAddressFromName(utils.EmergencyPolicyName), chainEth.ChainId, diff --git a/e2e/e2etests/test_precompiles_staking.go b/e2e/e2etests/test_precompiles_staking.go index e665bd0571..7b1fc44e1c 100644 --- a/e2e/e2etests/test_precompiles_staking.go +++ b/e2e/e2etests/test_precompiles_staking.go @@ -126,7 +126,12 @@ func CleanValidatorDelegations(r *runner.E2ERunner, stakingContract *staking.ISt delegationAmount := delegation.DelegationResponse.Balance.Amount.Int64() if delegationAmount > 0 && err == nil { - tx, err := stakingContract.Unstake(r.ZEVMAuth, r.ZEVMAuth.From, validator.OperatorAddress, big.NewInt(delegationAmount)) + tx, err := stakingContract.Unstake( + r.ZEVMAuth, + r.ZEVMAuth.From, + validator.OperatorAddress, + big.NewInt(delegationAmount), + ) require.NoError(r, err) utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout) } From 695d22ea676e4ea1ae1eff388d258e91d6408379 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Fri, 13 Sep 2024 11:01:11 -0400 Subject: [PATCH 4/5] run precompiles after upgrade --- contrib/localnet/orchestrator/start-zetae2e.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index b26a1c7544..264a8918a7 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -259,9 +259,9 @@ if [ "$LOCALNET_MODE" == "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 local $E2E_ARGS --skip-setup --config deployed.yml --light --skip-precompiles ${COMMON_ARGS} + zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light ${COMMON_ARGS} else - zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-precompiles ${COMMON_ARGS} + zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --skip-bitcoin-setup --light ${COMMON_ARGS} fi ZETAE2E_EXIT_CODE=$? From 410185808f9047f6a15a6580719e57b32279147c Mon Sep 17 00:00:00 2001 From: Tanmay Date: Mon, 16 Sep 2024 11:39:13 +0530 Subject: [PATCH 5/5] Update changelog.md Co-authored-by: Lucas Bertrand --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 3be7201e57..40bdf92a49 100644 --- a/changelog.md +++ b/changelog.md @@ -36,7 +36,7 @@ * [2763](https://github.com/zeta-chain/node/pull/2763) - add V2 contracts migration test * [2830](https://github.com/zeta-chain/node/pull/2830) - extend staking precompile tests * [2867](https://github.com/zeta-chain/node/pull/2867) - skip precompiles test for tss migration -* [2874](https://github.com/zeta-chain/node/pull/2874/files) - add support for multiple runs for precompile tests +* [2874](https://github.com/zeta-chain/node/pull/2874) - add support for multiple runs for precompile tests ### Fixes