Browse Source

Merge remote-tracking branch 'mike/dev' into dev

pull/438/head
Asher Dawes 2 years ago
parent
commit
a86f6e2f3f
  1. 2
      src/main.cpp
  2. 2
      src/miner.cpp
  3. 66
      src/pbaas/notarization.cpp
  4. 8
      src/rpc/pbaasrpc.cpp

2
src/main.cpp

@ -4318,7 +4318,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
{
gatewayDeposits += originalFees;
}
gatewayDeposits.valueMap[cbCurID] += gatewayDepositsUsed.valueMap[cbCurID];
gatewayDeposits.valueMap[cbCurID] += gatewayDepositsUsed.valueMap[cbCurID] + newNotarization.currencyState.primaryCurrencyOut;
printf("importedcurrency %s\nspentcurrencyout %s\nnewgatewaydeposits %s\n",
importedCurrency.ToUniValue().write(1,2).c_str(),

2
src/miner.cpp

@ -925,7 +925,7 @@ bool AddOneCurrencyImport(const CCurrencyDefinition &newCurrency,
gatewayDeposits += originalFees;
}
gatewayDeposits.valueMap[newCurID] += gatewayDepositsUsed.valueMap[newCurID];
gatewayDeposits.valueMap[newCurID] += gatewayDepositsUsed.valueMap[newCurID] + newNotarization.currencyState.primaryCurrencyOut;
printf("importedcurrency %s\nspentcurrencyout %s\ngatewaydeposits %s\n",
importedCurrency.ToUniValue().write(1,2).c_str(),

66
src/pbaas/notarization.cpp

@ -1270,12 +1270,9 @@ bool CPBaaSNotarization::NextNotarizationInfo(const CCurrencyDefinition &sourceS
if (tempState.IsPrelaunch())
{
tempState.reserveIn = tempState.AddVectors(tempState.reserveIn, this->currencyState.reserveIn);
if (!destCurrency.IsFractional() && !this->IsDefinitionNotarization())
if (!destCurrency.IsFractional() && !this->IsDefinitionNotarization() && !tempState.IsLaunchClear())
{
if (this->currencyState.IsLaunchClear())
{
tempState.supply += this->currencyState.supply - this->currencyState.emitted;
}
tempState.supply += this->currencyState.supply - this->currencyState.emitted;
tempState.preConvertedOut += this->currencyState.preConvertedOut;
tempState.primaryCurrencyOut += this->currencyState.primaryCurrencyOut;
}
@ -4281,38 +4278,40 @@ std::vector<uint256> CPBaaSNotarization::SubmitFinalizedNotarizations(const CRPC
confirmingIdx = crosschainCND.IsConfirmed() ? crosschainCND.lastConfirmed : 0;
CObjectFinalization finalizationObj;
if (!isFirstLaunchingNotarization &&
!crosschainCND.vtx[confirmingIdx].second.FindEarnedNotarization(finalizationObj, &earnedNotarizationIndexEntry))
{
return retVal;
}
else if (!finalizationObj.IsValid() || !finalizationObj.IsConfirmed())
if (!isFirstLaunchingNotarization)
{
// the notarization considered confirmed on the other
// chain must be in the same notarization chain as the one confirmed on this chain that would
// be true if it is on both chains, accurate on both, and behind this confirmed notarization
CTransaction notarizationTx;
CPBaaSNotarization checkNotarization1, checkNotarization2 = crosschainCND.vtx[confirmingIdx].second;
uint256 blkHash;
COptCCParams nP;
if (!myGetTransaction(earnedNotarizationIndexEntry.first.txhash, notarizationTx, blkHash) ||
earnedNotarizationIndexEntry.first.index >= notarizationTx.vout.size() ||
!(notarizationTx.vout[earnedNotarizationIndexEntry.first.index].scriptPubKey.IsPayToCryptoCondition(nP) &&
nP.IsValid() &&
nP.evalCode == EVAL_EARNEDNOTARIZATION &&
nP.vData.size() &&
(checkNotarization1 = CPBaaSNotarization(nP.vData[0])).IsValid() &&
checkNotarization2.SetMirror(false) &&
::AsVector(checkNotarization1) == ::AsVector(checkNotarization2) &&
checkNotarization1.proofRoots.count(ASSETCHAINS_CHAINID) &&
checkNotarization2.proofRoots.count(ASSETCHAINS_CHAINID) &&
checkNotarization1.proofRoots[ASSETCHAINS_CHAINID].rootHeight < checkNotarization2.proofRoots[ASSETCHAINS_CHAINID].rootHeight))
if (!crosschainCND.vtx[confirmingIdx].second.FindEarnedNotarization(finalizationObj, &earnedNotarizationIndexEntry))
{
LogPrintf("Invalid notarization index entry for txid: %s\n", earnedNotarizationIndexEntry.first.txhash.GetHex().c_str());
printf("Invalid notarization index entry for txid: %s\n", earnedNotarizationIndexEntry.first.txhash.GetHex().c_str());
return retVal;
}
}
else if (!finalizationObj.IsValid() || !finalizationObj.IsConfirmed())
{
// the notarization considered confirmed on the other
// chain must be in the same notarization chain as the one confirmed on this chain that would
// be true if it is on both chains, accurate on both, and behind this confirmed notarization
CTransaction notarizationTx;
CPBaaSNotarization checkNotarization1, checkNotarization2 = crosschainCND.vtx[confirmingIdx].second;
uint256 blkHash;
COptCCParams nP;
if (!myGetTransaction(earnedNotarizationIndexEntry.first.txhash, notarizationTx, blkHash) ||
earnedNotarizationIndexEntry.first.index >= notarizationTx.vout.size() ||
!(notarizationTx.vout[earnedNotarizationIndexEntry.first.index].scriptPubKey.IsPayToCryptoCondition(nP) &&
nP.IsValid() &&
nP.evalCode == EVAL_EARNEDNOTARIZATION &&
nP.vData.size() &&
(checkNotarization1 = CPBaaSNotarization(nP.vData[0])).IsValid() &&
checkNotarization2.SetMirror(false) &&
::AsVector(checkNotarization1) == ::AsVector(checkNotarization2) &&
checkNotarization1.proofRoots.count(ASSETCHAINS_CHAINID) &&
checkNotarization2.proofRoots.count(ASSETCHAINS_CHAINID) &&
checkNotarization1.proofRoots[ASSETCHAINS_CHAINID].rootHeight < checkNotarization2.proofRoots[ASSETCHAINS_CHAINID].rootHeight))
{
LogPrintf("Invalid notarization index entry for txid: %s\n", earnedNotarizationIndexEntry.first.txhash.GetHex().c_str());
printf("Invalid notarization index entry for txid: %s\n", earnedNotarizationIndexEntry.first.txhash.GetHex().c_str());
return retVal;
}
}
}
}
// if we have pending notarizations, see which of the possible ones we agree with
@ -4462,6 +4461,7 @@ std::vector<uint256> CPBaaSNotarization::SubmitFinalizedNotarizations(const CRPC
}
}
// TODO: HARDENING - ensure that notarizationTxInfo gets passed to the other side
if (!isFirstLaunchingNotarization && !(notarizationTxInfo.second.IsValid() && notarizationTxInfo.second.components.size()))
{
LogPrintf("Cannot construct notarization proof for %s\n", EncodeDestination(CIdentityID(systemID)).c_str());

8
src/rpc/pbaasrpc.cpp

@ -3161,6 +3161,10 @@ UniValue getbestproofroot(const UniValue& params, bool fHelp)
retVal.pushKV("laststableproofroot", lastConfirmedRoot.ToUniValue());
retVal.pushKV("lastconfirmedindex", validRoots[lastConfirmedRoot.rootHeight]);
}
else if (lastConfirmedRoot.IsValid())
{
retVal.pushKV("laststableproofroot", lastConfirmedRoot.ToUniValue());
}
else
{
retVal.pushKV("laststableproofroot", CProofRoot::GetProofRoot((nHeight - COINBASE_MATURITY) > 0 ? (nHeight - COINBASE_MATURITY) : 1).ToUniValue());
@ -6742,9 +6746,9 @@ UniValue sendcurrency(const UniValue& params, bool fHelp)
{
throw JSONRPCError(RPC_INVALID_PARAMETER, "To specify a fractional currency converter, \"currency\" and \"convertto\" must both be reserves of \"via\"");
}
if (burnCurrency || mintNew || preConvert)
if (mintNew || preConvert)
{
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot combine reserve to reserve conversion with burning, minting, or preconversion");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot combine reserve to reserve conversion with minting or preconversion");
}
if (convertToCurrencyID.IsNull())
{

Loading…
Cancel
Save