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

updated submodules, bugfixes

- added new fift/func code for validator complaint creation
- bugfixes in validator
- updates in tonlib
- new versions of rocksdb/abseil
- hardfork support
This commit is contained in:
ton 2020-04-27 16:01:46 +04:00
parent 16a4566091
commit 9f008b129f
129 changed files with 8438 additions and 879 deletions

File diff suppressed because it is too large Load diff

View file

@ -33,6 +33,7 @@
#include "vm/cells.h"
#include "vm/stack.hpp"
#include "block/block.h"
#include "block/mc-config.h"
#include "td/utils/filesystem.h"
using td::Ref;
@ -67,8 +68,8 @@ class TestNode : public td::actor::Actor {
ton::BlockIdExt last_block_id_, last_state_id_;
td::BufferSlice last_block_data_, last_state_data_;
ton::StdSmcAddress dns_root_;
bool dns_root_queried_{false};
ton::StdSmcAddress dns_root_, elect_addr_;
bool dns_root_queried_{false}, elect_addr_queried_{false};
std::string line_;
const char *parse_ptr_, *parse_end_;
@ -89,6 +90,9 @@ class TestNode : public td::actor::Actor {
std::unique_ptr<ton::adnl::AdnlExtClient::Callback> make_callback();
using creator_stats_func_t =
std::function<bool(const td::Bits256&, const block::DiscountedCounter&, const block::DiscountedCounter&)>;
struct TransId {
ton::Bits256 acc_addr;
ton::LogicalTime trans_lt;
@ -98,6 +102,75 @@ class TestNode : public td::actor::Actor {
}
};
struct BlockHdrInfo {
ton::BlockIdExt blk_id;
Ref<vm::Cell> proof, virt_blk_root;
int mode;
BlockHdrInfo() : mode(-1) {
}
BlockHdrInfo(const ton::BlockIdExt blk_id_, Ref<vm::Cell> proof_, Ref<vm::Cell> vroot_, int mode_)
: blk_id(blk_id_), proof(std::move(proof_)), virt_blk_root(std::move(vroot_)), mode(mode_) {
}
};
struct ConfigInfo {
std::unique_ptr<block::Config> config;
Ref<vm::Cell> state_proof, config_proof;
ConfigInfo() = default;
ConfigInfo(std::unique_ptr<block::Config> config_, Ref<vm::Cell> state_proof_, Ref<vm::Cell> config_proof_)
: config(std::move(config_)), state_proof(std::move(state_proof_)), config_proof(std::move(config_proof_)) {
}
};
struct CreatorStatsRes {
int mode;
bool complete{false};
td::Bits256 last_key;
Ref<vm::Cell> state_proof, data_proof;
CreatorStatsRes(int mode_ = 0) : mode(mode_) {
last_key.set_zero();
}
CreatorStatsRes(int mode_, const td::Bits256& key_, Ref<vm::Cell> st_proof_ = {}, Ref<vm::Cell> dproof_ = {})
: mode(mode_), last_key(key_), state_proof(std::move(st_proof_)), data_proof(std::move(dproof_)) {
}
};
struct ValidatorLoadInfo {
ton::BlockIdExt blk_id;
Ref<vm::Cell> state_proof, data_proof, virt_root;
std::unique_ptr<block::Config> config;
ton::UnixTime block_created_at{0};
ton::UnixTime valid_since{0};
ton::LogicalTime end_lt{0};
ton::Bits256 vset_hash;
Ref<vm::Cell> vset_root;
std::unique_ptr<block::ValidatorSet> vset;
std::map<ton::Bits256, int> vset_map;
int special_idx{-1};
std::pair<td::int64, td::int64> created_total, created_special;
std::vector<std::pair<td::int64, td::int64>> created;
ValidatorLoadInfo(ton::BlockIdExt blkid, Ref<vm::Cell> root, Ref<vm::Cell> root2,
std::unique_ptr<block::Config> cfg = {})
: blk_id(blkid)
, state_proof(std::move(root))
, data_proof(std::move(root2))
, config(std::move(cfg))
, valid_since(0) {
}
td::Status unpack_vset();
bool store_record(const td::Bits256& key, const block::DiscountedCounter& mc_cnt,
const block::DiscountedCounter& shard_cnt);
bool has_data() const {
return blk_id.is_masterchain_ext() && state_proof.not_null() && data_proof.not_null() && config;
}
td::Status check_header_proof(ton::UnixTime* save_utime = nullptr, ton::LogicalTime* save_lt = nullptr) const;
td::Result<Ref<vm::Cell>> build_proof(int idx, td::Bits256* save_pubkey = nullptr) const;
td::Result<Ref<vm::Cell>> build_producer_info(int idx, td::Bits256* save_pubkey = nullptr) const;
td::Status init_check_proofs();
static td::Result<std::unique_ptr<ValidatorLoadInfo>> preinit_from_producer_info(Ref<vm::Cell> prod_info);
td::Status load_special_creator_stat(const td::Bits256& spec_pubkey, bool load_total = true);
};
void run_init_queries();
char cur() const {
return *parse_ptr_;
@ -133,6 +206,8 @@ class TestNode : public td::actor::Actor {
std::vector<vm::StackEntry> params, td::BufferSlice remote_c7, td::BufferSlice remote_libs,
td::BufferSlice remote_result, int remote_exit_code,
td::Promise<std::vector<vm::StackEntry>> promise);
bool register_config_param(int idx, Ref<vm::Cell> value);
bool register_config_param1(Ref<vm::Cell> value);
bool register_config_param4(Ref<vm::Cell> value);
bool dns_resolve_start(ton::WorkchainId workchain, ton::StdSmcAddress addr, ton::BlockIdExt blkid, std::string domain,
int cat, int mode);
@ -144,18 +219,24 @@ class TestNode : public td::actor::Actor {
bool show_dns_record(std::ostream& os, int cat, Ref<vm::Cell> value, bool raw_dump);
bool get_all_shards(std::string filename = "", bool use_last = true, ton::BlockIdExt blkid = {});
void got_all_shards(ton::BlockIdExt blk, td::BufferSlice proof, td::BufferSlice data, std::string filename);
bool get_config_params(ton::BlockIdExt blkid, td::Promise<td::Unit> do_after, int mode = 0, std::string filename = "",
std::vector<int> params = {});
void got_config_params(ton::BlockIdExt req_blkid, ton::BlockIdExt blkid, td::BufferSlice state_proof,
td::BufferSlice cfg_proof, int mode, std::string filename, std::vector<int> params,
td::Promise<td::Unit> do_after);
bool parse_get_config_params(ton::BlockIdExt blkid, int mode = 0, std::string filename = "",
std::vector<int> params = {});
bool get_config_params(ton::BlockIdExt blkid, td::Promise<std::unique_ptr<block::Config>> promise, int mode = 0,
std::string filename = "", std::vector<int> params = {});
bool get_config_params_ext(ton::BlockIdExt blkid, td::Promise<ConfigInfo> promise, int mode = 0,
std::string filename = "", std::vector<int> params = {});
void got_config_params(ton::BlockIdExt req_blkid, int mode, std::string filename, std::vector<int> params,
td::Result<td::BufferSlice> R, td::Promise<ConfigInfo> promise);
bool get_block(ton::BlockIdExt blk, bool dump = false);
void got_block(ton::BlockIdExt blkid, td::BufferSlice data, bool dump);
bool get_state(ton::BlockIdExt blk, bool dump = false);
void got_state(ton::BlockIdExt blkid, ton::RootHash root_hash, ton::FileHash file_hash, td::BufferSlice data,
bool dump);
bool get_block_header(ton::BlockIdExt blk, int mode);
bool lookup_block(ton::ShardIdFull shard, int mode, td::uint64 arg);
bool get_show_block_header(ton::BlockIdExt blk, int mode);
bool get_block_header(ton::BlockIdExt blk, int mode, td::Promise<BlockHdrInfo> promise);
bool lookup_show_block(ton::ShardIdFull shard, int mode, td::uint64 arg);
bool lookup_block(ton::ShardIdFull shard, int mode, td::uint64 arg, td::Promise<BlockHdrInfo>);
void got_block_header_raw(td::BufferSlice res, td::Promise<BlockHdrInfo> promise, ton::BlockIdExt req_blkid = {});
void got_block_header(ton::BlockIdExt blkid, td::BufferSlice data, int mode);
bool show_block_header(ton::BlockIdExt blkid, Ref<vm::Cell> root, int mode);
bool show_state_header(ton::BlockIdExt blkid, Ref<vm::Cell> root, int mode);
@ -177,9 +258,43 @@ class TestNode : public td::actor::Actor {
void got_block_proof(ton::BlockIdExt from, ton::BlockIdExt to, int mode, td::BufferSlice res);
bool get_creator_stats(ton::BlockIdExt blkid, int mode, unsigned req_count, ton::Bits256 start_after,
ton::UnixTime min_utime);
void got_creator_stats(ton::BlockIdExt req_blkid, ton::BlockIdExt blkid, int req_mode, int mode,
td::Bits256 start_after, ton::UnixTime min_utime, td::BufferSlice state_proof,
td::BufferSlice data_proof, int count, int req_count, bool complete);
bool get_creator_stats(ton::BlockIdExt blkid, int mode, unsigned req_count, ton::Bits256 start_after,
ton::UnixTime min_utime, creator_stats_func_t func, td::Promise<td::Bits256> promise);
bool get_creator_stats(ton::BlockIdExt blkid, unsigned req_count, ton::UnixTime min_utime, creator_stats_func_t func,
std::unique_ptr<CreatorStatsRes> state, td::Promise<std::unique_ptr<CreatorStatsRes>> promise);
void got_creator_stats(ton::BlockIdExt req_blkid, ton::BlockIdExt blkid, int mode, ton::UnixTime min_utime,
td::BufferSlice state_proof, td::BufferSlice data_proof, int count, int req_count,
bool complete, creator_stats_func_t func, std::unique_ptr<CreatorStatsRes> state,
td::Promise<std::unique_ptr<CreatorStatsRes>> promise);
bool check_validator_load(int start_time, int end_time, int mode = 0, std::string file_pfx = "");
void continue_check_validator_load(ton::BlockIdExt blkid1, Ref<vm::Cell> root1, ton::BlockIdExt blkid2,
Ref<vm::Cell> root2, int mode = 0, std::string file_pfx = "");
void continue_check_validator_load2(std::unique_ptr<ValidatorLoadInfo> info1,
std::unique_ptr<ValidatorLoadInfo> info2, int mode = 0,
std::string file_pfx = "");
void continue_check_validator_load3(std::unique_ptr<ValidatorLoadInfo> info1,
std::unique_ptr<ValidatorLoadInfo> info2, int mode = 0,
std::string file_pfx = "");
td::Status write_val_create_proof(ValidatorLoadInfo& info1, ValidatorLoadInfo& info2, int idx, bool severe,
std::string file_pfx, int cnt);
bool load_creator_stats(std::unique_ptr<ValidatorLoadInfo> load_to,
td::Promise<std::unique_ptr<ValidatorLoadInfo>> promise, bool need_proofs);
td::Status check_validator_load_proof(std::string filename, std::string vset_filename = "",
ton::Bits256 vset_hash = ton::Bits256::zero());
td::Status continue_check_validator_load_proof(std::unique_ptr<ValidatorLoadInfo> info1,
std::unique_ptr<ValidatorLoadInfo> info2, Ref<vm::Cell> root);
bool get_elector_addr(td::Promise<ton::StdSmcAddress> promise);
bool get_past_validator_sets();
bool send_past_vset_query(ton::StdSmcAddress elector_addr);
void register_past_vset_info(vm::StackEntry list);
bool get_complaints(unsigned elect_id, std::string file_pfx);
void send_get_complaints_query(unsigned elect_id, ton::StdSmcAddress elector_addr, std::string file_pfx);
void save_complaints(unsigned elect_id, Ref<vm::Cell> complaints, std::string file_pfx);
td::Status get_complaint_price(unsigned expires_in, std::string filename);
td::Status get_complaint_price(unsigned expires_in, unsigned bits, unsigned refs,
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 cache_cell(Ref<vm::Cell> cell);
bool list_cached_cells() const;
bool dump_cached_cell(td::Slice hash_pfx, td::Slice type_name = {});
@ -222,6 +337,17 @@ class TestNode : public td::actor::Actor {
bool show_new_blkids(bool all = false);
bool complete_blkid(ton::BlockId partial_blkid, ton::BlockIdExt& complete_blkid) const;
td::Promise<td::Unit> trivial_promise();
template <typename T>
td::Promise<T> trivial_promise_of() {
return td::PromiseCreator::lambda([Self = actor_id(this)](td::Result<T> res) {
if (res.is_error()) {
LOG(ERROR) << "error: " << res.move_as_error();
}
});
}
static ton::UnixTime now() {
return static_cast<td::uint32>(td::Clocks::system());
}
static const tlb::TypenameLookup& get_tlb_dict();
public:
@ -292,7 +418,8 @@ class TestNode : public td::actor::Actor {
//td::actor::SchedulerContext::get()->stop();
}
void got_result();
void got_result(td::Result<td::BufferSlice> R, td::Promise<td::BufferSlice> promise);
void after_got_result(bool ok);
bool envelope_send_query(td::BufferSlice query, td::Promise<td::BufferSlice> promise);
void parse_line(td::BufferSlice data);