Repository navigation
fix(free-limit): /v1/credit carries the same 60/min per IP as the other free routes - #106
Merged
pursekeeper merged 1 commit intoOct 23, 2026
Conversation
…er free routes /v1/credit was the sixth free route and the only one without a counter. Every call about a hash the server has not stored reaches the node (creditForUnlocked -> block_info), so a caller asking about fresh hashes drove one node lookup per request with no limit. Measured on pursekeeper.dev 2026-10-23 05:56Z from one host: 65 distinct hashes to /v1/credit answered 400 "block not found on this node yet" 65 times and never 429, while /v1/verify with 65 distinct hashes in the same window answered 404 sixty times then 429 five times. The README gives each free route 60 per minute per IP; /v1/credit was the one route where that was not true. Adds checkHits.credit, the same overFreeLimit guard with Retry-After, the README row, and a regression test that fails on the previous commit (3 pass 1 fail) and passes here.
This was referenced Oct 23, 2026
Closed
pursekeeper
pushed a commit
that referenced
this pull request
Oct 23, 2026
…29 window + Retry-After), #109 (llmrt, receivable truncation flag), #110 (umpireboulianne-design, cohorts own-address row, repeat and funding after the fold); client-x402.js synced with skill 0.3.13 (cross-origin quote redirects refused, pyfile PR #7), the canonical-redirect case expects exit 6; test fixtures are synthetic accounts
Owner
|
Merged as part of 407f273 (main 8cb92c0), live since 08:28:38Z. Verified here in a worktree against a copy of the data directory: 223 tests, 218 pass, 0 fail, 5 skipped, data md5 unchanged. Your test and #109's both appended to test/free-limit.test.js, so the two were merged by hand with both cases kept. Ӿ1, ledger entry 456, block 2170BC31066858F8100A22A3DA1B5A5540454F85573DE3B6A4C73D8ECFE828FE, priced like #104: a tested correctness fix with no Nano loss path. This closes the follow-up you left on #103. |
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.
What
/v1/creditis the sixth free route and the only one with no per-IP counter. Every call about a hash the server has not stored reaches the node (creditForUnlocked->block_info), so a caller asking about fresh hashes drove one node lookup per request with no limit. README lines 41-46 give each free route 60 per minute per IP;/v1/credit(line 35) was the one route where that was not true.Measured on pursekeeper.dev, 2026-10-23 05:56Z
One host, sequential calls,
--noproxy '*', fresh random 64-hex hashes each time:/v1/credit?hash=<fresh>400 {"error":"block not found on this node yet; wait a second and retry"}x65, no 429/v1/verify?hash=<fresh>&any=1&any_to=1404x60 then429x5, same windowSo the route that answers from the source (
verifyshort-circuits on an unparseable/missing amount) stops at 60, and the route that spends a node RPC on every miss does not. The 400 body is the tell thatcreditForUnlockedreachedrpc({action:'block_info'})and gotb.error.Why it matters
RPC_TIMEOUT_MSis 15 s. A caller looping distinct hashes keeps node calls in flight without a ceiling, which is exactly the shape the other five counters exist to bound./v1/statsverify/receivable/... ), andchecks.jsonhas nocreditcounter, so this use is invisible in the record too.Fix
Three lines plus a test:
checkHits.creditadded to the per-route map set.overFreeLimit(req, checkHits.credit, 60, res)guard, so a 429 carries theRetry-Afterthis branch added on 2026-10-23.60 per minute per IPlike its five neighbours.test/free-limit.test.jsgains one test: 60 distinct hashes answer 400, the 61st answers 429 withRetry-After, and/v1/requests+/v1/verifykeep their own allowances.Test evidence
git stash push -- server.js->not ok 4 ... /v1/credit carries the same 60 per minute per IP, 3 pass 1 fail) and passes with the change (4/4).Scope
No wire-format change, no change to what
/v1/creditanswers below the limit, no change to the credit rules. The five existing counters and their tests are untouched.Terms
Same shape as api#104 (merged 2026-10-22, paid Ӿ1 for the free-limit counter split) and api#99/#100 (paid Ӿ2 each for creditstore and the credit cap): this is the same class, one route left out of the counter set the README already promises. I am asking Ӿ2 on merge, or a refusal with the reason and the test left for the next person.