Fix locking issues in DIP3 unit tests (#2285)
* Don't use GetTransaction in CheckProUpRegTx GetTransaction locks mempool.cs internally. This brings messes up the locking order of cs_main, mempool.cs and CCheckQueue::ControlMutex. * Lock cs_main in TestChainSetup::CreateBlock when updating CbTx
This commit is contained in:
parent
1e74bcace9
commit
2a95dd30c5
@ -190,11 +190,11 @@ bool CheckProUpRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CVal
|
|||||||
|
|
||||||
// This is a temporary restriction that will be lifted later
|
// This is a temporary restriction that will be lifted later
|
||||||
// It is required while we are transitioning from the old MN list to the deterministic list
|
// It is required while we are transitioning from the old MN list to the deterministic list
|
||||||
CTransactionRef proRegTx;
|
Coin coin;
|
||||||
uint256 tmpHashBlock;
|
if (!GetUTXOCoin(COutPoint(dmn->proTxHash, dmn->nCollateralIndex), coin) || coin.IsSpent()) {
|
||||||
if (!GetTransaction(ptx.proTxHash, proRegTx, Params().GetConsensus(), tmpHashBlock))
|
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-protx-payee-collateral");
|
return state.DoS(100, false, REJECT_INVALID, "bad-protx-payee-collateral");
|
||||||
if (proRegTx->vout[dmn->nCollateralIndex].scriptPubKey != ptx.scriptPayout)
|
}
|
||||||
|
if (coin.out.scriptPubKey != ptx.scriptPayout)
|
||||||
return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee-collateral");
|
return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee-collateral");
|
||||||
|
|
||||||
if (mnList.HasUniqueProperty(ptx.keyIDOperator)) {
|
if (mnList.HasUniqueProperty(ptx.keyIDOperator)) {
|
||||||
|
@ -151,6 +151,7 @@ CBlock TestChainSetup::CreateBlock(const std::vector<CMutableTransaction>& txns,
|
|||||||
|
|
||||||
// Manually update CbTx as we modified the block here
|
// Manually update CbTx as we modified the block here
|
||||||
if (block.vtx[0]->nType == TRANSACTION_COINBASE) {
|
if (block.vtx[0]->nType == TRANSACTION_COINBASE) {
|
||||||
|
LOCK(cs_main);
|
||||||
CCbTx cbTx;
|
CCbTx cbTx;
|
||||||
if (!GetTxPayload(*block.vtx[0], cbTx)) {
|
if (!GetTxPayload(*block.vtx[0], cbTx)) {
|
||||||
BOOST_ASSERT(false);
|
BOOST_ASSERT(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user