Skip to content

Commit 76fc825

Browse files
committed
Flags propagation
1 parent a0ddf86 commit 76fc825

17 files changed

Lines changed: 76 additions & 26 deletions

File tree

core/capabilities/remote/executable/hasher.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"strings"
8+
"time"
89

910
"google.golang.org/protobuf/types/known/anypb"
1011

@@ -64,9 +65,10 @@ func (r *simpleHasher) Hash(msg *types.MessageBody) ([32]byte, error) {
6465
return [32]byte{}, fmt.Errorf("failed to unmarshal capability request: %w", err)
6566
}
6667

67-
// Exclude SpendLimits from RequestMetadata to ensure identical requests
68-
// with different SpendLimits produce the same hash
68+
// Exclude per-node-divergent metadata fields to ensure identical requests
69+
// with different values produce the same hash
6970
req.Metadata.SpendLimits = nil
71+
req.Metadata.ExecutionTimestamp = time.Time{}
7072

7173
reqBytes, err := pb.MarshalCapabilityRequest(req)
7274
if err != nil {
@@ -92,9 +94,10 @@ func (r *writeReportExcludeSignaturesHasher) Hash(msg *types.MessageBody) ([32]b
9294
return [32]byte{}, errors.New("capability request payload is nil")
9395
}
9496

95-
// Exclude SpendLimits from RequestMetadata to ensure identical requests
96-
// with different SpendLimits produce the same hash
97+
// Exclude per-node-divergent metadata fields to ensure identical requests
98+
// with different values produce the same hash
9799
req.Metadata.SpendLimits = nil
100+
req.Metadata.ExecutionTimestamp = time.Time{}
98101
family, familyErr := getWriteReportFamily(msg)
99102
if familyErr != nil {
100103
return [32]byte{}, familyErr

core/capabilities/remote/executable/hasher_test.go

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

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

67
"github.com/stretchr/testify/require"
78
"google.golang.org/protobuf/types/known/anypb"
@@ -106,6 +107,31 @@ func TestSimpleHasher_ExcludesSpendLimits(t *testing.T) {
106107
require.NotEqual(t, hash1, hash3) // different data should produce different hash
107108
}
108109

110+
func TestSimpleHasher_ExcludesExecutionTimestamp(t *testing.T) {
111+
ts1 := time.Date(2025, 6, 15, 12, 0, 0, 0, time.UTC)
112+
ts2 := time.Date(2025, 7, 20, 8, 30, 0, 0, time.UTC)
113+
req1 := getRequestWithMetadata(t, []byte("testdata"), capabilities.RequestMetadata{
114+
WorkflowID: "wf1", WorkflowExecutionID: "exec1", ExecutionTimestamp: ts1,
115+
})
116+
req2 := getRequestWithMetadata(t, []byte("testdata"), capabilities.RequestMetadata{
117+
WorkflowID: "wf1", WorkflowExecutionID: "exec1", ExecutionTimestamp: ts2,
118+
})
119+
req3 := getRequestWithMetadata(t, []byte("otherdata"), capabilities.RequestMetadata{
120+
WorkflowID: "wf1", WorkflowExecutionID: "exec1", ExecutionTimestamp: ts1,
121+
})
122+
123+
hasher := NewSimpleHasher()
124+
hash1, err := hasher.Hash(req1)
125+
require.NoError(t, err)
126+
hash2, err := hasher.Hash(req2)
127+
require.NoError(t, err)
128+
hash3, err := hasher.Hash(req3)
129+
require.NoError(t, err)
130+
131+
require.Equal(t, hash1, hash2) // same data, different ExecutionTimestamp should produce same hash
132+
require.NotEqual(t, hash1, hash3) // different data should produce different hash
133+
}
134+
109135
func TestWriteReportExcludeSignaturesHasher_ExcludesSpendLimits(t *testing.T) {
110136
// Create two requests with identical payloads but different SpendLimits
111137
req1 := getWriteReportRequestWithSpendLimits(t, []byte("testdata"), [][]byte{[]byte("sig1"), []byte("sig2")}, []capabilities.SpendLimit{
@@ -161,6 +187,27 @@ func getRequest(t *testing.T, data []byte, sigs [][]byte) *types.MessageBody {
161187
}
162188
}
163189

190+
func getRequestWithMetadata(t *testing.T, data []byte, md capabilities.RequestMetadata) *types.MessageBody {
191+
report := &sdk.ReportResponse{
192+
RawReport: data,
193+
Sigs: []*sdk.AttributedSignature{},
194+
}
195+
wrReq := &evmcappb.WriteReportRequest{
196+
Report: report,
197+
}
198+
wrAny, err := anypb.New(wrReq)
199+
require.NoError(t, err)
200+
capReq := capabilities.CapabilityRequest{
201+
Payload: wrAny,
202+
Metadata: md,
203+
}
204+
capReqBytes, err := pb.MarshalCapabilityRequest(capReq)
205+
require.NoError(t, err)
206+
return &types.MessageBody{
207+
Payload: capReqBytes,
208+
}
209+
}
210+
164211
func getRequestWithSpendLimits(t *testing.T, data []byte, spendLimits []capabilities.SpendLimit) *types.MessageBody {
165212
report := &sdk.ReportResponse{
166213
RawReport: data,

core/scripts/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
github.com/smartcontractkit/chain-selectors v1.0.97
4646
github.com/smartcontractkit/chainlink-automation v0.8.1
4747
github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260317185256-d5f7db87ae70
48-
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260326163134-c8e0d77df421
48+
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260327152052-032e58514a84
4949
github.com/smartcontractkit/chainlink-common/keystore v1.0.2
5050
github.com/smartcontractkit/chainlink-data-streams v0.1.13
5151
github.com/smartcontractkit/chainlink-deployments-framework v0.86.3

core/scripts/go.sum

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

core/services/workflows/v2/capability_executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (c *ExecutionHelper) callCapability(ctx context.Context, request *sdkpb.Cap
187187
DecodedWorkflowName: c.cfg.WorkflowName.String(),
188188
SpendLimits: spendLimits,
189189
WorkflowTag: c.cfg.WorkflowTag,
190-
// TODO(CRE-2087): Propagate execution timestamp to capability calls (including remote)
190+
ExecutionTimestamp: c.ExecutionTimestamp,
191191
},
192192
Config: values.EmptyMap(),
193193
}

deployment/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ require (
4444
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260224214816-cb23ec38649f
4545
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260310183131-8d0f0e383288
4646
github.com/smartcontractkit/chainlink-ccip/deployment v0.0.0-20260317175207-e9ff89561326
47-
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260326163134-c8e0d77df421
47+
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260327152052-032e58514a84
4848
github.com/smartcontractkit/chainlink-common/keystore v1.0.2
4949
github.com/smartcontractkit/chainlink-deployments-framework v0.86.3
5050
github.com/smartcontractkit/chainlink-evm v0.3.4-0.20260326181417-f2272e4b4aa6

deployment/go.sum

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

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ require (
8585
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260224214816-cb23ec38649f
8686
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20250912190424-fd2e35d7deb5
8787
github.com/smartcontractkit/chainlink-ccv v0.0.0-20260324000441-d4cfddc9f7d2
88-
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260326163134-c8e0d77df421
88+
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260327152052-032e58514a84
8989
github.com/smartcontractkit/chainlink-common/keystore v1.0.2
9090
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.10
9191
github.com/smartcontractkit/chainlink-data-streams v0.1.13

go.sum

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

integration-tests/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ require (
3838
github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260317185256-d5f7db87ae70
3939
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260310183131-8d0f0e383288
4040
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260310183131-8d0f0e383288
41-
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260326163134-c8e0d77df421
41+
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260327152052-032e58514a84
4242
github.com/smartcontractkit/chainlink-common/keystore v1.0.2
4343
github.com/smartcontractkit/chainlink-deployments-framework v0.86.3
4444
github.com/smartcontractkit/chainlink-evm v0.3.4-0.20260326181417-f2272e4b4aa6

0 commit comments

Comments
 (0)