Skip to content

Add OPENAUDIO_ prefixed env vars for all configuration - #195

Merged
raymondjacobson merged 2 commits into
mainfrom
ray/openaudio-env-vars
Apr 3, 2026
Merged

Add OPENAUDIO_ prefixed env vars for all configuration#195
raymondjacobson merged 2 commits into
mainfrom
ray/openaudio-env-vars

Conversation

@raymondjacobson

@raymondjacobson raymondjacobson commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduces pkg/env package with helpers (Get, String, Bool, GetInt, GetDuration, Lookup, IsSet) that check OPENAUDIO_-prefixed keys first, then fall back to legacy names
  • Every env var now has a canonical OPENAUDIO_ version — legacy names (nodeEndpoint, delegatePrivateKey, dbUrl, etc.) continue to work but OPENAUDIO_ takes priority when both are set
  • Cloud provider vars (AWS_*, GOOGLE_*, AZURE_*) left unchanged as industry standards
  • Updates dev env files and open-audio-docs to use new names

Key mappings

Canonical Legacy
OPENAUDIO_NODE_ENDPOINT nodeEndpoint
OPENAUDIO_DELEGATE_PRIVATE_KEY delegatePrivateKey
OPENAUDIO_DELEGATE_WALLET delegateOwnerWallet
OPENAUDIO_OWNER_WALLET spOwnerWallet
OPENAUDIO_DB_URL dbUrl
OPENAUDIO_ETH_PROVIDER_URL ethProviderUrl
OPENAUDIO_ETH_REGISTRY_ADDRESS ethRegistryAddress
OPENAUDIO_EXTERNAL_ADDRESS externalAddress
OPENAUDIO_PERSISTENT_PEERS persistentPeers
OPENAUDIO_ARCHIVE archive
OPENAUDIO_RETAIN_HEIGHT retainHeight
OPENAUDIO_COMET_LOG_LEVEL audius_comet_log_level
OPENAUDIO_CORE_ROOT_DIR audius_core_root_dir
... and ~20 more (see full list in files changed)

Test plan

  • go build ./... passes
  • CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build passes
  • make test-unit passes
  • Verify devnet boots with make up using updated env files
  • Verify existing deployments using legacy env var names still work (no behavior change)

🤖 Generated with Claude Code

@raymondjacobson
raymondjacobson force-pushed the ray/openaudio-env-vars branch 3 times, most recently from 46a64cc to 5238202 Compare April 2, 2026 22:35
Introduces a `pkg/env` package with helpers (Get, String, Bool, GetInt,
GetDuration, Lookup, IsSet) that check OPENAUDIO_ prefixed keys first,
then fall back to legacy names for backward compatibility.

Every env var now has a canonical OPENAUDIO_ version. Legacy names
(nodeEndpoint, delegatePrivateKey, dbUrl, etc.) continue to work but the
OPENAUDIO_ form takes priority when both are set. Cloud provider vars
(AWS_*, GOOGLE_*, AZURE_*) are left unchanged as they are industry
standards.

Updates dev env files and docs to use the new names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raymondjacobson
raymondjacobson force-pushed the ray/openaudio-env-vars branch from 5238202 to fd4bcba Compare April 3, 2026 00:25
go run ./cmd/openaudio/main.go only compiled main.go, missing other
files in the package like consensus_check.go. Use ./cmd/openaudio/
to compile the full package.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@rickyrombo rickyrombo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb q - but why have prefixes at all?

@raymondjacobson

raymondjacobson commented Apr 3, 2026

Copy link
Copy Markdown
Contributor Author

Dumb q - but why have prefixes at all?

not a dumb q at all!

I thought about this. My thinking is that it reduces any likelihood of collisions in shared envs etc since people may run the docker image in various ways. I think it also makes very clear that these variables should be looked up in the open audio codebase rather than some dependency or something.

@raymondjacobson
raymondjacobson merged commit 008d5d6 into main Apr 3, 2026
6 checks passed
@raymondjacobson
raymondjacobson deleted the ray/openaudio-env-vars branch April 3, 2026 18:42
raymondjacobson added a commit that referenced this pull request Apr 3, 2026
raymondjacobson added a commit that referenced this pull request May 19, 2026
On a legacy creator/discovery node, the bundled /env/${NETWORK}.env
declares OPENAUDIO_ defaults (e.g. OPENAUDIO_CORE_ROOT_DIR=/data/core).
If the operator only set the legacy name with a *different* value
(e.g. audius_core_root_dir=/data/bolt), the Go env helper would pick
the OPENAUDIO_ default and look at a path that has no chain data —
producing the CometBFT `state.AppHash does not match AppHash after
replay` panic that originally got #195 reverted.

Promote externally-set legacy keys to their OPENAUDIO_ counterparts
before source_env_file runs. source_env_file is a no-op for already-set
keys, so the legacy value wins; if the operator instead set the
OPENAUDIO_ name directly, that already-set value is left alone.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
raymondjacobson added a commit that referenced this pull request May 19, 2026
* Reland OPENAUDIO_ prefixed env vars (reverts #197)

This re-applies #195 (reverted in #197). The handshake panic that
prompted the original revert (`state.AppHash does not match AppHash
after replay. Got E3B0..., expected .`) was caused by an
unrelated state-sync bug: CometBFT's state.db could end up at height 0
while the app database had block records, producing the mismatch.
That class of failure has since been fixed by #253 and related
state-sync reliability work, so the env-var change is safe to bring
back on top of current main.

Changes since #195:
- Keep state-sync defaults from #255 (Keep=2, BlockInterval=100000)
- Carry forward #224's separate archive bucket DSN (now goes through
  env.String with AUDIUS_ARCHIVE_STORAGE_DRIVER_URL fallback)
- Update pkg/uptime/uptime.go which post-revert added a
  `mustGetenv("nodeEndpoint")` call — read OPENAUDIO_NODE_ENDPOINT first
  with legacy fallback, drop the now-unused mustGetenv/getenvWithDefault
- CLAUDE.md: keep the validator-node terminology from #264 and add the
  pkg/env helper list

Legacy env vars (nodeEndpoint, delegatePrivateKey, dbUrl,
audius_core_root_dir, spOwnerWallet, etc.) continue to work via
fallback, so legacy creator / discovery node registrations are
unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(entrypoint): promote legacy env vars before sourcing prod.env

On a legacy creator/discovery node, the bundled /env/${NETWORK}.env
declares OPENAUDIO_ defaults (e.g. OPENAUDIO_CORE_ROOT_DIR=/data/core).
If the operator only set the legacy name with a *different* value
(e.g. audius_core_root_dir=/data/bolt), the Go env helper would pick
the OPENAUDIO_ default and look at a path that has no chain data —
producing the CometBFT `state.AppHash does not match AppHash after
replay` panic that originally got #195 reverted.

Promote externally-set legacy keys to their OPENAUDIO_ counterparts
before source_env_file runs. source_env_file is a no-op for already-set
keys, so the legacy value wins; if the operator instead set the
OPENAUDIO_ name directly, that already-set value is left alone.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants