From b030f90d98c4ec59bfd048dc145fe36c6b1ab49e Mon Sep 17 00:00:00 2001 From: Justin Kaseman Date: Fri, 6 Nov 2026 16:12:43 -0800 Subject: [PATCH 1/4] [CRE] (feat): validate OCR key bundles against expected signers in ProposeJobSpec --- deployment/cre/jobs/propose_job_spec.go | 11 +- .../jobs/propose_job_spec_keyring_check.go | 289 +++++++++++++++++ .../propose_job_spec_keyring_check_test.go | 294 ++++++++++++++++++ .../jobs/propose_job_spec_keyring_e2e_test.go | 108 +++++++ 4 files changed, 700 insertions(+), 2 deletions(-) create mode 100644 deployment/cre/jobs/propose_job_spec_keyring_check.go create mode 100644 deployment/cre/jobs/propose_job_spec_keyring_check_test.go create mode 100644 deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go diff --git a/deployment/cre/jobs/propose_job_spec.go b/deployment/cre/jobs/propose_job_spec.go index 166222799f3..b5fba850364 100644 --- a/deployment/cre/jobs/propose_job_spec.go +++ b/deployment/cre/jobs/propose_job_spec.go @@ -34,11 +34,18 @@ type ProposeJobSpecInput struct { // These will vary based on the template used, and will be validated differently // for each template type. Inputs job_types.JobSpecInput `json:"inputs" yaml:"inputs"` + + // ExpectedSigners maps a node CSA key to the onchain signing address (EVM, 20 bytes, optionally 0x-prefixed + // and zero-padded to 32) its OCR2 key bundle must have in JD. When set, VerifyPreconditions rejects + // OCR-bearing templates whose target nodes have a missing or different bundle. Optional. + ExpectedSigners map[string]string `json:"expectedSigners,omitempty" yaml:"expectedSigners,omitempty"` + // SkipKeyringCheck bypasses the ExpectedSigners check for emergencies. + SkipKeyringCheck bool `json:"skipKeyringCheck,omitempty" yaml:"skipKeyringCheck,omitempty"` } type ProposeJobSpec struct{} -func (u ProposeJobSpec) VerifyPreconditions(_ cldf.Environment, config ProposeJobSpecInput) error { +func (u ProposeJobSpec) VerifyPreconditions(e cldf.Environment, config ProposeJobSpecInput) error { if config.Environment == "" { return errors.New("environment is required") } @@ -93,7 +100,7 @@ func (u ProposeJobSpec) VerifyPreconditions(_ cldf.Environment, config ProposeJo return errors.New("inputs are required") } - return nil + return verifyOCRKeyrings(e, config) } func (u ProposeJobSpec) Apply(e cldf.Environment, input ProposeJobSpecInput) (cldf.ChangesetOutput, error) { diff --git a/deployment/cre/jobs/propose_job_spec_keyring_check.go b/deployment/cre/jobs/propose_job_spec_keyring_check.go new file mode 100644 index 00000000000..8d0b9cc3f37 --- /dev/null +++ b/deployment/cre/jobs/propose_job_spec_keyring_check.go @@ -0,0 +1,289 @@ +package jobs + +import ( + "encoding/hex" + "errors" + "fmt" + "slices" + "strings" + + chainsel "github.com/smartcontractkit/chain-selectors" + + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" + "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/shared/ptypes" + "github.com/smartcontractkit/chainlink/deployment" + job_ops "github.com/smartcontractkit/chainlink/deployment/cre/jobs/operations" + "github.com/smartcontractkit/chainlink/deployment/cre/jobs/pkg" + job_types "github.com/smartcontractkit/chainlink/deployment/cre/jobs/types" + "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" +) + +// templatesWithOCRKeys are the templates whose specs embed a per-node OCR key bundle ID. +var templatesWithOCRKeys = []job_types.JobSpecTemplate{ + job_types.OCR3, job_types.Consensus, job_types.Ring, + job_types.Aptos, job_types.Solana, job_types.Stellar, +} + +// verifyOCRKeyrings checks that, for every target node, the EVM OCR2 key bundle recorded in JD has +// the onchain signing address the caller expects. It is a no-op unless ExpectedSigners is set. +func verifyOCRKeyrings(e cldf.Environment, config ProposeJobSpecInput) error { + if len(config.ExpectedSigners) == 0 || config.SkipKeyringCheck || !slices.Contains(templatesWithOCRKeys, config.Template) { + return nil + } + sel, err := specChainSelectors(config) + if err != nil { + return err + } + if sel.Skip { + return nil + } + + if e.Offchain == nil { + return errors.New("keyring check needs a job distributor client; unset expectedSigners or set skipKeyringCheck to bypass") + } + + nodeInfos, err := fetchTargetNodeInfos(e, config) + if err != nil { + return err + } + + return checkKeyringsAgainstExpected(nodeInfos, config.ExpectedSigners, sel) +} + +// fetchTargetNodeInfos mirrors the JD node selection used when the job is proposed. +func fetchTargetNodeInfos(e cldf.Environment, config ProposeJobSpecInput) (deployment.Nodes, error) { + donName := jdDONName(config) + filter := targetNodeFilter(config) + + jdNodes, err := offchain.FetchNodesFromJD(e.GetContext(), e.Offchain, filter) + if err != nil { + return nil, fmt.Errorf("keyring check: failed to fetch nodes from JD: %w", err) + } + if len(jdNodes) == 0 { + return nil, fmt.Errorf("keyring check: no nodes found on JD for DON %q", donName) + } + ids := make([]string, len(jdNodes)) + for i, n := range jdNodes { + ids[i] = n.Id + } + infos, err := deployment.NodeInfo(ids, e.Offchain) + if err != nil { + return nil, fmt.Errorf("keyring check: failed to fetch node infos: %w", err) + } + + return infos, nil +} + +// checkKeyringsAgainstExpected requires every non-bootstrap node to have an EVM OCR2 key bundle in +// JD with a non-empty ID and an onchain signing address equal to the expected signer for its CSA +// key. A stale JD chain config (e.g. after a key rotation) would otherwise bake the wrong bundle +// ID into the spec. For the non-EVM chain selectors the spec uses, it also requires a non-empty +// bundle ID on every node and no bundle ID shared between nodes; nodes.json has no committed +// non-EVM signers to compare against. +func checkKeyringsAgainstExpected(nodeInfos deployment.Nodes, expected map[string]string, sel specSelectors) error { + var problems []string + for _, n := range nodeInfos { + if n.IsBootstrap { + continue + } + signer, ok := expected[n.CSAKey] + if !ok { + problems = append(problems, fmt.Sprintf("%s: no expected signer for csa %s", n.Name, n.CSAKey)) + + continue + } + want, err := normalizeSigner(signer) + if err != nil { + problems = append(problems, fmt.Sprintf("%s: %v", n.Name, err)) + + continue + } + + problems = append(problems, evmBundleProblems(n, want, sel.EVM)...) + } + problems = append(problems, nonEVMBundleProblems(nodeInfos, sel.NonEVM)...) + if len(problems) == 0 { + return nil + } + slices.Sort(problems) + + return fmt.Errorf("OCR key bundles in JD do not match the expected keyrings; re-sync JD chain configs or the expected signers (or set skipKeyringCheck):\n %s", strings.Join(problems, "\n ")) +} + +// normalizeSigner reduces a signer (20-byte address, optionally 0x-prefixed and zero-padded to 32 +// bytes) to 40 lowercase hex characters. +func normalizeSigner(signer string) (string, error) { + s := strings.ToLower(strings.TrimPrefix(signer, "0x")) + if len(s) != 40 && len(s) != 64 { + return "", fmt.Errorf("expected signer %q is not a 20 or 32 byte hex value", signer) + } + if _, err := hex.DecodeString(s); err != nil { + return "", fmt.Errorf("expected signer %q is not hex: %w", signer, err) + } + + if len(s) == 64 && strings.Trim(s[40:], "0") != "" { + return "", fmt.Errorf("expected signer %q is not a zero-padded 20 byte address", signer) + } + + return s[:40], nil +} + +func jdDONName(config ProposeJobSpecInput) string { + if config.JDDONName != "" { + return config.JDDONName + } + + return config.DONName +} + +// targetNodeFilter reproduces the JD node selection of the operation that proposes the template, so +// the check validates the same nodes the proposal targets. +func targetNodeFilter(config ProposeJobSpecInput) *nodev1.ListNodesRequest_Filter { + switch config.Template { + case job_types.OCR3, job_types.Ring: + filter := &nodev1.ListNodesRequest_Filter{} + for _, f := range config.DONFilters { + filter = f.AddToFilter(filter) + } + + return offchain.TargetDONFilter{Key: "type", Value: "plugin"}.AddToFilter(filter) + default: + nodeType := job_ops.PluginNodeType + filter := &nodev1.ListNodesRequest_Filter{ + Selectors: []*ptypes.Selector{ + {Key: "don-" + jdDONName(config), Op: ptypes.SelectorOp_EXIST}, + {Key: "environment", Op: ptypes.SelectorOp_EQ, Value: &config.Environment}, + {Key: "product", Op: ptypes.SelectorOp_EQ, Value: &config.Domain}, + {Key: "type", Op: ptypes.SelectorOp_EQ, Value: &nodeType}, + }, + } + for _, f := range config.DONFilters { + filter = f.AddToFilter(filter) + } + for _, f := range config.DONFilters { + filter = f.AddToFilterIfNotPresent(filter) + } + + return filter + } +} + +// specSelectors are the chain selectors the spec reads OCR key bundles from. EVM is zero when the +// template does not pin one, in which case any EVM bundle may match. +type specSelectors struct { + EVM uint64 + NonEVM []uint64 + // Skip is set when the spec takes no bundle IDs from JD. + Skip bool +} + +func specChainSelectors(config ProposeJobSpecInput) (specSelectors, error) { + var evm pkg.ChainSelector + var raw []pkg.ChainSelector + switch config.Template { //nolint:exhaustive // only templates in templatesWithOCRKeys reach here + case job_types.OCR3: + in, err := config.Inputs.ToOCR3JobConfigInput() + if err != nil { + return specSelectors{}, fmt.Errorf("keyring check: failed to parse OCR3 inputs: %w", err) + } + evm = in.ChainSelectorEVM + raw = []pkg.ChainSelector{in.ChainSelectorAptos, in.ChainSelectorSolana} + case job_types.Consensus, job_types.Aptos, job_types.Solana, job_types.Stellar: + job, err := config.Inputs.ToStandardCapabilityJob(config.JobName) + if err != nil { + return specSelectors{}, fmt.Errorf("keyring check: failed to parse standard capability inputs: %w", err) + } + // Mirrors the operation: an explicit or minimal oracle factory means no JD bundles are used. + if job.MinimalOracleFactory || job.OracleFactory != nil { + return specSelectors{Skip: true}, nil + } + // Matches generateOracleFactory: the OCR contract chain wins over the EVM selector. + evm = job.ChainSelectorEVM + if job.OCRChainSelector != 0 { + evm = job.OCRChainSelector + } + raw = []pkg.ChainSelector{job.ChainSelectorAptos, job.ChainSelectorSolana, job.ChainSelectorStellar} + case job_types.Ring: + var in pkg.RingJobConfigInput + if err := config.Inputs.UnmarshalTo(&in); err != nil { + return specSelectors{}, fmt.Errorf("keyring check: failed to parse Ring inputs: %w", err) + } + evm = in.ChainSelectorEVM + } + + out := specSelectors{EVM: uint64(evm)} + for _, s := range raw { + if s != 0 { + out.NonEVM = append(out.NonEVM, uint64(s)) + } + } + + return out, nil +} + +// evmBundleProblems requires the node's EVM OCR bundle for the spec's chain selector (or, when the +// template pins none, any EVM chain) to have a non-empty ID and the wanted signing address. +func evmBundleProblems(n deployment.Node, want string, evmSel uint64) []string { + var problems []string + var have []string + matched := false + for details, cfg := range n.SelToOCRConfig { + if evmSel != 0 && details.ChainSelector != evmSel { + continue + } + family, err := chainsel.GetSelectorFamily(details.ChainSelector) + if err != nil || family != chainsel.FamilyEVM { + continue + } + if cfg.KeyBundleID == "" { + problems = append(problems, fmt.Sprintf("%s: JD has an empty OCR key bundle ID for chain selector %d", n.Name, details.ChainSelector)) + + continue + } + addr := hex.EncodeToString(cfg.OnchainPublicKey) + have = append(have, addr) + if addr == want { + matched = true + } + } + switch { + case matched: + case len(have) == 0: + problems = append(problems, n.Name+": no EVM OCR key bundle in JD") + default: + slices.Sort(have) + problems = append(problems, fmt.Sprintf("%s: expected signer %s matches no JD EVM bundle (JD has %s)", n.Name, want, strings.Join(have, ", "))) + } + + return problems +} + +func nonEVMBundleProblems(nodeInfos deployment.Nodes, selectors []uint64) []string { + var problems []string + for _, sel := range selectors { + owners := make(map[string][]string) + for _, n := range nodeInfos { + if n.IsBootstrap { + continue + } + cfg, ok := n.OCRConfigForChainSelector(sel) + switch { + case !ok: + problems = append(problems, fmt.Sprintf("%s: no OCR key bundle in JD for chain selector %d", n.Name, sel)) + case cfg.KeyBundleID == "": + problems = append(problems, fmt.Sprintf("%s: JD has an empty OCR key bundle ID for chain selector %d", n.Name, sel)) + default: + owners[cfg.KeyBundleID] = append(owners[cfg.KeyBundleID], n.Name) + } + } + for id, names := range owners { + if len(names) > 1 { + slices.Sort(names) + problems = append(problems, fmt.Sprintf("chain selector %d: bundle ID %s is shared by nodes %s", sel, id, strings.Join(names, ", "))) + } + } + } + + return problems +} diff --git a/deployment/cre/jobs/propose_job_spec_keyring_check_test.go b/deployment/cre/jobs/propose_job_spec_keyring_check_test.go new file mode 100644 index 00000000000..588a70d485b --- /dev/null +++ b/deployment/cre/jobs/propose_job_spec_keyring_check_test.go @@ -0,0 +1,294 @@ +package jobs + +import ( + "encoding/hex" + "strings" + "testing" + + "github.com/stretchr/testify/require" + + chainsel "github.com/smartcontractkit/chain-selectors" + + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" + "github.com/smartcontractkit/chainlink/deployment" + job_types "github.com/smartcontractkit/chainlink/deployment/cre/jobs/types" + "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" +) + +const ( + testSignerA = "02baa006fc5f6e9c138c37fb58c962bb7f40ca7c" + testSignerB = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + testCSAKey = "csa-1" +) + +func nodeWithEVMBundle(t *testing.T, addrHex, bundleID string) deployment.Node { + t.Helper() + b, err := hex.DecodeString(addrHex) + require.NoError(t, err) + + return deployment.Node{ + Name: "node-1", + CSAKey: testCSAKey, + SelToOCRConfig: map[chainsel.ChainDetails]deployment.OCRConfig{ + {ChainSelector: chainsel.ETHEREUM_MAINNET.Selector}: {OnchainPublicKey: b, KeyBundleID: bundleID}, + }, + } +} + +func TestCheckKeyringsAgainstExpected(t *testing.T) { + t.Parallel() + + padded := testSignerA + "000000000000000000000000" + tests := []struct { + name string + nodes deployment.Nodes + expected map[string]string + wantErr string + }{ + {"padded signer matches", deployment.Nodes{nodeWithEVMBundle(t, testSignerA, "b")}, map[string]string{testCSAKey: padded}, ""}, + {"0x unpadded signer matches", deployment.Nodes{nodeWithEVMBundle(t, testSignerA, "b")}, map[string]string{testCSAKey: "0x" + testSignerA}, ""}, + {"signer mismatch", deployment.Nodes{nodeWithEVMBundle(t, testSignerB, "b")}, map[string]string{testCSAKey: padded}, "expected signer " + testSignerA + " matches no JD EVM bundle"}, + {"empty bundle id", deployment.Nodes{nodeWithEVMBundle(t, testSignerA, "")}, map[string]string{testCSAKey: padded}, "empty OCR key bundle ID"}, + {"node without expected signer", deployment.Nodes{nodeWithEVMBundle(t, testSignerA, "b")}, map[string]string{"other": padded}, "no expected signer"}, + {"no evm bundle", deployment.Nodes{{Name: "node-1", CSAKey: testCSAKey}}, map[string]string{testCSAKey: padded}, "no EVM OCR key bundle in JD"}, + {"malformed signer", deployment.Nodes{nodeWithEVMBundle(t, testSignerA, "b")}, map[string]string{testCSAKey: "zz"}, "not a 20 or 32 byte hex value"}, + {"non-zero padding rejected", deployment.Nodes{nodeWithEVMBundle(t, testSignerA, "b")}, map[string]string{testCSAKey: testSignerA + "000000000000000000000001"}, "not a zero-padded 20 byte address"}, + {"uppercase signer matches", deployment.Nodes{nodeWithEVMBundle(t, testSignerA, "b")}, map[string]string{testCSAKey: "0x" + strings.ToUpper(testSignerA)}, ""}, + {"bootstrap skipped", deployment.Nodes{{Name: "bt", CSAKey: "x", IsBootstrap: true}}, map[string]string{testCSAKey: padded}, ""}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + err := checkKeyringsAgainstExpected(tt.nodes, tt.expected, specSelectors{}) + if tt.wantErr == "" { + require.NoError(t, err) + + return + } + require.ErrorContains(t, err, tt.wantErr) + }) + } +} + +func TestVerifyOCRKeyrings_Gating(t *testing.T) { + t.Parallel() + + base := ProposeJobSpecInput{ + Environment: "staging", + Domain: "cre", + DONName: "don", + DONFilters: []offchain.TargetDONFilter{{Key: "k", Value: "v"}}, + JobName: "job", + Template: job_types.Consensus, + ExpectedSigners: map[string]string{testCSAKey: testSignerA}, + Inputs: job_types.JobSpecInput{"command": "consensus"}, + } + + t.Run("no expected signers is a no-op", func(t *testing.T) { + t.Parallel() + in := base + in.ExpectedSigners = nil + require.NoError(t, verifyOCRKeyrings(cldf.Environment{}, in)) + }) + t.Run("skip flag bypasses JD", func(t *testing.T) { + t.Parallel() + in := base + in.SkipKeyringCheck = true + require.NoError(t, verifyOCRKeyrings(cldf.Environment{}, in)) + }) + t.Run("non-OCR template bypasses JD", func(t *testing.T) { + t.Parallel() + in := base + in.Template = job_types.Cron + require.NoError(t, verifyOCRKeyrings(cldf.Environment{}, in)) + }) + t.Run("EVM template bypasses JD", func(t *testing.T) { + t.Parallel() + in := base + in.Template = job_types.EVM + require.NoError(t, verifyOCRKeyrings(cldf.Environment{}, in)) + }) + t.Run("minimal oracle factory bypasses JD", func(t *testing.T) { + t.Parallel() + in := base + in.Inputs = job_types.JobSpecInput{"command": "consensus", "minimalOracleFactory": true} + require.NoError(t, verifyOCRKeyrings(cldf.Environment{}, in)) + }) + t.Run("explicit oracle factory bypasses JD", func(t *testing.T) { + t.Parallel() + in := base + in.Inputs = job_types.JobSpecInput{"command": "consensus", "oracleFactory": map[string]any{"enabled": true}} + require.NoError(t, verifyOCRKeyrings(cldf.Environment{}, in)) + }) + t.Run("invalid inputs fail before any JD call", func(t *testing.T) { + t.Parallel() + in := base + in.Inputs = job_types.JobSpecInput{"chainSelectorEVM": "not-a-number"} + require.ErrorContains(t, verifyOCRKeyrings(cldf.Environment{}, in), "failed to parse") + }) + t.Run("OCR template without JD client errors", func(t *testing.T) { + t.Parallel() + require.ErrorContains(t, verifyOCRKeyrings(cldf.Environment{}, base), "needs a job distributor client") + }) +} + +func selectorKeys(f *nodev1.ListNodesRequest_Filter) []string { + keys := make([]string, 0, len(f.GetSelectors())) + for _, s := range f.GetSelectors() { + keys = append(keys, s.GetKey()) + } + + return keys +} + +func TestTargetNodeFilter_MatchesProposingOperation(t *testing.T) { + t.Parallel() + + base := ProposeJobSpecInput{ + Environment: "staging", + Domain: "cre", + DONName: "don", + DONFilters: []offchain.TargetDONFilter{{Key: "zone", Value: "a"}}, + } + + for _, tmpl := range []job_types.JobSpecTemplate{job_types.OCR3, job_types.Ring} { + in := base + in.Template = tmpl + keys := selectorKeys(targetNodeFilter(in)) + require.ElementsMatch(t, []string{"zone", "type"}, keys, tmpl.String()) + } + + for _, tmpl := range []job_types.JobSpecTemplate{job_types.Consensus, job_types.EVM, job_types.Aptos, job_types.Solana, job_types.Stellar} { + in := base + in.Template = tmpl + keys := selectorKeys(targetNodeFilter(in)) + require.Contains(t, keys, "don-don", tmpl.String()) + require.Contains(t, keys, "environment", tmpl.String()) + require.Contains(t, keys, "product", tmpl.String()) + } + + in := base + in.Template = job_types.Consensus + in.JDDONName = "jd-don" + require.Contains(t, selectorKeys(targetNodeFilter(in)), "don-jd-don") +} + +func nodeWithBundles(name string, bundles map[uint64]string) deployment.Node { + n := deployment.Node{Name: name, CSAKey: name, SelToOCRConfig: map[chainsel.ChainDetails]deployment.OCRConfig{}} + for sel, id := range bundles { + n.SelToOCRConfig[chainsel.ChainDetails{ChainSelector: sel}] = deployment.OCRConfig{KeyBundleID: id} + } + + return n +} + +func TestNonEVMBundleProblems(t *testing.T) { + t.Parallel() + + aptos := chainsel.APTOS_MAINNET.Selector + tests := []struct { + name string + nodes deployment.Nodes + want []string + }{ + { + name: "distinct bundles pass", + nodes: deployment.Nodes{ + nodeWithBundles("n1", map[uint64]string{aptos: "b1"}), + nodeWithBundles("n2", map[uint64]string{aptos: "b2"}), + }, + }, + { + name: "missing bundle", + nodes: deployment.Nodes{ + nodeWithBundles("n1", map[uint64]string{aptos: "b1"}), + nodeWithBundles("n2", nil), + }, + want: []string{"n2: no OCR key bundle in JD for chain selector"}, + }, + { + name: "empty bundle id", + nodes: deployment.Nodes{nodeWithBundles("n1", map[uint64]string{aptos: ""})}, + want: []string{"n1: JD has an empty OCR key bundle ID"}, + }, + { + name: "shared bundle id", + nodes: deployment.Nodes{ + nodeWithBundles("n1", map[uint64]string{aptos: "same"}), + nodeWithBundles("n2", map[uint64]string{aptos: "same"}), + }, + want: []string{"bundle ID same is shared by nodes n1, n2"}, + }, + { + name: "bootstrap skipped", + nodes: deployment.Nodes{{Name: "bt", IsBootstrap: true}}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + got := nonEVMBundleProblems(tt.nodes, []uint64{aptos}) + require.Len(t, got, len(tt.want)) + for i, w := range tt.want { + require.Contains(t, got[i], w) + } + }) + } +} + +func TestSpecChainSelectors(t *testing.T) { + t.Parallel() + + in := ProposeJobSpecInput{ + Template: job_types.Consensus, + JobName: "j", + Inputs: job_types.JobSpecInput{ + "command": "consensus", "chainSelectorEVM": 5, "chainSelectorAptos": 7, "chainSelectorSolana": 8, + }, + } + got, err := specChainSelectors(in) + require.NoError(t, err) + require.Equal(t, uint64(5), got.EVM) + require.ElementsMatch(t, []uint64{7, 8}, got.NonEVM) + + in.Inputs["ocrChainSelector"] = 6 + got, err = specChainSelectors(in) + require.NoError(t, err) + require.Equal(t, uint64(6), got.EVM, "ocrChainSelector wins") + + in.Template = job_types.OCR3 + in.Inputs["templateName"] = "t" + in.Inputs["contractQualifier"] = "q" + in.Inputs["bootstrapperOCR3Urls"] = []any{"u"} + got, err = specChainSelectors(in) + require.NoError(t, err) + require.Equal(t, uint64(5), got.EVM) + require.ElementsMatch(t, []uint64{7, 8}, got.NonEVM) + + in.Template = job_types.Ring + got, err = specChainSelectors(in) + require.NoError(t, err) + require.Equal(t, uint64(5), got.EVM) + require.Empty(t, got.NonEVM) +} + +func TestEVMBundleProblems_PinnedSelector(t *testing.T) { + t.Parallel() + + selA := chainsel.ETHEREUM_MAINNET.Selector + selB := chainsel.ETHEREUM_TESTNET_SEPOLIA.Selector + a, err := hex.DecodeString(testSignerA) + require.NoError(t, err) + b, err := hex.DecodeString(testSignerB) + require.NoError(t, err) + n := deployment.Node{Name: "n1", SelToOCRConfig: map[chainsel.ChainDetails]deployment.OCRConfig{ + {ChainSelector: selA}: {OnchainPublicKey: a, KeyBundleID: "ba"}, + {ChainSelector: selB}: {OnchainPublicKey: b, KeyBundleID: "bb"}, + }} + + require.Empty(t, evmBundleProblems(n, testSignerA, selA)) + require.Empty(t, evmBundleProblems(n, testSignerA, 0), "unpinned accepts any EVM chain") + require.NotEmpty(t, evmBundleProblems(n, testSignerA, selB), "pinned to the chain whose bundle differs") + require.NotEmpty(t, evmBundleProblems(n, testSignerA, chainsel.ETHEREUM_TESTNET_HOLESKY.Selector), "pinned chain missing") +} diff --git a/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go b/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go new file mode 100644 index 00000000000..ccc6d751dfd --- /dev/null +++ b/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go @@ -0,0 +1,108 @@ +package jobs_test + +import ( + "encoding/hex" + "strconv" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" + "github.com/smartcontractkit/chainlink/deployment" + "github.com/smartcontractkit/chainlink/deployment/cre/jobs" + job_types "github.com/smartcontractkit/chainlink/deployment/cre/jobs/types" + "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" + "github.com/smartcontractkit/chainlink/deployment/cre/test" +) + +func TestProposeJobSpec_VerifyPreconditions_KeyringCheck(t *testing.T) { + h := test.NewTestHarness(t) + env := h.Runtime.Environment() + + resp, err := h.TestJD.ListNodes(t.Context(), &node.ListNodesRequest{}) + require.NoError(t, err) + ids := make([]string, 0, len(resp.Nodes)) + for _, n := range resp.Nodes { + ids = append(ids, n.Id) + } + infos, err := deployment.NodeInfo(ids, h.TestJD) + require.NoError(t, err) + + expected := make(map[string]string) + for _, n := range infos { + if n.IsBootstrap { + continue + } + cfg, ok := n.OCRConfigForChainSelector(h.RegistrySelector) + require.True(t, ok) + expected[n.CSAKey] = hex.EncodeToString(cfg.OnchainPublicKey) + } + require.NotEmpty(t, expected) + + newInput := func(signers map[string]string) jobs.ProposeJobSpecInput { + return jobs.ProposeJobSpecInput{ + Environment: test.EnvironmentName, + Domain: "cre", + JobName: "consensus-cap-job", + DONName: test.DONName, + Template: job_types.Consensus, + DONFilters: []offchain.TargetDONFilter{ + {Key: offchain.FilterKeyDONName, Value: test.DONName}, + {Key: "environment", Value: test.EnvironmentName}, + {Key: "product", Value: offchain.ProductLabel}, + }, + Inputs: job_types.JobSpecInput{ + "command": "consensus", + "chainSelectorEVM": strconv.FormatUint(h.RegistrySelector, 10), + }, + ExpectedSigners: signers, + } + } + + t.Run("matching signers pass", func(t *testing.T) { + require.NoError(t, jobs.ProposeJobSpec{}.VerifyPreconditions(env, newInput(expected))) + }) + + t.Run("no expected signers skips the check", func(t *testing.T) { + require.NoError(t, jobs.ProposeJobSpec{}.VerifyPreconditions(env, newInput(nil))) + }) + + t.Run("a wrong signer is rejected", func(t *testing.T) { + bad := make(map[string]string, len(expected)) + var victim string + for csa, addr := range expected { + bad[csa] = addr + victim = csa + } + bad[victim] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + + err := jobs.ProposeJobSpec{}.VerifyPreconditions(env, newInput(bad)) + require.ErrorContains(t, err, "matches no JD EVM bundle") + + in := newInput(bad) + in.SkipKeyringCheck = true + require.NoError(t, jobs.ProposeJobSpec{}.VerifyPreconditions(env, in)) + }) + + t.Run("non-EVM bundles shared between nodes are rejected", func(t *testing.T) { + in := newInput(expected) + in.Inputs["chainSelectorAptos"] = strconv.FormatUint(h.AptosSelector, 10) + + // the harness gives every node the same fake aptos bundle ID + err := jobs.ProposeJobSpec{}.VerifyPreconditions(env, in) + require.ErrorContains(t, err, "is shared by nodes") + }) + + t.Run("a node missing from expected signers is rejected", func(t *testing.T) { + // one entry leaves the other targeted nodes without an expected signer + partial := make(map[string]string) + for csa, addr := range expected { + partial[csa] = addr + + break + } + + err := jobs.ProposeJobSpec{}.VerifyPreconditions(env, newInput(partial)) + require.ErrorContains(t, err, "no expected signer for csa") + }) +} From 725b68824a1ba3f037154fe73556bc60e883fe64 Mon Sep 17 00:00:00 2001 From: Justin Kaseman Date: Thu, 19 Nov 2026 15:43:09 -0800 Subject: [PATCH 2/4] Soothe flaky test --- deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go b/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go index ccc6d751dfd..4538a173e77 100644 --- a/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go +++ b/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go @@ -68,13 +68,11 @@ func TestProposeJobSpec_VerifyPreconditions_KeyringCheck(t *testing.T) { }) t.Run("a wrong signer is rejected", func(t *testing.T) { + // corrupt every entry so the check hits a targeted node whichever nodes the proposal selects bad := make(map[string]string, len(expected)) - var victim string - for csa, addr := range expected { - bad[csa] = addr - victim = csa + for csa := range expected { + bad[csa] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } - bad[victim] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" err := jobs.ProposeJobSpec{}.VerifyPreconditions(env, newInput(bad)) require.ErrorContains(t, err, "matches no JD EVM bundle") From 9b2b250d0f4bb5ef5c6d30196cb4c08285fd02db Mon Sep 17 00:00:00 2001 From: Justin Kaseman Date: Thu, 19 Nov 2026 15:51:42 -0800 Subject: [PATCH 3/4] Changes from copilot review --- .../cre/jobs/operations/node_filters.go | 41 +++++++++++++++++++ .../cre/jobs/operations/propose_ocr3_job.go | 14 +------ .../cre/jobs/operations/propose_ring_job.go | 14 +------ .../jobs/operations/propose_std_cap_job.go | 33 +-------------- .../jobs/propose_job_spec_keyring_check.go | 30 ++------------ deployment/environment.go | 4 ++ deployment/environment_test.go | 24 +++++++++++ 7 files changed, 76 insertions(+), 84 deletions(-) create mode 100644 deployment/cre/jobs/operations/node_filters.go diff --git a/deployment/cre/jobs/operations/node_filters.go b/deployment/cre/jobs/operations/node_filters.go new file mode 100644 index 00000000000..93bc557e657 --- /dev/null +++ b/deployment/cre/jobs/operations/node_filters.go @@ -0,0 +1,41 @@ +package operations + +import ( + nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" + "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/shared/ptypes" + + "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" +) + +// StandardCapabilityNodeFilter is the JD node selection of the standard capability proposal. +// jdDONName is the resolved JD DON name (JDDONName if set, else DONName). +func StandardCapabilityNodeFilter(jdDONName, environment, domain string, donFilters []offchain.TargetDONFilter) *nodev1.ListNodesRequest_Filter { + nodeType := PluginNodeType + filter := &nodev1.ListNodesRequest_Filter{ + Selectors: []*ptypes.Selector{ + {Key: "don-" + jdDONName, Op: ptypes.SelectorOp_EXIST}, + {Key: "environment", Op: ptypes.SelectorOp_EQ, Value: &environment}, + {Key: "product", Op: ptypes.SelectorOp_EQ, Value: &domain}, + {Key: "type", Op: ptypes.SelectorOp_EQ, Value: &nodeType}, + }, + } + for _, f := range donFilters { + filter = f.AddToFilter(filter) + } + for _, f := range donFilters { + filter = f.AddToFilterIfNotPresent(filter) + } + + return filter +} + +// PluginDONNodeFilter is the JD node selection of the OCR3 and Ring proposals: the DON filters +// restricted to plugin nodes. +func PluginDONNodeFilter(donFilters []offchain.TargetDONFilter) *nodev1.ListNodesRequest_Filter { + filter := &nodev1.ListNodesRequest_Filter{} + for _, f := range donFilters { + filter = f.AddToFilter(filter) + } + + return offchain.TargetDONFilter{Key: "type", Value: PluginNodeType}.AddToFilter(filter) +} diff --git a/deployment/cre/jobs/operations/propose_ocr3_job.go b/deployment/cre/jobs/operations/propose_ocr3_job.go index edc27214714..30efaff86b7 100644 --- a/deployment/cre/jobs/operations/propose_ocr3_job.go +++ b/deployment/cre/jobs/operations/propose_ocr3_job.go @@ -7,7 +7,6 @@ import ( cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" "github.com/smartcontractkit/chainlink-deployments-framework/operations" - nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" "github.com/smartcontractkit/chainlink/deployment/cre/jobs/pkg" "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" @@ -55,18 +54,7 @@ var ProposeOCR3Job = operations.NewSequence[ProposeOCR3JobInput, ProposeOCR3JobO semver.MustParse("1.0.0"), "Propose OCR3 Job", func(b operations.Bundle, deps ProposeOCR3JobDeps, input ProposeOCR3JobInput) (ProposeOCR3JobOutput, error) { - filters := &nodev1.ListNodesRequest_Filter{} - for _, f := range input.DONFilters { - filters = offchain.TargetDONFilter{ - Key: f.Key, - Value: f.Value, - }.AddToFilter(filters) - } - // We only want to target plugin nodes for OCR3 jobs. - filters = offchain.TargetDONFilter{ - Key: "type", - Value: "plugin", - }.AddToFilter(filters) + filters := PluginDONNodeFilter(input.DONFilters) nodes, err := pkg.FetchNodesFromJD(b.GetContext(), deps.Env, pkg.FetchNodesRequest{ Domain: input.Domain, Filters: filters, diff --git a/deployment/cre/jobs/operations/propose_ring_job.go b/deployment/cre/jobs/operations/propose_ring_job.go index 565a8b86c42..28ca82cb55d 100644 --- a/deployment/cre/jobs/operations/propose_ring_job.go +++ b/deployment/cre/jobs/operations/propose_ring_job.go @@ -8,7 +8,6 @@ import ( cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" "github.com/smartcontractkit/chainlink-deployments-framework/operations" - nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" "github.com/smartcontractkit/chainlink/deployment/cre/jobs/pkg" "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" @@ -47,18 +46,7 @@ var ProposeRingJob = operations.NewSequence[ProposeRingJobInput, ProposeRingJobO semver.MustParse("1.0.0"), "Propose Ring Job", func(b operations.Bundle, deps ProposeRingJobDeps, input ProposeRingJobInput) (ProposeRingJobOutput, error) { - filters := &nodev1.ListNodesRequest_Filter{} - for _, f := range input.DONFilters { - filters = offchain.TargetDONFilter{ - Key: f.Key, - Value: f.Value, - }.AddToFilter(filters) - } - // We only want to target plugin nodes for Ring jobs. - filters = offchain.TargetDONFilter{ - Key: "type", - Value: "plugin", - }.AddToFilter(filters) + filters := PluginDONNodeFilter(input.DONFilters) nodes, err := pkg.FetchNodesFromJD(b.GetContext(), deps.Env, pkg.FetchNodesRequest{ Domain: input.Domain, Filters: filters, diff --git a/deployment/cre/jobs/operations/propose_std_cap_job.go b/deployment/cre/jobs/operations/propose_std_cap_job.go index 93bfae94859..5f3e73c4548 100644 --- a/deployment/cre/jobs/operations/propose_std_cap_job.go +++ b/deployment/cre/jobs/operations/propose_std_cap_job.go @@ -15,8 +15,6 @@ import ( cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" cldf_offchain "github.com/smartcontractkit/chainlink-deployments-framework/offchain" "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" - "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/shared/ptypes" "github.com/smartcontractkit/chainlink/deployment" "github.com/smartcontractkit/chainlink/deployment/common/view" "github.com/smartcontractkit/chainlink/deployment/cre/jobs/pkg" @@ -74,36 +72,7 @@ var ProposeStandardCapabilityJob = operations.NewSequence[ jdDONName = input.JDDONName } - filter := &node.ListNodesRequest_Filter{ - Selectors: []*ptypes.Selector{ - { - Key: "don-" + jdDONName, - Op: ptypes.SelectorOp_EXIST, - }, - { - Key: "environment", - Op: ptypes.SelectorOp_EQ, - Value: &input.Environment, - }, - { - Key: "product", - Op: ptypes.SelectorOp_EQ, - Value: &input.Domain, - }, - { - Key: "type", - Op: ptypes.SelectorOp_EQ, - Value: new(PluginNodeType), - }, - }, - } - for _, f := range input.DONFilters { - filter = f.AddToFilter(filter) - } - - for _, f := range input.DONFilters { - filter = f.AddToFilterIfNotPresent(filter) - } + filter := StandardCapabilityNodeFilter(jdDONName, input.Environment, input.Domain, input.DONFilters) nodes, err := offchain.FetchNodesFromJD(b.GetContext(), deps.Env.Offchain, filter) if err != nil { diff --git a/deployment/cre/jobs/propose_job_spec_keyring_check.go b/deployment/cre/jobs/propose_job_spec_keyring_check.go index 8d0b9cc3f37..ca22e74f74a 100644 --- a/deployment/cre/jobs/propose_job_spec_keyring_check.go +++ b/deployment/cre/jobs/propose_job_spec_keyring_check.go @@ -11,7 +11,6 @@ import ( cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" - "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/shared/ptypes" "github.com/smartcontractkit/chainlink/deployment" job_ops "github.com/smartcontractkit/chainlink/deployment/cre/jobs/operations" "github.com/smartcontractkit/chainlink/deployment/cre/jobs/pkg" @@ -137,35 +136,14 @@ func jdDONName(config ProposeJobSpecInput) string { return config.DONName } -// targetNodeFilter reproduces the JD node selection of the operation that proposes the template, so -// the check validates the same nodes the proposal targets. +// targetNodeFilter uses the same filter builders as the proposing operations, so the check validates +// the same nodes the proposal targets. func targetNodeFilter(config ProposeJobSpecInput) *nodev1.ListNodesRequest_Filter { switch config.Template { case job_types.OCR3, job_types.Ring: - filter := &nodev1.ListNodesRequest_Filter{} - for _, f := range config.DONFilters { - filter = f.AddToFilter(filter) - } - - return offchain.TargetDONFilter{Key: "type", Value: "plugin"}.AddToFilter(filter) + return job_ops.PluginDONNodeFilter(config.DONFilters) default: - nodeType := job_ops.PluginNodeType - filter := &nodev1.ListNodesRequest_Filter{ - Selectors: []*ptypes.Selector{ - {Key: "don-" + jdDONName(config), Op: ptypes.SelectorOp_EXIST}, - {Key: "environment", Op: ptypes.SelectorOp_EQ, Value: &config.Environment}, - {Key: "product", Op: ptypes.SelectorOp_EQ, Value: &config.Domain}, - {Key: "type", Op: ptypes.SelectorOp_EQ, Value: &nodeType}, - }, - } - for _, f := range config.DONFilters { - filter = f.AddToFilter(filter) - } - for _, f := range config.DONFilters { - filter = f.AddToFilterIfNotPresent(filter) - } - - return filter + return job_ops.StandardCapabilityNodeFilter(jdDONName(config), config.Environment, config.Domain, config.DONFilters) } } diff --git a/deployment/environment.go b/deployment/environment.go index f31eef5cf0f..b3de03a8491 100644 --- a/deployment/environment.go +++ b/deployment/environment.go @@ -358,6 +358,10 @@ func NewNodeFromJD(jdNode *nodev1.Node, chainConfigs []*nodev1.ChainConfig) (*No func ChainConfigsToOCRConfig(chainConfigs []*nodev1.ChainConfig) (map[chain_selectors.ChainDetails]OCRConfig, error) { selToOCRConfig := make(map[chain_selectors.ChainDetails]OCRConfig) for _, chainConfig := range chainConfigs { + // A chain config without OCR2 enabled carries no key bundle; leave it out instead of panicking. + if chainConfig.GetOcr2Config().GetOcrKeyBundle() == nil || chainConfig.GetOcr2Config().GetP2PKeyBundle() == nil { + continue + } b := common.Hex2Bytes(chainConfig.Ocr2Config.OcrKeyBundle.OffchainPublicKey) var opk types2.OffchainPublicKey copy(opk[:], b) diff --git a/deployment/environment_test.go b/deployment/environment_test.go index 49df6a0182b..7d4193a9f36 100644 --- a/deployment/environment_test.go +++ b/deployment/environment_test.go @@ -466,3 +466,27 @@ func TestNewNodeFromJD(t *testing.T) { }) } } + +func TestChainConfigsToOCRConfig_SkipsConfigsWithoutOCR2Bundle(t *testing.T) { + evmDetails, err := chainToDetails(&nodev1.Chain{Type: nodev1.ChainType_CHAIN_TYPE_EVM, Id: "1"}) + require.NoError(t, err) + p2p := p2pkey.MustNewV2XXXTestingOnly(big.NewInt(1)).PeerID().String() + + good := &nodev1.ChainConfig{ + Chain: &nodev1.Chain{Type: nodev1.ChainType_CHAIN_TYPE_EVM, Id: "1"}, + Ocr2Config: &nodev1.OCR2Config{ + P2PKeyBundle: &nodev1.OCR2Config_P2PKeyBundle{PeerId: p2p}, + OcrKeyBundle: &nodev1.OCR2Config_OCRKeyBundle{BundleId: "bundle-1"}, + }, + } + noBundle := &nodev1.ChainConfig{ + Chain: &nodev1.Chain{Type: nodev1.ChainType_CHAIN_TYPE_EVM, Id: "2"}, + Ocr2Config: &nodev1.OCR2Config{P2PKeyBundle: &nodev1.OCR2Config_P2PKeyBundle{PeerId: p2p}}, + } + noOCR2 := &nodev1.ChainConfig{Chain: &nodev1.Chain{Type: nodev1.ChainType_CHAIN_TYPE_EVM, Id: "3"}} + + got, err := ChainConfigsToOCRConfig([]*nodev1.ChainConfig{good, noBundle, noOCR2}) + require.NoError(t, err) + require.Len(t, got, 1) + require.Equal(t, "bundle-1", got[evmDetails].KeyBundleID) +} From 1daeb170fead0fcd66228b0d453aab722eaed2df Mon Sep 17 00:00:00 2001 From: Justin Kaseman Date: Thu, 19 Nov 2026 17:01:35 -0800 Subject: [PATCH 4/4] Return error instead of panicking on missing OCR2 metadata in NewNodeFromJD --- .../jobs/propose_job_spec_keyring_e2e_test.go | 48 +++++++++++++++++++ deployment/environment.go | 3 ++ 2 files changed, 51 insertions(+) diff --git a/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go b/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go index 4538a173e77..3d4398f51d7 100644 --- a/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go +++ b/deployment/cre/jobs/propose_job_spec_keyring_e2e_test.go @@ -1,11 +1,15 @@ package jobs_test import ( + "context" "encoding/hex" + "errors" "strconv" "testing" "github.com/stretchr/testify/require" + "google.golang.org/grpc" + "google.golang.org/protobuf/proto" "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node" "github.com/smartcontractkit/chainlink/deployment" @@ -13,6 +17,7 @@ import ( job_types "github.com/smartcontractkit/chainlink/deployment/cre/jobs/types" "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" "github.com/smartcontractkit/chainlink/deployment/cre/test" + envtest "github.com/smartcontractkit/chainlink/deployment/environment/test" ) func TestProposeJobSpec_VerifyPreconditions_KeyringCheck(t *testing.T) { @@ -103,4 +108,47 @@ func TestProposeJobSpec_VerifyPreconditions_KeyringCheck(t *testing.T) { err := jobs.ProposeJobSpec{}.VerifyPreconditions(env, newInput(partial)) require.ErrorContains(t, err, "no expected signer for csa") }) + + t.Run("EVM chain config without OCR2 metadata errors instead of panicking", func(t *testing.T) { + broken := env + broken.Offchain = rewriteChainConfigsJD{h.TestJD, func(cc *node.ChainConfig) { cc.Ocr2Config = nil }} + + err := jobs.ProposeJobSpec{}.VerifyPreconditions(broken, newInput(expected)) + require.ErrorContains(t, err, "no OCR2 or P2P key bundle") + }) + + t.Run("an unrelated chain config without a key bundle is skipped", func(t *testing.T) { + broken := env + broken.Offchain = rewriteChainConfigsJD{h.TestJD, func(cc *node.ChainConfig) { + if cc.Chain.Type == node.ChainType_CHAIN_TYPE_APTOS { + cc.Ocr2Config.OcrKeyBundle = nil + } + }} + + require.NoError(t, jobs.ProposeJobSpec{}.VerifyPreconditions(broken, newInput(expected))) + }) +} + +// rewriteChainConfigsJD serves the harness JD's chain configs after applying rewrite to each copy. +type rewriteChainConfigsJD struct { + *envtest.JDNodeService + rewrite func(*node.ChainConfig) +} + +func (j rewriteChainConfigsJD) ListNodeChainConfigs(ctx context.Context, req *node.ListNodeChainConfigsRequest, opts ...grpc.CallOption) (*node.ListNodeChainConfigsResponse, error) { + resp, err := j.JDNodeService.ListNodeChainConfigs(ctx, req, opts...) + if err != nil { + return nil, err + } + out := make([]*node.ChainConfig, len(resp.ChainConfigs)) + for i, cc := range resp.ChainConfigs { + c, ok := proto.Clone(cc).(*node.ChainConfig) + if !ok { + return nil, errors.New("unexpected chain config type") + } + j.rewrite(c) + out[i] = c + } + + return &node.ListNodeChainConfigsResponse{ChainConfigs: out}, nil } diff --git a/deployment/environment.go b/deployment/environment.go index b3de03a8491..90ba69424ae 100644 --- a/deployment/environment.go +++ b/deployment/environment.go @@ -332,6 +332,9 @@ func NewNodeFromJD(jdNode *nodev1.Node, chainConfigs []*nodev1.ChainConfig) (*No if goldenConfig == nil { return emptyNode, fmt.Errorf("node '%s', id '%s', csa '%s': %w", jdNode.Name, jdNode.Id, jdNode.PublicKey, ErrMissingEVMChain) } + if goldenConfig.GetOcr2Config() == nil || goldenConfig.GetOcr2Config().GetP2PKeyBundle() == nil { + return emptyNode, fmt.Errorf("node '%s', id '%s', csa '%s': EVM chain config has no OCR2 or P2P key bundle", jdNode.Name, jdNode.Id, jdNode.PublicKey) + } selToOCRConfig := make(map[chain_selectors.ChainDetails]OCRConfig) bootstrap := goldenConfig.Ocr2Config.IsBootstrap if !bootstrap { // no ocr config on bootstrap