Skip to content

Pass Registry into bootstrap applications.#1005

Open
winder wants to merge 15 commits intomainfrom
will/bootstrap-registry
Open

Pass Registry into bootstrap applications.#1005
winder wants to merge 15 commits intomainfrom
will/bootstrap-registry

Conversation

@winder
Copy link
Copy Markdown
Collaborator

@winder winder commented Apr 7, 2026

Followup to #1002. Use the new initialization path for the registry and pass it in to apps via the bootstrapper.

Includes a changelog to explain the major changes in #1002, #1007, #1005 and #1022.

"github.com/smartcontractkit/chainlink-ccv/bootstrap"
"github.com/smartcontractkit/chainlink-ccv/integration/pkg/accessors/evm"
"github.com/smartcontractkit/chainlink-ccv/pkg/chainaccess"
_ "github.com/smartcontractkit/chainlink-ccv/integration/pkg/accessors/evm" // evm accessor driver
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EVM factory is now loaded like a driver.


"github.com/smartcontractkit/chainlink-ccv/bootstrap"
"github.com/smartcontractkit/chainlink-ccv/integration/pkg/accessors/evm"
_ "github.com/smartcontractkit/chainlink-ccv/integration/pkg/accessors/evm" // evm accessor driver
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EVM factory is now loaded like a driver.

Comment on lines -62 to +61
type factory[T any] struct {
type factory struct {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generics no longer required because accessor creation is handled by the registry + chain family driver.

Comment on lines -61 to +56
type tokenVerifierFactory[T any] struct {
type tokenVerifierFactory struct {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as committee service factory. Generics no longer needed because it's handle by the registry + chain family driver.

Comment on lines -192 to -204
family, err := chainsel.GetSelectorFamily(uint64(selector))
if err != nil {
lggr.Errorw("Failed to get selector family", "error", err, "selector", selector)
return fmt.Errorf("failed to get selector family: %w", err)
}
if family != f.chainFamily {
lggr.Warnw("Skipping chain in provided config, doesn't match expected chain family",
"selector", selector,
"family", family,
"expectedFamily", f.chainFamily,
)
continue
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer a limitation, so the check is removed. If you want multiple families, you would load multiple drivers. But I don't think we want multiple families in a single binary, so we would only load/configure one family at a time.

Pass registry in via bootstrap dependency.

Remove unused generics.

No more missing key tests.

More logs

Justfile stuff...

Fix tests.
@winder winder force-pushed the will/bootstrap-registry branch from ef376ac to 307f896 Compare April 14, 2026 17:56
// GetAccessor is called, it will delegate to the AccessorFactory corresponding to the chain
// family of the given chain selector.
type AccessorFactoryConstructor func(lggr logger.Logger, cfg string) (AccessorFactory, error)
type AccessorFactoryConstructor func(lggr logger.Logger, cfg GenericConfig) (AccessorFactory, error)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the constructor to use a stronger type.


// NewRegistry creates a new Registry with some configuration.
func NewRegistry(lggr logger.Logger, config string) (AccessorFactory, error) {
func NewRegistry(lggr logger.Logger, config string) (*Registry, error) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need AccessorFactory anymore. That may be removed in a followup.

@winder winder marked this pull request as ready for review April 14, 2026 21:37
@winder winder requested review from a team and skudasov as code owners April 14, 2026 21:37
Copilot AI review requested due to automatic review settings April 14, 2026 21:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the accessor-registry refactor by initializing a chainaccess.Registry in the bootstrap layer and passing it into bootstrap applications via bootstrap.ServiceDeps, removing the need for app-specific accessor factory wiring and generics.

Changes:

  • Initialize chainaccess.Registry inside the bootstrap runner/bootstrapper and expose it to apps through ServiceDeps.Registry.
  • Remove generic Infos[T] plumbing in verifier config loading in favor of Infos[any] and use the injected registry to obtain accessors.
  • Update the EVM accessor driver constructor to accept pre-parsed chainaccess.GenericConfig and adjust EVM factory address maps to use protocol.ChainSelector keys.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
verifier/pkg/token/config.go Drops generic config wrapper and switches blockchain infos to Infos[any].
verifier/pkg/commit/load.go Updates committee config loader to return Infos[any] (but changes strict-decoding behavior).
verifier/pkg/commit/load_test.go Updates tests to match the new Infos[any] flow and GenericConfig usage.
verifier/cmd/token/main.go Token verifier now relies on deps.Registry and blank-imports the EVM driver.
verifier/cmd/servicefactory.go Committee verifier factory now uses deps.Registry and removes family-specific wiring.
verifier/cmd/committee/main.go Removes deprecated accessor wiring and uses the non-generic service factory.
pkg/chainaccess/registry.go Registry constructors now take GenericConfig; NewRegistry returns *Registry.
pkg/chainaccess/test_test.go Adds a minimal test package file for chainaccess.
integration/pkg/accessors/evm/factory_constructor.go EVM driver constructor takes GenericConfig and logs loaded chain info.
integration/pkg/accessors/evm/factory.go Switches on-ramp/RMN address maps to ChainSelector keys and improves init error reporting.
bootstrap/bootstrap.go Creates a registry per job start and injects it into ServiceDeps.
bootstrap/bootstrap_test.go Updates runner tests to include a test logger and use t.Context().
build/devenv/services/tokenVerifier.go Adapts devenv token verifier config generation to Infos[any].
build/devenv/fakes/Justfile Adds --network=host to docker build commands.
indexer/Justfile Adds --network=host to docker build commands and modifies replay build recipe.
changelog/2025-04-14_accessor_registry.md Adds a detailed migration/adoption guide for the registry changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to 28
_, err := toml.Decode(cfg, &decodeTarget)
if err != nil {
return nil, nil, fmt.Errorf("failed to decode committee verifier config: %w", err)
}
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoadConfigWithBlockchainInfos no longer performs strict TOML decoding (Undecoded field check was removed), but the function comment still claims unknown keys (including under blockchain_infos) cause an error. This change will silently ignore config typos and can lead to misconfigured services; reintroduce strict decoding (e.g., keep the toml.Metadata from toml.Decode and fail if md.Undecoded() is non-empty, or reuse bootstrap.parseTOMLStrict if appropriate).

Suggested change
_, err := toml.Decode(cfg, &decodeTarget)
if err != nil {
return nil, nil, fmt.Errorf("failed to decode committee verifier config: %w", err)
}
md, err := toml.Decode(cfg, &decodeTarget)
if err != nil {
return nil, nil, fmt.Errorf("failed to decode committee verifier config: %w", err)
}
if undecoded := md.Undecoded(); len(undecoded) > 0 {
return nil, nil, fmt.Errorf("failed to decode committee verifier config: unknown keys %v", undecoded)
}

Copilot uses AI. Check for mistakes.
Comment on lines 41 to +60
@@ -47,36 +50,19 @@ UniqueChainName = "chain-1"
info, ok := infos["1"]
require.True(t, ok, "blockchain_infos should contain key \"1\"")
require.NotNil(t, info)
assert.Equal(t, "1", info.ChainID)
assert.Equal(t, "evm", info.Type)
assert.Equal(t, "evm", info.Family)
assert.Equal(t, "chain-1", info.UniqueChainName)
}

func TestLoadConfigWithBlockchainInfos_UnknownTopLevelKey_ReturnsError(t *testing.T) {
tomlConfig := `
typo_key = "should fail"
`
_, _, err := LoadConfigWithBlockchainInfos[testChainInfo](tomlConfig)
require.Error(t, err)
assert.Contains(t, err.Error(), "unknown fields")
assert.Contains(t, err.Error(), "typo_key")
}

func TestLoadConfigWithBlockchainInfos_UnknownKeyUnderBlockchainInfos_ReturnsError(t *testing.T) {
tomlConfig := `
[blockchain_infos."1"]
UnknownField = "should fail"
`
_, _, err := LoadConfigWithBlockchainInfos[testChainInfo](tomlConfig)
require.Error(t, err)
assert.Contains(t, err.Error(), "unknown fields")
assert.Contains(t, err.Error(), "blockchain_infos")
gcfg := chainaccess.GenericConfig{ChainConfig: infos}
var tinfo testChainInfo
require.NoError(t, gcfg.GetConcreteConfig(protocol.ChainSelector(1), &tinfo))
assert.Equal(t, "1", tinfo.ChainID)
assert.Equal(t, "evm", tinfo.Type)
assert.Equal(t, "evm", tinfo.Family)
assert.Equal(t, "chain-1", tinfo.UniqueChainName)
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests for LoadConfigWithBlockchainInfos no longer validate the documented “strict decode” behavior (unknown top-level keys / unknown keys under blockchain_infos). Without these assertions, config typos can slip through unnoticed; consider restoring explicit tests that unknown fields produce an error once strict decoding is re-enabled.

Copilot uses AI. Check for mistakes.
Comment thread bootstrap/bootstrap.go
Comment thread indexer/Justfile Outdated
Comment thread changelog/2025-04-14_accessor_registry.md
Comment thread integration/pkg/accessors/evm/factory_constructor.go Outdated
tt-cll
tt-cll previously approved these changes Apr 15, 2026
Comment thread bootstrap/bootstrap.go Outdated
Comment thread build/devenv/fakes/Justfile Outdated
Comment thread indexer/Justfile Outdated
Comment thread indexer/Justfile Outdated
Comment thread pkg/chainaccess/test_test.go Outdated
}
if len(md.Undecoded()) > 0 {
return nil, nil, fmt.Errorf("unknown fields in committee verifier config: %v", md.Undecoded())
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we rm'd the strict decode? It has caused errors in the past where we silently unmarshal into a struct that ends up having empty fields.

Copy link
Copy Markdown
Collaborator Author

@winder winder Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it because the config now has any fields for the blockchain config. I think all of these load functions can go away in a followup because the app no longer needs the family specific RPC config.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can work on this as a followup today.

Co-authored-by: Makram <makramkd@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Code coverage report:

Package main will/bootstrap-registry diff
github.com/smartcontractkit/chainlink-ccv/aggregator 48.46% 48.44% -0.02%
github.com/smartcontractkit/chainlink-ccv/bootstrap 36.77% 39.50% +2.73%
github.com/smartcontractkit/chainlink-ccv/cli 65.13% 65.13% +0.00%
github.com/smartcontractkit/chainlink-ccv/cmd 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/common 50.74% 50.74% +0.00%
github.com/smartcontractkit/chainlink-ccv/executor 45.74% 45.74% +0.00%
github.com/smartcontractkit/chainlink-ccv/indexer 37.46% 37.46% +0.00%
github.com/smartcontractkit/chainlink-ccv/integration 47.68% 47.78% +0.10%
github.com/smartcontractkit/chainlink-ccv/pkg 38.00% 100.00% +62.00%
github.com/smartcontractkit/chainlink-ccv/pricer 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/protocol 65.19% 65.19% +0.00%
github.com/smartcontractkit/chainlink-ccv/verifier 32.60% 32.60% +0.00%

@winder winder requested review from makramkd and tt-cll April 15, 2026 13:58
@winder winder enabled auto-merge April 15, 2026 15:05
@winder winder added this pull request to the merge queue Apr 15, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 15, 2026
@@ -59,49 +58,32 @@ func chainSelectorsFromMap[T any](m chainaccess.Infos[T]) []protocol.ChainSelect
// NOTE: this factory supports only a single chain family at a time.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can update the comment now that it's no longer generic

}

// NewCommitteeVerifierServiceFactory creates a new ServiceFactory for the committee verifier service.
// T is the chain config type for this family (e.g. blockchain.Info for EVM).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generic comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants