Skip to content

Commit

Permalink
Revert "BCF-2564: update the relayer to use a chain rather than chain…
Browse files Browse the repository at this point in the history
…set (#320)"

This reverts commit 2f61ad0.
  • Loading branch information
krehermann authored Aug 25, 2023
1 parent 2f61ad0 commit 21193d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
1 change: 0 additions & 1 deletion relayer/pkg/chainlink/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type ChainSet = types.ChainSet[string, Chain]
type Chain interface {
types.ChainService

ID() string
Config() config.Config

TxManager() txm.TxManager
Expand Down
34 changes: 22 additions & 12 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 {
chain starkchain.Chain
ctx context.Context
chainSet starkchain.ChainSet
ctx context.Context

lggr logger.Logger

cancel func()
}

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

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

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

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

reader, err := r.chain.Reader()
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()
if err != nil {
return nil, errors.Wrap(err, "error in NewConfigProvider chain.Reader")
}
configProvider, err := ocr2.NewConfigProvider(r.chain.ID(), args.ContractID, reader, r.chain.Config(), r.lggr)
configProvider, err := ocr2.NewConfigProvider(relayConfig.ChainID, args.ContractID, reader, chain.Config(), r.lggr)
if err != nil {
return nil, errors.Wrap(err, "coudln't initialize ConfigProvider")
}
Expand All @@ -89,12 +94,17 @@ 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 := r.chain.Reader()
reader, err := chain.Reader()
if err != nil {
return nil, errors.Wrap(err, "error in NewMedianProvider chain.Reader")
}
medianProvider, err := ocr2.NewMedianProvider(r.chain.ID(), rargs.ContractID, pargs.TransmitterID, relayConfig.AccountAddress, reader, r.chain.Config(), r.chain.TxManager(), r.lggr)
medianProvider, err := ocr2.NewMedianProvider(relayConfig.ChainID, rargs.ContractID, pargs.TransmitterID, relayConfig.AccountAddress, reader, chain.Config(), chain.TxManager(), r.lggr)
if err != nil {
return nil, errors.Wrap(err, "couldn't initilize MedianProvider")
}
Expand Down

0 comments on commit 21193d5

Please sign in to comment.