Skip to content

Commit

Permalink
Merge branch 'develop' into fix-cli-args
Browse files Browse the repository at this point in the history
  • Loading branch information
brewmaster012 authored Feb 7, 2024
2 parents d399cf5 + 4d47d4f commit 1340359
Show file tree
Hide file tree
Showing 99 changed files with 3,182 additions and 1,683 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ contrib/meta.pem.pub
dispatch_payload.json
.github/workflows/local-testing.yml


# Hardhat files
cache
localnet/artifacts
Expand Down Expand Up @@ -53,4 +52,7 @@ contrib/localnet/blockscout/services/logs/*
contrib/localnet/blockscout/services/redis-data/*
contrib/localnet/blockscout/services/stats-db-data/*
contrib/localnet/grafana/addresses.txt
contrib/localnet/addresses.txt
contrib/localnet/addresses.txt

# Config for e2e tests
e2e_conf*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ generate: proto openapi specs typescript docs-zetacored
###############################################################################

install-zetae2e: go.sum
@echo "--> Installing orchestrator"
@echo "--> Installing zetae2e"
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetae2e
.PHONY: install-zetae2e

Expand Down
20 changes: 20 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

## Unreleased

* `zetaclientd start` : 2 inputs required from stdin

### Refactor

* [1630](https://github.com/zeta-chain/node/pull/1630) added password prompts for hotkey and tss keyshare in zetaclient
Starting zetaclient now requires two passwords to be input; one for the hotkey and another for the tss key-share.

### Fixes

* [1690](https://github.com/zeta-chain/node/issues/1690) - double watched gas prices and fix btc scheduler
* [1687](https://github.com/zeta-chain/node/pull/1687) - only use EVM supported chains for gas stability pool
* [1692](https://github.com/zeta-chain/node/pull/1692) - fix get params query for emissions module

### Tests

* [1584](https://github.com/zeta-chain/node/pull/1584) - allow to run E2E tests on any networks

## Version: v12.2.4

### Fixes

* [1638](https://github.com/zeta-chain/node/issues/1638) - additional check to make sure external chain height always increases
Expand All @@ -17,6 +36,7 @@
## Version: v12.1.0

### Tests

* [1577](https://github.com/zeta-chain/node/pull/1577) - add chain header tests in E2E tests and fix admin tests

### Features
Expand Down
6 changes: 5 additions & 1 deletion cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func GenerateTss(logger zerolog.Logger,
priKey secp256k1.PrivKey,
ts *mc.TelemetryServer,
tssHistoricalList []observertypes.TSS,
metrics *metrics.Metrics) (*mc.TSS, error) {
metrics *metrics.Metrics,
tssPassword string,
hotkeyPassword string) (*mc.TSS, error) {
keygenLogger := logger.With().Str("module", "keygen").Logger()

// Bitcoin chain ID is currently used for using the correct signature format
Expand All @@ -47,6 +49,8 @@ func GenerateTss(logger zerolog.Logger,
tssHistoricalList,
metrics,
bitcoinChainID,
tssPassword,
hotkeyPassword,
)
if err != nil {
keygenLogger.Error().Err(err).Msg("NewTSS error")
Expand Down
36 changes: 33 additions & 3 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bufio"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -45,6 +46,12 @@ func start(_ *cobra.Command, _ []string) error {

SetupConfigForTest()

//Prompt for Hotkey and TSS key-share passwords
hotkeyPass, tssKeyPass, err := promptPasswords()
if err != nil {
return err
}

//Load Config file given path
cfg, err := config.Load(rootArgs.zetaCoreHome)
if err != nil {
Expand Down Expand Up @@ -77,7 +84,7 @@ func start(_ *cobra.Command, _ []string) error {

// CreateZetaBridge: Zetabridge is used for all communication to zetacore , which this client connects to.
// Zetacore accumulates votes , and provides a centralized source of truth for all clients
zetaBridge, err := CreateZetaBridge(cfg, telemetryServer)
zetaBridge, err := CreateZetaBridge(cfg, telemetryServer, hotkeyPass)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -120,7 +127,7 @@ func start(_ *cobra.Command, _ []string) error {
// The bridgePk is private key for the Hotkey. The Hotkey is used to sign all inbound transactions
// Each node processes a portion of the key stored in ~/.tss by default . Custom location can be specified in config file during init.
// After generating the key , the address is set on the zetacore
bridgePk, err := zetaBridge.GetKeys().GetPrivateKey()
bridgePk, err := zetaBridge.GetKeys().GetPrivateKey(hotkeyPass)
if err != nil {
startLogger.Error().Err(err).Msg("zetabridge getPrivateKey error")
}
Expand Down Expand Up @@ -160,7 +167,7 @@ func start(_ *cobra.Command, _ []string) error {
}

telemetryServer.SetIPAddress(cfg.PublicIP)
tss, err := GenerateTss(masterLogger, cfg, zetaBridge, peers, priKey, telemetryServer, tssHistoricalList, metrics)
tss, err := GenerateTss(masterLogger, cfg, zetaBridge, peers, priKey, telemetryServer, tssHistoricalList, metrics, tssKeyPass, hotkeyPass)
if err != nil {
return err
}
Expand Down Expand Up @@ -309,3 +316,26 @@ func initPreParams(path string) {
}
}
}

// promptPasswords() This function will prompt for passwords which will be used to decrypt two key files:
// 1. HotKey
// 2. TSS key-share
func promptPasswords() (string, string, error) {
reader := bufio.NewReader(os.Stdin)
fmt.Print("HotKey Password: ")
hotKeyPass, err := reader.ReadString('\n')
if err != nil {
return "", "", err
}
fmt.Print("TSS Password: ")
TSSKeyPass, err := reader.ReadString('\n')
if err != nil {
return "", "", err
}

if TSSKeyPass == "" {
return "", "", errors.New("tss password is required to start zetaclient")
}

return hotKeyPass, TSSKeyPass, err
}
6 changes: 3 additions & 3 deletions cmd/zetaclientd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ func CreateAuthzSigner(granter string, grantee sdk.AccAddress) {
zetaclient.SetupAuthZSignerList(granter, grantee)
}

func CreateZetaBridge(cfg *config.Config, telemetry *zetaclient.TelemetryServer) (*zetaclient.ZetaCoreBridge, error) {
func CreateZetaBridge(cfg *config.Config, telemetry *zetaclient.TelemetryServer, hotkeyPassword string) (*zetaclient.ZetaCoreBridge, error) {
hotKey := cfg.AuthzHotkey
if cfg.HsmMode {
hotKey = cfg.HsmHotKey
}

chainIP := cfg.ZetaCoreURL

kb, _, err := zetaclient.GetKeyringKeybase(cfg)
kb, _, err := zetaclient.GetKeyringKeybase(cfg, hotkeyPassword)
if err != nil {
return nil, err
}
Expand All @@ -33,7 +33,7 @@ func CreateZetaBridge(cfg *config.Config, telemetry *zetaclient.TelemetryServer)
return nil, err
}

k := zetaclient.NewKeysWithKeybase(kb, granterAddreess, cfg.AuthzHotkey)
k := zetaclient.NewKeysWithKeybase(kb, granterAddreess, cfg.AuthzHotkey, hotkeyPassword)

bridge, err := zetaclient.NewZetaCoreBridge(k, chainIP, hotKey, cfg.ChainID, cfg.HsmMode, telemetry)
if err != nil {
Expand Down
89 changes: 89 additions & 0 deletions cmd/zetae2e/balances.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package main

import (
"context"
"errors"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/app"
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/utils"
)

const flagSkipBTC = "skip-btc"

// NewBalancesCmd returns the balances command
// which shows from the key and rpc, the balance of the account on different network
func NewBalancesCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "balances [config-file]",
Short: "Show account balances on networks for E2E tests",
RunE: runBalances,
Args: cobra.ExactArgs(1),
}
cmd.Flags().Bool(
flagSkipBTC,
false,
"skip the BTC network",
)
return cmd
}

func runBalances(cmd *cobra.Command, args []string) error {
// read the config file
conf, err := config.ReadConfig(args[0])
if err != nil {
return err
}

skipBTC, err := cmd.Flags().GetBool(flagSkipBTC)
if err != nil {
return err
}

// initialize logger
logger := runner.NewLogger(false, color.FgHiCyan, "")

// set config
app.SetConfig()

// initialize context
ctx, cancel := context.WithCancel(context.Background())

// get EVM address from config
evmAddr := conf.Accounts.EVMAddress
if !ethcommon.IsHexAddress(evmAddr) {
cancel()
return errors.New("invalid EVM address")
}

// initialize deployer runner with config
r, err := zetae2econfig.RunnerFromConfig(
ctx,
"e2e",
cancel,
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
cancel()
return err
}

balances, err := r.GetAccountBalances(skipBTC)
if err != nil {
cancel()
return err
}
r.PrintAccountBalances(balances)

return nil
}
92 changes: 92 additions & 0 deletions cmd/zetae2e/bitcoin_address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package main

import (
"context"
"errors"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/app"
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/config"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/runner"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/utils"
)

const flagPrivKey = "privkey"

// NewBitcoinAddressCmd returns the bitcoin address command
// which shows from the used config file, the bitcoin address that can be used to receive funds for the E2E tests
func NewBitcoinAddressCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "bitcoin-address [config-file] ",
Short: "Show Bitcoin address to receive funds for E2E tests",
RunE: runBitcoinAddress,
Args: cobra.ExactArgs(1),
}
cmd.Flags().Bool(
flagPrivKey,
false,
"show the priv key in WIF format",
)
return cmd
}

func runBitcoinAddress(cmd *cobra.Command, args []string) error {
showPrivKey, err := cmd.Flags().GetBool(flagPrivKey)
if err != nil {
return err
}

// read the config file
conf, err := config.ReadConfig(args[0])
if err != nil {
return err
}

// initialize logger
logger := runner.NewLogger(false, color.FgHiYellow, "")

// set config
app.SetConfig()

// initialize context
ctx, cancel := context.WithCancel(context.Background())

// get EVM address from config
evmAddr := conf.Accounts.EVMAddress
if !ethcommon.IsHexAddress(evmAddr) {
cancel()
return errors.New("invalid EVM address")
}

// initialize deployer runner with config
r, err := zetae2econfig.RunnerFromConfig(
ctx,
"e2e",
cancel,
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
cancel()
return err
}

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

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

return nil
}
Loading

0 comments on commit 1340359

Please sign in to comment.