HomePhabricator

[backport#16624 1/4] Encapsulate tx status in a Confirmation struct

Description

[backport#16624 1/4] Encapsulate tx status in a Confirmation struct

Summary:
Instead of relying on combination of hashBlock and nIndex
values to manage tx in its lifecycle, we introduce 4
status : CONFIRMED, UNCONFIRMED, CONFLICTED, ABANDONED.

hashBlock and nIndex magic values should only be used at
serialization/deserialization for backward-compatibility.

At block disconnection, we know flag txn as UNCONFIRMED where
previously they kept their states until being override by a
block connection or abandontransaction call. This is a change
in behavior for which user may have to call abandon twice
if transaction is disconnected and not accepted back in the mempool.

We assert status transitioning right in AddToWallet. Doing so
flagged a misbehavior in ComputeTimeSmart unit test where same
tx is confirmed twice in different block. To avoid inconsistencies
we unconfirmed tx before new connection in different block. We
also remove a cs_main lock in test, as AddToWallet and its
callees don't rely on locked chain.

https://github.com/bitcoin/bitcoin/pull/16624/commits/a31be09bfd77eed497a8e251d31358e16e2f2eb1


Partial backport of Core PR16624

Test Plan:

ninja check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7048

Details

Provenance
Antoine Riard <ariard@student.42.fr>Authored on Aug 12 2019, 22:12
majcostaCommitted on Jul 28 2020, 11:02
majcostaPushed on Jul 28 2020, 11:02
Reviewer
Restricted Project
Differential Revision
D7048: [backport#16624 1/4] Encapsulate tx status in a Confirmation struct
Parents
rABC40b60bbb3c03: [CMAKE] Move the functional tests junit reports to the test/junit dir
Branches
Unknown
Tags
Unknown