| 600 | } |
| 601 | |
| 602 | bool BlockAssembler::AttemptToAddContractToBlock(CTxMemPool::txiter iter, uint64_t minGasPrice) { |
| 603 | if (nTimeLimit != 0 && GetAdjustedTime() >= nTimeLimit - BYTECODE_TIME_BUFFER) { |
| 604 | return false; |
| 605 | } |
| 606 | if (GetBoolArg("-disablecontractstaking", false)) |
| 607 | { |
| 608 | return false; |
| 609 | } |
| 610 | |
| 611 | CBlockIndex* pindexState = chainActive.Tip(); |
| 612 | dev::h256 oldHashStateRoot = getGlobalStateRoot(pindexState); |
| 613 | dev::h256 oldHashUTXORoot = getGlobalStateUTXO(pindexState); |
| 614 | |
| 615 | // operate on local vars first, then later apply to `this` |
| 616 | uint64_t nBlockWeight = this->nBlockWeight; |
| 617 | uint64_t nBlockSize = this->nBlockSize; |
| 618 | uint64_t nBlockSigOpsCost = this->nBlockSigOpsCost; |
| 619 | |
| 620 | LuxTxConverter convert(iter->GetTx(), NULL, &pblock->vtx); |
| 621 | |
| 622 | ExtractLuxTX resultConverter; |
| 623 | if(!convert.extractionLuxTransactions(resultConverter)){ |
| 624 | //this check already happens when accepting txs into mempool |
| 625 | //therefore, this can only be triggered by using raw transactions on the staker itself |
| 626 | return false; |
| 627 | } |
| 628 | std::vector<LuxTransaction> luxTransactions = resultConverter.first; |
| 629 | dev::u256 txGas = 0; |
| 630 | for(LuxTransaction luxTransaction : luxTransactions){ |
| 631 | txGas += luxTransaction.gas(); |
| 632 | if(txGas > txGasLimit) { |
| 633 | // Limit the tx gas limit by the soft limit if such a limit has been specified. |
| 634 | return false; |
| 635 | } |
| 636 | |
| 637 | if(bceResult.usedGas + luxTransaction.gas() > softBlockGasLimit){ |
| 638 | //if this transaction's gasLimit could cause block gas limit to be exceeded, then don't add it |
| 639 | return false; |
| 640 | } |
| 641 | if(luxTransaction.gasPrice() < minGasPrice){ |
| 642 | //if this transaction's gasPrice is less than the current DGP minGasPrice don't add it |
| 643 | return false; |
| 644 | } |
| 645 | } |
| 646 | // We need to pass the DGP's block gas limit (not the soft limit) since it is consensus critical. |
| 647 | ByteCodeExec exec(*pblock, luxTransactions, hardBlockGasLimit); |
| 648 | if(!exec.performByteCode()){ |
| 649 | //error, don't add contract |
| 650 | setGlobalStateRoot(oldHashStateRoot); |
| 651 | setGlobalStateUTXO(oldHashUTXORoot); |
| 652 | return false; |
| 653 | } |
| 654 | |
| 655 | ByteCodeExecResult testExecResult; |
| 656 | if(!exec.processingResults(testExecResult)){ |
| 657 | setGlobalStateRoot(oldHashStateRoot); |
| 658 | setGlobalStateUTXO(oldHashUTXORoot); |
| 659 | return false; |
nothing calls this directly
no test coverage detected