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
15 changes: 15 additions & 0 deletions pkg/capabilities/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"

"github.com/smartcontractkit/chainlink-common/pkg/contexts"
"github.com/smartcontractkit/chainlink-protos/cre/go/values"
)

Expand Down Expand Up @@ -108,13 +109,27 @@ type RequestMetadata struct {
WorkflowTag string
}

func (m *RequestMetadata) ContextWithCRE(ctx context.Context) context.Context {
return contexts.WithCRE(ctx, contexts.CRE{
Owner: m.WorkflowOwner,
Workflow: m.WorkflowID,
})
}

type RegistrationMetadata struct {
WorkflowID string
WorkflowOwner string
// The step reference ID of the workflow
ReferenceID string
}

func (m *RegistrationMetadata) ContextWithCRE(ctx context.Context) context.Context {
return contexts.WithCRE(ctx, contexts.CRE{
Owner: m.WorkflowOwner,
Workflow: m.WorkflowID,
})
}

// CapabilityRequest is a struct for the Execute request of a capability.
type CapabilityRequest struct {
Metadata RequestMetadata
Expand Down
8 changes: 8 additions & 0 deletions pkg/config/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ var (
}
)

// SizeOf returns the cumulative len of the byte slice arguments as a Size.
func SizeOf[B ~[]byte](bs ...B) (s Size) {
for _, b := range bs {
s += Size(len(b))
}
return
}

func (b Size) MarshalText() ([]byte, error) {
if b >= TByte {
d := decimal.NewFromInt(int64(b)).Div(decimal.NewFromInt(int64(TByte)))
Expand Down
4 changes: 2 additions & 2 deletions pkg/settings/cresettings/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"LogTrigger": {
"RateLimit": "every10s:-1",
"Limit": "5",
"EventRateLimit": "every-1s:-1",
"EventRateLimit": "every6s:10",
"FilterAddressLimit": "5",
"FilterTopicsPerSlotLimit": "10"
},
Expand All @@ -58,7 +58,7 @@
"TargetsLimit": "3",
"ReportSizeLimit": "1kb",
"EVM": {
"TransactionGasLimit": "-1"
"TransactionGasLimit": "500000"
}
},
"ChainRead": {
Expand Down
4 changes: 2 additions & 2 deletions pkg/settings/cresettings/defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RateLimit = 'every30s:3'
[PerWorkflow.LogTrigger]
RateLimit = 'every10s:-1'
Limit = '5'
EventRateLimit = 'every-1s:-1'
EventRateLimit = 'every6s:10'
FilterAddressLimit = '5'
FilterTopicsPerSlotLimit = '10'

Expand All @@ -60,7 +60,7 @@ TargetsLimit = '3'
ReportSizeLimit = '1kb'

[PerWorkflow.ChainWrite.EVM]
TransactionGasLimit = '-1'
TransactionGasLimit = '500000'

[PerWorkflow.ChainRead]
CallLimit = '3'
Expand Down
12 changes: 6 additions & 6 deletions pkg/settings/cresettings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var Default = Schema{
LogTrigger: logTrigger{
RateLimit: Rate(rate.Every(10*time.Second), -1), //TODO
Limit: Int(5),
EventRateLimit: Rate(-1, -1), //TODO
EventRateLimit: Rate(rate.Every(time.Minute/10), 10), // TODO
FilterAddressLimit: Int(5),
FilterTopicsPerSlotLimit: Int(10),
},
Expand All @@ -91,12 +91,12 @@ var Default = Schema{
TargetsLimit: Int(3),
ReportSizeLimit: Size(config.KByte),
EVM: evmChainWrite{
TransactionGasLimit: Int(-1), //TODO
TransactionGasLimit: Uint64(500_000), //TODO
},
},
ChainRead: chainRead{
CallLimit: Int(3),
LogQueryBlockLimit: Int(100),
LogQueryBlockLimit: Uint64(100),
PayloadSizeLimit: Size(5 * config.KByte),
},
},
Expand Down Expand Up @@ -187,11 +187,11 @@ type chainWrite struct {
EVM evmChainWrite
}
type evmChainWrite struct {
TransactionGasLimit Setting[int] `unit:"{gas}"`
TransactionGasLimit Setting[uint64] `unit:"{gas}"`
}

type chainRead struct {
CallLimit Setting[int] `unit:"{call}"`
LogQueryBlockLimit Setting[int] `unit:"{block}"`
CallLimit Setting[int] `unit:"{call}"`
LogQueryBlockLimit Setting[uint64] `unit:"{block}"`
PayloadSizeLimit Setting[config.Size]
}
2 changes: 1 addition & 1 deletion pkg/settings/cresettings/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ func TestSchema_Unmarshal(t *testing.T) {
assert.Equal(t, config.Rate{Limit: rate.Every(13 * time.Second), Burst: 6}, cfg.PerWorkflow.LogTrigger.EventRateLimit.DefaultValue)
assert.Equal(t, config.Rate{Limit: rate.Every(3 * time.Second), Burst: 5}, cfg.PerWorkflow.HTTPAction.RateLimit.DefaultValue)
assert.Equal(t, 5*time.Minute, cfg.PerWorkflow.HTTPAction.CacheAgeLimit.DefaultValue)
assert.Equal(t, 500000, cfg.PerWorkflow.ChainWrite.EVM.TransactionGasLimit.DefaultValue)
assert.Equal(t, uint64(500000), cfg.PerWorkflow.ChainWrite.EVM.TransactionGasLimit.DefaultValue)
assert.Equal(t, 3, cfg.PerWorkflow.ChainRead.CallLimit.DefaultValue)
}
2 changes: 1 addition & 1 deletion pkg/settings/limits/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type ResourceLimiter[N Number] interface {
Use(ctx context.Context, amount N) error
// Free is the counterpart to Use and releases amount of resources from use.
Free(ctx context.Context, amount N) error
// Available returns
// Available returns the available remaining capacity.
Available(ctx context.Context) (N, error)
}

Expand Down
Loading