Skip to content

Commit

Permalink
rebase develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Aug 26, 2024
2 parents 23d26a7 + c3d1929 commit c4817fd
Show file tree
Hide file tree
Showing 37 changed files with 760 additions and 207 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature Request
about: Suggest an idea for this project
title: ''
labels: 'feature'
labels: 'feature:idea'
assignees: ''

---
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ 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' }}
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ start-stress-test: zetanode
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress -f docker-compose.yml up -d

start-tss-migration-test: zetanode
@echo "--> Starting migration test"
@echo "--> Starting tss migration test"
export LOCALNET_MODE=tss-migrate && \
export E2E_ARGS="--test-tss-migration" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d

Expand Down
2 changes: 1 addition & 1 deletion app/ante/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (ald AuthzLimiterDecorator) AnteHandle(
next sdk.AnteHandler,
) (newCtx sdk.Context, err error) {
if err := ald.checkDisabledMsgs(tx.GetMsgs(), false, 1); err != nil {
return ctx, errorsmod.Wrapf(errortypes.ErrUnauthorized, err.Error())
return ctx, errorsmod.Wrap(errortypes.ErrUnauthorized, err.Error())
}
return next(ctx, tx, simulate)
}
Expand Down
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
### Refactor

* [2615](https://github.com/zeta-chain/node/pull/2615) - Refactor cleanup of outbound trackers
* [2749](https://github.com/zeta-chain/node/pull/2749) - fix all lint errors from govet
* [2725](https://github.com/zeta-chain/node/pull/2725) - refactor SetCctxAndNonceToCctxAndInboundHashToCctx to receive tsspubkey as an argument

### Tests

* [2661](https://github.com/zeta-chain/node/pull/2661) - update connector and erc20Custody addresses in tss migration e2e tests
* [2726](https://github.com/zeta-chain/node/pull/2726) - add e2e tests for deposit and call, deposit and revert

### Fixes

* [2654](https://github.com/zeta-chain/node/pull/2654) - add validation for authorization list in when validating genesis state for authorization module
* [2674](https://github.com/zeta-chain/node/pull/2674) - allow operators to vote on ballots assosiated with discarded keygen without affecting the status of the current keygen.
* [2672](https://github.com/zeta-chain/node/pull/2672) - check observer set for duplicates when adding a new observer or updating an existing one

## v19.0.0
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func start(_ *cobra.Command, _ []string) error {
startLogger.Debug().Msgf("hotkeyPk %s", hotkeyPk.String())
if len(hotkeyPk.Bytes()) != 32 {
errMsg := fmt.Sprintf("key bytes len %d != 32", len(hotkeyPk.Bytes()))
log.Error().Msgf(errMsg)
log.Error().Msg(errMsg)
return errors.New(errMsg)
}
priKey := secp256k1.PrivKey(hotkeyPk.Bytes()[:32])
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ var VersionCmd = &cobra.Command{
}

func Version(_ *cobra.Command, _ []string) error {
fmt.Printf(constant.Version)
fmt.Print(constant.Version)
return nil
}
45 changes: 1 addition & 44 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"

zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
Expand Down Expand Up @@ -439,7 +438,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
logger.Print("✅ e2e tests completed in %s", time.Since(testStartTime).String())

if testTSSMigration {
runTSSMigrationTest(deployerRunner, logger, verbose, conf)
TSSMigration(deployerRunner, logger, verbose, conf)
}
// Verify that there are no trackers left over after tests complete
if !skipTrackerCheck {
Expand Down Expand Up @@ -496,48 +495,6 @@ func waitKeygenHeight(
}
}

func runTSSMigrationTest(deployerRunner *runner.E2ERunner, logger *runner.Logger, verbose bool, conf config.Config) {
migrationStartTime := time.Now()
logger.Print("🏁 starting tss migration")

response, err := deployerRunner.CctxClient.LastZetaHeight(
deployerRunner.Ctx,
&crosschaintypes.QueryLastZetaHeightRequest{},
)
require.NoError(deployerRunner, err)
err = deployerRunner.ZetaTxServer.UpdateKeygen(response.Height)
require.NoError(deployerRunner, err)

// Generate new TSS
waitKeygenHeight(deployerRunner.Ctx, deployerRunner.CctxClient, deployerRunner.ObserverClient, logger, 0)

// migration test is a blocking thread, we cannot run other tests in parallel
// The migration test migrates funds to a new TSS and then updates the TSS address on zetacore.
// The necessary restarts are done by the zetaclient supervisor
fn := migrationTestRoutine(conf, deployerRunner, verbose, e2etests.TestMigrateTSSName)

if err := fn(); err != nil {
logger.Print("❌ %v", err)
logger.Print("❌ tss migration failed")
os.Exit(1)
}

logger.Print("✅ migration completed in %s ", time.Since(migrationStartTime).String())
logger.Print("🏁 starting post migration tests")

tests := []string{
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestEtherWithdrawName,
}
fn = postMigrationTestRoutine(conf, deployerRunner, verbose, tests...)

if err := fn(); err != nil {
logger.Print("❌ %v", err)
logger.Print("❌ post migration tests failed")
os.Exit(1)
}
}

func must[T any](v T, err error) T {
return testutil.Must(v, err)
}
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/zeta-chain/zetacore/e2e/runner"
)

// migrationTestRoutine runs migration related e2e tests
func migrationTestRoutine(
// migrationRoutine runs migration related e2e tests
func migrationRoutine(
conf config.Config,
deployerRunner *runner.E2ERunner,
verbose bool,
Expand Down
58 changes: 0 additions & 58 deletions cmd/zetae2e/local/post_migration.go

This file was deleted.

43 changes: 43 additions & 0 deletions cmd/zetae2e/local/tss_migration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package local

import (
"os"
"time"

"github.com/stretchr/testify/require"

"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/e2etests"
"github.com/zeta-chain/zetacore/e2e/runner"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
)

func TSSMigration(deployerRunner *runner.E2ERunner, logger *runner.Logger, verbose bool, conf config.Config) {
migrationStartTime := time.Now()
logger.Print("🏁 starting tss migration")

response, err := deployerRunner.CctxClient.LastZetaHeight(
deployerRunner.Ctx,
&crosschaintypes.QueryLastZetaHeightRequest{},
)
require.NoError(deployerRunner, err)
err = deployerRunner.ZetaTxServer.UpdateKeygen(response.Height)
require.NoError(deployerRunner, err)

// Generate new TSS
waitKeygenHeight(deployerRunner.Ctx, deployerRunner.CctxClient, deployerRunner.ObserverClient, logger, 0)

// Run migration
// migrationRoutine runs migration e2e test , which migrates funds from the older TSS to the new one
// The zetaclient restarts required for this process are managed by the background workers in zetaclient (TSSListener)
fn := migrationRoutine(conf, deployerRunner, verbose, e2etests.TestMigrateTSSName)

if err := fn(); err != nil {
logger.Print("❌ %v", err)
logger.Print("❌ tss migration failed")
os.Exit(1)
}
deployerRunner.UpdateTssAddressForConnector()
deployerRunner.UpdateTssAddressForErc20custody()
logger.Print("✅ migration completed in %s ", time.Since(migrationStartTime).String())
}
42 changes: 40 additions & 2 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,45 @@ fi

### Run zetae2e command depending on the option passed

# Mode migrate is used to run the e2e tests before and after the TSS migration
# It runs the e2e tests with the migrate flag which triggers a TSS migration at the end of the tests. Once the migrationis done the first e2e test is complete
# The second e2e test is run after the migration to ensure the network is still working as expected with the new tss address
if [ "$LOCALNET_MODE" == "tss-migrate" ]; then
if [[ ! -f deployed.yml ]]; then
zetae2e local $E2E_ARGS --setup-only --config config.yml --config-out deployed.yml --skip-header-proof
if [ $? -ne 0 ]; then
echo "e2e setup failed"
exit 1
fi
else
echo "skipping e2e setup because it has already been completed"
fi

echo "running e2e test before migrating TSS"
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --skip-header-proof
if [ $? -ne 0 ]; then
echo "first e2e failed"
exit 1
fi

echo "waiting 10 seconds for node to restart"
sleep 10

zetae2e local --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-header-proof
ZETAE2E_EXIT_CODE=$?
if [ $ZETAE2E_EXIT_CODE -eq 0 ]; then
echo "E2E passed after migration"
exit 0
else
echo "E2E failed after migration"
exit 1
fi
fi


# Mode upgrade is used to run the e2e tests before and after the upgrade
# It runs the e2e tests , waits for the upgrade height to be reached, and then runs the e2e tests again once the ungrade is done.
# The second e2e test is run after the upgrade to ensure the network is still working as expected with the new version
if [ "$LOCALNET_MODE" == "upgrade" ]; then

# Run the e2e tests, then restart zetaclientd at upgrade height and run the e2e tests again
Expand Down Expand Up @@ -185,8 +224,7 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then
fi

else

# Run the e2e tests normally
# If no mode is passed, run the e2e tests normally
echo "running e2e setup..."

if [[ ! -f deployed.yml ]]; then
Expand Down
12 changes: 6 additions & 6 deletions e2e/e2etests/test_crosschain_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
)

func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
stop := r.MineBlocksIfLocalBitcoin()
defer stop()
r.ZEVMAuth.GasLimit = 10000000

// TODO: move into setup and skip it if already initialized
Expand All @@ -23,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")
}

txERC20ZRC20Approve, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18))
Expand Down Expand Up @@ -90,10 +92,6 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
_, err = r.GenerateToAddressIfLocalBitcoin(10, r.BTCDeployerAddress)
require.NoError(r, err)

// mine blocks if testing on regnet
stop := r.MineBlocksIfLocalBitcoin()
defer stop()

// cctx1 index acts like the inboundHash for the second cctx (the one that withdraws BTC)
cctx2 := utils.WaitCctxMinedByInboundHash(r.Ctx, cctx1.Index, r.CctxClient, r.Logger, r.CctxTimeout)

Expand Down Expand Up @@ -145,7 +143,9 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
r.Logger.Info("memo length %d", len(memo))

amount := 0.1
txid, err := r.SendToTSSFromDeployerWithMemo(amount, utxos[1:2], memo)
utxos, err = r.ListDeployerUTXOs()
require.NoError(r, err)
txid, err := r.SendToTSSFromDeployerWithMemo(amount, utxos[0:1], memo)
require.NoError(r, err)

cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, txid.String(), r.CctxClient, r.Logger, r.CctxTimeout)
Expand Down
3 changes: 1 addition & 2 deletions e2e/e2etests/test_message_passing_evm_to_zevm.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package e2etests

import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -56,7 +55,7 @@ func TestMessagePassingEVMtoZEVM(r *runner.E2ERunner, args []string) {
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout)
utils.RequireCCTXStatus(r, cctx, cctxtypes.CctxStatus_OutboundMined)

r.Logger.Info(fmt.Sprintf("🔄 Cctx mined for contract call chain zevm %s", cctx.Index))
r.Logger.Info("🔄 Cctx mined for contract call chain zevm %s", cctx.Index)

// On finalization the Fungible module calls the onReceive function which in turn calls the onZetaMessage function on the destination contract
receipt, err = r.ZEVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutboundParam().Hash))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func TestMessagePassingRevertFailExternalChains(r *runner.E2ERunner, args []stri
r.Logger.Info(" Zeta Value: %d", sentLog.ZetaValueAndGas)
}
}

// expect revert tx to fail
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, receipt.TxHash.String(), r.CctxClient, r.Logger, r.CctxTimeout)
receipt, err = r.EVMClient.TransactionReceipt(r.Ctx, ethcommon.HexToHash(cctx.GetCurrentOutboundParam().Hash))
Expand Down
Loading

0 comments on commit c4817fd

Please sign in to comment.