diff --git a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp index 9dcd0f6345..39295cf0c1 100644 --- a/libraries/core_libs/consensus/src/final_chain/final_chain.cpp +++ b/libraries/core_libs/consensus/src/final_chain/final_chain.cpp @@ -108,6 +108,8 @@ class FinalChainImpl final : public FinalChain { num_executed_dag_blk_ -= period_data.dag_blocks.size(); num_executed_trx_ -= period_data.transactions.size(); } + auto period_system_transactions = db_->getPeriodSystemTransactionsHashes(block_n); + num_executed_trx_ -= period_system_transactions.size(); } db_->insert(batch, DB::Columns::status, StatusDbField::ExecutedBlkCount, num_executed_dag_blk_.load()); db_->insert(batch, DB::Columns::status, StatusDbField::ExecutedTrxCount, num_executed_trx_.load()); @@ -230,7 +232,7 @@ class FinalChainImpl final : public FinalChain { receipts, new_blk.pbft_blk->getExtraDataRlp()); // Update number of executed DAG blocks and transactions auto num_executed_dag_blk = num_executed_dag_blk_ + finalized_dag_blk_hashes.size(); - auto num_executed_trx = num_executed_trx_ + new_blk.transactions.size(); + auto num_executed_trx = num_executed_trx_ + new_blk.transactions.size() + system_transactions.size(); if (!finalized_dag_blk_hashes.empty()) { db_->insert(batch, DB::Columns::status, StatusDbField::ExecutedBlkCount, num_executed_dag_blk); db_->insert(batch, DB::Columns::status, StatusDbField::ExecutedTrxCount, num_executed_trx); diff --git a/tests/pillar_chain_test.cpp b/tests/pillar_chain_test.cpp index 5f7feae5a2..79b9ae45d6 100644 --- a/tests/pillar_chain_test.cpp +++ b/tests/pillar_chain_test.cpp @@ -166,29 +166,23 @@ TEST_F(PillarChainTest, votes_count_changes) { // Change validators delegation const auto delegation_value = 2 * node_cfgs[0].genesis.state.dpos.eligibility_balance_threshold; - const auto vote_count_change_validators_count = validators_count - 1; - for (size_t i = 0; i < vote_count_change_validators_count; i++) { + for (size_t i = 0; i < validators_count; i++) { const auto trx = make_delegate_tx(node_cfgs[i], delegation_value, 1, 1000); nodes[0]->getTransactionManager()->insertTransaction(trx); } - PbftPeriod executed_delegations_pbft_period = 1000000; - EXPECT_HAPPENS({20s, 1s}, [&](auto& ctx) { + EXPECT_HAPPENS({20s, 100ms}, [&](auto& ctx) { for (auto& node : nodes) { - if (ctx.fail_if(node->getDB()->getNumTransactionExecuted() != vote_count_change_validators_count)) { + if (ctx.fail_if(node->getDB()->getNumTransactionExecuted() <= validators_count)) { return; } - const auto chain_size = node->getPbftChain()->getPbftChainSize(); - if (chain_size < executed_delegations_pbft_period) { - executed_delegations_pbft_period = chain_size; - } } }); + const auto chain_size = nodes[0]->getPbftChain()->getPbftChainSize(); // Wait until new pillar block with changed validators vote_counts is created const auto new_pillar_block_period = - executed_delegations_pbft_period - - executed_delegations_pbft_period % node_cfgs[0].genesis.state.hardforks.ficus_hf.pillar_blocks_interval + + chain_size - chain_size % node_cfgs[0].genesis.state.hardforks.ficus_hf.pillar_blocks_interval + node_cfgs[0].genesis.state.hardforks.ficus_hf.pillar_blocks_interval; ASSERT_HAPPENS({20s, 250ms}, [&](auto& ctx) { for (const auto& node : nodes) { @@ -203,8 +197,7 @@ TEST_F(PillarChainTest, votes_count_changes) { const auto new_pillar_block_data = node->getDB()->getPillarBlockData(new_pillar_block_period); ASSERT_TRUE(new_pillar_block_data.has_value()); ASSERT_EQ(new_pillar_block_data->block_->getPeriod(), new_pillar_block_period); - ASSERT_EQ(new_pillar_block_data->block_->getValidatorsVoteCountsChanges().size(), - vote_count_change_validators_count); + ASSERT_EQ(new_pillar_block_data->block_->getValidatorsVoteCountsChanges().size(), validators_count); size_t idx = 0; for (const auto& vote_count_change : new_pillar_block_data->block_->getValidatorsVoteCountsChanges()) { ASSERT_EQ(vote_count_change.vote_count_change_,