fix: fall back to latest stake when L2 block lookup reverts#593
Merged
fix: fall back to latest stake when L2 block lookup reverts#593
Conversation
When getL2BlockRangeForL1 reverts (e.g. no Arbitrum batches posted for that L1 block), the returned lastBlock of 0 was passed to getTotalStake, querying the subgraph at block 0 and producing near-zero stake. This could cause incorrect poll status calculations. Now passes undefined instead of 0 so getTotalStake queries latest stake. Also downgrades console.error to console.warn for expected failures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves poll stake calculation robustness by falling back to querying the latest total stake when the L1→L2 block-range lookup fails, avoiding incorrect outcomes for finished polls when the Arbitrum NodeInterface call reverts.
Changes:
- Refactors
getPollExtendedto compute an optionall2BlockNumberand passundefinedtogetTotalStakewhen an L2 end block can’t be resolved. - Downgrades the L2 block-range lookup failure log from
console.errorto a cleanerconsole.warn.
Comments suppressed due to low confidence (1)
lib/api/polls.ts:220
- Using
lastBlock: 0as the failure sentinel is ambiguous because block 0 is a valid L2 block height. Returningundefined/null(or anokflag) on failure would make the API unambiguous and avoid relying onlastBlock > 0checks at call sites.
return {
lastBlock: 0,
firstBlock: 0,
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
getL2BlockRangeForL1reverts for an L1 block (no corresponding Arbitrum batches), the returnedlastBlock: 0was passed togetTotalStake(0), querying the subgraph at block 0 and producing near-zero total stake — potentially causing incorrect poll status (e.g. marking polls aspassedwhen they should bequorum-not-met)console.error(with full RPC error dump) to a cleanconsole.warnTest plan
🤖 Generated with Claude Code