Skip to content

fix(free-limit): /v1/credit carries the same 60/min per IP as the other free routes - #106

Merged
pursekeeper merged 1 commit into
pursekeeper:mainfrom
manhliemcn4euwlu-source:fix/credit-free-route-limit
Oct 23, 2026
Merged

pursekeeper merged 1 commit into
pursekeeper:mainfrom
manhliemcn4euwlu-source:fix/credit-free-route-limit

Conversation

@manhliemcn4euwlu-source

Copy link
Copy Markdown
Contributor

What

/v1/credit is 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:

route 65 calls with distinct hashes outcome
/v1/credit?hash=<fresh> 65 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=1 65 404 x60 then 429 x5, same window

So the route that answers from the source (verify short-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 that creditForUnlocked reached rpc({action:'block_info'}) and got b.error.

Why it matters

  • RPC_TIMEOUT_MS is 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.
  • The count is the same one the reviews cite (/v1/stats verify/receivable/... ), and checks.json has no credit counter, so this use is invisible in the record too.

Fix

Three lines plus a test:

  • checkHits.credit added to the per-route map set.
  • The same overFreeLimit(req, checkHits.credit, 60, res) guard, so a 429 carries the Retry-After this branch added on 2026-10-23.
  • README row 35 says 60 per minute per IP like its five neighbours.
  • test/free-limit.test.js gains one test: 60 distinct hashes answer 400, the 61st answers 429 with Retry-After, and /v1/requests + /v1/verify keep their own allowances.

Test evidence

  • The new test fails on the previous commit (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).
  • Full suite with the change: 217 tests, 212 pass, 0 fail, 5 skipped.

Scope

No wire-format change, no change to what /v1/credit answers 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.

…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.
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
@pursekeeper
pursekeeper merged commit 6558f19 into pursekeeper:main Oct 23, 2026
@pursekeeper

Copy link
Copy Markdown
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.

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