Skip to content

Commit

Permalink
Merge pull request #55 from Layr-Labs/sm-rewards
Browse files Browse the repository at this point in the history
Rewards calculation
  • Loading branch information
seanmcgary authored Oct 8, 2024
2 parents fef7eb5 + 02e7fb7 commit 8294c9b
Show file tree
Hide file tree
Showing 104 changed files with 8,974 additions and 1,159 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ sidecar.db*
/sqlite
/sqlite*
go-sidecar
!/sqlite-extensions
21 changes: 8 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,22 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Install dependencies
run: make deps-linux
run: make deps
- name: Run tests
run: make ci-test
lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Install dependencies
run: make deps-linux
- name: Run tests
run: make lint
- name: Run linter
run: |
make deps
go env GOPATH
export PATH=$PATH:$(go env GOPATH)/bin
echo $PATH
make lint
build:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@ go-sidecar
/internal/tests/testdata/**/*.json
/internal/tests/testdata/*.sql
!/internal/tests/testdata/**/generateExpectedResults.sql
!/internal/tests/testdata/**/*generateExpectedResults.sql
!sqlite-extensions
/*.tar
/sidecar-data
__pycache__
test-db
*.dylib
*.dylib.dSYM
/sqlite-extensions/build
1 change: 1 addition & 0 deletions .testdataVersion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
070a7fa07a31795caaf6e2423d5c60f429d1d7a4
106 changes: 0 additions & 106 deletions .vscode/tasks.json

This file was deleted.

2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Global owners
* @Layr-Labs/sidecar
17 changes: 7 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
FROM golang:1.22-bullseye AS builder
FROM debian:testing-slim AS builder

ARG TARGETARCH

RUN export DEBIAN_FRONTEND=noninteractive && \
apt update && \
apt install -y -q --no-install-recommends \
build-essential gcc musl-dev linux-headers-${TARGETARCH} && \
apt clean && \
rm -rf /var/lib/apt/lists/*
RUN apt update && \
apt install -y make curl git

WORKDIR /build

COPY . .

# system and linux dependencies
RUN make deps-linux
RUN make deps

RUN make build

FROM debian:stable-slim
RUN mv /build/bin/sidecar /usr/local/bin/sidecar

COPY --from=builder /build/bin/sidecar /usr/local/bin/sidecar
RUN apt clean && \
rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["/usr/local/bin/sidecar"]
52 changes: 34 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,49 @@
.PHONY: deps proto

PROJECT_ROOT = $(shell pwd)
CGO_CFLAGS = "-I$(PROJECT_ROOT)/sqlite-extensions"
CGO_LDFLAGS = "-L$(PROJECT_ROOT)/sqlite-extensions/build/lib -lcalculations -Wl,-rpath,$(PROJECT_ROOT)/sqlite-extensions/build/lib"
PYTHONPATH = $(PROJECT_ROOT)/sqlite-extensions
CGO_ENABLED = 1
GO=$(shell which go)
ALL_FLAGS=CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) PYTHONPATH=$(PYTHONPATH) CGO_ENABLED=$(CGO_ENABLED)

PROTO_OPTS=--proto_path=protos --go_out=paths=source_relative:protos

deps/dev:
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
${GO} install github.com/golangci/golangci-lint/cmd/[email protected]
${GO} install honnef.co/go/tools/cmd/staticcheck@latest
${GO} install github.com/google/yamlfmt/cmd/yamlfmt@latest

deps/go:
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
go get \
${GO} install google.golang.org/protobuf/cmd/[email protected]
${GO} install google.golang.org/grpc/cmd/[email protected]
${GO} get \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
go install \
${GO} install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
go mod tidy
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.61.0
${GO} mod tidy


deps-linux: deps/go deps/dev
deps-buf:
GOROOT=$(go env GOROOT)
BIN="${GOROOT}/bin" VERSION="1.32.2" && \
curl -sSL "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" -o "${BIN}/buf" && \
chmod +x "${BIN}/buf"

deps: deps/go
brew install bufbuild/buf/buf
deps-system:
./scripts/installDeps.sh

deps: deps-system deps-buf deps/go deps/dev

PROTO_OPTS=--proto_path=protos --go_out=paths=source_relative:protos

# Build targets
proto:
buf generate protos

Expand All @@ -42,11 +53,13 @@ clean:

.PHONY: build/cmd/sidecar
build/cmd/sidecar:
CGO_ENABLED=1 go build -o bin/sidecar main.go
cd sqlite-extensions && make all && cd -
$(ALL_FLAGS) $(GO) build -o bin/sidecar main.go

.PHONY: build
build: build/cmd/sidecar

# Docker build steps
docker-buildx-self:
docker buildx build -t go-sidecar:latest -t go-sidecar:latest .

Expand All @@ -72,19 +85,22 @@ fmtcheck:
fi
.PHONY: vet
vet:
go vet ./...
$(ALL_FLAGS) $(GO) vet ./...

.PHONY: lint
lint:
golangci-lint run
$(ALL_FLAGS) golangci-lint run

.PHONY: test
test:
TESTING=true go test -v -p 1 -parallel 1 ./...
./scripts/goTest.sh -v -p 1 -parallel 1 ./...

.PHONY: staticcheck
staticcheck:
staticcheck ./...

.PHONY: ci-test
ci-test: test
ci-test: build test

test-rewards:
TEST_REWARDS=true TESTING=true ${GO} test ./pkg/rewards -v -p 1
Loading

0 comments on commit 8294c9b

Please sign in to comment.