message: Disallow version 0 contract transactions outside of the AAL
diff: @@ -791,7 +791,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
  VersionVM v = qtumTransaction.getVersion();
  if(v.format!=0)
  return state.DoS(100, error("AcceptToMempool(): Contract execution uses unknown version format"), REJECT_INVALID, "bad-tx-version-format");
  - if(!(v.rootVM == 0 || v.rootVM == 1))
  + if(v.rootVM != 1)
  return state.DoS(100, error("AcceptToMempool(): Contract execution uses unknown root VM"), REJECT_INVALID, "bad-tx-version-rootvm");
  if(v.vmVersion != 0)
  return state.DoS(100, error("AcceptToMempool(): Contract execution uses unknown VM version"), REJECT_INVALID, "bad-tx-version-vmversion");
  @@ -2691,10 +2691,19 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
  //validate VM version and other ETH params before execution
  //Reject anything unknown (could be changed later by DGP)
  //TODO evaluate if this should be relaxed for soft-fork purposes
  + bool nonZeroVersion=false;
  for(QtumTransaction& qtx : resultConvertQtumTX.first){
  VersionVM v = qtx.getVersion();
  if(v.format!=0)
  return state.DoS(100, error("ConnectBlock(): Contract execution uses unknown version format"), REJECT_INVALID, "bad-tx-version-format");
  + if(v.rootVM != 0){
  + nonZeroVersion=true;
  + }else{
  + if(nonZeroVersion){
  + //If an output is version 0, then do not allow any other versions in the same tx
  + return state.DoS(100, error("ConnectBlock(): Contract tx has mixed version 0 and non-0 VM executions"), REJECT_INVALID, "bad-tx-mixed-zero-versions");
  + }
  + }
  if(!(v.rootVM == 0 || v.rootVM == 1))
  return state.DoS(100, error("ConnectBlock(): Contract execution uses unknown root VM"), REJECT_INVALID, "bad-tx-version-rootvm");
  if(v.vmVersion != 0)
  @@ -2718,6 +2727,22 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
  return state.DoS(100, error("ConnectBlock(): Contract execution has lower gas price than allowed"), REJECT_INVALID, "bad-tx-low-gas-price");
  }
  + if(!nonZeroVersion){
  + //if tx is 0 version, then the tx must already have been added by a previous contract execution
  + bool found=false;
  + //iterate backwards because the AAL tx should have been added by the last contract exec, though there can be multiple txs by a single contract tx
  + for (unsigned int j = checkBlock.vtx.size()-1; j > 0; j--)
  + {
  + const CTransaction &ctx = *(checkBlock.vtx[j]);
  + if(ctx.GetHash() == tx.GetHash()){
  + found = true;
  + }
  + }
  + if(!found){
  + return state.DoS(100, error("ConnectBlock(): Version 0 contract executions are not allowed unless created by the AAL "), REJECT_INVALID, "bad-tx-improper-version-0");
  + }
  + }
  +
  if(!exec.performByteCode()){
  return state.DoS(100, error("ConnectBlock(): Unknown error during contract execution"), REJECT_INVALID, "bad-tx-unknown-error");
  }
  