From 2c572076da31bd82e092aa29568724b144093d42 Mon Sep 17 00:00:00 2001 From: mfrankovi Date: Wed, 30 Oct 2024 13:07:06 +0100 Subject: [PATCH] chore: sharding improvements --- .../core_libs/consensus/include/dag/dag_block_proposer.hpp | 1 + libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/core_libs/consensus/include/dag/dag_block_proposer.hpp b/libraries/core_libs/consensus/include/dag/dag_block_proposer.hpp index 5ceb738401..1a52d653e7 100644 --- a/libraries/core_libs/consensus/include/dag/dag_block_proposer.hpp +++ b/libraries/core_libs/consensus/include/dag/dag_block_proposer.hpp @@ -148,6 +148,7 @@ class DagBlockProposer { const HardforksConfig kHardforks; const uint64_t kValidatorMaxVote; + const uint64_t kShardProposePeriodInterval = 10; LOG_OBJECTS_DEFINE }; diff --git a/libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp b/libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp index cdc137af23..2f47fbe5c3 100644 --- a/libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp +++ b/libraries/core_libs/consensus/src/dag/dag_block_proposer.cpp @@ -231,10 +231,11 @@ std::pair> DagBlockProposer::getSharde SharedTransactions sharded_trxs; std::vector sharded_estimations; for (uint32_t i = 0; i < transactions.size(); i++) { - auto shard = std::stoull(transactions[i]->getHash().toString().substr(0, 10), NULL, 16); + auto shard = std::stoull(transactions[i]->getSender().toString().substr(0, 10), NULL, 16) + + proposal_period / kShardProposePeriodInterval; if (shard % total_trx_shards_ == my_trx_shard_) { sharded_trxs.emplace_back(transactions[i]); - estimations.emplace_back(estimations[i]); + sharded_estimations.emplace_back(estimations[i]); } } if (sharded_trxs.empty()) {