bitshares / bitshares/bitshares-core

`operation_history_object::virtual_op` numbering may be discontinuous (possibly with holes)

Open
#2,692 0 comments 0 reactions 0 assignees View on GitHub
informative
Dominant language
C++
Stars
1.2k
Forks
661
Avg merge
8h 17m
Merged PRs (30d)
26

Description

**Bug Description**

In `database::push_applied_operation()`, after `_current_virtual_op` is assigned to `virtual_op` of the newly created `operation_history_object`, `_current_virtual_op++` is called: https://github.com/bitshares/bitshares-core/blob/f812666bb3bb884f6e8e5e7e669dc0050d3f3a69/libraries/chain/db_block.cpp#L535-L544

If the operation being pushed is in a proposal, after it is added to `_applied_ops`, it may be removed later if the proposal fails, but `_current_virtual_op` is not updated back: https://github.com/bitshares/bitshares-core/blob/f812666bb3bb884f6e8e5e7e669dc0050d3f3a69/libraries/chain/db_block.cpp#L361-L364

I'm not sure if it is worth fixing.

https://github.com/bitshares/bitshares-core/issues/1675 is related.

**Impacts**
Describe which portion(s) of BitShares Core may be impacted by this bug. Please tick at least one box.
- [x] 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.)
- [ ] Protocol (the blockchain logic, consensus, validation, etc.)
- [ ] Security (the security of system or user data, etc.)
- [x] UX (the User Experience)
- [ ] Other (please add below)

**Host Environment**
Please provide details about the host environment. Much of this information can be found running: `witness_node --version`.
- BitShares Version: `6.0.2`

## 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 with libraries/chain/db_block.cpp, especially database::push_applied_operation() and the proposal handling around the cited lines. Compare the virtual_op assignment and increment with the later removal from _applied_ops, then clarify the expected numbering behavior for failed proposals. Done means an agreed behavior is covered by a regression test and the API history no longer exhibits unintended holes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, blockchain
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.