diff --git a/charts/arbitrum-nitro/README.md b/charts/arbitrum-nitro/README.md index a84d2176..a0a2429b 100644 --- a/charts/arbitrum-nitro/README.md +++ b/charts/arbitrum-nitro/README.md @@ -94,15 +94,19 @@ We do not recommend that you upgrade the application by overriding `image.tag`. | nameOverride | | string | `""` | | nitro.affinity | | object | `{}` | | nitro.affinityPresets.antiAffinityByHostname | Configure anti-affinity rules to prevent multiple arbitrum instances on the same host | bool | `true` | - | nitro.config | Nitro configuration parameters | object | `{"chainId":42161,"extraArgs":[],"httpApi":"net,web3,eth,debug","nodeRpcClassicRedirect":"","parentChainConnectionURL":""}` | + | nitro.config | Nitro configuration parameters | object | `{"chainId":42161,"extraArgs":[],"httpApi":"net,web3,eth,debug","nodeRpcClassicRedirect":null,"parentChainConnectionURL":"CHANGE_ME_RPC_URL"}` | | nitro.config.extraArgs | Additional CLI arguments to pass to `nitro` | list | `[]` | | nitro.extraLabels | Extra labels to attach to the Pod for matching against | object | `{}` | | nitro.nodeSelector | | object | `{}` | | nitro.podAnnotations | Annotations for the `Pod` | object | `{}` | | nitro.podSecurityContext | Pod-wide security context | object | `{"fsGroup":101337,"runAsGroup":101337,"runAsNonRoot":true,"runAsUser":101337}` | | nitro.resources | | object | `{}` | - | nitro.restoreSnapshot.enabled | Enable initialising arbitrum state from a remote snapshot | bool | `false` | + | nitro.restoreSnapshot.chunkSize | | int | `1000000000` | + | nitro.restoreSnapshot.cleanSubpath | | bool | `true` | + | nitro.restoreSnapshot.enabled | Enable initialising arbitrum state from a remote snapshot | bool | `true` | + | nitro.restoreSnapshot.extraTarArgs | | string | `nil` | | nitro.restoreSnapshot.snapshotUrl | URL for snapshot to download and extract to restore state | string | `"https://snapshot.arbitrum.foundation/arb1/nitro-archive.tar"` | + | nitro.restoreSnapshot.subpath | | string | `"data/nitro"` | | nitro.service.ports.http-metrics | Service Port to expose Prometheus metrics on | int | `6070` | | nitro.service.ports.http-rpc | Service Port to expose JSON-RPC interface on | int | `8547` | | nitro.service.ports.ws-rpc | Service Port to expose engineAPI interface on | int | `8548` | diff --git a/charts/arbitrum-nitro/templates/arbitrum-nitro/statefulset.yaml b/charts/arbitrum-nitro/templates/arbitrum-nitro/statefulset.yaml index ae85d128..7939a903 100644 --- a/charts/arbitrum-nitro/templates/arbitrum-nitro/statefulset.yaml +++ b/charts/arbitrum-nitro/templates/arbitrum-nitro/statefulset.yaml @@ -5,14 +5,16 @@ {{/* Generate the array of options for nitro */}} +{{- $nitroArgs := list }} {{- with $.Values.nitro.config }} -{{- $args := list }} -{{- $args := concat $args (list (print "--parent-chain.connection.url=" .parentChainConnectionURL)) }} -{{- $args := concat $args (list (print "--node.rpc.classic-redirect=" .nodeRpcClassicRedirect)) }} -{{- $args := concat $args (list (print "--chain.id=" .chainId)) }} -{{- $args := concat $args (list (print "--http.api=" .httpApi)) }} -{{- $args := concat $args .extraArgs }} -{{- $args := concat $args (list +{{- $nitroArgs = concat $nitroArgs (list (print "--parent-chain.connection.url=" .parentChainConnectionURL)) }} +{{- $nitroArgs = concat $nitroArgs (list (print "--chain.id=" .chainId)) }} +{{- $nitroArgs = concat $nitroArgs (list (print "--http.api=" .httpApi)) }} +{{- if not (empty .nodeRpcClassicRedirect) }} +{{- $nitroArgs = concat $nitroArgs (list (print "--node.rpc.classic-redirect=" .nodeRpcClassicRedirect)) }} +{{- end }} +{{- $nitroArgs = concat $nitroArgs .extraArgs }} +{{- $nitroArgs = concat $nitroArgs (list "--persistent.chain=/storage/data" "--persistent.global-config=/storage" "--http.addr=0.0.0.0" @@ -20,7 +22,6 @@ Generate the array of options for nitro "--metrics" "--metrics-server.addr=0.0.0.0" ) }} -{{- $_ := set $values.config "_computedArgs" $args }} {{- end }} #{{ $values.config._computedArgs | toYaml | indent 1 | replace "\n" "\n#" }} @@ -73,48 +74,28 @@ spec: initContainers: {{- if $values.restoreSnapshot.enabled }} - name: init-snapshot - image: busybox:stable + image: ghcr.io/graphops/docker-builds/init-stream-download:main imagePullPolicy: IfNotPresent securityContext: privileged: true - command: - - sh - - -c - - | - set -x - STORAGE_PATH="/storage" - if [ "${SNAPSHOT_RESTORE_PATH}" == "" ]; then - SNAPSHOT_RESTORE_PATH="$STORAGE_PATH/data/nitro" - else - SNAPSHOT_RESTORE_PATH="${SNAPSHOT_RESTORE_PATH}" - fi - # If enabled and snapshot URL has been provided, restore snapshot - if [ "${RESTORE_SNAPSHOT}" = "true" ] && [ "${SNAPSHOT_URL}" != "" ]; then - echo "Snapshot restoration enabled" - if [ ! -f "$STORAGE_PATH/from_snapshot" ] || [ "$(cat $STORAGE_PATH/from_snapshot)" != "${SNAPSHOT_URL}" ]; then - echo "Clearing existing chaindata..." - rm -rf "$SNAPSHOT_RESTORE_PATH" - echo "Downloading and extracting $SNAPSHOT_URL..." - mkdir -p "$SNAPSHOT_RESTORE_PATH" - wget -c --no-check-certificate -O - "${SNAPSHOT_URL}" | tar -xv -C "$SNAPSHOT_RESTORE_PATH" - [ "$?" != "0" ] && echo "Streaming download failed" && exit 1 - echo "${SNAPSHOT_URL}" > ${STORAGE_PATH}/from_snapshot - else - echo "Snapshot configuration already restored, continuing..." - fi - else - echo "Snapshot restoration not enabled, skipping..." - fi volumeMounts: - name: storage mountPath: /storage env: + - name: DIR + value: "/storage" - name: RESTORE_SNAPSHOT - value: "true" - - name: SNAPSHOT_RESTORE_PATH - value: {{ $values.restoreSnapshot.snapshotRestorePath | default "" }} - - name: SNAPSHOT_URL + value: {{ $values.restoreSnapshot.enabled }} + - name: SUBPATH + value: {{ $values.restoreSnapshot.subpath }} + - name: RM_SUBPATH + value: {{ $values.restoreSnapshot.cleanSubpath }} + - name: URL value: {{ $values.restoreSnapshot.snapshotUrl }} + - name: TAR_ARGS + value: {{ $values.restoreSnapshot.extraTarArgs }} + - name: CHUNK_SIZE + value: {{ $values.restoreSnapshot.chunkSize }} {{- with $values.env }} {{- range $key, $val := .}} - name: {{ $key }} @@ -137,10 +118,10 @@ spec: - | set -ex; exec nitro \ - {{- range $val := initial $values.config._computedArgs }} + {{- range $val := initial $nitroArgs }} {{ $val }} \ {{- end }} - {{ last $values.config._computedArgs }} + {{ last $nitroArgs }} ports: - name: ws-rpc containerPort: 8548 diff --git a/charts/arbitrum-nitro/values.yaml b/charts/arbitrum-nitro/values.yaml index 0336cc65..a020f905 100644 --- a/charts/arbitrum-nitro/values.yaml +++ b/charts/arbitrum-nitro/values.yaml @@ -70,8 +70,8 @@ grafana: nitro: # -- Nitro configuration parameters config: - nodeRpcClassicRedirect: "" - parentChainConnectionURL: "" + nodeRpcClassicRedirect: null + parentChainConnectionURL: "CHANGE_ME_RPC_URL" chainId: 42161 httpApi: net,web3,eth,debug # -- Additional CLI arguments to pass to `nitro` @@ -92,9 +92,13 @@ nitro: restoreSnapshot: # -- Enable initialising arbitrum state from a remote snapshot - enabled: false + enabled: true # -- URL for snapshot to download and extract to restore state snapshotUrl: "https://snapshot.arbitrum.foundation/arb1/nitro-archive.tar" + subpath: "data/nitro" + cleanSubpath: true + chunkSize: 1000000000 + extraTarArgs: null # Increasing the grace termination period prevents Kubernetes # from killing the node process prematurely. Premature shutdown