Skip to content

Commit

Permalink
BCF 2440 remove chainsets from core (#10349)
Browse files Browse the repository at this point in the history
* add native token field to cosmos config

* remove fcdurl

* change gas token to native token

* rename to fee token

* add basic methods to chain service

* add bech32 prefix to cosmos config

* bump chainlink-cosmos to feature branch

* fix type error

* update chain-cosmos.toml

* fix fee estimator test

* fix types and gas price estimator input

* make config-docs

* update chainlink-cosmos version

* fix cosmos config tests

* update tomls and types

* GetChainStatus, ListNodeStatuses for cosmos and evm

* fix tests

* cleanup CosmosSendAtom

* solana and starknet. fix solana tests

* fix docs and scripts tests

* remove atom references

* use ValidateDenom

* fix cosmos config in relayer test

* sort cosmos config fields alphabetically

* undo accidental test changes

* WIP: remove chainset implementation from all chains

* bump chainlink-cosmos version

* fix cosmos config order

* update relay factor to work with chains instead of chainsets

* remove chainsets implementations :)

* fix implementations to work with existing loop.Relay interfaces. previous developed in a workspace with modified interfaces

* fix dependencies

* fix nil test failure and linter

* fixes and more tests

* update toml passed to loop

* address comments; fix or document TODOs; revert test changes; move/rename code for clarity

* fix variable naming and error messages and revert total to -1 on error

---------

Co-authored-by: Calvin Wang <calvin.wang@smartcontract.com>
Co-authored-by: Calvin <78729586+calvwang9@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 30, 2023
1 parent 64395bc commit b41e626
Show file tree
Hide file tree
Showing 48 changed files with 1,379 additions and 883 deletions.
6 changes: 4 additions & 2 deletions core/chains/chain_kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import (
"fmt"

"golang.org/x/exp/maps"

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

type ChainsKV[T ChainService] struct {
type ChainsKV[T types.ChainService] struct {
// note: this is read only after construction so no need for mutex
chains map[string]T
}

var ErrNoSuchChainID = errors.New("chain id does not exist")

func NewChainsKV[T ChainService](cs map[string]T) *ChainsKV[T] {
func NewChainsKV[T types.ChainService](cs map[string]T) *ChainsKV[T] {

return &ChainsKV[T]{
chains: cs,
Expand Down
14 changes: 14 additions & 0 deletions core/chains/chain_kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/smartcontractkit/chainlink-relay/pkg/types"
"github.com/smartcontractkit/chainlink/v2/core/chains"
)

Expand Down Expand Up @@ -88,6 +89,19 @@ func (s *testChainService) HealthReport() map[string]error {
return map[string]error{}
}

// Implement updated [loop.Relay] interface funcs in preparation for BCF-2441
// TODO update this comment after BCF-2441 is done
func (s *testChainService) GetChainStatus(ctx context.Context) (stat types.ChainStatus, err error) {
return
}
func (s *testChainService) ListNodeStatuses(ctx context.Context, pageSize int32, pageToken string) (stats []types.NodeStatus, nextPageToken string, err error) {
return
}

func (s *testChainService) Transact(ctx context.Context, from string, to string, amount *big.Int, balanceCheck bool) error {
return nil
}

func (s *testChainService) SendTx(ctx context.Context, from string, to string, amount *big.Int, balanceCheck bool) error {
return nil
}
166 changes: 0 additions & 166 deletions core/chains/chain_set.go

This file was deleted.

31 changes: 30 additions & 1 deletion core/chains/config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package chains

import (
"context"
"errors"

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

var (
// ErrChainIDEmpty is returned when chain is required but was empty.
ErrChainIDEmpty = errors.New("chain id empty")
ErrNotFound = errors.New("not found")
)

type ChainConfigs interface {
Chains(offset, limit int, ids ...string) ([]types.ChainStatus, int, error)
}
Expand All @@ -13,11 +23,30 @@ type NodeConfigs[I ID, N Node] interface {
Nodes(chainID I) (nodes []N, err error)

NodeStatus(name string) (types.NodeStatus, error)
NodeStatusesPaged(offset, limit int, chainIDs ...string) (nodes []types.NodeStatus, count int, err error)
}

// Configs holds chain and node configurations.
// TODO: BCF-2605 audit the usage of this interface and potentially remove it
type Configs[I ID, N Node] interface {
ChainConfigs
NodeConfigs[I, N]
}

// ChainStatuser is a generic interface for chain configuration.
type ChainStatuser interface {
// must return [ErrNotFound] if the id is not found
ChainStatus(ctx context.Context, id string) (types.ChainStatus, error)
ChainStatuses(ctx context.Context, offset, limit int) ([]types.ChainStatus, int, error)
}

// NodesStatuser is an interface for node configuration and state.
// TODO BCF-2440, BCF-2511 may need Node(ctx,name) to get a node status by name
type NodesStatuser interface {
NodeStatuses(ctx context.Context, offset, limit int, chainIDs ...string) (nodes []types.NodeStatus, count int, err error)
}

// ChainOpts holds options for configuring a Chain
type ChainOpts[I ID, N Node] interface {
Validate() error
ConfigsAndLogger() (Configs[I, N], logger.Logger)
}
Loading

0 comments on commit b41e626

Please sign in to comment.