[VPD-1182]: add script to drain pendingScoreUpdates after addMarket#671
Merged
Conversation
Reconstructs holders from Mint/Burn events, batches updateScores by maxLoopsLimit until drained. Resumable via on-chain isScoreUpdated. Covered by 18 unit + 4 E2E tests (real Prime via deployProtocol).
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
fred-venus
reviewed
May 12, 2026
fred-venus
reviewed
May 12, 2026
Batch isScoreUpdated reads via Promise.all(20) — ~20x faster on the cold path. Default FROM_BLOCK to BSC Prime deploy block (33_264_762) so operators skip the lookup.
fred-venus
approved these changes
May 12, 2026
fred-venus
approved these changes
May 12, 2026
Contributor
fred-venus
approved these changes
May 17, 2026
Cap tx gas at 15M (BSC's EIP-7825 cap is 2^24); add holder cache so reruns skip the scan; retry transient ECONNRESET on isScoreUpdated + updateScores.
|
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
addMarket/updateAlpha/updateMultipliers, Prime queues a score update per holder and freezesissue/burnuntil the queue drains. There is no on-chain holder enumeration and no existing keeper, so the queue must be drained manually.Mint/Burnevents and batchesupdateScoresuntilpendingScoreUpdates == 0. Resumable across runs via the contract'sisScoreUpdated[roundId][user]mapping.Changes
chunk/eventsToHolders/fetchHolderEvents/runUpdatefor testability;main()guarded byrequire.main === module. Address resolved viadeployments.get("Prime"). Env vars:FROM_BLOCK,BLOCK_RANGE,DRY_RUN.chunk,eventsToHolders) plusrunUpdateorchestration against a hand-rolledPrimeStub.deployProtocolfixture. Trigger is the realaddMarket(vU)codepath. Covers full drain, multi-batch chunking bymaxLoopsLimit, resumability, and burn handling.exporttoSetupProtocolFixtureanddeployProtocolso the E2E test can reuse them. No behavioral change.Test plan
FORKED_NETWORK= npx hardhat test tests/hardhat/Scripts/— expect 46 passing (18 unit + 4 E2E + 24 inherited via fixture import)DRY_RUN=1 FROM_BLOCK=<prime_deploy_block> BLOCK_RANGE=2000 npx hardhat run scripts/prime-update-scores.ts --network bscmainnetprime.paused() == falsebefore any real executionaddMarket(vU)):FROM_BLOCK=<prime_deploy_block> BLOCK_RANGE=2000 npx hardhat run scripts/prime-update-scores.ts --network bscmainnetpendingScoreUpdates() == 0after run completes