Browse Source

PBaaS miner/staker notarization fix

pull/456/head
miketout 2 years ago
parent
commit
b8ed30e8a4
  1. 21
      src/miner.cpp
  2. 26
      src/pbaas/notarization.cpp
  3. 3
      src/pbaas/pbaas.cpp
  4. 3
      src/pbaas/reserves.h
  5. 2
      src/rpc/misc.cpp
  6. 9
      src/rpc/pbaasrpc.cpp

21
src/miner.cpp

@ -3745,14 +3745,6 @@ void static BitcoinMiner_noeq()
}
break;
}
else if ((i + 1) < count)
{
// if we'll not drop through, update hashcount
{
miningTimer += totalDone;
totalDone = 0;
}
}
}
else
{
@ -3804,13 +3796,18 @@ void static BitcoinMiner_noeq()
SetThreadPriority(THREAD_PRIORITY_LOWEST);
break;
}
}
{
miningTimer += totalDone;
if ((i + 1) < count)
{
// if we haven't broken out and will not drop through, update hashcount
{
miningTimer += totalDone;
}
}
}
miningTimer += totalDone;
}
// Check for stop or if block needs to be rebuilt
boost::this_thread::interruption_point();

26
src/pbaas/notarization.cpp

@ -2834,6 +2834,28 @@ bool CPBaaSNotarization::CreateEarnedNotarization(const CRPCChainData &externalS
(ConnectedChains.ThisChain().notarizationProtocol == CCurrencyDefinition::NOTARIZATION_AUTO &&
((isStake && mapBlockIt->second->IsVerusPOSBlock()) || (!isStake && !mapBlockIt->second->IsVerusPOSBlock())))))
{
if (LogAcceptCategory("notarization"))
{
LogPrintf("%s: block period #%d, prior block period #%d, height: %u, notarization protocol: %d, isPoS: %s, is last notarization PoS: %s\n",
__func__,
blockPeriodNumber,
priorBlockPeriod,
height,
ConnectedChains.ThisChain().notarizationProtocol,
isStake ? "true" : "false",
mapBlockIt->second->IsVerusPOSBlock() ? "true" : "false");
if (LogAcceptCategory("verbose"))
{
printf("%s: block period #%d, prior block period #%d, height: %u, notarization protocol: %d, isPoS: %s, is last notarization PoS: %s\n",
__func__,
blockPeriodNumber,
priorBlockPeriod,
height,
ConnectedChains.ThisChain().notarizationProtocol,
isStake ? "true" : "false",
mapBlockIt->second->IsVerusPOSBlock() ? "true" : "false");
}
}
return state.Error("ineligible");
}
@ -2925,8 +2947,8 @@ bool CPBaaSNotarization::CreateEarnedNotarization(const CRPCChainData &externalS
if (LogAcceptCategory("notarization") && LogAcceptCategory("verbose"))
{
std::vector<unsigned char> checkHex = ::AsVector(lastPBN);
LogPrintf("%s: hex of notarization: %s\n", __func__, HexBytes(&(checkHex[0]), checkHex.size()).c_str());
printf("%s: hex of notarization: %s\n", __func__, HexBytes(&(checkHex[0]), checkHex.size()).c_str());
LogPrintf("%s: hex of notarization: %s\nnotarization: %s\n", __func__, HexBytes(&(checkHex[0]), checkHex.size()).c_str(), lastPBN.ToUniValue().write(1,2).c_str());
printf("%s: notarization: %s\n", __func__, lastPBN.ToUniValue().write(1,2).c_str());
}
CNativeHashWriter hw;

3
src/pbaas/pbaas.cpp

@ -634,7 +634,8 @@ bool PrecheckCrossChainExport(const CTransaction &tx, int32_t outNum, CValidatio
return state.Error("Multi-currency operation before PBaaS activation");
}
// TODO: HARDENING - ensure that we have confirmed all totals and fees are correct, then convert all warnings to errors
// TODO: HARDENING - ensure that we have confirmed all totals and fees are correct, especially cross-chain fees
// then convert all warnings to errors
// ensure that this transaction has the appropriate finalization outputs, as required
// check that all reserve transfers are matched to this export, and no others are mined in to the block that should be included

3
src/pbaas/reserves.h

@ -948,7 +948,8 @@ public:
CCurrencyValueMap totalFees; // total fees in all currencies to split between this export and import
CCurrencyValueMap totalBurned; // if this is a cross chain export, some currencies will be burned, the rest held in deposits
// TODO: HARDENING - on next testnet reset, move this variable to before the CCurrencyValueMaps for easier parsing in the contracts
// TODO: HARDENING - on next testnet reset, put exporter right above the currency maps with totalFees as the first map after that
// also ensure that only valid destination system fee currencies can be used for destination - do this in prechecks
CTransferDestination exporter; // typically the exporting miner or staker's address, to accept deferred payment for the export
int32_t firstInput; // if export is from inputs, on chain of reserveTransfers, this is first input, -1 for cross-chain

2
src/rpc/misc.cpp

@ -1628,7 +1628,7 @@ void CurrencyValuesAndNames(UniValue &output, bool spending, const CTransaction
if (spending) {
CTransaction priorOutTx;
uint256 blockHash;
if (myGetTransaction(tx.vin[index].prevout.hash, priorOutTx, blockHash))
if (tx.vin.size() > index && index >= 0 && myGetTransaction(tx.vin[index].prevout.hash, priorOutTx, blockHash))
{
script = priorOutTx.vout[tx.vin[index].prevout.n].scriptPubKey;
}

9
src/rpc/pbaasrpc.cpp

@ -3179,7 +3179,14 @@ UniValue getbestproofroot(const UniValue& params, bool fHelp)
{
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("invalid currency state request for %s", EncodeDestination(CIdentityID(ASSETCHAINS_CHAINID))));
}
currencyStatesUni.push_back(ConnectedChains.GetCurrencyState(targetCur, nHeight).ToUniValue());
if (lastConfirmedRoot.IsValid())
{
confirmedCurrencyStatesUni.push_back(ConnectedChains.GetCurrencyState(targetCur, lastConfirmedRoot.rootHeight).ToUniValue());
}
else
{
currencyStatesUni.push_back(ConnectedChains.GetCurrencyState(targetCur, nHeight).ToUniValue());
}
for (int i = 0; i < currenciesUni.size(); i++)
{

Loading…
Cancel
Save