Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions deployment/cre/jobs/operations/node_filters.go
Original file line number Diff line number Diff line change
@@ -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)
}
14 changes: 1 addition & 13 deletions deployment/cre/jobs/operations/propose_ocr3_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 1 addition & 13 deletions deployment/cre/jobs/operations/propose_ring_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
33 changes: 1 addition & 32 deletions deployment/cre/jobs/operations/propose_std_cap_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 9 additions & 2 deletions deployment/cre/jobs/propose_job_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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) {
Expand Down
Loading
Loading