bitshares / bitshares/bitshares-core

Buyback orders that fail to place should not show in account history

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

Description

**Bug Description**

On Testnet:
```
>>> get_account_history special-account 3
61978003 2022-11-21T20:41:00 1.11.151387577 Create limit order to sell 10 SPECIALA for 0.0001 SPECIAL (Fee: 0 TEST)
61977906 2022-11-21T20:36:00 1.11.151387576 Create limit order to sell 10 SPECIALA for 0.0001 SPECIAL (Fee: 0 TEST)
61977809 2022-11-21T20:31:00 1.11.151387575 Create limit order to sell 10 SPECIALA for 0.0001 SPECIAL (Fee: 0 TEST)
```
Note that there is no `result` showing with these orders. A normal limit order looks like this:
```
61978048 2022-11-21T20:43:24 1.11.151387578 Create limit order to sell 1 TEST for 1000 CONTEST.BTC (Fee: 0.00100 TEST) result: 1.7.9085458
```

Actually the results of those orders are `[0,{}]` aka `void_result()`:
```
>>> get_object 1.11.151387577
[{
"id": "1.11.151387577",
"op": [
1,{
"fee": {
"amount": 0,
"asset_id": "1.3.0"
},
"seller": "1.2.3564",
"amount_to_sell": {
"amount": 100000,
"asset_id": "1.3.329"
},
"min_to_receive": {
"amount": 1,
"asset_id": "1.3.330"
},
"expiration": "2106-02-07T06:28:15",
"fill_or_kill": false,
"extensions": []
}
],
"result": [
0,{}
],
"block_num": 61978003,
"trx_in_block": 0,
"op_in_trx": 0,
"virtual_op": 0,
"is_virtual": true,
"block_time": "2022-11-21T20:41:00"
}
]
```
According to the log messages, there was an error when placing these orders, so no order was successfully placed:
>`create_buyback_order ] Skipping buyback processing selling 1.3.329 for {"id":"1.3.330","symbol":"SPECIAL","precision":4,"issuer":"1.2.3563","options":{"max_supply":1000000000,"market_fee_percent":0,"max_market_fee":0,"issuer_permissions":79,"flags":0,"core_exchange_rate":{"base":{"amount":100000,"asset_id":"1.3.0"},"quote":{"amount":10000,"asset_id":"1.3.330"}},"whitelist_authorities":[],"blacklist_authorities":[],"whitelist_markets":[],"blacklist_markets":[],"description":"{\"main\":\"\",\"market\":\"\"}","extensions":{}},"dynamic_asset_data_id":"2.3.330","buyback_account":"1.2.3564","creation_block_num":10660593,"creation_time":"2017-09-01T07:44:54"} for buyback account {"id":"1.2.3564","membership_expiration_date":"1970-01-01T00:00:00","registrar":"1.2.17","referrer":"1.2.17","lifetime_referrer":"1.2.17","network_fee_percentage":2000,"lifetime_referrer_fee_percentage":3000,"referrer_rewards_percentage":3,"name":"special-account","owner":{"weight_threshold":1,"account_auths":[["1.2.3",1]],"key_auths":[],"address_auths":[]},"active":{"weight_threshold":1,"account_auths":[["1.2.3",1]],"key_auths":[],"address_auths":[]},"options":{"memo_key":"TEST7H976gDkY4PkUTpLTDNjYL8u7n9fP9X4qgi4rbArYRS7srxUqE","voting_account":"1.2.5","num_witness":0,"num_committee":0,"votes":[],"extensions":[]},"num_committee_voted":0,"statistics":"2.6.3564","whitelisting_accounts":[],"blacklisting_accounts":[],"whitelisted_accounts":[],"blacklisted_accounts":[],"owner_special_authority":[0,{}],"active_special_authority":[0,{}],"top_n_control_flags":0,"allowed_assets":["1.3.329","1.3.330"],"creation_block_num":10660894,"creation_time":"2017-09-01T08:03:45"} at block 61978003; exception was 10 assert_exception: Assert Exception
is_authorized_asset( d, *fee_paying_account, *fee_asset ): Account 1.2.3564 'special-account' attempted to pay fee by using asset 1.3.0 'TEST', which is unauthorized due to whitelist / blacklist`

Like failed proposals, I think we should not list these orders in account history (see https://github.com/cryptonomex/graphene/issues/481 and https://github.com/bitshares/bitshares-core/commit/7e0e58f4411457472f2a407b4c675482bb8dbfc9). Note that existing operation history IDs (`1.11.x`) should remain unchanged (see https://github.com/cryptonomex/graphene/issues/483 and https://github.com/bitshares/bitshares-core/commit/7cae3501f8120b23ef143d0baa3abfe413d4dbf4).

Strictly speaking, fixing this issue does not change consensus. However, in order to preserve the existing operations history IDs, we need to fix this issue in a consensus upgrade.

**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.)
- [x] 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: `test-6.1.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 by tracing how failed buyback operations reach get_account_history and how void_result() operations are indexed, then review the referenced failed-proposal history changes. Reproduce the unauthorized-fee failure and verify that it no longer appears in account history while existing operation history IDs remain unchanged through the required consensus upgrade.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.