mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 11:12:16 +00:00
liteServer.getOutMsgQueueSizes method (#943)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
438e59a324
commit
b07614335c
9 changed files with 98 additions and 0 deletions
|
@ -973,6 +973,7 @@ bool TestNode::show_help(std::string command) {
|
|||
"savecomplaints <election-id> <filename-pfx>\tSaves all complaints registered for specified validator set id "
|
||||
"into files <filename-pfx><complaint-hash>.boc\n"
|
||||
"complaintprice <expires-in> <complaint-boc>\tComputes the price (in nanograms) for creating a complaint\n"
|
||||
"msgqueuesizes\tShows current sizes of outbound message queues in all shards\n"
|
||||
"known\tShows the list of all known block ids\n"
|
||||
"knowncells\tShows the list of hashes of all known (cached) cells\n"
|
||||
"dumpcell <hex-hash-pfx>\nDumps a cached cell by a prefix of its hash\n"
|
||||
|
@ -1108,6 +1109,8 @@ bool TestNode::do_parse_line() {
|
|||
std::string filename;
|
||||
return parse_uint32(expire_in) && get_word_to(filename) && seekeoln() &&
|
||||
set_error(get_complaint_price(expire_in, filename));
|
||||
} else if (word == "msgqueuesizes") {
|
||||
return get_msg_queue_sizes();
|
||||
} else if (word == "known") {
|
||||
return eoln() && show_new_blkids(true);
|
||||
} else if (word == "knowncells") {
|
||||
|
@ -1611,6 +1614,30 @@ void TestNode::send_compute_complaint_price_query(ton::StdSmcAddress elector_add
|
|||
std::move(P));
|
||||
}
|
||||
|
||||
bool TestNode::get_msg_queue_sizes() {
|
||||
auto q = ton::serialize_tl_object(ton::create_tl_object<ton::lite_api::liteServer_getOutMsgQueueSizes>(0, 0, 0), true);
|
||||
return envelope_send_query(std::move(q), [Self = actor_id(this)](td::Result<td::BufferSlice> res) -> void {
|
||||
if (res.is_error()) {
|
||||
LOG(ERROR) << "liteServer.getOutMsgQueueSizes error: " << res.move_as_error();
|
||||
return;
|
||||
}
|
||||
auto F = ton::fetch_tl_object<ton::lite_api::liteServer_outMsgQueueSizes>(res.move_as_ok(), true);
|
||||
if (F.is_error()) {
|
||||
LOG(ERROR) << "cannot parse answer to liteServer.getOutMsgQueueSizes";
|
||||
return;
|
||||
}
|
||||
td::actor::send_closure_later(Self, &TestNode::got_msg_queue_sizes, F.move_as_ok());
|
||||
});
|
||||
}
|
||||
|
||||
void TestNode::got_msg_queue_sizes(ton::tl_object_ptr<ton::lite_api::liteServer_outMsgQueueSizes> f) {
|
||||
td::TerminalIO::out() << "Outbound message queue sizes:" << std::endl;
|
||||
for (auto &x : f->shards_) {
|
||||
td::TerminalIO::out() << ton::create_block_id(x->id_).id.to_str() << " " << x->size_ << std::endl;
|
||||
}
|
||||
td::TerminalIO::out() << "External message queue size limit: " << f->ext_msg_queue_size_limit_ << std::endl;
|
||||
}
|
||||
|
||||
bool TestNode::dns_resolve_start(ton::WorkchainId workchain, ton::StdSmcAddress addr, ton::BlockIdExt blkid,
|
||||
std::string domain, td::Bits256 cat, int mode) {
|
||||
if (domain.size() >= 2 && domain[0] == '"' && domain.back() == '"') {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "block/block.h"
|
||||
#include "block/mc-config.h"
|
||||
#include "td/utils/filesystem.h"
|
||||
#include "auto/tl/lite_api.h"
|
||||
|
||||
using td::Ref;
|
||||
|
||||
|
@ -302,6 +303,8 @@ class TestNode : public td::actor::Actor {
|
|||
td::Bits256 chash = td::Bits256::zero(), std::string filename = "");
|
||||
void send_compute_complaint_price_query(ton::StdSmcAddress elector_addr, unsigned expires_in, unsigned bits,
|
||||
unsigned refs, td::Bits256 chash, std::string filename);
|
||||
bool get_msg_queue_sizes();
|
||||
void got_msg_queue_sizes(ton::tl_object_ptr<ton::lite_api::liteServer_outMsgQueueSizes> f);
|
||||
bool cache_cell(Ref<vm::Cell> cell);
|
||||
bool list_cached_cells() const;
|
||||
bool dump_cached_cell(td::Slice hash_pfx, td::Slice type_name = {});
|
||||
|
|
|
@ -148,6 +148,7 @@ std::string lite_query_name_by_id(int id) {
|
|||
{lite_api::liteServer_getOneTransaction::ID, "getOneTransaction"},
|
||||
{lite_api::liteServer_getTransactions::ID, "getTransactions"},
|
||||
{lite_api::liteServer_lookupBlock::ID, "lookupBlock"},
|
||||
{lite_api::liteServer_lookupBlockWithProof::ID, "lookupBlockWithProof"},
|
||||
{lite_api::liteServer_listBlockTransactions::ID, "listBlockTransactions"},
|
||||
{lite_api::liteServer_listBlockTransactionsExt::ID, "listBlockTransactionsExt"},
|
||||
{lite_api::liteServer_getBlockProof::ID, "getBlockProof"},
|
||||
|
@ -155,7 +156,9 @@ std::string lite_query_name_by_id(int id) {
|
|||
{lite_api::liteServer_getConfigParams::ID, "getConfigParams"},
|
||||
{lite_api::liteServer_getValidatorStats::ID, "getValidatorStats"},
|
||||
{lite_api::liteServer_getLibraries::ID, "getLibraries"},
|
||||
{lite_api::liteServer_getLibrariesWithProof::ID, "getLibrariesWithProof"},
|
||||
{lite_api::liteServer_getShardBlockProof::ID, "getShardBlockProof"},
|
||||
{lite_api::liteServer_getOutMsgQueueSizes::ID, "getOutMsgQueueSizes"},
|
||||
{lite_api::liteServer_nonfinal_getCandidate::ID, "nonfinal.getCandidate"},
|
||||
{lite_api::liteServer_nonfinal_getValidatorGroups::ID, "nonfinal.getValidatorGroups"}};
|
||||
auto it = names.find(id);
|
||||
|
|
|
@ -57,6 +57,8 @@ liteServer.libraryResultWithProof id:tonNode.blockIdExt mode:# result:(vector li
|
|||
liteServer.shardBlockLink id:tonNode.blockIdExt proof:bytes = liteServer.ShardBlockLink;
|
||||
liteServer.shardBlockProof masterchain_id:tonNode.blockIdExt links:(vector liteServer.shardBlockLink) = liteServer.ShardBlockProof;
|
||||
liteServer.lookupBlockResult id:tonNode.blockIdExt mode:# mc_block_id:tonNode.blockIdExt client_mc_state_proof:bytes mc_block_proof:bytes shard_links:(vector liteServer.shardBlockLink) header:bytes prev_header:bytes = liteServer.LookupBlockResult;
|
||||
liteServer.outMsgQueueSize id:tonNode.blockIdExt size:int = liteServer.OutMsgQueueSize;
|
||||
liteServer.outMsgQueueSizes shards:(vector liteServer.outMsgQueueSize) ext_msg_queue_size_limit:int = liteServer.OutMsgQueueSizes;
|
||||
|
||||
liteServer.debug.verbosity value:int = liteServer.debug.Verbosity;
|
||||
|
||||
|
@ -94,6 +96,7 @@ liteServer.getValidatorStats#091a58bc mode:# id:tonNode.blockIdExt limit:int sta
|
|||
liteServer.getLibraries library_list:(vector int256) = liteServer.LibraryResult;
|
||||
liteServer.getLibrariesWithProof id:tonNode.blockIdExt mode:# library_list:(vector int256) = liteServer.LibraryResultWithProof;
|
||||
liteServer.getShardBlockProof id:tonNode.blockIdExt = liteServer.ShardBlockProof;
|
||||
liteServer.getOutMsgQueueSizes mode:# wc:mode.0?int shard:mode.0?long = liteServer.OutMsgQueueSizes;
|
||||
|
||||
liteServer.nonfinal.getValidatorGroups mode:# wc:mode.0?int shard:mode.1?long = liteServer.nonfinal.ValidatorGroups;
|
||||
liteServer.nonfinal.getCandidate id:liteServer.nonfinal.candidateId = liteServer.nonfinal.Candidate;
|
||||
|
|
Binary file not shown.
|
@ -322,6 +322,9 @@ class Collator final : public td::actor::Actor {
|
|||
bool create_block_candidate();
|
||||
void return_block_candidate(td::Result<td::Unit> saved);
|
||||
bool update_last_proc_int_msg(const std::pair<ton::LogicalTime, ton::Bits256>& new_lt_hash);
|
||||
|
||||
public:
|
||||
static td::uint32 get_skip_externals_queue_size();
|
||||
};
|
||||
|
||||
} // namespace validator
|
||||
|
|
|
@ -5140,6 +5140,10 @@ void Collator::after_get_external_messages(td::Result<std::vector<Ref<ExtMessage
|
|||
check_pending();
|
||||
}
|
||||
|
||||
td::uint32 Collator::get_skip_externals_queue_size() {
|
||||
return SKIP_EXTERNALS_QUEUE_SIZE;
|
||||
}
|
||||
|
||||
} // namespace validator
|
||||
|
||||
} // namespace ton
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include "signature-set.hpp"
|
||||
#include "fabric.h"
|
||||
#include <ctime>
|
||||
#include "td/actor/MultiPromise.h"
|
||||
#include "collator-impl.h"
|
||||
|
||||
namespace ton {
|
||||
|
||||
|
@ -282,6 +284,9 @@ void LiteQuery::perform() {
|
|||
[&](lite_api::liteServer_nonfinal_getValidatorGroups& q) {
|
||||
this->perform_nonfinal_getValidatorGroups(q.mode_, ShardIdFull{q.wc_, (ShardId)q.shard_});
|
||||
},
|
||||
[&](lite_api::liteServer_getOutMsgQueueSizes& q) {
|
||||
this->perform_getOutMsgQueueSizes(q.mode_ & 1 ? ShardIdFull(q.wc_, q.shard_) : td::optional<ShardIdFull>());
|
||||
},
|
||||
[&](auto& obj) { this->abort_query(td::Status::Error(ErrorCode::protoviolation, "unknown query")); }));
|
||||
}
|
||||
|
||||
|
@ -3216,6 +3221,53 @@ void LiteQuery::continue_getShardBlockProof(Ref<BlockData> cur_block,
|
|||
});
|
||||
}
|
||||
|
||||
void LiteQuery::perform_getOutMsgQueueSizes(td::optional<ShardIdFull> shard) {
|
||||
LOG(INFO) << "started a getOutMsgQueueSizes" << (shard ? shard.value().to_str() : "") << " liteserver query";
|
||||
td::actor::send_closure_later(
|
||||
manager_, &ton::validator::ValidatorManager::get_last_liteserver_state_block,
|
||||
[Self = actor_id(this), shard](td::Result<std::pair<Ref<MasterchainState>, BlockIdExt>> res) {
|
||||
if (res.is_error()) {
|
||||
td::actor::send_closure(Self, &LiteQuery::abort_query, res.move_as_error());
|
||||
} else {
|
||||
td::actor::send_closure_later(Self, &LiteQuery::continue_getOutMsgQueueSizes, shard, res.ok().first);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void LiteQuery::continue_getOutMsgQueueSizes(td::optional<ShardIdFull> shard, Ref<MasterchainState> state) {
|
||||
std::vector<BlockIdExt> blocks;
|
||||
if (!shard || shard_intersects(shard.value(), state->get_shard())) {
|
||||
blocks.push_back(state->get_block_id());
|
||||
}
|
||||
for (auto& x : state->get_shards()) {
|
||||
if (!shard || shard_intersects(shard.value(), x->shard())) {
|
||||
blocks.push_back(x->top_block_id());
|
||||
}
|
||||
}
|
||||
auto res = std::make_shared<std::vector<tl_object_ptr<lite_api::liteServer_outMsgQueueSize>>>(blocks.size());
|
||||
td::MultiPromise mp;
|
||||
auto ig = mp.init_guard();
|
||||
for (size_t i = 0; i < blocks.size(); ++i) {
|
||||
td::actor::send_closure(manager_, &ValidatorManager::get_out_msg_queue_size, blocks[i],
|
||||
[promise = ig.get_promise(), res, i, id = blocks[i]](td::Result<td::uint32> R) mutable {
|
||||
TRY_RESULT_PROMISE(promise, value, std::move(R));
|
||||
res->at(i) = create_tl_object<lite_api::liteServer_outMsgQueueSize>(
|
||||
create_tl_lite_block_id(id), value);
|
||||
promise.set_value(td::Unit());
|
||||
});
|
||||
}
|
||||
ig.add_promise([Self = actor_id(this), res](td::Result<td::Unit> R) {
|
||||
if (R.is_error()) {
|
||||
td::actor::send_closure(Self, &LiteQuery::abort_query, R.move_as_error());
|
||||
return;
|
||||
}
|
||||
td::actor::send_closure(Self, &LiteQuery::finish_query,
|
||||
create_serialize_tl_object<lite_api::liteServer_outMsgQueueSizes>(
|
||||
std::move(*res), Collator::get_skip_externals_queue_size()),
|
||||
false);
|
||||
});
|
||||
}
|
||||
|
||||
void LiteQuery::perform_nonfinal_getCandidate(td::Bits256 source, BlockIdExt blkid, td::Bits256 collated_data_hash) {
|
||||
LOG(INFO) << "started a nonfinal.getCandidate liteserver query";
|
||||
td::actor::send_closure_later(
|
||||
|
|
|
@ -168,6 +168,9 @@ class LiteQuery : public td::actor::Actor {
|
|||
void perform_getShardBlockProof(BlockIdExt blkid);
|
||||
void continue_getShardBlockProof(Ref<BlockData> cur_block,
|
||||
std::vector<std::pair<BlockIdExt, td::BufferSlice>> result);
|
||||
void perform_getOutMsgQueueSizes(td::optional<ShardIdFull> shard);
|
||||
void continue_getOutMsgQueueSizes(td::optional<ShardIdFull> shard, Ref<MasterchainState> state);
|
||||
|
||||
void perform_nonfinal_getCandidate(td::Bits256 source, BlockIdExt blkid, td::Bits256 collated_data_hash);
|
||||
void perform_nonfinal_getValidatorGroups(int mode, ShardIdFull shard);
|
||||
|
||||
|
|
Loading…
Reference in a new issue