Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/zeta-chain/node into e2e…
Browse files Browse the repository at this point in the history
…-bitcoin-deposit-and-call
  • Loading branch information
ws4charlie committed Sep 18, 2024
2 parents b0928b2 + 8d17118 commit db99f8f
Show file tree
Hide file tree
Showing 99 changed files with 3,314 additions and 665 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
STATEFUL_DATA_TESTS: ${{ steps.matrix-conditionals.outputs.STATEFUL_DATA_TESTS }}
TSS_MIGRATION_TESTS: ${{ steps.matrix-conditionals.outputs.TSS_MIGRATION_TESTS }}
SOLANA_TESTS: ${{ steps.matrix-conditionals.outputs.SOLANA_TESTS }}
TON_TESTS: ${{ steps.matrix-conditionals.outputs.TON_TESTS }}
V2_TESTS: ${{ steps.matrix-conditionals.outputs.V2_TESTS }}
V2_MIGRATION_TESTS: ${{ steps.matrix-conditionals.outputs.V2_MIGRATION_TESTS }}
steps:
Expand All @@ -62,6 +63,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', labels.includes('STATEFUL_DATA_TESTS'));
core.setOutput('TSS_MIGRATION_TESTS', labels.includes('TSS_MIGRATION_TESTS'));
core.setOutput('SOLANA_TESTS', labels.includes('SOLANA_TESTS'));
core.setOutput('TON_TESTS', labels.includes('TON_TESTS'));
core.setOutput('V2_TESTS', labels.includes('V2_TESTS')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', labels.includes('V2_MIGRATION_TESTS')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'merge_group') {
Expand All @@ -77,6 +79,8 @@ jobs:
core.setOutput('ADMIN_TESTS', true);
core.setOutput('PERFORMANCE_TESTS', true);
core.setOutput('STATEFUL_DATA_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
core.setOutput('TON_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'schedule') {
Expand All @@ -89,6 +93,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', true);
core.setOutput('TSS_MIGRATION_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
core.setOutput('TON_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'workflow_dispatch') {
Expand All @@ -102,6 +107,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', makeTargets.includes('import-mainnet-test'));
core.setOutput('TSS_MIGRATION_TESTS', makeTargets.includes('tss-migration-test'));
core.setOutput('SOLANA_TESTS', makeTargets.includes('solana-test'));
core.setOutput('TON_TESTS', makeTargets.includes('ton-test'));
core.setOutput('V2_TESTS', makeTargets.includes('v2-test')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
core.setOutput('V2_MIGRATION_TESTS', makeTargets.includes('v2-migration-test')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
}
Expand Down Expand Up @@ -142,6 +148,9 @@ jobs:
- make-target: "start-solana-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.SOLANA_TESTS == 'true' }}
- make-target: "start-ton-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.TON_TESTS == 'true' }}
- make-target: "start-v2-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.V2_TESTS == 'true' }}
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ start-solana-test: zetanode solana
export E2E_ARGS="--skip-regular --test-solana" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile solana -f docker-compose.yml up -d

start-ton-test: zetanode
@echo "--> Starting TON test"
export E2E_ARGS="--skip-regular --test-ton" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile ton -f docker-compose.yml up -d

start-v2-test: zetanode
@echo "--> Starting e2e smart contracts v2 test"
export E2E_ARGS="--skip-regular --test-v2" && \
Expand Down
52 changes: 42 additions & 10 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@

### Features

* [2633](https://github.com/zeta-chain/node/pull/2633) - support for stateful precompiled contracts
* [2788](https://github.com/zeta-chain/node/pull/2788) - add common importable zetacored rpc package
* [2784](https://github.com/zeta-chain/node/pull/2784) - staking precompiled contract
* [2795](https://github.com/zeta-chain/node/pull/2795) - support restricted address in Solana
* [2861](https://github.com/zeta-chain/node/pull/2861) - emit events from staking precompile
* [2870](https://github.com/zeta-chain/node/pull/2870) - support for multiple Bitcoin chains in the zetaclient
* [2883](https://github.com/zeta-chain/node/pull/2883) - add chain static information for btc signet testnet

### Refactor

* [2749](https://github.com/zeta-chain/node/pull/2749) - fix all lint errors from govet
* [2725](https://github.com/zeta-chain/node/pull/2725) - refactor SetCctxAndNonceToCctxAndInboundHashToCctx to receive tsspubkey as an argument
* [2802](https://github.com/zeta-chain/node/pull/2802) - set default liquidity cap for new ZRC20s
* [2826](https://github.com/zeta-chain/node/pull/2826) - remove unused code from emissions module and add new parameter for fixed block reward amount

### Tests

* [2661](https://github.com/zeta-chain/node/pull/2661) - update connector and erc20Custody addresses in tss migration e2e tests
* [2703](https://github.com/zeta-chain/node/pull/2703) - add e2e tests for stateful precompiled contracts
* [2830](https://github.com/zeta-chain/node/pull/2830) - extend staking precompile tests
* [2867](https://github.com/zeta-chain/node/pull/2867) - skip precompiles test for tss migration
* [2833](https://github.com/zeta-chain/node/pull/2833) - add e2e framework for TON blockchain
* [2874](https://github.com/zeta-chain/node/pull/2874) - add support for multiple runs for precompile tests

### Fixes

* [2674](https://github.com/zeta-chain/node/pull/2674) - allow operators to vote on ballots associated with discarded keygen without affecting the status of the current keygen.
* [2672](https://github.com/zeta-chain/node/pull/2672) - check observer set for duplicates when adding a new observer or updating an existing one
* [2735](https://github.com/zeta-chain/node/pull/2735) - fix the outbound tracker blocking confirmation and outbound processing on EVM chains by locally index outbound txs in zetaclient
* [2944](https://github.com/zeta-chain/node/pull/2844) - add tsspubkey to index for tss keygen voting
* [2842](https://github.com/zeta-chain/node/pull/2842) - fix: move interval assignment out of cctx loop in EVM outbound tx scheduler
* [2853](https://github.com/zeta-chain/node/pull/2853) - calling precompile through sc with sc state update

## v20.0.0

### Features

* [2578](https://github.com/zeta-chain/node/pull/2578) - add Gateway address in protocol contract list
* [2630](https://github.com/zeta-chain/node/pull/2630) - implement `MsgMigrateERC20CustodyFunds` to migrate the funds from the ERC20Custody to a new contracts (to be used for the new ERC20Custody contract for smart contract V2)
* [2578](https://github.com/zeta-chain/node/pull/2578) - Add Gateway address in protocol contract list
Expand All @@ -15,36 +52,31 @@
* [2644](https://github.com/zeta-chain/node/pull/2644) - add created_timestamp to cctx status
* [2673](https://github.com/zeta-chain/node/pull/2673) - add relayer key importer, encryption and decryption
* [2633](https://github.com/zeta-chain/node/pull/2633) - support for stateful precompiled contracts
* [2751](https://github.com/zeta-chain/node/pull/2751) - add RPC status check for Solana chain
* [2788](https://github.com/zeta-chain/node/pull/2788) - add common importable zetacored rpc package
* [2784](https://github.com/zeta-chain/node/pull/2784) - staking precompiled contract
* [2795](https://github.com/zeta-chain/node/pull/2795) - support restricted address in Solana
* [2861](https://github.com/zeta-chain/node/pull/2861) - emit events from staking precompile
* [2825](https://github.com/zeta-chain/node/pull/2825) - add Bitcoin inscriptions support

### Refactor

* [2615](https://github.com/zeta-chain/node/pull/2615) - Refactor cleanup of outbound trackers
* [2749](https://github.com/zeta-chain/node/pull/2749) - fix all lint errors from govet
* [2725](https://github.com/zeta-chain/node/pull/2725) - refactor SetCctxAndNonceToCctxAndInboundHashToCctx to receive tsspubkey as an argument
* [2802](https://github.com/zeta-chain/node/pull/2802) - set default liquidity cap for new ZRC20s
* [2826](https://github.com/zeta-chain/node/pull/2826) - remove unused code from emissions module and add new parameter for fixed block reward amount
* [2855](https://github.com/zeta-chain/node/pull/2855) - disable Bitcoin witness support for mainnet

### Tests

* [2661](https://github.com/zeta-chain/node/pull/2661) - update connector and erc20Custody addresses in tss migration e2e tests
* [2726](https://github.com/zeta-chain/node/pull/2726) - add e2e tests for deposit and call, deposit and revert
* [2703](https://github.com/zeta-chain/node/pull/2703) - add e2e tests for stateful precompiled contracts
* [2763](https://github.com/zeta-chain/node/pull/2763) - add V2 contracts migration test
* [2830](https://github.com/zeta-chain/node/pull/2830) - extend staking precompile tests
* [2821](https://github.com/zeta-chain/node/pull/2821) - V2 protocol contracts migration e2e tests
* [2895](https://github.com/zeta-chain/node/pull/2895) - add e2e test for bitcoin deposit and call

### Fixes

* [2654](https://github.com/zeta-chain/node/pull/2654) - add validation for authorization list in when validating genesis state for authorization module
* [2674](https://github.com/zeta-chain/node/pull/2674) - allow operators to vote on ballots associated with discarded keygen without affecting the status of the current keygen.
* [2672](https://github.com/zeta-chain/node/pull/2672) - check observer set for duplicates when adding a new observer or updating an existing one
* [2787](https://github.com/zeta-chain/node/pull/2787) - ask for 3 accounts (signer, pda, system_program) on solana gateway deposit
* [2842](https://github.com/zeta-chain/node/pull/2842) - fix: move interval assignment out of cctx loop in EVM outbound tx scheduler
* [2853](https://github.com/zeta-chain/node/pull/2853) - calling precompile through sc with sc state update
* [2824](https://github.com/zeta-chain/node/pull/2824) - fix Solana deposit number

## v19.0.0

Expand Down
14 changes: 9 additions & 5 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,21 @@ func debugCmd(_ *cobra.Command, args []string) error {
fmt.Println("CoinType not detected")
}
fmt.Println("CoinType : ", coinType)
} else if chain.IsUTXO() {
} else if chain.IsBitcoin() {
btcObserver := btcobserver.Observer{}
btcObserver.WithZetacoreClient(client)
btcObserver.WithChain(*chainProto)
btcConfig, found := cfg.GetBTCConfig(chainID)
if !found {
return fmt.Errorf("unable to find config for BTC chain %d", chainID)
}
connCfg := &rpcclient.ConnConfig{
Host: cfg.BitcoinConfig.RPCHost,
User: cfg.BitcoinConfig.RPCUsername,
Pass: cfg.BitcoinConfig.RPCPassword,
Host: btcConfig.RPCHost,
User: btcConfig.RPCUsername,
Pass: btcConfig.RPCPassword,
HTTPPostMode: true,
DisableTLS: true,
Params: cfg.BitcoinConfig.RPCParams,
Params: btcConfig.RPCParams,
}

btcClient, err := rpcclient.New(connCfg, nil)
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func start(_ *cobra.Command, _ []string) error {
return err
}

startLogger.Info().Msgf("Config is updated from zetacore %s", maskCfg(cfg))
startLogger.Info().Msgf("Config is updated from zetacore\n %s", cfg.StringMasked())

go zetacoreClient.UpdateAppContextWorker(ctx, appContext)

Expand Down Expand Up @@ -230,7 +230,7 @@ func start(_ *cobra.Command, _ []string) error {
return err
}

btcChains := appContext.FilterChains(zctx.Chain.IsUTXO)
btcChains := appContext.FilterChains(zctx.Chain.IsBitcoin)
switch {
case len(btcChains) == 0:
return errors.New("no BTC chains found")
Expand Down
41 changes: 0 additions & 41 deletions cmd/zetaclientd/start_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"net"
"net/url"
"strings"
"time"

Expand Down Expand Up @@ -52,43 +51,3 @@ func validatePeer(seedPeer string) error {

return nil
}

// maskCfg sensitive fields are masked, currently only the EVM endpoints and bitcoin credentials,
//
// other fields can be added.
func maskCfg(cfg config.Config) string {
maskedCfg := cfg

maskedCfg.BitcoinConfig = config.BTCConfig{
RPCUsername: cfg.BitcoinConfig.RPCUsername,
RPCPassword: cfg.BitcoinConfig.RPCPassword,
RPCHost: cfg.BitcoinConfig.RPCHost,
RPCParams: cfg.BitcoinConfig.RPCParams,
}
maskedCfg.EVMChainConfigs = map[int64]config.EVMConfig{}
for key, val := range cfg.EVMChainConfigs {
maskedCfg.EVMChainConfigs[key] = config.EVMConfig{
Chain: val.Chain,
Endpoint: val.Endpoint,
}
}

// Mask Sensitive data
for _, chain := range maskedCfg.EVMChainConfigs {
if chain.Endpoint == "" {
continue
}
endpointURL, err := url.Parse(chain.Endpoint)
if err != nil {
continue
}
chain.Endpoint = endpointURL.Hostname()
}

// mask endpoints
maskedCfg.BitcoinConfig.RPCUsername = ""
maskedCfg.BitcoinConfig.RPCPassword = ""
maskedCfg.SolanaConfig.Endpoint = ""

return maskedCfg.String()
}
64 changes: 54 additions & 10 deletions cmd/zetae2e/config/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,51 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/gagliardetto/solana-go/rpc"
ton "github.com/tonkeeper/tongo/liteapi"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/zeta-chain/node/e2e/config"
"github.com/zeta-chain/node/e2e/runner"
tonrunner "github.com/zeta-chain/node/e2e/runner/ton"
"github.com/zeta-chain/node/pkg/retry"
zetacore_rpc "github.com/zeta-chain/node/pkg/rpc"
tonconfig "github.com/zeta-chain/node/zetaclient/chains/ton"
)

// getClientsFromConfig get clients from config
func getClientsFromConfig(ctx context.Context, conf config.Config, account config.Account) (
runner.Clients,
error,
) {
var solanaClient *rpc.Client
if conf.RPCs.Solana != "" {
if solanaClient = rpc.New(conf.RPCs.Solana); solanaClient == nil {
return runner.Clients{}, fmt.Errorf("failed to get solana client")
}
}
func getClientsFromConfig(ctx context.Context, conf config.Config, account config.Account) (runner.Clients, error) {
btcRPCClient, err := getBtcClient(conf.RPCs.Bitcoin)
if err != nil {
return runner.Clients{}, fmt.Errorf("failed to get btc client: %w", err)
}

evmClient, evmAuth, err := getEVMClient(ctx, conf.RPCs.EVM, account)
if err != nil {
return runner.Clients{}, fmt.Errorf("failed to get evm client: %w", err)
}

var solanaClient *rpc.Client
if conf.RPCs.Solana != "" {
if solanaClient = rpc.New(conf.RPCs.Solana); solanaClient == nil {
return runner.Clients{}, fmt.Errorf("failed to get solana client")
}
}

var tonClient *tonrunner.Client
if conf.RPCs.TONSidecarURL != "" {
c, err := getTONClient(ctx, conf.RPCs.TONSidecarURL)
if err != nil {
return runner.Clients{}, fmt.Errorf("failed to get ton client: %w", err)
}
tonClient = c
}

zetaCoreClients, err := GetZetacoreClient(conf)
if err != nil {
return runner.Clients{}, fmt.Errorf("failed to get zetacore client: %w", err)
}

zevmClient, zevmAuth, err := getEVMClient(ctx, conf.RPCs.Zevm, account)
if err != nil {
return runner.Clients{}, fmt.Errorf("failed to get zevm client: %w", err)
Expand All @@ -48,6 +62,7 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, account confi
Zetacore: zetaCoreClients,
BtcRPC: btcRPCClient,
Solana: solanaClient,
TON: tonClient,
Evm: evmClient,
EvmAuth: evmAuth,
Zevm: zevmClient,
Expand Down Expand Up @@ -106,6 +121,35 @@ 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")
}

sidecar := tonrunner.NewSidecarClient(sidecarURL)

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

if err != nil {
return nil, fmt.Errorf("failed to get ton config: %w", err)
}

client, err := ton.NewClient(ton.WithConfigurationFile(*cfg))
if err != nil {
return nil, fmt.Errorf("failed to create ton client: %w", err)
}

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

func GetZetacoreClient(conf config.Config) (zetacore_rpc.Clients, error) {
if conf.RPCs.ZetaCoreGRPC != "" {
return zetacore_rpc.NewGRPCClients(
Expand Down
Loading

0 comments on commit db99f8f

Please sign in to comment.