Skip to content

Commit

Permalink
Merge branch 'master' into release/rewards-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrajath authored Nov 14, 2024
2 parents 63f744e + 1de6ecb commit a9e0fdd
Show file tree
Hide file tree
Showing 23 changed files with 402 additions and 75 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ jobs:
else
docker buildx build --platform $PLATFORMS -t $REGISTRY/$REPOSITORY:$VERSION --push .
fi
build-binary:
build-create-release:
runs-on: ubuntu-latest
needs: [lint, test]
if: startsWith(github.ref, 'refs/tags/')
needs: [build-container]
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -107,16 +109,9 @@ jobs:
- name: Build binary
run: |
VERSION=$(cat .release_version)
echo "Building binary for version $VERSION"
make release
./scripts/bundleReleases.sh $VERSION
create-release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [build-binary]
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand Down Expand Up @@ -152,3 +147,19 @@ jobs:
--data-binary @"$asset" \
"${upload_url}?name=$asset_name"
done
release-helm-chart:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: [build-create-release]
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release Helm Chart
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
./scripts/releaseHelmChart.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ test-db
node_modules
/release
.release_version
chart_releases
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ RUN make deps

RUN make build

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

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

ENTRYPOINT ["/usr/local/bin/sidecar"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

GO=$(shell which go)
ALL_FLAGS=
GO_FLAGS=-ldflags "-X 'github.com/Layr-Labs/sidecar/internal/version.Version=$(shell cat .release_version || "unknown")' -X 'github.com/Layr-Labs/sidecar/internal/version.Commit=$(shell git rev-parse --short HEAD)'"
GO_FLAGS=-ldflags "-X 'github.com/Layr-Labs/sidecar/internal/version.Version=$(shell cat .release_version)' -X 'github.com/Layr-Labs/sidecar/internal/version.Commit=$(shell git rev-parse --short HEAD)'"

deps/dev:
${GO} install github.com/golangci/golangci-lint/cmd/[email protected]
Expand Down
23 changes: 23 additions & 0 deletions charts/sidecar/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/sidecar/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: sidecar
description: A Helm chart for the EigenLayer sidecar

type: application

version: 0.1.0-beta.2

appVersion: "v1.0.0-beta.1"
45 changes: 45 additions & 0 deletions charts/sidecar/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

{{/*
Expand the name of the chart.
*/}}
{{- define "sidecar.name" -}}
{{- default .Chart.Name .Values.sidecar.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}


{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "sidecar.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}


{{/*
Common labels
*/}}
{{- define "sidecar.labels" -}}
helm.sh/chart: {{ include "sidecar.chart" . }}
{{ include "sidecar.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- with .Values.sidecar.additionalLabels }}
{{- toYaml . | nindent 0 }}
{{- end }}


{{- define "sidecar.selectorLabels" -}}
app.kubernetes.io/name: {{ include "sidecar.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{- define "sidecar.metadataLabels" -}}
{{ include "sidecar.selectorLabels" . }}
{{- with .Values.sidecar.metadataLabels }}
{{- toYaml . | nindent 0 }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/sidecar/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.sidecar.secret.name }}
namespace: {{ .Release.Namespace }}
type: Opaque
data:
{{- range $key, $value := .Values.sidecar.secret.data }}
{{ $key }}: {{ $value | b64enc }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/sidecar/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.sidecar.service.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "sidecar.name" . }}
labels:
{{- include "sidecar.labels" . | nindent 4 }}
spec:
ports:
{{- range $key, $port := .Values.sidecar.ports }}
-
{{ $port | toYaml | indent 4 }}
{{- end }}
clusterIP: None
selector:
{{- include "sidecar.selectorLabels" . | nindent 6 }}
{{- end }}
51 changes: 51 additions & 0 deletions charts/sidecar/templates/sidecarStatefulSet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "sidecar.name" . }}
labels:
{{- include "sidecar.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.sidecar.replicas }}
selector:
matchLabels:
{{- include "sidecar.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "sidecar.metadataLabels" . | nindent 8 }}
spec:
{{- if .Values.sidecar.serviceAccount }}
serviceAccountName: {{ .Values.sidecar.serviceAccount.name }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: {{ .Values.sidecar.args | toJson}}
{{- if .Values.sidecar.ports }}
ports:
{{- range $k, $v := .Values.sidecar.ports }}
- name: {{ $v.name }}
containerPort: {{ $v.containerPort }}
protocol: {{ $v.protocol }}
{{- end -}}
{{- end }}
{{- if .Values.sidecar.resources }}
resources:
{{- toYaml .Values.sidecar.resources | nindent 12 }}
{{- end }}
env:
{{- range $k, $v := .Values.sidecar.env }}
- name: {{ $k }}
value: '{{ $v }}'
{{- end }}
{{- if .Values.sidecar.secret.data }}
{{- range $k, $v := .Values.sidecar.secret.data }}
- name: {{ $k }}
valueFrom:
secretKeyRef:
name: {{ .Values.sidecar.secret.name }}
key: {{ $k }}
{{- end}}
{{ .Values.sidecar.additionalEnv | nindent 12 }}
{{- end}}
42 changes: 42 additions & 0 deletions charts/sidecar/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
image:
repository: public.ecr.aws/z6g0f8n7/sidecar
pullPolicy: Always
tag: "v1.0.0-beta.1"

sidecar:
replicas: 1
nameOverride: ''
additionalLabels: {}
args: ["run"]
env:
SIDECAR_CHAIN: "mainnet"
SIDECAR_DEBUG: "false"
SIDECAR_ETHEREUM_RPC_URL: ""
SIDECAR_DATABASE_HOST: ""
SIDECAR_DATABASE_PORT: "5432"
SIDECAR_DATABASE_USER: "sidecar"
SIDECAR_DATABASE_DB_NAME: "sidecar"
# SIDECAR_STATSD_URL: ""
additionalEnv: {}
# - name: ENV_NAME
# value: "env value"
ports:
- name: grpc
port: 7100
containerPort: 7100
protocol: TCP
- name: http
port: 7101
containerPort: 7101
protocol: TCP
resources: {}
metadataLabels: {}
serviceAccount:
name: default
secret:
name: sidecar-secrets
data: {}
# SIDECAR_DATABASE_PASSWORD: ""
service:
enabled: true

1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func init() {
rootCmd.PersistentFlags().String(config.DatabaseUser, "sidecar", `Defaults to 'sidecar'`)
rootCmd.PersistentFlags().String(config.DatabasePassword, "", ``)
rootCmd.PersistentFlags().String(config.DatabaseDbName, "sidecar", `Defaults to 'sidecar'`)
rootCmd.PersistentFlags().String(config.DatabaseSchemaName, "", `Defaults to "public"`)

rootCmd.PersistentFlags().Int("rpc.grpc-port", 7100, `e.g. 7100`)
rootCmd.PersistentFlags().Int("rpc.http-port", 7101, `e.g. 7101`)
Expand Down
39 changes: 31 additions & 8 deletions docs/postgresql_setup.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Linux (Ubuntu 24.04+)

## Running PostgreSQL with the Sidecar

_Instructions for Linux (Ubuntu 24.04+)_

```bash
su root
Expand Down Expand Up @@ -38,18 +41,38 @@ GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO sidecar;

-- Grant permissions for future objects
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT ALL ON TABLES TO sidecar;
GRANT ALL ON TABLES TO sidecar;
GRANT ALL ON SEQUENCES TO sidecar;
GRANT ALL ON FUNCTIONS TO sidecar;
GRANT ALL ON TYPES TO sidecar;
```

ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT ALL ON SEQUENCES TO sidecar;
### Using a custom schema name

ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT ALL ON FUNCTIONS TO sidecar;
```bash
psql --dbname <your db name>
```

ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT ALL ON TYPES TO sidecar;
```sql

-- Create the schema
create schema if not exists <your schema name>;

-- Set the default search path
alter database <your db name> set search_path to <your schema name>;

ALTER SCHEMA <your schema name> OWNER TO sidecar;

-- Grant all privileges on existing tables and sequences (there shouldnt be any if this is brand new)
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA <your schema name> TO sidecar;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA <your schema name> TO sidecar;

-- Grant permissions for future objects
ALTER DEFAULT PRIVILEGES IN SCHEMA <your schema name>
```

## Appendix

### Tuned PostgreSQL parameters

```text
Expand Down
14 changes: 14 additions & 0 deletions index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
entries:
sidecar:
- apiVersion: v2
appVersion: v1.0.0-beta.1
created: "2024-11-13T21:23:12.29288-06:00"
description: A Helm chart for the EigenLayer sidecar
digest: bb14bb5ec625c6b4596a042aa9b4a1661bb58f1e9710e1cd17250e71ae3e31ec
name: sidecar
type: application
urls:
- https://eigenlayer-sidecar.s3.amazonaws.com/helm/sidecar-0.1.0-beta.1.tgz
version: 0.1.0-beta.1
generated: "2024-11-13T21:23:12.292376-06:00"
Loading

0 comments on commit a9e0fdd

Please sign in to comment.