feat(price-pusher): allow mnemonic from MNEMONIC env var#3689
feat(price-pusher): allow mnemonic from MNEMONIC env var#36890xghost42 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 7 Skipped Deployments
|
ea1abb5 to
f1a68c4
Compare
|
Pushed
Type check ( |
|
Hi @keyvankhademi — gentle bump on this one. Open since 13/05, all checks green, Devin findings (version bump to 10.5.0, readMnemonic test coverage) both marked Resolved. Small additive change: env-var fallback for mnemonic with existing CLI/file paths untouched. Happy to rebase if a different version cadence is preferred. |
The sample Grafana dashboard (`grafana-dashboard.sample.json`) filters
every Prometheus query by `namespace=$chain`:
pyth_price_feeds_total{namespace="$chain"}
pyth_price_last_published_time{namespace="$chain"}
pyth_price_update_attempts_total{namespace="$chain", ...}
...
But `src/metrics.ts` only set `app="price_pusher"` as the default label
and never emitted a `namespace` label on any counter/gauge, and
`prometheus.sample.yml` did not add one via relabeling. With the
dashboard out of the box that filter matched zero series, so every
panel for a fresh deployment came up empty — flagged by Devin during
review of pyth-network#3692 and acknowledged there as pre-existing dashboard
behavior worth fixing in a separate PR. This is that PR.
Wiring:
- new CLI option `--metrics-namespace <name>` in `src/options.ts`,
defaulted per chain command (`evm`, `sui`, `aptos`, `solana`) so
that single-chain deployments work without configuration
- `PricePusherMetrics` constructor now takes a `namespace: string`
parameter and sets it via `registry.setDefaultLabels`, so every
existing metric series gains a `namespace` label without per-metric
`labelNames` plumbing
- each chain command (`evm/sui/aptos/solana/command.ts`) reads the
new arg and passes through to the constructor
Operators running multiple deployments of the same chain (e.g. several
EVM networks against one Grafana instance) can now set
`--metrics-namespace bsc-mainnet` / `--metrics-namespace polygon-mainnet`
to disambiguate. Single-deployment setups keep working unchanged.
Bumps `@pythnetwork/price-pusher` to `10.5.0` (additive, no breaking
changes — old CLIs still work). Note: pyth-network#3689 and pyth-network#3703 also bump to
`10.5.0`, so whichever of the three lands second/third will need a
trivial rebase to `10.6.0` / `10.7.0`.
Refs pyth-network#3692.
…-network#1015) Previously the price pusher required `--mnemonic-file` pointing at a file on disk containing the signing mnemonic. On platforms that provide encrypted env vars (DigitalOcean, Fly.io, etc.) this forces operators to first write the secret to disk before launching the process. Make `--mnemonic-file` optional and fall back to the `MNEMONIC` environment variable when the flag is not supplied. If both are supplied, the file takes precedence (explicit beats implicit). If neither is supplied, the existing required-arg error is replaced with a clearer message naming both sources. The helper lives in `utils.ts` so all four chain commands (evm, sui, aptos, injective) share identical resolution behaviour.
Per review feedback: - Bump @pythnetwork/price-pusher to 10.5.0 (minor) — backward-compatible feature addition (MNEMONIC env var fallback). 10.4.0 was consumed by pyth-network#3687 hermes-access-token. - Add tests/utils.test.ts covering all three readMnemonic paths plus the file-precedence-over-env behaviour: file source, env fallback, empty-string path (treated as not supplied), file > env precedence, missing-both error, empty-env error. - Wire `test:unit` script into apps/price_pusher/package.json so the workspace runner picks it up. `pnpm --filter @pythnetwork/price-pusher exec test-unit` — 6 passing.
f1a68c4 to
8c59265
Compare
| return fs.readFileSync(mnemonicFile, "utf8").trim(); | ||
| } | ||
|
|
||
| const envMnemonic = process.env.MNEMONIC; |
There was a problem hiding this comment.
🔴 Missing biome-ignore for noProcessEnv lint rule in utils.ts
The new readMnemonic function uses process.env.MNEMONIC at line 70, which violates the repository's Biome noProcessEnv: "error" lint rule (biome.json:151). The test file correctly includes // biome-ignore-all lint/style/noProcessEnv (tests/utils.test.ts:1), but the source file has no such suppression comment. Every other file in the repo that accesses process.env includes a biome-ignore comment (e.g., apps/mcp/src/config.ts:1, apps/developer-hub/src/cookies/initialAccessTokenCookie.ts:12). CI runs biome ci --changed which will report this as an error and fail the lint check.
| const envMnemonic = process.env.MNEMONIC; | |
| // biome-ignore lint/style/noProcessEnv: readMnemonic is the designated env var fallback point | |
| const envMnemonic = process.env.MNEMONIC; | |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Closes #1015.
Make
--mnemonic-fileoptional in the price pusher and fall back to aMNEMONICenvironment variable when the flag is not supplied. This makes deployments on platforms that inject secrets as encrypted env vars (DigitalOcean, Fly.io, etc.) much simpler, since operators no longer need to write the mnemonic to disk before launching the process.Maintainer pre-approval: @jayantk on the original issue — "happily accept a PR".
Change
apps/price_pusher/src/options.ts:--mnemonic-fileis nowrequired: false, with an updated description noting the env var fallback.apps/price_pusher/src/utils.ts: newreadMnemonic(mnemonicFile)helper. Resolution order: file (if supplied) →MNEMONICenv var → clear error naming both sources.apps/price_pusher/src/{evm,sui,aptos,injective}/command.ts: replace per-commandfs.readFileSync(mnemonicFile, "utf8").trim()with the shared helper; drop now-unusedfsimport.apps/price_pusher/README.md: short note on the two supported sources and the precedence rule.Verification
pnpm exec tsc --noEmitfromapps/price_pusherpasses.pnpm turbo fix --filter @pythnetwork/price-pusheris clean (formatting + biome).--mnemonic-file <path>only → reads file (unchanged from today).MNEMONIC=…env var only → reads env.No mnemonic provided. Pass --mnemonic-file or set the MNEMONIC environment variable.Out of scope
I did not touch the
solana,fuel,near, ortoncommands — they use different key-loading paths (keypair files / explicit private keys) and don't accept--mnemonic-filetoday. Happy to extend to those in a follow-up if useful.