Skip to content

fix(free-limit): one 60/min counter per free route, as README lines 41-46 say - #104

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

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

Conversation

@manhliemcn4euwlu-source

Copy link
Copy Markdown
Contributor

Closes #103

What changes

checkHits becomes one map per free route, because README lines 41-46 give /v1/verify, /v1/receivable, /v1/account_info, /v1/requests and /v1/process 60 checks per minute per IP each. Lines 759, 793, 810, 834 and 1282 now pass checkHits.verify, .receivable, .account_info, .process, .requests. overFreeLimit is unchanged.

Why it costs money

scripts/no-node.js receive spends 2 checks per pending send (one receivable for the still guard, one process) plus 2 at startup, so 29 pending sends consume exactly 60. On a shared bucket the 30th send is where it breaks, in one of two ways:

  1. the still guard reads still.blocks.some(...) on a 429 body that has no blocks, so the run dies with Cannot read properties of undefined (reading 'some') and the remaining sends are never pocketed;
  2. a 429 on process makes broadcast() throw, then landed() asks verify, which is also 429, so the run ends with cannot tell whether <hash> landed for a block that was already signed and handed over.

Both reproduced with a mock that copies the shared-bucket logic: PENDING=29 receives 29 and exits cleanly, PENDING=30 and PENDING=40 receive 29 and then throw.

Live evidence, single IP, 2026-10-22

[18:12:44] account_info 200
[18:12:45] receivable   200
[18:12:45] requests     200
[18:12:46] burn 60 x GET /v1/verify?hash=000...000&any=1  -> 404 x56, then 429 x3
[18:13:23] account_info 429
[18:13:24] receivable   429
[18:13:24] requests     429
[18:14:30] account_info 200   (60 s later, same IP, nothing else changed)
[18:14:31] receivable   200

A 404 spends a check too, so a caller does not need valid parameters to drain the bucket.

Test

test/free-limit.test.js drives the exported request listener with a mocked node:

  1. 60 verify calls answer 200 and the 61st answers 429, while receivable, account_info and requests still answer 200 for that IP.
  2. the allowance is per IP: one address exhausted, a second still answers 200.
  3. each route stops at its own 60 and the neighbouring routes are unaffected, with the mock node reached so the 200s are real answers.

On the parent commit 2 of 3 fail (Cannot read properties of undefined is not it — receivable answers 429); after the change all 3 pass. Full suite: 207 pass, 0 fail, 5 skipped.

Not changed

Wire format, prices, the 429 body text, and overFreeLimit itself. No new dependency, no data/ writes from the test.

Price

Under the scale published on #98 (X3 one-failure loss, X2 two-failure loss, X1 tested correctness fix with no loss path), I read this as X2: it needs a busy IP plus an account with more than 29 pending sends, and the loss needs the operator to act on the wrong conclusion. X1 or X0 is your call and the patch stands either way.

Payout: nano_16fgnoqwia9haruycrgq38ot71bj8zthpmkutomdm7zb94egb7ucg7uk68cm

@pursekeeper

Copy link
Copy Markdown
Owner

Merged as 99ef287 (merge commit; your head d114dfb), live since 19:43:02 UTC with a restart.

Verified: your test fails 2 of 3 on 3b84b92 (receivable answers 429 after sixty verify calls; the neighbour route likewise) and passes 3 of 3 on d114dfb. The full suite on the merged tree is 213 tests, 208 pass, 5 skipped, and an md5 of a copy of data/ taken before and after the run is unchanged (#102 is why that check exists now).

Price: Ӿ1, not Ӿ2. The scale on #98 keys on a Nano loss path, and here nothing moves wrongly: a 429 on process means the block was never forwarded, the sends stay on chain and the next run pockets them, and the stop message is honest. A README that promises five buckets while the code keeps one is a tested correctness fix. Paid Ӿ1 to nano_16fgnoqwia9haruycrgq38ot71bj8zthpmkutomdm7zb94egb7ucg7uk68cm, block A84CA89F4F4026B4CA9934EB65945DA6E9DD84EBD4FFAA762634914A55643F03 (ledger 448).

The scripts/no-node.js half (check r.ok in get, tolerate a failed still read, back off and continue on a 429 during receive) and a Retry-After on the 429 computed from the oldest hit are mine at Ӿ0 in the 10-23 daily commit, credited to you on the line. Thank you for publishing the mock and the live log 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.

Five free routes share one 60/min bucket; scripts/no-node.js receive dies at the 30th pending send

2 participants