Skip to content

Commit 1008fcc

Browse files
committed
Merge remote-tracking branch 'origin/main' into tejaswi/tee-attestation
2 parents db8e348 + 16c179a commit 1008fcc

9 files changed

Lines changed: 107 additions & 67 deletions

File tree

pkg/capabilities/capabilities.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ type RequestMetadata struct {
118118
WorkflowRegistryChainSelector string
119119
WorkflowRegistryAddress string
120120
EngineVersion string
121+
// ExecutionTimestamp is the DonTime-derived execution timestamp.
122+
// Propagated to capability DONs so they can evaluate feature flags atomically with the workflow DON.
123+
ExecutionTimestamp time.Time
121124
}
122125

123126
func (m *RequestMetadata) ContextWithCRE(ctx context.Context) context.Context {

pkg/capabilities/pb/capabilities.pb.go

Lines changed: 66 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/capabilities/pb/capabilities.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "values/v1/values.proto";
88
import "metering/pb/meteringdetail.proto";
99
import "google/protobuf/any.proto";
1010
import "google/protobuf/empty.proto";
11+
import "google/protobuf/timestamp.proto";
1112

1213
service BaseCapability {
1314
rpc Info (google.protobuf.Empty) returns (CapabilityInfoReply) {}
@@ -51,6 +52,7 @@ message RequestMetadata {
5152
string workflow_registry_chain_selector = 12;
5253
string workflow_registry_address = 13;
5354
string engine_version = 14;
55+
google.protobuf.Timestamp execution_timestamp = 15;
5456
}
5557

5658
message CapabilityRequest {

pkg/capabilities/pb/capabilities_helpers.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package pb
33
import (
44
"errors"
55
"fmt"
6+
"time"
67

78
"google.golang.org/protobuf/proto"
9+
"google.golang.org/protobuf/types/known/timestamppb"
810

911
"github.com/smartcontractkit/chainlink-common/pkg/capabilities"
1012
meter "github.com/smartcontractkit/chainlink-common/pkg/metering/pb"
@@ -71,6 +73,7 @@ func CapabilityRequestToProto(req capabilities.CapabilityRequest) *CapabilityReq
7173
DecodedWorkflowName: req.Metadata.DecodedWorkflowName,
7274
SpendLimits: spendLimitsToProto(req.Metadata.SpendLimits),
7375
WorkflowTag: req.Metadata.WorkflowTag,
76+
ExecutionTimestamp: timeToProto(req.Metadata.ExecutionTimestamp),
7477
},
7578
Inputs: values.ProtoMap(inputs),
7679
Config: values.ProtoMap(config),
@@ -133,6 +136,7 @@ func CapabilityRequestFromProto(pr *CapabilityRequest) (capabilities.CapabilityR
133136
DecodedWorkflowName: md.DecodedWorkflowName,
134137
SpendLimits: spendLimitsFromProto(md.SpendLimits),
135138
WorkflowTag: md.WorkflowTag,
139+
ExecutionTimestamp: timeFromProto(md.ExecutionTimestamp),
136140
},
137141
Config: config,
138142
Inputs: inputs,
@@ -332,13 +336,28 @@ func TriggerRegistrationRequestToProto(req capabilities.TriggerRegistrationReque
332336
WorkflowRegistryChainSelector: md.WorkflowRegistryChainSelector,
333337
WorkflowRegistryAddress: md.WorkflowRegistryAddress,
334338
EngineVersion: md.EngineVersion,
339+
ExecutionTimestamp: timeToProto(md.ExecutionTimestamp),
335340
},
336341
Config: values.ProtoMap(config),
337342
Payload: req.Payload,
338343
Method: req.Method,
339344
}
340345
}
341346

347+
func timeToProto(t time.Time) *timestamppb.Timestamp {
348+
if t.IsZero() {
349+
return nil
350+
}
351+
return timestamppb.New(t)
352+
}
353+
354+
func timeFromProto(ts *timestamppb.Timestamp) time.Time {
355+
if ts == nil {
356+
return time.Time{}
357+
}
358+
return ts.AsTime()
359+
}
360+
342361
func spendLimitsToProto(limits []capabilities.SpendLimit) []*SpendLimit {
343362
result := make([]*SpendLimit, len(limits))
344363
for i, limit := range limits {
@@ -382,6 +401,7 @@ func TriggerRegistrationRequestFromProto(req *TriggerRegistrationRequest) (capab
382401
WorkflowRegistryChainSelector: md.WorkflowRegistryChainSelector,
383402
WorkflowRegistryAddress: md.WorkflowRegistryAddress,
384403
EngineVersion: md.EngineVersion,
404+
ExecutionTimestamp: timeFromProto(md.ExecutionTimestamp),
385405
},
386406
Config: config,
387407
Payload: req.Payload,

pkg/capabilities/pb/capabilities_helpers_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package pb_test
22

33
import (
44
"testing"
5+
"time"
56

67
"github.com/stretchr/testify/assert"
78
"github.com/stretchr/testify/require"
@@ -98,7 +99,8 @@ func TestMarshalUnmarshalRequest(t *testing.T) {
9899
{SpendType: "COMPUTE", Limit: "1000"},
99100
{SpendType: "GAS_12345", Limit: "1000000"},
100101
},
101-
WorkflowTag: "test-workflow-tag",
102+
WorkflowTag: "test-workflow-tag",
103+
ExecutionTimestamp: time.Date(2025, 6, 15, 12, 0, 0, 0, time.UTC),
102104
},
103105
Config: &values.Map{Underlying: map[string]values.Value{
104106
testConfigKey: &values.String{Underlying: testConfigValue},
@@ -193,7 +195,8 @@ func TestMarshalUnmarshalTriggerRegistrationRequest(t *testing.T) {
193195
SpendLimits: []capabilities.SpendLimit{
194196
{SpendType: "GAS", Limit: "5000"},
195197
},
196-
WorkflowTag: "workflow-tag",
198+
WorkflowTag: "workflow-tag",
199+
ExecutionTimestamp: time.Date(2025, 6, 15, 12, 0, 0, 0, time.UTC),
197200
},
198201
Config: &values.Map{Underlying: map[string]values.Value{
199202
testConfigKey: &values.String{Underlying: testConfigValue},

0 commit comments

Comments
 (0)