mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
Merge bitcoin/bitcoin#21970: fuzz: Add missing CheckTransaction before CheckTxInputs
fae4ee545a
fuzz: Add missing CheckTransaction before CheckTxInputs (MarcoFalke)faacb7eadb
fuzz: Sanity check result of CheckTransaction (MarcoFalke) Pull request description: This bug was introduced by myself in commiteeee8f5be1
(https://github.com/bitcoin/bitcoin/pull/21553) Reproducer: https://github.com/bitcoin/bitcoin/files/6492249/clusterfuzz-testcase-minimized-coins_view-6109460079706112.log Hopefully fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34301 ACKs for top commit: practicalswift: cr ACKfae4ee545a
: patch looks correct :) Tree-SHA512: 9ece7a5c4bfa60f5e5ffeba3f0ee52a07944c9bd6102588dd7ff7405695e6b32449945b7c41bd25baf38814df5a2436521e655ceff87223ad03c69ed39053023
This commit is contained in:
commit
7d19c85f4a
2 changed files with 11 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <chainparams.h>
|
#include <chainparams.h>
|
||||||
#include <chainparamsbase.h>
|
#include <chainparamsbase.h>
|
||||||
#include <coins.h>
|
#include <coins.h>
|
||||||
|
#include <consensus/tx_check.h>
|
||||||
#include <consensus/tx_verify.h>
|
#include <consensus/tx_verify.h>
|
||||||
#include <consensus/validation.h>
|
#include <consensus/validation.h>
|
||||||
#include <key.h>
|
#include <key.h>
|
||||||
|
@ -230,6 +231,11 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
|
||||||
// consensus/tx_verify.cpp:171: bool Consensus::CheckTxInputs(const CTransaction &, TxValidationState &, const CCoinsViewCache &, int, CAmount &): Assertion `!coin.IsSpent()' failed.
|
// consensus/tx_verify.cpp:171: bool Consensus::CheckTxInputs(const CTransaction &, TxValidationState &, const CCoinsViewCache &, int, CAmount &): Assertion `!coin.IsSpent()' failed.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TxValidationState dummy;
|
||||||
|
if (!CheckTransaction(transaction, dummy)) {
|
||||||
|
// It is not allowed to call CheckTxInputs if CheckTransaction failed
|
||||||
|
return;
|
||||||
|
}
|
||||||
(void)Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out);
|
(void)Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out);
|
||||||
assert(MoneyRange(tx_fee_out));
|
assert(MoneyRange(tx_fee_out));
|
||||||
},
|
},
|
||||||
|
|
|
@ -61,8 +61,11 @@ FUZZ_TARGET_INIT(transaction, initialize_transaction)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
TxValidationState state_with_dupe_check;
|
TxValidationState state_with_dupe_check;
|
||||||
(void)CheckTransaction(tx, state_with_dupe_check);
|
const bool res{CheckTransaction(tx, state_with_dupe_check)};
|
||||||
|
Assert(res == state_with_dupe_check.IsValid());
|
||||||
|
}
|
||||||
|
|
||||||
const CFeeRate dust_relay_fee{DUST_RELAY_TX_FEE};
|
const CFeeRate dust_relay_fee{DUST_RELAY_TX_FEE};
|
||||||
std::string reason;
|
std::string reason;
|
||||||
|
|
Loading…
Add table
Reference in a new issue