Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BCF 2440 remove chainsets from core #10349

Merged
merged 48 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
26053b0
add native token field to cosmos config
calvwang9 Aug 16, 2023
5f4708b
remove fcdurl
calvwang9 Aug 16, 2023
8d97686
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
calvwang9 Aug 16, 2023
061df89
change gas token to native token
calvwang9 Aug 16, 2023
052cd3b
rename to fee token
calvwang9 Aug 16, 2023
3f28435
add basic methods to chain service
krehermann Aug 18, 2023
a09355a
add bech32 prefix to cosmos config
calvwang9 Aug 22, 2023
0db2e6b
bump chainlink-cosmos to feature branch
calvwang9 Aug 22, 2023
e2da6d2
fix type error
calvwang9 Aug 22, 2023
f68729b
update chain-cosmos.toml
calvwang9 Aug 22, 2023
08c799d
merge develop
calvwang9 Aug 22, 2023
8380ee6
fix fee estimator test
calvwang9 Aug 22, 2023
52cb367
fix types and gas price estimator input
calvwang9 Aug 22, 2023
e12c5e2
make config-docs
calvwang9 Aug 22, 2023
383fddd
update chainlink-cosmos version
calvwang9 Aug 22, 2023
0c8579a
fix cosmos config tests
calvwang9 Aug 22, 2023
d087834
update tomls and types
calvwang9 Aug 22, 2023
c88d6ca
GetChainStatus, ListNodeStatuses for cosmos and evm
krehermann Aug 22, 2023
eb96835
fix tests
calvwang9 Aug 23, 2023
af81c8d
cleanup CosmosSendAtom
calvwang9 Aug 23, 2023
0de74a9
solana and starknet. fix solana tests
krehermann Aug 23, 2023
035d82f
fix docs and scripts tests
calvwang9 Aug 23, 2023
5b8a8a8
remove atom references
calvwang9 Aug 23, 2023
3ed0672
use ValidateDenom
calvwang9 Aug 23, 2023
a87247b
fix cosmos config in relayer test
calvwang9 Aug 23, 2023
7261bf1
Merge branch 'develop' into BCI-1738/cosmos-cleanup
calvwang9 Aug 24, 2023
0ce6de7
sort cosmos config fields alphabetically
calvwang9 Aug 24, 2023
5a0231c
undo accidental test changes
calvwang9 Aug 24, 2023
a574125
WIP: remove chainset implementation from all chains
krehermann Aug 24, 2023
4a3a273
bump chainlink-cosmos version
calvwang9 Aug 24, 2023
c16aeb5
fix cosmos config order
calvwang9 Aug 24, 2023
bb69b02
Merge branch 'develop' into BCI-1738/cosmos-cleanup
calvwang9 Aug 24, 2023
12c1b66
Merge branch 'develop' into BCI-1738/cosmos-cleanup
calvwang9 Aug 24, 2023
6ecd16e
Merge branch 'develop' into BCI-1738/cosmos-cleanup
krehermann Aug 24, 2023
7a15731
Merge branch 'BCI-1738/cosmos-cleanup' into BCF-2441-update-loop-inte…
krehermann Aug 24, 2023
f9ac243
update relay factor to work with chains instead of chainsets
krehermann Aug 24, 2023
a6da710
Merge branch 'develop' into BCF-2441-update-loop-interface
krehermann Aug 24, 2023
c866cb5
remove chainsets implementations :)
krehermann Aug 24, 2023
c558c4a
fix implementations to work with existing loop.Relay interfaces. prev…
krehermann Aug 24, 2023
e567f3e
fix dependencies
krehermann Aug 25, 2023
9a568ae
fix nil test failure and linter
krehermann Aug 25, 2023
15a5f0a
fixes and more tests
krehermann Aug 25, 2023
62f7070
update toml passed to loop
krehermann Aug 25, 2023
6b519a9
address comments; fix or document TODOs; revert test changes; move/re…
krehermann Aug 29, 2023
bd78e90
Merge branch 'develop' into BCF-2441-update-loop-interface
krehermann Aug 29, 2023
01d1897
Merge branch 'develop' into BCF-2441-update-loop-interface
krehermann Aug 30, 2023
56f0be0
fix variable naming and error messages and revert total to -1 on error
krehermann Aug 30, 2023
1153e16
Merge branch 'develop' into BCF-2441-update-loop-interface
krehermann Aug 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address comments; fix or document TODOs; revert test changes; move/re…
…name code for clarity
  • Loading branch information
krehermann committed Aug 29, 2023
commit 6b519a929d66773ff05c6ab62f5694faa358e3af
35 changes: 0 additions & 35 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)
}
60 changes: 60 additions & 0 deletions core/chains/cosmos/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,66 @@ import (
// TODO(BCI-979): Remove this, or make this configurable with the updated client.
const DefaultRequestTimeout = 30 * time.Second

var (
// ErrChainIDEmpty is returned when chain is required but was empty.
ErrChainIDEmpty = errors.New("chain id empty")
// ErrChainIDInvalid is returned when a chain id does not match any configured chains.
ErrChainIDInvalid = errors.New("chain id does not match any local chains")
)

// Chain is a wrap for easy use in other places in the core node
type Chain = adapters.Chain

// ChainOpts holds options for configuring a Chain.
type ChainOpts struct {
QueryConfig pg.QConfig
Logger logger.Logger
DB *sqlx.DB
KeyStore keystore.Cosmos
EventBroadcaster pg.EventBroadcaster
Configs types.Configs
}

func (o *ChainOpts) Validate() (err error) {
required := func(s string) error {
return fmt.Errorf("%s is required", s)
}
if o.QueryConfig == nil {
err = multierr.Append(err, required("Config"))
}
if o.Logger == nil {
err = multierr.Append(err, required("Logger'"))
}
if o.DB == nil {
err = multierr.Append(err, required("DB"))
}
if o.KeyStore == nil {
err = multierr.Append(err, required("KeyStore"))
}
if o.EventBroadcaster == nil {
err = multierr.Append(err, required("EventBroadcaster"))
}
if o.Configs == nil {
err = multierr.Append(err, required("Configs"))
}
return
}

func (o *ChainOpts) ConfigsAndLogger() (chains.Configs[string, db.Node], logger.Logger) {
return o.Configs, o.Logger
}

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)
}
c, err := newChain(*cfg.ChainID, cfg, opts.DB, opts.KeyStore, opts.QueryConfig, opts.EventBroadcaster, opts.Configs, opts.Logger)
if err != nil {
return nil, err
}
return c, nil
}

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

type chain struct {
Expand Down
166 changes: 0 additions & 166 deletions core/chains/cosmos/chain_set.go

This file was deleted.

1 change: 1 addition & 0 deletions core/chains/cosmos/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func legacyNode(n *coscfg.Node, id string) db.Node {

type CosmosConfig struct {
ChainID *string
// Do not access directly. Use [IsEnabled]
Enabled *bool
coscfg.Chain
Nodes CosmosNodes
Expand Down
Loading