diff --git a/.github/chart_schema.yaml b/.github/chart_schema.yaml new file mode 100644 index 0000000..af357f4 --- /dev/null +++ b/.github/chart_schema.yaml @@ -0,0 +1,37 @@ +name: str() +home: str(required=False) +version: str() +apiVersion: str() +appVersion: any(str(), num(), required=False) +description: str(required=False) +keywords: list(str(), required=False) +sources: list(str(), required=False) +maintainers: list(include('maintainer'), required=False) +dependencies: list(include('dependency'), required=False) +icon: str(required=False) +engine: str(required=False) +condition: str(required=False) +tags: str(required=False) +deprecated: bool(required=False) +kubeVersion: str(required=False) +annotations: map(str(), str(), required=False) +type: str(required=False) +--- +maintainer: + name: str() + email: str(required=False) + url: str(required=False) +--- +dependency: + name: str() + version: str() + repository: str(required=False) + condition: str(required=False) + tags: list(str(), required=False) + enabled: bool(required=False) + import-values: any(list(str()), list(include('import-value')), required=False) + alias: str(required=False) +--- +import-value: + child: str() + parent: str() \ No newline at end of file diff --git a/.github/lintconf.yaml b/.github/lintconf.yaml new file mode 100644 index 0000000..6789bc5 --- /dev/null +++ b/.github/lintconf.yaml @@ -0,0 +1,42 @@ +--- +rules: + braces: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + max-spaces-before: 0 + max-spaces-after: 1 + commas: + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + require-starting-space: true + min-spaces-from-content: 2 + document-end: disable + document-start: disable # No --- to start a file + empty-lines: + max: 2 + max-start: 0 + max-end: 0 + hyphens: + max-spaces-after: 1 + indentation: + spaces: consistent + indent-sequences: whatever # - list indentation will handle both indentation and without + check-multi-line-strings: false + key-duplicates: enable + line-length: disable # Lines can be any length + new-line-at-end-of-file: enable + new-lines: + type: unix + trailing-spaces: enable + truthy: + level: warning \ No newline at end of file diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 8628319..115dba6 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -25,14 +25,6 @@ jobs: uses: docker/build-push-action@v4 with: context: . - file: docker/Dockerfile.cloud + file: docker/Dockerfile push: true - tags: scrolltech/sdk-cloud-prover:${{ github.ref_name }},scrolltech/sdk-cloud-prover:latest - - # - name: Build and push local Docker image - # uses: docker/build-push-action@v4 - # with: - # context: . - # file: docker/Dockerfile.local - # push: true - # tags: scrolltech/sdk-local-prover:${{ github.ref_name }},scrolltech/sdk-local-prover:latest + tags: snarkify/snarkify-scroll-proving-sdk:${{ github.ref_name }},snarkify/snarkify-scroll-proving-sdk:latest diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml new file mode 100644 index 0000000..6136324 --- /dev/null +++ b/.github/workflows/publish-chart.yaml @@ -0,0 +1,104 @@ +name: Lint, test and publish charts + +on: + push: + branches: [ main ] + paths: + - 'charts/**' + +jobs: + helm-chart-testing: + name: chart-testing + runs-on: ubuntu-latest + environment: test + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: v3.12.1 + + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.0 + + - name: Helm registry login + run: | + # TODO: Update this line + helm registry login ghcr.io/scroll-tech/helm/scroll-sdk --username ${{ github.actor }} --password ${{ secrets.HELM_GITHUB_PASSWORD }} + env: + HELM_GITHUB_PASSWORD: "${{ secrets.HELM_GITHUB_PASSWORD }}" + + # List chart change except scroll-sdk + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --excluded-charts scroll-sdk --target-branch ${{ github.event.repository.default_branch }} ) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --config ct.yaml --excluded-charts scroll-sdk --target-branch ${{ github.event.repository.default_branch }} + + publish-ghcr: + name: publish-to-github + runs-on: ubuntu-latest + needs: + - helm-chart-testing + outputs: + charts: ${{ steps.list-changed.outputs.changed }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: dorny/paths-filter@v2 + id: filter + with: + base: ${{ github.event.repository.default_branch }} + list-files: shell + filters: | + addedOrModified: + - added|modified: 'charts/**' + + - name: Helm registry login + run: | + # TODO: Update this line + helm registry login ghcr.io/scroll-tech/helm/scroll-sdk --username ${{ github.actor }} --password ${{ secrets.HELM_GITHUB_PASSWORD }} + env: + HELM_GITHUB_PASSWORD: "${{ secrets.HELM_GITHUB_PASSWORD }}" + + - name: Push chart to ghcr + if: steps.filter.outputs.addedOrModified == 'true' + env: + HELM_EXPERIMENTAL_OCI: 1 + run: | + set -x + CHARTS=() + PATHS=(${{ steps.filter.outputs.addedOrModified_files }}) + echo ${PATHS} + # Get only the chart paths + for i in "${PATHS[@]}" + do + chart=$(echo $i | awk -F "/" '{print $2}') + done + # Remove duplicates + CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` ) + echo "CHARTS: ${CHARTS[@]}" + for chart in ${CHARTS[@]}; do + helm dependencies build charts/$chart + helm package charts/$chart + export CHART_VERSION=$(grep 'version:' charts/$chart/Chart.yaml | head -n1 | awk '{ print $2 }') + # TODO: Update this line + helm push $chart-${CHART_VERSION}.tgz oci://ghcr.io/scroll-tech/scroll-sdk/helm + done \ No newline at end of file diff --git a/.github/workflows/publish-dev-chart.yaml b/.github/workflows/publish-dev-chart.yaml new file mode 100644 index 0000000..e69de29 diff --git a/charts/snarkify-scroll-proving-sdk/.helmignore b/charts/snarkify-scroll-proving-sdk/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/snarkify-scroll-proving-sdk/.helmignore @@ -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/ diff --git a/charts/snarkify-scroll-proving-sdk/Chart.yaml b/charts/snarkify-scroll-proving-sdk/Chart.yaml new file mode 100644 index 0000000..63f314d --- /dev/null +++ b/charts/snarkify-scroll-proving-sdk/Chart.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v2 +description: A chart for Scroll SDK to generate proofs in Snarkify platform. +name: snarkify-scroll-proving-sdk +version: 0.0.1 +kubeVersion: ">=1.22.0-0" +maintainers: + - name: snarkify + email: support@snarkify.io +dependencies: + - name: common + repository: "oci://ghcr.io/scroll-tech/scroll-sdk/helm" + version: 1.5.1 +type: application + + diff --git a/charts/snarkify-scroll-proving-sdk/templates/common.yaml b/charts/snarkify-scroll-proving-sdk/templates/common.yaml new file mode 100644 index 0000000..ed32775 --- /dev/null +++ b/charts/snarkify-scroll-proving-sdk/templates/common.yaml @@ -0,0 +1,14 @@ +--- +{{- include "scroll.common.loader.init" . }} + +{{- define "app-template.hardcodedValues" -}} +# Set the nameOverride based on the release name if no override has been set +{{ if not .Values.global.nameOverride }} +global: + nameOverride: "{{ .Release.Name }}" +{{ end }} +{{- end -}} +{{- $_ := mergeOverwrite .Values (include "app-template.hardcodedValues" . | fromYaml) -}} + +{{/* Render the templates */}} +{{ include "scroll.common.loader.generate" . }} diff --git a/charts/snarkify-scroll-proving-sdk/templates/config-file.yaml b/charts/snarkify-scroll-proving-sdk/templates/config-file.yaml new file mode 100644 index 0000000..57ca472 --- /dev/null +++ b/charts/snarkify-scroll-proving-sdk/templates/config-file.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-config + labels: + {{- include "scroll-sdk.labels" $ | nindent 4 }} +data: + config.json: | +{{ .Values.scrollConfig | indent 4 }} \ No newline at end of file diff --git a/charts/snarkify-scroll-proving-sdk/templates/helpers.tpl b/charts/snarkify-scroll-proving-sdk/templates/helpers.tpl new file mode 100644 index 0000000..82b6134 --- /dev/null +++ b/charts/snarkify-scroll-proving-sdk/templates/helpers.tpl @@ -0,0 +1,47 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "scroll-sdk.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "scroll-sdk.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} +{{/* +Create chart name and build as used by the chart label. +*/}} +{{- define "scroll-sdk.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} +{{/* +Common labels +*/}} +{{- define "scroll-sdk.labels" -}} +helm.sh/chart: {{ include "scroll-sdk.chart" . }} +{{ include "scroll-sdk.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/build: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} +{{/* +Selector labels +*/}} +{{- define "scroll-sdk.selectorLabels" -}} +app.kubernetes.io/name: {{ include "scroll-sdk.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} \ No newline at end of file diff --git a/charts/snarkify-scroll-proving-sdk/values.yaml b/charts/snarkify-scroll-proving-sdk/values.yaml new file mode 100644 index 0000000..3b63d31 --- /dev/null +++ b/charts/snarkify-scroll-proving-sdk/values.yaml @@ -0,0 +1,89 @@ +--- +global: + nameOverride: &app_name snarkify-scroll-proving-sdk + fullnameOverride: *app_name + +image: + repository: snarkify/snarkify-scroll-proving-sdk + pullPolicy: Always + tag: v0.0.1 + +command: + - "/bin/sh" + - "-c" + - "exec snarkify --config /sdk_prover/config.json --service-id {{ .Values.serviceId }}" + +resources: + requests: + memory: "100Mi" + cpu: "50m" + limits: + memory: "500Mi" + cpu: "100m" + +persistence: + config: + enabled: true + type: configMap + mountPath: /sdk_prover/ + name: snarkify-scroll-proving-sdk-config + keys: + enabled: true + type: pvc + mountPath: /keys/ + size: 10Mi + accessMode: ReadWriteOnce + +service: + main: + enabled: true + ports: + http: + enabled: true + port: 80 + +defaultProbes: &default_probes + enabled: true + custom: true + spec: + httpGet: + path: "/" + port: 80 + +probes: + liveness: + <<: *default_probes + readiness: + <<: *default_probes + startup: + <<: *default_probes + +# scrollConfig should be overwritten the config in json format. See the example below. +scrollConfig: | + {} +# { +# "prover_name_prefix": "snarkify_", +# "keys_dir": "keys", +# "coordinator": { +# "base_url": "https://coordinator-api.scrollsdk", +# "retry_count": 3, +# "retry_wait_time_sec": 5, +# "connection_timeout_sec": 60 +# }, +# "l2geth": { +# "endpoint": "https://l2-rpc.scrollsdk" +# }, +# "prover": { +# "circuit_type": 1, +# "circuit_version": "v0.13.1", +# "n_workers": 1, +# "cloud": { +# "base_url": "https://api.snarkify.io", +# "api_key": , +# "retry_count": 3, +# "retry_wait_time_sec": 5, +# "connection_timeout_sec": 60 +# } +# } +# } +serviceId: "" \ No newline at end of file diff --git a/charts/snarkify-scroll-proving-sdk/values/production.yaml b/charts/snarkify-scroll-proving-sdk/values/production.yaml new file mode 100644 index 0000000..51651c4 --- /dev/null +++ b/charts/snarkify-scroll-proving-sdk/values/production.yaml @@ -0,0 +1,27 @@ +scrollConfig: | + { + "prover_name_prefix": "snarkify_", + "keys_dir": "keys", + "coordinator": { + "base_url": "https://coordinator-api.scrollsdk", + "retry_count": 3, + "retry_wait_time_sec": 5, + "connection_timeout_sec": 60 + }, + "l2geth": { + "endpoint": "https://l2-rpc.scrollsdk" + }, + "prover": { + "circuit_type": 1, + "circuit_version": "v0.13.1", + "n_workers": 1, + "cloud": { + "base_url": "https://api.snarkify.io", + "api_key": , + "retry_count": 3, + "retry_wait_time_sec": 5, + "connection_timeout_sec": 60 + } + } + } +serviceId: "" \ No newline at end of file