staking: migrate from discovery and fix prod runtime + build issues#36
Merged
Conversation
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>
a36f6dc to
903ebe0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the staking service from
apps/packages/discovery-provider/plugins/pedalboard/apps/stakingto this repo at parity, and fixes a set of issues that would have prevented it from running correctly in prod:ClaimsManagerruntime bug —@audius/eth1.0.0 changedClaimsManagerfrom a class to a plain{ abi, address }object, sonew ClaimsManager(viemClient)was a runtime crash. Bump the dep from 0.1.0 → 1.0.0 and rewriteinitRoundto useviemClient.readContract({ abi, address, functionName }). The three on-chain reads now run in parallel.start: npx tsx ./src/index.tswithbuild: tsc+start: node ./dist/index.js, matching theanti-abuse-oraclepattern. The Dockerfile already runsnpm run buildduring install, so the dev toolchain was being dragged into prod for no reason.GET /healthnow returns the standard{ status: 'ok' }shape used by the other pedalboard services.6000(matches the nginx/plugins/<service>/...upstream) and drop theprocess.env.portfallback that no caller was setting.Git history
History preserved —
git log --follow apps/staking/src/index.tsshows 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 locallogger.ts(because@pedalboard/loggerinside discovery's monorepo only exportslog). This repo's@pedalboard/loggeralready exportscreateLogger, so no local logger is needed.Paired PR
Pairs with AudiusProject/apps#14375, which adds the missing
env_fileandenvironment:blocks to the staking entry indev-tools/compose/docker-compose.pedalboard.prod.ymlsosolana_rpc_endpointandeth_rpc_endpointactually reach the container. Until that lands, the service will boot but every Eth/Solana read will fail.Test plan
npm run buildsucceeds (tscclean)npm run lintclean (only pre-existing non-null assertion warnings unchanged by this PR)/plugins/staking/health— expect{ status: 'ok' }/plugins/staking/init-roundwith valideth_rpc_endpoint— expect 200 withlastFundedBlockNumber,latestBlock,fundingRoundBlockDiff,blockDiff/plugins/staking/balance?chain=eth&address=0x…— expect 200 with formatted balance/plugins/staking/balance?chain=solana&address=…— expect 200 with sol balanceapps/packages/discovery-provider/plugins/pedalboard/apps/stakingcan be removed in a follow-up after this deploys cleanly🤖 Generated with Claude Code