Skip to content

Commit

Permalink
remove unused references to EventBroadcaster from evm relayer
Browse files Browse the repository at this point in the history
  • Loading branch information
krehermann committed Jan 9, 2024
1 parent 7fc45b6 commit 8e4c59a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 37 deletions.
9 changes: 4 additions & 5 deletions core/services/chainlink/relayer_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ func (r *RelayerFactory) NewEVM(ctx context.Context, config EVMFactoryConfig) (m
}

relayerOpts := evmrelay.RelayerOpts{
DB: ccOpts.DB,
QConfig: ccOpts.AppConfig.Database(),
CSAETHKeystore: config.CSAETHKeystore,
EventBroadcaster: ccOpts.EventBroadcaster,
MercuryPool: r.MercuryPool,
DB: ccOpts.DB,
QConfig: ccOpts.AppConfig.Database(),
CSAETHKeystore: config.CSAETHKeystore,
MercuryPool: r.MercuryPool,
}
relayer, err2 := evmrelay.NewRelayer(lggr.Named(relayID.ChainID), chain, relayerOpts)
if err2 != nil {
Expand Down
8 changes: 3 additions & 5 deletions core/services/job/spawner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/job/mocks"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
"github.com/smartcontractkit/chainlink/v2/core/services/relay"
evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm"
Expand Down Expand Up @@ -285,10 +284,9 @@ func TestSpawner_CreateJobDeleteJob(t *testing.T) {
chain := evmtest.MustGetDefaultChain(t, legacyChains)

evmRelayer, err := evmrelayer.NewRelayer(lggr, chain, evmrelayer.RelayerOpts{
DB: db,
QConfig: testopts.GeneralConfig.Database(),
CSAETHKeystore: keyStore,
EventBroadcaster: pg.NewNullEventBroadcaster(),
DB: db,
QConfig: testopts.GeneralConfig.Database(),
CSAETHKeystore: keyStore,
})
assert.NoError(t, err)

Expand Down
40 changes: 17 additions & 23 deletions core/services/relay/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ import (
var _ commontypes.Relayer = &Relayer{} //nolint:staticcheck

type Relayer struct {
db *sqlx.DB
chain legacyevm.Chain
lggr logger.Logger
ks CSAETHKeystore
mercuryPool wsrpc.Pool
eventBroadcaster pg.EventBroadcaster
pgCfg pg.QConfig
chainReader commontypes.ChainReader
db *sqlx.DB
chain legacyevm.Chain
lggr logger.Logger
ks CSAETHKeystore
mercuryPool wsrpc.Pool
pgCfg pg.QConfig
chainReader commontypes.ChainReader
}

type CSAETHKeystore interface {
Expand All @@ -64,7 +63,6 @@ type RelayerOpts struct {
*sqlx.DB
pg.QConfig
CSAETHKeystore
pg.EventBroadcaster
MercuryPool wsrpc.Pool
}

Expand All @@ -79,9 +77,6 @@ func (c RelayerOpts) Validate() error {
if c.CSAETHKeystore == nil {
err = errors.Join(err, errors.New("nil Keystore"))
}
if c.EventBroadcaster == nil {
err = errors.Join(err, errors.New("nil Eventbroadcaster"))
}

if err != nil {
err = fmt.Errorf("invalid RelayerOpts: %w", err)
Expand All @@ -96,13 +91,12 @@ func NewRelayer(lggr logger.Logger, chain legacyevm.Chain, opts RelayerOpts) (*R
}
lggr = lggr.Named("Relayer")
return &Relayer{
db: opts.DB,
chain: chain,
lggr: lggr,
ks: opts.CSAETHKeystore,
mercuryPool: opts.MercuryPool,
eventBroadcaster: opts.EventBroadcaster,
pgCfg: opts.QConfig,
db: opts.DB,
chain: chain,
lggr: lggr,
ks: opts.CSAETHKeystore,
mercuryPool: opts.MercuryPool,
pgCfg: opts.QConfig,
}, nil
}

Expand Down Expand Up @@ -151,7 +145,7 @@ func (r *Relayer) NewMercuryProvider(rargs commontypes.RelayArgs, pargs commonty
if relayConfig.ChainID.String() != r.chain.ID().String() {
return nil, fmt.Errorf("internal error: chain id in spec does not match this relayer's chain: have %s expected %s", relayConfig.ChainID.String(), r.chain.ID().String())
}
cw, err := newConfigProvider(lggr, r.chain, relayOpts, r.eventBroadcaster)
cw, err := newConfigProvider(lggr, r.chain, relayOpts)
if err != nil {
return nil, pkgerrors.WithStack(err)
}
Expand Down Expand Up @@ -210,7 +204,7 @@ func (r *Relayer) NewConfigProvider(args commontypes.RelayArgs) (commontypes.Con
return nil, fmt.Errorf("internal error: chain id in spec does not match this relayer's chain: have %s expected %s", relayConfig.ChainID.String(), r.chain.ID().String())
}

configProvider, err := newConfigProvider(lggr, r.chain, relayOpts, r.eventBroadcaster)
configProvider, err := newConfigProvider(lggr, r.chain, relayOpts)
if err != nil {
// Never return (*configProvider)(nil)
return nil, err
Expand Down Expand Up @@ -320,7 +314,7 @@ func (c *configWatcher) ContractConfigTracker() ocrtypes.ContractConfigTracker {
return c.configPoller
}

func newConfigProvider(lggr logger.Logger, chain legacyevm.Chain, opts *types.RelayOpts, eventBroadcaster pg.EventBroadcaster) (*configWatcher, error) {
func newConfigProvider(lggr logger.Logger, chain legacyevm.Chain, opts *types.RelayOpts) (*configWatcher, error) {
if !common.IsHexAddress(opts.ContractID) {
return nil, pkgerrors.Errorf("invalid contractID, expected hex address")
}
Expand Down Expand Up @@ -464,7 +458,7 @@ func (r *Relayer) NewMedianProvider(rargs commontypes.RelayArgs, pargs commontyp
}
contractID := common.HexToAddress(relayOpts.ContractID)

configWatcher, err := newConfigProvider(lggr, r.chain, relayOpts, r.eventBroadcaster)
configWatcher, err := newConfigProvider(lggr, r.chain, relayOpts)
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions core/services/relay/evm/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ nil Keystore`,
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := evm.RelayerOpts{
DB: tt.fields.DB,
QConfig: tt.fields.QConfig,
CSAETHKeystore: tt.fields.CSAETHKeystore,
EventBroadcaster: tt.fields.EventBroadcaster,
DB: tt.fields.DB,
QConfig: tt.fields.QConfig,
CSAETHKeystore: tt.fields.CSAETHKeystore,
}
err := c.Validate()
if tt.wantErrContains != "" {
Expand Down

0 comments on commit 8e4c59a

Please sign in to comment.