Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions core/services/internal/internal.go
Original file line number Diff line number Diff line change
@@ -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
)
23 changes: 13 additions & 10 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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"
Expand All @@ -87,18 +88,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"
consensusQueueOCRConfigKey = "consensus-queue"
consensusQueueCapabilityID = internal.ConsensusQueueCapabilityID
gaugeConsensusQueueBytes = "platform_consensus_queue_usage_bytes"
consensusQueueDiskMonitorTickInterval = time.Minute
)
Expand Down Expand Up @@ -821,7 +821,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 {
Expand Down Expand Up @@ -849,7 +853,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) {
Expand Down Expand Up @@ -882,8 +886,7 @@ 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)
configTracker, configDigester, lc, err := d.maybeWrapConfigService(consensusQueueCapabilityID, capabilitiespb.OCR3ConfigDefaultKey, lggr, provider.ContractConfigTracker(), provider.OffchainConfigDigester(), lc)
if err != nil {
return nil, err
}
Expand All @@ -892,7 +895,7 @@ func (d *Delegate) newServicesConsensusQueue(
BinaryNetworkEndpointFactory: d.peerWrapper.Peer3_1,
V2Bootstrappers: bootstrapPeers,
ContractConfigTracker: configTracker,
ContractTransmitter: nil, // TODO ticket transmitter
ContractTransmitter: queue.NewTransmitter(lggr, ocrtypes.Account(spec.TransmitterID.String)),
Database: ocrDB,
KeyValueDatabaseFactory: kvFactory,
LocalConfig: lc,
Expand All @@ -904,7 +907,7 @@ 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, cfg, d.limitsFactory)
if err != nil {
return nil, err
}
Expand Down
11 changes: 11 additions & 0 deletions core/services/ocr2/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
}
14 changes: 14 additions & 0 deletions core/services/ocr3_1/plugins/queue/config.go
Original file line number Diff line number Diff line change
@@ -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
}
88 changes: 46 additions & 42 deletions core/services/ocr3_1/plugins/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,101 @@ 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"
)

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",
}.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
}
34 changes: 34 additions & 0 deletions core/services/ocr3_1/plugins/queue/queue_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package queue

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3_1types"
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"

"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())
}
30 changes: 30 additions & 0 deletions core/services/ocr3_1/plugins/queue/transmitter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package queue

import (
"context"

"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
)

type contractTransmitter struct {
lggr logger.Logger
fromAccount ocrtypes.Account
}

func NewTransmitter(lggr logger.Logger, fromAccount ocrtypes.Account) ocr3types.ContractTransmitter[[]byte] {
return &contractTransmitter{
lggr: lggr,
fromAccount: fromAccount,
}
}

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
}
12 changes: 5 additions & 7 deletions core/services/workflows/v2/capability_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down
Loading
Loading