Skip to content

Commit

Permalink
more dead code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
krehermann committed Sep 7, 2023
1 parent 24f1bfd commit 451e034
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 60 deletions.
18 changes: 1 addition & 17 deletions core/chains/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package chains

import (
"errors"

"github.com/smartcontractkit/chainlink-relay/pkg/logger"
"github.com/smartcontractkit/chainlink-relay/pkg/types"
)

var (
Expand All @@ -13,20 +10,7 @@ var (
ErrNotFound = errors.New("not found")
)

type ChainConfig[N Node] interface {
GetChainStatus() (types.ChainStatus, error)
GetNodeStatus(name string) (types.NodeStatus, error)
NodeConfig[N]
}

type NodeConfig[N Node] interface {
ListNodes() (nodes []N, err error)
Node(name string) (N, error)
}

// ChainOpts holds options for configuring a Chain
type ChainOpts[N Node] interface {
type ChainOpts interface {
Validate() error
Logger() logger.Logger
ChainConfig() ChainConfig[N]
}
15 changes: 1 addition & 14 deletions core/chains/cosmos/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/smartcontractkit/chainlink/v2/core/chains"
"github.com/smartcontractkit/chainlink/v2/core/chains/cosmos/cosmostxm"
"github.com/smartcontractkit/chainlink/v2/core/chains/cosmos/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/internal"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/services/relay"
Expand Down Expand Up @@ -57,7 +56,6 @@ type ChainOpts struct {
DB *sqlx.DB
KeyStore loop.Keystore
EventBroadcaster pg.EventBroadcaster
Config types.Config
}

func (o *ChainOpts) Validate() (err error) {
Expand All @@ -79,20 +77,9 @@ func (o *ChainOpts) Validate() (err error) {
if o.EventBroadcaster == nil {
err = multierr.Append(err, required("EventBroadcaster"))
}
if o.Config == nil {
err = multierr.Append(err, required("Configs"))
}
return
}

func (o *ChainOpts) GetLogger() logger.Logger {
return o.Logger
}

func (o *ChainOpts) ChainConfig() chains.ChainConfig[db.Node] {
return o.Config
}

func NewChain(cfg *CosmosConfig, opts ChainOpts) (adapters.Chain, error) {
if !cfg.IsEnabled() {
return nil, fmt.Errorf("cannot create new chain with ID %s, the chain is disabled", *cfg.ChainID)
Expand Down Expand Up @@ -188,7 +175,7 @@ func (c *chain) getClient(name string) (cosmosclient.ReaderWriter, error) {
}
client, err := cosmosclient.NewClient(c.id, node.TendermintURL, DefaultRequestTimeout, logger.Named(c.lggr, "Client."+name))
if err != nil {
return nil, fmt.Errorf("failed to create client: %w")
return nil, fmt.Errorf("failed to create client: %w", err)
}
c.lggr.Debugw("Created client", "name", node.Name, "tendermint-url", node.TendermintURL)
return client, nil
Expand Down
10 changes: 0 additions & 10 deletions core/chains/cosmos/types/types.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
package types

import (
"github.com/smartcontractkit/chainlink-cosmos/pkg/cosmos/db"

"github.com/smartcontractkit/chainlink/v2/core/chains"
)

type Config interface {
chains.ChainConfig[db.Node]
}

// NewNode defines a new node to create.
type NewNode struct {
Name string `json:"name"`
Expand Down
11 changes: 4 additions & 7 deletions core/chains/evm/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"math/big"
"net/url"
"sync"
"time"

"go.uber.org/multierr"
Expand Down Expand Up @@ -55,8 +54,6 @@ type Chain interface {
BalanceMonitor() monitor.BalanceMonitor
LogPoller() logpoller.LogPoller
GasEstimator() gas.EvmFeeEstimator

//GetNodeStatus(ctx context.Context, name string) (relaytypes.NodeStatus, error)
}

var (
Expand All @@ -70,7 +67,7 @@ type LegacyChains struct {
*chains.ChainsKV[Chain]
dflt Chain

cfgs toml.EVMConfigs //evmtypes.Configs
cfgs toml.EVMConfigs
}

// LegacyChainContainer is container for EVM chains.
Expand All @@ -84,6 +81,9 @@ type LegacyChainContainer interface {
List(ids ...string) ([]Chain, error)
Slice() []Chain

// BCF-2516: this is only used for EVMORM. When we delete that
// we can promote/move the needed funcs from it to LegacyChainContainer
// so instead of EVMORM().XYZ() we'd have something like legacyChains.XYZ()
ChainNodeConfigs() evmtypes.Configs
}

Expand Down Expand Up @@ -173,9 +173,6 @@ type RelayerConfig struct {
MailMon *utils.MailboxMonitor
GasEstimator gas.EvmFeeEstimator

init sync.Once
//operationalConfigs evmtypes.Configs

// TODO BCF-2513 remove test code from the API
// Gen-functions are useful for dependency injection by tests
GenEthClient func(*big.Int) client.Client
Expand Down
5 changes: 0 additions & 5 deletions core/chains/evm/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/mocks"
Expand All @@ -25,8 +24,4 @@ func TestLegacyChains(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, c, got)

require.NotPanics(t, func() {
l = evm.NewLegacyChains(m, nil)
assert.NotNil(t, l.ChainNodeConfigs())
})
}
2 changes: 1 addition & 1 deletion core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (cs EVMConfigs) totalChains() int {
if ch == nil {
continue
}
total += 1
total++
}
return total
}
Expand Down
4 changes: 0 additions & 4 deletions core/chains/starknet/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ func (o *ChainOpts) Validate() (err error) {
return
}

func (o *ChainOpts) GetLogger() logger.Logger {
return o.Logger
}

var _ starkChain.Chain = (*chain)(nil)

type chain struct {
Expand Down
3 changes: 1 addition & 2 deletions core/services/chainlink/relayer_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ func (r *RelayerFactory) NewCosmos(ctx context.Context, config CosmosFactoryConf
KeyStore: loopKs,
EventBroadcaster: config.EventBroadcaster,
}
// opts.Config = cosmos.New // cosmos.NewConfigs(cosmos.CosmosConfigs{chainCfg})
chain, err := cosmos.NewChain(chainCfg, opts)

chain, err := cosmos.NewChain(chainCfg, opts)
if err != nil {
return nil, fmt.Errorf("failed to load Cosmos chain %q: %w", relayId, err)
}
Expand Down

0 comments on commit 451e034

Please sign in to comment.