Merge bitcoin/bitcoin#22232: refactor: Pass interpreter flags as uint32_t instead of signed int

BACKPORT NOTE:
Prior work is done here: c338cd69d4 (diff-060e8fd790fc1c3e18c64327a7395bb5b2d6d57db9792cc666bd8d7354a40c0b)
Missing changes in tx_verify.h included in this PR, but changes in
src/test/sigopcount_tests.cpp and src/test/transaction_tests.cpp are
irrelevant because they are segwit-related

fa621ededdfe31a200b77a8787de7e3d2e667aec refactor: Pass script verify flags as uint32_t (MarcoFalke)

Pull request description:

  The flags are cast to unsigned in the interpreter anyway, so avoid the confusion (and fuzz crashes) by just passing them as unsigned from the beginning.

  Also, the flags are often inverted bit-wise with the `~` operator, which also works on signed integers, but might cause confusion as the sign bit is flipped.

  Fixes #22233

ACKs for top commit:
  theStack:
    Concept and code review ACK fa621ededdfe31a200b77a8787de7e3d2e667aec
  kristapsk:
    ACK fa621ededdfe31a200b77a8787de7e3d2e667aec
  jonatack:
    ACK fa621ededdfe31a200b77a8787de7e3d2e667aec

Tree-SHA512: ea0720f32f823fa7f075309978672aa39773c6019d12b6c1c9d611fc1983a76115b7fe2a28d50814673bb6415c311ccc05b99d6e871575fb6900faf75ed17769
This commit is contained in:
MarcoFalke 2021-07-20 15:35:31 +02:00 committed by Konstantin Akimov
parent aaccc9ea51
commit e3c69da4f2
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524

View File

@ -49,7 +49,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& ma
* Count total signature operations for a transaction. * Count total signature operations for a transaction.
* @param[in] tx Transaction for which we are counting sigops * @param[in] tx Transaction for which we are counting sigops
* @param[in] inputs Map of previous transactions that have outputs we're spending * @param[in] inputs Map of previous transactions that have outputs we're spending
* @param[out] flags Script verification flags * @param[in] flags Script verification flags
* @return Total signature operation count for a tx * @return Total signature operation count for a tx
*/ */
unsigned int GetTransactionSigOpCount(const CTransaction& tx, const CCoinsViewCache& inputs, uint32_t flags); unsigned int GetTransactionSigOpCount(const CTransaction& tx, const CCoinsViewCache& inputs, uint32_t flags);