1
0
Fork 0
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:
SpyCheese 2022-07-20 15:39:50 +03:00
parent 996c23e506
commit 53270a00e6
25 changed files with 577 additions and 33 deletions

View file

@ -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;