Skip to content

fix: cap block header count parameter#8

Open
tolga-tom-nook wants to merge 2 commits into
BitgesellOfficial:masterfrom
tolga-tom-nook:tomnook/header-count-validation-20260601
Open

fix: cap block header count parameter#8
tolga-tom-nook wants to merge 2 commits into
BitgesellOfficial:masterfrom
tolga-tom-nook:tomnook/header-count-validation-20260601

Conversation

@tolga-tom-nook

@tolga-tom-nook tolga-tom-nook commented Jun 1, 2026

Copy link
Copy Markdown

Fixes an impossible block-header count guard in api/views/headers.py.

The previous condition used count < 1 and count > 2000, which can never be true. As a result, /rest/block/headers/{block_pointer}/0, negative counts, and very large counts bypassed the intended default/cap behavior and were passed through to the model layer.

This PR changes the guard to count < 1 or count > 2000 and now includes focused regression coverage for:

  • count=0, count=-1, and count=5000 defaulting to the safe 2000-header bound;
  • non-numeric count returning the existing parameter error without a model call;
  • valid in-range counts continuing to call the model unchanged.

Bounty context / claim:

Validation:

  • python3 -m py_compile api/views/headers.py test/pytest/blocks_data/test_block_headers_count_validation_unit.py
  • python3 -m pytest -q --confcutdir=test/pytest/blocks_data test/pytest/blocks_data/test_block_headers_count_validation_unit.py → 3 passed
  • git diff --check

Executor refresh — 2026-06-17T08:57:30Z

Revalidated payout-readiness for the Bitgesell #81/#39 direct-USDT candidate:

  • GitHub live check: PR remains open/authored by tolga-tom-nook, MERGEABLE / CLEAN; no maintainer requested-changes review found.
  • Local validation: python3 -m py_compile api/views/headers.py test/pytest/blocks_data/test_block_headers_count_validation_unit.py passed.
  • Local validation: python3 -m pytest -q --confcutdir=test/pytest/blocks_data test/pytest/blocks_data/test_block_headers_count_validation_unit.py passed (3 passed).
  • Local validation: git diff --check origin/master...HEAD passed.
  • Branch remains current enough for review: git rev-list --left-right --count origin/master...HEAD = 0 2.

Evidence: /home/ubuntu/tom-agent/opportunity-os/evidence_bundle/bitgesell_bglapiserver_pr8_revalidation_20260617T085730Z/summary.md

@MyTH-zyxeon

Copy link
Copy Markdown

Maintainers - this looks like a narrow, reviewer-friendly bounty slice for the Bitgesell improvement program.

What seems concretely useful here:

  • Root cause is explicit and easy to validate: count < 1 and count > 2000 can never trigger, so invalid / oversized header counts leak through instead of collapsing to the intended safe bound.
  • Patch scope stays tight: request validation + regression coverage, without broad API or model-layer changes.
  • The acceptance surface is small enough to review quickly.

Suggested acceptance checks:

  1. /rest/block/headers/{block_pointer}/0 no longer passes 0 through and returns the bounded/default behavior instead.
  2. oversized values like 5000 are capped the same way.
  3. existing normal in-range requests still behave unchanged.
  4. negative / malformed path values still follow the repo's existing error-handling path rather than introducing a new behavior contract by accident.

If you want a different cap/default behavior than 2000, calling that out here should let the author adjust without broadening the PR.

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