Skip to content

fix: source the round on-chain in the pending-stake endpoint#736

Merged
rickstaa merged 1 commit into
mainfrom
fix/pending-stake-onchain-round
Jul 21, 2026
Merged

fix: source the round on-chain in the pending-stake endpoint#736
rickstaa merged 1 commit into
mainfrom
fix/pending-stake-onchain-round

Conversation

@rickstaa

@rickstaa rickstaa commented Jul 21, 2026

Copy link
Copy Markdown
Member

Follow-up to #731, which moved /api/current-round on-chain but left /api/pending-stake on the subgraph.

Problem

/api/pending-stake/[address] read the current round from the subgraph and passed it straight into on-chain pendingStake / pendingFees calls:

  • when indexing lags, a stale round understates pending stake and fees in the header balance (layouts/main.tsx) and the staking widget;
  • when the subgraph errors or returns no protocol, the handler threw No current round found and the route returned a 500.

Fix

Read currentRound from the RoundsManager through l2PublicClient, in parallel with the BondingManager address lookup. The route becomes a pure contract read that cannot fail on subgraph health. Response shape is unchanged.

This was the last caller of the subgraph-backed getCurrentRound() helper, so it is removed. queries/currentRound.graphql stays — getOrchestrators() still uses CurrentRoundDocument.

Notes

getContractAddress is not memoized, so this route now performs two controller reads instead of one. They run in parallel, so there is no added latency, and it replaces a subgraph HTTP query with an RPC read.

@rickstaa
rickstaa requested a review from ECWireless as a code owner July 21, 2026 08:47
Copilot AI review requested due to automatic review settings July 21, 2026 08:47
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment Jul 21, 2026 8:53am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@rickstaa, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 39dc4516-9c5d-4150-b5fd-89df684dcf21

📥 Commits

Reviewing files that changed from the base of the PR and between f0213aa and daa216f.

📒 Files selected for processing (2)
  • lib/api/ssr.ts
  • pages/api/pending-stake/[address].tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pending-stake-onchain-round

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Pull request overview

This PR updates the /api/pending-stake/[address] endpoint to source currentRound directly from the on-chain RoundsManager (via l2PublicClient) instead of from the subgraph, preventing stale/failed subgraph reads from understating pending stake/fees or causing 500s.

Changes:

  • Replace subgraph-backed getCurrentRound() usage in /api/pending-stake/[address] with an on-chain RoundsManager.currentRound() contract read.
  • Fetch BondingManager and RoundsManager addresses in parallel via the Controller lookup helpers.
  • Remove the now-unused getCurrentRound() helper from lib/api/ssr.ts.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pages/api/pending-stake/[address].tsx Reads currentRound from RoundsManager on-chain and uses it for pendingStake/pendingFees calls, removing subgraph dependency.
lib/api/ssr.ts Removes the unused getCurrentRound() Apollo helper after the endpoint migration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/api/pending-stake read the current round from the subgraph and passed it to
on-chain pendingStake/pendingFees calls. When indexing falls behind, the stale
round understates both values, and a subgraph error or empty response threw
"No current round found" and returned a 500.

Read currentRound from the RoundsManager via l2PublicClient instead, so the
route is a pure contract read that no longer depends on subgraph health.
Response shape is unchanged.

This was the last caller of the subgraph-backed getCurrentRound() helper, so
drop it. queries/currentRound.graphql stays in use by getOrchestrators().

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@rickstaa
rickstaa force-pushed the fix/pending-stake-onchain-round branch from c1083e6 to daa216f Compare July 21, 2026 08:51
@rickstaa
rickstaa merged commit 6f2a4a1 into main Jul 21, 2026
8 of 9 checks passed
@rickstaa
rickstaa deleted the fix/pending-stake-onchain-round branch July 21, 2026 09:04
moudi-network pushed a commit to moudi-network/explorer that referenced this pull request Jul 24, 2026
…r#736)

/api/pending-stake read the current round from the subgraph and passed it to
on-chain pendingStake/pendingFees calls. When indexing falls behind, the stale
round understates both values, and a subgraph error or empty response threw
"No current round found" and returned a 500.

Read currentRound from the RoundsManager via l2PublicClient instead, so the
route is a pure contract read that no longer depends on subgraph health.
Response shape is unchanged.

This was the last caller of the subgraph-backed getCurrentRound() helper, so
drop it. queries/currentRound.graphql stays in use by getOrchestrators().

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
moudi-network pushed a commit to moudi-network/explorer that referenced this pull request Jul 24, 2026
…r#736)

/api/pending-stake read the current round from the subgraph and passed it to
on-chain pendingStake/pendingFees calls. When indexing falls behind, the stale
round understates both values, and a subgraph error or empty response threw
"No current round found" and returned a 500.

Read currentRound from the RoundsManager via l2PublicClient instead, so the
route is a pure contract read that no longer depends on subgraph health.
Response shape is unchanged.

This was the last caller of the subgraph-backed getCurrentRound() helper, so
drop it. queries/currentRound.graphql stays in use by getOrchestrators().
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