Skip to content

Commit

Permalink
Merge pull request jl777#2 from miketout/dev
Browse files Browse the repository at this point in the history
Enable PBaaS on testnet
  • Loading branch information
Asherda authored Jun 18, 2019
2 parents fb7b9e3 + 4802c85 commit 82ef063
Show file tree
Hide file tree
Showing 12 changed files with 390 additions and 70 deletions.
8 changes: 5 additions & 3 deletions src/cc/CCcustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,11 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode)
cp->ismyvin = IsServiceRewardInput;
break;

case EVAL_RESERVEIMPORT:
case EVAL_RESERVEEXPORT:
case EVAL_RESERVEOUTPUT:
case EVAL_INSTANTSPEND:
case EVAL_CROSSCHAIN_INPUT:
case EVAL_CROSSCHAIN_OUTPUT:
case EVAL_CROSSCHAIN_IMPORT:
case EVAL_CROSSCHAIN_EXPORT:
assert(false);
break;

Expand Down
16 changes: 12 additions & 4 deletions src/cc/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,23 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn)
std::vector<uint8_t> vparams(cond->code+1, cond->code+cond->codeLength);
switch ( ecode )
{
case EVAL_STAKEGUARD:
case EVAL_PBAASDEFINITION:
case EVAL_SERVICEREWARD:
case EVAL_EARNEDNOTARIZATION:
case EVAL_ACCEPTEDNOTARIZATION:
case EVAL_FINALIZENOTARIZATION:
case EVAL_RESERVEOUTPUT:
case EVAL_RESERVEEXPORT:
case EVAL_RESERVEIMPORT:
case EVAL_CROSSCHAIN_OUTPUT:
case EVAL_CROSSCHAIN_EXPORT:
case EVAL_CROSSCHAIN_IMPORT:
case EVAL_INSTANTSPEND:
case EVAL_CROSSCHAIN_INPUT:
if (!chainActive.LastTip() || CConstVerusSolutionVector::activationHeight.ActiveVersion(chainActive.LastTip()->GetHeight()) < CActivationHeight::SOLUTION_VERUSV3)
{
// if chain is not able to process this yet, don't drop through to do so
break;
}

case EVAL_STAKEGUARD:
return(ProcessCC(cp,this, vparams, txTo, nIn));
break;

Expand Down
14 changes: 9 additions & 5 deletions src/cc/eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@
EVAL(EVAL_EARNEDNOTARIZATION, 0x4) \
EVAL(EVAL_ACCEPTEDNOTARIZATION, 0x5) \
EVAL(EVAL_FINALIZENOTARIZATION, 0x6) \
EVAL(EVAL_RESERVEOUTPUT, 0x7) \
EVAL(EVAL_RESERVEEXPORT, 0x8) \
EVAL(EVAL_RESERVEIMPORT, 0x9) \
EVAL(EVAL_INSTANTSPEND, 0x7) \
EVAL(EVAL_CROSSCHAIN_INPUT, 0x8) \
EVAL(EVAL_CROSSCHAIN_OUTPUT, 0x9) \
EVAL(EVAL_CROSSCHAIN_EXPORT, 0xa) \
EVAL(EVAL_CROSSCHAIN_IMPORT, 0xb) \
EVAL(EVAL_RESERVE_OUTPUT, 0xc) \
EVAL(EVAL_RESERVE_EXCHANGE, 0xd) \
EVAL(EVAL_IMPORTPAYOUT, 0xe1) \
EVAL(EVAL_IMPORTCOIN, 0xe2) \
EVAL(EVAL_ASSETS, 0xe3) \
EVAL(EVAL_IMPORTCOIN, 0xe2) \
EVAL(EVAL_ASSETS, 0xe3) \
EVAL(EVAL_FAUCET, 0xe4) \
EVAL(EVAL_REWARDS, 0xe5) \
EVAL(EVAL_DICE, 0xe6) \
Expand Down
2 changes: 1 addition & 1 deletion src/komodo_bitcoind.h
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
{
txnouttype tp;
std::vector<std::vector<unsigned char>> vvch = std::vector<std::vector<unsigned char>>();
// solve all outputs to check that destinations all go only to the pk
// solve all outputs to check that non-instantspend destinations all go only to the pk
// specified in the stake params
if ((!supportInstantSpend || !vout.scriptPubKey.IsInstantSpend()) &&
(!Solver(vout.scriptPubKey, tp, vvch) ||
Expand Down
7 changes: 4 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ bool AcceptToMemoryPoolInt(CTxMemPool& pool, CValidationState &state, const CTra
{
return error("AcceptToMemoryPool: non-coinbase with null input tx");
}
/*
CTransaction inputTx;
uint256 blkHash;
if (myGetTransaction(tx.vin[j].prevout.hash, inputTx, blkHash))
Expand All @@ -1609,13 +1610,13 @@ bool AcceptToMemoryPoolInt(CTxMemPool& pool, CValidationState &state, const CTra
printf("transaction input from %s on input %d is not a notarization\n", tx.vin[j].prevout.hash.GetHex().c_str(), tx.vin[j].prevout.n);
}
}
*/
}
}
printf("%s%s at height %d has no outputs\n", tx.IsCoinBase() ? "coinbase transaction" : "transaction #", tx.GetHash().GetHex().c_str(), simHeight);
LogPrintf("%s%s at height %d has no outputs\n", tx.IsCoinBase() ? "coinbase transaction" : "transaction #", tx.GetHash().GetHex().c_str(), simHeight);
//printf("%s%s at height %d has no outputs\n", tx.IsCoinBase() ? "coinbase transaction" : "transaction #", tx.GetHash().GetHex().c_str(), simHeight);
//LogPrintf("%s%s at height %d has no outputs\n", tx.IsCoinBase() ? "coinbase transaction" : "transaction #", tx.GetHash().GetHex().c_str(), simHeight);
}


auto verifier = libzcash::ProofVerifier::Strict();
if ( komodo_validate_interest(tx,chainActive.LastTip()->GetHeight()+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 )
{
Expand Down
7 changes: 7 additions & 0 deletions src/pbaas/notarization.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ class CNotarizationFinalization
{
return ::AsVector(*this);
}

UniValue ToUniValue() const
{
UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("confirmedinput", confirmedInput));
return ret;
}
};

class CChainNotarizationData
Expand Down
24 changes: 19 additions & 5 deletions src/pbaas/pbaas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,16 @@ CServiceReward::CServiceReward(const CTransaction &tx, bool validate)
}


CCrossChainInput::CCrossChainInput(const CTransaction &tx)
{
// TODO - finish
}

CCrossChainInput::CCrossChainInput(const UniValue &obj)
{
// TODO - finish
}

uint160 CPBaaSChainDefinition::GetChainID(std::string name)
{
const char *chainName = name.c_str();
Expand Down Expand Up @@ -764,10 +774,11 @@ vector<pair<string, UniValue>> CConnectedChains::SubmitQualifiedBlocks()
inHeader.insert(pbh.chainID);
}

uint160 chainID;
// now look through all targets that are equal to or above the hash of this header
for (auto chainIt = mergeMinedTargets.lower_bound(headerIt->first); !submissionFound && chainIt != mergeMinedTargets.end(); chainIt++)
{
uint160 chainID = chainIt->second->GetChainID();
chainID = chainIt->second->GetChainID();
if (inHeader.count(chainID))
{
// first, check that the winning header matches the block that is there
Expand All @@ -782,9 +793,6 @@ vector<pair<string, UniValue>> CConnectedChains::SubmitQualifiedBlocks()

*(CBlockHeader *)&chainData.block = headerIt->second;

// once it is going to be submitted, remove block from this chain until a new one is added again
RemoveMergedBlock(chainID);

submissionFound = true;
}
//else // not an error condition. code is here for debugging
Expand All @@ -799,7 +807,13 @@ vector<pair<string, UniValue>> CConnectedChains::SubmitQualifiedBlocks()
}

// if this header matched no block, discard and move to the next, otherwise, we'll drop through
if (!submissionFound)
if (submissionFound)
{
// once it is going to be submitted, remove block from this chain until a new one is added again
RemoveMergedBlock(chainID);
break;
}
else
{
qualifiedHeaders.erase(headerIt);
}
Expand Down
Loading

0 comments on commit 82ef063

Please sign in to comment.