fix!: Return FinalCommitment in qrinfo (instead of simply quorumHash) (#4850)

This commit is contained in:
Odysseas Gabrielides 2022-05-28 19:37:20 +03:00 committed by GitHub
parent 145fee358d
commit 3fcfe3f176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 11 deletions

View File

@ -90,12 +90,13 @@ void CQuorumRotationInfo::ToJson(UniValue& obj) const
mnListDiffAtHMinus4C.value().ToJson(objdiff4c);
obj.pushKV("mnListDiffAtHMinus4C", objdiff4c);
}
UniValue hlists(UniValue::VARR);
for (const auto& h : lastQuorumHashPerIndex) {
hlists.push_back(h.ToString());
UniValue hqclists(UniValue::VARR);
for (const auto& qc : lastCommitmentPerIndex) {
UniValue objqc;
qc.ToJson(objqc);
hqclists.push_back(objqc);
}
obj.pushKV("lastQuorumHashPerIndex", hlists);
obj.pushKV("lastCommitmentPerIndex", hqclists);
UniValue snapshotlist(UniValue::VARR);
for (const auto& snap : quorumSnapshotList) {
@ -298,7 +299,12 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
std::vector<std::pair<int, const CBlockIndex*>> qdata = quorumBlockProcessor->GetLastMinedCommitmentsPerQuorumIndexUntilBlock(llmqType, blockIndex, 0);
for (const auto& obj : qdata) {
response.lastQuorumHashPerIndex.push_back(obj.second->GetBlockHash());
uint256 minedBlockHash;
llmq::CFinalCommitmentPtr qc = llmq::quorumBlockProcessor->GetMinedCommitment(llmqType, obj.second->GetBlockHash(), minedBlockHash);
if (qc == nullptr) {
return false;
}
response.lastCommitmentPerIndex.push_back(*qc);
int quorumCycleStartHeight = obj.second->nHeight - (obj.second->nHeight % llmqParams.dkgInterval);
snapshotHeightsNeeded.insert(quorumCycleStartHeight - cycleLength);

View File

@ -7,6 +7,7 @@
#include <evo/evodb.h>
#include <evo/simplifiedmns.h>
#include <llmq/commitment.h>
#include <llmq/params.h>
#include <saltedhasher.h>
#include <serialize.h>
@ -115,7 +116,7 @@ public:
std::optional<CQuorumSnapshot> quorumSnapshotAtHMinus4C;
std::optional<CSimplifiedMNListDiff> mnListDiffAtHMinus4C;
std::vector<uint256> lastQuorumHashPerIndex;
std::vector<llmq::CFinalCommitment> lastCommitmentPerIndex;
std::vector<CQuorumSnapshot> quorumSnapshotList;
std::vector<CSimplifiedMNListDiff> mnListDiffList;
@ -146,8 +147,8 @@ public:
::Serialize(s, mnListDiffAtHMinus4C.value());
}
WriteCompactSize(s, lastQuorumHashPerIndex.size());
for (const auto& obj : lastQuorumHashPerIndex) {
WriteCompactSize(s, lastCommitmentPerIndex.size());
for (const auto& obj : lastCommitmentPerIndex) {
::Serialize(s, obj);
}
@ -178,8 +179,9 @@ public:
size_t cnt = ReadCompactSize(s);
for ([[maybe_unused]] const auto _ : irange::range(cnt)) {
uint256 hash;
::Unserialize(s, hash);
lastQuorumHashPerIndex.push_back(std::move(hash));
CFinalCommitment qc;
::Unserialize(s, qc);
lastCommitmentPerIndex.push_back(std::move(qc));
}
cnt = ReadCompactSize(s);