From 8f1afd84a8b9cd06625f382fcadd457e5949ceac Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Thu, 29 Oct 2026 07:16:59 -0500 Subject: [PATCH 01/10] ConsensusQueue: wire no-op ReportingPlugin --- .../workflow-gateway-capabilities-don.toml | 2 +- core/services/internal/internal.go | 9 ++ core/services/ocr2/delegate.go | 39 +++-- core/services/ocr2/validate/validate.go | 11 ++ core/services/ocr3_1/plugins/queue/config.go | 14 ++ core/services/ocr3_1/plugins/queue/queue.go | 89 ++++++----- .../ocr3_1/plugins/queue/transmitter.go | 33 ++++ .../workflows/v2/capability_executor.go | 12 +- .../workflows/v2/capability_executor_test.go | 8 +- .../workflows/v2/triggers/triggers.go | 25 +++ .../jobs/pkg/templates/consensus-queue.tmpl | 14 ++ deployment/cre/jobs/propose_job_spec_test.go | 2 + system-tests/lib/cre/don.go | 2 +- .../lib/cre/environment/environment.go | 43 ++++++ system-tests/lib/cre/features/queue/queue.go | 146 ++++++++++++++++++ system-tests/lib/cre/features/sets/sets.go | 2 + system-tests/lib/cre/flags/provider.go | 2 + system-tests/lib/cre/types.go | 3 +- 18 files changed, 384 insertions(+), 72 deletions(-) create mode 100644 core/services/internal/internal.go create mode 100644 core/services/ocr3_1/plugins/queue/config.go create mode 100644 core/services/ocr3_1/plugins/queue/transmitter.go create mode 100644 deployment/cre/jobs/pkg/templates/consensus-queue.tmpl create mode 100644 system-tests/lib/cre/features/queue/queue.go diff --git a/core/scripts/cre/environment/configs/workflow-gateway-capabilities-don.toml b/core/scripts/cre/environment/configs/workflow-gateway-capabilities-don.toml index e9cf7c74544..a885c6e09ab 100644 --- a/core/scripts/cre/environment/configs/workflow-gateway-capabilities-don.toml +++ b/core/scripts/cre/environment/configs/workflow-gateway-capabilities-don.toml @@ -49,7 +49,7 @@ supported_evm_chains = [1337, 2337] env_vars = { CL_EVM_CMD = "", OTEL_SERVICE_NAME = "chainlink-node", CL_CRE_SETTINGS = '{"global":{"PerOrg":{"BaseTriggerRetransmitEnabled":"true"}}}' } - capabilities = ["cron", "http-action", "http-trigger", "consensus", "don-time", "evm-1337"] + capabilities = ["cron", "http-action", "http-trigger", "consensus", "don-time", "evm-1337", "consensus-queue"] registry_based_launch_allowlist = ["cron-trigger@1.0.0", "dontime@1.0.0"] # See ./examples/workflow-don-overrides.toml to learn how to override capability configs diff --git a/core/services/internal/internal.go b/core/services/internal/internal.go new file mode 100644 index 00000000000..7da30869133 --- /dev/null +++ b/core/services/internal/internal.go @@ -0,0 +1,9 @@ +package internal + +import "github.com/smartcontractkit/chainlink-common/pkg/capabilities/actions/vault" + +const ( + ConsensusQueueCapabilityID = "consensus-queue@1.0.0" + DontimeCapabilityID = "dontime@1.0.0" + VaultCapabilityID = vault.CapabilityID +) diff --git a/core/services/ocr2/delegate.go b/core/services/ocr2/delegate.go index 0f3c7cdf358..faa8c5befc5 100644 --- a/core/services/ocr2/delegate.go +++ b/core/services/ocr2/delegate.go @@ -60,6 +60,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/config/env" "github.com/smartcontractkit/chainlink/v2/core/logger" "github.com/smartcontractkit/chainlink/v2/core/services/arbiter" + "github.com/smartcontractkit/chainlink/v2/core/services/internal" "github.com/smartcontractkit/chainlink/v2/core/services/job" "github.com/smartcontractkit/chainlink/v2/core/services/keystore" "github.com/smartcontractkit/chainlink/v2/core/services/llo" @@ -86,17 +87,17 @@ import ( ) const ( - vaultCapabilityID = "vault@1.0.0" + vaultCapabilityID = internal.VaultCapabilityID vaultOCRConfigKey = "vault" dkgOCRConfigKey = "dkg" - dontimeCapabilityID = "dontime@1.0.0" + dontimeCapabilityID = internal.DontimeCapabilityID // dontimeCapabilityPrefix matches any dontime version (e.g. "dontime@2.0.0"), // so the registry-driven launch guard keeps working if the version changes. dontimeCapabilityPrefix = "dontime" gaugeVaultDiskUsageBytes = "platform_vault_disk_usage_bytes" vaultDiskMonitorTickInterval = time.Minute - consensusQueueCapabilityID = "consensus-queue@1.0.0" + consensusQueueCapabilityID = internal.ConsensusQueueCapabilityID consensusQueueOCRConfigKey = "consensus-queue" gaugeConsensusQueueBytes = "platform_consensus_queue_usage_bytes" consensusQueueDiskMonitorTickInterval = time.Minute @@ -798,7 +799,11 @@ func (d *Delegate) newServicesConsensusQueue( ) (srvs []job.ServiceCtx, err error) { spec := jb.OCR2OracleSpec - // TODO ticket validate job spec + cfg := &queue.PluginConfig{} + err = json.Unmarshal(spec.PluginConfig.Bytes(), cfg) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal plugin config: %w", err) + } rid, relayer, err := d.getRelayer(spec) if err != nil { @@ -826,7 +831,7 @@ func (d *Delegate) newServicesConsensusQueue( rid.Network, rid.ChainID, spec.ContractID, - synchronization.TelemetryType(types.VaultPlugin), + synchronization.TelemetryType(types.ConsensusQueue), ) ocrLogger := ocrcommon.NewOCRWrapper(lggr, d.cfg.OCR2().TraceLogging(), func(ctx context.Context, msg string) { @@ -859,7 +864,6 @@ func (d *Delegate) newServicesConsensusQueue( return nil, err } - // Get DKG config tracker and digester, optionally wrapping with OCRConfigService configTracker, configDigester, lc, err := d.maybeWrapConfigService(consensusQueueCapabilityID, consensusQueueOCRConfigKey, lggr, provider.ContractConfigTracker(), provider.OffchainConfigDigester(), lc) if err != nil { return nil, err @@ -869,19 +873,20 @@ func (d *Delegate) newServicesConsensusQueue( BinaryNetworkEndpointFactory: d.peerWrapper.Peer3_1, V2Bootstrappers: bootstrapPeers, ContractConfigTracker: configTracker, - ContractTransmitter: nil, // TODO ticket transmitter - Database: ocrDB, - KeyValueDatabaseFactory: kvFactory, - LocalConfig: lc, - Logger: ocrLogger, - MonitoringEndpoint: oracleEndpoint, - OffchainConfigDigester: configDigester, - OffchainKeyring: kb, - OnchainKeyring: ocr3shims.OnchainKeyringAsOnchainKeyring2(onchainKeyringAdapter), - MetricsRegisterer: prometheus.WrapRegistererWith(map[string]string{"job_name": jb.Name.ValueOrZero()}, prometheus.DefaultRegisterer), + //TODO pass engine as EventSink + ContractTransmitter: queue.NewTransmitter(lggr, ocrtypes.Account(spec.TransmitterID.String), nil), + Database: ocrDB, + KeyValueDatabaseFactory: kvFactory, + LocalConfig: lc, + Logger: ocrLogger, + MonitoringEndpoint: oracleEndpoint, + OffchainConfigDigester: configDigester, + OffchainKeyring: kb, + OnchainKeyring: ocr3shims.OnchainKeyringAsOnchainKeyring2(onchainKeyringAdapter), + MetricsRegisterer: prometheus.WrapRegistererWith(map[string]string{"job_name": jb.Name.ValueOrZero()}, prometheus.DefaultRegisterer), } - rpf, err := queue.NewConsensusQueuePluginFactory(lggr, d.limitsFactory) + rpf, err := queue.NewConsensusQueuePluginFactory(lggr, cfg, d.limitsFactory) if err != nil { return nil, err } diff --git a/core/services/ocr2/validate/validate.go b/core/services/ocr2/validate/validate.go index 5e2b8668e1a..687e3eb2a11 100644 --- a/core/services/ocr2/validate/validate.go +++ b/core/services/ocr2/validate/validate.go @@ -23,6 +23,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/services/job" ringconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ring/config" "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/vault" + "github.com/smartcontractkit/chainlink/v2/core/services/ocr3_1/plugins/queue" "github.com/smartcontractkit/chainlink/v2/core/services/ocrcommon" "github.com/smartcontractkit/chainlink/v2/core/services/relay" "github.com/smartcontractkit/chainlink/v2/plugins" @@ -122,6 +123,8 @@ func validateSpec(ctx context.Context, tree *toml.Tree, spec job.Job, rc plugins return validateDonTimePluginSpec(spec.OCR2OracleSpec.PluginConfig) case types.RingPlugin: return validateRingPluginSpec(spec.OCR2OracleSpec.PluginConfig) + case types.ConsensusQueue: + return validateConsensusQueuePluginSpec(spec.OCR2OracleSpec.PluginConfig) case "": return errors.New("no plugin specified") default: @@ -323,3 +326,11 @@ func validateOCR2LLOSpec(jsonConfig job.JSONConfig) error { } return pkgerrors.Wrap(pluginConfig.Validate(), "LLO PluginConfig is invalid") } + +func validateConsensusQueuePluginSpec(jsonConfig job.JSONConfig) error { + cfg := &queue.PluginConfig{} + if err := json.Unmarshal(jsonConfig.Bytes(), &cfg); err != nil { + return fmt.Errorf("failed to unmarshal consensus queue plugin config: %w", err) + } + return cfg.Validate() +} diff --git a/core/services/ocr3_1/plugins/queue/config.go b/core/services/ocr3_1/plugins/queue/config.go new file mode 100644 index 00000000000..b63436ca646 --- /dev/null +++ b/core/services/ocr3_1/plugins/queue/config.go @@ -0,0 +1,14 @@ +package queue + +import ( + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3_1types" +) + +type PluginConfig struct { + Limits ocr3_1types.ReportingPluginLimits `json:"limits,omitzero"` +} + +func (c *PluginConfig) Validate() error { + //TODO validate? + return nil +} diff --git a/core/services/ocr3_1/plugins/queue/queue.go b/core/services/ocr3_1/plugins/queue/queue.go index 27f76a0a775..73a3b43bf9c 100644 --- a/core/services/ocr3_1/plugins/queue/queue.go +++ b/core/services/ocr3_1/plugins/queue/queue.go @@ -2,13 +2,14 @@ package queue import ( "context" - "errors" "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3_1types" "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/libocr/quorumhelper" "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/services" "github.com/smartcontractkit/chainlink-common/pkg/settings/limits" ) @@ -16,83 +17,87 @@ var _ ocr3_1types.ReportingPluginFactory[[]byte] = &consensusQueuePluginFactory{ type consensusQueuePluginFactory struct { lggr logger.Logger + cfg *PluginConfig } -func NewConsensusQueuePluginFactory(lggr logger.Logger, limitsFactory limits.Factory) (ocr3_1types.ReportingPluginFactory[[]byte], error) { +func NewConsensusQueuePluginFactory(lggr logger.Logger, cfg *PluginConfig, limitsFactory limits.Factory) (ocr3_1types.ReportingPluginFactory[[]byte], error) { // TODO pass CentralTriggerQueue, CapacityReporter, EngineRegistry // TODO construct limiters - return &consensusQueuePluginFactory{lggr: lggr}, nil + return &consensusQueuePluginFactory{lggr: lggr, cfg: cfg}, nil } func (c *consensusQueuePluginFactory) NewReportingPlugin(ctx context.Context, config ocr3types.ReportingPluginConfig, fetcher ocr3_1types.BlobBroadcastFetcher) (ocr3_1types.ReportingPlugin[[]byte], ocr3_1types.ReportingPluginInfo, error) { - plugin := newConsensusQueuePlugin(c.lggr) + plugin := newConsensusQueuePlugin(c.lggr, config) pluginInfo := ocr3_1types.ReportingPluginInfo1{ - Name: "ConsensusQueueReportingPlugin", - Limits: ocr3_1types.ReportingPluginLimits{ - // TODO limits - MaxQueryBytes: 0, - MaxObservationBytes: 0, - MaxReportsPlusPrecursorBytes: 0, - MaxReportBytes: 0, - MaxReportCount: 0, - MaxKeyValueModifiedKeys: 0, - MaxKeyValueModifiedKeysPlusValuesBytes: 0, - MaxBlobPayloadBytes: 0, - MaxPerOracleUnexpiredBlobCumulativePayloadBytes: 0, - MaxPerOracleUnexpiredBlobCount: 0, - }, + Name: "ConsensusQueueReportingPlugin", + Limits: c.cfg.Limits, } - return plugin, pluginInfo, nil + return plugin, pluginInfo, plugin.Start(ctx) } var _ ocr3_1types.ReportingPlugin[[]byte] = &consensusQueuePlugin{} type consensusQueuePlugin struct { - lggr logger.Logger + services.Service + eng *services.Engine + lggr logger.Logger + onchainCfg ocr3types.ReportingPluginConfig } -func newConsensusQueuePlugin(lggr logger.Logger) ocr3_1types.ReportingPlugin[[]byte] { - return &consensusQueuePlugin{lggr: logger.Named(lggr, "ConsensusQueuePlugin")} +func newConsensusQueuePlugin(lggr logger.Logger, onchainCfg ocr3types.ReportingPluginConfig) *consensusQueuePlugin { + c := &consensusQueuePlugin{lggr: logger.Named(lggr, "ConsensusQueuePlugin"), onchainCfg: onchainCfg} + c.Service, c.eng = services.Config{ + Name: "ConsensusQueueReportingPlugin", + Close: c.Close, + }.NewServiceEngine(lggr) + + return c } -func (c *consensusQueuePlugin) Query(ctx context.Context, seqNr uint64, keyValueStateReader ocr3_1types.KeyValueStateReader, blobBroadcastFetcher ocr3_1types.BlobBroadcastFetcher) (ocrtypes.Query, error) { - return nil, errors.ErrUnsupported +func (c *consensusQueuePlugin) Query(_ context.Context, _ uint64, _ ocr3_1types.KeyValueStateReader, _ ocr3_1types.BlobBroadcastFetcher) (ocrtypes.Query, error) { + return nil, nil } -func (c *consensusQueuePlugin) Observation(ctx context.Context, seqNr uint64, aq ocrtypes.AttributedQuery, keyValueStateReader ocr3_1types.KeyValueStateReader, blobBroadcastFetcher ocr3_1types.BlobBroadcastFetcher) (ocrtypes.Observation, error) { - // TODO observe queue via c.CentralTriggerQueue.TakeForObservation() - return nil, errors.ErrUnsupported +func (c *consensusQueuePlugin) Observation( + ctx context.Context, seqNr uint64, _ ocrtypes.AttributedQuery, kvState ocr3_1types.KeyValueStateReader, _ ocr3_1types.BlobBroadcastFetcher, +) (ocrtypes.Observation, error) { + return nil, nil } -func (c *consensusQueuePlugin) ValidateObservation(ctx context.Context, seqNr uint64, aq ocrtypes.AttributedQuery, ao ocrtypes.AttributedObservation, keyValueStateReader ocr3_1types.KeyValueStateReader, blobFetcher ocr3_1types.BlobFetcher) error { - return errors.ErrUnsupported +func (c *consensusQueuePlugin) ValidateObservation( + ctx context.Context, seqNr uint64, _ ocrtypes.AttributedQuery, ao ocrtypes.AttributedObservation, + _ ocr3_1types.KeyValueStateReader, _ ocr3_1types.BlobFetcher, +) error { + //TODO validate + return nil } -func (c *consensusQueuePlugin) ObservationQuorum(ctx context.Context, seqNr uint64, aq ocrtypes.AttributedQuery, aos []ocrtypes.AttributedObservation, keyValueStateReader ocr3_1types.KeyValueStateReader, blobFetcher ocr3_1types.BlobFetcher) (quorumReached bool, err error) { - return false, errors.ErrUnsupported +func (c *consensusQueuePlugin) ObservationQuorum( + ctx context.Context, seqNr uint64, _ ocrtypes.AttributedQuery, aos []ocrtypes.AttributedObservation, + _ ocr3_1types.KeyValueStateReader, _ ocr3_1types.BlobFetcher, +) (quorumReached bool, err error) { + return quorumhelper.ObservationCountReachesObservationQuorum(quorumhelper.QuorumTwoFPlusOne, c.onchainCfg.N, c.onchainCfg.F, aos), nil } -func (c *consensusQueuePlugin) StateTransition(ctx context.Context, seqNr uint64, aq ocrtypes.AttributedQuery, aos []ocrtypes.AttributedObservation, keyValueStateReadWriter ocr3_1types.KeyValueStateReadWriter, blobFetcher ocr3_1types.BlobFetcher) (ocr3_1types.ReportsPlusPrecursor, error) { - // TODO write to KV store - return nil, errors.ErrUnsupported +func (c *consensusQueuePlugin) StateTransition( + ctx context.Context, seqNr uint64, aq ocrtypes.AttributedQuery, aos []ocrtypes.AttributedObservation, + kvState ocr3_1types.KeyValueStateReadWriter, _ ocr3_1types.BlobFetcher, +) (ocr3_1types.ReportsPlusPrecursor, error) { + return ocr3_1types.ReportsPlusPrecursor{}, nil } func (c *consensusQueuePlugin) Committed(ctx context.Context, seqNr uint64, keyValueStateReader ocr3_1types.KeyValueStateReader) error { - return nil // no-op + return nil } func (c *consensusQueuePlugin) Reports(ctx context.Context, seqNr uint64, reportsPlusPrecursor ocr3_1types.ReportsPlusPrecursor) ([]ocr3types.ReportPlus[[]byte], error) { - return nil, errors.ErrUnsupported + return nil, nil } func (c *consensusQueuePlugin) ShouldAcceptAttestedReport(ctx context.Context, seqNr uint64, reportWithInfo ocr3types.ReportWithInfo[[]byte]) (bool, error) { - return false, errors.ErrUnsupported + return true, nil } func (c *consensusQueuePlugin) ShouldTransmitAcceptedReport(ctx context.Context, seqNr uint64, reportWithInfo ocr3types.ReportWithInfo[[]byte]) (bool, error) { - return false, errors.ErrUnsupported -} - -func (c *consensusQueuePlugin) Close() error { - return nil + return true, nil } diff --git a/core/services/ocr3_1/plugins/queue/transmitter.go b/core/services/ocr3_1/plugins/queue/transmitter.go new file mode 100644 index 00000000000..69ad7a77d04 --- /dev/null +++ b/core/services/ocr3_1/plugins/queue/transmitter.go @@ -0,0 +1,33 @@ +package queue + +import ( + "context" + + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/workflows/v2/triggers" +) + +type contractTransmitter struct { + lggr logger.Logger + fromAccount ocrtypes.Account + eventSink triggers.EventSink +} + +func NewTransmitter(lggr logger.Logger, fromAccount ocrtypes.Account, eventSink triggers.EventSink) ocr3types.ContractTransmitter[[]byte] { + return &contractTransmitter{ + lggr: lggr, + fromAccount: fromAccount, + eventSink: eventSink, + } +} + +func (c *contractTransmitter) Transmit(ctx context.Context, digest ocrtypes.ConfigDigest, seqNum uint64, rpi ocr3types.ReportWithInfo[[]byte], signatures []ocrtypes.AttributedOnchainSignature) error { + return nil +} + +func (c *contractTransmitter) FromAccount(ctx context.Context) (ocrtypes.Account, error) { + return c.fromAccount, nil +} diff --git a/core/services/workflows/v2/capability_executor.go b/core/services/workflows/v2/capability_executor.go index c290d0095f5..a99de9f579b 100644 --- a/core/services/workflows/v2/capability_executor.go +++ b/core/services/workflows/v2/capability_executor.go @@ -23,6 +23,7 @@ import ( protoevents "github.com/smartcontractkit/chainlink-protos/workflows/go/events" eventsv2 "github.com/smartcontractkit/chainlink-protos/workflows/go/v2" "github.com/smartcontractkit/chainlink/v2/core/platform" + "github.com/smartcontractkit/chainlink/v2/core/services/internal" "github.com/smartcontractkit/chainlink/v2/core/services/workflows/metering" "github.com/smartcontractkit/chainlink/v2/core/services/workflows/store" ) @@ -411,16 +412,13 @@ func (c *ExecutionHelper) EmitUserMetric(ctx context.Context, metric *eventsv2.W return c.base.cfg.EventEmitter.EmitUserMetric(ctx, c.base.eventLabels(), metric) } -// dontimeCapabilityID matches the capability ID registered by the OCR2 delegate -// (core/services/ocr2/delegate.go). -const dontimeCapabilityID = "dontime@1.0.0" - // systemCapabilities lists capability IDs that are internal plumbing and must // not be callable from user workflow steps. var systemCapabilities = map[string]bool{ - confidentialWorkflowsCapabilityID: true, - vaultcommon.CapabilityID: true, - dontimeCapabilityID: true, + confidentialWorkflowsCapabilityID: true, + internal.VaultCapabilityID: true, + internal.DontimeCapabilityID: true, + internal.ConsensusQueueCapabilityID: true, } func isSystemCapability(capID string) bool { diff --git a/core/services/workflows/v2/capability_executor_test.go b/core/services/workflows/v2/capability_executor_test.go index 2ed9173b250..a99e5109b5f 100644 --- a/core/services/workflows/v2/capability_executor_test.go +++ b/core/services/workflows/v2/capability_executor_test.go @@ -14,10 +14,11 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/settings" "github.com/smartcontractkit/chainlink-common/pkg/settings/cresettings" "github.com/smartcontractkit/chainlink-common/pkg/settings/limits" - core "github.com/smartcontractkit/chainlink-common/pkg/types/core" + "github.com/smartcontractkit/chainlink-common/pkg/types/core" "github.com/smartcontractkit/chainlink-protos/cre/go/sdk" eventsv2 "github.com/smartcontractkit/chainlink-protos/workflows/go/v2" "github.com/smartcontractkit/chainlink/v2/core/logger" + "github.com/smartcontractkit/chainlink/v2/core/services/internal" ) func TestExecutionHelper_SystemCapabilityBlocked(t *testing.T) { @@ -157,8 +158,9 @@ func TestIsSystemCapability(t *testing.T) { want bool }{ {"confidential-workflows registered ID", confidentialWorkflowsCapabilityID, true}, - {"vault registered ID", vault.CapabilityID, true}, - {"dontime registered ID", dontimeCapabilityID, true}, + {"vault registered ID", internal.VaultCapabilityID, true}, + {"dontime registered ID", internal.DontimeCapabilityID, true}, + {"consensus queue registered ID", internal.ConsensusQueueCapabilityID, true}, {"confidential-workflows other version", "confidential-workflows@1.0.0", false}, {"vault other version", "vault@2.0.0", false}, {"vault unversioned", "vault", false}, diff --git a/core/services/workflows/v2/triggers/triggers.go b/core/services/workflows/v2/triggers/triggers.go index 74da564ed38..2b04f4a8761 100644 --- a/core/services/workflows/v2/triggers/triggers.go +++ b/core/services/workflows/v2/triggers/triggers.go @@ -12,8 +12,10 @@ import ( "golang.org/x/sync/errgroup" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/smartcontractkit/chainlink-common/pkg/capabilities" + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" "github.com/smartcontractkit/chainlink-common/pkg/capabilities/registry" "github.com/smartcontractkit/chainlink-common/pkg/contexts" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -151,6 +153,29 @@ type CoordinatedEvent struct { Event capabilities.TriggerResponse } +func (e *CoordinatedEvent) ToProto() *pb.CoordinatedEvent { + return &pb.CoordinatedEvent{ + WorkflowID: e.WorkflowID, + TriggerCapID: e.TriggerCapID, + TriggerIndex: int64(e.TriggerIndex), + ObservedAt: timestamppb.New(e.ObservedAt), + Deadline: timestamppb.New(e.Deadline), + SequenceNumber: e.SequenceNumber, + Event: pb.TriggerResponseToProto(e.Event), + } +} + +func (e *CoordinatedEvent) FromProto(p *pb.CoordinatedEvent) (err error) { + e.WorkflowID = p.WorkflowID + e.TriggerCapID = p.TriggerCapID + e.TriggerIndex = int(p.TriggerIndex) + e.ObservedAt = p.ObservedAt.AsTime() + e.Deadline = p.Deadline.AsTime() + e.SequenceNumber = p.SequenceNumber + e.Event, err = pb.TriggerResponseFromProto(p.Event) + return +} + // ReadLoop consumes triggerEventCh until it closes or ctx is done, // converting each received capabilities.TriggerResponse into a // CoordinatedEvent and handing it to deliver. diff --git a/deployment/cre/jobs/pkg/templates/consensus-queue.tmpl b/deployment/cre/jobs/pkg/templates/consensus-queue.tmpl new file mode 100644 index 00000000000..9f7d38356d8 --- /dev/null +++ b/deployment/cre/jobs/pkg/templates/consensus-queue.tmpl @@ -0,0 +1,14 @@ +type = "offchainreporting2" +schemaVersion = 1 +externalJobID = "{{ .ExternalJobID }}" +name = "{{ .JobName }}" +contractID = "{{ .ContractID }}" +ocrKeyBundleID = "{{ .OCR2EVMKeyBundleID }}" +p2pv2Bootstrappers = [ +{{ range .P2Pv2Bootstrappers }} "{{ . }}", +{{ end }}] +pluginType = "consensus-queue" +transmitterID = "{{ .TransmitterID }}" +relay = "evm" +[relayConfig] +chainID = "{{ .ChainID }}" diff --git a/deployment/cre/jobs/propose_job_spec_test.go b/deployment/cre/jobs/propose_job_spec_test.go index 8182079d7b5..4d25ebe9f6d 100644 --- a/deployment/cre/jobs/propose_job_spec_test.go +++ b/deployment/cre/jobs/propose_job_spec_test.go @@ -31,6 +31,7 @@ import ( "github.com/smartcontractkit/chainlink/deployment/cre/test" ) +// TODO add a subtest for ConsensusQueue func TestProposeJobSpec_VerifyPreconditions(t *testing.T) { j := jobs.ProposeJobSpec{} var env cldf.Environment @@ -508,6 +509,7 @@ func TestProposeJobSpec_VerifyPreconditions_Aptos(t *testing.T) { } } +// TODO add a subtest for ConsensusQueue func TestProposeJobSpec_Apply(t *testing.T) { h := test.NewTestHarness(t) env := new(h.Runtime.Environment()) diff --git a/system-tests/lib/cre/don.go b/system-tests/lib/cre/don.go index 46d0ed9d43e..585abd6b2e3 100644 --- a/system-tests/lib/cre/don.go +++ b/system-tests/lib/cre/don.go @@ -946,7 +946,7 @@ func HasFlag(values []string, capability string) bool { } for _, value := range values { - if strings.HasPrefix(value, capability+"-") { + if strings.HasPrefix(value, capability+"-") { //TODO collisions? return true } } diff --git a/system-tests/lib/cre/environment/environment.go b/system-tests/lib/cre/environment/environment.go index bcd91e893f2..51e01805129 100644 --- a/system-tests/lib/cre/environment/environment.go +++ b/system-tests/lib/cre/environment/environment.go @@ -288,6 +288,49 @@ func SetupTestEnvironment( // allow to pass custom job spec factories for extensibility jobSpecFactoryFunctions = append(jobSpecFactoryFunctions, input.JobSpecFactoryFunctions...) + // ConsensusQueue + //TODO remove - replaced by feature + //jobSpecFactoryFunctions = append(jobSpecFactoryFunctions, func(input *cre.JobSpecInput) (cre.DonJobs, error) { + // chainID, err := chainselectors.GetChainIDFromSelector(deployedBlockchains.RegistryChain().ChainSelector()) + // if err != nil { + // return nil, fmt.Errorf("failed to get chain ID from selector: %w", err) + // } + // evmChainID, err := strconv.ParseUint(chainID, 10, 64) + // if err != nil { + // return nil, fmt.Errorf("non-integer chain ID: %s: %w", chainID, err) + // } + // + // don := dons.MustWorkflowDON() + // + // bs, ok := dons.Bootstrap() + // if !ok { + // return nil, fmt.Errorf("failed to look up bootstrap node") + // } + // jobConfig := pkg.OCR3JobConfig{ + // JobName: "consensus-queue-test", + // ChainID: chainID, + // ContractID: "0x0000000000000000000000000000000000000000", // TODO + // P2Pv2Bootstrappers: []string{bs.Keys.P2PKey.PeerID.Raw() + "@" + bs.Host + ":" + strconv.Itoa(cre.OCRPeeringPort)}, + // ExternalJobID: uuid.NewV4().String(), // TODO deterministic? + // TemplateName: "consensus-queue", + // } + // + // var donJobs cre.DonJobs + // for _, node := range don.Nodes { + // jobConfig.P2PID = node.PeerID() + // jobConfig.OCR2EVMKeyBundleID = node.Keys.OCR2BundleIDs["evm"] + // jobConfig.TransmitterID = node.Keys.EVM[evmChainID].PublicAddress.String() + // + // jobSpec, err := jobConfig.ResolveJob() + // if err != nil { + // return nil, fmt.Errorf("failed to resolve OCR3 job spec: %w", err) + // } + // nodeID := node.JobDistributorDetails.NodeID + // donJobs = append(donJobs, &job.ProposeJobRequest{NodeId: nodeID, Spec: jobSpec}) + // } + // return donJobs, nil + //}) + createJobsDeps := CreateJobsWithJdOpDeps{ Logger: testLogger, SingleFileLogger: singleFileLogger, diff --git a/system-tests/lib/cre/features/queue/queue.go b/system-tests/lib/cre/features/queue/queue.go new file mode 100644 index 00000000000..eff5f9b3b5e --- /dev/null +++ b/system-tests/lib/cre/features/queue/queue.go @@ -0,0 +1,146 @@ +package queue + +import ( + "context" + "fmt" + "strconv" + + "dario.cat/mergo" + "github.com/google/uuid" + "github.com/pkg/errors" + "github.com/rs/zerolog" + + capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb" + kcr "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/capabilities_registry_1_1_0" + cre_jobs "github.com/smartcontractkit/chainlink/deployment/cre/jobs" + cre_jobs_ops "github.com/smartcontractkit/chainlink/deployment/cre/jobs/operations" + job_types "github.com/smartcontractkit/chainlink/deployment/cre/jobs/types" + "github.com/smartcontractkit/chainlink/deployment/cre/ocr3" + "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" + keystone_changeset "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" + "github.com/smartcontractkit/chainlink/system-tests/lib/cre" + "github.com/smartcontractkit/chainlink/system-tests/lib/cre/contracts" + "github.com/smartcontractkit/chainlink/system-tests/lib/cre/don/jobs" +) + +const flag = cre.ConsensusQueueCapability + +const consensusQueueLabelledName = cre.ConsensusQueueCapability + +type ConsensusQueue struct{} + +func (o *ConsensusQueue) Flag() cre.CapabilityFlag { return flag } +func (o *ConsensusQueue) PreEnvStartup( + ctx context.Context, + testLogger zerolog.Logger, + don *cre.DonMetadata, + topology *cre.Topology, + creEnv *cre.Environment, +) (*cre.PreEnvStartupOutput, error) { + if !don.HasFlag(flag) { + return nil, nil + } + + return &cre.PreEnvStartupOutput{ + DONCapabilityWithConfig: []keystone_changeset.DONCapabilityWithConfig{{ + Capability: kcr.CapabilitiesRegistryCapability{ + LabelledName: consensusQueueLabelledName, + Version: "1.0.0", + CapabilityType: 2, // CONSENSUS + ResponseType: 0, // REPORT (not used) + }, + Config: &capabilitiespb.CapabilityConfig{ + LocalOnly: don.HasOnlyLocalCapabilities(), + }, + UseCapRegOCRConfig: true, + }}, + CapabilityToOCR3Config: map[string]*ocr3.OracleConfig{ + //TODO don't we need DefaultOCR3_1Config? + consensusQueueLabelledName: contracts.DefaultOCR3Config(), + }, + }, nil +} + +func (o *ConsensusQueue) PostEnvStartup( + ctx context.Context, + testLogger zerolog.Logger, + don *cre.Don, + dons *cre.Dons, + creEnv *cre.Environment, +) error { + if !don.HasFlag(flag) { + return nil + } + + err := createJobs(ctx, creEnv, don, dons) + if err != nil { + return fmt.Errorf("failed to create consensusQueue jobs: %w", err) + } + //TODO more? + return nil +} + +func createJobs( + ctx context.Context, + creEnv *cre.Environment, + don *cre.Don, + dons *cre.Dons, +) error { + bootstrap, isBootstrap := dons.Bootstrap() + if !isBootstrap { + return errors.New("could not find bootstrap node in topology, exactly one bootstrap node is required") + } + + peeringCfg, err := cre.PeeringCfgs(bootstrap) + if err != nil { + return errors.Wrap(err, "failed to get peering configs") + } + + input := cre_jobs.ProposeJobSpecInput{ + Domain: offchain.ProductLabel, + Environment: creEnv.CldfEnvironment.Name, + DONName: don.Name, + JobName: cre.ConsensusQueueCapability + "-worker", + ExtraLabels: map[string]string{cre.CapabilityLabelKey: cre.ConsensusQueueCapability}, + DONFilters: []offchain.TargetDONFilter{ + {Key: offchain.FilterKeyDONName, Value: don.Name}, + }, + Template: job_types.OCR3, + Inputs: job_types.JobSpecInput{ + "chainSelectorEVM": creEnv.RegistryChainSelector, + "contractQualifier": cre.ConsensusQueueCapability, + "templateName": cre.ConsensusQueueCapability, + "bootstrapperOCR3Urls": []string{peeringCfg.BootstrapperPeerID + "@" + peeringCfg.BootstrapperHost + ":" + strconv.Itoa(peeringCfg.Port)}, + }, + } + if creEnv.FreshExternalJobIDs { + input.Inputs["externalJobID"] = uuid.NewString() + } + if err := (cre_jobs.ProposeJobSpec{}).VerifyPreconditions(*creEnv.CldfEnvironment, input); err != nil { + return errors.Wrapf(err, "precondition verification failed for %s worker job", flag) + } + + report, err := (cre_jobs.ProposeJobSpec{}).Apply(*creEnv.CldfEnvironment, input) + if err != nil { + return errors.Wrapf(err, "failed to propose %s worker job spec", flag) + } + + // Proposing only queues the spec in Job Distributor; without approval the + // nodes never run it and the capability never registers locally. + specs := make(map[string][]string) + for _, r := range report.Reports { + out, ok := r.Output.(cre_jobs_ops.ProposeOCR3JobOutput) + if !ok { + return fmt.Errorf("unable to cast to ProposeOCR3JobOutput, actual type: %T", r.Output) + } + if mErr := mergo.Merge(&specs, out.Specs, mergo.WithAppendSlice); mErr != nil { + return errors.Wrapf(mErr, "failed to merge %s worker job specs", flag) + } + } + + if aErr := jobs.Approve(ctx, creEnv.CldfEnvironment.Offchain, dons, specs); aErr != nil { + return errors.Wrapf(aErr, "failed to approve %s worker jobs", flag) + } + + return nil +} diff --git a/system-tests/lib/cre/features/sets/sets.go b/system-tests/lib/cre/features/sets/sets.go index 8db4cb51b28..90c4bc8e9e7 100644 --- a/system-tests/lib/cre/features/sets/sets.go +++ b/system-tests/lib/cre/features/sets/sets.go @@ -11,6 +11,7 @@ import ( evm_feature "github.com/smartcontractkit/chainlink/system-tests/lib/cre/features/evm/v2" http_actions_feature "github.com/smartcontractkit/chainlink/system-tests/lib/cre/features/http_action" http_trigger_feature "github.com/smartcontractkit/chainlink/system-tests/lib/cre/features/http_trigger" + consensus_queue_feature "github.com/smartcontractkit/chainlink/system-tests/lib/cre/features/queue" solana_feature "github.com/smartcontractkit/chainlink/system-tests/lib/cre/features/solana/v2" stellar_feature "github.com/smartcontractkit/chainlink/system-tests/lib/cre/features/stellar" vault_feature "github.com/smartcontractkit/chainlink/system-tests/lib/cre/features/vault" @@ -30,5 +31,6 @@ func New() cre.Features { &vault_feature.Vault{}, &confidential_relay_feature.ConfidentialRelay{}, &confidential_workflows_feature.ConfidentialWorkflows{}, + &consensus_queue_feature.ConsensusQueue{}, ) } diff --git a/system-tests/lib/cre/flags/provider.go b/system-tests/lib/cre/flags/provider.go index e045aef025d..635af1e0021 100644 --- a/system-tests/lib/cre/flags/provider.go +++ b/system-tests/lib/cre/flags/provider.go @@ -21,6 +21,7 @@ func NewDefaultCapabilityFlagsProvider() *DefaultCapbilityFlagsProvider { cre.StellarCapability, cre.ConfidentialRelayCapability, cre.ConfidentialWorkflowsCapability, + cre.ConsensusQueueCapability, }, } } @@ -44,6 +45,7 @@ func NewExtensibleCapabilityFlagsProvider(extraGlobalFlags []string) *Extensible cre.HTTPActionCapability, cre.ConfidentialRelayCapability, cre.ConfidentialWorkflowsCapability, + cre.ConsensusQueueCapability, }, extraGlobalFlags...), chainSpecificCapabilities: []cre.CapabilityFlag{ cre.EVMCapability, diff --git a/system-tests/lib/cre/types.go b/system-tests/lib/cre/types.go index ae28fa68b2a..156befa9d2c 100644 --- a/system-tests/lib/cre/types.go +++ b/system-tests/lib/cre/types.go @@ -66,6 +66,7 @@ const ( ConfidentialRelayCapability CapabilityFlag = "confidential-relay" // ConfidentialWorkflowsCapability doubles as the enclave application name. ConfidentialWorkflowsCapability CapabilityFlag = "confidential-workflows" + ConsensusQueueCapability CapabilityFlag = "consensus-queue" AptosCapability CapabilityFlag = "aptos" StellarCapability CapabilityFlag = "stellar" // Add more capabilities as needed @@ -777,7 +778,7 @@ func (m *DonMetadata) StellarChains() []string { func (m *DonMetadata) RequiresOCR() bool { return slices.Contains(m.Flags, ConsensusCapability) || - slices.Contains(m.Flags, VaultCapability) || slices.Contains(m.Flags, EVMCapability) || slices.Contains(m.Flags, SolanaCapability) + slices.Contains(m.Flags, VaultCapability) || slices.Contains(m.Flags, ConsensusQueueCapability) || slices.Contains(m.Flags, EVMCapability) || slices.Contains(m.Flags, SolanaCapability) } func (m *DonMetadata) RequiresGateway() bool { From 62492c7cbb2ccec0fbbb8ab605d494e87b5b5a70 Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Fri, 6 Nov 2026 09:35:52 +0100 Subject: [PATCH 02/10] fix: the new consensus-queue feature asks the Job Distributor for an OCR3 job with contractQualifier: consensus-queue --- system-tests/lib/cre/features/queue/queue.go | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/system-tests/lib/cre/features/queue/queue.go b/system-tests/lib/cre/features/queue/queue.go index eff5f9b3b5e..e1bd702eb05 100644 --- a/system-tests/lib/cre/features/queue/queue.go +++ b/system-tests/lib/cre/features/queue/queue.go @@ -15,7 +15,9 @@ import ( cre_jobs "github.com/smartcontractkit/chainlink/deployment/cre/jobs" cre_jobs_ops "github.com/smartcontractkit/chainlink/deployment/cre/jobs/operations" job_types "github.com/smartcontractkit/chainlink/deployment/cre/jobs/types" + "github.com/smartcontractkit/chainlink/deployment/cre/jobs/pkg" "github.com/smartcontractkit/chainlink/deployment/cre/ocr3" + ocr3_changeset "github.com/smartcontractkit/chainlink/deployment/cre/ocr3/v2/changeset" "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" keystone_changeset "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" "github.com/smartcontractkit/chainlink/system-tests/lib/cre" @@ -72,6 +74,10 @@ func (o *ConsensusQueue) PostEnvStartup( return nil } + if err := deployContract(creEnv, testLogger); err != nil { + return fmt.Errorf("failed to deploy consensusQueue OCR3 contract: %w", err) + } + err := createJobs(ctx, creEnv, don, dons) if err != nil { return fmt.Errorf("failed to create consensusQueue jobs: %w", err) @@ -80,6 +86,32 @@ func (o *ConsensusQueue) PostEnvStartup( return nil } +// deployContract deploys the OCR3 contract the job spec uses as its contractID. +// The OCR config itself comes from the Capabilities Registry. +func deployContract(creEnv *cre.Environment, testLogger zerolog.Logger) error { + input := ocr3_changeset.DeployOCR3Input{ + ChainSelector: creEnv.RegistryChainSelector, + Qualifier: cre.ConsensusQueueCapability, + Labels: []string{cre.ConsensusQueueCapability}, + } + if err := (ocr3_changeset.DeployOCR3{}).VerifyPreconditions(*creEnv.CldfEnvironment, input); err != nil { + return errors.Wrap(err, "precondition verification failed") + } + out, err := (ocr3_changeset.DeployOCR3{}).Apply(*creEnv.CldfEnvironment, input) + if err != nil { + return err + } + contracts.MergeAllDataStores(creEnv, out) + + refKey := pkg.GetOCR3CapabilityAddressRefKey(creEnv.RegistryChainSelector, cre.ConsensusQueueCapability) + addrRef, err := creEnv.CldfEnvironment.DataStore.Addresses().Get(refKey) + if err != nil { + return errors.Wrap(err, "failed to get deployed contract address") + } + testLogger.Info().Msgf("Deployed consensus-queue OCR3 contract on chain %d at %s", creEnv.RegistryChainSelector, addrRef.Address) + return nil +} + func createJobs( ctx context.Context, creEnv *cre.Environment, From 68e415d09cf163c895b23cc7fbbcd550f8a10fdd Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Mon, 9 Nov 2026 17:33:35 +0100 Subject: [PATCH 03/10] chore: fix lint --- core/services/ocr3_1/plugins/queue/config.go | 2 +- core/services/ocr3_1/plugins/queue/queue.go | 2 +- .../lib/cre/environment/environment.go | 43 ------------------- 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/core/services/ocr3_1/plugins/queue/config.go b/core/services/ocr3_1/plugins/queue/config.go index b63436ca646..0cdf2ec0086 100644 --- a/core/services/ocr3_1/plugins/queue/config.go +++ b/core/services/ocr3_1/plugins/queue/config.go @@ -9,6 +9,6 @@ type PluginConfig struct { } func (c *PluginConfig) Validate() error { - //TODO validate? + // TODO validate? return nil } diff --git a/core/services/ocr3_1/plugins/queue/queue.go b/core/services/ocr3_1/plugins/queue/queue.go index 73a3b43bf9c..dbb4cc077ee 100644 --- a/core/services/ocr3_1/plugins/queue/queue.go +++ b/core/services/ocr3_1/plugins/queue/queue.go @@ -68,7 +68,7 @@ func (c *consensusQueuePlugin) ValidateObservation( ctx context.Context, seqNr uint64, _ ocrtypes.AttributedQuery, ao ocrtypes.AttributedObservation, _ ocr3_1types.KeyValueStateReader, _ ocr3_1types.BlobFetcher, ) error { - //TODO validate + // TODO validate return nil } diff --git a/system-tests/lib/cre/environment/environment.go b/system-tests/lib/cre/environment/environment.go index 51e01805129..bcd91e893f2 100644 --- a/system-tests/lib/cre/environment/environment.go +++ b/system-tests/lib/cre/environment/environment.go @@ -288,49 +288,6 @@ func SetupTestEnvironment( // allow to pass custom job spec factories for extensibility jobSpecFactoryFunctions = append(jobSpecFactoryFunctions, input.JobSpecFactoryFunctions...) - // ConsensusQueue - //TODO remove - replaced by feature - //jobSpecFactoryFunctions = append(jobSpecFactoryFunctions, func(input *cre.JobSpecInput) (cre.DonJobs, error) { - // chainID, err := chainselectors.GetChainIDFromSelector(deployedBlockchains.RegistryChain().ChainSelector()) - // if err != nil { - // return nil, fmt.Errorf("failed to get chain ID from selector: %w", err) - // } - // evmChainID, err := strconv.ParseUint(chainID, 10, 64) - // if err != nil { - // return nil, fmt.Errorf("non-integer chain ID: %s: %w", chainID, err) - // } - // - // don := dons.MustWorkflowDON() - // - // bs, ok := dons.Bootstrap() - // if !ok { - // return nil, fmt.Errorf("failed to look up bootstrap node") - // } - // jobConfig := pkg.OCR3JobConfig{ - // JobName: "consensus-queue-test", - // ChainID: chainID, - // ContractID: "0x0000000000000000000000000000000000000000", // TODO - // P2Pv2Bootstrappers: []string{bs.Keys.P2PKey.PeerID.Raw() + "@" + bs.Host + ":" + strconv.Itoa(cre.OCRPeeringPort)}, - // ExternalJobID: uuid.NewV4().String(), // TODO deterministic? - // TemplateName: "consensus-queue", - // } - // - // var donJobs cre.DonJobs - // for _, node := range don.Nodes { - // jobConfig.P2PID = node.PeerID() - // jobConfig.OCR2EVMKeyBundleID = node.Keys.OCR2BundleIDs["evm"] - // jobConfig.TransmitterID = node.Keys.EVM[evmChainID].PublicAddress.String() - // - // jobSpec, err := jobConfig.ResolveJob() - // if err != nil { - // return nil, fmt.Errorf("failed to resolve OCR3 job spec: %w", err) - // } - // nodeID := node.JobDistributorDetails.NodeID - // donJobs = append(donJobs, &job.ProposeJobRequest{NodeId: nodeID, Spec: jobSpec}) - // } - // return donJobs, nil - //}) - createJobsDeps := CreateJobsWithJdOpDeps{ Logger: testLogger, SingleFileLogger: singleFileLogger, From 9b10fdfcabf00836e85def9a3f247cf1814bd57b Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Mon, 9 Nov 2026 17:52:43 +0100 Subject: [PATCH 04/10] fix: removed named OCRConfigKey and use the capabilitiespb.OCR3ConfigDefaultKey, this solves the zero configDigest error --- core/services/ocr2/delegate.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/services/ocr2/delegate.go b/core/services/ocr2/delegate.go index faa8c5befc5..d9397a4e583 100644 --- a/core/services/ocr2/delegate.go +++ b/core/services/ocr2/delegate.go @@ -98,7 +98,6 @@ const ( vaultDiskMonitorTickInterval = time.Minute consensusQueueCapabilityID = internal.ConsensusQueueCapabilityID - consensusQueueOCRConfigKey = "consensus-queue" gaugeConsensusQueueBytes = "platform_consensus_queue_usage_bytes" consensusQueueDiskMonitorTickInterval = time.Minute ) @@ -864,7 +863,7 @@ func (d *Delegate) newServicesConsensusQueue( return nil, err } - configTracker, configDigester, lc, err := d.maybeWrapConfigService(consensusQueueCapabilityID, consensusQueueOCRConfigKey, lggr, provider.ContractConfigTracker(), provider.OffchainConfigDigester(), lc) + configTracker, configDigester, lc, err := d.maybeWrapConfigService(consensusQueueCapabilityID, capabilitiespb.OCR3ConfigDefaultKey, lggr, provider.ContractConfigTracker(), provider.OffchainConfigDigester(), lc) if err != nil { return nil, err } From 170247b43cf7cf1a4dc50ed14bd142e8b5f4409b Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Mon, 9 Nov 2026 22:17:18 +0100 Subject: [PATCH 05/10] fix: write an OCR 3.1 config for consensus-queue in local CRE --- system-tests/lib/cre/contracts/keystone.go | 93 ++++++++++++++----- .../lib/cre/contracts/keystone_test.go | 2 +- .../lib/cre/environment/environment.go | 4 + system-tests/lib/cre/features/queue/queue.go | 15 ++- system-tests/lib/cre/types.go | 7 ++ 5 files changed, 93 insertions(+), 28 deletions(-) diff --git a/system-tests/lib/cre/contracts/keystone.go b/system-tests/lib/cre/contracts/keystone.go index 3f50c05a8b7..94d930b8796 100644 --- a/system-tests/lib/cre/contracts/keystone.go +++ b/system-tests/lib/cre/contracts/keystone.go @@ -29,6 +29,7 @@ import ( cap_reg_v2_seq "github.com/smartcontractkit/chainlink/deployment/cre/capabilities_registry/v2/changeset/sequences" cre_contracts "github.com/smartcontractkit/chainlink/deployment/cre/contracts" "github.com/smartcontractkit/chainlink/deployment/cre/ocr3" + "github.com/smartcontractkit/chainlink/deployment/cre/ocr3/ocr3_1" keystone_changeset "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" ks_contracts_op "github.com/smartcontractkit/chainlink/deployment/keystone/changeset/operations/contracts" libc "github.com/smartcontractkit/chainlink/system-tests/lib/conversions" @@ -126,6 +127,49 @@ func (d *dons) donsOrderedByID() []donConfig { func (d *dons) embedOCR3Config(capConfig *capabilitiespb.CapabilityConfig, don donConfig, registryChainSelector uint64, oracleConfig *ocr3.OracleConfig, extraSignerFamilies []string) error { oracleConfig.TransmissionSchedule = []int{len(don.Nops[0].Nodes)} + nodes, err := d.donNodeInfo(don) + if err != nil { + return err + } + + ocrConfig, err := ocr3.GenerateOCR3ConfigFromNodes(*oracleConfig, nodes, registryChainSelector, d.env.OCRSecrets, nil, extraSignerFamilies) + if err != nil { + return fmt.Errorf("failed to generate OCR3 config: %w", err) + } + + setDefaultOCR3ConfigProto(capConfig, ocrConfig) + return nil +} + +// embedOCR3_1Config is the OCR 3.1 version of embedOCR3Config. +// The node's OCR 3.1 oracle only accepts offchain config version 310, which is +// what GenerateOCR3_1ConfigFromNodes writes. +func (d *dons) embedOCR3_1Config(capConfig *capabilitiespb.CapabilityConfig, don donConfig, registryChainSelector uint64, oracleConfig *ocr3_1.V3_1OracleConfig, extraSignerFamilies []string) error { + oracleConfig.TransmissionSchedule = []int{len(don.Nops[0].Nodes)} + + nodes, err := d.donNodeInfo(don) + if err != nil { + return err + } + + // Vault and DKG carry their plugin config in the OCR offchain config. + // Other OCR 3.1 plugins read it from the job spec, so it stays empty here. + // Empty but not nil, because nil makes the generator ask for a Vault or DKG config. + var pluginConfig []byte + if oracleConfig.VaultOffchainConfig == nil && oracleConfig.DKGOffchainConfig == nil { + pluginConfig = []byte{} + } + + ocrConfig, err := ocr3_1.GenerateOCR3_1ConfigFromNodes(*oracleConfig, nodes, registryChainSelector, d.env.OCRSecrets, pluginConfig, extraSignerFamilies) + if err != nil { + return fmt.Errorf("failed to generate OCR3_1 config: %w", err) + } + + setDefaultOCR3ConfigProto(capConfig, ocrConfig) + return nil +} + +func (d *dons) donNodeInfo(don donConfig) ([]deployment.Node, error) { var allNodeIDs []string for _, nop := range don.Nops { allNodeIDs = append(allNodeIDs, nop.Nodes...) @@ -133,20 +177,23 @@ func (d *dons) embedOCR3Config(capConfig *capabilitiespb.CapabilityConfig, don d nodes, err := deployment.NodeInfo(allNodeIDs, d.offChain) if err != nil { - return fmt.Errorf("failed to get node info: %w", err) - } - - ocrConfig, err := ocr3.GenerateOCR3ConfigFromNodes(*oracleConfig, nodes, registryChainSelector, d.env.OCRSecrets, nil, extraSignerFamilies) - if err != nil { - return fmt.Errorf("failed to generate OCR3 config: %w", err) + return nil, fmt.Errorf("failed to get node info: %w", err) } + return nodes, nil +} +// setDefaultOCR3ConfigProto writes ocrConfig under the default key, which is the +// key the node reads for single-instance capabilities. +func setDefaultOCR3ConfigProto(capConfig *capabilitiespb.CapabilityConfig, ocrConfig ocr3.OCR2OracleConfig) { transmitterBytes := make([][]byte, len(ocrConfig.Transmitters)) for i, t := range ocrConfig.Transmitters { transmitterBytes[i] = t.Bytes() } - ocr3Proto := &capabilitiespb.OCR3Config{ + if capConfig.Ocr3Configs == nil { + capConfig.Ocr3Configs = make(map[string]*capabilitiespb.OCR3Config) + } + capConfig.Ocr3Configs[capabilitiespb.OCR3ConfigDefaultKey] = &capabilitiespb.OCR3Config{ Signers: ocrConfig.Signers, Transmitters: transmitterBytes, F: uint32(ocrConfig.F), @@ -155,16 +202,9 @@ func (d *dons) embedOCR3Config(capConfig *capabilitiespb.CapabilityConfig, don d OffchainConfig: ocrConfig.OffchainConfig, ConfigCount: 1, } - - if capConfig.Ocr3Configs == nil { - capConfig.Ocr3Configs = make(map[string]*capabilitiespb.OCR3Config) - } - capConfig.Ocr3Configs[capabilitiespb.OCR3ConfigDefaultKey] = ocr3Proto - - return nil } -func (d *dons) mustToV2ConfigureInput(chainSelector uint64, contractAddress string, capabilityToOCR3Config map[string]*ocr3.OracleConfig, capabilityToExtraSignerFamilies map[string][]string) cap_reg_v2_seq.ConfigureCapabilitiesRegistryInput { +func (d *dons) mustToV2ConfigureInput(chainSelector uint64, contractAddress string, capabilityToOCR3Config map[string]*ocr3.OracleConfig, capabilityToOCR3_1Config map[string]*ocr3_1.V3_1OracleConfig, capabilityToExtraSignerFamilies map[string][]string) cap_reg_v2_seq.ConfigureCapabilitiesRegistryInput { nodes := make([]contracts.NodesInput, 0) orderedDons := d.donsOrderedByID() donParams := make([]capabilities_registry_v2.CapabilitiesRegistryNewDONParams, len(orderedDons)) @@ -253,12 +293,21 @@ func (d *dons) mustToV2ConfigureInput(chainSelector uint64, contractAddress stri } shouldMarshalProtoConfig = true - ocrConfig := capabilityToOCR3Config[cap.Capability.LabelledName] - if ocrConfig == nil { - panic("no OCR3 config found for capability " + cap.Capability.LabelledName) - } - if err := d.embedOCR3Config(capConfig, don, chainSelector, ocrConfig, capabilityToExtraSignerFamilies[cap.Capability.LabelledName]); err != nil { - panic(fmt.Sprintf("failed to embed OCR3 config for capability %s: %s", cap.Capability.LabelledName, err)) + name := cap.Capability.LabelledName + extraSignerFamilies := capabilityToExtraSignerFamilies[name] + ocr3_1Config := capabilityToOCR3_1Config[name] + ocrConfig := capabilityToOCR3Config[name] + switch { + case ocr3_1Config != nil: + if err := d.embedOCR3_1Config(capConfig, don, chainSelector, ocr3_1Config, extraSignerFamilies); err != nil { + panic(fmt.Sprintf("failed to embed OCR3_1 config for capability %s: %s", name, err)) + } + case ocrConfig != nil: + if err := d.embedOCR3Config(capConfig, don, chainSelector, ocrConfig, extraSignerFamilies); err != nil { + panic(fmt.Sprintf("failed to embed OCR3 config for capability %s: %s", name, err)) + } + default: + panic("no OCR3 or OCR3_1 config found for capability " + name) } } @@ -467,7 +516,7 @@ func ExecuteConfigureCapabilitiesRegistry(input cre.ConfigureCapabilityRegistryI if dErr != nil { return nil, errors.Wrap(dErr, "failed to map input to dons") } - contractInput := dons.mustToV2ConfigureInput(input.ChainSelector, input.CapabilitiesRegistryAddress.Hex(), input.CapabilityToOCR3Config, input.CapabilityToExtraSignerFamilies) + contractInput := dons.mustToV2ConfigureInput(input.ChainSelector, input.CapabilitiesRegistryAddress.Hex(), input.CapabilityToOCR3Config, input.CapabilityToOCR3_1Config, input.CapabilityToExtraSignerFamilies) _, seqErr := operations.ExecuteSequence( input.CldEnv.OperationsBundle, cap_reg_v2_seq.ConfigureCapabilitiesRegistry, diff --git a/system-tests/lib/cre/contracts/keystone_test.go b/system-tests/lib/cre/contracts/keystone_test.go index c2e07df5f97..abd1a689402 100644 --- a/system-tests/lib/cre/contracts/keystone_test.go +++ b/system-tests/lib/cre/contracts/keystone_test.go @@ -216,7 +216,7 @@ func TestToV2ConfigureInput(t *testing.T) { }, } - result := d.mustToV2ConfigureInput(chainSel, "0x1234567890abcdef", nil, nil) + result := d.mustToV2ConfigureInput(chainSel, "0x1234567890abcdef", nil, nil, nil) require.Equal(t, chainSel, result.RegistryChainSel) diff --git a/system-tests/lib/cre/environment/environment.go b/system-tests/lib/cre/environment/environment.go index bcd91e893f2..e0fe5a5a420 100644 --- a/system-tests/lib/cre/environment/environment.go +++ b/system-tests/lib/cre/environment/environment.go @@ -24,6 +24,7 @@ import ( "github.com/smartcontractkit/chainlink-testing-framework/framework/components/jd" "github.com/smartcontractkit/chainlink-testing-framework/framework/components/s3provider" "github.com/smartcontractkit/chainlink/deployment/cre/ocr3" + "github.com/smartcontractkit/chainlink/deployment/cre/ocr3/ocr3_1" keystone_changeset "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" "github.com/smartcontractkit/chainlink/system-tests/lib/cre" crecontracts "github.com/smartcontractkit/chainlink/system-tests/lib/cre/contracts" @@ -180,6 +181,7 @@ func SetupTestEnvironment( fmt.Print(libformat.PurpleText("%s", input.StageGen.Wrap("Applying Features before environment startup"))) var donsCapabilities = make(map[uint64][]keystone_changeset.DONCapabilityWithConfig) var capabilityToOCR3Config = make(map[string]*ocr3.OracleConfig) + capabilityToOCR3_1Config := make(map[string]*ocr3_1.V3_1OracleConfig) capabilityToExtraSignerFamilies := make(map[string][]string) for _, feature := range input.Features.List() { for _, donMetadata := range topology.DonsMetadataWithFlag(feature.Flag()) { @@ -200,6 +202,7 @@ func SetupTestEnvironment( } donsCapabilities[donMetadata.ID] = append(donsCapabilities[donMetadata.ID], output.DONCapabilityWithConfig...) maps.Copy(capabilityToOCR3Config, output.CapabilityToOCR3Config) + maps.Copy(capabilityToOCR3_1Config, output.CapabilityToOCR3_1Config) for capability, families := range output.CapabilityToExtraSignerFamilies { capabilityToExtraSignerFamilies[capability] = append([]string(nil), families...) } @@ -347,6 +350,7 @@ func SetupTestEnvironment( NodeSets: input.NodeSets, DONCapabilityWithConfigs: make(map[uint64][]keystone_changeset.DONCapabilityWithConfig), CapabilityToOCR3Config: capabilityToOCR3Config, + CapabilityToOCR3_1Config: capabilityToOCR3_1Config, CapabilityToExtraSignerFamilies: capabilityToExtraSignerFamilies, } diff --git a/system-tests/lib/cre/features/queue/queue.go b/system-tests/lib/cre/features/queue/queue.go index e1bd702eb05..4ec6e51d934 100644 --- a/system-tests/lib/cre/features/queue/queue.go +++ b/system-tests/lib/cre/features/queue/queue.go @@ -14,9 +14,9 @@ import ( kcr "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/capabilities_registry_1_1_0" cre_jobs "github.com/smartcontractkit/chainlink/deployment/cre/jobs" cre_jobs_ops "github.com/smartcontractkit/chainlink/deployment/cre/jobs/operations" - job_types "github.com/smartcontractkit/chainlink/deployment/cre/jobs/types" "github.com/smartcontractkit/chainlink/deployment/cre/jobs/pkg" - "github.com/smartcontractkit/chainlink/deployment/cre/ocr3" + job_types "github.com/smartcontractkit/chainlink/deployment/cre/jobs/types" + "github.com/smartcontractkit/chainlink/deployment/cre/ocr3/ocr3_1" ocr3_changeset "github.com/smartcontractkit/chainlink/deployment/cre/ocr3/v2/changeset" "github.com/smartcontractkit/chainlink/deployment/cre/pkg/offchain" keystone_changeset "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" @@ -43,6 +43,11 @@ func (o *ConsensusQueue) PreEnvStartup( return nil, nil } + workers, err := don.Workers() + if err != nil { + return nil, fmt.Errorf("failed to get workers for DON %s: %w", don.Name, err) + } + return &cre.PreEnvStartupOutput{ DONCapabilityWithConfig: []keystone_changeset.DONCapabilityWithConfig{{ Capability: kcr.CapabilitiesRegistryCapability{ @@ -56,9 +61,9 @@ func (o *ConsensusQueue) PreEnvStartup( }, UseCapRegOCRConfig: true, }}, - CapabilityToOCR3Config: map[string]*ocr3.OracleConfig{ - //TODO don't we need DefaultOCR3_1Config? - consensusQueueLabelledName: contracts.DefaultOCR3Config(), + // The plugin runs on the OCR 3.1 oracle, which rejects OCR3 (version 30) offchain configs. + CapabilityToOCR3_1Config: map[string]*ocr3_1.V3_1OracleConfig{ + consensusQueueLabelledName: contracts.DefaultOCR3_1Config(len(workers)), }, }, nil } diff --git a/system-tests/lib/cre/types.go b/system-tests/lib/cre/types.go index 156befa9d2c..d2ff5236f4e 100644 --- a/system-tests/lib/cre/types.go +++ b/system-tests/lib/cre/types.go @@ -31,6 +31,7 @@ import ( ks_sol "github.com/smartcontractkit/chainlink/deployment/cre/forwarder/solana" ks_stellar "github.com/smartcontractkit/chainlink/deployment/cre/forwarder/stellar" "github.com/smartcontractkit/chainlink/deployment/cre/ocr3" + "github.com/smartcontractkit/chainlink/deployment/cre/ocr3/ocr3_1" keystone_changeset "github.com/smartcontractkit/chainlink/deployment/keystone/changeset" "github.com/smartcontractkit/chainlink/system-tests/lib/cre/don/secrets" "github.com/smartcontractkit/chainlink/system-tests/lib/cre/environment/blockchains" @@ -367,6 +368,10 @@ type ConfigureCapabilityRegistryInput struct { // keyed by LabelledName CapabilityToOCR3Config map[string]*ocr3.OracleConfig + // keyed by LabelledName. For capabilities that run an OCR 3.1 plugin. + // An entry here is used instead of CapabilityToOCR3Config. + CapabilityToOCR3_1Config map[string]*ocr3_1.V3_1OracleConfig + // keyed by LabelledName. Non-EVM chain families whose signing keys should be // included in OCR3 config signers for that capability (e.g. ["solana"]). // EVM is always included. @@ -1745,6 +1750,8 @@ type PreEnvStartupOutput struct { DONCapabilityWithConfig []keystone_changeset.DONCapabilityWithConfig // keyed by LabelledName CapabilityToOCR3Config map[string]*ocr3.OracleConfig + // keyed by LabelledName. For capabilities that run an OCR 3.1 plugin. + CapabilityToOCR3_1Config map[string]*ocr3_1.V3_1OracleConfig // keyed by LabelledName. Non-EVM chain families whose signing keys should be // included in OCR3 config signers for that capability (e.g. ["solana"]). // EVM is always included. From 2c39984ff5c2e87bcd9c890374eba24c08da5940 Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Mon, 9 Nov 2026 22:26:31 +0100 Subject: [PATCH 06/10] fix: Remove c.Close from services.Config. Right now it reads a method of the still-nil embedded Service --- core/services/ocr3_1/plugins/queue/queue.go | 3 +- .../ocr3_1/plugins/queue/queue_test.go | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 core/services/ocr3_1/plugins/queue/queue_test.go diff --git a/core/services/ocr3_1/plugins/queue/queue.go b/core/services/ocr3_1/plugins/queue/queue.go index dbb4cc077ee..c5060f5fead 100644 --- a/core/services/ocr3_1/plugins/queue/queue.go +++ b/core/services/ocr3_1/plugins/queue/queue.go @@ -47,8 +47,7 @@ type consensusQueuePlugin struct { func newConsensusQueuePlugin(lggr logger.Logger, onchainCfg ocr3types.ReportingPluginConfig) *consensusQueuePlugin { c := &consensusQueuePlugin{lggr: logger.Named(lggr, "ConsensusQueuePlugin"), onchainCfg: onchainCfg} c.Service, c.eng = services.Config{ - Name: "ConsensusQueueReportingPlugin", - Close: c.Close, + Name: "ConsensusQueueReportingPlugin", }.NewServiceEngine(lggr) return c diff --git a/core/services/ocr3_1/plugins/queue/queue_test.go b/core/services/ocr3_1/plugins/queue/queue_test.go new file mode 100644 index 00000000000..09a2e6d9dfa --- /dev/null +++ b/core/services/ocr3_1/plugins/queue/queue_test.go @@ -0,0 +1,33 @@ +package queue + +import ( + "testing" + + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3_1types" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + "github.com/stretchr/testify/require" + + "github.com/smartcontractkit/chainlink-common/pkg/logger" + "github.com/smartcontractkit/chainlink-common/pkg/settings/limits" +) + +// libocr calls NewReportingPlugin with no recover, so a panic here takes down +// the whole node. This guards the constructor and the plugin lifecycle. +func TestConsensusQueuePluginFactory_NewReportingPlugin(t *testing.T) { + t.Parallel() + + cfg := &PluginConfig{Limits: ocr3_1types.ReportingPluginLimits{MaxKeyValueModifiedKeys: 1}} + factory, err := NewConsensusQueuePluginFactory(logger.Test(t), cfg, limits.Factory{}) + require.NoError(t, err) + + plugin, info, err := factory.NewReportingPlugin(t.Context(), ocr3types.ReportingPluginConfig{N: 4, F: 1}, nil) + require.NoError(t, err) + require.NotNil(t, plugin) + + info1, ok := info.(ocr3_1types.ReportingPluginInfo1) + require.True(t, ok, "unexpected ReportingPluginInfo type %T", info) + require.Equal(t, "ConsensusQueueReportingPlugin", info1.Name) + require.Equal(t, cfg.Limits, info1.Limits) + + require.NoError(t, plugin.Close()) +} From 25d4123e7e057b161c82fe74ce85055542d5bba4 Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Mon, 9 Nov 2026 22:51:33 +0100 Subject: [PATCH 07/10] test: add consensus-queue cases to ProposeJobSpec tests --- deployment/cre/jobs/propose_job_spec_test.go | 88 +++++++++++++++++++- 1 file changed, 86 insertions(+), 2 deletions(-) diff --git a/deployment/cre/jobs/propose_job_spec_test.go b/deployment/cre/jobs/propose_job_spec_test.go index 4d25ebe9f6d..898fc65f1fd 100644 --- a/deployment/cre/jobs/propose_job_spec_test.go +++ b/deployment/cre/jobs/propose_job_spec_test.go @@ -31,7 +31,6 @@ import ( "github.com/smartcontractkit/chainlink/deployment/cre/test" ) -// TODO add a subtest for ConsensusQueue func TestProposeJobSpec_VerifyPreconditions(t *testing.T) { j := jobs.ProposeJobSpec{} var env cldf.Environment @@ -232,6 +231,28 @@ func TestProposeJobSpec_VerifyPreconditions(t *testing.T) { expectError: true, errorMsg: "unsupported template", }, + { + name: "valid consensus-queue job", + input: jobs.ProposeJobSpecInput{ + Environment: test.EnvironmentName, + JobName: "consensus-queue-worker", + Domain: "cre", + DONName: "test-don", + DONFilters: []offchain.TargetDONFilter{ + {Key: offchain.FilterKeyDONName, Value: "d"}, + {Key: "environment", Value: "e"}, + {Key: "product", Value: offchain.ProductLabel}, + }, + Template: job_types.OCR3, + Inputs: job_types.JobSpecInput{ + "templateName": "consensus-queue", + "contractQualifier": "consensus-queue", + "chainSelectorEVM": "3379446385462418246", + "bootstrapperOCR3Urls": []string{"12D3KooWHfYFQ8hGttAYbMCevQVESEQhzJAqFZokMVtom8bNxwGq@127.0.0.1:5001"}, + }, + }, + expectError: false, + }, { name: "missing inputs", input: jobs.ProposeJobSpecInput{ @@ -509,7 +530,6 @@ func TestProposeJobSpec_VerifyPreconditions_Aptos(t *testing.T) { } } -// TODO add a subtest for ConsensusQueue func TestProposeJobSpec_Apply(t *testing.T) { h := test.NewTestHarness(t) env := new(h.Runtime.Environment()) @@ -1388,6 +1408,70 @@ func TestProposeJobSpec_Apply(t *testing.T) { } }) + t.Run("successful consensus-queue ocr3 job distribution", func(t *testing.T) { + h2 := test.NewTestHarness(t) + env2 := new(h2.Runtime.Environment()) + + chainSelector := h2.RegistrySelector + ds := datastore.NewMemoryDataStore() + err := ds.Addresses().Add(datastore.AddressRef{ + ChainSelector: chainSelector, + Type: datastore.ContractType(ocr3.OCR3Capability), + Version: semver.MustParse("1.0.0"), + Address: "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B", + Qualifier: "consensus-queue", + }) + require.NoError(t, err) + env2.DataStore = ds.Seal() + + input := jobs.ProposeJobSpecInput{ + Environment: test.EnvironmentName, + Domain: "cre", + JobName: "consensus-queue-worker", + DONName: test.DONName, + Template: job_types.OCR3, + DONFilters: []offchain.TargetDONFilter{ + {Key: offchain.FilterKeyDONName, Value: test.DONName}, + {Key: "environment", Value: test.EnvironmentName}, + {Key: "product", Value: offchain.ProductLabel}, + }, + Inputs: job_types.JobSpecInput{ + "templateName": "consensus-queue", + "contractQualifier": "consensus-queue", + "chainSelectorEVM": strconv.FormatUint(chainSelector, 10), + "bootstrapperOCR3Urls": []string{ + "12D3KooWHfYFQ8hGttAYbMCevQVESEQhzJAqFZokMVtom8bNxwGq@127.0.0.1:5001", + }, + }, + } + + out, err := jobs.ProposeJobSpec{}.Apply(*env2, input) + require.NoError(t, err) + assert.Len(t, out.Reports, 1) + + reqs, err := h2.TestJD.ListProposedJobRequests() + require.NoError(t, err) + + found := 0 + for _, req := range reqs { + if !strings.Contains(req.Spec, `pluginType = "consensus-queue"`) { + continue + } + found++ + assert.Contains(t, req.Spec, `type = "offchainreporting2"`) + assert.Contains(t, req.Spec, `name = "consensus-queue-worker`) + assert.Contains(t, req.Spec, `contractID = "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"`) + assert.Contains(t, req.Spec, `p2pv2Bootstrappers = [ + "12D3KooWHfYFQ8hGttAYbMCevQVESEQhzJAqFZokMVtom8bNxwGq@127.0.0.1:5001", +]`) + assert.Contains(t, req.Spec, `relay = "evm"`) + assert.Contains(t, req.Spec, fmt.Sprintf(`chainID = "%d"`, chainsel.TEST_90000001.EvmChainID)) + assert.Contains(t, req.Spec, `ocrKeyBundleID = "`) + assert.Contains(t, req.Spec, `transmitterID = "`) + } + require.Positive(t, found, "no consensus-queue job spec was proposed") + }) + t.Run("successful consensus job distribution", func(t *testing.T) { chainSelector := h.RegistrySelector ds := datastore.NewMemoryDataStore() From 7a8c4924e30ccfa692e2b46e3d0b36b87ffa4115 Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Mon, 9 Nov 2026 22:55:05 +0100 Subject: [PATCH 08/10] fix: stop HasFlag matching consensus against consensus-queue --- system-tests/lib/cre/don.go | 17 ++++++++++------ system-tests/lib/cre/flags/flags.go | 13 +----------- system-tests/lib/cre/flags/flags_test.go | 25 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/system-tests/lib/cre/don.go b/system-tests/lib/cre/don.go index 585abd6b2e3..ef145b2177c 100644 --- a/system-tests/lib/cre/don.go +++ b/system-tests/lib/cre/don.go @@ -939,14 +939,19 @@ func LinkToJobDistributor(ctx context.Context, input *LinkDonsToJDInput) error { return nil } -// copied from flags package to avoid circular dependency +// HasFlag reports whether values holds capability, either bare or with a +// chain ID suffix such as "evm-1337". The suffix must be numeric, so +// "consensus" does not match "consensus-queue". func HasFlag(values []string, capability string) bool { - if slices.Contains(values, capability) { - return true - } - for _, value := range values { - if strings.HasPrefix(value, capability+"-") { //TODO collisions? + if value == capability { + return true + } + suffix, ok := strings.CutPrefix(value, capability+"-") + if !ok { + continue + } + if _, err := strconv.ParseUint(suffix, 10, 64); err == nil { return true } } diff --git a/system-tests/lib/cre/flags/flags.go b/system-tests/lib/cre/flags/flags.go index 126dd44c01f..5532161f200 100644 --- a/system-tests/lib/cre/flags/flags.go +++ b/system-tests/lib/cre/flags/flags.go @@ -3,7 +3,6 @@ package flags import ( "slices" "strconv" - "strings" "github.com/pkg/errors" @@ -28,17 +27,7 @@ func HasFlagForChain(values []string, capability string, chainID uint64) bool { } func HasFlagForAnyChain(values []string, capability string) bool { - if slices.Contains(values, capability) { - return true - } - - for _, value := range values { - if strings.HasPrefix(value, capability+"-") { - return true - } - } - - return false + return cre.HasFlag(values, capability) } func RequiresForwarderContract(values []string, chainID uint64) bool { diff --git a/system-tests/lib/cre/flags/flags_test.go b/system-tests/lib/cre/flags/flags_test.go index d9d74d146b1..557d4089a9f 100644 --- a/system-tests/lib/cre/flags/flags_test.go +++ b/system-tests/lib/cre/flags/flags_test.go @@ -23,3 +23,28 @@ func TestRequiresForwarderContract(t *testing.T) { require.True(t, RequiresForwarderContract([]string{cre.StellarCapability}, 0)) }) } + +func TestHasFlagForAnyChain(t *testing.T) { + t.Parallel() + + values := []string{cre.ConsensusQueueCapability, cre.EVMCapability + "-1337", cre.CronCapability} + + tests := []struct { + name string + capability string + want bool + }{ + {"exact match", cre.CronCapability, true}, + {"exact match with a hyphen in the name", cre.ConsensusQueueCapability, true}, + {"chain ID suffix", cre.EVMCapability, true}, + {"non-numeric suffix is a different flag", cre.ConsensusCapability, false}, + {"absent", cre.VaultCapability, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + require.Equal(t, tt.want, HasFlagForAnyChain(values, tt.capability)) + require.Equal(t, tt.want, cre.HasFlag(values, tt.capability)) + }) + } +} From 980d4c79ba15d66f18e8ab7dd5e494cd0851fea8 Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Tue, 10 Nov 2026 11:41:46 +0100 Subject: [PATCH 09/10] fix: lint issues --- core/services/ocr2/delegate.go | 2 +- core/services/ocr3_1/plugins/queue/queue_test.go | 3 ++- system-tests/lib/cre/features/queue/queue.go | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/services/ocr2/delegate.go b/core/services/ocr2/delegate.go index d9397a4e583..4dc4c38198f 100644 --- a/core/services/ocr2/delegate.go +++ b/core/services/ocr2/delegate.go @@ -872,7 +872,7 @@ func (d *Delegate) newServicesConsensusQueue( BinaryNetworkEndpointFactory: d.peerWrapper.Peer3_1, V2Bootstrappers: bootstrapPeers, ContractConfigTracker: configTracker, - //TODO pass engine as EventSink + // TODO pass engine as EventSink ContractTransmitter: queue.NewTransmitter(lggr, ocrtypes.Account(spec.TransmitterID.String), nil), Database: ocrDB, KeyValueDatabaseFactory: kvFactory, diff --git a/core/services/ocr3_1/plugins/queue/queue_test.go b/core/services/ocr3_1/plugins/queue/queue_test.go index 09a2e6d9dfa..f5b83690325 100644 --- a/core/services/ocr3_1/plugins/queue/queue_test.go +++ b/core/services/ocr3_1/plugins/queue/queue_test.go @@ -3,9 +3,10 @@ package queue import ( "testing" + "github.com/stretchr/testify/require" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3_1types" "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" - "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/settings/limits" diff --git a/system-tests/lib/cre/features/queue/queue.go b/system-tests/lib/cre/features/queue/queue.go index 4ec6e51d934..34b595d5891 100644 --- a/system-tests/lib/cre/features/queue/queue.go +++ b/system-tests/lib/cre/features/queue/queue.go @@ -87,7 +87,7 @@ func (o *ConsensusQueue) PostEnvStartup( if err != nil { return fmt.Errorf("failed to create consensusQueue jobs: %w", err) } - //TODO more? + // TODO more? return nil } @@ -153,7 +153,8 @@ func createJobs( if creEnv.FreshExternalJobIDs { input.Inputs["externalJobID"] = uuid.NewString() } - if err := (cre_jobs.ProposeJobSpec{}).VerifyPreconditions(*creEnv.CldfEnvironment, input); err != nil { + err = (cre_jobs.ProposeJobSpec{}).VerifyPreconditions(*creEnv.CldfEnvironment, input) + if err != nil { return errors.Wrapf(err, "precondition verification failed for %s worker job", flag) } From 4b0f196e359cb7547a953a9cd0c85096476d1558 Mon Sep 17 00:00:00 2001 From: Gabriel Paradiso Date: Wed, 11 Nov 2026 10:08:10 +0100 Subject: [PATCH 10/10] fix: remove unused EventSink from consensus-queue transmitter The plugin produces no reports, so libocr never calls Transmit. Event delivery will happen in the plugin's Committed step instead. --- core/services/ocr2/delegate.go | 21 +++++++++---------- .../ocr3_1/plugins/queue/transmitter.go | 5 +---- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/core/services/ocr2/delegate.go b/core/services/ocr2/delegate.go index 4dc4c38198f..69f8180517b 100644 --- a/core/services/ocr2/delegate.go +++ b/core/services/ocr2/delegate.go @@ -872,17 +872,16 @@ func (d *Delegate) newServicesConsensusQueue( BinaryNetworkEndpointFactory: d.peerWrapper.Peer3_1, V2Bootstrappers: bootstrapPeers, ContractConfigTracker: configTracker, - // TODO pass engine as EventSink - ContractTransmitter: queue.NewTransmitter(lggr, ocrtypes.Account(spec.TransmitterID.String), nil), - Database: ocrDB, - KeyValueDatabaseFactory: kvFactory, - LocalConfig: lc, - Logger: ocrLogger, - MonitoringEndpoint: oracleEndpoint, - OffchainConfigDigester: configDigester, - OffchainKeyring: kb, - OnchainKeyring: ocr3shims.OnchainKeyringAsOnchainKeyring2(onchainKeyringAdapter), - MetricsRegisterer: prometheus.WrapRegistererWith(map[string]string{"job_name": jb.Name.ValueOrZero()}, prometheus.DefaultRegisterer), + ContractTransmitter: queue.NewTransmitter(lggr, ocrtypes.Account(spec.TransmitterID.String)), + Database: ocrDB, + KeyValueDatabaseFactory: kvFactory, + LocalConfig: lc, + Logger: ocrLogger, + MonitoringEndpoint: oracleEndpoint, + OffchainConfigDigester: configDigester, + OffchainKeyring: kb, + OnchainKeyring: ocr3shims.OnchainKeyringAsOnchainKeyring2(onchainKeyringAdapter), + MetricsRegisterer: prometheus.WrapRegistererWith(map[string]string{"job_name": jb.Name.ValueOrZero()}, prometheus.DefaultRegisterer), } rpf, err := queue.NewConsensusQueuePluginFactory(lggr, cfg, d.limitsFactory) diff --git a/core/services/ocr3_1/plugins/queue/transmitter.go b/core/services/ocr3_1/plugins/queue/transmitter.go index 69ad7a77d04..4c9b94187c5 100644 --- a/core/services/ocr3_1/plugins/queue/transmitter.go +++ b/core/services/ocr3_1/plugins/queue/transmitter.go @@ -7,20 +7,17 @@ import ( ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/smartcontractkit/chainlink-common/pkg/logger" - "github.com/smartcontractkit/chainlink/v2/core/services/workflows/v2/triggers" ) type contractTransmitter struct { lggr logger.Logger fromAccount ocrtypes.Account - eventSink triggers.EventSink } -func NewTransmitter(lggr logger.Logger, fromAccount ocrtypes.Account, eventSink triggers.EventSink) ocr3types.ContractTransmitter[[]byte] { +func NewTransmitter(lggr logger.Logger, fromAccount ocrtypes.Account) ocr3types.ContractTransmitter[[]byte] { return &contractTransmitter{ lggr: lggr, fromAccount: fromAccount, - eventSink: eventSink, } }