Reject transactions with negative fees#109
Conversation
Walkthrough
ChangesFee and Nonce Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@minichain/state.py`:
- Around line 95-105: The numeric validation in the state transaction checks
still accepts booleans because `isinstance(..., int)` matches `bool`; update the
guards in the transaction validation logic to explicitly reject `True`/`False`.
In the code around the `tx.amount`, `fee`, and `tx.nonce` checks, switch to
exact integer-type validation so only real integers pass, keeping the existing
non-negative constraints unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: dfb1d7ce-cabc-465f-aed0-5f61b9070be3
📒 Files selected for processing (3)
.gitignoreminichain/state.pytests/test_negative_fee.py
Addressed Issues:
Fixes #108
Screenshots/Recordings:
Not applicable. This PR modifies transaction validation logic and adds regression tests.
Additional Notes:
This PR adds validation to reject transactions with negative fees before state execution and includes a regression test to prevent this issue from recurring. The changes were tested locally.
AI Usage Disclosure:
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Check one of the checkboxes below:
I have used the following AI models and tools: Claude Sonnet 4.6
Checklist
Summary by CodeRabbit
Bug Fixes
Tests
Chores