@@ -441,12 +441,13 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
441441 vTxHashes.emplace_back (hash, newit);
442442 newit->vTxHashesIdx = vTxHashes.size () - 1 ;
443443
444+ // Invalid ProTxes should never get this far because transactions should be
445+ // fully checked by AcceptToMemoryPool() at this point, so we just assume that
446+ // everything is fine here.
444447 if (tx.nType == TRANSACTION_PROVIDER_REGISTER) {
445448 CProRegTx proTx;
446- if (!GetTxPayload (tx, proTx)) {
447- LogPrintf (" %s: ERROR: Invalid transaction payload, tx: %s" , __func__, tx.ToString ());
448- return false ;
449- }
449+ bool ok = GetTxPayload (tx, proTx);
450+ assert (ok);
450451 if (!proTx.collateralOutpoint .hash .IsNull ()) {
451452 mapProTxRefs.emplace (tx.GetHash (), proTx.collateralOutpoint .hash );
452453 }
@@ -458,36 +459,29 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
458459 }
459460 } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
460461 CProUpServTx proTx;
461- if (!GetTxPayload (tx, proTx)) {
462- LogPrintf (" %s: ERROR: Invalid transaction payload, tx: %s" , __func__, tx.ToString ());
463- return false ;
464- }
462+ bool ok = GetTxPayload (tx, proTx);
463+ assert (ok);
465464 mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
466465 mapProTxAddresses.emplace (proTx.addr , tx.GetHash ());
467466 } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
468467 CProUpRegTx proTx;
469- if (!GetTxPayload (tx, proTx)) {
470- LogPrintf (" %s: ERROR: Invalid transaction payload, tx: %s" , __func__, tx.ToString ());
471- return false ;
472- }
468+ bool ok = GetTxPayload (tx, proTx);
469+ assert (ok);
473470 mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
474471 mapProTxBlsPubKeyHashes.emplace (proTx.pubKeyOperator .GetHash (), tx.GetHash ());
475-
476472 auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
477- assert (dmn); // we should never get such a ProTx into the mempool
473+ assert (dmn);
478474 newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
479475 if (dmn->pdmnState ->pubKeyOperator != proTx.pubKeyOperator ) {
480476 newit->isKeyChangeProTx = true ;
481477 }
482478 } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
483479 CProUpRevTx proTx;
484- if (!GetTxPayload (tx, proTx)) {
485- LogPrintf (" %s: ERROR: Invalid transaction payload, tx: %s" , __func__, tx.ToString ());
486- return false ;
487- }
480+ bool ok = GetTxPayload (tx, proTx);
481+ assert (ok);
488482 mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
489483 auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
490- assert (dmn); // we should never get such a ProTx into the mempool
484+ assert (dmn);
491485 newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
492486 if (dmn->pdmnState ->pubKeyOperator != CBLSPublicKey ()) {
493487 newit->isKeyChangeProTx = true ;
@@ -1306,9 +1300,13 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const {
13061300 return true ; // i.e. can't decode payload == conflict
13071301 }
13081302
1309- // only allow one operator key change in the mempool
1303+ // this method should only be called with validated ProTxs
13101304 auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
1311- assert (dmn); // this method should only be called with validated ProTxs
1305+ if (!dmn) {
1306+ LogPrintf (" %s: ERROR: Masternode is not in the list, proTxHash: %s" , __func__, proTx.proTxHash .ToString ());
1307+ return true ; // i.e. failed to find validated ProTx == conflict
1308+ }
1309+ // only allow one operator key change in the mempool
13121310 if (dmn->pdmnState ->pubKeyOperator != proTx.pubKeyOperator ) {
13131311 if (hasKeyChangeInMempool (proTx.proTxHash )) {
13141312 return true ;
@@ -1324,9 +1322,13 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const {
13241322 return true ; // i.e. can't decode payload == conflict
13251323 }
13261324
1327- // only allow one operator key change in the mempool
1325+ // this method should only be called with validated ProTxs
13281326 auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
1329- assert (dmn); // this method should only be called with validated ProTxs
1327+ if (!dmn) {
1328+ LogPrintf (" %s: ERROR: Masternode is not in the list, proTxHash: %s" , __func__, proTx.proTxHash .ToString ());
1329+ return true ; // i.e. failed to find validated ProTx == conflict
1330+ }
1331+ // only allow one operator key change in the mempool
13301332 if (dmn->pdmnState ->pubKeyOperator != CBLSPublicKey ()) {
13311333 if (hasKeyChangeInMempool (proTx.proTxHash )) {
13321334 return true ;
0 commit comments