Skip to content

Commit 1082fd4

Browse files
authored
Merge branch 'main' into ARCH-331-keystore-encryptor-2
2 parents ac08a79 + a7f07f3 commit 1082fd4

File tree

7 files changed

+125
-13
lines changed

7 files changed

+125
-13
lines changed

.github/workflows/keystore.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Keystore Checks
2+
permissions:
3+
contents: read
4+
5+
on:
6+
push:
7+
paths:
8+
- "keystore/**"
9+
10+
jobs:
11+
run-tests:
12+
defaults:
13+
run:
14+
working-directory: keystore
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: ./.github/actions/setup-go
22+
with:
23+
go-version-file: "go.mod"
24+
restore-build-cache-only: "false"
25+
26+
- name: Build
27+
run: go build -v ./...
28+
29+
- name: Unit Tests
30+
run: go test ./... -coverpkg=./... -coverprofile=coverage.txt
31+
32+
build-race-tests:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Set up Go
39+
uses: ./.github/actions/setup-go
40+
with:
41+
go-version-file: "go.mod"
42+
43+
- name: Build
44+
run: go build -v ./...
45+
46+
- name: Race Tests
47+
run: GORACE="log_path=$PWD/race" go test -race ./...
48+
49+
- name: Print Races
50+
if: failure()
51+
id: print-races
52+
run: |
53+
find race.* | xargs cat > race.txt
54+
if [[ -s race.txt ]]; then
55+
cat race.txt
56+
fi
57+
58+
- name: Upload Go test results
59+
if: always()
60+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
61+
with:
62+
name: go-race-results
63+
path: |
64+
./race.*

pkg/capabilities/capabilities.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package capabilities
33
import (
44
"context"
55
"fmt"
6+
"iter"
67
"regexp"
78
"strings"
89
"time"
@@ -155,6 +156,30 @@ type CapabilityRequest struct {
155156
CapabilityId string
156157
}
157158

159+
// ParseID parses a capability ID in form of: `{name}:{label1_key}_{labe1_value}:{label2_key}_{label2_value}@{version}`
160+
func ParseID(id string) (name string, labels iter.Seq2[string, string], version string) {
161+
if i := strings.LastIndex(id, "@"); i != -1 {
162+
version = id[i+1:]
163+
id = id[:i]
164+
}
165+
if parts := strings.Split(id, ":"); len(parts) >= 1 {
166+
name = parts[0]
167+
labels = func(yield func(string, string) bool) {
168+
for _, label := range parts[1:] {
169+
kv := strings.SplitN(label, "_", 2)
170+
var v string
171+
if len(kv) == 2 {
172+
v = kv[1]
173+
}
174+
if !yield(kv[0], v) {
175+
return
176+
}
177+
}
178+
}
179+
}
180+
return
181+
}
182+
158183
type RegisterToWorkflowRequest struct {
159184
Metadata RegistrationMetadata
160185
Config *values.Map

pkg/capabilities/capabilities_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"errors"
7+
"maps"
78
"strings"
89
"testing"
910

@@ -275,3 +276,29 @@ func TestOCRTriggerEvent_ToMapFromMap(t *testing.T) {
275276
})
276277

277278
}
279+
280+
func TestParseID(t *testing.T) {
281+
for _, tc := range []struct {
282+
id string
283+
name string
284+
labels map[string]string
285+
version string
286+
}{
287+
{id: "foo", name: "foo"},
288+
{id: "[email protected]", name: "foo", version: "1.0.0"},
289+
{id: "foo:[email protected]", name: "foo", labels: map[string]string{"k": "v"}, version: "1.0.0"},
290+
{id: "foo:k_v:k2_v2:[email protected]", name: "foo", labels: map[string]string{"k": "v", "k2": "v2", "k3": ""}, version: "1.0.0"},
291+
//TODO more
292+
} {
293+
t.Run(tc.id, func(t *testing.T) {
294+
if tc.labels == nil {
295+
tc.labels = map[string]string{}
296+
}
297+
298+
name, labels, version := ParseID(tc.id)
299+
assert.Equal(t, tc.name, name)
300+
assert.Equal(t, tc.labels, maps.Collect(labels))
301+
assert.Equal(t, tc.version, version)
302+
})
303+
}
304+
}

pkg/settings/cresettings/defaults.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,17 @@
4949
"FilterTopicsPerSlotLimit": "10"
5050
},
5151
"HTTPAction": {
52-
"RateLimit": "every30s:3",
52+
"CallLimit": "3",
5353
"ResponseSizeLimit": "10kb",
5454
"ConnectionTimeout": "10s",
5555
"RequestSizeLimit": "100kb",
5656
"CacheAgeLimit": "10m0s"
5757
},
5858
"ChainWrite": {
59-
"RateLimit": "every30s:3",
6059
"TargetsLimit": "3",
6160
"ReportSizeLimit": "1kb",
6261
"EVM": {
63-
"TransactionGasLimit": "500000"
62+
"TransactionGasLimit": "5000000"
6463
}
6564
},
6665
"ChainRead": {

pkg/settings/cresettings/defaults.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,18 @@ FilterAddressLimit = '5'
5050
FilterTopicsPerSlotLimit = '10'
5151

5252
[PerWorkflow.HTTPAction]
53-
RateLimit = 'every30s:3'
53+
CallLimit = '3'
5454
ResponseSizeLimit = '10kb'
5555
ConnectionTimeout = '10s'
5656
RequestSizeLimit = '100kb'
5757
CacheAgeLimit = '10m0s'
5858

5959
[PerWorkflow.ChainWrite]
60-
RateLimit = 'every30s:3'
6160
TargetsLimit = '3'
6261
ReportSizeLimit = '1kb'
6362

6463
[PerWorkflow.ChainWrite.EVM]
65-
TransactionGasLimit = '500000'
64+
TransactionGasLimit = '5000000'
6665

6766
[PerWorkflow.ChainRead]
6867
CallLimit = '3'

pkg/settings/cresettings/settings.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,17 @@ var Default = Schema{
8282
EventSizeLimit: Size(5 * config.KByte),
8383
},
8484
HTTPAction: httpAction{
85-
RateLimit: Rate(rate.Every(30*time.Second), 3),
85+
CallLimit: Int(3),
8686
ResponseSizeLimit: Size(10 * config.KByte),
8787
ConnectionTimeout: Duration(10 * time.Second),
8888
RequestSizeLimit: Size(100 * config.KByte),
8989
CacheAgeLimit: Duration(10 * time.Minute),
9090
},
9191
ChainWrite: chainWrite{
92-
RateLimit: Rate(rate.Every(30*time.Second), 3),
9392
TargetsLimit: Int(3),
9493
ReportSizeLimit: Size(config.KByte),
9594
EVM: evmChainWrite{
96-
TransactionGasLimit: Uint64(500_000),
95+
TransactionGasLimit: Uint64(5_000_000),
9796
},
9897
},
9998
ChainRead: chainRead{
@@ -177,14 +176,13 @@ type logTrigger struct {
177176
FilterTopicsPerSlotLimit Setting[int] `unit:"{topic}"`
178177
}
179178
type httpAction struct {
180-
RateLimit Setting[config.Rate]
179+
CallLimit Setting[int] `unit:"{call}"`
181180
ResponseSizeLimit Setting[config.Size]
182181
ConnectionTimeout Setting[time.Duration]
183182
RequestSizeLimit Setting[config.Size]
184183
CacheAgeLimit Setting[time.Duration]
185184
}
186185
type chainWrite struct {
187-
RateLimit Setting[config.Rate]
188186
TargetsLimit Setting[int] `unit:"{target}"`
189187
ReportSizeLimit Setting[config.Size]
190188

pkg/settings/cresettings/settings_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestSchema_Unmarshal(t *testing.T) {
8383
"EventRateLimit": "every13s:6"
8484
},
8585
"HTTPAction": {
86-
"RateLimit": "every3s:5",
86+
"CallLimit": "5",
8787
"CacheAgeLimit": "5m"
8888
},
8989
"ChainWrite": {
@@ -107,7 +107,7 @@ func TestSchema_Unmarshal(t *testing.T) {
107107
assert.Equal(t, config.Rate{Limit: rate.Every(10 * time.Second), Burst: 5}, cfg.PerWorkflow.CRONTrigger.RateLimit.DefaultValue)
108108
assert.Equal(t, config.Rate{Limit: rate.Every(30 * time.Second), Burst: 3}, cfg.PerWorkflow.HTTPTrigger.RateLimit.DefaultValue)
109109
assert.Equal(t, config.Rate{Limit: rate.Every(13 * time.Second), Burst: 6}, cfg.PerWorkflow.LogTrigger.EventRateLimit.DefaultValue)
110-
assert.Equal(t, config.Rate{Limit: rate.Every(3 * time.Second), Burst: 5}, cfg.PerWorkflow.HTTPAction.RateLimit.DefaultValue)
110+
assert.Equal(t, 5, cfg.PerWorkflow.HTTPAction.CallLimit.DefaultValue)
111111
assert.Equal(t, 5*time.Minute, cfg.PerWorkflow.HTTPAction.CacheAgeLimit.DefaultValue)
112112
assert.Equal(t, uint64(500000), cfg.PerWorkflow.ChainWrite.EVM.TransactionGasLimit.DefaultValue)
113113
assert.Equal(t, 3, cfg.PerWorkflow.ChainRead.CallLimit.DefaultValue)

0 commit comments

Comments
 (0)