diff --git a/changelog.md b/changelog.md index f5eafa5b5f..cd1cf3c5c5 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index e1a5b6315f..46d204fa34 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -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 diff --git a/cmd/zetacored/root.go b/cmd/zetacored/root.go index 3880b12108..93ae4ba469 100644 --- a/cmd/zetacored/root.go +++ b/cmd/zetacored/root.go @@ -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" @@ -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) { diff --git a/cmd/zetae2e/bitcoin_address.go b/cmd/zetae2e/bitcoin_address.go index 70d64ab582..be1251d1d2 100644 --- a/cmd/zetae2e/bitcoin_address.go +++ b/cmd/zetae2e/bitcoin_address.go @@ -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 diff --git a/cmd/zetae2e/config/local.yml b/cmd/zetae2e/config/local.yml index 2481ab31fa..5cc87be394 100644 --- a/cmd/zetae2e/config/local.yml +++ b/cmd/zetae2e/config/local.yml @@ -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" diff --git a/cmd/zetae2e/config/localnet.yml b/cmd/zetae2e/config/localnet.yml index 5bd207a020..24e51223ef 100644 --- a/cmd/zetae2e/config/localnet.yml +++ b/cmd/zetae2e/config/localnet.yml @@ -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" diff --git a/cmd/zetae2e/local/bitcoin.go b/cmd/zetae2e/local/bitcoin.go index f28f182877..900c9c3792 100644 --- a/cmd/zetae2e/local/bitcoin.go +++ b/cmd/zetae2e/local/bitcoin.go @@ -5,55 +5,116 @@ 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..., ) @@ -61,15 +122,11 @@ func bitcoinTestRoutine( 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 } diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 9b818ea8c0..a170929cbb 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -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) @@ -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 { @@ -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{ @@ -367,7 +372,7 @@ 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...) } @@ -375,7 +380,16 @@ func localE2ETest(cmd *cobra.Command, _ []string) { 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...)) } @@ -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) @@ -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 { diff --git a/cmd/zetae2e/setup_bitcoin.go b/cmd/zetae2e/setup_bitcoin.go index 622855a027..a51d8880b0 100644 --- a/cmd/zetae2e/setup_bitcoin.go +++ b/cmd/zetae2e/setup_bitcoin.go @@ -58,7 +58,7 @@ func runSetupBitcoin(_ *cobra.Command, args []string) error { return err } - r.SetupBitcoinAccount(true) + r.SetupBitcoinAccounts(true) logger.Print("* BTC setup done") diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index 670befa7b6..e0078230e7 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -5,7 +5,6 @@ # - An Ethereum node (eth) # - A secondary optional Ethereum node (eth2) enabled when profile is set to eth2 # - A Bitcoin node (bitcoin) -# - A Rosetta API (rosetta) # - An orchestrator to manage interaction with the localnet (orchestrator) # - An upgrade host to serve binaries for the upgrade tests (upgrade-host). Only enabled when profile is set to upgrade. # - An upgrade orchestrator to send the upgrade governance proposal (upgrade-orchestrator). Only enabled when profile is set to upgrade. @@ -19,22 +18,6 @@ networks: - subnet: 172.20.0.0/24 services: - rosetta: - image: zetanode:latest - container_name: rosetta - hostname: rosetta - depends_on: - zetacore0: - condition: service_healthy - ports: - - "8080:8080" - networks: - mynetwork: - ipv4_address: 172.20.0.200 - entrypoint: ["zetacored", "rosetta", "--tendermint", "zetacore0:26657", "--grpc", "zetacore0:9090", "--network", "athens_101-1", "--blockchain", "zetacore"] - volumes: - - ssh:/root/.ssh - zetacore0: image: zetanode:latest container_name: zetacore0 diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index 33f0d4e956..5d8c9c5586 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -98,8 +98,11 @@ fund_eth_from_config '.additional_accounts.user_zeta_test.evm_address' 10000 "ze # unlock zevm message passing tester accounts fund_eth_from_config '.additional_accounts.user_zevm_mp_test.evm_address' 10000 "zevm mp tester" -# unlock bitcoin tester accounts -fund_eth_from_config '.additional_accounts.user_bitcoin.evm_address' 10000 "bitcoin tester" +# unlock bitcoin deposit tester accounts +fund_eth_from_config '.additional_accounts.user_bitcoin_deposit.evm_address' 10000 "bitcoin deposit tester" + +# unlock bitcoin withdraw tester accounts +fund_eth_from_config '.additional_accounts.user_bitcoin_withdraw.evm_address' 10000 "bitcoin withdraw tester" # unlock solana tester accounts fund_eth_from_config '.additional_accounts.user_solana.evm_address' 10000 "solana tester" diff --git a/contrib/localnet/scripts/start-rosetta.sh b/contrib/localnet/scripts/start-rosetta.sh deleted file mode 100644 index e675da6a6a..0000000000 --- a/contrib/localnet/scripts/start-rosetta.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# This script is used to start the Rosetta API server for the Zetacore network. - -echo "Waiting for network to start producing blocks" -CURRENT_HEIGHT=0 -WAIT_HEIGHT=1 -while [[ $CURRENT_HEIGHT -lt $WAIT_HEIGHT ]] -do - CURRENT_HEIGHT=$(curl -s zetacore0:26657/status | jq '.result.sync_info.latest_block_height' | tr -d '"') - sleep 5 -done - -zetacored rosetta --tendermint zetacore0:26657 --grpc zetacore0:9090 --network athens_101-1 --blockchain zetacore \ No newline at end of file diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index c0e8424738..38047a6b46 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -242,8 +242,11 @@ then # zeta tester address=$(yq -r '.additional_accounts.user_zeta_test.bech32_address' /root/config.yml) zetacored add-genesis-account "$address" 100000000000000000000000000azeta -# bitcoin tester - address=$(yq -r '.additional_accounts.user_bitcoin.bech32_address' /root/config.yml) +# bitcoin deposit tester + address=$(yq -r '.additional_accounts.user_bitcoin_deposit.bech32_address' /root/config.yml) + zetacored add-genesis-account "$address" 100000000000000000000000000azeta +# bitcoin withdraw tester + address=$(yq -r '.additional_accounts.user_bitcoin_withdraw.bech32_address' /root/config.yml) zetacored add-genesis-account "$address" 100000000000000000000000000azeta # solana tester address=$(yq -r '.additional_accounts.user_solana.bech32_address' /root/config.yml) diff --git a/contrib/localnet/zetacored/common/app.toml b/contrib/localnet/zetacored/common/app.toml index 7bbf48cf96..adee8fb76c 100644 --- a/contrib/localnet/zetacored/common/app.toml +++ b/contrib/localnet/zetacored/common/app.toml @@ -136,26 +136,6 @@ enabled-unsafe-cors = true ### Rosetta Configuration ### ############################################################################### -[rosetta] - -# Enable defines if the Rosetta API server should be enabled. -enable = false - -# Address defines the Rosetta API server to listen on. -address = ":8080" - -# Network defines the name of the blockchain that will be returned by Rosetta. -blockchain = "app" - -# Network defines the name of the network that will be returned by Rosetta. -network = "network" - -# Retries defines the number of retries when connecting to the node before failing. -retries = 3 - -# Offline defines if Rosetta server should run in offline mode. -offline = false - ############################################################################### ### gRPC Configuration ### ############################################################################### diff --git a/docs/cli/zetacored/cli.md b/docs/cli/zetacored/cli.md index 36440f2704..d7a594d94f 100644 --- a/docs/cli/zetacored/cli.md +++ b/docs/cli/zetacored/cli.md @@ -33,7 +33,6 @@ Zetacore Daemon (server) * [zetacored parse-genesis-file](#zetacored-parse-genesis-file) - Parse the provided genesis file and import the required data into the optionally provided genesis file * [zetacored query](#zetacored-query) - Querying subcommands * [zetacored rollback](#zetacored-rollback) - rollback cosmos-sdk and tendermint state by one height -* [zetacored rosetta](#zetacored-rosetta) - spin up a rosetta server * [zetacored snapshots](#zetacored-snapshots) - Manage local snapshots * [zetacored start](#zetacored-start) - Run the full node * [zetacored status](#zetacored-status) - Query remote node for status @@ -7363,45 +7362,6 @@ zetacored rollback [flags] * [zetacored](#zetacored) - Zetacore Daemon (server) -## zetacored rosetta - -spin up a rosetta server - -``` -zetacored rosetta [flags] -``` - -### Options - -``` - --addr string the address rosetta will bind to - --blockchain string the blockchain type - --denom-to-suggest string default denom for fee suggestion - --enable-fee-suggestion enable default fee suggestion - --gas-to-suggest int default gas for fee suggestion (default 200000) - --grpc string the app gRPC endpoint - -h, --help help for rosetta - --network string the network name - --offline run rosetta only with construction API - --prices-to-suggest string default prices for fee suggestion - --retries int the number of retries that will be done before quitting (default 5) - --tendermint string the tendermint rpc endpoint, without tcp:// -``` - -### Options inherited from parent commands - -``` - --home string directory for config and data - --log_format string The logging format (json|plain) - --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) - --log_no_color Disable colored logs - --trace print out full stack trace on errors -``` - -### SEE ALSO - -* [zetacored](#zetacored) - Zetacore Daemon (server) - ## zetacored snapshots Manage local snapshots diff --git a/e2e/config/config.go b/e2e/config/config.go index 15ca4a1f2c..33a8c2bea8 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -61,20 +61,21 @@ type Account struct { // AdditionalAccounts are extra accounts required to run specific tests type AdditionalAccounts struct { - UserERC20 Account `yaml:"user_erc20"` - UserZetaTest Account `yaml:"user_zeta_test"` - UserZEVMMPTest Account `yaml:"user_zevm_mp_test"` - UserBitcoin Account `yaml:"user_bitcoin"` - UserSolana Account `yaml:"user_solana"` - UserEther Account `yaml:"user_ether"` - UserMisc Account `yaml:"user_misc"` - UserAdmin Account `yaml:"user_admin"` - UserMigration Account `yaml:"user_migration"` // used for TSS migration, TODO: rename (https://github.com/zeta-chain/node/issues/2780) - UserPrecompile Account `yaml:"user_precompile"` - UserV2Ether Account `yaml:"user_v2_ether"` - UserV2ERC20 Account `yaml:"user_v2_erc20"` - UserV2EtherRevert Account `yaml:"user_v2_ether_revert"` - UserV2ERC20Revert Account `yaml:"user_v2_erc20_revert"` + UserERC20 Account `yaml:"user_erc20"` + UserZetaTest Account `yaml:"user_zeta_test"` + UserZEVMMPTest Account `yaml:"user_zevm_mp_test"` + UserBitcoinDeposit Account `yaml:"user_bitcoin_deposit"` + UserBitcoinWithdraw Account `yaml:"user_bitcoin_withdraw"` + UserSolana Account `yaml:"user_solana"` + UserEther Account `yaml:"user_ether"` + UserMisc Account `yaml:"user_misc"` + UserAdmin Account `yaml:"user_admin"` + UserMigration Account `yaml:"user_migration"` // used for TSS migration, TODO: rename (https://github.com/zeta-chain/node/issues/2780) + UserPrecompile Account `yaml:"user_precompile"` + UserV2Ether Account `yaml:"user_v2_ether"` + UserV2ERC20 Account `yaml:"user_v2_erc20"` + UserV2EtherRevert Account `yaml:"user_v2_ether_revert"` + UserV2ERC20Revert Account `yaml:"user_v2_erc20_revert"` } type PolicyAccounts struct { @@ -235,7 +236,8 @@ func (a AdditionalAccounts) AsSlice() []Account { a.UserERC20, a.UserZetaTest, a.UserZEVMMPTest, - a.UserBitcoin, + a.UserBitcoinDeposit, + a.UserBitcoinWithdraw, a.UserSolana, a.UserEther, a.UserMisc, @@ -314,7 +316,11 @@ func (c *Config) GenerateKeys() error { if err != nil { return err } - c.AdditionalAccounts.UserBitcoin, err = generateAccount() + c.AdditionalAccounts.UserBitcoinDeposit, err = generateAccount() + if err != nil { + return err + } + c.AdditionalAccounts.UserBitcoinWithdraw, err = generateAccount() if err != nil { return err } diff --git a/e2e/e2etests/e2etests.go b/e2e/e2etests/e2etests.go index a880172830..3b5ef2ed00 100644 --- a/e2e/e2etests/e2etests.go +++ b/e2e/e2etests/e2etests.go @@ -80,6 +80,7 @@ const ( TestBitcoinDepositName = "bitcoin_deposit" TestBitcoinDepositAndCallName = "bitcoin_deposit_and_call" TestBitcoinDepositAndCallRevertName = "bitcoin_deposit_and_call_revert" + TestBitcoinDepositAndCallRevertWithDustName = "bitcoin_deposit_and_call_revert_with_dust" TestBitcoinDonationName = "bitcoin_donation" TestBitcoinStdMemoDepositName = "bitcoin_std_memo_deposit" TestBitcoinStdMemoDepositAndCallName = "bitcoin_std_memo_deposit_and_call" @@ -555,6 +556,11 @@ var AllE2ETests = []runner.E2ETest{ }, TestBitcoinDepositAndCallRevert, ), + runner.NewE2ETest( + TestBitcoinDepositAndCallRevertWithDustName, + "deposit Bitcoin into ZEVM; revert with dust amount that aborts the CCTX", []runner.ArgDefinition{}, + TestBitcoinDepositAndCallRevertWithDust, + ), runner.NewE2ETest( TestBitcoinStdMemoDepositName, "deposit Bitcoin into ZEVM with standard memo", diff --git a/e2e/e2etests/test_bitcoin_deposit.go b/e2e/e2etests/test_bitcoin_deposit.go index 590a5c81d8..59df40f9b6 100644 --- a/e2e/e2etests/test_bitcoin_deposit.go +++ b/e2e/e2etests/test_bitcoin_deposit.go @@ -13,8 +13,6 @@ func TestBitcoinDeposit(r *runner.E2ERunner, args []string) { depositAmount := parseFloat(r, args[0]) - r.SetBtcAddress(r.Name, false) - txHash := r.DepositBTCWithAmount(depositAmount, nil) // wait for the cctx to be mined diff --git a/e2e/e2etests/test_bitcoin_deposit_and_call_revert.go b/e2e/e2etests/test_bitcoin_deposit_and_call_revert.go index eed10485bf..0c0e45c77f 100644 --- a/e2e/e2etests/test_bitcoin_deposit_and_call_revert.go +++ b/e2e/e2etests/test_bitcoin_deposit_and_call_revert.go @@ -11,10 +11,6 @@ import ( ) func TestBitcoinDepositAndCallRevert(r *runner.E2ERunner, args []string) { - // ARRANGE - // Given BTC address - r.SetBtcAddress(r.Name, false) - // Given "Live" BTC network stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go b/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go new file mode 100644 index 0000000000..1dec399a9b --- /dev/null +++ b/e2e/e2etests/test_bitcoin_deposit_and_call_revert_with_dust.go @@ -0,0 +1,53 @@ +package e2etests + +import ( + "github.com/stretchr/testify/require" + + "github.com/zeta-chain/node/e2e/runner" + "github.com/zeta-chain/node/e2e/utils" + "github.com/zeta-chain/node/pkg/constant" + "github.com/zeta-chain/node/testutil/sample" + crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" + zetabitcoin "github.com/zeta-chain/node/zetaclient/chains/bitcoin" +) + +// TestBitcoinDepositAndCallRevertWithDust sends a Bitcoin deposit that reverts with a dust amount in the revert outbound. +func TestBitcoinDepositAndCallRevertWithDust(r *runner.E2ERunner, args []string) { + // Given "Live" BTC network + stop := r.MineBlocksIfLocalBitcoin() + defer stop() + + require.Len(r, args, 0) + + // 0.002 BTC is consumed in a deposit and revert, the dust is set to 1000 satoshis in the protocol + // Therefore the deposit amount should be 0.002 + 0.000001 = 0.00200100 should trigger the condition + // As only 100 satoshis are left after the deposit + const ( + // depositAmount is 0.002001 BTC, chosen to result in 100 satoshis after deposit + // which is below the dust threshold of 1000 satoshis + depositAmount = 0.00200100 + ) + amount := depositAmount + zetabitcoin.DefaultDepositorFee + + // Given a list of UTXOs + utxos, err := r.ListDeployerUTXOs() + require.NoError(r, err) + require.NotEmpty(r, utxos) + + // ACT + // Send BTC to TSS address with a dummy memo + // zetacore should revert cctx if call is made on a non-existing address + nonExistReceiver := sample.EthAddress() + badMemo := append(nonExistReceiver.Bytes(), []byte("gibberish-memo")...) + txHash, err := r.SendToTSSFromDeployerWithMemo(amount, utxos, badMemo) + require.NoError(r, err) + require.NotEmpty(r, txHash) + + // wait for the cctx to be mined + cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, txHash.String(), r.CctxClient, r.Logger, r.CctxTimeout) + r.Logger.CCTX(*cctx, "deposit_and_revert") + utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Reverted) + + // check the test was effective: the revert outbound amount is less than the dust amount + require.Less(r, cctx.GetCurrentOutboundParam().Amount.Uint64(), uint64(constant.BTCWithdrawalDustAmount)) +} diff --git a/e2e/e2etests/test_bitcoin_deposit_call.go b/e2e/e2etests/test_bitcoin_deposit_call.go index d3d6917c59..0ddbcb0b27 100644 --- a/e2e/e2etests/test_bitcoin_deposit_call.go +++ b/e2e/e2etests/test_bitcoin_deposit_call.go @@ -13,10 +13,6 @@ import ( ) func TestBitcoinDepositAndCall(r *runner.E2ERunner, args []string) { - // ARRANGE - // Given BTC address - r.SetBtcAddress(r.Name, false) - // Given "Live" BTC network stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_bitcoin_donation.go b/e2e/e2etests/test_bitcoin_donation.go index 1dd5a34859..91b39ebff3 100644 --- a/e2e/e2etests/test_bitcoin_donation.go +++ b/e2e/e2etests/test_bitcoin_donation.go @@ -12,10 +12,6 @@ import ( ) func TestBitcoinDonation(r *runner.E2ERunner, args []string) { - // ARRANGE - // Given BTC address - r.SetBtcAddress(r.Name, false) - // Given "Live" BTC network stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_bitcoin_std_deposit.go b/e2e/e2etests/test_bitcoin_std_deposit.go index e90b23d64a..b822487f21 100644 --- a/e2e/e2etests/test_bitcoin_std_deposit.go +++ b/e2e/e2etests/test_bitcoin_std_deposit.go @@ -14,9 +14,6 @@ import ( ) func TestBitcoinStdMemoDeposit(r *runner.E2ERunner, args []string) { - // setup deployer BTC address - r.SetBtcAddress(r.Name, false) - // start mining blocks if local bitcoin stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_bitcoin_std_deposit_and_call.go b/e2e/e2etests/test_bitcoin_std_deposit_and_call.go index 7a9c6ca255..2cdd7caa3d 100644 --- a/e2e/e2etests/test_bitcoin_std_deposit_and_call.go +++ b/e2e/e2etests/test_bitcoin_std_deposit_and_call.go @@ -14,9 +14,6 @@ import ( ) func TestBitcoinStdMemoDepositAndCall(r *runner.E2ERunner, args []string) { - // setup deployer BTC address - r.SetBtcAddress(r.Name, false) - // start mining blocks if local bitcoin stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert.go b/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert.go index 76bf128aad..96b4186d8f 100644 --- a/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert.go +++ b/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert.go @@ -11,10 +11,6 @@ import ( ) func TestBitcoinStdMemoDepositAndCallRevert(r *runner.E2ERunner, args []string) { - // ARRANGE - // Given BTC address - r.SetBtcAddress(r.Name, false) - // Start mining blocks stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go b/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go index c6da1b1696..8ecb3b0d5f 100644 --- a/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go +++ b/e2e/e2etests/test_bitcoin_std_deposit_and_call_revert_other_address.go @@ -12,10 +12,6 @@ import ( ) func TestBitcoinStdMemoDepositAndCallRevertOtherAddress(r *runner.E2ERunner, args []string) { - // ARRANGE - // Given BTC address - r.SetBtcAddress(r.Name, false) - // Start mining blocks stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_bitcoin_std_memo_inscribed_deposit_and_call.go b/e2e/e2etests/test_bitcoin_std_memo_inscribed_deposit_and_call.go index c9a5d7af31..df23ae8383 100644 --- a/e2e/e2etests/test_bitcoin_std_memo_inscribed_deposit_and_call.go +++ b/e2e/e2etests/test_bitcoin_std_memo_inscribed_deposit_and_call.go @@ -14,10 +14,6 @@ import ( ) func TestBitcoinStdMemoInscribedDepositAndCall(r *runner.E2ERunner, args []string) { - // ARRANGE - // Given BTC address - r.SetBtcAddress(r.Name, false) - // Start mining blocks stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_bitcoin_withdraw_invalid_address.go b/e2e/e2etests/test_bitcoin_withdraw_invalid_address.go index 5c7254a3a1..aae4b4a446 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_invalid_address.go +++ b/e2e/e2etests/test_bitcoin_withdraw_invalid_address.go @@ -15,8 +15,6 @@ func TestBitcoinWithdrawToInvalidAddress(r *runner.E2ERunner, args []string) { withdrawalAmount := parseFloat(r, args[0]) amount := btcAmountFromFloat64(r, withdrawalAmount) - r.SetBtcAddress(r.Name, false) - withdrawToInvalidAddress(r, amount) } diff --git a/e2e/e2etests/test_bitcoin_withdraw_legacy.go b/e2e/e2etests/test_bitcoin_withdraw_legacy.go index 091bb63531..ba33c8b24d 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_legacy.go +++ b/e2e/e2etests/test_bitcoin_withdraw_legacy.go @@ -11,8 +11,6 @@ func TestBitcoinWithdrawLegacy(r *runner.E2ERunner, args []string) { // check length of arguments require.Len(r, args, 2) - r.SetBtcAddress(r.Name, false) - // parse arguments and withdraw BTC receiver, amount := parseBitcoinWithdrawArgs(r, args, defaultReceiver) diff --git a/e2e/e2etests/test_bitcoin_withdraw_multiple.go b/e2e/e2etests/test_bitcoin_withdraw_multiple.go index 09d77fde80..642f1d49dd 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_multiple.go +++ b/e2e/e2etests/test_bitcoin_withdraw_multiple.go @@ -18,9 +18,6 @@ func WithdrawBitcoinMultipleTimes(r *runner.E2ERunner, args []string) { times = parseInt(r, args[1]) ) - // Given BTC address set - r.SetBtcAddress(r.Name, false) - // Given a receiver receiver, err := chains.DecodeBtcAddress(defaultReceiver, r.GetBitcoinChainID()) require.NoError(r, err) diff --git a/e2e/e2etests/test_bitcoin_withdraw_p2sh.go b/e2e/e2etests/test_bitcoin_withdraw_p2sh.go index 248ce14ec5..e3eda5f9d5 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_p2sh.go +++ b/e2e/e2etests/test_bitcoin_withdraw_p2sh.go @@ -11,8 +11,6 @@ func TestBitcoinWithdrawP2SH(r *runner.E2ERunner, args []string) { // check length of arguments require.Len(r, args, 2) - r.SetBtcAddress(r.Name, false) - // parse arguments and withdraw BTC defaultReceiver := "2N6AoUj3KPS7wNGZXuCckh8YEWcSYNsGbqd" receiver, amount := parseBitcoinWithdrawArgs(r, args, defaultReceiver) diff --git a/e2e/e2etests/test_bitcoin_withdraw_p2wsh.go b/e2e/e2etests/test_bitcoin_withdraw_p2wsh.go index 1865018628..41b65824bc 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_p2wsh.go +++ b/e2e/e2etests/test_bitcoin_withdraw_p2wsh.go @@ -10,8 +10,6 @@ import ( func TestBitcoinWithdrawP2WSH(r *runner.E2ERunner, args []string) { require.Len(r, args, 2) - r.SetBtcAddress(r.Name, false) - // parse arguments and withdraw BTC defaultReceiver := "bcrt1qm9mzhyky4w853ft2ms6dtqdyyu3z2tmrq8jg8xglhyuv0dsxzmgs2f0sqy" receiver, amount := parseBitcoinWithdrawArgs(r, args, defaultReceiver) diff --git a/e2e/e2etests/test_bitcoin_withdraw_restricted_address.go b/e2e/e2etests/test_bitcoin_withdraw_restricted_address.go index 84bd11b8de..87610cac09 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_restricted_address.go +++ b/e2e/e2etests/test_bitcoin_withdraw_restricted_address.go @@ -16,8 +16,6 @@ func TestBitcoinWithdrawRestricted(r *runner.E2ERunner, args []string) { withdrawalAmount := parseFloat(r, args[0]) amount := btcAmountFromFloat64(r, withdrawalAmount) - r.SetBtcAddress(r.Name, false) - withdrawBitcoinRestricted(r, amount) } diff --git a/e2e/e2etests/test_bitcoin_withdraw_segwit.go b/e2e/e2etests/test_bitcoin_withdraw_segwit.go index fe30c118f8..6d5c7d4516 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_segwit.go +++ b/e2e/e2etests/test_bitcoin_withdraw_segwit.go @@ -10,8 +10,6 @@ import ( func TestBitcoinWithdrawSegWit(r *runner.E2ERunner, args []string) { require.Len(r, args, 2) - r.SetBtcAddress(r.Name, false) - // parse arguments defaultReceiver := r.BTCDeployerAddress.EncodeAddress() receiver, amount := parseBitcoinWithdrawArgs(r, args, defaultReceiver) diff --git a/e2e/e2etests/test_bitcoin_withdraw_taproot.go b/e2e/e2etests/test_bitcoin_withdraw_taproot.go index f675a88c43..5935bb1986 100644 --- a/e2e/e2etests/test_bitcoin_withdraw_taproot.go +++ b/e2e/e2etests/test_bitcoin_withdraw_taproot.go @@ -10,8 +10,6 @@ import ( func TestBitcoinWithdrawTaproot(r *runner.E2ERunner, args []string) { require.Len(r, args, 2) - r.SetBtcAddress(r.Name, false) - // parse arguments and withdraw BTC defaultReceiver := "bcrt1pqqqsyqcyq5rqwzqfpg9scrgwpugpzysnzs23v9ccrydpk8qarc0sj9hjuh" receiver, amount := parseBitcoinWithdrawArgs(r, args, defaultReceiver) diff --git a/e2e/e2etests/test_migrate_tss.go b/e2e/e2etests/test_migrate_tss.go index 3825228c14..067623a325 100644 --- a/e2e/e2etests/test_migrate_tss.go +++ b/e2e/e2etests/test_migrate_tss.go @@ -20,7 +20,6 @@ import ( ) func TestMigrateTSS(r *runner.E2ERunner, _ []string) { - r.SetBtcAddress(r.Name, false) stop := r.MineBlocksIfLocalBitcoin() defer stop() diff --git a/e2e/e2etests/test_stress_btc_deposit.go b/e2e/e2etests/test_stress_btc_deposit.go index bedf004bdf..ea15d4fa9b 100644 --- a/e2e/e2etests/test_stress_btc_deposit.go +++ b/e2e/e2etests/test_stress_btc_deposit.go @@ -20,8 +20,6 @@ func TestStressBTCDeposit(r *runner.E2ERunner, args []string) { depositAmount := parseFloat(r, args[0]) numDeposits := parseInt(r, args[1]) - r.SetBtcAddress(r.Name, false) - r.Logger.Print("starting stress test of %d deposits", numDeposits) // create a wait group to wait for all the deposits to complete diff --git a/e2e/e2etests/test_stress_btc_withdraw.go b/e2e/e2etests/test_stress_btc_withdraw.go index 52d60430d2..1c02d17bf0 100644 --- a/e2e/e2etests/test_stress_btc_withdraw.go +++ b/e2e/e2etests/test_stress_btc_withdraw.go @@ -22,8 +22,6 @@ func TestStressBTCWithdraw(r *runner.E2ERunner, args []string) { withdrawalAmount := parseFloat(r, args[0]) numWithdraws := parseInt(r, args[1]) - r.SetBtcAddress(r.Name, false) - r.Logger.Print("starting stress test of %d withdraws", numWithdraws) // create a wait group to wait for all the withdraws to complete diff --git a/e2e/runner/accounting.go b/e2e/runner/accounting.go index c47883c3f0..223ca9c8c4 100644 --- a/e2e/runner/accounting.go +++ b/e2e/runner/accounting.go @@ -33,15 +33,20 @@ type Response struct { Amount Amount `json:"amount"` } -func (r *E2ERunner) CheckZRC20ReserveAndSupply() error { - r.Logger.Info("Checking ZRC20 Reserve and Supply") - if err := r.checkEthTSSBalance(); err != nil { - return err - } - if err := r.checkERC20TSSBalance(); err != nil { - return err - } - return r.checkZetaTSSBalance() +func (r *E2ERunner) CheckZRC20BalanceAndSupply() { + r.Logger.Info("Checking ZRC20 Balance vs. Supply") + + err := r.checkEthTSSBalance() + require.NoError(r, err, "ETH balance check failed") + + err = r.checkERC20TSSBalance() + require.NoError(r, err, "ERC20 balance check failed") + + err = r.checkZetaTSSBalance() + require.NoError(r, err, "ZETA balance check failed") + + err = r.CheckBtcTSSBalance() + require.NoError(r, err, "BTC balance check failed") } func (r *E2ERunner) checkEthTSSBalance() error { diff --git a/e2e/runner/balances.go b/e2e/runner/balances.go index 5def04090f..38ac61d70c 100644 --- a/e2e/runner/balances.go +++ b/e2e/runner/balances.go @@ -107,16 +107,7 @@ func (r *E2ERunner) GetAccountBalances(skipBTC bool) (AccountBalances, error) { // GetBitcoinBalance returns the spendable BTC balance of the BTC address func (r *E2ERunner) GetBitcoinBalance() (string, error) { - addr, _, err := r.GetBtcAddress() - if err != nil { - return "", fmt.Errorf("failed to get BTC address: %w", err) - } - - address, err := btcutil.DecodeAddress(addr, r.BitcoinParams) - if err != nil { - return "", fmt.Errorf("failed to decode BTC address: %w", err) - } - + address, _ := r.GetBtcAddress() total, err := r.GetBitcoinBalanceByAddress(address) if err != nil { return "", err diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 047e97139b..bec7a1e907 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -14,6 +14,7 @@ import ( "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" "github.com/rs/zerolog/log" "github.com/stretchr/testify/require" @@ -106,7 +107,7 @@ func (r *E2ERunner) DepositBTCWithAmount(amount float64, memo *memo.InboundMemo) if memo != nil { txHash, err = r.DepositBTCWithStandardMemo(amount, utxos, memo) } else { - txHash, err = r.DepositBTCWithLegacyMemo(amount, utxos) + txHash, err = r.DepositBTCWithLegacyMemo(amount, utxos, r.EVMAddress()) } require.NoError(r, err) @@ -115,8 +116,9 @@ func (r *E2ERunner) DepositBTCWithAmount(amount float64, memo *memo.InboundMemo) return txHash } -// DepositBTC deposits BTC on ZetaChain -func (r *E2ERunner) DepositBTC() { +// DepositBTC deposits BTC from the Bitcoin node wallet into ZetaChain. +// Note: This function only works for node wallet based deployer account. +func (r *E2ERunner) DepositBTC(receiver common.Address) { r.Logger.Print("⏳ depositing BTC into ZEVM") startTime := time.Now() defer func() { @@ -130,6 +132,7 @@ func (r *E2ERunner) DepositBTC() { spendableAmount := 0.0 spendableUTXOs := 0 for _, utxo := range utxos { + // 'Spendable' indicates whether we have the private keys to spend this output if utxo.Spendable { spendableAmount += utxo.Amount spendableUTXOs++ @@ -142,27 +145,24 @@ func (r *E2ERunner) DepositBTC() { r.Logger.Info("ListUnspent:") r.Logger.Info(" spendableAmount: %f", spendableAmount) r.Logger.Info(" spendableUTXOs: %d", spendableUTXOs) - r.Logger.Info("Now sending two txs to TSS address...") - - // send two transactions to the TSS address - amount1 := 1.1 + zetabitcoin.DefaultDepositorFee - _, err = r.DepositBTCWithLegacyMemo(amount1, utxos[:2]) - require.NoError(r, err) + r.Logger.Info("Now sending two txs to TSS address and tester ZEVM address...") - amount2 := 0.05 + zetabitcoin.DefaultDepositorFee - txHash2, err := r.DepositBTCWithLegacyMemo(amount2, utxos[2:4]) + // send initial BTC to the tester ZEVM address + amount := 1.15 + zetabitcoin.DefaultDepositorFee + txHash, err := r.DepositBTCWithLegacyMemo(amount, utxos[:2], receiver) require.NoError(r, err) // send a donation to the TSS address to compensate for the funds minted automatically during pool creation // and prevent accounting errors - _, err = r.SendToTSSFromDeployerWithMemo(0.11, utxos[4:5], []byte(constant.DonationMessage)) + // it also serves as gas fee for the TSS to send BTC to other addresses + _, err = r.SendToTSSFromDeployerWithMemo(0.11, utxos[2:4], []byte(constant.DonationMessage)) require.NoError(r, err) r.Logger.Info("testing if the deposit into BTC ZRC20 is successful...") cctx := utils.WaitCctxMinedByInboundHash( r.Ctx, - txHash2.String(), + txHash.String(), r.CctxClient, r.Logger, r.CctxTimeout, @@ -180,11 +180,12 @@ func (r *E2ERunner) DepositBTC() { func (r *E2ERunner) DepositBTCWithLegacyMemo( amount float64, inputUTXOs []btcjson.ListUnspentResult, + receiver common.Address, ) (*chainhash.Hash, error) { r.Logger.Info("⏳ depositing BTC into ZEVM with legacy memo") // payload is not needed for pure deposit - memoBytes := r.EVMAddress().Bytes() + memoBytes := receiver.Bytes() return r.SendToTSSFromDeployerWithMemo(amount, inputUTXOs, memoBytes) } @@ -431,7 +432,7 @@ func (r *E2ERunner) MineBlocksIfLocalBitcoin() func() { _, err := r.GenerateToAddressIfLocalBitcoin(1, r.BTCDeployerAddress) require.NoError(r, err) - time.Sleep(3 * time.Second) + time.Sleep(6 * time.Second) } } }() diff --git a/e2e/runner/logger.go b/e2e/runner/logger.go index 24f9c8f7bc..ba8053de60 100644 --- a/e2e/runner/logger.go +++ b/e2e/runner/logger.go @@ -15,7 +15,7 @@ import ( const ( loggerSeparator = " | " - padding = 10 + padding = 12 ) // Logger is a wrapper around log.Logger that adds verbosity diff --git a/e2e/runner/require.go b/e2e/runner/require.go index 9e296bf748..98496c5f25 100644 --- a/e2e/runner/require.go +++ b/e2e/runner/require.go @@ -24,8 +24,8 @@ func (r *E2ERunner) EnsureNoTrackers() { require.Empty(r, res.OutboundTracker, "there should be no trackers at the end of the test") } -// EnsureZeroBalanceAddressZEVM ensures that the balance of the address is zero in the ZEVM -func (r *E2ERunner) EnsureZeroBalanceAddressZEVM() { +// EnsureZeroBalanceAddressZEVM ensures that the balance of the restricted address is zero in the ZEVM +func (r *E2ERunner) EnsureZeroBalanceOnRestrictedAddressZEVM() { restrictedAddress := ethcommon.HexToAddress(sample.RestrictedEVMAddressTest) // ensure ZETA balance is zero diff --git a/e2e/runner/run.go b/e2e/runner/run.go index c05129b775..fde3de2277 100644 --- a/e2e/runner/run.go +++ b/e2e/runner/run.go @@ -26,11 +26,9 @@ func (r *E2ERunner) RunE2ETest(e2eTest E2ETest, checkAccounting bool) error { } e2eTest.E2ETest(r, args) - //check supplies + // check zrc20 balance vs. supply if checkAccounting { - if err := r.CheckZRC20ReserveAndSupply(); err != nil { - return err - } + r.CheckZRC20BalanceAndSupply() } r.Logger.Print("✅ completed in %s - %s", time.Since(startTime), e2eTest.Description) diff --git a/e2e/runner/setup_bitcoin.go b/e2e/runner/setup_bitcoin.go index 7b4d794f87..88d516e1b7 100644 --- a/e2e/runner/setup_bitcoin.go +++ b/e2e/runner/setup_bitcoin.go @@ -26,78 +26,65 @@ func (r *E2ERunner) AddTSSToNode() { require.NoError(r, err) } -func (r *E2ERunner) SetupBitcoinAccount(initNetwork bool) { - r.Logger.Print("⚙️ setting up Bitcoin account") +// SetupBitcoinAccounts sets up the TSS account and deployer account +func (r *E2ERunner) SetupBitcoinAccounts(createWallet bool) { + r.Logger.Info("⚙️ setting up Bitcoin account") startTime := time.Now() defer func() { r.Logger.Print("✅ Bitcoin account setup in %s", time.Since(startTime)) }() - _, err := r.BtcRPCClient.CreateWallet(r.Name, rpcclient.WithCreateWalletBlank()) - if err != nil { - require.ErrorContains(r, err, "Database already exists") - } - - r.SetBtcAddress(r.Name, true) - - if initNetwork { - // import the TSS address - err = r.BtcRPCClient.ImportAddress(r.BTCTSSAddress.EncodeAddress()) - require.NoError(r, err) + // setup deployer address + r.SetupBtcAddress(r.Name, createWallet) - // mine some blocks to get some BTC into the deployer address - _, err = r.GenerateToAddressIfLocalBitcoin(101, r.BTCDeployerAddress) - require.NoError(r, err) + // import the TSS address to index TSS utxos and transactions + err := r.BtcRPCClient.ImportAddress(r.BTCTSSAddress.EncodeAddress()) + require.NoError(r, err) + r.Logger.Info("⚙️ imported BTC TSSAddress: %s", r.BTCTSSAddress.EncodeAddress()) - _, err = r.GenerateToAddressIfLocalBitcoin(4, r.BTCDeployerAddress) - require.NoError(r, err) - } + // import deployer address to index deployer utxos and transactions + err = r.BtcRPCClient.ImportAddress(r.BTCDeployerAddress.EncodeAddress()) + require.NoError(r, err) + r.Logger.Info("⚙️ imported BTCDeployerAddress: %s", r.BTCDeployerAddress.EncodeAddress()) } -// GetBtcAddress returns the BTC address of the deployer from its EVM private key -func (r *E2ERunner) GetBtcAddress() (string, string, error) { +// GetBtcAddress returns the BTC address of the deployer and private key in WIF format +func (r *E2ERunner) GetBtcAddress() (*btcutil.AddressWitnessPubKeyHash, *btcutil.WIF) { + // load configured private key skBytes, err := hex.DecodeString(r.Account.RawPrivateKey.String()) - if err != nil { - return "", "", err - } + require.NoError(r, err) + // create private key in WIF format sk, _ := btcec.PrivKeyFromBytes(skBytes) privkeyWIF, err := btcutil.NewWIF(sk, r.BitcoinParams, true) - if err != nil { - return "", "", err - } + require.NoError(r, err) + // derive address from private key address, err := btcutil.NewAddressWitnessPubKeyHash( btcutil.Hash160(privkeyWIF.SerializePubKey()), r.BitcoinParams, ) - if err != nil { - return "", "", err - } + require.NoError(r, err) - // return the string representation of the address - return address.EncodeAddress(), privkeyWIF.String(), nil + return address, privkeyWIF } -// SetBtcAddress imports the deployer's private key into the Bitcoin node -func (r *E2ERunner) SetBtcAddress(name string, rescan bool) { - skBytes, err := hex.DecodeString(r.Account.RawPrivateKey.String()) - require.NoError(r, err) +// SetupBtcAddress setups the deployer Bitcoin address +func (r *E2ERunner) SetupBtcAddress(name string, setupWallet bool) { + // set the deployer address + address, privkeyWIF := r.GetBtcAddress() + r.BTCDeployerAddress = address - sk, _ := btcec.PrivKeyFromBytes(skBytes) - privkeyWIF, err := btcutil.NewWIF(sk, r.BitcoinParams, true) - require.NoError(r, err) + r.Logger.Info("BTCDeployerAddress: %s, %v", r.BTCDeployerAddress.EncodeAddress(), setupWallet) - if rescan { - err := r.BtcRPCClient.ImportPrivKeyRescan(privkeyWIF, name, true) + // import the deployer private key as a Bitcoin node wallet + if setupWallet { + _, err := r.BtcRPCClient.CreateWallet(r.Name, rpcclient.WithCreateWalletBlank()) + if err != nil { + require.ErrorContains(r, err, "Database already exists") + } + + err = r.BtcRPCClient.ImportPrivKeyRescan(privkeyWIF, name, true) require.NoError(r, err, "failed to execute ImportPrivKeyRescan") } - - r.BTCDeployerAddress, err = btcutil.NewAddressWitnessPubKeyHash( - btcutil.Hash160(privkeyWIF.PrivKey.PubKey().SerializeCompressed()), - r.BitcoinParams, - ) - require.NoError(r, err) - - r.Logger.Info("BTCDeployerAddress: %s", r.BTCDeployerAddress.EncodeAddress()) } diff --git a/go.mod b/go.mod index adb9b1cdb7..795cfb4528 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.8 require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.3.0 - cosmossdk.io/tools/rosetta v0.2.1 + cosmossdk.io/tools/rosetta v0.2.1 // indirect github.com/99designs/keyring v1.2.1 github.com/btcsuite/btcd v0.24.2 github.com/btcsuite/btcd/btcec/v2 v2.3.2 @@ -15,7 +15,7 @@ require ( github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 github.com/cenkalti/backoff/v4 v4.3.0 github.com/cockroachdb/errors v1.11.1 - github.com/coinbase/rosetta-sdk-go v0.7.9 + github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect github.com/cometbft/cometbft v0.37.5 github.com/cometbft/cometbft-db v0.12.0 github.com/cosmos/btcutil v1.0.5 diff --git a/server/start.go b/server/start.go index 09bb9215c0..14c64482f8 100644 --- a/server/start.go +++ b/server/start.go @@ -27,8 +27,6 @@ import ( "time" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/tools/rosetta" - crgserver "cosmossdk.io/tools/rosetta/lib/server" dbm "github.com/cometbft/cometbft-db" abciserver "github.com/cometbft/cometbft/abci/server" tcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" @@ -50,7 +48,6 @@ import ( "github.com/cosmos/cosmos-sdk/server/types" pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types" "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" ethmetricsexp "github.com/ethereum/go-ethereum/metrics/exp" "github.com/spf13/cobra" "github.com/zeta-chain/ethermint/indexer" @@ -626,61 +623,12 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOpt } // At this point it is safe to block the process if we're in query only mode as - // we do not need to start Rosetta or handle any Tendermint related processes. + // we do not need to handle any Tendermint related processes. if gRPCOnly { // wait for signal capture and gracefully return return server.WaitForQuitSignals() } - var rosettaSrv crgserver.Server - if config.Rosetta.Enable { - offlineMode := config.Rosetta.Offline - - // If GRPC is not enabled rosetta cannot work in online mode, so it works in - // offline mode. - if !config.GRPC.Enable { - offlineMode = true - } - - minGasPrices, err := sdk.ParseDecCoins(config.MinGasPrices) - if err != nil { - ctx.Logger.Error("failed to parse minimum-gas-prices", "error", err.Error()) - return err - } - - conf := &rosetta.Config{ - Blockchain: config.Rosetta.Blockchain, - Network: config.Rosetta.Network, - TendermintRPC: ctx.Config.RPC.ListenAddress, - GRPCEndpoint: config.GRPC.Address, - Addr: config.Rosetta.Address, - Retries: config.Rosetta.Retries, - Offline: offlineMode, - GasToSuggest: config.Rosetta.GasToSuggest, - EnableFeeSuggestion: config.Rosetta.EnableFeeSuggestion, - GasPrices: minGasPrices.Sort(), - Codec: clientCtx.Codec.(*codec.ProtoCodec), - InterfaceRegistry: clientCtx.InterfaceRegistry, - } - - rosettaSrv, err = rosetta.ServerFromConfig(conf) - if err != nil { - return err - } - - errCh := make(chan error) - go func() { - if err := rosettaSrv.Start(); err != nil { - errCh <- err - } - }() - - select { - case err := <-errCh: - return err - case <-time.After(types.ServerStartTime): // assume server started successfully - } - } // Wait for SIGINT or SIGTERM signal return server.WaitForQuitSignals() } diff --git a/x/observer/keeper/events.go b/x/observer/keeper/events.go index d1ddbc44ff..aed3b726a9 100644 --- a/x/observer/keeper/events.go +++ b/x/observer/keeper/events.go @@ -1,9 +1,10 @@ package keeper import ( + "encoding/json" + "log" "strconv" - types2 "github.com/coinbase/rosetta-sdk-go/types" sdk "github.com/cosmos/cosmos-sdk/types" types "github.com/zeta-chain/node/x/observer/types" @@ -21,11 +22,25 @@ func EmitEventBallotCreated(ctx sdk.Context, ballot types.Ballot, observationHas } } +// vendor this code from github.com/coinbase/rosetta-sdk-go/types +func prettyPrintStruct(val interface{}) string { + prettyStruct, err := json.MarshalIndent( + val, + "", + " ", + ) + if err != nil { + log.Fatal(err) + } + + return string(prettyStruct) +} + func EmitEventKeyGenBlockUpdated(ctx sdk.Context, keygen *types.Keygen) { err := ctx.EventManager().EmitTypedEvents(&types.EventKeygenBlockUpdated{ MsgTypeUrl: sdk.MsgTypeURL(&types.MsgUpdateKeygen{}), KeygenBlock: strconv.Itoa(int(keygen.BlockNumber)), - KeygenPubkeys: types2.PrettyPrintStruct(keygen.GranteePubkeys), + KeygenPubkeys: prettyPrintStruct(keygen.GranteePubkeys), }) if err != nil { ctx.Logger().Error("Error emitting EventKeygenBlockUpdated :", err) diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index b1a5335e58..b76af2da49 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -290,7 +290,7 @@ func GetDefaultBtcRegtestChainParams() *ChainParams { WatchUtxoTicker: 1, InboundTicker: 1, OutboundTicker: 2, - OutboundScheduleInterval: 2, + OutboundScheduleInterval: 1, OutboundScheduleLookahead: 5, BallotThreshold: DefaultBallotThreshold, MinObserverDelegation: DefaultMinObserverDelegation, diff --git a/zetaclient/chains/bitcoin/observer/outbound.go b/zetaclient/chains/bitcoin/observer/outbound.go index 16c8d24b81..a66559b62e 100644 --- a/zetaclient/chains/bitcoin/observer/outbound.go +++ b/zetaclient/chains/bitcoin/observer/outbound.go @@ -13,6 +13,7 @@ import ( "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/pkg/coin" + "github.com/zeta-chain/node/pkg/constant" crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" "github.com/zeta-chain/node/zetaclient/chains/bitcoin" "github.com/zeta-chain/node/zetaclient/chains/bitcoin/rpc" @@ -531,8 +532,8 @@ func (ob *Observer) checkTssOutboundResult( return errors.Wrapf(err, "checkTssOutboundResult: invalid TSS Vin in outbound %s nonce %d", hash, nonce) } - // differentiate between normal and restricted cctx - if compliance.IsCctxRestricted(cctx) { + // differentiate between normal and cancelled cctx + if compliance.IsCctxRestricted(cctx) || params.Amount.Uint64() < constant.BTCWithdrawalDustAmount { err = ob.checkTSSVoutCancelled(params, rawResult.Vout) if err != nil { return errors.Wrapf( diff --git a/zetaclient/chains/bitcoin/signer/signer.go b/zetaclient/chains/bitcoin/signer/signer.go index 1c08dcdcd6..c239627f22 100644 --- a/zetaclient/chains/bitcoin/signer/signer.go +++ b/zetaclient/chains/bitcoin/signer/signer.go @@ -21,6 +21,7 @@ import ( "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/pkg/coin" + "github.com/zeta-chain/node/pkg/constant" "github.com/zeta-chain/node/x/crosschain/types" observertypes "github.com/zeta-chain/node/x/observer/types" "github.com/zeta-chain/node/zetaclient/chains/base" @@ -413,13 +414,25 @@ func (signer *Signer) TryProcessOutbound( gasprice.Add(gasprice, satPerByte) // compliance check - cancelTx := compliance.IsCctxRestricted(cctx) - if cancelTx { + restrictedCCTX := compliance.IsCctxRestricted(cctx) + if restrictedCCTX { compliance.PrintComplianceLog(logger, signer.Logger().Compliance, true, chain.ChainId, cctx.Index, cctx.InboundParams.Sender, params.Receiver, "BTC") - amount = 0.0 // zero out the amount to cancel the tx } - logger.Info().Msgf("SignGasWithdraw: to %s, value %d sats", to.EncodeAddress(), params.Amount.Uint64()) + + // check dust amount + dustAmount := params.Amount.Uint64() < constant.BTCWithdrawalDustAmount + if dustAmount { + logger.Warn().Msgf("dust amount %d sats, canceling tx", params.Amount.Uint64()) + } + + // set the amount to 0 when the tx should be cancelled + cancelTx := restrictedCCTX || dustAmount + if cancelTx { + amount = 0.0 + } else { + logger.Info().Msgf("SignGasWithdraw: to %s, value %d sats", to.EncodeAddress(), params.Amount.Uint64()) + } // sign withdraw tx tx, err := signer.SignWithdrawTx( diff --git a/zetaclient/chains/evm/observer/observer_test.go b/zetaclient/chains/evm/observer/observer_test.go index d30be608e5..3be38cd86c 100644 --- a/zetaclient/chains/evm/observer/observer_test.go +++ b/zetaclient/chains/evm/observer/observer_test.go @@ -53,7 +53,6 @@ func getAppContext( // create config cfg := config.New(false) cfg.EVMChainConfigs[evmChain.ChainId] = config.EVMConfig{ - Chain: evmChain, Endpoint: endpoint, } @@ -178,7 +177,6 @@ func Test_NewObserver(t *testing.T) { { name: "should be able to create observer", evmCfg: config.EVMConfig{ - Chain: chain, Endpoint: "http://localhost:8545", }, chainParams: params, @@ -192,7 +190,6 @@ func Test_NewObserver(t *testing.T) { { name: "should fail if RPC call fails", evmCfg: config.EVMConfig{ - Chain: chain, Endpoint: "http://localhost:8545", }, chainParams: params, @@ -212,7 +209,6 @@ func Test_NewObserver(t *testing.T) { { name: "should fail on invalid ENV var", evmCfg: config.EVMConfig{ - Chain: chain, Endpoint: "http://localhost:8545", }, chainParams: params, diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index 6f17153b52..81cd3b2e1c 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -32,7 +32,9 @@ func New(setDefaults bool) Config { // bitcoinConfigRegnet contains Bitcoin config for regnet func bitcoinConfigRegnet() BTCConfig { return BTCConfig{ - RPCUsername: "smoketest", // smoketest is the previous name for E2E test, we keep this name for compatibility between client versions in upgrade test + // `smoketest` is the previous name for E2E test, + // we keep this name for compatibility between client versions in upgrade test + RPCUsername: "smoketest", RPCPassword: "123", RPCHost: "bitcoin:18443", RPCParams: "regtest", @@ -59,30 +61,7 @@ func tonConfigLocalnet() TONConfig { // it contains list of EVM chains with empty endpoint except for localnet func evmChainsConfigs() map[int64]EVMConfig { return map[int64]EVMConfig{ - chains.Ethereum.ChainId: { - Chain: chains.Ethereum, - }, - chains.BscMainnet.ChainId: { - Chain: chains.BscMainnet, - }, - chains.Goerli.ChainId: { - Chain: chains.Goerli, - Endpoint: "", - }, - chains.Sepolia.ChainId: { - Chain: chains.Sepolia, - Endpoint: "", - }, - chains.BscTestnet.ChainId: { - Chain: chains.BscTestnet, - Endpoint: "", - }, - chains.Mumbai.ChainId: { - Chain: chains.Mumbai, - Endpoint: "", - }, chains.GoerliLocalnet.ChainId: { - Chain: chains.GoerliLocalnet, Endpoint: "http://eth:8545", RPCAlertLatency: 60, }, diff --git a/zetaclient/config/types.go b/zetaclient/config/types.go index d3a1e4b3a0..e843397e0c 100644 --- a/zetaclient/config/types.go +++ b/zetaclient/config/types.go @@ -6,8 +6,6 @@ import ( "sync" "github.com/showa-93/go-mask" - - "github.com/zeta-chain/node/pkg/chains" ) // KeyringBackend is the type of keyring backend to use for the hotkey @@ -40,7 +38,6 @@ type ClientConfiguration struct { // EVMConfig is the config for EVM chain type EVMConfig struct { - Chain chains.Chain Endpoint string `mask:"filled"` RPCAlertLatency int64 } @@ -216,7 +213,7 @@ func (c Config) GetRelayerKeyPath() string { } func (c EVMConfig) Empty() bool { - return c.Endpoint == "" || c.Chain.IsEmpty() + return c.Endpoint == "" } func (c BTCConfig) Empty() bool { diff --git a/zetaclient/config/types_test.go b/zetaclient/config/types_test.go index 02f7eb5a6f..0b8884a30a 100644 --- a/zetaclient/config/types_test.go +++ b/zetaclient/config/types_test.go @@ -17,7 +17,6 @@ func Test_GetRelayerKeyPath(t *testing.T) { } func Test_GetEVMConfig(t *testing.T) { - chain := chains.Sepolia chainID := chains.Sepolia.ChainId t.Run("should find non-empty evm config", func(t *testing.T) { @@ -26,7 +25,6 @@ func Test_GetEVMConfig(t *testing.T) { // set valid evm endpoint cfg.EVMChainConfigs[chainID] = config.EVMConfig{ - Chain: chain, Endpoint: "localhost", } @@ -44,21 +42,6 @@ func Test_GetEVMConfig(t *testing.T) { _, found := cfg.GetEVMConfig(chainID) require.False(t, found) }) - - t.Run("should not find evm config if chain is empty", func(t *testing.T) { - // create config with defaults - cfg := config.New(true) - - // set empty chain - cfg.EVMChainConfigs[chainID] = config.EVMConfig{ - Chain: chains.Chain{}, - Endpoint: "localhost", - } - - // should not find evm config because chain is empty - _, found := cfg.GetEVMConfig(chainID) - require.False(t, found) - }) } func Test_GetBTCConfig(t *testing.T) { diff --git a/zetaclient/orchestrator/bootstap_test.go b/zetaclient/orchestrator/bootstap_test.go index eaae3a8e6d..c93efada00 100644 --- a/zetaclient/orchestrator/bootstap_test.go +++ b/zetaclient/orchestrator/bootstap_test.go @@ -44,12 +44,10 @@ func TestCreateSignerMap(t *testing.T) { cfg := config.New(false) cfg.EVMChainConfigs[chains.Ethereum.ChainId] = config.EVMConfig{ - Chain: chains.Ethereum, Endpoint: testutils.MockEVMRPCEndpoint, } cfg.EVMChainConfigs[chains.Polygon.ChainId] = config.EVMConfig{ - Chain: chains.Polygon, Endpoint: testutils.MockEVMRPCEndpoint, } @@ -225,12 +223,10 @@ func TestCreateChainObserverMap(t *testing.T) { cfg := config.New(false) cfg.EVMChainConfigs[chains.Ethereum.ChainId] = config.EVMConfig{ - Chain: chains.Ethereum, Endpoint: evmServer.Endpoint, } cfg.EVMChainConfigs[chains.Polygon.ChainId] = config.EVMConfig{ - Chain: chains.Polygon, Endpoint: evmServer.Endpoint, } diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index d88006920f..b86e85cc15 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -602,7 +602,7 @@ func createAppContext(t *testing.T, chainsOrParams ...any) *zctx.AppContext { for _, c := range supportedChains { switch { case chains.IsEVMChain(c.ChainId, nil): - cfg.EVMChainConfigs[c.ChainId] = config.EVMConfig{Chain: c} + cfg.EVMChainConfigs[c.ChainId] = config.EVMConfig{Endpoint: "localhost"} case chains.IsBitcoinChain(c.ChainId, nil): cfg.BTCChainConfigs[c.ChainId] = config.BTCConfig{RPCHost: "localhost"} case chains.IsSolanaChain(c.ChainId, nil):