Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion charts/nitro/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ maintainers:

type: application

version: 0.7.2
version: 0.7.3

appVersion: "v3.6.2-5b41a2d"
8 changes: 6 additions & 2 deletions charts/nitro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ helm install xai offchainlabs/nitro -f values.yaml
### Nitro Deployment Options

| Name | Description | Value |
|------------------------------------------------------------|---------------------------------------------------------------------------------|---------------------------------------------------------------------|
| ---------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `lifecycle` | Lifecycle hooks configuration | `{}` |
| `extraEnv` | Additional environment variables for the container | `{}` |
| `replicaCount` | Number of replicas to deploy | `1` |
Expand All @@ -94,8 +94,12 @@ helm install xai offchainlabs/nitro -f values.yaml
| `updateStrategy.type` | Update strategy type | `RollingUpdate` |
| `env.splitvalidator.goMemLimit.enabled` | Enable setting the garbage cleanup limit in Go for the split validator | `true` |
| `env.splitvalidator.goMemLimit.multiplier` | The multiplier of available memory to use for the split validator | `0.75` |
| `env.splitvalidator.goMaxProcs.enabled` | Enable setting GOMAXPROCS for the split validator | `true` |
| `env.splitvalidator.goMaxProcs.multiplier` | The multiplier to use for CPU request (default 2) | `2` |
| `env.nitro.goMemLimit.enabled` | Enable setting the garbage cleanup limit in Go for nitro | `true` |
| `env.nitro.goMemLimit.multiplier` | The multiplier of available memory to use for nitro | `0.9` |
| `env.nitro.goMaxProcs.enabled` | Enable setting GOMAXPROCS for nitro | `false` |
| `env.nitro.goMaxProcs.multiplier` | The multiplier to use for CPU request (default 2) | `2` |
| `env.resourceMgmtMemFreeLimit.enabled` | Enable nitro resource management | `false` |
| `env.resourceMgmtMemFreeLimit.multiplier` | The multiplier of available memory to use | `0.05` |
| `env.blockValidatorMemFreeLimit.enabled` | Enable block validator memory management | `false` |
Expand Down Expand Up @@ -180,7 +184,7 @@ helm install xai offchainlabs/nitro -f values.yaml
### Stateless Validator

| Name | Description | Value |
|-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|-------------------------------|
| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------- |
| `validator.enabled` | Enable the stateless validator | `false` |
| `validator.splitvalidator.deployments` | List of deployments for the split validator. Each deploymeny can have its own image, config, etc. | `[]` |
| `validator.splitvalidator.global.replicaCount` | Number of replicas for the split validator | `1` |
Expand Down
153 changes: 142 additions & 11 deletions charts/nitro/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ nitro args
{{- if and (get .Values.env.nitro.goMemLimit "enabled" | default false) (not $envPrefix) -}}
{{- fail "configmap.data.conf.env-prefix must be set when goMemLimit is enabled" -}}
{{- end -}}
{{- if and .Values.resources .Values.resources.limits .Values.resources.limits.memory -}}

{{/* Memory-based environment variables */}}
{{- if and .Values.resources .Values.resources.limits .Values.resources.limits.memory .Values.env.nitro.goMemLimit.enabled -}}
{{- $memory := .Values.resources.limits.memory -}}
{{- $value := regexFind "^\\d*\\.?\\d+" $memory | float64 -}}
{{- $unit := regexFind "[A-Za-z]+" $memory -}}
Expand All @@ -107,23 +109,98 @@ nitro args
{{- else if eq $unit "Mi" -}}
{{- $valueMi = $value -}}
{{- end }}
{{- if $.Values.env.nitro.goMemLimit.enabled }}
- name: GOMEMLIMIT
value: {{ printf "%dMiB" (int (mulf $valueMi ($.Values.env.nitro.goMemLimit.multiplier | default 0.9))) }}
value: {{ printf "%dMiB" (int (mulf $valueMi ($.Values.env.nitro.goMemLimit.multiplier | default 0.9))) | quote }}
{{- end }}

{{- if and .Values.resources .Values.resources.limits .Values.resources.limits.memory .Values.env.resourceMgmtMemFreeLimit.enabled -}}
{{- $memory := .Values.resources.limits.memory -}}
{{- $value := regexFind "^\\d*\\.?\\d+" $memory | float64 -}}
{{- $unit := regexFind "[A-Za-z]+" $memory -}}
{{- $valueMi := 0.0 -}}
{{- if eq $unit "Gi" -}}
{{- $valueMi = mulf $value 1024 -}}
{{- else if eq $unit "Mi" -}}
{{- $valueMi = $value -}}
{{- end }}
{{- if $.Values.env.resourceMgmtMemFreeLimit.enabled }}
- name: {{ $envPrefix }}_NODE_RESOURCE__MGMT_MEM__FREE__LIMIT
value: {{ printf "%dB" (int (mulf $valueMi ($.Values.env.resourceMgmtMemFreeLimit.multiplier | default 0.05) 1048576)) }}
value: {{ printf "%dB" (int (mulf $valueMi ($.Values.env.resourceMgmtMemFreeLimit.multiplier | default 0.05) 1048576)) | quote }}
{{- end }}

{{- if and .Values.resources .Values.resources.limits .Values.resources.limits.memory .Values.env.blockValidatorMemFreeLimit.enabled -}}
{{- $memory := .Values.resources.limits.memory -}}
{{- $value := regexFind "^\\d*\\.?\\d+" $memory | float64 -}}
{{- $unit := regexFind "[A-Za-z]+" $memory -}}
{{- $valueMi := 0.0 -}}
{{- if eq $unit "Gi" -}}
{{- $valueMi = mulf $value 1024 -}}
{{- else if eq $unit "Mi" -}}
{{- $valueMi = $value -}}
{{- end }}
{{- if $.Values.env.blockValidatorMemFreeLimit.enabled }}
- name: {{ $envPrefix }}_NODE_BLOCK__VALIDATOR_MEMORY__FREE__LIMIT
value: {{ printf "%dB" (int (mulf $valueMi ($.Values.env.blockValidatorMemFreeLimit.multiplier | default 0.05) 1048576)) }}
value: {{ printf "%dB" (int (mulf $valueMi ($.Values.env.blockValidatorMemFreeLimit.multiplier | default 0.05) 1048576)) | quote }}
{{- end }}

{{/* CPU-based environment variables */}}
{{- if .Values.env.nitro.goMaxProcs.enabled -}}
{{- $cpuRequest := 0.0 -}}
{{- $cpuLimit := 0.0 -}}
{{- $multiplier := $.Values.env.nitro.goMaxProcs.multiplier | default 2 -}}

{{/* Get CPU request if set */}}
{{- if and .Values.resources .Values.resources.requests .Values.resources.requests.cpu -}}
{{- $cpuRequestStr := toString .Values.resources.requests.cpu -}}
{{/* Handle different CPU formats: cores (1), millicores (1000m), or decimal (0.5) */}}
{{- if contains "m" $cpuRequestStr -}}
{{/* Convert millicores to cores (e.g., 500m -> 0.5) */}}
{{- $milliCores := regexFind "^\\d+" $cpuRequestStr | int -}}
{{- $cpuRequest = mulf (divf $milliCores 1000.0) $multiplier -}}
{{- else -}}
{{/* Handle decimal or whole cores */}}
{{- $cpuRequestVal := regexFind "^\\d*\\.?\\d+" $cpuRequestStr | float64 -}}
{{- $cpuRequest = mulf $cpuRequestVal $multiplier -}}
{{- end -}}
{{- end -}}

{{/* Get CPU limit if set */}}
{{- if and .Values.resources .Values.resources.limits .Values.resources.limits.cpu -}}
{{- $cpuLimitStr := toString .Values.resources.limits.cpu -}}
{{/* Handle different CPU formats: cores (1), millicores (1000m), or decimal (0.5) */}}
{{- if contains "m" $cpuLimitStr -}}
{{/* Convert millicores to cores (e.g., 500m -> 0.5) */}}
{{- $milliCores := regexFind "^\\d+" $cpuLimitStr | int -}}
{{- $cpuLimit = divf $milliCores 1000.0 -}}
{{- else -}}
{{/* Handle decimal or whole cores */}}
{{- $cpuLimit = regexFind "^\\d*\\.?\\d+" $cpuLimitStr | float64 -}}
{{- end -}}
{{- end -}}

{{/* Only set GOMAXPROCS if CPU requests or limits are defined */}}
{{- if or (gt $cpuRequest 0.0) (gt $cpuLimit 0.0) -}}
{{/* Use the higher value between CPU request*multiplier and CPU limit */}}
{{- $maxProcs := 0 -}}
{{- if gt $cpuRequest $cpuLimit -}}
{{- $maxProcs = ceil $cpuRequest | int -}}
{{- else if gt $cpuLimit 0.0 -}}
{{- $maxProcs = ceil $cpuLimit | int -}}
{{- else if gt $cpuRequest 0.0 -}}
{{- $maxProcs = ceil $cpuRequest | int -}}
{{- end -}}

{{/* Ensure GOMAXPROCS is at least 1 */}}
{{- if eq $maxProcs 0 -}}
{{- $maxProcs = 1 -}}
{{- end }}
- name: GOMAXPROCS
value: {{ $maxProcs | quote }}
{{- end }}
{{- end }}
{{- end -}}

{{- define "nitro.splitvalidator.env" -}}
{{- if and .Values.validator .Values.validator.splitvalidator .Values.validator.splitvalidator.global .Values.validator.splitvalidator.global.resources .Values.validator.splitvalidator.global.resources.limits .Values.validator.splitvalidator.global.resources.limits.memory -}}
{{/* Memory-based environment variables */}}
{{- if and .Values.validator .Values.validator.splitvalidator .Values.validator.splitvalidator.global .Values.validator.splitvalidator.global.resources .Values.validator.splitvalidator.global.resources.limits .Values.validator.splitvalidator.global.resources.limits.memory .Values.env.splitvalidator.goMemLimit.enabled -}}
{{- $memory := .Values.validator.splitvalidator.global.resources.limits.memory -}}
{{- $value := regexFind "^\\d*\\.?\\d+" $memory | float64 -}}
{{- $unit := regexFind "[A-Za-z]+" $memory -}}
Expand All @@ -133,11 +210,65 @@ nitro args
{{- else if eq $unit "Mi" -}}
{{- $valueMi = $value -}}
{{- end }}
{{- if $.Values.env.splitvalidator.goMemLimit.enabled }}
- name: GOMEMLIMIT
value: {{ printf "%dMiB" (int (mulf $valueMi ($.Values.env.splitvalidator.goMemLimit.multiplier | default 0.75))) }}
value: {{ printf "%dMiB" (int (mulf $valueMi ($.Values.env.splitvalidator.goMemLimit.multiplier | default 0.75))) | quote }}
{{- end }}

{{/* CPU-based environment variables */}}
{{- if .Values.env.splitvalidator.goMaxProcs.enabled -}}
{{- $cpuRequest := 0.0 -}}
{{- $cpuLimit := 0.0 -}}
{{- $multiplier := $.Values.env.splitvalidator.goMaxProcs.multiplier | default 2 -}}

{{/* Get CPU request if set */}}
{{- if and .Values.validator.splitvalidator.global.resources .Values.validator.splitvalidator.global.resources.requests .Values.validator.splitvalidator.global.resources.requests.cpu -}}
{{- $cpuRequestStr := toString .Values.validator.splitvalidator.global.resources.requests.cpu -}}
{{/* Handle different CPU formats: cores (1), millicores (1000m), or decimal (0.5) */}}
{{- if contains "m" $cpuRequestStr -}}
{{/* Convert millicores to cores (e.g., 500m -> 0.5) */}}
{{- $milliCores := regexFind "^\\d+" $cpuRequestStr | int -}}
{{- $cpuRequest = mulf (divf $milliCores 1000.0) $multiplier -}}
{{- else -}}
{{/* Handle decimal or whole cores */}}
{{- $cpuRequestVal := regexFind "^\\d*\\.?\\d+" $cpuRequestStr | float64 -}}
{{- $cpuRequest = mulf $cpuRequestVal $multiplier -}}
{{- end -}}
{{- end -}}

{{/* Get CPU limit if set */}}
{{- if and .Values.validator.splitvalidator.global.resources .Values.validator.splitvalidator.global.resources.limits .Values.validator.splitvalidator.global.resources.limits.cpu -}}
{{- $cpuLimitStr := toString .Values.validator.splitvalidator.global.resources.limits.cpu -}}
{{/* Handle different CPU formats: cores (1), millicores (1000m), or decimal (0.5) */}}
{{- if contains "m" $cpuLimitStr -}}
{{/* Convert millicores to cores (e.g., 500m -> 0.5) */}}
{{- $milliCores := regexFind "^\\d+" $cpuLimitStr | int -}}
{{- $cpuLimit = divf $milliCores 1000.0 -}}
{{- else -}}
{{/* Handle decimal or whole cores */}}
{{- $cpuLimit = regexFind "^\\d*\\.?\\d+" $cpuLimitStr | float64 -}}
{{- end -}}
{{- end -}}

{{/* Only set GOMAXPROCS if CPU requests or limits are defined */}}
{{- if or (gt $cpuRequest 0.0) (gt $cpuLimit 0.0) -}}
{{/* Use the higher value between CPU request*multiplier and CPU limit */}}
{{- $maxProcs := 0 -}}
{{- if gt $cpuRequest $cpuLimit -}}
{{- $maxProcs = ceil $cpuRequest | int -}}
{{- else if gt $cpuLimit 0.0 -}}
{{- $maxProcs = ceil $cpuLimit | int -}}
{{- else if gt $cpuRequest 0.0 -}}
{{- $maxProcs = ceil $cpuRequest | int -}}
{{- end -}}

{{/* Ensure GOMAXPROCS is at least 1 */}}
{{- if eq $maxProcs 0 -}}
{{- $maxProcs = 1 -}}
{{- end }}
- name: GOMAXPROCS
value: {{ $maxProcs | quote }}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Expand Down Expand Up @@ -194,4 +325,4 @@ Currently primarily used for stateless validator configuration
{{- end -}}

{{- define "nitro.lifecycle" -}}
{{- end -}}
{{- end -}}
10 changes: 10 additions & 0 deletions charts/nitro/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ updateStrategy:

## @param env.splitvalidator.goMemLimit.enabled Enable setting the garbage cleanup limit in Go for the split validator
## @param env.splitvalidator.goMemLimit.multiplier The multiplier of available memory to use for the split validator
## @param env.splitvalidator.goMaxProcs.enabled Enable setting GOMAXPROCS for the split validator
## @param env.splitvalidator.goMaxProcs.multiplier The multiplier to use for CPU request (default 2)
## @param env.nitro.goMemLimit.enabled Enable setting the garbage cleanup limit in Go for nitro
## @param env.nitro.goMemLimit.multiplier The multiplier of available memory to use for nitro
## @param env.nitro.goMaxProcs.enabled Enable setting GOMAXPROCS for nitro
## @param env.nitro.goMaxProcs.multiplier The multiplier to use for CPU request (default 2)
## @param env.resourceMgmtMemFreeLimit.enabled Enable nitro resource management
## @param env.resourceMgmtMemFreeLimit.multiplier The multiplier of available memory to use
## @param env.blockValidatorMemFreeLimit.enabled Enable block validator memory management
Expand All @@ -62,10 +66,16 @@ env:
goMemLimit:
enabled: true
multiplier: 0.75
goMaxProcs:
enabled: true
multiplier: 2
nitro:
goMemLimit:
enabled: true
multiplier: 0.9
goMaxProcs:
enabled: false
multiplier: 2
resourceMgmtMemFreeLimit:
enabled: false
multiplier: 0.05
Expand Down