Skip to content

Conversation

@random-zebra
Copy link

@random-zebra random-zebra commented Oct 16, 2019

Additional bug introduced with the changes of #970 (and not caught in #1040 even though the culprit is the same: GetDepthInMainChain returning a value 0 when -1 was expected).

After a block reorganization, the coins used as coinstake inputs in the orphan chain were still marked as spent in the wallet. Thus there were inconsistencies in the balance (either displayed in the GUI or returned by getbalance via CLI) and missing utxos in the wallet (either accessed through coincontrol in the GUI or returned by listunspent via CLI).

a0285e4 fixes it by marking as "spent" the inputs of not-in-mempool txes only for non-coinstakes (coinstakes don't hit the mempool so, when not in chain, their inputs should be considered unspent).

bb683c7 Introduces the functional test wallet_reorg-stake to reproduce the issue.
The test fails without a0285e4 and passes with it.

@random-zebra random-zebra added this to the 4.0.0 milestone Oct 16, 2019
@random-zebra random-zebra self-assigned this Oct 16, 2019
to check balances in a reorganization of PoS blocks, and verify that the
input of an orphan block's coinstake is spendable after.
@random-zebra random-zebra force-pushed the 2019_stakeinput_reorg branch from 9fe0270 to a0285e4 Compare October 16, 2019 22:07
Copy link

@Warrows Warrows left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3a7ec7c

Copy link

@Mrs-X Mrs-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK and thanks for the test for it 👍

random-zebra added a commit that referenced this pull request Oct 18, 2019
…uts to the wallet

3a7ec7c [Tests] Add wallet_reorg-stake functional test to test_runner.py (random-zebra)
a0285e4 [Wallet] Fix bug with coinstake inputs wrongly marked as spent (random-zebra)
bb683c7 [Tests] Add wallet_reorg-stake functional test (random-zebra)
3eca8da [Core][Tests] REGTEST: fix nStakeModifier=0 (random-zebra)

Pull request description:

  Additional bug introduced with the changes of #970 (and not caught in #1040 even though the culprit is the same: `GetDepthInMainChain` returning a value `0` when `-1` was expected).

  After a block reorganization, the coins used as coinstake inputs in the orphan chain were still marked as spent in the wallet. Thus there were inconsistencies in the balance (either displayed in the GUI or returned by `getbalance` via CLI) and missing utxos in the wallet (either accessed through coincontrol in the GUI or returned by `listunspent` via CLI).

  a0285e4 fixes it by marking as "spent" the inputs of not-in-mempool txes only for non-coinstakes (coinstakes don't hit the mempool so, when not in chain, their inputs should be considered unspent).

  bb683c7 Introduces the functional test `wallet_reorg-stake` to reproduce the issue.
  The test fails without a0285e4 and passes with it.

ACKs for top commit:
  Warrows:
    ACK 3a7ec7c

Tree-SHA512: 8f97e3d48720b776c84820e0ab8257665ac4c4c9d394db0e4b9f3a05b0904bf9f70cf54865338c4e29066e6b3670e9e90f77780d3ddd198e8e2b6e416c4cb49c
@random-zebra random-zebra merged commit 3a7ec7c into PIVX-Project:master Oct 18, 2019
@random-zebra random-zebra deleted the 2019_stakeinput_reorg branch September 24, 2020 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants