Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions src/evo/cbtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,6 @@ bool CheckCbTx(const CCbTx& cbTx, const CBlockIndex* pindexPrev, TxValidationSta
return true;
}

bool CheckCbTxMerkleRoots(const CBlock& block, const CCbTx& cbTx, const CBlockIndex* pindex,
const llmq::CQuorumBlockProcessor& quorum_block_processor, BlockValidationState& state)
{
if (pindex && cbTx.nVersion >= CCbTx::Version::MERKLE_ROOT_QUORUMS) {
uint256 calculatedMerkleRoot;
if (!CalcCbTxMerkleRootQuorums(block, pindex->pprev, quorum_block_processor, calculatedMerkleRoot, state)) {
// pass the state returned by the function above
return false;
}
if (calculatedMerkleRoot != cbTx.merkleRootQuorums) {
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-quorummerkleroot");
}
}

return true;
}

using QcHashMap = std::map<Consensus::LLMQType, std::vector<uint256>>;
using QcIndexedHashMap = std::map<Consensus::LLMQType, std::map<int16_t, uint256>>;

Expand Down
3 changes: 0 additions & 3 deletions src/evo/cbtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ template<> struct is_serializable_enum<CCbTx::Version> : std::true_type {};

bool CheckCbTx(const CCbTx& cbTx, const CBlockIndex* pindexPrev, TxValidationState& state);

// This can only be done after the block has been fully processed, as otherwise we won't have the finished MN list
bool CheckCbTxMerkleRoots(const CBlock& block, const CCbTx& cbTx, const CBlockIndex* pindex,
const llmq::CQuorumBlockProcessor& quorum_block_processor, BlockValidationState& state);
bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPrev,
const llmq::CQuorumBlockProcessor& quorum_block_processor, uint256& merkleRootRet,
BlockValidationState& state);
Expand Down
63 changes: 32 additions & 31 deletions src/evo/specialtxman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
static int64_t nTimeQuorum = 0;
static int64_t nTimeDMN = 0;
static int64_t nTimeMerkleMNL = 0;
static int64_t nTimeMerkle = 0;
static int64_t nTimeMerkleQuorums = 0;
static int64_t nTimeCbTxCL = 0;
static int64_t nTimeMnehf = 0;
static int64_t nTimePayload = 0;
Expand Down Expand Up @@ -601,62 +601,63 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB
}
}

int64_t nTime5_1 = GetTimeMicros();
nTimeDMN += nTime5_1 - nTime5;

LogPrint(BCLog::BENCHMARK, " - m_dmnman: %.2fms [%.2fs]\n", 0.001 * (nTime5_1 - nTime5),
nTimeDMN * 0.000001);
int64_t nTime6 = GetTimeMicros();
nTimeDMN += nTime6 - nTime5;
LogPrint(BCLog::BENCHMARK, " - m_dmnman: %.2fms [%.2fs]\n", 0.001 * (nTime6 - nTime5), nTimeDMN * 0.000001);

if (opt_cbTx.has_value()) {
uint256 calculatedMerkleRoot;
if (!CalcCbTxMerkleRootMNList(calculatedMerkleRoot, mn_list.to_sml(), state)) {
uint256 calculatedMerkleRootMNL;
if (!CalcCbTxMerkleRootMNList(calculatedMerkleRootMNL, mn_list.to_sml(), state)) {
// pass the state returned by the function above
return false;
}
if (calculatedMerkleRoot != opt_cbTx->merkleRootMNList) {
if (calculatedMerkleRootMNL != opt_cbTx->merkleRootMNList) {
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-mnmerkleroot");
}

int64_t nTime5_2 = GetTimeMicros();
nTimeMerkleMNL += nTime5_2 - nTime5_1;
int64_t nTime6_1 = GetTimeMicros();
nTimeMerkleMNL += nTime6_1 - nTime6;
LogPrint(BCLog::BENCHMARK, " - CalcCbTxMerkleRootMNList: %.2fms [%.2fs]\n",
0.001 * (nTime5_2 - nTime5_1), nTimeMerkleMNL * 0.000001);
}
0.001 * (nTime6_1 - nTime6), nTimeMerkleMNL * 0.000001);

int64_t nTime6 = GetTimeMicros();
if (opt_cbTx.has_value()) {
if (!CheckCbTxMerkleRoots(block, *opt_cbTx, pindex, m_qblockman, state)) {
// pass the state returned by the function above
return false;
if (opt_cbTx->nVersion >= CCbTx::Version::MERKLE_ROOT_QUORUMS) {
uint256 calculatedMerkleRootQuorums;
if (!CalcCbTxMerkleRootQuorums(block, pindex->pprev, m_qblockman, calculatedMerkleRootQuorums, state)) {
// pass the state returned by the function above
return false;
}
if (calculatedMerkleRootQuorums != opt_cbTx->merkleRootQuorums) {
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-quorummerkleroot");
}
}
}

int64_t nTime7 = GetTimeMicros();
nTimeMerkle += nTime7 - nTime6;
int64_t nTime6_2 = GetTimeMicros();
nTimeMerkleQuorums += nTime6_2 - nTime6_1;

LogPrint(BCLog::BENCHMARK, " - CheckCbTxMerkleRoots: %.2fms [%.2fs]\n", 0.001 * (nTime7 - nTime6),
nTimeMerkle * 0.000001);
LogPrint(BCLog::BENCHMARK, " - CalcCbTxMerkleRootQuorums: %.2fms [%.2fs]\n",
0.001 * (nTime6_2 - nTime6_1), nTimeMerkleQuorums * 0.000001);

if (opt_cbTx.has_value()) {
if (!CheckCbTxBestChainlock(*opt_cbTx, pindex, m_clhandler, state)) {
// pass the state returned by the function above
return false;
}

int64_t nTime6_3 = GetTimeMicros();
nTimeCbTxCL += nTime6_3 - nTime6_2;
LogPrint(BCLog::BENCHMARK, " - CheckCbTxBestChainlock: %.2fms [%.2fs]\n",
0.001 * (nTime6_3 - nTime6_2), nTimeCbTxCL * 0.000001);
}

int64_t nTime8 = GetTimeMicros();
nTimeCbTxCL += nTime8 - nTime7;
LogPrint(BCLog::BENCHMARK, " - CheckCbTxBestChainlock: %.2fms [%.2fs]\n", 0.001 * (nTime8 - nTime7),
nTimeCbTxCL * 0.000001);
int64_t nTime7 = GetTimeMicros();

if (!m_mnhfman.ProcessBlock(block, pindex, fJustCheck, state)) {
// pass the state returned by the function above
return false;
}

int64_t nTime9 = GetTimeMicros();
nTimeMnehf += nTime9 - nTime8;
LogPrint(BCLog::BENCHMARK, " - m_mnhfman: %.2fms [%.2fs]\n", 0.001 * (nTime9 - nTime8), nTimeMnehf * 0.000001);
int64_t nTime8 = GetTimeMicros();
nTimeMnehf += nTime8 - nTime7;
LogPrint(BCLog::BENCHMARK, " - m_mnhfman: %.2fms [%.2fs]\n", 0.001 * (nTime8 - nTime7), nTimeMnehf * 0.000001);

if (DeploymentActiveAfter(pindex, m_consensus_params, Consensus::DEPLOYMENT_V19) && bls::bls_legacy_scheme.load()) {
// NOTE: The block next to the activation is the one that is using new rules.
Expand Down
Loading