Skip to content

Commit bc6d77b

Browse files
authored
Merge branch 'main' into limits-multi-resource
2 parents 18e35b8 + 6d6d46a commit bc6d77b

File tree

13 files changed

+86
-48
lines changed

13 files changed

+86
-48
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ require (
3737
github.com/shopspring/decimal v1.4.0
3838
github.com/smartcontractkit/chain-selectors v1.0.62
3939
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.1
40-
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250707214334-e164c13b2f32
41-
github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk/v2/pb v0.0.0-20250708135749-8736758474ec
40+
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250710185807-2e08944e72d2
41+
github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk/v2/pb v0.0.0-20250715132921-fbb00f834ac8
4242
github.com/smartcontractkit/chainlink-protos/billing/go v0.0.0-20250701181457-37bd0d618b58
4343
github.com/smartcontractkit/freeport v0.1.1
4444
github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@ github.com/smartcontractkit/chain-selectors v1.0.62 h1:KWLEyKQXHxGGHIlUfLrzjYldl
304304
github.com/smartcontractkit/chain-selectors v1.0.62/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
305305
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.1 h1:ca2z5OXgnbBPQRxpwXwBLJsUA1+cAp5ncfW4Ssvd6eY=
306306
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.1/go.mod h1:NZv/qKYGFRnkjOYBouajnDfFoZ+WDa6H2KNmSf1dnKc=
307-
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250707214334-e164c13b2f32 h1:+yOhdrImF2R4qnMZQaGWyJ2qd1HhvSHtJjeKJSWplbI=
308-
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250707214334-e164c13b2f32/go.mod h1:U1UAbPhy6D7Qz0wHKGPoQO+dpR0hsYjgUz8xwRrmKwI=
309-
github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk/v2/pb v0.0.0-20250708135749-8736758474ec h1:6XpqaGA2a4ik2zte0bEKeFIgPyHlTQNrVdaIbJWqlks=
310-
github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk/v2/pb v0.0.0-20250708135749-8736758474ec/go.mod h1:0B4c6GEcnm67Q/E8vwpxTpdjL8elQkh8pVzxGhXkVsM=
307+
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250710185807-2e08944e72d2 h1:pMwrNp2BFITYYDP3sAiGtecDP3frYDNPXpa4/vleghU=
308+
github.com/smartcontractkit/chainlink-common/pkg/values v0.0.0-20250710185807-2e08944e72d2/go.mod h1:U1UAbPhy6D7Qz0wHKGPoQO+dpR0hsYjgUz8xwRrmKwI=
309+
github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk/v2/pb v0.0.0-20250715132921-fbb00f834ac8 h1:/AUP/7d2ILZyYeb/Zs70WllVzjuyzUjQGDJCaF50hww=
310+
github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk/v2/pb v0.0.0-20250715132921-fbb00f834ac8/go.mod h1:ay4g8WruGFr512i+0IWDPmc1ZGpsw2ivfqfk0ED9vqY=
311311
github.com/smartcontractkit/chainlink-protos/billing/go v0.0.0-20250701181457-37bd0d618b58 h1:yXbKWplUgoC+PoOoPXseKunxElXrnCKnKBGxkmUVR2I=
312312
github.com/smartcontractkit/chainlink-protos/billing/go v0.0.0-20250701181457-37bd0d618b58/go.mod h1:HHGeDUpAsPa0pmOx7wrByCitjQ0mbUxf0R9v+g67uCA=
313313
github.com/smartcontractkit/chainlink-protos/workflows/go v0.0.0-20250430163438-97d324ef9061 h1:5BKk6j2QWmb5TFoWYVLuL8U2XUIzTUUo5HBkCHTX2kM=

pkg/billing/workflow_client.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ type workflowConfig struct {
5353
type WorkflowClientOpt func(*workflowConfig)
5454

5555
func defaultWorkflowConfig() workflowConfig {
56-
loggerInst, _ := logger.New()
5756
// By default, no JWT manager is set and we fallback to insecure creds.
5857
return workflowConfig{
5958
transportCredentials: insecure.NewCredentials(),
60-
log: loggerInst,
6159
tlsCert: "",
6260
// Default to "localhost" if not overridden.
6361
serverName: "localhost",
@@ -71,12 +69,6 @@ func WithWorkflowTransportCredentials(creds credentials.TransportCredentials) Wo
7169
}
7270
}
7371

74-
func WithWorkflowLogger(l logger.Logger) WorkflowClientOpt {
75-
return func(cfg *workflowConfig) {
76-
cfg.log = l
77-
}
78-
}
79-
8072
// WithJWTGenerator sets the JWT generator for authentication.
8173
func WithJWTGenerator(jwtGenerator auth.JWTGenerator) WorkflowClientOpt {
8274
return func(cfg *workflowConfig) {
@@ -98,15 +90,15 @@ func WithServerName(name string) WorkflowClientOpt {
9890
}
9991

10092
// NewWorkflowClient creates a new workflow client with JWT signing enabled.
101-
func NewWorkflowClient(address string, opts ...WorkflowClientOpt) (WorkflowClient, error) {
93+
func NewWorkflowClient(lggr logger.Logger, address string, opts ...WorkflowClientOpt) (WorkflowClient, error) {
10294
cfg := defaultWorkflowConfig()
10395
for _, opt := range opts {
10496
opt(&cfg)
10597
}
10698

10799
wc := &workflowClient{
108100
address: address,
109-
logger: cfg.log,
101+
logger: logger.Named(lggr, "WorkflowClient"),
110102
tlsCert: cfg.tlsCert,
111103
creds: cfg.transportCredentials,
112104
serverName: cfg.serverName,

pkg/billing/workflow_client_test.go

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"google.golang.org/grpc/metadata"
1717
"google.golang.org/protobuf/types/known/emptypb"
1818

19-
"github.com/smartcontractkit/chainlink-common/pkg/nodeauth/jwt/mocks"
2019
"github.com/smartcontractkit/chainlink-common/pkg/logger"
20+
"github.com/smartcontractkit/chainlink-common/pkg/nodeauth/jwt/mocks"
2121
pb "github.com/smartcontractkit/chainlink-protos/billing/go"
2222
)
2323

@@ -30,7 +30,6 @@ func (d MockRequest) String() string {
3030
return d.Field
3131
}
3232

33-
3433
// ---------- Test Server Implementation ----------
3534

3635
// testWorkflowServer implements pb.WorkflowServiceServer for testing.
@@ -101,11 +100,10 @@ func TestIntegration_GRPCWithCerts(t *testing.T) {
101100
mockJWT.EXPECT().CreateJWTForRequest(&pb.GetRateCardRequest{WorkflowOwner: "test-account", WorkflowRegistryAddress: "0x..", ChainSelector: 1}).Return("test.jwt.token", nil).Once()
102101

103102
lggr := logger.Test(t)
104-
wc, err := NewWorkflowClient(addr,
103+
wc, err := NewWorkflowClient(lggr, addr,
105104
WithWorkflowTransportCredentials(clientCreds), // Provided but may be overridden by TLS cert.
106105
WithWorkflowTLSCert(string(certBytes)),
107106
WithJWTGenerator(mockJWT),
108-
WithWorkflowLogger(lggr),
109107
WithServerName("localhost"),
110108
)
111109
require.NoError(t, err)
@@ -153,9 +151,8 @@ func TestIntegration_GRPC_Insecure(t *testing.T) {
153151
addr := lis.Addr().String()
154152
lggr := logger.Test(t)
155153

156-
wc, err := NewWorkflowClient(addr,
154+
wc, err := NewWorkflowClient(lggr, addr,
157155
WithWorkflowTransportCredentials(insecure.NewCredentials()),
158-
WithWorkflowLogger(lggr),
159156
WithServerName("localhost"),
160157
)
161158

@@ -170,9 +167,8 @@ func TestIntegration_GRPC_Insecure(t *testing.T) {
170167
// Test that NewWorkflowClient fails when given an invalid address.
171168
func TestNewWorkflowClient_InvalidAddress(t *testing.T) {
172169
lggr := logger.Test(t)
173-
wc, err := NewWorkflowClient("invalid-address",
170+
wc, err := NewWorkflowClient(lggr, "invalid-address",
174171
WithWorkflowTransportCredentials(insecure.NewCredentials()),
175-
WithWorkflowLogger(lggr),
176172
WithServerName("localhost"),
177173
)
178174

@@ -196,9 +192,8 @@ func TestWorkflowClient_CloseTwice(t *testing.T) {
196192

197193
addr := lis.Addr().String()
198194
lggr := logger.Test(t)
199-
wc, err := NewWorkflowClient(addr,
195+
wc, err := NewWorkflowClient(lggr, addr,
200196
WithWorkflowTransportCredentials(insecure.NewCredentials()),
201-
WithWorkflowLogger(lggr),
202197
WithServerName("localhost"),
203198
)
204199
require.NoError(t, err)
@@ -215,9 +210,8 @@ func TestWorkflowClient_CloseTwice(t *testing.T) {
215210
func TestWorkflowClient_DialUnreachable(t *testing.T) {
216211
lggr := logger.Test(t)
217212
unreachableAddr := "192.0.2.1:12345" // Reserved for documentation.
218-
wc, err := NewWorkflowClient(unreachableAddr,
213+
wc, err := NewWorkflowClient(lggr, unreachableAddr,
219214
WithWorkflowTransportCredentials(insecure.NewCredentials()),
220-
WithWorkflowLogger(lggr),
221215
WithServerName("localhost"),
222216
)
223217

@@ -240,7 +234,7 @@ func TestWorkflowClient_AddJWTAuthToContext(t *testing.T) {
240234
mockJWT.EXPECT().CreateJWTForRequest(req).Return(expectedToken, nil).Once()
241235

242236
wc := &workflowClient{
243-
logger: logger.Test(t),
237+
logger: logger.Test(t),
244238
jwtGenerator: mockJWT,
245239
}
246240

@@ -263,7 +257,7 @@ func TestWorkflowClient_NoSigningKey(t *testing.T) {
263257
ctx := context.Background()
264258
req := MockRequest{Field: "test"}
265259
wc := &workflowClient{
266-
logger: logger.Test(t),
260+
logger: logger.Test(t),
267261
jwtGenerator: nil,
268262
}
269263
newCtx, err := wc.addJWTAuth(ctx, req)
@@ -281,7 +275,7 @@ func TestWorkflowClient_VerifySignature_Invalid(t *testing.T) {
281275
mockJWT.EXPECT().CreateJWTForRequest(req).Return("", fmt.Errorf("mock JWT creation error")).Once()
282276

283277
wc := &workflowClient{
284-
logger: logger.Test(t),
278+
logger: logger.Test(t),
285279
jwtGenerator: mockJWT,
286280
}
287281

@@ -300,7 +294,7 @@ func TestWorkflowClient_RepeatedSign(t *testing.T) {
300294
mockJWT.EXPECT().CreateJWTForRequest(req).Return(expectedToken, nil).Times(2)
301295

302296
wc := &workflowClient{
303-
logger: logger.Test(t),
297+
logger: logger.Test(t),
304298
jwtGenerator: mockJWT,
305299
}
306300

@@ -319,4 +313,4 @@ func TestWorkflowClient_RepeatedSign(t *testing.T) {
319313
require.True(t, ok)
320314

321315
assert.Equal(t, md1["authorization"], md2["authorization"], "Expected same authorization header for same request")
322-
}
316+
}

pkg/capabilities/v2/chain-capabilities/evm/client.pb.go

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

pkg/capabilities/v2/chain-capabilities/evm/server/client_server_gen.go

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

pkg/capabilities/v2/protoc/pkg/template_generator.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ func (t *TemplateGenerator) runTemplate(name, tmplText string, args any, partial
203203

204204
return "emptypb.Empty", nil
205205
},
206+
"CleanComments": func(line string) string {
207+
line = strings.TrimSpace(line)
208+
switch {
209+
case strings.HasPrefix(line, "//"):
210+
return strings.TrimSpace(strings.TrimPrefix(line, "//"))
211+
case strings.HasPrefix(line, "/*"):
212+
line = strings.TrimPrefix(line, "/*")
213+
line = strings.TrimSuffix(line, "*/")
214+
return strings.TrimSpace(line)
215+
default:
216+
return line
217+
}
218+
},
206219
}).Funcs(t.ExtraFns)
207220

208221
// Register partials

pkg/capabilities/v2/protoc/pkg/templates/server.go.tmpl

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,26 @@ import (
2626
// Avoid unused imports if there is configuration type
2727
var _ = emptypb.Empty{}
2828

29-
{{- range .Services}}
29+
{{ range .Services}}
3030
{{ $hasTriggers := false }}
3131
{{ $hasActions := false }}
32-
{{ $service := . }}
33-
type {{.GoName}}Capability interface {
32+
{{ $service := . -}}
33+
{{ if .Comments.Leading.String }}//{{.GoName}}Capability {{CleanComments .Comments.Leading.String}} {{ end }}
34+
type {{.GoName}}Capability interface { {{- if .Comments.Trailing.String }}//{{.GoName}}Capability {{CleanComments .Comments.Trailing.String}} {{ end }}
3435
{{- range .Methods}}
3536
{{- if isTrigger . }}
3637
{{ $hasTriggers = true }}
37-
Register{{.GoName}}(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) (<- chan capabilities.TriggerAndId[*{{ImportAlias .Output.GoIdent.GoImportPath}}.{{.Output.GoIdent.GoName}}], error)
38-
Unregister{{.GoName}}(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) error
38+
{{- if .Comments.Leading.String }}//Register{{.GoName}} registration for {{CleanComments .Comments.Leading.String}} {{ end }}
39+
Register{{.GoName}}(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) (<- chan capabilities.TriggerAndId[*{{ImportAlias .Output.GoIdent.GoImportPath}}.{{.Output.GoIdent.GoName}}], error) {{- if .Comments.Trailing.String }}// {{CleanComments .Comments.Trailing.String}} {{ end }}
40+
{{ if .Comments.Leading.String }}//Unregister{{.GoName}} unregistration for {{CleanComments .Comments.Leading.String}} {{ end }}
41+
Unregister{{.GoName}}(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) error {{- if .Comments.Trailing.String }}// {{CleanComments .Comments.Trailing.String}} {{ end }}
3942
{{- else }}
4043
{{ $hasActions = true }}
41-
{{.GoName}}(ctx context.Context, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}} {{if ne "emptypb.Empty" (ConfigType $service)}}, {{(ConfigType $service)}}{{ end }}) (*{{ImportAlias .Output.GoIdent.GoImportPath}}.{{.Output.GoIdent.GoName}}, error)
42-
{{- end }}
44+
{{- if .Comments.Leading.String }}//{{.GoName}} {{CleanComments .Comments.Leading.String}} {{ end }}
45+
{{.GoName}}(ctx context.Context, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}} {{if ne "emptypb.Empty" (ConfigType $service)}}, {{(ConfigType $service)}}{{ end }}) (*{{ImportAlias .Output.GoIdent.GoImportPath}}.{{.Output.GoIdent.GoName}}, error) {{- if .Comments.Trailing.String }}// {{CleanComments .Comments.Trailing.String}} {{ end }}
46+
{{ end }}
4347
{{- end }}
4448

45-
4649
Start(ctx context.Context) error
4750
Close() error
4851
HealthReport() map[string]error
@@ -59,8 +62,8 @@ func New{{.GoName}}Server(capability {{.GoName}}Capability) *{{.GoName}}Server {
5962
stopCh: stopCh,
6063
}
6164
}
62-
63-
type {{.GoName}}Server struct {
65+
{{ if .Comments.Leading.String }}//{{.GoName}}Server {{CleanComments .Comments.Leading.String}} {{ end }}
66+
type {{.GoName}}Server struct { {{- if .Comments.Trailing.String }}// {{CleanComments .Comments.Trailing.String}} {{ end }}
6467
{{.GoName|LowerFirst}}Capability
6568
capabilityRegistry core.CapabilitiesRegistry
6669
stopCh chan struct{}

pkg/capabilities/v2/protoc/pkg/test_capabilities/actionandtrigger/server/action_and_trigger_server_gen.go

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

pkg/capabilities/v2/protoc/pkg/test_capabilities/basicaction/server/basic_action_server_gen.go

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

0 commit comments

Comments
 (0)