Skip to content

Commit

Permalink
Merge branch 'develop' into cctx-validate-inbound
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Jun 19, 2024
2 parents 2c2d7e5 + 3c4ea97 commit 86c1f5c
Show file tree
Hide file tree
Showing 105 changed files with 1,814 additions and 3,700 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @brewmaster012 @kingpinXD @lumtis @ws4charlie @skosito
* @brewmaster012 @kingpinXD @lumtis @ws4charlie @skosito @swift1337

.github/** @zeta-chain/devops
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/syncing.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Having difficulties setting up or syncing a node
description: Please fill out the following form to help us understand and resolve your issue with setting up or syncing a node. Provide as much detail as possible to ensure a quick and accurate resolution.
labels: ["infra"]
body:
- type: dropdown
attributes:
Expand All @@ -10,14 +11,14 @@ body:
- type: dropdown
attributes:
label: Does your machine match the technical requirements?
description: See https://www.zetachain.com/docs/validators/requirements/
description: See https://www.zetachain.com/docs/nodes/start-here/requirements/
options:
- "Yes"
- "No"
- type: dropdown
attributes:
label: Have you completed the setup?
description: See https://www.zetachain.com/docs/validators/setup/
description: See https://www.zetachain.com/docs/nodes/start-here/setup/
options:
- "Yes"
- "No"
Expand All @@ -30,10 +31,10 @@ body:
- KSYNC
- type: dropdown
attributes:
label: Did you build your binary from source or download it from the Releases[https://github.com/zeta-chain/node/releases] page?
description: We recommend using binaries from our releases page.
label: Did you build your binary from source or download it from the Releases page?
description: "We recommend using binaries from our Releases page: https://github.com/zeta-chain/node/releases"
options:
- "Downloaded from releases page"
- "Downloaded from Releases page"
- "Built locally"
- type: textarea
attributes:
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ RUN mkdir -p /root/.zetacored/cosmovisor/genesis/bin && \
ENV PATH /root/.zetacored/cosmovisor/current/bin/:/root/.zetaclientd/upgrades/current/:${PATH}

COPY contrib/localnet/scripts /root
COPY contrib/localnet/preparams /root/preparams
COPY contrib/localnet/ssh_config /root/.ssh/config
COPY contrib/localnet/zetacored /root/zetacored
COPY contrib/localnet/tss /root/tss

RUN chmod 755 /root/*.sh

Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* [2296](https://github.com/zeta-chain/node/pull/2296) - move `testdata` package to `testutil` to organize test-related utilities
* [2317](https://github.com/zeta-chain/node/pull/2317) - add ValidateOutbound method for cctx orchestrator
* [2340](https://github.com/zeta-chain/node/pull/2340) - add ValidateInbound method for cctx orchestrator
* [2344](https://github.com/zeta-chain/node/pull/2344) - group common data of EVM/Bitcoin signer and observer using base structs

### Tests

Expand All @@ -58,6 +59,8 @@
* [2240](https://github.com/zeta-chain/node/pull/2240) - removed hard-coded Bitcoin regnet chainID in E2E withdraw tests
* [2266](https://github.com/zeta-chain/node/pull/2266) - try fixing E2E test `crosschain_swap` failure `btc transaction not signed`
* [2294](https://github.com/zeta-chain/node/pull/2294) - add and fix existing ethermint rpc unit test
* [2329](https://github.com/zeta-chain/node/pull/2329) - fix TODOs in rpc unit tests
* [2342](https://github.com/zeta-chain/node/pull/2342) - extend rpc unit tests with testing extension to include synthetic ethereum txs
* [2299](https://github.com/zeta-chain/node/pull/2299) - add `zetae2e` command to deploy test contracts

### Fixes
Expand All @@ -68,6 +71,7 @@
* [2233](https://github.com/zeta-chain/node/pull/2233) - fix `IsSupported` flag not properly updated in zetaclient's context
* [2243](https://github.com/zeta-chain/node/pull/2243) - fix incorrect bitcoin outbound height in the CCTX outbound parameter
* [2256](https://github.com/zeta-chain/node/pull/2256) - fix rate limiter falsely included reverted non-withdraw cctxs
* [2327](https://github.com/zeta-chain/node/pull/2327) - partially cherry picked the fix to Bitcoin outbound dust amount

### CI

Expand Down
64 changes: 0 additions & 64 deletions cmd/zetaclientd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,15 @@ package main
import (
"math/rand"
"os"
"path/filepath"
"time"

ecdsakeygen "github.com/binance-chain/tss-lib/ecdsa/keygen"
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/types"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"

"github.com/zeta-chain/zetacore/app"
"github.com/zeta-chain/zetacore/cmd"
clientcommon "github.com/zeta-chain/zetacore/zetaclient/common"
"github.com/zeta-chain/zetacore/zetaclient/config"
)

const (
ComplianceLogFile = "compliance.log"
)

var (
Expand Down Expand Up @@ -53,58 +44,3 @@ func SetupConfigForTest() {
rand.Seed(time.Now().UnixNano())

}

func InitLogger(cfg config.Config) (clientcommon.ClientLogger, error) {
// open compliance log file
file, err := OpenComplianceLogFile(cfg)
if err != nil {
return clientcommon.DefaultLoggers(), err
}

var logger zerolog.Logger
var loggerCompliance zerolog.Logger
switch cfg.LogFormat {
case "json":
logger = zerolog.New(os.Stdout).Level(zerolog.Level(cfg.LogLevel)).With().Timestamp().Logger()
loggerCompliance = zerolog.New(file).Level(zerolog.Level(cfg.LogLevel)).With().Timestamp().Logger()
case "text":
logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339}).
Level(zerolog.Level(cfg.LogLevel)).
With().
Timestamp().
Logger()
loggerCompliance = zerolog.New(file).Level(zerolog.Level(cfg.LogLevel)).With().Timestamp().Logger()
default:
logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339})
loggerCompliance = zerolog.New(file).With().Timestamp().Logger()
}

if cfg.LogSampler {
logger = logger.Sample(&zerolog.BasicSampler{N: 5})
}
log.Logger = logger // set global logger

return clientcommon.ClientLogger{
Std: log.Logger,
Compliance: loggerCompliance,
}, nil
}

func OpenComplianceLogFile(cfg config.Config) (*os.File, error) {
// use zetacore home as default
logPath := cfg.ZetaCoreHome
if cfg.ComplianceConfig.LogPath != "" {
logPath = cfg.ComplianceConfig.LogPath
}

// clean file name
name := filepath.Join(logPath, ComplianceLogFile)
name, err := filepath.Abs(name)
if err != nil {
return nil, err
}
name = filepath.Clean(name)

// open (or create) compliance log file
return os.OpenFile(name, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
}
9 changes: 5 additions & 4 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/zeta-chain/zetacore/pkg/authz"
"github.com/zeta-chain/zetacore/pkg/constant"
observerTypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/chains/base"
"github.com/zeta-chain/zetacore/zetaclient/config"
"github.com/zeta-chain/zetacore/zetaclient/context"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
Expand Down Expand Up @@ -61,7 +62,7 @@ func start(_ *cobra.Command, _ []string) error {
if err != nil {
return err
}
loggers, err := InitLogger(cfg)
logger, err := base.InitLogger(cfg)
if err != nil {
log.Error().Err(err).Msg("InitLogger failed")
return err
Expand All @@ -76,7 +77,7 @@ func start(_ *cobra.Command, _ []string) error {
}
}

masterLogger := loggers.Std
masterLogger := logger.Std
startLogger := masterLogger.With().Str("module", "startup").Logger()

// Wait until zetacore is up
Expand Down Expand Up @@ -267,7 +268,7 @@ func start(_ *cobra.Command, _ []string) error {
}

// CreateSignerMap: This creates a map of all signers for each chain . Each signer is responsible for signing transactions for a particular chain
signerMap, err := CreateSignerMap(appContext, tss, loggers, telemetryServer)
signerMap, err := CreateSignerMap(appContext, tss, logger, telemetryServer)
if err != nil {
log.Error().Err(err).Msg("CreateSignerMap")
return err
Expand All @@ -281,7 +282,7 @@ func start(_ *cobra.Command, _ []string) error {
dbpath := filepath.Join(userDir, ".zetaclient/chainobserver")

// Creates a map of all chain observers for each chain. Each chain observer is responsible for observing events on the chain and processing them.
observerMap, err := CreateChainObserverMap(appContext, zetacoreClient, tss, dbpath, loggers, telemetryServer)
observerMap, err := CreateChainObserverMap(appContext, zetacoreClient, tss, dbpath, logger, telemetryServer)
if err != nil {
startLogger.Err(err).Msg("CreateChainObserverMap")
return err
Expand Down
26 changes: 13 additions & 13 deletions cmd/zetaclientd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
ethcommon "github.com/ethereum/go-ethereum/common"

"github.com/zeta-chain/zetacore/zetaclient/authz"
"github.com/zeta-chain/zetacore/zetaclient/chains/base"
btcobserver "github.com/zeta-chain/zetacore/zetaclient/chains/bitcoin/observer"
btcsigner "github.com/zeta-chain/zetacore/zetaclient/chains/bitcoin/signer"
evmobserver "github.com/zeta-chain/zetacore/zetaclient/chains/evm/observer"
evmsigner "github.com/zeta-chain/zetacore/zetaclient/chains/evm/signer"
"github.com/zeta-chain/zetacore/zetaclient/chains/interfaces"
clientcommon "github.com/zeta-chain/zetacore/zetaclient/common"
"github.com/zeta-chain/zetacore/zetaclient/config"
"github.com/zeta-chain/zetacore/zetaclient/context"
"github.com/zeta-chain/zetacore/zetaclient/keys"
Expand Down Expand Up @@ -57,7 +57,7 @@ func CreateZetacoreClient(
func CreateSignerMap(
appContext *context.AppContext,
tss interfaces.TSSSigner,
loggers clientcommon.ClientLogger,
logger base.Logger,
ts *metrics.TelemetryServer,
) (map[int64]interfaces.ChainSigner, error) {
coreContext := appContext.ZetacoreContext()
Expand All @@ -70,7 +70,7 @@ func CreateSignerMap(
}
evmChainParams, found := coreContext.GetEVMChainParams(evmConfig.Chain.ChainId)
if !found {
loggers.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
logger.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
continue
}
mpiAddress := ethcommon.HexToAddress(evmChainParams.ConnectorContractAddress)
Expand All @@ -84,20 +84,20 @@ func CreateSignerMap(
mpiAddress,
erc20CustodyAddress,
coreContext,
loggers,
logger,
ts)
if err != nil {
loggers.Std.Error().Err(err).Msgf("NewEVMSigner error for chain %s", evmConfig.Chain.String())
logger.Std.Error().Err(err).Msgf("NewEVMSigner error for chain %s", evmConfig.Chain.String())
continue
}
signerMap[evmConfig.Chain.ChainId] = signer
}
// BTC signer
btcChain, btcConfig, enabled := appContext.GetBTCChainAndConfig()
if enabled {
signer, err := btcsigner.NewSigner(btcConfig, tss, loggers, ts, coreContext)
signer, err := btcsigner.NewSigner(btcConfig, tss, logger, ts, coreContext)
if err != nil {
loggers.Std.Error().Err(err).Msgf("NewBTCSigner error for chain %s", btcChain.String())
logger.Std.Error().Err(err).Msgf("NewBTCSigner error for chain %s", btcChain.String())
} else {
signerMap[btcChain.ChainId] = signer
}
Expand All @@ -112,7 +112,7 @@ func CreateChainObserverMap(
zetacoreClient *zetacore.Client,
tss interfaces.TSSSigner,
dbpath string,
loggers clientcommon.ClientLogger,
logger base.Logger,
ts *metrics.TelemetryServer,
) (map[int64]interfaces.ChainObserver, error) {
observerMap := make(map[int64]interfaces.ChainObserver)
Expand All @@ -123,22 +123,22 @@ func CreateChainObserverMap(
}
_, found := appContext.ZetacoreContext().GetEVMChainParams(evmConfig.Chain.ChainId)
if !found {
loggers.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
logger.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
continue
}
co, err := evmobserver.NewObserver(appContext, zetacoreClient, tss, dbpath, loggers, evmConfig, ts)
co, err := evmobserver.NewObserver(appContext, zetacoreClient, tss, dbpath, logger, evmConfig, ts)
if err != nil {
loggers.Std.Error().Err(err).Msgf("NewObserver error for evm chain %s", evmConfig.Chain.String())
logger.Std.Error().Err(err).Msgf("NewObserver error for evm chain %s", evmConfig.Chain.String())
continue
}
observerMap[evmConfig.Chain.ChainId] = co
}
// BTC observer
btcChain, btcConfig, enabled := appContext.GetBTCChainAndConfig()
if enabled {
co, err := btcobserver.NewObserver(appContext, btcChain, zetacoreClient, tss, dbpath, loggers, btcConfig, ts)
co, err := btcobserver.NewObserver(appContext, btcChain, zetacoreClient, tss, dbpath, logger, btcConfig, ts)
if err != nil {
loggers.Std.Error().Err(err).Msgf("NewObserver error for bitcoin chain %s", btcChain.String())
logger.Std.Error().Err(err).Msgf("NewObserver error for bitcoin chain %s", btcChain.String())

} else {
observerMap[btcChain.ChainId] = co
Expand Down
4 changes: 0 additions & 4 deletions cmd/zetae2e/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import (

"github.com/zeta-chain/zetacore/app"
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
"github.com/zeta-chain/zetacore/cmd/zetae2e/local"
"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
)

const flagSkipBTC = "skip-btc"
Expand Down Expand Up @@ -71,8 +69,6 @@ func runBalances(cmd *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
local.FungibleAdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions cmd/zetae2e/bitcoin_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import (

"github.com/zeta-chain/zetacore/app"
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
"github.com/zeta-chain/zetacore/cmd/zetae2e/local"
"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
)

const flagPrivKey = "privkey"
Expand Down Expand Up @@ -71,8 +69,6 @@ func runBitcoinAddress(cmd *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
local.FungibleAdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
17 changes: 2 additions & 15 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/txserver"
)

// RunnerFromConfig create test runner from config
Expand All @@ -19,9 +18,8 @@ func RunnerFromConfig(
conf config.Config,
evmUserAddr ethcommon.Address,
evmUserPrivKey string,
zetaUserName string,
zetaUserMnemonic string,
logger *runner.Logger,
opts ...runner.E2ERunnerOption,
) (*runner.E2ERunner, error) {
// initialize clients
btcRPCClient,
Expand All @@ -39,16 +37,6 @@ func RunnerFromConfig(
if err != nil {
return nil, fmt.Errorf("failed to get clients from config: %w", err)
}
// initialize client to send messages to ZetaChain
zetaTxServer, err := txserver.NewZetaTxServer(
conf.RPCs.ZetaCoreRPC,
[]string{zetaUserName},
[]string{zetaUserMnemonic},
conf.ZetaChainID,
)
if err != nil {
return nil, fmt.Errorf("failed to initialize ZetaChain tx server: %w", err)
}

// initialize E2E test runner
newRunner := runner.NewE2ERunner(
Expand All @@ -57,11 +45,9 @@ func RunnerFromConfig(
ctxCancel,
evmUserAddr,
evmUserPrivKey,
zetaUserMnemonic,
evmClient,
zevmClient,
cctxClient,
zetaTxServer,
fungibleClient,
authClient,
bankClient,
Expand All @@ -71,6 +57,7 @@ func RunnerFromConfig(
zevmAuth,
btcRPCClient,
logger,
opts...,
)

// set contracts
Expand Down
Loading

0 comments on commit 86c1f5c

Please sign in to comment.