Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8f1afd8
ConsensusQueue: wire no-op ReportingPlugin
jmank88 Oct 29, 2026
a2b6326
core/services/ocr3_1/plugins/queue: ReportingPlugin implementation
jmank88 Oct 29, 2026
8e88824
inject triggers.Coordinator; implement more StateTransition
jmank88 Oct 30, 2026
1867569
simplify
jmank88 Nov 1, 2026
7482bef
blob support
jmank88 Nov 9, 2026
21514f3
blob helpers; kv cleanup; more validation; more methods
jmank88 Nov 12, 2026
711d054
cleanup & fixes
jmank88 Nov 13, 2026
90768bd
dedupe blobs
jmank88 Nov 17, 2026
b0d2926
Merge remote-tracking branch 'origin/develop' into CRE-6002-reporting…
jmank88 Nov 17, 2026
0a0595c
cleanup; medianization; swap map for entries
jmank88 Nov 17, 2026
51c55f9
wire trigger.Queue; implement SortedFunc & Remove
jmank88 Nov 18, 2026
e7bc3da
docs
jmank88 Nov 18, 2026
0fcadd7
CompareDeadline methods and cleanup
jmank88 Nov 18, 2026
60e3b4d
review feedback; reorder StateTransition to limit KV data; fill gaps
jmank88 Nov 19, 2026
d9b007e
drop observations < f+1; limit workflowCapacities; remove from queue …
jmank88 Nov 20, 2026
8111c59
fixes; swap out trigger event ID for execution ID
jmank88 Nov 20, 2026
668e74b
fixes
jmank88 Nov 20, 2026
9066e97
dynamic config; fixes
jmank88 Nov 20, 2026
5c2b92b
fixes; cleanup; simplifications
jmank88 Nov 22, 2026
fa2fcf6
add tests & fixes
jmank88 Nov 22, 2026
d6961fc
cleanup
jmank88 Nov 22, 2026
6919c07
cleanup TODOs
jmank88 Nov 22, 2026
7824491
optimizations
jmank88 Nov 22, 2026
c2255e1
fix central queue
jmank88 Nov 22, 2026
765c582
ensure idempotency
jmank88 Nov 22, 2026
0a6870a
defense
jmank88 Nov 22, 2026
4084466
metrics
jmank88 Nov 22, 2026
dca58bc
make coordinator.TryStartExecute respect shadow mode
jmank88 Nov 22, 2026
8874411
use FeatureConsensusQueueKVDrainActivePeriod
jmank88 Nov 22, 2026
2e10130
docs & diagrams
jmank88 Nov 22, 2026
e0e5799
consensus queue: do not keep a cancelled blob fetch as the result for…
jmank88 Nov 23, 2026
c098d9c
central queue: drainer yields to the consensus queue plugin
jmank88 Nov 23, 2026
ad4e205
consensus queue: fix nil plugin config panic and give the job templat…
jmank88 Nov 23, 2026
b6a8b3a
Merge remote-tracking branch 'origin/develop' into CRE-6002-reporting…
jmank88 Nov 23, 2026
9d6a4b3
bump common
jmank88 Nov 23, 2026
3030c17
lint
jmank88 Nov 23, 2026
9a042f1
never observe duplicate events; ensure no repeated blob handles
jmank88 Nov 23, 2026
2f2592e
Merge remote-tracking branch 'origin/develop' into CRE-6002-reporting…
jmank88 Nov 23, 2026
a5bebba
cleanup and pruning
jmank88 Nov 24, 2026
5a0e98c
don't short circuit on broacast failure
jmank88 Nov 24, 2026
b3cdbb0
Merge remote-tracking branch 'origin/develop' into CRE-6002-reporting…
jmank88 Nov 24, 2026
ad9d146
test cleanup
jmank88 Nov 24, 2026
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
2 changes: 2 additions & 0 deletions core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/llo"
ocr3beholderwrapper "github.com/smartcontractkit/chainlink/v2/core/services/ocr3/beholderwrapper"
ocr3_1beholderwrapper "github.com/smartcontractkit/chainlink/v2/core/services/ocr3_1/beholderwrapper"
consensusqueue "github.com/smartcontractkit/chainlink/v2/core/services/ocr3_1/plugins/queue"
"github.com/smartcontractkit/chainlink/v2/core/services/periodicbackup"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/services/versioning"
Expand All @@ -85,6 +86,7 @@ func metricViews() []sdkmetric.View {
ccvcommon.MetricViews(),
ocr3beholderwrapper.MetricViews(),
ocr3_1beholderwrapper.MetricViews(),
consensusqueue.MetricViews(),
gatewaynetwork.HTTPClientMetricViews(),
gatewaynetwork.WSConnectionMetricViews(),
gatewaymonitoring.MetricViews(),
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chain-selectors v1.0.112
github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20261001213322-a2d686f610ca
github.com/smartcontractkit/chainlink-common v0.11.2-0.20261123132302-3db945c721d8
github.com/smartcontractkit/chainlink-common v0.11.2-0.20261124133622-53ca4463ec7d
github.com/smartcontractkit/chainlink-common/keystore v1.3.1-0.20261111193935-c83f8e2996fb
github.com/smartcontractkit/chainlink-deployments-framework v0.126.0
github.com/smartcontractkit/chainlink-evm v0.3.4-0.20261118192309-cfc3cc2381a2
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,9 @@ func NewApplication(ctx context.Context, opts ApplicationOpts) (Application, err
OrgResolver: creServices.OrgResolver,
LimitsFactory: limitsFactory,
OCRConfigService: creServices.OCRConfigService,
TriggerCoordinator: creServices.TriggerCoordinator,
TriggerQueue: creServices.TriggerQueue,
Meter: meter,
DefaultBootstrappers: safeDefaultBootstrappers(cfg),
CapRegistryAddress: safeExternalRegistryAddress(cfg),
CapRegistryChainID: safeExternalRegistryChainID(cfg),
Expand Down
65 changes: 43 additions & 22 deletions core/services/cre/cre.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/static"
)

// completedExecutionRetentionMargin is added to the longest event lifetime to decide how long to remember completed
// executions. It allows for clock skew between nodes, as an event's agreed deadline is a median of theirs.
const completedExecutionRetentionMargin = time.Minute

// Keystore is the minimal interface needed from keystore for CRE
type Keystore interface {
CSA() keystore.CSA
Expand Down Expand Up @@ -135,6 +139,10 @@ type Services struct {

WorkflowRegistrySyncer syncerV2.WorkflowRegistrySyncer

TriggerCoordinator triggers.Coordinator

TriggerQueue triggers.Queue

OrgResolver orgresolver.OrgResolver

OCRConfigService capregconfig.OCRConfigService
Expand Down Expand Up @@ -297,7 +305,7 @@ func (s *Services) newSubservices(
wfSyncerLggr.Infof("failed to create billing client: %s", err)
}

wfSyncer, wfSyncerSrvcs, err := newWorkflowRegistrySyncerV2(
wfSyncer, triggerCoordinator, triggerQueue, wfSyncerSrvcs, err := newWorkflowRegistrySyncerV2(
cfg,
relayerChainInterops,
billingClient,
Expand All @@ -320,6 +328,8 @@ func (s *Services) newSubservices(
}
s.BillingClient = billingClient
s.WorkflowRegistrySyncer = wfSyncer
s.TriggerCoordinator = triggerCoordinator
s.TriggerQueue = triggerQueue
srvs = append(srvs, wfSyncerSrvcs...)

return srvs, nil
Expand Down Expand Up @@ -800,14 +810,14 @@ func newWorkflowRegistrySyncerV2(
meterIdentity resourcemanager.ResourceIdentity,
dispatcher remotetypes.Dispatcher,
shardIndexMapper *shardownership.ShardIndexMapper,
) (syncerV2.WorkflowRegistrySyncer, []commonsrv.Service, error) {
) (syncerV2.WorkflowRegistrySyncer, triggers.Coordinator, triggers.Queue, []commonsrv.Service, error) {
capCfg := cfg.Capabilities()
wfReg := capCfg.WorkflowRegistry()
key := opts.WorkflowKey

fetcherFunc, retrieverFunc, srvcs, err := newFetcherServiceV2(opts, capCfg, lggr, gatewayConnectorWrapper)
if err != nil {
return nil, nil, err
return nil, nil, nil, nil, err
}

artifactsStore, err := artifactsV2.NewStore(
Expand All @@ -824,29 +834,29 @@ func newWorkflowRegistrySyncerV2(
}),
)
if err != nil {
return nil, nil, fmt.Errorf("unable to create artifact store: %w", err)
return nil, nil, nil, nil, fmt.Errorf("unable to create artifact store: %w", err)
}

engineRegistry := syncerV2.NewEngineRegistry()

engineLimiters, err := v2.NewLimiters(lf, nil)
if err != nil {
return nil, nil, fmt.Errorf("could not instantiate engine limiters: %w", err)
return nil, nil, nil, nil, fmt.Errorf("could not instantiate engine limiters: %w", err)
}

featureFlags, err := v2.NewFeatureFlags(lf, nil)
if err != nil {
return nil, nil, fmt.Errorf("could not instantiate engine feature flags: %w", err)
return nil, nil, nil, nil, fmt.Errorf("could not instantiate engine feature flags: %w", err)
}

selector, err := chainSelector(wfReg.ChainID(), wfReg.NetworkID())
if err != nil {
return nil, nil, err
return nil, nil, nil, nil, err
}

crFactory, err := newContractReaderFactory(capCfg, relayerChainInterops)
if err != nil {
return nil, nil, fmt.Errorf("failed to instantiate contract reader factory: %w", err)
return nil, nil, nil, nil, fmt.Errorf("failed to instantiate contract reader factory: %w", err)
}

var shardOrchestratorClient shardorchestrator.ClientInterface
Expand All @@ -855,7 +865,7 @@ func newWorkflowRegistrySyncerV2(
} else {
c, clientErr := newShardOrchestratorClient(cfg, lggr)
if clientErr != nil {
return nil, nil, clientErr
return nil, nil, nil, nil, clientErr
}
if c != nil {
shardOrchestratorClient = c
Expand Down Expand Up @@ -902,24 +912,27 @@ func newWorkflowRegistrySyncerV2(

coordinatorMetrics, err := wfmonitoring.InitMonitoringResources()
if err != nil {
return nil, nil, fmt.Errorf("unable to init trigger coordinator metrics: %w", err)
return nil, nil, nil, nil, fmt.Errorf("unable to init trigger coordinator metrics: %w", err)
}
centralQueueMetrics, err := wfmonitoring.InitCentralTriggerQueueMetrics()
if err != nil {
return nil, nil, fmt.Errorf("unable to init central trigger queue metrics: %w", err)
return nil, nil, nil, nil, fmt.Errorf("unable to init central trigger queue metrics: %w", err)
}
drainerMetrics, err := wfmonitoring.InitTriggerDrainerMetrics()
if err != nil {
return nil, nil, fmt.Errorf("unable to init central trigger queue drainer metrics: %w", err)
return nil, nil, nil, nil, fmt.Errorf("unable to init central trigger queue drainer metrics: %w", err)
}
coordinatorClock := clockwork.NewRealClock()

// Shadow mode copies coordinated trigger events to the central queue while
// FeatureShadowTriggerModeActivePeriod is open. The copies are for observation only.
// The drainer logs and discards them, and each event still executes on its workflow's own queue.
// The drainer logs and discards them, and each event still executes on its workflow's own queue. The coordinator
// also logs instead of starting an event in that window when consensus on the queue chooses it. While the consensus
// queue plugin is reading the queue, the drainer leaves the events to it and only drops those that have expired.
eventLifetime := triggers.NewEventLifetime(triggers.ConsensusQueueExpirationGrace(lf))
centralQueue := triggers.NewQueue(engineLimiters.CentralTriggerEventQueue,
wfmonitoring.NewCentralTriggerQueueMetricLabeler(commonmetrics.NewLabeler(), centralQueueMetrics), lggr)
centralQueueDrainer := triggers.NewCentralQueueDrainer(centralQueue, engineLimiters.CentralTriggerQueueDrainInterval,
centralQueueDrainer := triggers.NewCentralQueueDrainer(centralQueue, triggers.ConsensusQueueExpirationGrace(lf), engineLimiters.CentralTriggerQueueDrainInterval,
wfmonitoring.NewTriggerDrainerMetricLabeler(commonmetrics.NewLabeler(), drainerMetrics), coordinatorClock, lggr)
triggerCoordinator := triggers.NewCoordinator(
triggers.RegisterDeps{
Expand All @@ -935,6 +948,8 @@ func newWorkflowRegistrySyncerV2(
coordinatorClock,
triggers.WithShadowMode(centralQueue, engineLimiters.ShadowTriggerMode),
triggers.WithDrainer(centralQueueDrainer),
triggers.WithExpirationGrace(triggers.ConsensusQueueExpirationGrace(lf)),
triggers.WithEventLifetime(eventLifetime),
)

handlerOpts := []syncerV2.EventHandlerOption{
Expand Down Expand Up @@ -971,7 +986,7 @@ func newWorkflowRegistrySyncerV2(
})
specMeter, smErr := syncerV2.NewSpecMeter(lggr, rm, meterIdentity, artifactsStore, orgResolver)
if smErr != nil {
return nil, nil, fmt.Errorf("unable to create workflow spec meter: %w", smErr)
return nil, nil, nil, nil, fmt.Errorf("unable to create workflow spec meter: %w", smErr)
}
handlerOpts = append(handlerOpts, syncerV2.WithSpecMeter(specMeter))
}
Expand All @@ -992,7 +1007,7 @@ func newWorkflowRegistrySyncerV2(
if diskMonitorEnabled {
fileStore, fsErr := artifactsV2.NewFileModuleStore(mc.CacheDir(), cacheEnabled)
if fsErr != nil {
return nil, nil, fmt.Errorf("unable to create file module store: %w", fsErr)
return nil, nil, nil, nil, fmt.Errorf("unable to create file module store: %w", fsErr)
}

dm, dmErr := syncerV2.NewWorkflowModuleCacheDiskMonitor(
Expand All @@ -1001,7 +1016,7 @@ func newWorkflowRegistrySyncerV2(
syncerV2.WorkflowModuleCacheDiskMonitorTickInterval,
)
if dmErr != nil {
return nil, nil, fmt.Errorf("unable to create module cache disk monitor: %w", dmErr)
return nil, nil, nil, nil, fmt.Errorf("unable to create module cache disk monitor: %w", dmErr)
}
srvcs = append(srvcs, dm)

Expand All @@ -1010,7 +1025,7 @@ func newWorkflowRegistrySyncerV2(
if cacheEnabled {
cm, cmErr := syncerV2.NewCacheMetrics()
if cmErr != nil {
return nil, nil, fmt.Errorf("unable to create module cache metrics: %w", cmErr)
return nil, nil, nil, nil, fmt.Errorf("unable to create module cache metrics: %w", cmErr)
}

var idleTimeout time.Duration
Expand Down Expand Up @@ -1041,9 +1056,15 @@ func newWorkflowRegistrySyncerV2(
}
}

// An event can be queued again (by nodes that were late to see it) until it expires, and the store is what tells the
// engine that such an event already ran. So it must remember executions for at least that long.
workflowStore := workflowstore.NewInMemoryStore(lggr, clockwork.NewRealClock())
workflowStore.SetMinimumCompletedRetention(func() time.Duration {
return eventLifetime.Longest(context.Background()) + completedExecutionRetentionMargin
})
eventHandler, err := syncerV2.NewEventHandler(
lggr,
workflowstore.NewInMemoryStore(lggr, clockwork.NewRealClock()),
workflowStore,
dontimeStore,
opts.UseLocalTimeProvider,
opts.CapabilitiesRegistry,
Expand All @@ -1060,7 +1081,7 @@ func newWorkflowRegistrySyncerV2(
handlerOpts...,
)
if err != nil {
return nil, nil, fmt.Errorf("unable to create workflow registry event handler: %w", err)
return nil, nil, nil, nil, fmt.Errorf("unable to create workflow registry event handler: %w", err)
}

addSources := wfReg.AdditionalSources()
Expand Down Expand Up @@ -1113,12 +1134,12 @@ func newWorkflowRegistrySyncerV2(
registryOpts...,
)
if err != nil {
return nil, nil, fmt.Errorf("unable to create workflow registry syncer: %w", err)
return nil, nil, nil, nil, fmt.Errorf("unable to create workflow registry syncer: %w", err)
}

srvcs = append(srvcs, workflowRegistrySyncerV2)
lggr.Debugw("Created WorkflowRegistrySyncer V2")
return workflowRegistrySyncerV2, srvcs, nil
return workflowRegistrySyncerV2, triggerCoordinator, centralQueue, srvcs, nil
}

// NewServices creates and initializes all CRE services
Expand Down
19 changes: 16 additions & 3 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/jonboulle/clockwork"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"go.opentelemetry.io/otel/metric"
"google.golang.org/grpc"
"gopkg.in/guregu/null.v4"

Expand Down Expand Up @@ -83,6 +84,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/synchronization"
"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"
syncerV2 "github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncer/v2"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/v2/triggers"
"github.com/smartcontractkit/chainlink/v2/core/utils"
"github.com/smartcontractkit/chainlink/v2/plugins"
)
Expand Down Expand Up @@ -156,6 +158,9 @@ type Delegate struct {
OrgResolver orgresolver.OrgResolver
limitsFactory limits.Factory
ocrConfigService capregconfig.OCRConfigService
triggerCoordinator triggers.Coordinator
triggerQueue triggers.Queue
meter metric.Meter

// Registry-driven launch support: when the delegate is used via
// LocalCapabilityManager (no job spec), these fields provide the
Expand Down Expand Up @@ -309,6 +314,10 @@ type DelegateOpts struct {
OrgResolver orgresolver.OrgResolver
LimitsFactory limits.Factory
OCRConfigService capregconfig.OCRConfigService
TriggerCoordinator triggers.Coordinator
TriggerQueue triggers.Queue
// Meter creates the plugins' metrics.
Meter metric.Meter

// Registry-driven launch support: defaults for capabilities launched
// via LocalCapabilityManager (no job spec).
Expand Down Expand Up @@ -358,6 +367,9 @@ func NewDelegate(
OrgResolver: opts.OrgResolver,
limitsFactory: opts.LimitsFactory,
ocrConfigService: opts.OCRConfigService,
triggerCoordinator: opts.TriggerCoordinator,
triggerQueue: opts.TriggerQueue,
meter: opts.Meter,
defaultBootstrappers: opts.DefaultBootstrappers,
capRegistryAddress: opts.CapRegistryAddress,
capRegistryChainID: opts.CapRegistryChainID,
Expand Down Expand Up @@ -904,7 +916,7 @@ func (d *Delegate) newServicesConsensusQueue(
BinaryNetworkEndpointFactory: d.peerWrapper.Peer3_1,
V2Bootstrappers: bootstrapPeers,
ContractConfigTracker: configTracker,
ContractTransmitter: queue.NewTransmitter(lggr, ocrtypes.Account(spec.TransmitterID.String)),
ContractTransmitter: queue.NewTransmitter(ocrtypes.Account(spec.TransmitterID.String)),
Database: ocrDB,
KeyValueDatabaseFactory: kvFactory,
LocalConfig: lc,
Expand All @@ -916,12 +928,12 @@ func (d *Delegate) newServicesConsensusQueue(
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, d.limitsFactory, d.triggerCoordinator, d.triggerQueue, d.meter)
if err != nil {
return nil, err
}

wrappedRpf := beholderwrapper.NewReportingPluginFactory(rpf, lggr, string(types.ConsensusQueue))
wrappedRpf := beholderwrapper.NewReportingPluginFactory(rpf, lggr, string(types.ConsensusQueue), d.meter)
oracleArgs.ReportingPluginFactory = wrappedRpf

oracle, err := libocr2.NewOracle(oracleArgs)
Expand Down Expand Up @@ -1124,6 +1136,7 @@ func (d *Delegate) newServicesVaultPlugin(
rpf,
lggr,
"vault",
d.meter,
)
oracleArgs.ReportingPluginFactory = wrappedRpf

Expand Down
Loading
Loading