Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12428699
D6742.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D6742.id.diff
View Options
diff --git a/src/consensus/validation.h b/src/consensus/validation.h
--- a/src/consensus/validation.h
+++ b/src/consensus/validation.h
@@ -70,6 +70,30 @@
TX_MEMPOOL_POLICY,
};
+inline bool IsTransactionReason(ValidationInvalidReason r) {
+ return r == ValidationInvalidReason::NONE ||
+ r == ValidationInvalidReason::CONSENSUS ||
+ r == ValidationInvalidReason::RECENT_CONSENSUS_CHANGE ||
+ r == ValidationInvalidReason::TX_NOT_STANDARD ||
+ r == ValidationInvalidReason::TX_MISSING_INPUTS ||
+ r == ValidationInvalidReason::TX_CONFLICT ||
+ r == ValidationInvalidReason::TX_MEMPOOL_POLICY;
+}
+
+inline bool IsBlockReason(ValidationInvalidReason r) {
+ return r == ValidationInvalidReason::NONE ||
+ r == ValidationInvalidReason::CONSENSUS ||
+ r == ValidationInvalidReason::RECENT_CONSENSUS_CHANGE ||
+ r == ValidationInvalidReason::CACHED_INVALID ||
+ r == ValidationInvalidReason::BLOCK_INVALID_HEADER ||
+ r == ValidationInvalidReason::BLOCK_MUTATED ||
+ r == ValidationInvalidReason::BLOCK_MISSING_PREV ||
+ r == ValidationInvalidReason::BLOCK_INVALID_PREV ||
+ r == ValidationInvalidReason::BLOCK_TIME_FUTURE ||
+ r == ValidationInvalidReason::BLOCK_CHECKPOINT ||
+ r == ValidationInvalidReason::BLOCK_FINALIZATION;
+}
+
/** Capture information about block/transaction validation */
class CValidationState {
private:
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1202,6 +1202,7 @@
* transactions from a whitelisted peer that we can safely relay.
*/
static bool TxRelayMayResultInDisconnect(const CValidationState &state) {
+ assert(IsTransactionReason(state.GetReason()));
return state.GetReason() == ValidationInvalidReason::CONSENSUS;
}
@@ -2206,6 +2207,7 @@
// Probably non-standard or insufficient fee
LogPrint(BCLog::MEMPOOL, " removed orphan tx %s\n",
orphanTxId.ToString());
+ assert(IsTransactionReason(orphan_state.GetReason()));
assert(recentRejects);
recentRejects->insert(orphanTxId);
@@ -3042,8 +3044,11 @@
recentRejects->insert(tx.GetId());
}
} else {
+ assert(IsTransactionReason(state.GetReason()));
+
assert(recentRejects);
recentRejects->insert(tx.GetId());
+
if (RecursiveDynamicUsage(*ptx) < 100000) {
AddToCompactExtraTransactions(ptx);
}
diff --git a/src/validation.cpp b/src/validation.cpp
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -519,6 +519,7 @@
if (!CheckInputs(tx, state, view, true, scriptVerifyFlags, true, false,
txdata, nSigChecksStandard)) {
// State filled in by CheckInputs.
+ assert(IsTransactionReason(state.GetReason()));
return false;
}
@@ -1708,6 +1709,8 @@
state.GetRejectCode(), state.GetRejectReason(),
state.GetDebugMessage());
}
+
+ assert(IsBlockReason(state.GetReason()));
return error("%s: Consensus::CheckTxInputs: %s, %s", __func__,
tx.GetId().ToString(), FormatStateMessage(state));
}
@@ -4003,6 +4006,7 @@
if (!CheckBlock(block, state, consensusParams,
BlockValidationOptions(config)) ||
!ContextualCheckBlock(block, state, consensusParams, pindex->pprev)) {
+ assert(IsBlockReason(state.GetReason()));
if (state.IsInvalid() &&
state.GetReason() != ValidationInvalidReason::BLOCK_MUTATED) {
pindex->nStatus = pindex->nStatus.withFailed();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 28, 19:18 (7 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4844918
Default Alt Text
D6742.id.diff (3 KB)
Attached To
D6742: Assert validation reasons are contextually correct
Event Timeline
Log In to Comment