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
3 changes: 3 additions & 0 deletions pkg/capabilities/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ type RequestMetadata struct {
WorkflowRegistryChainSelector string
WorkflowRegistryAddress string
EngineVersion string
// ExecutionTimestamp is the DonTime-derived execution timestamp.
// Propagated to capability DONs so they can evaluate feature flags atomically with the workflow DON.
ExecutionTimestamp time.Time
}

func (m *RequestMetadata) ContextWithCRE(ctx context.Context) context.Context {
Expand Down
120 changes: 66 additions & 54 deletions pkg/capabilities/pb/capabilities.pb.go

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

2 changes: 2 additions & 0 deletions pkg/capabilities/pb/capabilities.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "values/v1/values.proto";
import "metering/pb/meteringdetail.proto";
import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

service BaseCapability {
rpc Info (google.protobuf.Empty) returns (CapabilityInfoReply) {}
Expand Down Expand Up @@ -51,6 +52,7 @@ message RequestMetadata {
string workflow_registry_chain_selector = 12;
string workflow_registry_address = 13;
string engine_version = 14;
google.protobuf.Timestamp execution_timestamp = 15;
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.

Wait, does this new field also become part of the payload hash on server here:
https://github.com/smartcontractkit/chainlink/blob/41586b4eec7437b564ae77614e8d7333d47a3796/core/capabilities/remote/executable/server.go#L269-L271

If yes, then isn't there a risk that when dontime fails, and we fallback to local node time, then all nodes will use a different timestamp, thus getting a different hash above, causing F+1 failures?

Is that an acceptable situation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This field will be excluded in the hasher similarly to other existing fields with the same problem - core PR coming.

}

message CapabilityRequest {
Expand Down
20 changes: 20 additions & 0 deletions pkg/capabilities/pb/capabilities_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package pb
import (
"errors"
"fmt"
"time"

"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/smartcontractkit/chainlink-common/pkg/capabilities"
meter "github.com/smartcontractkit/chainlink-common/pkg/metering/pb"
Expand Down Expand Up @@ -71,6 +73,7 @@ func CapabilityRequestToProto(req capabilities.CapabilityRequest) *CapabilityReq
DecodedWorkflowName: req.Metadata.DecodedWorkflowName,
SpendLimits: spendLimitsToProto(req.Metadata.SpendLimits),
WorkflowTag: req.Metadata.WorkflowTag,
ExecutionTimestamp: timeToProto(req.Metadata.ExecutionTimestamp),
},
Inputs: values.ProtoMap(inputs),
Config: values.ProtoMap(config),
Expand Down Expand Up @@ -133,6 +136,7 @@ func CapabilityRequestFromProto(pr *CapabilityRequest) (capabilities.CapabilityR
DecodedWorkflowName: md.DecodedWorkflowName,
SpendLimits: spendLimitsFromProto(md.SpendLimits),
WorkflowTag: md.WorkflowTag,
ExecutionTimestamp: timeFromProto(md.ExecutionTimestamp),
},
Config: config,
Inputs: inputs,
Expand Down Expand Up @@ -332,13 +336,28 @@ func TriggerRegistrationRequestToProto(req capabilities.TriggerRegistrationReque
WorkflowRegistryChainSelector: md.WorkflowRegistryChainSelector,
WorkflowRegistryAddress: md.WorkflowRegistryAddress,
EngineVersion: md.EngineVersion,
ExecutionTimestamp: timeToProto(md.ExecutionTimestamp),
},
Config: values.ProtoMap(config),
Payload: req.Payload,
Method: req.Method,
}
}

func timeToProto(t time.Time) *timestamppb.Timestamp {
if t.IsZero() {
return nil
}
return timestamppb.New(t)
}

func timeFromProto(ts *timestamppb.Timestamp) time.Time {
if ts == nil {
return time.Time{}
}
return ts.AsTime()
}

func spendLimitsToProto(limits []capabilities.SpendLimit) []*SpendLimit {
result := make([]*SpendLimit, len(limits))
for i, limit := range limits {
Expand Down Expand Up @@ -382,6 +401,7 @@ func TriggerRegistrationRequestFromProto(req *TriggerRegistrationRequest) (capab
WorkflowRegistryChainSelector: md.WorkflowRegistryChainSelector,
WorkflowRegistryAddress: md.WorkflowRegistryAddress,
EngineVersion: md.EngineVersion,
ExecutionTimestamp: timeFromProto(md.ExecutionTimestamp),
},
Config: config,
Payload: req.Payload,
Expand Down
7 changes: 5 additions & 2 deletions pkg/capabilities/pb/capabilities_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pb_test

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -98,7 +99,8 @@ func TestMarshalUnmarshalRequest(t *testing.T) {
{SpendType: "COMPUTE", Limit: "1000"},
{SpendType: "GAS_12345", Limit: "1000000"},
},
WorkflowTag: "test-workflow-tag",
WorkflowTag: "test-workflow-tag",
ExecutionTimestamp: time.Date(2025, 6, 15, 12, 0, 0, 0, time.UTC),
},
Config: &values.Map{Underlying: map[string]values.Value{
testConfigKey: &values.String{Underlying: testConfigValue},
Expand Down Expand Up @@ -193,7 +195,8 @@ func TestMarshalUnmarshalTriggerRegistrationRequest(t *testing.T) {
SpendLimits: []capabilities.SpendLimit{
{SpendType: "GAS", Limit: "5000"},
},
WorkflowTag: "workflow-tag",
WorkflowTag: "workflow-tag",
ExecutionTimestamp: time.Date(2025, 6, 15, 12, 0, 0, 0, time.UTC),
},
Config: &values.Map{Underlying: map[string]values.Value{
testConfigKey: &values.String{Underlying: testConfigValue},
Expand Down
Loading