diff --git a/tonlib/tonlib/TonlibClient.cpp b/tonlib/tonlib/TonlibClient.cpp index b9ff4899c..507512d0f 100644 --- a/tonlib/tonlib/TonlibClient.cpp +++ b/tonlib/tonlib/TonlibClient.cpp @@ -5673,6 +5673,26 @@ td::Status TonlibClient::do_request(const tonlib_api::blocks_lookupBlock& reques td::Status check_lookup_block_proof(lite_api_ptr& result, int mode, ton::BlockId blkid, ton::BlockIdExt client_mc_blkid, td::uint64 lt, td::uint32 utime) { try { ton::BlockIdExt cur_id = ton::create_block_id(result->mc_block_id_); + if (!cur_id.is_masterchain_ext()) { + return td::Status::Error("invalid response: mc block id is not from masterchain"); + } + if (client_mc_blkid != cur_id) { + auto state = block::check_extract_state_proof(client_mc_blkid, result->client_mc_state_proof_.as_slice(), + result->mc_block_proof_.as_slice()); + if (state.is_error()) { + LOG(WARNING) << "cannot check state proof: " << state.move_as_error().to_string(); + return state.move_as_error(); + } + auto state_root = state.move_as_ok(); + auto prev_blocks_dict = block::get_prev_blocks_dict(state_root); + if (!prev_blocks_dict) { + return td::Status::Error("cannot extract prev blocks dict from state"); + } + + if (!block::check_old_mc_block_id(*prev_blocks_dict, cur_id)) { + return td::Status::Error("couldn't check old mc block id"); + } + } try { for (auto& link : result->shard_links_) { ton::BlockIdExt prev_id = create_block_id(link->id_); @@ -5686,23 +5706,6 @@ td::Status check_lookup_block_proof(lite_api_ptrclient_mc_state_proof_.as_slice(), - result->mc_block_proof_.as_slice()); - if (state.is_error()) { - LOG(WARNING) << "cannot check state proof: " << state.move_as_error().to_string(); - return state.move_as_error(); - } - auto state_root = state.move_as_ok(); - auto prev_blocks_dict = block::get_prev_blocks_dict(state_root); - if (!prev_blocks_dict) { - return td::Status::Error("cannot extract prev blocks dict from state"); - } - - if (!block::check_old_mc_block_id(*prev_blocks_dict, cur_id)) { - return td::Status::Error("couldn't check old mc block id"); - } - } block::gen::Block::Record blk; block::gen::BlockExtra::Record extra; block::gen::McBlockExtra::Record mc_extra; diff --git a/validator-engine/validator-engine.cpp b/validator-engine/validator-engine.cpp index 9ca22c4b9..cc7c57b35 100644 --- a/validator-engine/validator-engine.cpp +++ b/validator-engine/validator-engine.cpp @@ -1503,17 +1503,6 @@ td::Status ValidatorEngine::load_global_config() { h.push_back(b); } validator_options_.write().set_hardforks(std::move(h)); - - auto r_total_mem_stat = td::get_total_mem_stat(); - if (r_total_mem_stat.is_error()) { - LOG(ERROR) << "Failed to get total RAM size: " << r_total_mem_stat.move_as_error(); - } else { - td::uint64 total_ram = r_total_mem_stat.ok().total_ram; - LOG(WARNING) << "Total RAM = " << td::format::as_size(total_ram); - if (total_ram >= (90ULL << 30)) { - fast_state_serializer_enabled_ = true; - } - } validator_options_.write().set_fast_state_serializer_enabled(fast_state_serializer_enabled_); return td::Status::OK(); @@ -4553,7 +4542,7 @@ int main(int argc, char *argv[]) { }); p.add_option( '\0', "fast-state-serializer", - "faster persistent state serializer, but requires more RAM (enabled automatically on machines with >= 90GB RAM)", + "faster persistent state serializer, but requires more RAM", [&]() { acts.push_back( [&x]() { td::actor::send_closure(x, &ValidatorEngine::set_fast_state_serializer_enabled, true); });