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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gate-execution-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#changed Gate workflow execution metadata behind the FeatureExecutionMetadataActivePeriod setting (off by default)
6 changes: 3 additions & 3 deletions 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.20261118204812-c2cd552dc1f2
github.com/smartcontractkit/chainlink-common v0.11.2-0.20261119230624-78d15e1f1d4e
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 Expand Up @@ -500,7 +500,7 @@ require (
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260922043016-517a12a4220e // indirect
github.com/smartcontractkit/chainlink-ccip/deployment v0.0.0-20261001213322-a2d686f610ca // indirect
github.com/smartcontractkit/chainlink-ccv v0.16.0 // indirect
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20261106154152-9426766b30a9 // indirect
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20261119075727-f272852ab605 // indirect
github.com/smartcontractkit/chainlink-common/x/config v0.0.0-20260928140953-a9b0d3a04daa // indirect
github.com/smartcontractkit/chainlink-confidential-compute v1.3.0 // indirect
github.com/smartcontractkit/chainlink-data-streams v1.1.3 // indirect
Expand All @@ -515,7 +515,7 @@ require (
github.com/smartcontractkit/chainlink-protos/chainlink-ccv/message-discovery v0.0.0-20251211142334-5c3421fe2c8d // indirect
github.com/smartcontractkit/chainlink-protos/chainlink-ccv/message-rules v0.0.0-20260505131349-78e491b80735 // indirect
github.com/smartcontractkit/chainlink-protos/chainlink-ccv/verifier v0.0.0-20251211142334-5c3421fe2c8d // indirect
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20261103151748-aa8c64acc53c // indirect
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20261118180951-353e61fe935a // indirect
github.com/smartcontractkit/chainlink-protos/data-feeds v0.1.1-0.20260501174546-2e8846986b36 // indirect
github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20260916235422-d73d783612ca // indirect
github.com/smartcontractkit/chainlink-protos/metering/go v0.0.0-20260729184203-90b4cdd48536 // indirect
Expand Down
12 changes: 6 additions & 6 deletions core/scripts/go.sum

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

11 changes: 8 additions & 3 deletions core/services/workflows/cmd/cre/utils/standalone_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/capabilities/registry"
httpserver "github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/actions/http/server"
consensusserver "github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/consensus/server"
commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/contexts"
"github.com/smartcontractkit/chainlink-common/pkg/custmsg"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
Expand Down Expand Up @@ -172,9 +173,13 @@ func NewStandaloneEngine(
if moduleExecuteMaxResponseSizeBytes < 0 {
return nil, nil, fmt.Errorf("invalid moduleExecuteMaxResponseSizeBytes; must not be negative: %d", moduleExecuteMaxResponseSizeBytes)
}
workflowExecutionMetadata, err := getExecutionMetadata(ctx, cfg)
if err != nil {
return nil, nil, err
// Gated like the engine: no metadata unless FeatureExecutionMetadataActivePeriod covers now.
var workflowExecutionMetadata *sdkpb.WorkflowExecutionMetadata
if checkErr := cfg.LocalLimiters.ExecutionMetadata.Check(ctx, commonconfig.Timestamp(time.Now().Unix())); checkErr == nil {
workflowExecutionMetadata, err = getExecutionMetadata(ctx, cfg)
if err != nil {
return nil, nil, err
}
}
result, err := module.Execute(ctx, &sdkpb.ExecuteRequest{
ExecutionMetadata: workflowExecutionMetadata,
Expand Down
1 change: 1 addition & 0 deletions core/services/workflows/syncer/v2/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ func Test_workflowRegisteredHandler_confidentialRouting(t *testing.T) {
// confidential module routes and executes in this test.
limiters, err := v2.NewLimiters(lf, func(w *cresettings.Workflows) {
w.ConfidentialWorkflows.Enabled.DefaultValue = true
w.FeatureExecutionMetadataActivePeriod.DefaultValue = settings.TimeRange(time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC), time.Date(2100, 1, 1, 0, 0, 0, 0, time.UTC)).DefaultValue
})
require.NoError(t, err)
rl, err := ratelimiter.NewRateLimiter(rlConfig)
Expand Down
18 changes: 16 additions & 2 deletions core/services/workflows/v2/base_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,11 @@ func (e *baseEngine) Subscribe(ctx context.Context) ([]*sdkpb.TriggerSubscriptio
// No executionID exists unless startExecution is called.
// Hence, we initialize it as an empty string.
executionID := ""
// Subscribe has no execution timestamp, so the node's clock gates the metadata.
subscribeMetadata := e.executionMetadata(ctx, e.cfg.Clock.Now(), executionID)
result, err := e.cfg.Module.Execute(subCtx, &sdkpb.ExecuteRequest{
Request: &sdkpb.ExecuteRequest_Subscribe{},
ExecutionMetadata: e.getExecutionMetadata(executionID),
ExecutionMetadata: subscribeMetadata,
MaxResponseSize: uint64(moduleExecuteMaxResponseSizeBytes),
Config: e.cfg.WorkflowConfig,
}, NewDisallowedExecutionHelper(e.logger(), userLogChan, timeProvider))
Expand Down Expand Up @@ -784,7 +786,7 @@ func (e *baseEngine) startExecution(ctx context.Context, event triggers.Coordina

execHelper.initLimiters(e.cfg.LocalLimiters)
e.metrics.With(platform.KeyTriggerID, event.TriggerCapID).RecordTriggerPayloadBytes(ctx, int64(proto.Size(triggerEvent.Payload)))
executionMetadata := e.getExecutionMetadata(executionID)
executionMetadata := e.executionMetadata(ctx, executionTimestamp, executionID)
var result *sdkpb.ExecutionResult
result, execErr = e.cfg.Module.Execute(execCtx, &sdkpb.ExecuteRequest{
ExecutionMetadata: executionMetadata,
Expand Down Expand Up @@ -1212,6 +1214,18 @@ func (e *baseEngine) emitComputeUsage(ctx context.Context, lggr logger.Logger, t
)
}

// executionMetadata returns the metadata to attach to an ExecuteRequest, or nil while
// FeatureExecutionMetadataActivePeriod does not cover at. The metadata changes the request bytes,
// which confidential workflows hash across nodes, so at is the execution timestamp (DON time):
// every node then switches on the same execution. An execution without a timestamp (zero time,
// when ExecutionTimestampsEnabled is off) stays off unless the window reaches back to year 1.
func (e *baseEngine) executionMetadata(ctx context.Context, at time.Time, executionID string) *sdkpb.WorkflowExecutionMetadata {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename "at" -> "executionTimestamp"?

if err := e.cfg.LocalLimiters.ExecutionMetadata.Check(ctx, commonconfig.Timestamp(at.Unix())); err != nil {
return nil
}
return e.getExecutionMetadata(executionID)
}

func (e *baseEngine) getExecutionMetadata(executionID string) *sdkpb.WorkflowExecutionMetadata {
node := e.localNode.Load()
return &sdkpb.WorkflowExecutionMetadata{
Expand Down
10 changes: 10 additions & 0 deletions core/services/workflows/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ type EngineLimiters struct {
// ShadowTriggerMode is open while a coordinated trigger event's observed time is inside the
// FeatureShadowTriggerModeActivePeriod window, resolved per workflow, owner, org or global.
ShadowTriggerMode limits.RangeLimiter[commonconfig.Timestamp]
// ExecutionMetadata is open while an execution's timestamp is inside the
// FeatureExecutionMetadataActivePeriod window, resolved per workflow, owner, org or global.
// While closed, the engine sends no WorkflowExecutionMetadata in the ExecuteRequest.
ExecutionMetadata limits.RangeLimiter[commonconfig.Timestamp]
// CentralTriggerEventQueue is the node-wide capacity of the central trigger queue.
CentralTriggerEventQueue limits.BoundLimiter[int]
// CentralTriggerQueueDrainInterval is how often the central trigger queue is drained.
Expand Down Expand Up @@ -365,6 +369,10 @@ func (l *EngineLimiters) init(lf limits.Factory, cfgFn func(*cresettings.Workflo
if err != nil {
return err
}
l.ExecutionMetadata, err = limits.MakeRangeLimiter[commonconfig.Timestamp](lf, cfg.FeatureExecutionMetadataActivePeriod)
if err != nil {
return err
}
l.CentralTriggerEventQueue, err = limits.MakeUpperBoundLimiter(lf, cresettings.Default.CentralTriggerEventQueueLimit)
if err != nil {
return err
Expand Down Expand Up @@ -417,6 +425,7 @@ func (l *EngineLimiters) EvictWorkflow(workflowID string) error {
l.CentralizedWorkflowOwnerVerificationEnabled,
l.DONTimeRequestTimeout,
l.ShadowTriggerMode,
l.ExecutionMetadata,
}
var errs error
for _, e := range evictables {
Expand Down Expand Up @@ -464,6 +473,7 @@ func (l *EngineLimiters) Close() error {
l.CentralizedWorkflowOwnerVerificationEnabled,
l.DONTimeRequestTimeout,
l.ShadowTriggerMode,
l.ExecutionMetadata,
l.CentralTriggerEventQueue,
l.CentralTriggerQueueDrainInterval,
)
Expand Down
5 changes: 4 additions & 1 deletion core/services/workflows/v2/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,10 @@ func TestEngine_Execution(t *testing.T) {
subscribedToTriggersCh := make(chan []string, 1)
executionFinishedCh := make(chan string)

cfg := defaultTestConfig(t, nil)
cfg := defaultTestConfig(t, func(cfg *cresettings.Workflows) {
// The metadata assertions below require the (default-off) feature window.
cfg.FeatureExecutionMetadataActivePeriod.DefaultValue = settings.TimeRange(time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC), time.Date(2100, 1, 1, 0, 0, 0, 0, time.UTC)).DefaultValue
})
cfg.Module = module
cfg.CapRegistry = capreg
cfg.BillingClient = billingClient
Expand Down
58 changes: 58 additions & 0 deletions core/services/workflows/v2/execution_metadata_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package v2

import (
"context"
"testing"
"time"

"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"

"github.com/smartcontractkit/chainlink-common/pkg/capabilities"
"github.com/smartcontractkit/chainlink-common/pkg/contexts"
"github.com/smartcontractkit/chainlink-common/pkg/settings"
"github.com/smartcontractkit/chainlink-common/pkg/settings/cresettings"
"github.com/smartcontractkit/chainlink-common/pkg/settings/limits"
"github.com/smartcontractkit/chainlink-protos/cre/go/sdk"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)

// Synthetic identifiers use production encodings.
Expand Down Expand Up @@ -132,3 +139,54 @@ func metadataEngineFixture() *baseEngine {
engine.localNode.Store(&capabilities.Node{WorkflowDON: capabilities.DON{ID: 17, F: 3, ConfigVersion: 1}})
return engine
}

// The metadata is part of the ExecuteRequest bytes that confidential workflows hash across nodes,
// so it is gated by an activation window checked against the execution timestamp: it must stay off
// by default and switch on at the same execution for every node.
func TestEngine_ExecutionMetadataGate(t *testing.T) {
t.Parallel()

window := func(from, to time.Time) func(*cresettings.Workflows) {
return func(w *cresettings.Workflows) {
w.FeatureExecutionMetadataActivePeriod.DefaultValue = settings.TimeRange(from, to).DefaultValue
}
}
start := time.Date(2026, 12, 1, 0, 0, 0, 0, time.UTC)
end := time.Date(2026, 12, 2, 0, 0, 0, 0, time.UTC)

for _, tc := range []struct {
name string
cfgFn func(*cresettings.Workflows)
at time.Time
want bool
}{
{name: "default window is off", at: start},
{name: "inside the window", cfgFn: window(start, end), at: start.Add(time.Hour), want: true},
{name: "before the window", cfgFn: window(start, end), at: start.Add(-time.Second)},
{name: "after the window", cfgFn: window(start, end), at: end.Add(time.Second)},
{name: "no execution timestamp stays off", cfgFn: window(start, end), at: time.Time{}},
{name: "window reaching year 1 covers a zero timestamp", cfgFn: window(time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC), end), at: time.Time{}, want: true},
} {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

// Setup.
engine := metadataEngineFixture()
limiters, err := NewLimiters(limits.Factory{Logger: logger.TestLogger(t)}, tc.cfgFn)
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, limiters.Close()) })
engine.cfg.LocalLimiters = limiters
ctx := contexts.WithCRE(context.Background(), contexts.CRE{Workflow: metadataWorkflowIDFixture})

// Execute.
got := engine.executionMetadata(ctx, tc.at, metadataExecutionIDFixture)

// Verify.
if !tc.want {
require.Nil(t, got)
return
}
require.True(t, proto.Equal(engine.getExecutionMetadata(metadataExecutionIDFixture), got), "unexpected execution metadata: %v", got)
})
}
}
6 changes: 3 additions & 3 deletions deployment/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ require (
github.com/smartcontractkit/chainlink-ccip/chains/solana/deployment v0.0.0-20260916222901-720a003dab50
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260922043016-517a12a4220e
github.com/smartcontractkit/chainlink-ccip/deployment v0.0.0-20261001213322-a2d686f610ca
github.com/smartcontractkit/chainlink-common v0.11.2-0.20261118204812-c2cd552dc1f2
github.com/smartcontractkit/chainlink-common v0.11.2-0.20261119230624-78d15e1f1d4e
github.com/smartcontractkit/chainlink-common/keystore v1.3.1-0.20261111193935-c83f8e2996fb
github.com/smartcontractkit/chainlink-data-streams v1.1.3
github.com/smartcontractkit/chainlink-deployments-framework v0.126.0
github.com/smartcontractkit/chainlink-evm v0.3.4-0.20261118192309-cfc3cc2381a2
github.com/smartcontractkit/chainlink-evm/contracts/cre/gobindings v0.0.0-20260403151002-2c91155b5501
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20261005112317-b723176adfe8
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20261103151748-aa8c64acc53c
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20261118180951-353e61fe935a
github.com/smartcontractkit/chainlink-protos/job-distributor v0.20.1-0.20260701185448-696c075849ea
github.com/smartcontractkit/chainlink-protos/orchestrator v0.11.0
github.com/smartcontractkit/chainlink-solana v1.3.1-0.20261029182832-ae2ca5ac5292
Expand Down Expand Up @@ -430,7 +430,7 @@ require (
github.com/smartcontractkit/chainlink-canton/authentication v1.0.0 // indirect
github.com/smartcontractkit/chainlink-canton/contracts/v2 v2.1.0 // indirect
github.com/smartcontractkit/chainlink-ccv v0.16.0 // indirect
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20261106154152-9426766b30a9 // indirect
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20261119075727-f272852ab605 // indirect
github.com/smartcontractkit/chainlink-common/x/config v0.0.0-20260928140953-a9b0d3a04daa // indirect
github.com/smartcontractkit/chainlink-feeds v0.1.2-0.20250227211209-7cd000095135 // indirect
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20261009212658-df7dcfcb7a77 // indirect
Expand Down
Loading
Loading