Skip to content

Commit 6cf0b7f

Browse files
authored
Merge branch 'main' into ogt/extra-data-codec-registry-interface-v3
2 parents 3d1af8f + 2b8d634 commit 6cf0b7f

File tree

15 files changed

+244
-27
lines changed

15 files changed

+244
-27
lines changed

pkg/capabilities/capabilities.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"google.golang.org/protobuf/proto"
1212
"google.golang.org/protobuf/types/known/anypb"
1313

14+
"github.com/smartcontractkit/chainlink-common/pkg/contexts"
1415
"github.com/smartcontractkit/chainlink-protos/cre/go/values"
1516
)
1617

@@ -108,13 +109,27 @@ type RequestMetadata struct {
108109
WorkflowTag string
109110
}
110111

112+
func (m *RequestMetadata) ContextWithCRE(ctx context.Context) context.Context {
113+
return contexts.WithCRE(ctx, contexts.CRE{
114+
Owner: m.WorkflowOwner,
115+
Workflow: m.WorkflowID,
116+
})
117+
}
118+
111119
type RegistrationMetadata struct {
112120
WorkflowID string
113121
WorkflowOwner string
114122
// The step reference ID of the workflow
115123
ReferenceID string
116124
}
117125

126+
func (m *RegistrationMetadata) ContextWithCRE(ctx context.Context) context.Context {
127+
return contexts.WithCRE(ctx, contexts.CRE{
128+
Owner: m.WorkflowOwner,
129+
Workflow: m.WorkflowID,
130+
})
131+
}
132+
118133
// CapabilityRequest is a struct for the Execute request of a capability.
119134
type CapabilityRequest struct {
120135
Metadata RequestMetadata
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package types
2+
3+
//go:generate protoc --go_out=. --go_opt=paths=source_relative -I. ocr3_chain_capabilities_config_types.proto

pkg/capabilities/v2/chain-capabilities/consensus/ocr3/types/ocr3_chain_capabilities_config_types.pb.go

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
syntax = "proto3";
2+
3+
option go_package = "capabilities/v2/chain-capabilities/consensus/ocr3/types";
4+
5+
package chain_capabilities_ocr3_config_types;
6+
7+
message ReportingPluginConfig {
8+
// These fields are shadowing the `ReportingPluginLimits` fields.
9+
// See: https://github.com/smartcontractkit/libocr/blob/master/offchainreporting2plus/ocr3types/plugin.go#L296
10+
uint32 maxQueryLengthBytes = 1;
11+
uint32 maxObservationLengthBytes = 2;
12+
uint32 maxOutcomeLengthBytes = 3;
13+
uint32 maxReportLengthBytes = 4;
14+
uint32 maxReportCount = 5;
15+
16+
uint32 maxBatchSize = 6;
17+
}

pkg/chipingress/auth.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import (
1010
var _ credentials.PerRPCCredentials = basicAuthCredentials{}
1111
var _ credentials.PerRPCCredentials = tokenAuthCredentials{}
1212

13+
type HeaderProvider interface {
14+
Headers(ctx context.Context) (map[string]string, error)
15+
}
16+
1317
// Basic-Auth authentication for Chip Ingress
1418
type basicAuthCredentials struct {
1519
authHeader map[string]string
@@ -42,11 +46,11 @@ type tokenAuthCredentials struct {
4246
}
4347

4448
// implement PerRPCCredentials interface
45-
func (c tokenAuthCredentials) GetRequestMetadata(_ context.Context, _ ...string) (map[string]string, error) {
49+
func (c tokenAuthCredentials) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error) {
4650
if c.authTokenProvider == nil {
4751
return nil, nil
4852
}
49-
return c.authTokenProvider.GetHeaders(), nil
53+
return c.authTokenProvider.Headers(ctx)
5054
}
5155

5256
func (c tokenAuthCredentials) RequireTransportSecurity() bool {

pkg/chipingress/auth_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ func TestBasicAuth(t *testing.T) {
4949
})
5050
}
5151

52-
var authHeaderKey = "X-Auth-Token"
53-
5452
type testHeaderProvider struct {
5553
headers map[string]string
5654
}
5755

58-
func (p *testHeaderProvider) GetHeaders() map[string]string {
59-
return p.headers
56+
func (p *testHeaderProvider) Headers(ctx context.Context) (map[string]string, error) {
57+
return p.headers, nil
6058
}
6159

6260
func TestTokenAuth(t *testing.T) {

pkg/chipingress/client.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ import (
2020
)
2121

2222
// HeaderProvider defines an interface for providing headers
23-
type HeaderProvider interface {
24-
GetHeaders() map[string]string
25-
}
2623

2724
type Client interface {
2825
pb.ChipIngressClient
@@ -51,8 +48,10 @@ func newClientConfig(host string) *clientConfig {
5148
headerProvider: nil,
5249
perRPCCredentials: nil,
5350
host: host,
51+
// Default to insecure connection
52+
insecureConnection: true,
53+
transportCredentials: insecure.NewCredentials(),
5454
}
55-
WithInsecureConnection()(cfg) // Default to insecure connection
5655
return cfg
5756
}
5857

@@ -168,7 +167,13 @@ func newHeaderInterceptor(provider HeaderProvider) grpc.UnaryClientInterceptor {
168167
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
169168
// Add dynamic headers from provider if available
170169
if provider != nil {
171-
for k, v := range provider.GetHeaders() {
170+
171+
headers, err := provider.Headers(ctx)
172+
if err != nil {
173+
return fmt.Errorf("failed to get headers: %w", err)
174+
}
175+
176+
for k, v := range headers {
172177
ctx = metadata.AppendToOutgoingContext(ctx, k, v)
173178
}
174179
}

pkg/chipingress/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ type mockHeaderProvider struct {
584584
headers map[string]string
585585
}
586586

587-
func (m *mockHeaderProvider) GetHeaders() map[string]string {
588-
return m.headers
587+
func (m *mockHeaderProvider) Headers(ctx context.Context) (map[string]string, error) {
588+
return m.headers, nil
589589
}
590590

591591
func TestWithTLS(t *testing.T) {

pkg/config/bytes.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ var (
3232
}
3333
)
3434

35+
// SizeOf returns the cumulative len of the byte slice arguments as a Size.
36+
func SizeOf[B ~[]byte](bs ...B) (s Size) {
37+
for _, b := range bs {
38+
s += Size(len(b))
39+
}
40+
return
41+
}
42+
3543
func (b Size) MarshalText() ([]byte, error) {
3644
if b >= TByte {
3745
d := decimal.NewFromInt(int64(b)).Div(decimal.NewFromInt(int64(TByte)))

pkg/loop/telem.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"google.golang.org/grpc"
2020
"google.golang.org/grpc/credentials"
2121
"google.golang.org/grpc/credentials/insecure"
22-
"google.golang.org/grpc/encoding/gzip"
2322

2423
"github.com/smartcontractkit/chainlink-common/pkg/beholder"
2524
"github.com/smartcontractkit/chainlink-common/pkg/config/build"
@@ -150,7 +149,6 @@ func (config TracingConfig) NewSpanExporter() (sdktrace.SpanExporter, error) {
150149
traceExporter, err := otlptracegrpc.New(ctx,
151150
otlptracegrpc.WithGRPCConn(conn),
152151
otlptracegrpc.WithHeaders(config.AuthHeaders),
153-
otlptracegrpc.WithCompressor(gzip.Name),
154152
)
155153
if err != nil {
156154
return nil, err

0 commit comments

Comments
 (0)