mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Add CollatorNode and make validators request blocks from it
This commit is contained in:
parent
996c23e506
commit
53270a00e6
25 changed files with 577 additions and 33 deletions
|
@ -364,7 +364,8 @@ td::Status MasterchainStateQ::mc_init() {
|
|||
td::Status MasterchainStateQ::mc_reinit() {
|
||||
auto res = block::ConfigInfo::extract_config(
|
||||
root_cell(), block::ConfigInfo::needStateRoot | block::ConfigInfo::needValidatorSet |
|
||||
block::ConfigInfo::needShardHashes | block::ConfigInfo::needPrevBlocks);
|
||||
block::ConfigInfo::needShardHashes | block::ConfigInfo::needPrevBlocks |
|
||||
block::ConfigInfo::needWorkchainInfo);
|
||||
cur_validators_.reset();
|
||||
next_validators_.reset();
|
||||
if (res.is_error()) {
|
||||
|
@ -510,6 +511,27 @@ bool MasterchainStateQ::check_old_mc_block_id(const ton::BlockIdExt& blkid, bool
|
|||
return config_ && config_->check_old_mc_block_id(blkid, strict);
|
||||
}
|
||||
|
||||
std::vector<CollatorNodeDescr> MasterchainStateQ::get_collator_set() const {
|
||||
block::gen::CollatorSet::Record rec;
|
||||
auto cell = config_->get_config_param(81);
|
||||
if (cell.is_null() || !tlb::unpack_cell(std::move(cell), rec)) {
|
||||
return {};
|
||||
}
|
||||
vm::Dictionary dict{rec.collators->prefetch_ref(), 32 + 64 + 256};
|
||||
std::vector<CollatorNodeDescr> collators;
|
||||
dict.check_for_each([&](Ref<vm::CellSlice>, td::ConstBitPtr key, int n) {
|
||||
CHECK(n == 32 + 64 + 256);
|
||||
auto workchain = (td::int32)key.get_int(32);
|
||||
key.advance(32);
|
||||
td::uint64 shard = key.get_uint(64);
|
||||
key.advance(64);
|
||||
td::Bits256 adnl_id(key);
|
||||
collators.push_back({ShardIdFull(workchain, shard), adnl_id});
|
||||
return true;
|
||||
});
|
||||
return collators;
|
||||
}
|
||||
|
||||
td::uint32 MasterchainStateQ::min_split_depth(WorkchainId workchain_id) const {
|
||||
if (!config_) {
|
||||
return 0;
|
||||
|
|
|
@ -147,6 +147,10 @@ class MasterchainStateQ : public MasterchainState, public ShardStateQ {
|
|||
return td::make_ref<ConfigHolderQ>(config_);
|
||||
}
|
||||
}
|
||||
block::WorkchainSet get_workchain_list() const override {
|
||||
return config_ ? config_->get_workchain_list() : block::WorkchainSet();
|
||||
}
|
||||
std::vector<CollatorNodeDescr> get_collator_set() const override;
|
||||
|
||||
private:
|
||||
ZeroStateIdExt zerostate_id_;
|
||||
|
|
|
@ -448,7 +448,6 @@ bool ValidateQuery::init_parse() {
|
|||
return reject_query("after_merge value mismatch in block header");
|
||||
}
|
||||
rand_seed_ = extra.rand_seed;
|
||||
created_by_ = extra.created_by;
|
||||
if (created_by_ != extra.created_by) {
|
||||
return reject_query("block candidate "s + id_.to_str() + " has creator " + created_by_.to_hex() +
|
||||
" but the block header contains different value " + extra.created_by.to_hex());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue