Skip to content

staking: migrate from discovery and fix prod runtime + build issues#36

Merged
dylanjeffers merged 1 commit into
mainfrom
claude/quirky-torvalds-a39f85
May 21, 2026
Merged

staking: migrate from discovery and fix prod runtime + build issues#36
dylanjeffers merged 1 commit into
mainfrom
claude/quirky-torvalds-a39f85

Conversation

@dylanjeffers
Copy link
Copy Markdown
Contributor

Summary

Migrates the staking service from apps/packages/discovery-provider/plugins/pedalboard/apps/staking to this repo at parity, and fixes a set of issues that would have prevented it from running correctly in prod:

  • ClaimsManager runtime bug@audius/eth 1.0.0 changed ClaimsManager from a class to a plain { abi, address } object, so new ClaimsManager(viemClient) was a runtime crash. Bump the dep from 0.1.0 → 1.0.0 and rewrite initRound to use viemClient.readContract({ abi, address, functionName }). The three on-chain reads now run in parallel.
  • Build setup — replace start: npx tsx ./src/index.ts with build: tsc + start: node ./dist/index.js, matching the anti-abuse-oracle pattern. The Dockerfile already runs npm run build during install, so the dev toolchain was being dragged into prod for no reason.
  • Health endpointGET /health now returns the standard { status: 'ok' } shape used by the other pedalboard services.
  • Port — pin to 6000 (matches the nginx /plugins/<service>/... upstream) and drop the process.env.port fallback that no caller was setting.

Git history

History preserved — git log --follow apps/staking/src/index.ts shows the original 3 commits from the discovery plugin (Add staking plugin to replace other system checks, Update default staking health check plugin port, Add verified-notifications).

Source-of-truth comparison

Diffed against apps/packages/discovery-provider/plugins/pedalboard/apps/staking — only difference was that discovery uses a local logger.ts (because @pedalboard/logger inside discovery's monorepo only exports log). This repo's @pedalboard/logger already exports createLogger, so no local logger is needed.

Paired PR

Pairs with AudiusProject/apps#14375, which adds the missing env_file and environment: blocks to the staking entry in dev-tools/compose/docker-compose.pedalboard.prod.yml so solana_rpc_endpoint and eth_rpc_endpoint actually reach the container. Until that lands, the service will boot but every Eth/Solana read will fail.

Test plan

  • npm run build succeeds (tsc clean)
  • npm run lint clean (only pre-existing non-null assertion warnings unchanged by this PR)
  • Deploy to a single discovery node and hit /plugins/staking/health — expect { status: 'ok' }
  • Hit /plugins/staking/init-round with valid eth_rpc_endpoint — expect 200 with lastFundedBlockNumber, latestBlock, fundingRoundBlockDiff, blockDiff
  • Hit /plugins/staking/balance?chain=eth&address=0x… — expect 200 with formatted balance
  • Hit /plugins/staking/balance?chain=solana&address=… — expect 200 with sol balance
  • Verify apps/packages/discovery-provider/plugins/pedalboard/apps/staking can be removed in a follow-up after this deploys cleanly

🤖 Generated with Claude Code

Brings the staking service to parity with the version in
apps/packages/discovery-provider/plugins/pedalboard/apps/staking and
fixes a handful of issues that would have prevented it from running
in prod:

- Bump @audius/eth 0.1.0 -> 1.0.0. The 1.0.0 export shape changed:
  ClaimsManager is now a plain `{ abi, address }` object rather than
  a class, so `new ClaimsManager(viemClient)` was a runtime crash.
  Rewrite initRound to use viemClient.readContract({ abi, address,
  functionName }) and parallelize the three on-chain reads.

- Replace `npx tsx ./src/index.ts` start script with `tsc` build +
  `node ./dist/index.js`, matching anti-abuse-oracle. The Dockerfile
  already runs `npm run build` during install, so tsx at runtime
  was both slower and dragged the dev toolchain into prod.

- Pin the server port to 6000 (matches the nginx
  /plugins/<service>/... upstream) and drop the `process.env.port`
  fallback that no caller was setting.

- /health now returns the standard `{ status: 'ok' }` shape used by
  the other pedalboard services instead of `{ status: 'up', port }`.

The apps/dev-tools/compose/docker-compose.pedalboard.prod.yml entry
was also missing the env_file/environment blocks needed to forward
solana_rpc_endpoint and eth_rpc_endpoint to the container. That's
fixed in a paired PR on the apps repo (AudiusProject/apps#14375)
so this service actually has its RPC URLs at runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dylanjeffers dylanjeffers force-pushed the claude/quirky-torvalds-a39f85 branch from a36f6dc to 903ebe0 Compare May 21, 2026 23:29
@dylanjeffers dylanjeffers merged commit 66f6cae into main May 21, 2026
35 checks passed
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.

1 participant