mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Update validator config format; partial liteservers and their support in liteclient
This commit is contained in:
parent
a792565afa
commit
51e6885f2c
12 changed files with 657 additions and 363 deletions
|
@ -45,22 +45,41 @@ class TestNode : public td::actor::Actor {
|
|||
min_ls_version = 0x101,
|
||||
min_ls_capabilities = 1
|
||||
}; // server version >= 1.1, capabilities at least +1 = build proof chains
|
||||
td::actor::ActorOwn<ton::adnl::AdnlExtClient> client_;
|
||||
td::actor::ActorOwn<td::TerminalIO> io_;
|
||||
|
||||
struct LiteServer {
|
||||
td::IPAddress addr;
|
||||
ton::PublicKey public_key;
|
||||
bool is_full = true;
|
||||
std::vector<ton::ShardIdFull> shards;
|
||||
|
||||
td::actor::ActorOwn<ton::adnl::AdnlExtClient> client;
|
||||
bool client_ready = false;
|
||||
std::vector<td::Promise<td::Unit>> wait_client_ready;
|
||||
|
||||
int max_common_prefix(ton::ShardIdFull shard) const;
|
||||
bool supports_shard(ton::ShardIdFull shard) const;
|
||||
};
|
||||
std::vector<LiteServer> servers_;
|
||||
|
||||
td::int32 single_liteserver_idx_ = -1;
|
||||
td::IPAddress single_remote_addr_;
|
||||
ton::PublicKey single_remote_public_key_;
|
||||
|
||||
std::map<ton::ShardIdFull, td::int32> shard_server_idx_cached_;
|
||||
|
||||
bool readline_enabled_ = true;
|
||||
bool server_ok_ = false;
|
||||
td::int32 liteserver_idx_ = -1;
|
||||
int print_limit_ = 1024;
|
||||
|
||||
bool ready_ = false;
|
||||
bool inited_ = false;
|
||||
std::string db_root_;
|
||||
|
||||
int server_time_ = 0;
|
||||
int server_time_got_at_ = 0;
|
||||
int server_version_ = 0;
|
||||
long long server_capabilities_ = 0;
|
||||
// mc_server is the server for queries to masterchain
|
||||
int mc_server_idx_ = -1;
|
||||
int mc_server_time_ = 0;
|
||||
int mc_server_time_got_at_ = 0;
|
||||
int mc_server_version_ = 0;
|
||||
long long mc_server_capabilities_ = 0;
|
||||
bool mc_server_ok_ = false;
|
||||
|
||||
ton::ZeroStateIdExt zstate_id_;
|
||||
ton::BlockIdExt mc_last_id_;
|
||||
|
@ -75,9 +94,6 @@ class TestNode : public td::actor::Actor {
|
|||
const char *parse_ptr_, *parse_end_;
|
||||
td::Status error_;
|
||||
|
||||
td::IPAddress remote_addr_;
|
||||
ton::PublicKey remote_public_key_;
|
||||
|
||||
std::vector<ton::BlockIdExt> known_blk_ids_;
|
||||
std::size_t shown_blk_ids_ = 0;
|
||||
|
||||
|
@ -88,8 +104,6 @@ class TestNode : public td::actor::Actor {
|
|||
|
||||
std::map<td::Bits256, Ref<vm::Cell>> cell_cache_;
|
||||
|
||||
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&)>;
|
||||
|
||||
|
@ -182,8 +196,8 @@ class TestNode : public td::actor::Actor {
|
|||
void got_server_mc_block_id(ton::BlockIdExt blkid, ton::ZeroStateIdExt zstateid, int created_at);
|
||||
void got_server_mc_block_id_ext(ton::BlockIdExt blkid, ton::ZeroStateIdExt zstateid, int mode, int version,
|
||||
long long capabilities, int last_utime, int server_now);
|
||||
void set_server_version(td::int32 version, td::int64 capabilities);
|
||||
void set_server_time(int server_utime);
|
||||
void set_mc_server_version(td::int32 version, td::int64 capabilities);
|
||||
void set_mc_server_time(int server_utime);
|
||||
bool request_block(ton::BlockIdExt blkid);
|
||||
bool request_state(ton::BlockIdExt blkid);
|
||||
void got_mc_block(ton::BlockIdExt blkid, td::BufferSlice data);
|
||||
|
@ -358,16 +372,6 @@ class TestNode : public td::actor::Actor {
|
|||
static const tlb::TypenameLookup& get_tlb_dict();
|
||||
|
||||
public:
|
||||
void conn_ready() {
|
||||
LOG(ERROR) << "conn ready";
|
||||
ready_ = true;
|
||||
if (!inited_) {
|
||||
run_init_queries();
|
||||
}
|
||||
}
|
||||
void conn_closed() {
|
||||
ready_ = false;
|
||||
}
|
||||
void set_global_config(std::string str) {
|
||||
global_config_ = str;
|
||||
}
|
||||
|
@ -378,10 +382,10 @@ class TestNode : public td::actor::Actor {
|
|||
readline_enabled_ = value;
|
||||
}
|
||||
void set_liteserver_idx(td::int32 idx) {
|
||||
liteserver_idx_ = idx;
|
||||
single_liteserver_idx_ = idx;
|
||||
}
|
||||
void set_remote_addr(td::IPAddress addr) {
|
||||
remote_addr_ = addr;
|
||||
single_remote_addr_ = addr;
|
||||
}
|
||||
void set_public_key(td::BufferSlice file_name) {
|
||||
auto R = [&]() -> td::Result<ton::PublicKey> {
|
||||
|
@ -392,7 +396,7 @@ class TestNode : public td::actor::Actor {
|
|||
if (R.is_error()) {
|
||||
LOG(FATAL) << "bad server public key: " << R.move_as_error();
|
||||
}
|
||||
remote_public_key_ = R.move_as_ok();
|
||||
single_remote_public_key_ = R.move_as_ok();
|
||||
}
|
||||
void decode_public_key(td::BufferSlice b64_key) {
|
||||
auto R = [&]() -> td::Result<ton::PublicKey> {
|
||||
|
@ -404,7 +408,7 @@ class TestNode : public td::actor::Actor {
|
|||
if (R.is_error()) {
|
||||
LOG(FATAL) << "bad b64 server public key: " << R.move_as_error();
|
||||
}
|
||||
remote_public_key_ = R.move_as_ok();
|
||||
single_remote_public_key_ = R.move_as_ok();
|
||||
}
|
||||
void set_fail_timeout(td::Timestamp ts) {
|
||||
fail_timeout_ = ts;
|
||||
|
@ -439,7 +443,18 @@ class TestNode : public td::actor::Actor {
|
|||
|
||||
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);
|
||||
bool envelope_send_query_to_any(td::BufferSlice query, td::Promise<td::BufferSlice> promise);
|
||||
bool envelope_send_query_to_shard(ton::ShardIdFull shard, td::BufferSlice query,
|
||||
td::Promise<td::BufferSlice> promise);
|
||||
bool envelope_send_query_to_account(ton::AccountIdPrefixFull prefix, td::BufferSlice query,
|
||||
td::Promise<td::BufferSlice> promise);
|
||||
|
||||
bool envelope_send_query_to_server(td::int32 server_idx, td::BufferSlice query, td::Promise<td::BufferSlice> promise);
|
||||
|
||||
void start_client(int server_idx);
|
||||
void conn_ready(int server_idx);
|
||||
void conn_closed(int server_idx);
|
||||
|
||||
void parse_line(td::BufferSlice data);
|
||||
|
||||
TestNode() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue