Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 8e11746

Browse files
Alex | Skiptechnicallyty
andauthored
chore: backport cherry picks to release/v1.x.x (#805)
Co-authored-by: tyler <[email protected]>
1 parent ef03f40 commit 8e11746

33 files changed

+1118
-372
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
# Primary repo maintainers
66

7-
* @aljo242 @Eric-Warehime @technicallyty @wesl-ee
7+
* @skip-mev/skip-connect

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
build:
1515
strategy:
1616
matrix:
17-
image: [{file: "slinky.e2e.Dockerfile", name: "slinky-simapp"}, {file: "slinky.sidecar.prod.Dockerfile", name: "slinky-sidecar"}, {file: "slinky.local.Dockerfile", name: "slinky-testapp"}, {file: "slinky.sidecar.e2e.Dockerfile", name: "slinky-e2e-sidecar"}]
17+
image: [{file: "slinky.base.Dockerfile", name: "slinky-base"},file: "slinky.e2e.Dockerfile", name: "slinky-simapp"}, {file: "slinky.sidecar.prod.Dockerfile", name: "slinky-sidecar"}, {file: "slinky.local.Dockerfile", name: "slinky-testapp"}, {file: "slinky.sidecar.e2e.Dockerfile", name: "slinky-e2e-sidecar"}]
1818
runs-on: ubuntu-latest-m
1919
permissions:
2020
contents: read

.github/workflows/e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-go@v5
1616
with:
17-
go-version: 1.22.5
17+
go-version: 1.23.3
1818
cache: true
1919
cache-dependency-path: go.sum
2020
- uses: technote-space/[email protected]

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/setup-go@v5
2020
with:
21-
go-version: 1.22.5
21+
go-version: 1.23.3
2222
- uses: actions/checkout@v4
2323
- name: golangci-lint
2424
uses: golangci/golangci-lint-action@v6
@@ -43,7 +43,7 @@ jobs:
4343
- uses: actions/checkout@v4
4444
- uses: actions/setup-go@v5
4545
with:
46-
go-version: 1.22.5
46+
go-version: 1.23.3
4747
cache: true
4848
cache-dependency-path: go.sum
4949
- uses: technote-space/[email protected]

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Go
2121
uses: actions/setup-go@v5
2222
with:
23-
go-version: 1.22.5
23+
go-version: 1.23.3
2424
- name: Unshallow
2525
run: git fetch --prune --unshallow
2626
- name: Create release

.github/workflows/spell.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@v4
2424
- uses: actions/setup-go@v5
2525
with:
26-
go-version: 1.22.5
26+
go-version: 1.23.3
2727
cache: true
2828
cache-dependency-path: go.sum
2929
- uses: technote-space/[email protected]

cmd/slinky/main.go

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import (
55
"errors"
66
"fmt"
77
"net/http"
8+
9+
//nolint: gosec
10+
_ "net/http/pprof"
811
"os"
912
"os/signal"
13+
"regexp"
14+
"strings"
1015
"syscall"
1116

12-
_ "net/http/pprof" //nolint: gosec
13-
1417
"github.com/spf13/cobra"
1518
"github.com/spf13/viper"
1619
"go.uber.org/zap"
@@ -283,6 +286,14 @@ func runOracle() error {
283286
}
284287
}
285288

289+
// check that the marketmap endpoint they provided is correct.
290+
if marketMapProvider == marketmap.Name {
291+
mmEndpoint := cfg.Providers[marketMapProvider].API.Endpoints[0].URL
292+
if err := isValidGRPCEndpoint(mmEndpoint); err != nil {
293+
return err
294+
}
295+
}
296+
286297
var marketCfg mmtypes.MarketMap
287298
if marketCfgPath != "" {
288299
marketCfg, err = mmtypes.ReadMarketMapFromFile(marketCfgPath)
@@ -397,3 +408,27 @@ func overwriteMarketMapEndpoint(cfg config.OracleConfig, overwrite string) (conf
397408

398409
return cfg, fmt.Errorf("no market-map provider found in config")
399410
}
411+
412+
// isValidGRPCEndpoint checks that the string s is a valid gRPC endpoint. (doesn't start with http, ends with a port).
413+
func isValidGRPCEndpoint(s string) error {
414+
if strings.HasPrefix(s, "http") {
415+
return fmt.Errorf("expected gRPC endpoint but got HTTP endpoint %q. Please provide a gRPC endpoint (e.g. some.host:9090)", s)
416+
}
417+
if !hasPort(s) {
418+
// they might do something like foo.bar:hello
419+
// so lets just take the bit before foo.bar for the example in the error.
420+
example := strings.Split(s, ":")[0]
421+
return fmt.Errorf("invalid gRPC endpoint %q. Must specify port (e.g. %s:9090)", s, example)
422+
}
423+
return nil
424+
}
425+
426+
// hasPort reports whether s contains `:` followed by numbers.
427+
func hasPort(s string) bool {
428+
// matches anything that has `:` and some numbers after.
429+
pattern := `:[0-9]+$`
430+
431+
regex := regexp.MustCompile(pattern)
432+
433+
return regex.MatchString(s)
434+
}

cmd/slinky/main_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package main
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestCheckMarketMapEndpoint(t *testing.T) {
10+
tests := []struct {
11+
name string
12+
endpoint string
13+
wantErr bool
14+
errMsg string
15+
}{
16+
{
17+
name: "Valid gRPC endpoint",
18+
endpoint: "example.com:8080",
19+
wantErr: false,
20+
},
21+
{
22+
name: "Valid IP address endpoint",
23+
endpoint: "192.168.1.1:9090",
24+
wantErr: false,
25+
},
26+
{
27+
name: "HTTP endpoint",
28+
endpoint: "http://example.com:8080",
29+
wantErr: true,
30+
errMsg: `expected gRPC endpoint but got HTTP endpoint "http://example.com:8080". Please provide a gRPC endpoint (e.g. some.host:9090)`,
31+
},
32+
{
33+
name: "HTTPS endpoint",
34+
endpoint: "https://example.com:8080",
35+
wantErr: true,
36+
errMsg: `expected gRPC endpoint but got HTTP endpoint "https://example.com:8080". Please provide a gRPC endpoint (e.g. some.host:9090)`,
37+
},
38+
{
39+
name: "Missing port",
40+
endpoint: "example.com",
41+
wantErr: true,
42+
errMsg: `invalid gRPC endpoint "example.com". Must specify port (e.g. example.com:9090)`,
43+
},
44+
{
45+
name: "Invalid port format",
46+
endpoint: "example.com:port",
47+
wantErr: true,
48+
errMsg: `invalid gRPC endpoint "example.com:port". Must specify port (e.g. example.com:9090)`,
49+
},
50+
}
51+
52+
for _, tt := range tests {
53+
t.Run(tt.name, func(t *testing.T) {
54+
err := isValidGRPCEndpoint(tt.endpoint)
55+
if tt.wantErr {
56+
require.EqualError(t, err, tt.errMsg)
57+
} else {
58+
require.NoError(t, err)
59+
}
60+
})
61+
}
62+
}

contrib/images/slinky.base.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22-bullseye AS builder
1+
FROM golang:1.23-bullseye AS builder
22

33
RUN curl -sSLf "$(curl -sSLf https://api.github.com/repos/tomwright/dasel/releases/latest | grep browser_download_url | grep linux_amd64 | grep -v .gz | cut -d\" -f 4)" -L -o dasel && chmod +x dasel && mv ./dasel /usr/local/bin/dasel
44

0 commit comments

Comments
 (0)