bitshares / bitshares/bitshares-core

Fee amount validation

Open
#2,122 0 comments 0 reactions 0 assignees View on GitHub
3d Bug 4a Low Priority
Dominant language
C++
Stars
1.2k
Forks
660
Avg merge
8h 17m
Merged PRs (30d)
26

Description

**Bug Description**
Most non-virtual operations have a check `FC_ASSERT(fee.amount >= 0)` in `validate()` function. But some are different.
* `blind_transfer_operation` doesn't check `fee.amount`;
* `proposal_create_operation` doesn't check `fee.amount`;
* `custom_operation` checks `fee.amount > 0`, which is practically fine but not perfect;
* `balance_claim_operation` checks `fee.amount == asset()`, which is fine.

Anyway, there is a check `FC_ASSERT( fee.amount >= 0 )` in `generic_evaluator::prepare_fee()`, so the chain won't allow any user to pay a negative fee, which means we're safe. However, since the check is done in evaluators, there exists a minor issue that a user can wrap an operation with a negative fee in a `proposal_create_operation` which could be accepted by the chain, just a bit annoying.

**Impacts**
Describe which portion(s) of BitShares Core may be impacted by this bug. Please tick at least one box.
- [ ] API (the application programming interface)
- [ ] Build (the build process or something prior to compiled code)
- [ ] CLI (the command line wallet)
- [ ] Deployment (the deployment process after building such as Docker, Travis, etc.)
- [ ] DEX (the Decentralized EXchange, market engine, etc.)
- [ ] P2P (the peer-to-peer network for transaction/block propagation)
- [ ] Performance (system or user efficiency, etc.)
- [x] Protocol (the blockchain logic, consensus, validation, etc.)
- [ ] Security (the security of system or user data, etc.)
- [ ] UX (the User Experience)
- [ ] Other (please add below)

## CORE TEAM TASK LIST
- [ ] Evaluate / Prioritize Bug Report
- [ ] Refine User Stories / Requirements
- [ ] Define Test Cases
- [ ] Design / Develop Solution
- [ ] Perform QA/Testing
- [ ] Update Documentation

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the validate() functions for blind_transfer_operation, proposal_create_operation, custom_operation, and balance_claim_operation, then read generic_evaluator::prepare_fee(). Compare how each handles negative fee amounts and determine the consistent validation expected by the issue. Done means proposal-wrapped operations cannot carry a negative fee and the affected validation behavior is covered by the project's relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
blockchain
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.