Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add configs for anvil and aggregator dev env deployment MGX-820 #2

Merged
merged 26 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7e435df
feat: add configs for `anvil` and `aggregator` dev env deployment
tenequm Dec 4, 2023
b99a797
feat: add `operator` deployment to Kubernetes
tenequm Dec 4, 2023
eac4fa2
chore: update helmfile configs structure
tenequm Dec 4, 2023
5dd0019
chore: update node run command config
tenequm Dec 5, 2023
94da117
feat: update Dockerfile build configs
tenequm Dec 5, 2023
f756515
chore: update docker images build run command
tenequm Dec 5, 2023
d680681
chore: update Makefile docker image build config
tenequm Dec 5, 2023
15c7c9f
feat: add working remote cluster deployment configurations
tenequm Dec 5, 2023
2443743
ci: add initial workflow for debug
tenequm Dec 6, 2023
1912e90
chore: test build
tenequm Dec 6, 2023
e1b3465
chore: test docker builds
tenequm Dec 6, 2023
3c4ba67
ci: separate aggregator and operator builds
tenequm Dec 6, 2023
6bcfc53
ci: add fungible envs deployment
tenequm Dec 6, 2023
721e157
fix: permissions
tenequm Dec 6, 2023
5faf277
chore: try older auth action
tenequm Dec 6, 2023
b3e7100
fix: add fungible env to helmfile
tenequm Dec 6, 2023
dd1bf32
ci: move build steps to reusable workflow
tenequm Dec 6, 2023
806e012
fix: add docker images push
tenequm Dec 6, 2023
777d766
fix: version reference
tenequm Dec 6, 2023
43c903c
feat: enable prometheus metrics collectors for operator on fungible envs
tenequm Dec 6, 2023
2547479
fix: add missing config reference for fungible envs deployments
tenequm Dec 6, 2023
9fac191
ci: add workflow concurrency config
tenequm Dec 6, 2023
451e928
ci: add kludge to solve the issue with operator registration on fungi…
tenequm Dec 6, 2023
65a507c
fix: working directory config
tenequm Dec 6, 2023
e9324f4
fix: destroy command
tenequm Dec 6, 2023
5a02aa4
chore: validate redeployment
tenequm Dec 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Pull Request
on:
pull_request:
types: [opened, synchronize, closed]

permissions:
contents: write
id-token: write
deployments: write
checks: write

# The following concurrency group cancels in-progress jobs or runs on pull_request events only
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
init:
name: Set global version
if: github.event.action != 'closed'
runs-on: ubuntu-latest
outputs:
GLOBAL_VERSION: ${{ steps.set_vars.outputs.GLOBAL_VERSION }}
steps:
- name: Set global version
id: set_vars
run: echo "GLOBAL_VERSION=${{ github.sha }}" >> $GITHUB_OUTPUT

build-and-test:
needs: [init]
name: Build
uses: ./.github/workflows/reusable-build-and-test.yml
secrets: inherit
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}

deploy-fungible:
name: Deploy fungible environment
needs: [init, build-and-test]
uses: ./.github/workflows/reusable-deploy.yml
secrets: inherit
with:
env: fungible
version: ${{ needs.init.outputs.GLOBAL_VERSION }}

clean-up-fungible:
name: Delete fungible environment
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: mangata-dev-alpha
location: europe-west1

- name: Delete Kubernetes namespace with resources for fungible environment
run: kubectl delete namespace pr-${{ github.event.number }}

- name: Delete GitHub Deployment environment
if: always()
uses: bobheadxi/[email protected]
with:
step: delete-env
token: ${{ secrets.GITHUB_TOKEN }}
env: pr-${{ github.event.number }}

33 changes: 33 additions & 0 deletions .github/workflows/reusable-build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and test

on:
workflow_call:
inputs:
version:
description: Version to be assigned to the built image
required: true
type: string

permissions:
contents: read
id-token: write

jobs:
build-aggregator-image:
name: Build aggregator Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
docker login -u ${{ secrets.ORG_DOCKERHUB_USERNAME }} -p ${{ secrets.ORG_DOCKERHUB_TOKEN }}
docker buildx create --use
docker buildx build --push --platform linux/amd64,linux/arm64 -t mangatasolutions/aggregator:${{ inputs.version }} -f aggregator/Dockerfile .
build-operator-image:
name: Build operator Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
docker login -u ${{ secrets.ORG_DOCKERHUB_USERNAME }} -p ${{ secrets.ORG_DOCKERHUB_TOKEN }}
docker buildx create --use
docker buildx build --push --platform linux/amd64,linux/arm64 -t mangatasolutions/operator:${{ inputs.version }} -f operator/Dockerfile .
97 changes: 97 additions & 0 deletions .github/workflows/reusable-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: deploy

on:
workflow_dispatch:
inputs:
env:
description: "Target environment for deployment"
required: true
type: string
version:
description: "Version to be assigned to the built image"
required: true
type: string
cluster_name:
description: "Name of the cluster on which to perform deployment"
default: mangata-dev-alpha
required: false
type: string
workflow_call:
inputs:
env:
description: "Target environment for the deployment"
required: true
type: string
version:
description: "Version to be assigned to the built image"
required: true
type: string
cluster_name:
description: "Name of the cluster on which to perform deployment"
default: mangata-dev-alpha
required: false
type: string

permissions:
contents: read
id-token: write
deployments: write

jobs:
deploy:
runs-on: ubuntu-latest
env:
ENV_REF: ${{ inputs.env == 'fungible' && format('pr-{0}', github.event.number) || inputs.env }}
steps:
- uses: actions/checkout@v4
- uses: jkroepke/[email protected]
- name: Setup helmfile
uses: mamezou-tech/[email protected]
with:
install-kubectl: no
install-helm: no
additional-helm-plugins: https://github.com/jkroepke/helm-secrets --version v4.1.1,https://github.com/aslafy-z/helm-git --version 0.14.0
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ inputs.cluster_name }}
location: europe-west1

- name: Create a GitHub Deployment
uses: bobheadxi/[email protected]
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.ENV_REF }}
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}

- name: Delete the fungible env deployment before new one to allow operator to register and not fail
if: inputs.env == 'fungible'
run: export IMAGE_TAG=${{ inputs.version }} && export ENVIRONMENT=${{ env.ENV_REF }} && helmfile destroy -e fungible
working-directory: ops/helmfiles

- run: |
export ENVIRONMENT=${{ env.ENV_REF }}
export IMAGE_TAG=${{ inputs.version }}

# https://dev.to/derlin/helmfile-difference-between-sync-and-apply-helm-3-28o1

export HELM_DIFF_THREE_WAY_MERGE=true
helmfile apply -e ${{ inputs.env }}
working-directory: ops/helmfiles

- name: Update the GitHub Deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: "https://eigen-operator-${{ env.ENV_REF }}.mangata.online"
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ coverage.html

# log files
logs.txt

# Ignore generated kubeconfig from google-github-actions/get-gke-credentials
gha-kubeconfig-*
# Ignore generated credentials from google-github-actions/auth
gha-creds-*.json
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ bindings: ## generates contract bindings

___DOCKER___: ##
docker-build-and-publish-images: ## builds and publishes operator and aggregator docker images using Ko
# Temporarily set `-L` flag to not publish built images to dockerhub
KO_DOCKER_REPO=mangatasolutions/eigen-aggregator ko build aggregator/cmd/main.go --preserve-import-paths -L
KO_DOCKER_REPO=mangatasolutions/eigen-operator ko build operator/cmd/main.go --preserve-import-paths -L
docker buildx build --load --platform linux/amd64,linux/arm64 -t mangatasolutions/aggregator:latest -f aggregator/Dockerfile .
docker buildx build --load --platform linux/amd64,linux/arm64 -t mangatasolutions/operator:latest -f operator/Dockerfile .
# KO_DOCKER_REPO=mangatasolutions/aggregator ko build --bare aggregator/cmd/main.go --platform=linux/arm64,linux/amd64
# KO_DOCKER_REPO=mangatasolutions/operator ko build --bare operator/cmd/main.go --platform=linux/arm64,linux/amd64
docker-start-everything: docker-build-and-publish-images ## starts aggregator and operator docker containers
docker compose pull && docker compose up

Expand Down
8 changes: 5 additions & 3 deletions aggregator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM golang:1.21 as build
FROM --platform=$BUILDPLATFORM golang:1.21 as build
ARG TARGETOS
ARG TARGETARCH

WORKDIR /app

Expand All @@ -7,9 +9,9 @@ RUN go mod download && go mod tidy && go mod verify

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o /aggregator aggregator/cmd/main.go
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /aggregator aggregator/cmd/main.go

FROM debian:buster-slim
FROM debian:stable-slim
WORKDIR /app
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /aggregator /aggregator
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ services:
- ./:/app
command:
- --config
# - config-files/aggregator.yaml
- config-files/aggregator-docker-compose.yaml
- --credible-squaring-deployment
- contracts/script/output/31337/credible_squaring_avs_deployment_output.json
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.21.0

require (
github.com/Layr-Labs/eigensdk-go v0.0.8
github.com/ethereum/go-ethereum v1.13.4
github.com/ethereum/go-ethereum v1.13.5
github.com/prometheus/client_golang v1.17.0
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.26.0
Expand Down Expand Up @@ -42,7 +42,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
Expand All @@ -53,7 +53,7 @@ require (
github.com/docker/docker v24.0.6+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/ethereum/c-kzg-4844 v0.3.1 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHH
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/crate-crypto/go-kzg-4844 v0.3.0 h1:UBlWE0CgyFqqzTI+IFyCzA7A3Zw4iip6uzRv5NIXG0A=
github.com/crate-crypto/go-kzg-4844 v0.3.0/go.mod h1:SBP7ikXEgDnUPONgm33HtuDZEDtWa3L4QtN1ocJSEQ4=
github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA=
github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
Expand Down Expand Up @@ -128,8 +130,12 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/ethereum/c-kzg-4844 v0.3.1 h1:sR65+68+WdnMKxseNWxSJuAv2tsUrihTpVBTfM/U5Zg=
github.com/ethereum/c-kzg-4844 v0.3.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-ethereum v1.13.4 h1:25HJnaWVg3q1O7Z62LaaI6S9wVq8QCw3K88g8wEzrcM=
github.com/ethereum/go-ethereum v1.13.4/go.mod h1:I0U5VewuuTzvBtVzKo7b3hJzDhXOUtn9mJW7SsIPB0Q=
github.com/ethereum/go-ethereum v1.13.5 h1:U6TCRciCqZRe4FPXmy1sMGxTfuk8P7u2UoinF3VbaFk=
github.com/ethereum/go-ethereum v1.13.5/go.mod h1:yMTu38GSuyxaYzQMViqNmQ1s3cE84abZexQmTgenWk0=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
Expand Down
8 changes: 5 additions & 3 deletions operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM golang:1.21 as build
FROM --platform=$BUILDPLATFORM golang:1.21 as build
ARG TARGETOS
ARG TARGETARCH

WORKDIR /app

Expand All @@ -7,9 +9,9 @@ RUN go mod download && go mod tidy && go mod verify

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o /operator operator/cmd/main.go
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /operator operator/cmd/main.go

FROM debian:buster-slim
FROM debian:stable-slim
WORKDIR /app
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /operator /operator
Expand Down
23 changes: 23 additions & 0 deletions ops/helm-charts/anvil-testnet/.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/
5 changes: 5 additions & 0 deletions ops/helm-charts/anvil-testnet/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: anvil-testnet
description: A Helm chart for deploying forge's anvil testnet
type: application
version: 0.1.0

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions ops/helm-charts/anvil-testnet/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{/*
Useful links:
https://itnext.io/helm-reusable-chart-named-templates-and-a-generic-chart-for-multiple-applications-13d9b26e9244
https://www.replex.io/blog/9-best-practices-and-examples-for-working-with-kubernetes-labels
*/}}

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

{{/*
Common labels
*/}}
{{- define "anvil.labels" -}}
{{ include "anvil.selectorLabels" . }}
heritage: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "anvil.selectorLabels" -}}
application: {{ include "anvil.name" . }}
{{- end }}
7 changes: 7 additions & 0 deletions ops/helm-charts/anvil-testnet/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "anvil.name" . }}-configmap
labels: {{- include "anvil.labels" . | nindent 4 }}
data:
{{ (.Files.Glob "files/*").AsConfig | indent 2 }}
Loading
Loading