Repository navigation
Conversation
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
strongkeep-debug
left a comment
There was a problem hiding this comment.
Approved current head 5546df0.
This fixes the live rips/rustchain-core/config/chain_params.py::calculate_block_reward() path rather than adding a parallel calculator, and it covers the regression gap that earlier #4636 fixes left open. The guard runs before Python floor division can turn negative heights into negative halving counts, while the new tests keep the valid halving and tail-emission schedule unchanged.
| Check | Result |
|---|---|
| Negative-height repro | -1 and -210000 now raise ValueError from the production function. |
| Focused regression | uv run --no-project --with pytest --with flask python -m pytest tests\test_chain_params_block_reward.py -q -> 2 passed. |
| Adjacent reward consistency | PYTHONUTF8=1 with tests\test_epoch_window_consistency.py tests\test_chain_params_block_reward.py -> 7 passed. |
| Hygiene gates | py_compile, git diff --check, and python tools\bcos_spdx_check.py --base-ref origin/main all passed. |
There are older overlapping #4636 PRs, so maintainers should still merge only one candidate. This one is materially stronger than the bare guard variants because the production change is paired with focused boundary regression coverage.
saim256
left a comment
There was a problem hiding this comment.
Independently validated this PR against #4636. The production function now rejects negative heights before floor division can produce negative halving counts, and the tests cover both the previous inflation cases and unchanged valid boundary rewards.
Validation run locally:
python -m pytest tests\test_chain_params_block_reward.py -q-> 2 passed$env:PYTHONUTF8='1'; python -m pytest tests\test_epoch_window_consistency.py tests\test_chain_params_block_reward.py -q-> 7 passedpython -m py_compile rips\rustchain-core\config\chain_params.py tests\test_chain_params_block_reward.pygit diff --check origin/main...HEAD -- rips/rustchain-core/config/chain_params.py tests/test_chain_params_block_reward.pypython tools\bcos_spdx_check.py --base-ref origin/main-> OK
There are overlapping fixes for the same issue, so maintainers should merge only one. This one is scoped and includes useful regression coverage.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing. Approved.
godd-ctrl
left a comment
There was a problem hiding this comment.
Approved after local validation of current head 5546df0.
Scope reviewed:
- rips/rustchain-core/config/chain_params.py rejects negative heights before floor division can produce negative halving counts.
- tests/test_chain_params_block_reward.py covers the prior negative-height cases and confirms valid halving plus tail-emission behavior is unchanged.
Validation run locally on Windows:
- uv run --no-project --with pytest --with flask python -m pytest tests\test_chain_params_block_reward.py -q -> 2 passed
- PYTHONUTF8=1 uv run --no-project --with pytest --with flask python -m pytest tests\test_epoch_window_consistency.py tests\test_chain_params_block_reward.py -q -> 7 passed
- python -m py_compile rips\rustchain-core\config\chain_params.py tests\test_chain_params_block_reward.py -> passed
- uv run --no-project --with ruff python -m ruff check rips\rustchain-core\config\chain_params.py tests\test_chain_params_block_reward.py --select F821,F401 --output-format=concise -> All checks passed
- git diff --check origin/main...HEAD -- rips/rustchain-core/config/chain_params.py tests/test_chain_params_block_reward.py -> passed
- python tools\bcos_spdx_check.py --base-ref origin/main -> BCOS SPDX check: OK
No blocking issue found. There are overlapping fixes for the same negative-height reward issue, so maintainers should merge only one candidate; this one is a scoped production fix with useful boundary regression coverage.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing. Approved.
jaxint
left a comment
There was a problem hiding this comment.
Code review: LGTM! Thanks for contributing to RustChain. Approved.
jaxint
left a comment
There was a problem hiding this comment.
Great contribution! LGTM. 🚀
loganoe
left a comment
There was a problem hiding this comment.
Review for Scottcjn/rustchain-bounties#73 on current head 5546df0a3f6d04aae37fc4d266ca102db1076c89.
The block reward fix is correctly placed in the production calculate_block_reward() path and rejects negative heights before Python floor division can inflate rewards through negative halving counts. The regression also preserves the valid halving and tail-emission schedule.
Validation performed:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONUTF8=1 uv run --no-project --with pytest --with flask python -m pytest tests/test_epoch_window_consistency.py tests/test_chain_params_block_reward.py -q-> 7 passedpython3 -m py_compile rips/rustchain-core/config/chain_params.py tests/test_chain_params_block_reward.py-> passedgit diff --check origin/main...HEAD -- rips/rustchain-core/config/chain_params.py tests/test_chain_params_block_reward.py-> passedpython3 tools/bcos_spdx_check.py --base-ref origin/main-> OK
No blocking issues found. Maintainers should still merge only one of the overlapping negative-height reward fixes.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing.
TJCurnutte
left a comment
There was a problem hiding this comment.
Approved. The negative-height guard lands before the halving calculation, so negative block heights can no longer flow through Python floor-division into the normal reward schedule, while the existing halving/tail-emission outputs stay unchanged.
Validation I ran on the checked-out PR branch:
git diff --check origin/main...HEAD -- rips/rustchain-core/config/chain_params.py tests/test_chain_params_block_reward.py
/tmp/rustchain-review-venv/bin/python -B -m py_compile rips/rustchain-core/config/chain_params.py tests/test_chain_params_block_reward.py
/tmp/rustchain-review-venv/bin/python -B -m pytest tests/test_chain_params_block_reward.py -qResult: pytest passed with 2 passed in 0.03s.
I also ran a focused import/runtime probe: calculate_block_reward(-1) and calculate_block_reward(-210000) both raise ValueError with the expected height in the message; representative valid rewards still return 1.5 at height 0, 0.75 at the first halving boundary, and 0.09375 in the tail-emission window.
PR Review — Standard Quality ✓PR: #4759 — fix: reject negative block reward heights What I reviewed
Observations
LGTM. Bounty: #2782 |
|
Codex audit review (would award high-tier (50 RTC) once fixed): Issue: Prevents negative block heights from inflating block rewards; focused fix that likely only needs a rebase. Address the specific point and ping for re-review. |
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing. Approved.
HCIE2054
left a comment
There was a problem hiding this comment.
Reviewed PR 4759. Standard review.
HCIE2054
left a comment
There was a problem hiding this comment.
LGTM! Thanks for contributing to RustChain!
HCIE2054
left a comment
There was a problem hiding this comment.
LGTM! Great contribution to the RustChain ecosystem. Thanks for keeping the codebase clean and well-tested. Approved ✅
|
Security Review ✅ CRITICAL Reject negative block reward heights. Negative block reward = infinite mint attack — attacker could create blocks with negative height that generate unlimited RTC. Fix validates height >= 0. Reviewed by Xeophon - Solana: Lt9nERv6VHsojw15LpFeiaabuphAggzfLF9sM9UXRrZ |
|
Closing as stale branch — would cause destructive deletions if merged. Your branch is 966 commits behind current main. Filed during the May 11-13 contributor burst, the codebase has since moved substantially. GitHub's Bounty credit acknowledged where applicableMost of the canonical fixes from your work-period have already shipped via other contributors' parallel PRs that landed earlier this week. Specific cases credited via the Codex audit batches:
If you want fresh reviewRebase against current main and verify your diff matches the size of your original changes: If the deletion count is much higher than what you intended, the branch is still picking up stale assumptions — recreate from a fresh main. Thanks for the contribution work. |
Summary
rips/rustchain-core/config/chain_params.py::calculate_block_reward()path-1and-210000, the cases that previously inflated rewards through Python floor divisionFixes #4636.
Validation
Notes
tests/test_epoch_window_consistency.pyneeds UTF-8 mode on this Windows host because the existing source scan hits non-CP1252 bytes in a large integrated-node file. The focused reward regression itself passes without that environment override.