Skip to content

Commit

Permalink
Remove chain.Chain from zetaclientd config
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Nov 11, 2024
1 parent 7c70809 commit b667e17
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 55 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* [3118](https://github.com/zeta-chain/node/pull/3118) - zetaclient: remove hsm signer
* [3122](https://github.com/zeta-chain/node/pull/3122) - improve & refactor zetaclientd cli
* [3125](https://github.com/zeta-chain/node/pull/3125) - drop support for header proofs
* [3137](https://github.com/zeta-chain/node/pull/3137) - remove chain.Chain from zetaclientd config

### Fixes
* [3041](https://github.com/zeta-chain/node/pull/3041) - replace libp2p public DHT with private gossip peer discovery and connection gater for inbound connections
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Start(_ *cobra.Command, _ []string) error {
chains.Network_solana.String(): solanaKeyPass,
}

//Load Config file given path
// Load Config file given path
cfg, err := config.Load(globalOpts.ZetacoreHome)
if err != nil {
return err
Expand Down
4 changes: 0 additions & 4 deletions zetaclient/chains/evm/observer/observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func getAppContext(
// create config
cfg := config.New(false)
cfg.EVMChainConfigs[evmChain.ChainId] = config.EVMConfig{
Chain: evmChain,
Endpoint: endpoint,
}

Expand Down Expand Up @@ -178,7 +177,6 @@ func Test_NewObserver(t *testing.T) {
{
name: "should be able to create observer",
evmCfg: config.EVMConfig{
Chain: chain,
Endpoint: "http://localhost:8545",
},
chainParams: params,
Expand All @@ -192,7 +190,6 @@ func Test_NewObserver(t *testing.T) {
{
name: "should fail if RPC call fails",
evmCfg: config.EVMConfig{
Chain: chain,
Endpoint: "http://localhost:8545",
},
chainParams: params,
Expand All @@ -212,7 +209,6 @@ func Test_NewObserver(t *testing.T) {
{
name: "should fail on invalid ENV var",
evmCfg: config.EVMConfig{
Chain: chain,
Endpoint: "http://localhost:8545",
},
chainParams: params,
Expand Down
27 changes: 3 additions & 24 deletions zetaclient/config/config_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ func New(setDefaults bool) Config {
// bitcoinConfigRegnet contains Bitcoin config for regnet
func bitcoinConfigRegnet() BTCConfig {
return BTCConfig{
RPCUsername: "smoketest", // smoketest is the previous name for E2E test, we keep this name for compatibility between client versions in upgrade test
// `smoketest` is the previous name for E2E test,
// we keep this name for compatibility between client versions in upgrade test
RPCUsername: "smoketest",
RPCPassword: "123",
RPCHost: "bitcoin:18443",
RPCParams: "regtest",
Expand All @@ -59,30 +61,7 @@ func tonConfigLocalnet() TONConfig {
// it contains list of EVM chains with empty endpoint except for localnet
func evmChainsConfigs() map[int64]EVMConfig {
return map[int64]EVMConfig{
chains.Ethereum.ChainId: {
Chain: chains.Ethereum,
},
chains.BscMainnet.ChainId: {
Chain: chains.BscMainnet,
},
chains.Goerli.ChainId: {
Chain: chains.Goerli,
Endpoint: "",
},
chains.Sepolia.ChainId: {
Chain: chains.Sepolia,
Endpoint: "",
},
chains.BscTestnet.ChainId: {
Chain: chains.BscTestnet,
Endpoint: "",
},
chains.Mumbai.ChainId: {
Chain: chains.Mumbai,
Endpoint: "",
},
chains.GoerliLocalnet.ChainId: {
Chain: chains.GoerliLocalnet,
Endpoint: "http://eth:8545",
RPCAlertLatency: 60,
},
Expand Down
5 changes: 1 addition & 4 deletions zetaclient/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"sync"

"github.com/showa-93/go-mask"

"github.com/zeta-chain/node/pkg/chains"
)

// KeyringBackend is the type of keyring backend to use for the hotkey
Expand Down Expand Up @@ -40,7 +38,6 @@ type ClientConfiguration struct {

// EVMConfig is the config for EVM chain
type EVMConfig struct {
Chain chains.Chain
Endpoint string `mask:"filled"`
RPCAlertLatency int64
}
Expand Down Expand Up @@ -216,7 +213,7 @@ func (c Config) GetRelayerKeyPath() string {
}

func (c EVMConfig) Empty() bool {
return c.Endpoint == "" || c.Chain.IsEmpty()
return c.Endpoint == ""
}

func (c BTCConfig) Empty() bool {
Expand Down
17 changes: 0 additions & 17 deletions zetaclient/config/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func Test_GetRelayerKeyPath(t *testing.T) {
}

func Test_GetEVMConfig(t *testing.T) {
chain := chains.Sepolia
chainID := chains.Sepolia.ChainId

t.Run("should find non-empty evm config", func(t *testing.T) {
Expand All @@ -26,7 +25,6 @@ func Test_GetEVMConfig(t *testing.T) {

// set valid evm endpoint
cfg.EVMChainConfigs[chainID] = config.EVMConfig{
Chain: chain,
Endpoint: "localhost",
}

Expand All @@ -44,21 +42,6 @@ func Test_GetEVMConfig(t *testing.T) {
_, found := cfg.GetEVMConfig(chainID)
require.False(t, found)
})

t.Run("should not find evm config if chain is empty", func(t *testing.T) {
// create config with defaults
cfg := config.New(true)

// set empty chain
cfg.EVMChainConfigs[chainID] = config.EVMConfig{
Chain: chains.Chain{},
Endpoint: "localhost",
}

// should not find evm config because chain is empty
_, found := cfg.GetEVMConfig(chainID)
require.False(t, found)
})
}

func Test_GetBTCConfig(t *testing.T) {
Expand Down
4 changes: 0 additions & 4 deletions zetaclient/orchestrator/bootstap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ func TestCreateSignerMap(t *testing.T) {
cfg := config.New(false)

cfg.EVMChainConfigs[chains.Ethereum.ChainId] = config.EVMConfig{
Chain: chains.Ethereum,
Endpoint: testutils.MockEVMRPCEndpoint,
}

cfg.EVMChainConfigs[chains.Polygon.ChainId] = config.EVMConfig{
Chain: chains.Polygon,
Endpoint: testutils.MockEVMRPCEndpoint,
}

Expand Down Expand Up @@ -225,12 +223,10 @@ func TestCreateChainObserverMap(t *testing.T) {
cfg := config.New(false)

cfg.EVMChainConfigs[chains.Ethereum.ChainId] = config.EVMConfig{
Chain: chains.Ethereum,
Endpoint: evmServer.Endpoint,
}

cfg.EVMChainConfigs[chains.Polygon.ChainId] = config.EVMConfig{
Chain: chains.Polygon,
Endpoint: evmServer.Endpoint,
}

Expand Down
2 changes: 1 addition & 1 deletion zetaclient/orchestrator/orchestrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ func createAppContext(t *testing.T, chainsOrParams ...any) *zctx.AppContext {
for _, c := range supportedChains {
switch {
case chains.IsEVMChain(c.ChainId, nil):
cfg.EVMChainConfigs[c.ChainId] = config.EVMConfig{Chain: c}
cfg.EVMChainConfigs[c.ChainId] = config.EVMConfig{Endpoint: "localhost"}
case chains.IsBitcoinChain(c.ChainId, nil):
cfg.BTCChainConfigs[c.ChainId] = config.BTCConfig{RPCHost: "localhost"}
case chains.IsSolanaChain(c.ChainId, nil):
Expand Down

0 comments on commit b667e17

Please sign in to comment.