Skip to content

Commit

Permalink
conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Mar 22, 2024
2 parents f34ad21 + 1655c34 commit 43c747a
Show file tree
Hide file tree
Showing 93 changed files with 2,796 additions and 808 deletions.
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ install-zetaclient-race-test-only-build: go.sum
@echo "--> Installing zetaclientd"
@go install -race -mod=readonly $(BUILD_FLAGS) ./cmd/zetaclientd

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

###############################################################################
### Local network ###
###############################################################################
Expand Down Expand Up @@ -286,4 +290,17 @@ mainnet-bitcoind-node:
cd contrib/mainnet/bitcoind && DOCKER_TAG=$(DOCKER_TAG) docker-compose up

athens3-zetarpc-node:
cd contrib/athens3/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up
cd contrib/athens3/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up

###############################################################################
### Debug Tools ###
###############################################################################

filter-missed-btc: install-zetatool
zetatool filterdeposit btc --config ./tool/filter_missed_deposits/zetatool_config.json

filter-missed-eth: install-zetatool
zetatool filterdeposit eth \
--config ./tool/filter_missed_deposits/zetatool_config.json \
--evm-max-range 1000 \
--evm-start-block 19464041
15 changes: 14 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
* [1783](https://github.com/zeta-chain/node/pull/1783) - refactor zetaclient metrics naming and structure
* [1774](https://github.com/zeta-chain/node/pull/1774) - split params and config in zetaclient
* [1831](https://github.com/zeta-chain/node/pull/1831) - removing unnecessary pointers in context structure
* [1864](https://github.com/zeta-chain/node/pull/1864) - prevent panic in param management
* [1848](https://github.com/zeta-chain/node/issues/1848) - create a method to observe deposits to tss address in one evm block
* [1885](https://github.com/zeta-chain/node/pull/1885) - change important metrics on port 8123 to be prometheus compatible
* [1863](https://github.com/zeta-chain/node/pull/1863) - remove duplicate ValidateChainParams function

### Features

* [1789](https://github.com/zeta-chain/node/issues/1789) - block cross-chain transactions that involve restricted addresses
* [1755](https://github.com/zeta-chain/node/issues/1755) - use evm JSON RPC for inbound tx (including blob tx) observation.
* [1815](https://github.com/zeta-chain/node/pull/1815) - add authority module for authorized actions
* [1884](https://github.com/zeta-chain/node/pull/1884) - added zetatool cmd, added subcommand to filter deposits

### Tests

Expand All @@ -31,15 +34,19 @@
* [1791](https://github.com/zeta-chain/node/pull/1791) - add e2e tests for feature of restricted address
* [1787](https://github.com/zeta-chain/node/pull/1787) - add unit tests for cross-chain evm hooks and e2e test failed withdraw to BTC legacy address
* [1840](https://github.com/zeta-chain/node/pull/1840) - fix code coverage test failures ignored in CI
* [1870](https://github.com/zeta-chain/node/pull/1870) - enable emissions pool in local e2e testing
* [1868](https://github.com/zeta-chain/node/pull/1868) - run e2e btc tests locally
* [1851](https://github.com/zeta-chain/node/pull/1851) - rename usdt to erc20 in e2e tests
* [1872](https://github.com/zeta-chain/node/pull/1872) - remove usage of RPC in unit test
* [1805](https://github.com/zeta-chain/node/pull/1805) - add admin and performance test and fix upgrade test
* [1879](https://github.com/zeta-chain/node/pull/1879) - full coverage for messages in types packages
* [1899](https://github.com/zeta-chain/node/pull/1899) - add empty test files so packages are included in coverage

### Fixes

* [1861](https://github.com/zeta-chain/node/pull/1861) - fix `ObserverSlashAmount` invalid read
* [1880](https://github.com/zeta-chain/node/issues/1880) - lower the gas price multiplier for EVM chains.
* [1633](https://github.com/zeta-chain/node/issues/1633) - zetaclient should be able to pick up new connector and erc20Custody addresses

### Chores

Expand All @@ -51,7 +58,13 @@
* [1891](https://github.com/zeta-chain/node/pull/1891) - fix typo that was introduced to docker-compose and a typo in start.sh for the docker start script for full nodes.
* [1894](https://github.com/zeta-chain/node/pull/1894) - added download binaries and configs to the start sequence so it will download binaries that don't exist

## Version: v14
## Version: v15.0.0

### Features

*[1912](https://github.com/zeta-chain/node/pull/1912) - add reset chain nonces msg

## Version: v14.0.1

- [1817](https://github.com/zeta-chain/node/pull/1817) - Add migration script to fix pending and chain nonces on testnet

Expand Down
21 changes: 10 additions & 11 deletions cmd/zetaclientd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
sdk "github.com/cosmos/cosmos-sdk/types"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/zeta-chain/zetacore/common"
"github.com/zeta-chain/zetacore/common/cosmos"
appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context"
"github.com/zeta-chain/zetacore/zetaclient/authz"
Expand Down Expand Up @@ -55,8 +54,8 @@ func CreateSignerMap(
tss interfaces.TSSSigner,
loggers clientcommon.ClientLogger,
ts *metrics.TelemetryServer,
) (map[common.Chain]interfaces.ChainSigner, error) {
signerMap := make(map[common.Chain]interfaces.ChainSigner)
) (map[int64]interfaces.ChainSigner, error) {
signerMap := make(map[int64]interfaces.ChainSigner)
// EVM signers
for _, evmConfig := range appContext.Config().GetAllEVMConfigs() {
if evmConfig.Chain.IsZetaChain() {
Expand All @@ -77,7 +76,7 @@ func CreateSignerMap(
loggers.Std.Error().Err(err).Msgf("NewEVMSigner error for chain %s", evmConfig.Chain.String())
continue
}
signerMap[evmConfig.Chain] = signer
signerMap[evmConfig.Chain.ChainId] = signer
}
// BTC signer
btcChain, btcConfig, enabled := appContext.GetBTCChainAndConfig()
Expand All @@ -86,7 +85,7 @@ func CreateSignerMap(
if err != nil {
loggers.Std.Error().Err(err).Msgf("NewBTCSigner error for chain %s", btcChain.String())
} else {
signerMap[btcChain] = signer
signerMap[btcChain.ChainId] = signer
}
}

Expand All @@ -100,8 +99,8 @@ func CreateChainClientMap(
dbpath string,
loggers clientcommon.ClientLogger,
ts *metrics.TelemetryServer,
) (map[common.Chain]interfaces.ChainClient, error) {
clientMap := make(map[common.Chain]interfaces.ChainClient)
) (map[int64]interfaces.ChainClient, error) {
clientMap := make(map[int64]interfaces.ChainClient)
// EVM clients
for _, evmConfig := range appContext.Config().GetAllEVMConfigs() {
if evmConfig.Chain.IsZetaChain() {
Expand All @@ -120,17 +119,17 @@ func CreateChainClientMap(
loggers.Std.Error().Err(err).Msgf("NewEVMChainClient error for chain %s", evmConfig.Chain.String())
continue
}
clientMap[evmConfig.Chain] = co
clientMap[evmConfig.Chain.ChainId] = co
}
// BTC client
btcChain, _, enabled := appContext.GetBTCChainAndConfig()
btcChain, btcConfig, enabled := appContext.GetBTCChainAndConfig()
if enabled {
co, err := bitcoin.NewBitcoinClient(appContext, btcChain, bridge, tss, dbpath, loggers, ts)
co, err := bitcoin.NewBitcoinClient(appContext, btcChain, bridge, tss, dbpath, loggers, btcConfig, ts)
if err != nil {
loggers.Std.Error().Err(err).Msgf("NewBitcoinClient error for chain %s", btcChain.String())

} else {
clientMap[btcChain] = co
clientMap[btcChain.ChainId] = co
}
}

Expand Down
100 changes: 35 additions & 65 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,71 +44,19 @@ func NewLocalCmd() *cobra.Command {
Short: "Run Local E2E tests",
Run: localE2ETest,
}
cmd.Flags().Bool(
flagContractsDeployed,
false,
"set to to true if running tests again with existing state",
)
cmd.Flags().Int64(
flagWaitForHeight,
0,
"block height for tests to begin, ex. --wait-for 100",
)
cmd.Flags().String(
FlagConfigFile,
"",
"config file to use for the tests",
)
cmd.Flags().String(
flagConfigOut,
"",
"config file to write the deployed contracts from the setup",
)
cmd.Flags().Bool(
flagVerbose,
false,
"set to true to enable verbose logging",
)
cmd.Flags().Bool(
flagTestAdmin,
false,
"set to true to run admin tests",
)
cmd.Flags().Bool(
flagTestPerformance,
false,
"set to true to run performance tests",
)
cmd.Flags().Bool(
flagTestCustom,
false,
"set to true to run custom tests",
)
cmd.Flags().Bool(
flagSkipRegular,
false,
"set to true to skip regular tests",
)
cmd.Flags().Bool(
flagLight,
false,
"run the most basic regular tests, useful for quick checks",
)
cmd.Flags().Bool(
flagSetupOnly,
false,
"set to true to only setup the networks",
)
cmd.Flags().Bool(
flagSkipSetup,
false,
"set to true to skip setup",
)
cmd.Flags().Bool(
flagSkipBitcoinSetup,
false,
"set to true to skip bitcoin wallet setup",
)
cmd.Flags().Bool(flagContractsDeployed, false, "set to to true if running tests again with existing state")
cmd.Flags().Int64(flagWaitForHeight, 0, "block height for tests to begin, ex. --wait-for 100")
cmd.Flags().String(FlagConfigFile, "", "config file to use for the tests")
cmd.Flags().Bool(flagVerbose, false, "set to true to enable verbose logging")
cmd.Flags().Bool(flagTestAdmin, false, "set to true to run admin tests")
cmd.Flags().Bool(flagTestPerformance, false, "set to true to run performance tests")
cmd.Flags().Bool(flagTestCustom, false, "set to true to run custom tests")
cmd.Flags().Bool(flagSkipRegular, false, "set to true to skip regular tests")
cmd.Flags().Bool(flagLight, false, "run the most basic regular tests, useful for quick checks")
cmd.Flags().Bool(flagSetupOnly, false, "set to true to only setup the networks")
cmd.Flags().String(flagConfigOut, "", "config file to write the deployed contracts from the setup")
cmd.Flags().Bool(flagSkipSetup, false, "set to true to skip setup")
cmd.Flags().Bool(flagSkipBitcoinSetup, false, "set to true to skip bitcoin wallet setup")

return cmd
}
Expand Down Expand Up @@ -242,7 +190,16 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
startTime := time.Now()
deployerRunner.SetupEVM(contractsDeployed)
deployerRunner.SetZEVMContracts()

// NOTE: this method return an error so we handle it and panic if it occurs unlike other method that panics directly
// TODO: all methods should return errors instead of panicking and this current function should also return an error
// https://github.com/zeta-chain/node/issues/1500
if err := deployerRunner.FundEmissionsPool(); err != nil {
panic(err)
}

deployerRunner.MintERC20OnEvm(10000)

logger.Print("✅ setup completed in %s", time.Since(startTime))
}

Expand Down Expand Up @@ -347,4 +304,17 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
}

logger.Print("✅ e2e tests completed in %s", time.Since(testStartTime).String())

// print and validate report
networkReport, err := deployerRunner.GenerateNetworkReport()
if err != nil {
logger.Print("❌ failed to generate network report %v", err)
}
deployerRunner.PrintNetworkReport(networkReport)
if err := networkReport.Validate(); err != nil {
logger.Print("❌ network report validation failed %v", err)
os.Exit(1)
}

os.Exit(0)
}
71 changes: 71 additions & 0 deletions cmd/zetatool/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package config

import (
"encoding/json"

"github.com/spf13/afero"
)

var AppFs = afero.NewOsFs()

const (
FlagConfig = "config"
defaultCfgFileName = "zetatool_config.json"
ZetaURL = "127.0.0.1:1317"
BtcExplorerURL = "https://blockstream.info/api/"
EthRPCURL = "https://ethereum-rpc.publicnode.com"
ConnectorAddress = "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a"
CustodyAddress = "0x0000030Ec64DF25301d8414eE5a29588C4B0dE10"
)

// Config is a struct the defines the configuration fields used by zetatool
type Config struct {
ZetaURL string
BtcExplorerURL string
EthRPCURL string
EtherscanAPIkey string
ConnectorAddress string
CustodyAddress string
}

func DefaultConfig() *Config {
return &Config{
ZetaURL: ZetaURL,
BtcExplorerURL: BtcExplorerURL,
EthRPCURL: EthRPCURL,
ConnectorAddress: ConnectorAddress,
CustodyAddress: CustodyAddress,
}
}

func (c *Config) Save() error {
file, err := json.MarshalIndent(c, "", " ")
if err != nil {
return err
}
err = afero.WriteFile(AppFs, defaultCfgFileName, file, 0600)
return err
}

func (c *Config) Read(filename string) error {
data, err := afero.ReadFile(AppFs, filename)
if err != nil {
return err
}
err = json.Unmarshal(data, c)
return err
}

func GetConfig(filename string) (*Config, error) {
//Check if cfgFile is empty, if so return default Config and save to file
if filename == "" {
cfg := DefaultConfig()
err := cfg.Save()
return cfg, err
}

//if file is specified, open file and return struct
cfg := &Config{}
err := cfg.Read(filename)
return cfg, err
}
Loading

0 comments on commit 43c747a

Please sign in to comment.