mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Accelerator: partial fullnodes (#1393)
* Accelerator: partial fullnodes 1) Node can monitor a subset of shards 2) New archive slice format (sharded) 3) Validators are still required to have all shards 4) Support partial liteservers in lite-client, blockchain explorer, tonlib 5) Proxy liteserver * Fix compilation error
This commit is contained in:
parent
62444100f5
commit
954a96a077
83 changed files with 3213 additions and 1113 deletions
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
#include "state-serializer.hpp"
|
||||
#include "td/utils/Random.h"
|
||||
#include "adnl/utils.hpp"
|
||||
#include "ton/ton-io.hpp"
|
||||
#include "common/delay.h"
|
||||
#include "td/utils/filesystem.h"
|
||||
|
@ -151,6 +150,21 @@ void AsyncStateSerializer::next_iteration() {
|
|||
CHECK(masterchain_handle_->id() == last_block_id_);
|
||||
if (attempt_ < max_attempt() && last_key_block_id_.id.seqno < last_block_id_.id.seqno &&
|
||||
need_serialize(masterchain_handle_)) {
|
||||
if (!stored_persistent_state_description_) {
|
||||
LOG(INFO) << "storing persistent state description for " << masterchain_handle_->id().id;
|
||||
running_ = true;
|
||||
auto P = td::PromiseCreator::lambda([SelfId = actor_id(this)](td::Result<td::Ref<ShardState>> R) {
|
||||
if (R.is_error()) {
|
||||
td::actor::send_closure(SelfId, &AsyncStateSerializer::fail_handler,
|
||||
R.move_as_error_prefix("failed to get masterchain state: "));
|
||||
} else {
|
||||
td::actor::send_closure(SelfId, &AsyncStateSerializer::store_persistent_state_description,
|
||||
td::Ref<MasterchainState>(R.move_as_ok()));
|
||||
}
|
||||
});
|
||||
td::actor::send_closure(manager_, &ValidatorManager::get_shard_state_from_db, masterchain_handle_, std::move(P));
|
||||
return;
|
||||
}
|
||||
if (!have_masterchain_state_ && !opts_->get_state_serializer_enabled()) {
|
||||
LOG(ERROR) << "skipping serializing persistent state for " << masterchain_handle_->id().id.to_str()
|
||||
<< ": serializer is disabled (by user)";
|
||||
|
@ -174,14 +188,10 @@ void AsyncStateSerializer::next_iteration() {
|
|||
td::Timestamp::in(delay));
|
||||
return;
|
||||
}
|
||||
while (next_idx_ < shards_.size()) {
|
||||
if (!need_monitor(shards_[next_idx_].shard_full())) {
|
||||
next_idx_++;
|
||||
} else {
|
||||
running_ = true;
|
||||
request_shard_state(shards_[next_idx_]);
|
||||
return;
|
||||
}
|
||||
if (next_idx_ < shards_.size()) {
|
||||
running_ = true;
|
||||
request_shard_state(shards_[next_idx_]);
|
||||
return;
|
||||
}
|
||||
LOG(ERROR) << "finished serializing persistent state for " << masterchain_handle_->id().id.to_str();
|
||||
}
|
||||
|
@ -203,6 +213,7 @@ void AsyncStateSerializer::next_iteration() {
|
|||
if (masterchain_handle_->inited_next_left()) {
|
||||
last_block_id_ = masterchain_handle_->one_next(true);
|
||||
have_masterchain_state_ = false;
|
||||
stored_persistent_state_description_ = false;
|
||||
masterchain_handle_ = nullptr;
|
||||
saved_to_db_ = false;
|
||||
shards_.clear();
|
||||
|
@ -217,6 +228,24 @@ void AsyncStateSerializer::got_top_masterchain_handle(BlockIdExt block_id) {
|
|||
}
|
||||
}
|
||||
|
||||
void AsyncStateSerializer::store_persistent_state_description(td::Ref<MasterchainState> state) {
|
||||
stored_persistent_state_description_ = true;
|
||||
attempt_ = 0;
|
||||
running_ = false;
|
||||
|
||||
PersistentStateDescription desc;
|
||||
desc.masterchain_id = state->get_block_id();
|
||||
desc.start_time = state->get_unix_time();
|
||||
desc.end_time = ValidatorManager::persistent_state_ttl(desc.start_time);
|
||||
for (const auto &v : state->get_shards()) {
|
||||
desc.shard_blocks.push_back(v->top_block_id());
|
||||
}
|
||||
td::actor::send_closure(manager_, &ValidatorManager::add_persistent_state_description,
|
||||
td::Ref<PersistentStateDescription>(true, std::move(desc)));
|
||||
|
||||
next_iteration();
|
||||
}
|
||||
|
||||
void AsyncStateSerializer::got_masterchain_handle(BlockHandle handle) {
|
||||
CHECK(!masterchain_handle_);
|
||||
masterchain_handle_ = std::move(handle);
|
||||
|
@ -318,8 +347,10 @@ void AsyncStateSerializer::got_masterchain_state(td::Ref<MasterchainState> state
|
|||
CHECK(shards_.size() == 0);
|
||||
|
||||
auto vec = state->get_shards();
|
||||
for (auto& v : vec) {
|
||||
shards_.push_back(v->top_block_id());
|
||||
for (auto &v : vec) {
|
||||
if (opts_->need_monitor(v->shard(), state)) {
|
||||
shards_.push_back(v->top_block_id());
|
||||
}
|
||||
}
|
||||
|
||||
auto write_data = [shard = state->get_shard(), root = state->root_cell(), cell_db_reader,
|
||||
|
@ -447,11 +478,6 @@ void AsyncStateSerializer::auto_disable_serializer(bool disabled) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool AsyncStateSerializer::need_monitor(ShardIdFull shard) {
|
||||
return opts_->need_monitor(shard);
|
||||
}
|
||||
|
||||
bool AsyncStateSerializer::need_serialize(BlockHandle handle) {
|
||||
if (handle->id().id.seqno == 0 || !handle->is_key_block()) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue