Skip to content
Merged
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* [3560](https://github.com/zeta-chain/node/pull/3560) - initialize Sui E2E deposit tests
* [3595](https://github.com/zeta-chain/node/pull/3595) - add E2E tests for Sui withdraws
* [3591](https://github.com/zeta-chain/node/pull/3591) - add a runner for gov proposals in the e2e test.
* [3612](https://github.com/zeta-chain/node/pull/3612) - add support for TON live e2e tests

## v28.0.0

Expand Down
20 changes: 8 additions & 12 deletions cmd/zetae2e/config/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, account confi
}

var tonClient *tonrunner.Client
if conf.RPCs.TONSidecarURL != "" {
c, err := getTONClient(ctx, conf.RPCs.TONSidecarURL)
if conf.RPCs.TON != "" {
c, err := getTONClient(ctx, conf.RPCs.TON)
if err != nil {
return runner.Clients{}, fmt.Errorf("failed to get ton client: %w", err)
}
Expand Down Expand Up @@ -132,17 +132,16 @@ func getEVMClient(
return evmClient, evmAuth, nil
}

func getTONClient(ctx context.Context, sidecarURL string) (*tonrunner.Client, error) {
if sidecarURL == "" {
return nil, fmt.Errorf("sidecar URL is empty")
// getTONClient resolved tonrunner based on lite-server config (path or url)
func getTONClient(ctx context.Context, configURLOrPath string) (*tonrunner.Client, error) {
if configURLOrPath == "" {
return nil, fmt.Errorf("config is empty")
}

sidecar := tonrunner.NewSidecarClient(sidecarURL)

// It might take some time to bootstrap the sidecar
cfg, err := retry.DoTypedWithRetry(
func() (*tonconfig.GlobalConfigurationFile, error) {
return tonconfig.FromURL(ctx, sidecar.LiteServerURL())
return tonconfig.FromSource(ctx, configURLOrPath)
},
)

Expand All @@ -155,10 +154,7 @@ func getTONClient(ctx context.Context, sidecarURL string) (*tonrunner.Client, er
return nil, fmt.Errorf("failed to create ton client: %w", err)
}

return &tonrunner.Client{
Client: client,
SidecarClient: sidecar,
}, nil
return &tonrunner.Client{Client: client}, nil
}

func GetZetacoreClient(conf config.Config) (zetacore_rpc.Clients, error) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func RunnerFromConfig(
ctxCancel,
account,
e2eClients,

logger,
opts...,
)
Expand All @@ -58,6 +57,8 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
conf.Contracts.Solana.GatewayProgramID = config.DoubleQuotedString(r.GatewayProgram.String())
conf.Contracts.Solana.SPLAddr = config.DoubleQuotedString(r.SPLAddr.String())

conf.Contracts.TON.GatewayAccountID = config.DoubleQuotedString(r.TONGateway.ToRaw())

if r.SuiGateway != nil {
conf.Contracts.Sui.GatewayPackageID = config.DoubleQuotedString(r.SuiGateway.PackageID())
conf.Contracts.Sui.GatewayObjectID = config.DoubleQuotedString(r.SuiGateway.ObjectID())
Expand Down
5 changes: 5 additions & 0 deletions cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/gagliardetto/solana-go"
"github.com/stretchr/testify/require"
"github.com/tonkeeper/tongo/ton"
"github.com/zeta-chain/protocol-contracts/pkg/erc20custody.sol"
"github.com/zeta-chain/protocol-contracts/pkg/gatewayevm.sol"
"github.com/zeta-chain/protocol-contracts/pkg/gatewayzevm.sol"
Expand Down Expand Up @@ -118,6 +119,10 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
r.SPLAddr = solana.MustPublicKeyFromBase58(c.String())
}

if c := conf.Contracts.TON.GatewayAccountID; c != "" {
r.TONGateway = ton.MustParseAccountID(c.String())
}

// set Sui contracts
suiPackageID := conf.Contracts.Sui.GatewayPackageID
suiGatewayID := conf.Contracts.Sui.GatewayObjectID
Expand Down
15 changes: 13 additions & 2 deletions cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ additional_accounts:
evm_address: "0xf67deecc3B15F9CEeF5eba3468ed601f3e0B9de2"
private_key: "2b3306a8ac43dbf0e350b87876c131e7e12bd49563a16de9ce8aeb664b94d559"
solana_private_key: "4yqSQxDeTBvn86BuxcN5jmZb2gaobFXrBqu8kiE9rZxNkVMe3LfXmFigRsU4sRp7vk4vVP1ZCFiejDKiXBNWvs2C"
user_ton:
bech32_address: "zeta13a5yvmysdsncc704e093wy5wm0akp394tkrwje"
evm_address: "0x8f68466C906c278c79F5CbcB17128EdBfb60C4b5"
private_key: "a85f64e560fbef77422272b162915da8170152cf3983567b66f20a5494544591"
solana_private_key: "2AB2oDXWey3uhwYVj4bbJ4cGbz7R2ZMePJpY5r84KyVeUq2z89nsfWgcnb1sH1jUvRaCxXV2DBwMNUobQUfTbeqq"
user_sui:
bech32_address: "zeta1qluk7yfyqfejwss64lqmn7de6svudcedz94zs2"
evm_address: "0x07F96F1124027327421AAFc1B9F9B9D419C6e32d"
Expand Down Expand Up @@ -112,7 +117,9 @@ rpcs:
zetacore_grpc: "localhost:9090"
zetacore_rpc: "http://localhost:26657"
solana: "http://localhost:8899"
ton_sidecar_url: "http://localhost:8111"
# ton lite-server config url or path
ton: "http://ton:8111/lite-client.json"
ton_faucet: "http://ton:8111/faucet.json"
zetaclient_metrics: "http://localhost:8886"
contracts:
zevm:
Expand All @@ -139,4 +146,8 @@ contracts:
test_dapp_v2: "0xa825eAa55b497AF892faca73a3797046C10B7c23"
solana:
gateway_program_id: "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d"
spl: ""
spl: ""
ton:
# e.g. "0:31503e3dd1df464216e4c4ca0eee3a40b812822c8539823e009b0720fab527b5"
# unique on each e2e as it's partially derived from TSS address
gateway_account_id: ""
17 changes: 14 additions & 3 deletions cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ additional_accounts:
evm_address: "0xf67deecc3B15F9CEeF5eba3468ed601f3e0B9de2"
private_key: "2b3306a8ac43dbf0e350b87876c131e7e12bd49563a16de9ce8aeb664b94d559"
solana_private_key: "4yqSQxDeTBvn86BuxcN5jmZb2gaobFXrBqu8kiE9rZxNkVMe3LfXmFigRsU4sRp7vk4vVP1ZCFiejDKiXBNWvs2C"
user_ton:
bech32_address: "zeta13a5yvmysdsncc704e093wy5wm0akp394tkrwje"
evm_address: "0x8f68466C906c278c79F5CbcB17128EdBfb60C4b5"
private_key: "a85f64e560fbef77422272b162915da8170152cf3983567b66f20a5494544591"
solana_private_key: "2AB2oDXWey3uhwYVj4bbJ4cGbz7R2ZMePJpY5r84KyVeUq2z89nsfWgcnb1sH1jUvRaCxXV2DBwMNUobQUfTbeqq"
user_sui:
bech32_address: "zeta1qluk7yfyqfejwss64lqmn7de6svudcedz94zs2"
evm_address: "0x07F96F1124027327421AAFc1B9F9B9D419C6e32d"
Expand Down Expand Up @@ -108,14 +113,20 @@ rpcs:
disable_tls: true
params: regnet
solana: "http://solana:8899"
ton_sidecar_url: "http://ton:8000"
# ton lite-server config url or path
ton: "http://ton:8000/lite-client.json"
ton_faucet: "http://ton:8000/faucet.json"
sui: "http://sui:9000"
sui_faucet: "http://sui:9123"
zetacore_grpc: "zetacore0:9090"
zetacore_rpc: "http://zetacore0:26657"
zetaclient_metrics: "http://zetaclient0:8886"
contracts:
# configure localnet solana gateway program id
# configure localnet solana gateway program id
solana:
gateway_program_id: "94U5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d"
spl: ""
spl: ""
ton:
# e.g. "0:31503e3dd1df464216e4c4ca0eee3a40b812822c8539823e009b0720fab527b5"
# unique on each e2e as it's partially derived from TSS address
gateway_account_id: ""
2 changes: 1 addition & 1 deletion cmd/zetae2e/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewInitCmd() *cobra.Command {
InitCmd.Flags().
StringVar(&initConf.RPCs.Solana, "solanaURL", initConf.RPCs.Solana, "--solanaURL http://solana:8899")
InitCmd.Flags().
StringVar(&initConf.RPCs.TONSidecarURL, "tonSidecarURL", initConf.RPCs.TONSidecarURL, "--tonSidecarURL http://ton:8000")
StringVar(&initConf.RPCs.TON, "tonURL", initConf.RPCs.TON, "--tonURL http://ton:8000/lite-client.json")
InitCmd.Flags().StringVar(&initConf.ZetaChainID, "chainID", initConf.ZetaChainID, "--chainID athens_101-1")
InitCmd.Flags().StringVar(&configFile, local.FlagConfigFile, "e2e.config", "--cfg ./e2e.config")

Expand Down
17 changes: 12 additions & 5 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
conf, err := GetConfig(cmd)
noError(err)

// temporary spaghetti to overcome e2e flags limitations
if !testTON {
conf.RPCs.TONSidecarURL = ""
}

// initialize context
ctx, timeoutCancel := context.WithTimeoutCause(context.Background(), TestTimeout, ErrTopLevelTimeout)
defer timeoutCancel()
Expand Down Expand Up @@ -182,6 +177,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
)
noError(err)

// Drop this cond after TON e2e is included in the default suite
if !testTON {
conf.RPCs.TON = ""
}

// initialize deployer runner with config
deployerRunner, err := zetae2econfig.RunnerFromConfig(
ctx,
Expand Down Expand Up @@ -257,6 +257,13 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
// Update the chain params to contains protocol contract addresses
deployerRunner.UpdateProtocolContractsInChainParams()

if testTON {
deployerRunner.SetupTON(
conf.RPCs.TONFaucet,
conf.AdditionalAccounts.UserTON,
)
}

if testSui {
deployerRunner.SetupSui(conf.RPCs.SuiFaucet)
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/zetae2e/local/ton.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func tonTestRoutine(
"ton",
conf,
deployerRunner,
conf.DefaultAccount,
conf.AdditionalAccounts.UserTON,
runner.NewLogger(verbose, color.FgCyan, "ton"),
runner.WithZetaTxServer(deployerRunner.ZetaTxServer),
)
Expand All @@ -39,10 +39,6 @@ func tonTestRoutine(
return errors.Wrap(err, "unable to get ton tests to run")
}

if err := tonRunner.SetupTON(); err != nil {
return errors.Wrap(err, "unable to setup TON account")
}

if err := tonRunner.RunE2ETests(tests); err != nil {
return errors.Wrap(err, "ton tests failed")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/zeta-chain/node/cmd/zetae2e/local"
)

var asciiArt = `
const banner = `
_ ____
_______| |_ __ _ ___|___ \ ___
|_ / _ \ __/ _ |/ _ \ __) / _ \
Expand All @@ -17,7 +17,7 @@ var asciiArt = `
func NewRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "zetae2e",
Short: asciiArt,
Short: banner,
}
cmd.AddCommand(
NewRunCmd(),
Expand Down
6 changes: 6 additions & 0 deletions cmd/zetatool/cctx/inbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ import (
"github.com/zeta-chain/node/cmd/zetatool/cctx"
zetatoolcontext "github.com/zeta-chain/node/cmd/zetatool/context"
"github.com/zeta-chain/node/pkg/chains"
"github.com/zeta-chain/node/zetaclient/common"
)

func Test_InboundBallotIdentifier(t *testing.T) {
if !common.LiveTestEnabled() {
t.Skip("skipping live test")
return
}

tt := []struct {
name string
inboundHash string
Expand Down
3 changes: 3 additions & 0 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ fund_eth_from_config '.additional_accounts.user_bitcoin_withdraw.evm_address' 10
# unlock solana tester accounts
fund_eth_from_config '.additional_accounts.user_solana.evm_address' 10000 "solana tester"

# unlock ton tester accounts
fund_eth_from_config '.additional_accounts.user_ton.evm_address' 10000 "ton tester"

# unlock sui tester accounts
fund_eth_from_config '.additional_accounts.user_sui.evm_address' 10000 "sui tester"

Expand Down
3 changes: 3 additions & 0 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ then
# solana tester
address=$(yq -r '.additional_accounts.user_solana.bech32_address' /root/config.yml)
zetacored add-genesis-account "$address" 10000000000000000000000000azeta
# ton tester
address=$(yq -r '.additional_accounts.user_ton.bech32_address' /root/config.yml)
zetacored add-genesis-account "$address" 10000000000000000000000000azeta
# migration tester
address=$(yq -r '.additional_accounts.user_migration.bech32_address' /root/config.yml)
zetacored add-genesis-account "$address" 10000000000000000000000000azeta
Expand Down
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/wait-for-ton.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

timeout_seconds=300 # 5 minutes
poll_interval=10 # Check every 10 seconds
poll_interval=5 # Check every 5 seconds

status_url="http://ton:8000/status"

Expand Down
36 changes: 33 additions & 3 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package config

import (
"crypto/ecdsa"
"crypto/ed25519"
"encoding/hex"
"errors"
"fmt"
"os"
"strings"
Expand All @@ -13,8 +13,12 @@ import (
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/gagliardetto/solana-go"
"github.com/pkg/errors"
tonwallet "github.com/tonkeeper/tongo/wallet"
"gopkg.in/yaml.v3"

"github.com/zeta-chain/node/e2e/runner/ton"
"github.com/zeta-chain/node/pkg/contracts/sui"
)

Expand Down Expand Up @@ -72,6 +76,7 @@ type AdditionalAccounts struct {
UserBitcoinWithdraw Account `yaml:"user_bitcoin_withdraw"`
UserSolana Account `yaml:"user_solana"`
UserSPL Account `yaml:"user_spl"`
UserTON Account `yaml:"user_ton"`
UserSui Account `yaml:"user_sui"`
UserMisc Account `yaml:"user_misc"`
UserAdmin Account `yaml:"user_admin"`
Expand Down Expand Up @@ -102,7 +107,8 @@ type RPCs struct {
EVM string `yaml:"evm"`
Bitcoin BitcoinRPC `yaml:"bitcoin"`
Solana string `yaml:"solana"`
TONSidecarURL string `yaml:"ton_sidecar_url"`
TON string `yaml:"ton"`
TONFaucet string `yaml:"ton_faucet"`
Sui string `yaml:"sui"`
SuiFaucet string `yaml:"sui_faucet"`
ZetaCoreGRPC string `yaml:"zetacore_grpc"`
Expand All @@ -123,6 +129,7 @@ type Contracts struct {
EVM EVM `yaml:"evm"`
ZEVM ZEVM `yaml:"zevm"`
Solana Solana `yaml:"solana"`
TON TON `yaml:"ton"`
Sui Sui `yaml:"sui"`
}

Expand All @@ -132,6 +139,11 @@ type Solana struct {
SPLAddr DoubleQuotedString `yaml:"spl"`
}

// TON contains the address of predeployed contracts on the TON chain
type TON struct {
GatewayAccountID DoubleQuotedString `yaml:"gateway_account_id"`
}

// Sui contains the addresses of predeployed contracts on the Sui chain
type Sui struct {
GatewayPackageID DoubleQuotedString `yaml:"gateway_package_id"`
Expand Down Expand Up @@ -189,6 +201,7 @@ func DefaultConfig() Config {
ZetaCoreGRPC: "zetacore0:9090",
ZetaCoreRPC: "http://zetacore0:26657",
Solana: "http://solana:8899",
TON: "http://ton:8000/lite-client.json",
},
ZetaChainID: "athens_101-1",
Contracts: Contracts{
Expand Down Expand Up @@ -255,6 +268,7 @@ func (a AdditionalAccounts) AsSlice() []Account {
a.UserBitcoinDeposit,
a.UserBitcoinWithdraw,
a.UserSolana,
a.UserTON,
a.UserSui,
a.UserSPL,
a.UserLegacyEther,
Expand Down Expand Up @@ -351,6 +365,10 @@ func (c *Config) GenerateKeys() error {
if err != nil {
return err
}
c.AdditionalAccounts.UserTON, err = generateAccount()
if err != nil {
return err
}
c.AdditionalAccounts.UserSui, err = generateAccount()
if err != nil {
return err
Expand Down Expand Up @@ -429,7 +447,19 @@ func (a Account) SuiSigner() (*sui.SignerSecp256k1, error) {
return sui.NewSignerSecp256k1(privateKeyBytes), nil
}

// Validate that the address and the private key specified in the
// AsTONWallet derives TON V5R1 wallet solana private key
func (a Account) AsTONWallet(client *ton.Client) (*ton.AccountInit, *tonwallet.Wallet, error) {
pk := solana.MustPrivateKeyFromBase58(a.SolanaPrivateKey.String())

// Extract the seed bytes (first 32 bytes) from the ed25519 private key
// ed25519 private key is 64 bytes: 32 bytes seed + 32 bytes public key
seed := pk[:ed25519.SeedSize]

rawPk := ed25519.NewKeyFromSeed(seed)

return ton.ConstructWalletFromPrivateKey(rawPk, client)
}

// config actually match
func (a Account) Validate() error {
privateKey, err := a.PrivateKey()
Expand Down
Loading
Loading