1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Fix sending msg queue queries

This commit is contained in:
SpyCheese 2023-07-26 12:21:19 +03:00
parent f1e62d0075
commit 8c4bc5b3f1
3 changed files with 44 additions and 41 deletions

View file

@ -74,33 +74,35 @@ void CollatorNode::new_masterchain_block_notification(td::Ref<MasterchainState>
last_masterchain_block_ = state->get_block_id();
last_top_blocks_.clear();
last_top_blocks_[ShardIdFull{masterchainId, shardIdAll}] = last_masterchain_block_;
std::vector<ShardIdFull> next_shards;
if (can_collate_shard(ShardIdFull(masterchainId))) {
next_shards.push_back(ShardIdFull(masterchainId));
}
for (const auto& desc : state->get_shards()) {
last_top_blocks_[desc->shard()] = desc->top_block_id();
ShardIdFull shard = desc->shard();
if (desc->before_split()) {
if (can_collate_shard(shard_child(shard, true))) {
next_shards.push_back(shard_child(shard, true));
}
if (can_collate_shard(shard_child(shard, false))) {
next_shards.push_back(shard_child(shard, false));
}
} else if (desc->before_merge()) {
if (is_left_child(shard) && can_collate_shard(shard_parent(shard))) {
next_shards.push_back(shard_parent(shard));
}
} else if (can_collate_shard(shard)) {
next_shards.push_back(shard);
if (state->get_unix_time() > (td::uint32)td::Clocks::system() - 20) {
std::vector<ShardIdFull> next_shards;
if (can_collate_shard(ShardIdFull(masterchainId))) {
next_shards.push_back(ShardIdFull(masterchainId));
}
}
for (const ShardIdFull& shard : next_shards) {
for (const auto& neighbor : last_top_blocks_) {
if (neighbor.first != shard && block::ShardConfig::is_neighbor(shard, neighbor.first)) {
td::actor::send_closure(manager_, &ValidatorManager::wait_out_msg_queue_proof, neighbor.second, shard, 0,
td::Timestamp::in(10.0), [](td::Ref<OutMsgQueueProof>) {});
for (const auto& desc : state->get_shards()) {
last_top_blocks_[desc->shard()] = desc->top_block_id();
ShardIdFull shard = desc->shard();
if (desc->before_split()) {
if (can_collate_shard(shard_child(shard, true))) {
next_shards.push_back(shard_child(shard, true));
}
if (can_collate_shard(shard_child(shard, false))) {
next_shards.push_back(shard_child(shard, false));
}
} else if (desc->before_merge()) {
if (is_left_child(shard) && can_collate_shard(shard_parent(shard))) {
next_shards.push_back(shard_parent(shard));
}
} else if (can_collate_shard(shard)) {
next_shards.push_back(shard);
}
}
for (const ShardIdFull& shard : next_shards) {
for (const auto& neighbor : last_top_blocks_) {
if (neighbor.first != shard && block::ShardConfig::is_neighbor(shard, neighbor.first)) {
td::actor::send_closure(manager_, &ValidatorManager::wait_out_msg_queue_proof, neighbor.second, shard, 0,
td::Timestamp::in(10.0), [](td::Ref<OutMsgQueueProof>) {});
}
}
}
}

View file

@ -280,20 +280,20 @@ void WaitOutMsgQueueProof::run_local_cont() {
}
void WaitOutMsgQueueProof::run_net() {
auto P =
td::PromiseCreator::lambda([SelfId = actor_id(this), block_id = block_id_](td::Result<Ref<OutMsgQueueProof>> R) {
if (R.is_error()) {
if (R.error().code() == ErrorCode::notready) {
LOG(DEBUG) << "failed to get msg queue for " << block_id.to_str() << " from net: " << R.move_as_error();
} else {
LOG(WARNING) << "failed to get msg queue for " << block_id.to_str() << " from net: " << R.move_as_error();
}
delay_action([SelfId]() mutable { td::actor::send_closure(SelfId, &WaitOutMsgQueueProof::run_net); },
td::Timestamp::in(0.1));
} else {
td::actor::send_closure(SelfId, &WaitOutMsgQueueProof::finish_query, R.move_as_ok());
}
});
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this), block_id = block_id_,
retry_after = td::Timestamp::in(0.5)](td::Result<Ref<OutMsgQueueProof>> R) {
if (R.is_error()) {
if (R.error().code() == ErrorCode::notready) {
LOG(DEBUG) << "failed to get msg queue for " << block_id.to_str() << " from net: " << R.move_as_error();
} else {
LOG(WARNING) << "failed to get msg queue for " << block_id.to_str() << " from net: " << R.move_as_error();
}
delay_action([SelfId]() mutable { td::actor::send_closure(SelfId, &WaitOutMsgQueueProof::run_net); },
retry_after);
} else {
td::actor::send_closure(SelfId, &WaitOutMsgQueueProof::finish_query, R.move_as_ok());
}
});
td::actor::send_closure(manager_, &ValidatorManager::send_get_out_msg_queue_proof_request, block_id_, dst_shard_,
limits_, priority_, std::move(P));

View file

@ -1839,7 +1839,8 @@ void ValidatorManagerImpl::new_masterchain_block() {
for (auto &c : collator_nodes_) {
td::actor::send_closure(c.second.actor, &CollatorNode::new_masterchain_block_notification, last_masterchain_state_);
}
if (opts_->validator_mode() == ValidatorManagerOptions::validator_lite_shards && validating_masterchain()) {
if (opts_->validator_mode() == ValidatorManagerOptions::validator_lite_shards && validating_masterchain() &&
last_masterchain_state_->get_unix_time() > (td::uint32)td::Clocks::system() - 20) {
// Prepare neighboours' queues for collating masterchain
for (const auto &desc : last_masterchain_state_->get_shards()) {
wait_out_msg_queue_proof(desc->top_block_id(), ShardIdFull(masterchainId), 0, td::Timestamp::in(10.0),