Don't use pindex->GetBlockHash() in ProcessCommitment
The block hash is not necessarily set at this point, for example when coming from TestBlockValidity().
This commit is contained in:
parent
f9dbe3ed50
commit
44a3b9c90f
@ -153,7 +153,7 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, const CBlockIndex*
|
|||||||
|
|
||||||
for (auto& p : qcs) {
|
for (auto& p : qcs) {
|
||||||
auto& qc = p.second;
|
auto& qc = p.second;
|
||||||
if (!ProcessCommitment(pindex, qc, state)) {
|
if (!ProcessCommitment(pindex->nHeight, block.GetHash(), qc, state)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,11 +167,11 @@ static std::tuple<std::string, uint8_t, int> BuildInversedHeightKey(Consensus::L
|
|||||||
return std::make_tuple(DB_MINED_COMMITMENT_BY_INVERSED_HEIGHT, (uint8_t)llmqType, std::numeric_limits<int>::max() - nMinedHeight);
|
return std::make_tuple(DB_MINED_COMMITMENT_BY_INVERSED_HEIGHT, (uint8_t)llmqType, std::numeric_limits<int>::max() - nMinedHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CQuorumBlockProcessor::ProcessCommitment(const CBlockIndex* pindex, const CFinalCommitment& qc, CValidationState& state)
|
bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockHash, const CFinalCommitment& qc, CValidationState& state)
|
||||||
{
|
{
|
||||||
auto& params = Params().GetConsensus().llmqs.at((Consensus::LLMQType)qc.llmqType);
|
auto& params = Params().GetConsensus().llmqs.at((Consensus::LLMQType)qc.llmqType);
|
||||||
|
|
||||||
uint256 quorumHash = GetQuorumBlockHash((Consensus::LLMQType)qc.llmqType, pindex->nHeight);
|
uint256 quorumHash = GetQuorumBlockHash((Consensus::LLMQType)qc.llmqType, nHeight);
|
||||||
if (quorumHash.IsNull()) {
|
if (quorumHash.IsNull()) {
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-qc-block");
|
return state.DoS(100, false, REJECT_INVALID, "bad-qc-block");
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ bool CQuorumBlockProcessor::ProcessCommitment(const CBlockIndex* pindex, const C
|
|||||||
return state.DoS(100, false, REJECT_INVALID, "bad-qc-dup");
|
return state.DoS(100, false, REJECT_INVALID, "bad-qc-dup");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsMiningPhase(params.type, pindex->nHeight)) {
|
if (!IsMiningPhase(params.type, nHeight)) {
|
||||||
// should not happen as it's already handled in ProcessBlock
|
// should not happen as it's already handled in ProcessBlock
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-qc-height");
|
return state.DoS(100, false, REJECT_INVALID, "bad-qc-height");
|
||||||
}
|
}
|
||||||
@ -204,8 +204,8 @@ bool CQuorumBlockProcessor::ProcessCommitment(const CBlockIndex* pindex, const C
|
|||||||
|
|
||||||
// Store commitment in DB
|
// Store commitment in DB
|
||||||
auto quorumIndex = mapBlockIndex.at(qc.quorumHash);
|
auto quorumIndex = mapBlockIndex.at(qc.quorumHash);
|
||||||
evoDb.Write(std::make_pair(DB_MINED_COMMITMENT, std::make_pair((uint8_t)params.type, quorumHash)), std::make_pair(qc, pindex->GetBlockHash()));
|
evoDb.Write(std::make_pair(DB_MINED_COMMITMENT, std::make_pair((uint8_t)params.type, quorumHash)), std::make_pair(qc, blockHash));
|
||||||
evoDb.Write(BuildInversedHeightKey(params.type, pindex->nHeight), quorumIndex->nHeight);
|
evoDb.Write(BuildInversedHeightKey(params.type, nHeight), quorumIndex->nHeight);
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(minableCommitmentsCs);
|
LOCK(minableCommitmentsCs);
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool GetCommitmentsFromBlock(const CBlock& block, const CBlockIndex* pindexPrev, std::map<Consensus::LLMQType, CFinalCommitment>& ret, CValidationState& state);
|
bool GetCommitmentsFromBlock(const CBlock& block, const CBlockIndex* pindexPrev, std::map<Consensus::LLMQType, CFinalCommitment>& ret, CValidationState& state);
|
||||||
bool ProcessCommitment(const CBlockIndex* pindex, const CFinalCommitment& qc, CValidationState& state);
|
bool ProcessCommitment(int nHeight, const uint256& blockHash, const CFinalCommitment& qc, CValidationState& state);
|
||||||
bool IsMiningPhase(Consensus::LLMQType llmqType, int nHeight);
|
bool IsMiningPhase(Consensus::LLMQType llmqType, int nHeight);
|
||||||
bool IsCommitmentRequired(Consensus::LLMQType llmqType, int nHeight);
|
bool IsCommitmentRequired(Consensus::LLMQType llmqType, int nHeight);
|
||||||
uint256 GetQuorumBlockHash(Consensus::LLMQType llmqType, int nHeight);
|
uint256 GetQuorumBlockHash(Consensus::LLMQType llmqType, int nHeight);
|
||||||
|
Loading…
Reference in New Issue
Block a user