Skip to content

lint: enforce Q-54 memory caps 128 / 320 / 16 / follow_live - #621

Closed
Hero-Gamer wants to merge 3 commits into
reardencode:masterfrom
Hero-Gamer:lint-pending-blocks-cap
Closed

Hero-Gamer wants to merge 3 commits into
reardencode:masterfrom
Hero-Gamer:lint-pending-blocks-cap

Conversation

@Hero-Gamer

@Hero-Gamer Hero-Gamer commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Closes Q-54 per docs/quality.md:32 and docs/ibd-memory.md:61

Today: four structural rules, zero cap rules. After: 4 structural + 4 cap rules, each with lint/ast-grep/fixtures/{good,bad}/

Caps enforced (easy-to-delete -> RSS blowup #421)

  • pending-blocks-cap: const MAX_PENDING_BLOCKS = 128 (ibd)
  • held-bodies-cap: HeldBodies::CAP = 320 (ibd)
  • serve-blocks-cap: const MAX_SERVE_BLOCKS = 16 (serve)
  • follow-live-vs-max-outbound: fn stale_follow_needs_room(follow_live, max_outbound) -> bool { follow_live >= max_outbound.max(1) } in crates/rbitcoin-node/src/run.rs:1615
    • max_outbound default 16 from config.rs:98
    • Rotation victims from PeerHub::outbound_full_relay_ids() in peers.rs:1872 — skips inbound and noban per test outbound_full_relay_ids_skips_inbound_and_noban
    • Without cap: unbounded follow_live grows

Evidence

./scripts/ast-grep.sh # clean on crates/
./scripts/ast-grep.test.sh # 12 passed, good fixtures []
ast-grep scan lint/ast-grep/fixtures/bad # 12 errors including 4 caps

pending-blocks-cap
held-bodies-cap
serve-blocks-cap
follow-live-vs-max-outbound

Each cap has good (keeps cap) and bad (deletes cap -> unbounded) fixture.

Fixes Q-54.

First named-cap rule from docs/ibd-memory.md.

pending_blocks is 128 decoded bodies / session with FIFO evict
(fixed in 8b28c19). Easy to accidentally delete or raise to
unbounded, causing RSS blowup like reardencode#421.

Quality.md Q-54: one rule per cap that is easy to delete:
pending_blocks 128, held_bodies 320, MAX_SERVE_BLOCKS 16,
follow_live vs max_outbound.

Each rule needs fixtures per quality.md.
- held-bodies-cap: impl HeldBodies CAP must be 320, not 64/1008 from tx_relay
- serve-blocks-cap: MAX_SERVE_BLOCKS must be 16
- both with bad/good fixtures per quality.md, ast-grep.sh clean
@Hero-Gamer Hero-Gamer changed the title lint: enforce MAX_PENDING_BLOCKS=128 (Q-54) lint: enforce Q-54 memory caps 128 / 320 / 16 Sep 18, 2026
@Hero-Gamer Hero-Gamer changed the title lint: enforce Q-54 memory caps 128 / 320 / 16 lint: enforce Q-54 memory caps 128 / 320 / 16 / follow_live Sep 18, 2026
@rearden-grok

rearden-grok Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Sorry — Q-54 should not have been on Open.

It asked ast-grep to pin pending_blocks 128 / held_bodies 320 / MAX_SERVE_BLOCKS 16 / follow_live vs max_outbound. That is a second clippy. The same quality table already Won't-fixes “ast-grep as a second clippy” (structural RSS/task-leak shapes only). Caps live in docs/ibd-memory.md and the production evict/rotate code; Q-51 already landed the four shape rules.

You implemented the row as written. The defect was the inventory item, not the PR. Closing this rather than merging.

Q-54 is moving to Won't-fix in #624.

@rearden-grok rearden-grok Bot closed this Sep 18, 2026
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.

1 participant