Prevent possible skip of notarisation on KMD
This commit is contained in:
@@ -69,7 +69,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh
|
|||||||
destNotarisationTxid = nota.first;
|
destNotarisationTxid = nota.first;
|
||||||
else if (seenOwnNotarisations == 2)
|
else if (seenOwnNotarisations == 2)
|
||||||
goto end;
|
goto end;
|
||||||
break;
|
//break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ int ScanNotarisationsFromHeight(int nHeight, const IsTarget f, Notarisation &fou
|
|||||||
{
|
{
|
||||||
int limit = std::min(nHeight + NOTARISATION_SCAN_LIMIT_BLOCKS, chainActive.Height());
|
int limit = std::min(nHeight + NOTARISATION_SCAN_LIMIT_BLOCKS, chainActive.Height());
|
||||||
int start = std::max(nHeight, 1);
|
int start = std::max(nHeight, 1);
|
||||||
|
|
||||||
for (int h=start; h<limit; h++) {
|
for (int h=start; h<limit; h++) {
|
||||||
NotarisationsInBlock notarisations;
|
NotarisationsInBlock notarisations;
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
|
|||||||
*/
|
*/
|
||||||
EvalRef eval;
|
EvalRef eval;
|
||||||
uint256 MoM = assetChainProof.second.Exec(txid);
|
uint256 MoM = assetChainProof.second.Exec(txid);
|
||||||
|
|
||||||
// Get a kmd height for given notarisation Txid
|
// Get a kmd height for given notarisation Txid
|
||||||
int kmdHeight;
|
int kmdHeight;
|
||||||
{
|
{
|
||||||
@@ -158,7 +158,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
|
|||||||
uint256 MoMoM = CalculateProofRoot(targetSymbol, targetCCid, kmdHeight, moms, targetChainNotarisationTxid);
|
uint256 MoMoM = CalculateProofRoot(targetSymbol, targetCCid, kmdHeight, moms, targetChainNotarisationTxid);
|
||||||
if (MoMoM.IsNull())
|
if (MoMoM.IsNull())
|
||||||
throw std::runtime_error("No MoMs found");
|
throw std::runtime_error("No MoMs found");
|
||||||
|
|
||||||
// Find index of source MoM in MoMoM
|
// Find index of source MoM in MoMoM
|
||||||
int nIndex;
|
int nIndex;
|
||||||
for (nIndex=0; nIndex<moms.size(); nIndex++) {
|
for (nIndex=0; nIndex<moms.size(); nIndex++) {
|
||||||
@@ -311,7 +311,7 @@ TxProof GetAssetchainProof(uint256 hash)
|
|||||||
};
|
};
|
||||||
if (!ScanNotarisationsFromHeight(blockIndex->GetHeight(), isTarget, nota))
|
if (!ScanNotarisationsFromHeight(blockIndex->GetHeight(), isTarget, nota))
|
||||||
throw std::runtime_error("backnotarisation not yet confirmed");
|
throw std::runtime_error("backnotarisation not yet confirmed");
|
||||||
|
|
||||||
// index of block in MoM leaves
|
// index of block in MoM leaves
|
||||||
nIndex = nota.second.height - blockIndex->GetHeight();
|
nIndex = nota.second.height - blockIndex->GetHeight();
|
||||||
}
|
}
|
||||||
@@ -325,7 +325,7 @@ TxProof GetAssetchainProof(uint256 hash)
|
|||||||
}
|
}
|
||||||
bool fMutated;
|
bool fMutated;
|
||||||
BuildMerkleTree(&fMutated, leaves, tree);
|
BuildMerkleTree(&fMutated, leaves, tree);
|
||||||
branch = GetMerkleBranch(nIndex, leaves.size(), tree);
|
branch = GetMerkleBranch(nIndex, leaves.size(), tree);
|
||||||
|
|
||||||
// Check branch
|
// Check branch
|
||||||
uint256 ourResult = SafeCheckMerkleBranch(blockIndex->hashMerkleRoot, branch, nIndex);
|
uint256 ourResult = SafeCheckMerkleBranch(blockIndex->hashMerkleRoot, branch, nIndex);
|
||||||
@@ -364,7 +364,7 @@ TxProof GetAssetchainProof(uint256 hash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check the proof
|
// Check the proof
|
||||||
if (nota.second.MoM != CBlock::CheckMerkleBranch(hash, branch, nIndex))
|
if (nota.second.MoM != CBlock::CheckMerkleBranch(hash, branch, nIndex))
|
||||||
throw std::runtime_error("Failed validating MoM");
|
throw std::runtime_error("Failed validating MoM");
|
||||||
|
|
||||||
// All done!
|
// All done!
|
||||||
|
|||||||
Reference in New Issue
Block a user