Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into refactor/zetacore-…
Browse files Browse the repository at this point in the history
…worker

# Conflicts:
#	changelog.md
  • Loading branch information
swift1337 committed Nov 12, 2024
2 parents d7965d3 + 1738618 commit 9c9d683
Show file tree
Hide file tree
Showing 57 changed files with 353 additions and 436 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
* [3124](https://github.com/zeta-chain/node/pull/3124) - integrate SPL deposits

### Tests

* [3075](https://github.com/zeta-chain/node/pull/3075) - ton: withdraw concurrent, deposit & revert.
* [3105](https://github.com/zeta-chain/node/pull/3105) - split Bitcoin E2E tests into two runners for deposit and withdraw

### Refactor
* [3118](https://github.com/zeta-chain/node/pull/3118) - zetaclient: remove hsm signer
* [3122](https://github.com/zeta-chain/node/pull/3122) - improve & refactor zetaclientd cli
* [3125](https://github.com/zeta-chain/node/pull/3125) - drop support for header proofs
* [3131](https://github.com/zeta-chain/node/pull/3131) - move app context update from zetacore client
* [3137](https://github.com/zeta-chain/node/pull/3137) - remove chain.Chain from zetaclientd config

### Fixes
* [3041](https://github.com/zeta-chain/node/pull/3041) - replace libp2p public DHT with private gossip peer discovery and connection gater for inbound connections
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Start(_ *cobra.Command, _ []string) error {
chains.Network_solana.String(): solanaKeyPass,
}

//Load Config file given path
// Load Config file given path
cfg, err := config.Load(globalOpts.ZetacoreHome)
if err != nil {
return err
Expand Down
3 changes: 0 additions & 3 deletions cmd/zetacored/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"os"

rosettaCmd "cosmossdk.io/tools/rosetta/cmd"
dbm "github.com/cometbft/cometbft-db"
tmcfg "github.com/cometbft/cometbft/config"
tmcli "github.com/cometbft/cometbft/libs/cli"
Expand Down Expand Up @@ -177,8 +176,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig types.EncodingConfig) {
if err := SetEthereumHDPath(rootCmd); err != nil {
fmt.Printf("warning: unable to set default HD path: %v\n", err)
}

rootCmd.AddCommand(rosettaCmd.RosettaCommand(encodingConfig.InterfaceRegistry, encodingConfig.Codec))
}

func addModuleInitFlags(startCmd *cobra.Command) {
Expand Down
9 changes: 3 additions & 6 deletions cmd/zetae2e/bitcoin_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,11 @@ func runBitcoinAddress(cmd *cobra.Command, args []string) error {
return err
}

addr, privKey, err := r.GetBtcAddress()
if err != nil {
return err
}
addr, privKey := r.GetBtcAddress()

logger.Print("* BTC address: %s", addr)
logger.Print("* BTC address: %s", addr.EncodeAddress())
if showPrivKey {
logger.Print("* BTC privkey: %s", privKey)
logger.Print("* BTC privkey: %s", privKey.String())
}

return nil
Expand Down
6 changes: 5 additions & 1 deletion cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ additional_accounts:
bech32_address: "zeta13t3zjxvwec7g38q8mdjga37rpes9zkfvv7tkn2"
evm_address: "0x8Ae229198eCE3c889C07DB648Ec7C30E6051592c"
private_key: "105460aebf71b10bfdb710ef5aa6d2932ee6ff6fc317ac9c24e0979903b10a5d"
user_bitcoin:
user_bitcoin_deposit:
bech32_address: "zeta19q7czqysah6qg0n4y3l2a08gfzqxydla492v80"
evm_address: "0x283d810090EdF4043E75247eAeBcE848806237fD"
private_key: "7bb523963ee2c78570fb6113d886a4184d42565e8847f1cb639f5f5e2ef5b37a"
user_bitcoin_withdraw:
bech32_address: "zeta17e77anpmzhuuam67hg6x3mtqrulqh80z9chv70"
evm_address: "0xf67deecc3B15F9CEeF5eba3468ed601f3e0B9de2"
private_key: "2b3306a8ac43dbf0e350b87876c131e7e12bd49563a16de9ce8aeb664b94d559"
user_solana:
bech32_address: "zeta1zqlajgj0qr8rqylf2c572t0ux8vqt45d4zngpm"
evm_address: "0x103FD9224F00ce3013e95629e52DFc31D805D68d"
Expand Down
6 changes: 5 additions & 1 deletion cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ additional_accounts:
bech32_address: "zeta13t3zjxvwec7g38q8mdjga37rpes9zkfvv7tkn2"
evm_address: "0x8Ae229198eCE3c889C07DB648Ec7C30E6051592c"
private_key: "105460aebf71b10bfdb710ef5aa6d2932ee6ff6fc317ac9c24e0979903b10a5d"
user_bitcoin:
user_bitcoin_deposit:
bech32_address: "zeta19q7czqysah6qg0n4y3l2a08gfzqxydla492v80"
evm_address: "0x283d810090EdF4043E75247eAeBcE848806237fD"
private_key: "7bb523963ee2c78570fb6113d886a4184d42565e8847f1cb639f5f5e2ef5b37a"
user_bitcoin_withdraw:
bech32_address: "zeta17e77anpmzhuuam67hg6x3mtqrulqh80z9chv70"
evm_address: "0xf67deecc3B15F9CEeF5eba3468ed601f3e0B9de2"
private_key: "2b3306a8ac43dbf0e350b87876c131e7e12bd49563a16de9ce8aeb664b94d559"
user_solana:
bech32_address: "zeta1zqlajgj0qr8rqylf2c572t0ux8vqt45d4zngpm"
evm_address: "0x103FD9224F00ce3013e95629e52DFc31D805D68d"
Expand Down
135 changes: 96 additions & 39 deletions cmd/zetae2e/local/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,128 @@ import (
"time"

"github.com/fatih/color"
"github.com/stretchr/testify/require"

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

// bitcoinTestRoutine runs Bitcoin related e2e tests
func bitcoinTestRoutine(
// initBitcoinTestRunners initializes Bitcoin deposit and withdraw test runners
func initBitcoinTestRunners(
conf config.Config,
deployerRunner *runner.E2ERunner,
verbose bool,
initBitcoinNetwork bool,
testNames ...string,
) func() error {
return func() (err error) {
account := conf.AdditionalAccounts.UserBitcoin
// initialize runner for bitcoin test
bitcoinRunner, err := initTestRunner(
"bitcoin",
conf,
deployerRunner,
account,
runner.NewLogger(verbose, color.FgYellow, "bitcoin"),
)
if err != nil {
return err
}
initNetwork bool,
depositTests []string,
withdrawTests []string,
) (func() error, func() error) {
// initialize runner for deposit tests
// deposit tests need Bitcoin node wallet to handle UTXOs
account := conf.AdditionalAccounts.UserBitcoinDeposit
runnerDeposit := initBitcoinRunner(
"btc_deposit",
account,
conf,
deployerRunner,
color.FgYellow,
verbose,
initNetwork,
true,
)

bitcoinRunner.Logger.Print("🏃 starting Bitcoin tests")
startTime := time.Now()
// initialize runner for withdraw tests
// withdraw tests DON'T use Bitcoin node wallet
account = conf.AdditionalAccounts.UserBitcoinWithdraw
runnerWithdraw := initBitcoinRunner(
"btc_withdraw",
account,
conf,
deployerRunner,
color.FgHiYellow,
verbose,
initNetwork,
false,
)

// initialize funds
// send BTC to TSS for gas fees and to tester ZEVM address
if initNetwork {
// mine 101 blocks to ensure the BTC rewards are spendable
// Note: the block rewards can be sent to any address in here
_, err := runnerDeposit.GenerateToAddressIfLocalBitcoin(101, runnerDeposit.BTCDeployerAddress)
require.NoError(runnerDeposit, err)

// funding the account
// send BTC to ZEVM addresses
runnerDeposit.DepositBTC(runnerDeposit.EVMAddress())
runnerDeposit.DepositBTC(runnerWithdraw.EVMAddress())
}

// create test routines
routineDeposit := createBitcoinTestRoutine(runnerDeposit, depositTests)
routineWithdraw := createBitcoinTestRoutine(runnerWithdraw, withdrawTests)

return routineDeposit, routineWithdraw
}

// initBitcoinRunner initializes the Bitcoin runner for given test name and account
func initBitcoinRunner(
name string,
account config.Account,
conf config.Config,
deployerRunner *runner.E2ERunner,
printColor color.Attribute,
verbose, initNetwork, createWallet bool,
) *runner.E2ERunner {
// initialize runner for bitcoin test
runner, err := initTestRunner(name, conf, deployerRunner, account, runner.NewLogger(verbose, printColor, name))
testutil.NoError(err)

// setup TSS address and setup deployer wallet
runner.SetupBitcoinAccounts(createWallet)

// initialize funds
if initNetwork {
// send some BTC block rewards to the deployer address
_, err = runner.GenerateToAddressIfLocalBitcoin(4, runner.BTCDeployerAddress)
require.NoError(runner, err)

// send ERC20 token on EVM
txERC20Send := deployerRunner.SendERC20OnEvm(account.EVMAddress(), 1000)
bitcoinRunner.WaitForTxReceiptOnEvm(txERC20Send)
runner.WaitForTxReceiptOnEvm(txERC20Send)

// depositing the necessary tokens on ZetaChain
txEtherDeposit := bitcoinRunner.DepositEther()
txERC20Deposit := bitcoinRunner.DepositERC20()
// deposit ETH and ERC20 tokens on ZetaChain
txEtherDeposit := runner.DepositEther()
txERC20Deposit := runner.DepositERC20()

bitcoinRunner.WaitForMinedCCTX(txEtherDeposit)
bitcoinRunner.WaitForMinedCCTX(txERC20Deposit)
runner.WaitForMinedCCTX(txEtherDeposit)
runner.WaitForMinedCCTX(txERC20Deposit)
}

bitcoinRunner.SetupBitcoinAccount(initBitcoinNetwork)
bitcoinRunner.DepositBTC()
return runner
}

// run bitcoin test
// Note: due to the extensive block generation in Bitcoin localnet, block header test is run first
// to make it faster to catch up with the latest block header
testsToRun, err := bitcoinRunner.GetE2ETestsToRunByName(
// createBitcoinTestRoutine creates a test routine for given test names
func createBitcoinTestRoutine(r *runner.E2ERunner, testNames []string) func() error {
return func() (err error) {
r.Logger.Print("🏃 starting bitcoin tests")
startTime := time.Now()

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

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

if err := bitcoinRunner.CheckBtcTSSBalance(); err != nil {
return err
}

bitcoinRunner.Logger.Print("🍾 Bitcoin tests completed in %s", time.Since(startTime).String())
r.Logger.Print("🍾 bitcoin tests completed in %s", time.Since(startTime).String())

return err
}
Expand Down
41 changes: 30 additions & 11 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
)
noError(err)

// monitor block production to ensure we fail fast if there are consensus failures
// this is not run in an errgroup since only returning an error will not exit immedately
// this needs to be early to quickly detect consensus failure during genesis
go monitorBlockProductionExit(ctx, conf)

// set the authority client to the zeta tx server to be able to query message permissions
deployerRunner.ZetaTxServer.SetAuthorityClient(deployerRunner.AuthorityClient)

Expand All @@ -190,10 +195,6 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
noError(deployerRunner.FundEmissionsPool())
}

// monitor block production to ensure we fail fast if there are consensus failures
// this is not run in an errgroup since only returning an error will not exit immedately
go monitorBlockProductionExit(ctx, conf)

// wait for keygen to be completed
// if setup is skipped, we assume that the keygen is already completed
if !skipSetup {
Expand Down Expand Up @@ -313,27 +314,31 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestMessagePassingEVMtoZEVMRevertFailName,
}

bitcoinTests := []string{
// btc withdraw tests are those that need a Bitcoin node wallet to send UTXOs
bitcoinDepositTests := []string{
e2etests.TestBitcoinDonationName,
e2etests.TestBitcoinDepositName,
e2etests.TestBitcoinDepositAndCallName,
e2etests.TestBitcoinDepositAndCallRevertName,
e2etests.TestBitcoinDepositAndCallRevertWithDustName,
e2etests.TestBitcoinStdMemoDepositName,
e2etests.TestBitcoinStdMemoDepositAndCallName,
e2etests.TestBitcoinStdMemoDepositAndCallRevertName,
e2etests.TestBitcoinStdMemoDepositAndCallRevertOtherAddressName,
e2etests.TestBitcoinStdMemoInscribedDepositAndCallName,
e2etests.TestCrosschainSwapName,
}
bitcoinWithdrawTests := []string{
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestBitcoinWithdrawInvalidAddressName,
e2etests.TestZetaWithdrawBTCRevertName,
e2etests.TestCrosschainSwapName,
}
bitcoinAdvancedTests := []string{
bitcoinWithdrawTestsAdvanced := []string{
e2etests.TestBitcoinWithdrawTaprootName,
e2etests.TestBitcoinWithdrawLegacyName,
e2etests.TestBitcoinWithdrawMultipleName,
e2etests.TestBitcoinWithdrawP2SHName,
e2etests.TestBitcoinWithdrawP2WSHName,
e2etests.TestBitcoinWithdrawMultipleName,
e2etests.TestBitcoinWithdrawRestrictedName,
}
ethereumTests := []string{
Expand Down Expand Up @@ -367,15 +372,24 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
erc20Tests = append(erc20Tests, erc20AdvancedTests...)
zetaTests = append(zetaTests, zetaAdvancedTests...)
zevmMPTests = append(zevmMPTests, zevmMPAdvancedTests...)
bitcoinTests = append(bitcoinTests, bitcoinAdvancedTests...)
bitcoinWithdrawTests = append(bitcoinWithdrawTests, bitcoinWithdrawTestsAdvanced...)
ethereumTests = append(ethereumTests, ethereumAdvancedTests...)
}

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...))
runnerDeposit, runnerWithdraw := initBitcoinTestRunners(
conf,
deployerRunner,
verbose,
!skipBitcoinSetup,
bitcoinDepositTests,
bitcoinWithdrawTests,
)
eg.Go(runnerDeposit)
eg.Go(runnerWithdraw)
eg.Go(ethereumTestRoutine(conf, deployerRunner, verbose, ethereumTests...))
}

Expand Down Expand Up @@ -470,7 +484,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
}

// if all tests pass, cancel txs priority monitoring and check if tx priority is not correct in some blocks
logger.Print("⏳ e2e tests passed,checking tx priority")
logger.Print("⏳ e2e tests passed, checking tx priority")
monitorPriorityCancel()
if err := <-txPriorityErrCh; err != nil && errors.Is(err, errWrongTxPriority) {
logger.Print("❌ %v", err)
Expand All @@ -483,10 +497,15 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
if testTSSMigration {
TSSMigration(deployerRunner, logger, verbose, conf)
}

// Verify that there are no trackers left over after tests complete
if !skipTrackerCheck {
deployerRunner.EnsureNoTrackers()
}

// Verify that the balance of restricted address is zero
deployerRunner.EnsureZeroBalanceOnRestrictedAddressZEVM()

// print and validate report
networkReport, err := deployerRunner.GenerateNetworkReport()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/setup_bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func runSetupBitcoin(_ *cobra.Command, args []string) error {
return err
}

r.SetupBitcoinAccount(true)
r.SetupBitcoinAccounts(true)

logger.Print("* BTC setup done")

Expand Down
Loading

0 comments on commit 9c9d683

Please sign in to comment.