HomePhabricator

[validation/mempool] use Spend/AddCoin instead of UpdateCoins

Description

[validation/mempool] use Spend/AddCoin instead of UpdateCoins

Summary:
UpdateCoins is an unnecessary dependency on validation. All we need to
do is add and remove coins to check inputs. We don't need the extra
logic for checking coinbases and handling TxUndos.

Also remove the wrapper function in validation.h which constructs a
throwaway TxUndo object before calling UpdateCoins because it is now
unused.

This is a backport of core#23157 [6/8]
https://github.com/bitcoin/bitcoin/pull/23157/commits/9e8d7ad5d9cc4b013826daead9cee09aad539401

Notes:

  • there was another occurence of the removed UpdateCoins function in the unit test added in rABC880d847f076f7b38c849ce3f31120f2f582a0ba0 . For that case, as the tx is a coinbase transaction (without inputs), UpdateCoins was just calling AddCoins.
  • the removed UpdateCoins function was slighlty modified in D1479 to avoid building an uneccessary CTxUndo

Depends on D12171

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
glozow <gloriajzhao@gmail.com>Authored on Oct 4 2021, 12:01
PiRKCommitted on Oct 7 2022, 13:38
PiRKPushed on Oct 7 2022, 13:39
Reviewer
Restricted Project
Differential Revision
D12172: [validation/mempool] use Spend/AddCoin instead of UpdateCoins
Parents
rABC6521a557d53d: MOVEONLY: remove single-use helper func CheckInputsAndUpdateCoins
Branches
Unknown
Tags
Unknown