Skip to content

Commit

Permalink
chore: backport cherry picks to release/v1.x.x (#805)
Browse files Browse the repository at this point in the history
Co-authored-by: tyler <[email protected]>
  • Loading branch information
Alex | Skip and technicallyty authored Nov 12, 2024
1 parent ef03f40 commit 8e11746
Show file tree
Hide file tree
Showing 33 changed files with 1,118 additions and 372 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

# Primary repo maintainers

* @aljo242 @Eric-Warehime @technicallyty @wesl-ee
* @skip-mev/skip-connect
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build:
strategy:
matrix:
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"}]
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"}]
runs-on: ubuntu-latest-m
permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22.5
go-version: 1.23.3
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.22.5
go-version: 1.23.3
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
Expand All @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22.5
go-version: 1.23.3
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.5
go-version: 1.23.3
- name: Unshallow
run: git fetch --prune --unshallow
- name: Create release
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/spell.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22.5
go-version: 1.23.3
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
Expand Down
39 changes: 37 additions & 2 deletions cmd/slinky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import (
"errors"
"fmt"
"net/http"

//nolint: gosec
_ "net/http/pprof"
"os"
"os/signal"
"regexp"
"strings"
"syscall"

_ "net/http/pprof" //nolint: gosec

"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/zap"
Expand Down Expand Up @@ -283,6 +286,14 @@ func runOracle() error {
}
}

// check that the marketmap endpoint they provided is correct.
if marketMapProvider == marketmap.Name {
mmEndpoint := cfg.Providers[marketMapProvider].API.Endpoints[0].URL
if err := isValidGRPCEndpoint(mmEndpoint); err != nil {
return err
}
}

var marketCfg mmtypes.MarketMap
if marketCfgPath != "" {
marketCfg, err = mmtypes.ReadMarketMapFromFile(marketCfgPath)
Expand Down Expand Up @@ -397,3 +408,27 @@ func overwriteMarketMapEndpoint(cfg config.OracleConfig, overwrite string) (conf

return cfg, fmt.Errorf("no market-map provider found in config")
}

// isValidGRPCEndpoint checks that the string s is a valid gRPC endpoint. (doesn't start with http, ends with a port).
func isValidGRPCEndpoint(s string) error {
if strings.HasPrefix(s, "http") {
return fmt.Errorf("expected gRPC endpoint but got HTTP endpoint %q. Please provide a gRPC endpoint (e.g. some.host:9090)", s)
}
if !hasPort(s) {
// they might do something like foo.bar:hello
// so lets just take the bit before foo.bar for the example in the error.
example := strings.Split(s, ":")[0]
return fmt.Errorf("invalid gRPC endpoint %q. Must specify port (e.g. %s:9090)", s, example)
}
return nil
}

// hasPort reports whether s contains `:` followed by numbers.
func hasPort(s string) bool {
// matches anything that has `:` and some numbers after.
pattern := `:[0-9]+$`

regex := regexp.MustCompile(pattern)

return regex.MatchString(s)
}
62 changes: 62 additions & 0 deletions cmd/slinky/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package main

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestCheckMarketMapEndpoint(t *testing.T) {
tests := []struct {
name string
endpoint string
wantErr bool
errMsg string
}{
{
name: "Valid gRPC endpoint",
endpoint: "example.com:8080",
wantErr: false,
},
{
name: "Valid IP address endpoint",
endpoint: "192.168.1.1:9090",
wantErr: false,
},
{
name: "HTTP endpoint",
endpoint: "http://example.com:8080",
wantErr: true,
errMsg: `expected gRPC endpoint but got HTTP endpoint "http://example.com:8080". Please provide a gRPC endpoint (e.g. some.host:9090)`,
},
{
name: "HTTPS endpoint",
endpoint: "https://example.com:8080",
wantErr: true,
errMsg: `expected gRPC endpoint but got HTTP endpoint "https://example.com:8080". Please provide a gRPC endpoint (e.g. some.host:9090)`,
},
{
name: "Missing port",
endpoint: "example.com",
wantErr: true,
errMsg: `invalid gRPC endpoint "example.com". Must specify port (e.g. example.com:9090)`,
},
{
name: "Invalid port format",
endpoint: "example.com:port",
wantErr: true,
errMsg: `invalid gRPC endpoint "example.com:port". Must specify port (e.g. example.com:9090)`,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := isValidGRPCEndpoint(tt.endpoint)
if tt.wantErr {
require.EqualError(t, err, tt.errMsg)
} else {
require.NoError(t, err)
}
})
}
}
2 changes: 1 addition & 1 deletion contrib/images/slinky.base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22-bullseye AS builder
FROM golang:1.23-bullseye AS builder

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

Expand Down
2 changes: 1 addition & 1 deletion contrib/images/slinky.generator.dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ./contrib/images/slinky.generator.dev.Dockerfile

# Stage 1: Build the Go application
FROM golang:1.22 AS builder
FROM golang:1.23 AS builder

WORKDIR /src/slinky

Expand Down
Loading

0 comments on commit 8e11746

Please sign in to comment.