Skip to content

Commit

Permalink
BCF-2564: update the relayer to use a chain rather than chainset (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
krehermann authored Aug 24, 2023
1 parent b677e2d commit 2f61ad0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
1 change: 1 addition & 0 deletions relayer/pkg/chainlink/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type ChainSet = types.ChainSet[string, Chain]
type Chain interface {
types.ChainService

ID() string
Config() config.Config

TxManager() txm.TxManager
Expand Down
34 changes: 12 additions & 22 deletions relayer/pkg/chainlink/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ import (
var _ relaytypes.Relayer = (*relayer)(nil)

type relayer struct {
chainSet starkchain.ChainSet
ctx context.Context
chain starkchain.Chain
ctx context.Context

lggr logger.Logger

cancel func()
}

func NewRelayer(lggr logger.Logger, chainSet starkchain.ChainSet) *relayer {
func NewRelayer(lggr logger.Logger, chain starkchain.Chain) *relayer {
ctx, cancel := context.WithCancel(context.Background())
return &relayer{
chainSet: chainSet,
ctx: ctx,
lggr: lggr,
cancel: cancel,
chain: chain,
ctx: ctx,
lggr: lggr,
cancel: cancel,
}
}

Expand All @@ -48,7 +48,7 @@ func (r *relayer) Close() error {
}

func (r *relayer) Ready() error {
return r.chainSet.Ready()
return r.chain.Ready()
}

func (r *relayer) Healthy() error { return nil }
Expand All @@ -65,16 +65,11 @@ func (r *relayer) NewConfigProvider(args relaytypes.RelayArgs) (relaytypes.Confi
return nil, errors.Wrap(err, "couldn't unmarshal RelayConfig")
}

chain, err := r.chainSet.Chain(r.ctx, relayConfig.ChainID)
if err != nil {
return nil, errors.Wrap(err, "couldn't initilize Chain")
}

reader, err := chain.Reader()
reader, err := r.chain.Reader()
if err != nil {
return nil, errors.Wrap(err, "error in NewConfigProvider chain.Reader")
}
configProvider, err := ocr2.NewConfigProvider(relayConfig.ChainID, args.ContractID, reader, chain.Config(), r.lggr)
configProvider, err := ocr2.NewConfigProvider(r.chain.ID(), args.ContractID, reader, r.chain.Config(), r.lggr)
if err != nil {
return nil, errors.Wrap(err, "coudln't initialize ConfigProvider")
}
Expand All @@ -94,17 +89,12 @@ func (r *relayer) NewMedianProvider(rargs relaytypes.RelayArgs, pargs relaytypes
return nil, errors.New("no account address in relay config")
}

chain, err := r.chainSet.Chain(r.ctx, relayConfig.ChainID)
if err != nil {
return nil, errors.Wrap(err, "couldn't initilize Chain")
}

// todo: use pargs for median provider
reader, err := chain.Reader()
reader, err := r.chain.Reader()
if err != nil {
return nil, errors.Wrap(err, "error in NewMedianProvider chain.Reader")
}
medianProvider, err := ocr2.NewMedianProvider(relayConfig.ChainID, rargs.ContractID, pargs.TransmitterID, relayConfig.AccountAddress, reader, chain.Config(), chain.TxManager(), r.lggr)
medianProvider, err := ocr2.NewMedianProvider(r.chain.ID(), rargs.ContractID, pargs.TransmitterID, relayConfig.AccountAddress, reader, r.chain.Config(), r.chain.TxManager(), r.lggr)
if err != nil {
return nil, errors.Wrap(err, "couldn't initilize MedianProvider")
}
Expand Down

0 comments on commit 2f61ad0

Please sign in to comment.