Skip to content

Commit c550d95

Browse files
committed
Introduce CCVProvider interface.
WIP: ccv provider Provider container struct and committee constructor shim Do not change name of function used in cl core.
1 parent cf06c2f commit c550d95

File tree

3 files changed

+83
-35
lines changed

3 files changed

+83
-35
lines changed

integration/pkg/constructors/committee_verifier.go

Lines changed: 72 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import (
2121
"github.com/smartcontractkit/chainlink-evm/pkg/chains/legacyevm"
2222
)
2323

24-
// NewVerificationCoordinator starts the Committee Verifier with evm chains.
24+
// NewVerificationCoordinatorFromProviders starts the Committee Verifier with evm chains.
2525
// Signing is passed in because it's managed differently in the CL node vs standalone modes.
26-
func NewVerificationCoordinator(
26+
func NewVerificationCoordinatorFromProviders(
2727
lggr logger.Logger,
2828
cfg verifier.Config,
2929
aggregatorSecret *hmac.ClientConfig,
3030
signingAddress protocol.UnknownAddress,
3131
signer verifier.MessageSigner,
32-
relayers map[protocol.ChainSelector]legacyevm.Chain,
32+
providers map[protocol.ChainSelector]chainaccess.Provider,
3333
) (*verifier.Coordinator, error) {
3434
if err := cfg.Validate(); err != nil {
3535
lggr.Errorw("Invalid CCV verifier configuration.", "error", err)
@@ -41,11 +41,6 @@ func NewVerificationCoordinator(
4141
return nil, fmt.Errorf("signing address does not match configuration: config %x vs provided %x", cfgSignerBytes, signingAddress.Bytes())
4242
}
4343

44-
onRampAddrs, err := mapAddresses(cfg.OnRampAddresses)
45-
if err != nil {
46-
lggr.Errorw("Invalid CCV configuration, failed to map onramp addresses.", "error", err)
47-
return nil, fmt.Errorf("invalid ccv configuration: failed to map onramp addresses: %w", err)
48-
}
4944
verifierAddrs, err := mapAddresses(cfg.CommitteeVerifierAddresses)
5045
if err != nil {
5146
lggr.Errorw("Invalid CCV configuration, failed to map verifier addresses.", "error", err)
@@ -81,33 +76,9 @@ func NewVerificationCoordinator(
8176
// Initialize chain components.
8277
sourceReaders := make(map[protocol.ChainSelector]chainaccess.SourceReader)
8378
sourceConfigs := make(map[protocol.ChainSelector]verifier.SourceConfig)
84-
for sel, chain := range relayers {
85-
if _, ok := onRampAddrs[sel]; !ok {
86-
lggr.Warnw("No onramp address for chain, skipping.", "chainID", sel)
87-
continue
88-
}
89-
if _, ok := verifierAddrs[sel]; !ok {
90-
lggr.Warnw("No verifier address for chain, skipping.", "chainID", sel)
91-
continue
92-
}
93-
94-
sourceReader, err := sourcereader.NewEVMSourceReader(
95-
chain.Client(),
96-
chain.HeadTracker(),
97-
// TODO: use UnknownAddress instead of ethereum address.
98-
common.HexToAddress(onRampAddrs[sel].String()),
99-
common.HexToAddress(rmnRemoteAddrs[sel].String()),
100-
// TODO: does this need to be configurable?
101-
onramp.OnRampCCIPMessageSent{}.Topic().Hex(),
102-
sel,
103-
logger.With(lggr, "component", "SourceReader", "chainID", sel))
104-
if err != nil {
105-
lggr.Errorw("Failed to create source reader.", "error", err, "chainID", sel)
106-
return nil, fmt.Errorf("failed to create source reader: %w", err)
107-
}
108-
79+
for sel, provider := range providers {
10980
observedSourceReader := sourcereader.NewObservedSourceReader(
110-
sourceReader, cfg.VerifierID, sel, verifierMonitoring,
81+
provider.SourceReader, cfg.VerifierID, sel, verifierMonitoring,
11182
)
11283

11384
sourceReaders[sel] = observedSourceReader
@@ -183,3 +154,70 @@ func NewVerificationCoordinator(
183154

184155
return verifierCoordinator, nil
185156
}
157+
158+
// NewVerificationCoordinator starts the Committee Verifier with evm chains.
159+
// Signing is passed in because it's managed differently in the CL node vs standalone modes.
160+
//
161+
// deprecated: use NewVerificationCoordinatorFromProviders instead.
162+
func NewVerificationCoordinator(
163+
lggr logger.Logger,
164+
cfg verifier.Config,
165+
aggregatorSecret *hmac.ClientConfig,
166+
signingAddress protocol.UnknownAddress,
167+
signer verifier.MessageSigner,
168+
relayers map[protocol.ChainSelector]legacyevm.Chain,
169+
) (*verifier.Coordinator, error) {
170+
// map legacy to new
171+
providers := make(map[protocol.ChainSelector]chainaccess.Provider)
172+
173+
onRampAddrs, err := mapAddresses(cfg.OnRampAddresses)
174+
if err != nil {
175+
lggr.Errorw("Invalid CCV configuration, failed to map onramp addresses.", "error", err)
176+
return nil, fmt.Errorf("invalid ccv configuration: failed to map onramp addresses: %w", err)
177+
}
178+
rmnRemoteAddrs, err := mapAddresses(cfg.RMNRemoteAddresses)
179+
if err != nil {
180+
lggr.Errorw("Invalid CCV configuration, failed to map RMN Remote addresses.", "error", err)
181+
return nil, fmt.Errorf("invalid ccv configuration: failed to map RMN Remote addresses: %w", err)
182+
}
183+
184+
// Initialize chain components.
185+
for sel, chain := range relayers {
186+
if _, ok := onRampAddrs[sel]; !ok {
187+
lggr.Warnw("No onramp address for chain, skipping.", "chainID", sel)
188+
continue
189+
}
190+
if _, ok := rmnRemoteAddrs[sel]; !ok {
191+
lggr.Warnw("No rmn remote address for chain, skipping.", "chainID", sel)
192+
continue
193+
}
194+
195+
sourceReader, err := sourcereader.NewEVMSourceReader(
196+
chain.Client(),
197+
chain.HeadTracker(),
198+
// TODO: use UnknownAddress instead of ethereum address.
199+
common.HexToAddress(onRampAddrs[sel].String()),
200+
common.HexToAddress(rmnRemoteAddrs[sel].String()),
201+
// TODO: does this need to be configurable?
202+
onramp.OnRampCCIPMessageSent{}.Topic().Hex(),
203+
sel,
204+
logger.With(lggr, "component", "SourceReader", "chainID", sel))
205+
if err != nil {
206+
lggr.Errorw("Failed to create source reader.", "error", err, "chainID", sel)
207+
return nil, fmt.Errorf("failed to create source reader: %w", err)
208+
}
209+
210+
p := providers[sel]
211+
p.SourceReader = sourceReader
212+
providers[sel] = p
213+
}
214+
215+
return NewVerificationCoordinatorFromProviders(
216+
lggr,
217+
cfg,
218+
aggregatorSecret,
219+
signingAddress,
220+
signer,
221+
providers,
222+
)
223+
}

integration/pkg/constructors/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
func NewExecutorCoordinator(
3131
lggr logger.Logger,
3232
cfg executor.Configuration,
33-
// TODO: all these are EVM specific, shouldn't be.
3433
relayers map[protocol.ChainSelector]legacyevm.Chain,
34+
// TODO move keys + fromAddress to CCVProvider services
3535
keys map[protocol.ChainSelector]keys.RoundRobin,
3636
fromAddresses map[protocol.ChainSelector][]common.Address,
3737
) (*executor.Coordinator, error) {

pkg/chainaccess/interfaces.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ import (
77
"github.com/smartcontractkit/chainlink-ccv/protocol"
88
)
99

10+
type Provider struct {
11+
SourceReader SourceReader
12+
13+
// TODO: Unused? The filter is created by the verification coordinator directly.
14+
// MessageFilter
15+
16+
// TODO: add Executor interfaces
17+
// TxManager txmgr.TxManager
18+
}
19+
1020
// HeadTracker provides access to the latest blockchain head information.
1121
// This interface is responsible for tracking the current and finalized block states.
1222
//

0 commit comments

Comments
 (0)