mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Validator patch: state download, adnl stats (#1257)
* Persistent state download improvements 1) Don't start over on restart 2) Download shards one at a time to reduce RAM usage 3) More logs * Remove old peers from adnl stats
This commit is contained in:
parent
1da94e62ad
commit
b69214b6af
19 changed files with 135 additions and 76 deletions
|
@ -52,12 +52,7 @@ DownloadState::DownloadState(BlockIdExt block_id, BlockIdExt masterchain_block_i
|
|||
|
||||
void DownloadState::abort_query(td::Status reason) {
|
||||
if (promise_) {
|
||||
if (reason.code() == ErrorCode::notready || reason.code() == ErrorCode::timeout) {
|
||||
VLOG(FULL_NODE_DEBUG) << "failed to download state " << block_id_ << " from " << download_from_ << ": " << reason;
|
||||
} else {
|
||||
VLOG(FULL_NODE_NOTICE) << "failed to download state " << block_id_ << " from " << download_from_ << ": "
|
||||
<< reason;
|
||||
}
|
||||
LOG(WARNING) << "failed to download state " << block_id_.to_str() << " from " << download_from_ << ": " << reason;
|
||||
promise_.set_error(std::move(reason));
|
||||
}
|
||||
stop();
|
||||
|
@ -77,6 +72,19 @@ void DownloadState::finish_query() {
|
|||
void DownloadState::start_up() {
|
||||
alarm_timestamp() = timeout_;
|
||||
|
||||
td::actor::send_closure(validator_manager_, &ValidatorManagerInterface::get_persistent_state, block_id_,
|
||||
masterchain_block_id_,
|
||||
[SelfId = actor_id(this), block_id = block_id_](td::Result<td::BufferSlice> R) {
|
||||
if (R.is_error()) {
|
||||
td::actor::send_closure(SelfId, &DownloadState::get_block_handle);
|
||||
} else {
|
||||
LOG(WARNING) << "got block state from disk: " << block_id.to_str();
|
||||
td::actor::send_closure(SelfId, &DownloadState::got_block_state, R.move_as_ok());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void DownloadState::get_block_handle() {
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<BlockHandle> R) {
|
||||
if (R.is_error()) {
|
||||
td::actor::send_closure(SelfId, &DownloadState::abort_query, R.move_as_error());
|
||||
|
@ -115,7 +123,7 @@ void DownloadState::got_block_handle(BlockHandle handle) {
|
|||
|
||||
void DownloadState::got_node_to_download(adnl::AdnlNodeIdShort node) {
|
||||
download_from_ = node;
|
||||
LOG(INFO) << "downloading state " << block_id_.to_str() << " from " << download_from_;
|
||||
LOG(WARNING) << "downloading state " << block_id_.to_str() << " from " << download_from_;
|
||||
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<td::BufferSlice> R) mutable {
|
||||
if (R.is_error()) {
|
||||
|
@ -192,8 +200,8 @@ void DownloadState::got_block_state_part(td::BufferSlice data, td::uint32 reques
|
|||
double elapsed = prev_logged_timer_.elapsed();
|
||||
if (elapsed > 10.0) {
|
||||
prev_logged_timer_ = td::Timer();
|
||||
LOG(INFO) << "downloading state " << block_id_.to_str() << ": total=" << sum_ << " ("
|
||||
<< td::format::as_size((td::uint64)(double(sum_ - prev_logged_sum_) / elapsed)) << "/s)";
|
||||
LOG(WARNING) << "downloading state " << block_id_.to_str() << ": " << td::format::as_size(sum_) << " ("
|
||||
<< td::format::as_size((td::uint64)(double(sum_ - prev_logged_sum_) / elapsed)) << "/s)";
|
||||
prev_logged_sum_ = sum_;
|
||||
}
|
||||
|
||||
|
@ -234,7 +242,7 @@ void DownloadState::got_block_state_part(td::BufferSlice data, td::uint32 reques
|
|||
|
||||
void DownloadState::got_block_state(td::BufferSlice data) {
|
||||
state_ = std::move(data);
|
||||
LOG(INFO) << "finished downloading state " << block_id_.to_str() << ": total=" << sum_;
|
||||
LOG(WARNING) << "finished downloading state " << block_id_.to_str() << ": " << td::format::as_size(state_.size());
|
||||
finish_query();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue