Skip to content

Commit

Permalink
feat: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
cjorge-graphops committed Nov 14, 2023
1 parent 0049fd5 commit 29dead1
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 35 deletions.
23 changes: 17 additions & 6 deletions charts/arbitrum-nitro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,30 @@ 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":null,"parentChainConnectionURL":"CHANGE_ME_RPC_URL"}` |
| nitro.config | Nitro configuration parameters | object | `{"chain":42161,"classicURL":null,"defaultArgs":["--node.caching.archive","--core.checkpoint-gas-frequency=156250000"],"extraArgs":[],"httpRPC":{"addr":"0.0.0.0","api":"net,web3,eth,debug","cors":"*","vhosts":"*"},"metrics":{"addr":"0.0.0.0","enabled":true},"parentChainURL":"CHANGE_ME_RPC_URL"}` |
| nitro.config.chain | Chain ID, 42161 for Arbitrum One | int | `42161` |
| nitro.config.classicURL | RPC Url to Arbitrum Classic Archive node if serving classic blocks | string | `nil` |
| nitro.config.extraArgs | Additional CLI arguments to pass to `nitro` | list | `[]` |
| nitro.config.httpRPC | RPC config parameters | object | `{"addr":"0.0.0.0","api":"net,web3,eth,debug","cors":"*","vhosts":"*"}` |
| nitro.config.httpRPC.addr | Listen address | string | `"0.0.0.0"` |
| nitro.config.httpRPC.api | Enabled APIs | string | `"net,web3,eth,debug"` |
| nitro.config.httpRPC.cors | Allowed CORS domains | string | `"*"` |
| nitro.config.httpRPC.vhosts | Allowed vhosts | string | `"*"` |
| nitro.config.metrics | Metrics parameters | object | `{"addr":"0.0.0.0","enabled":true}` |
| nitro.config.metrics.addr | Listen address | string | `"0.0.0.0"` |
| nitro.config.metrics.enabled | Enable metrics | bool | `true` |
| nitro.config.parentChainURL | RPC URL to L1 chain (ethereum) | string | `"CHANGE_ME_RPC_URL"` |
| 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.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.chunkSize | Size of chunks for chunked downloading. Too small hurts performance, too big leads to more waste when it needs to be retried | int | `1000000000` |
| nitro.restoreSnapshot.cleanSubpath | Erase destination path before unpacking | bool | `true` |
| nitro.restoreSnapshot.enabled | Enable initialising arbitrum state from a remote snapshot | bool | `false` |
| nitro.restoreSnapshot.extraTarArgs | A string with extra arguments to tar command (i.e. "--strip-components=1") | 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.restoreSnapshot.subpath | Path where the snapshot should be unpacked to, relative to the volume root | 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` |
Expand Down
27 changes: 27 additions & 0 deletions charts/arbitrum-nitro/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,30 @@ Create the name of the service account to use
{{- define "arbitrum-nitro.replicas" -}}
{{- default 1 .replicaCount }}
{{- end -}}

{{/*
Generate the array of options for nitro
*/}}
{{- define "arbitrum-nitro.computedArgs" -}}
{{- $args := list
"--persistent.chain=/storage/data"
"--persistent.global-config=/storage"
}}
{{- with .config }}
{{- $args = concat $args (list (print "--parent-chain.connection.url=" .parentChainURL)) }}
{{- $args = concat $args (list (print "--chain.id=" .chain)) }}
{{- $args = concat $args (list (print "--http.api=" .httpRPC.api)) }}
{{- $args = concat $args (list (print "--http.addr=" .httpRPC.addr)) }}
{{- $args = concat $args (list (print "--http.vhosts=" .httpRPC.vhosts)) }}
{{- $args = concat $args (list (print "--http.corsdomain=" .httpRPC.cors)) }}
{{- if not (empty .classicURL) }}
{{- $args = concat $args (list (print "--node.rpc.classic-redirect=" .classicURL)) }}
{{- end }}
{{- if .metrics.enabled }}
{{- $args = concat $args (list "--metrics" (print "--metrics-server-addr" .metrics.addr)) }}
{{- end }}
{{- $args = concat $args .defaultArgs }}
{{- $args = concat $args .extraArgs }}
{{- end }}
{{ dict "computedArgs" $args | toJson }}
{{- end }}
26 changes: 2 additions & 24 deletions charts/arbitrum-nitro/templates/arbitrum-nitro/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
{{- $values := $.Values.nitro }}
{{- $componentName := "nitro" }}
{{- $componentLabel := include "arbitrum-nitro.componentLabelFor" $componentName }}

{{/*
Generate the array of options for nitro
*/}}
{{- $nitroArgs := list }}
{{- with $.Values.nitro.config }}
{{- $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"
"--http.vhosts=*"
"--metrics"
"--metrics-server.addr=0.0.0.0"
) }}
{{- end }}

#{{ $values.config._computedArgs | toYaml | indent 1 | replace "\n" "\n#" }}
{{- $nitroArgs := get (fromJson (include "arbitrum-nitro.computedArgs" $values)) "computedArgs" }}
#{{ toYaml $nitroArgs | indent 1 | replace "\n" "\n#" }}

apiVersion: apps/v1
kind: StatefulSet
Expand Down
36 changes: 31 additions & 5 deletions charts/arbitrum-nitro/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,32 @@ grafana:
nitro:
# -- Nitro configuration parameters
config:
nodeRpcClassicRedirect: null
parentChainConnectionURL: "CHANGE_ME_RPC_URL"
chainId: 42161
httpApi: net,web3,eth,debug
# -- Chain ID, 42161 for Arbitrum One
chain: 42161
# -- RPC URL to L1 chain (ethereum)
parentChainURL: "CHANGE_ME_RPC_URL"
# -- RPC Url to Arbitrum Classic Archive node if serving classic blocks
classicURL: null
# -- RPC config parameters
httpRPC:
# -- Enabled APIs
api: net,web3,eth,debug
# -- Listen address
addr: 0.0.0.0
# -- Allowed vhosts
vhosts: "*"
# -- Allowed CORS domains
cors: "*"
# -- Metrics parameters
metrics:
# -- Enable metrics
enabled: true
# -- Listen address
addr: 0.0.0.0

defaultArgs:
- "--node.caching.archive"
- "--core.checkpoint-gas-frequency=156250000"
# -- Additional CLI arguments to pass to `nitro`
extraArgs: []

Expand All @@ -92,12 +114,16 @@ nitro:

restoreSnapshot:
# -- Enable initialising arbitrum state from a remote snapshot
enabled: true
enabled: false
# -- URL for snapshot to download and extract to restore state
snapshotUrl: "https://snapshot.arbitrum.foundation/arb1/nitro-archive.tar"
# -- Path where the snapshot should be unpacked to, relative to the volume root
subpath: "data/nitro"
# -- Erase destination path before unpacking
cleanSubpath: true
# -- Size of chunks for chunked downloading. Too small hurts performance, too big leads to more waste when it needs to be retried
chunkSize: 1000000000
# -- A string with extra arguments to tar command (i.e. "--strip-components=1")
extraTarArgs: null

# Increasing the grace termination period prevents Kubernetes
Expand Down

0 comments on commit 29dead1

Please sign in to comment.