mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Limit collated data size in collator
This commit is contained in:
parent
d5a56b7c2b
commit
21ce145af2
9 changed files with 116 additions and 17 deletions
|
@ -701,12 +701,19 @@ int BlockLimits::classify_lt(ton::LogicalTime lt) const {
|
|||
return lt_delta.classify(lt - start_lt);
|
||||
}
|
||||
|
||||
int BlockLimits::classify(td::uint64 size, td::uint64 gas, ton::LogicalTime lt) const {
|
||||
return std::max(std::max(classify_size(size), classify_gas(gas)), classify_lt(lt));
|
||||
int BlockLimits::classify_collated_data_size(td::uint64 size) const {
|
||||
return bytes.classify(size); // TODO: Maybe separate limits in config
|
||||
}
|
||||
|
||||
bool BlockLimits::fits(unsigned cls, td::uint64 size, td::uint64 gas_value, ton::LogicalTime lt) const {
|
||||
return bytes.fits(cls, size) && gas.fits(cls, gas_value) && lt_delta.fits(cls, lt - start_lt);
|
||||
int BlockLimits::classify(td::uint64 size, td::uint64 gas, ton::LogicalTime lt, td::uint64 collated_size) const {
|
||||
return std::max(
|
||||
{classify_size(size), classify_gas(gas), classify_lt(lt), classify_collated_data_size(collated_size)});
|
||||
}
|
||||
|
||||
bool BlockLimits::fits(unsigned cls, td::uint64 size, td::uint64 gas_value, ton::LogicalTime lt,
|
||||
td::uint64 collated_size) const {
|
||||
return bytes.fits(cls, size) && gas.fits(cls, gas_value) && lt_delta.fits(cls, lt - start_lt) &&
|
||||
bytes.fits(cls, collated_size);
|
||||
}
|
||||
|
||||
td::uint64 BlockLimitStatus::estimate_block_size(const vm::NewCellStorageStat::Stat* extra) const {
|
||||
|
@ -719,20 +726,22 @@ td::uint64 BlockLimitStatus::estimate_block_size(const vm::NewCellStorageStat::S
|
|||
}
|
||||
|
||||
int BlockLimitStatus::classify() const {
|
||||
return limits.classify(estimate_block_size(), gas_used, cur_lt);
|
||||
return limits.classify(estimate_block_size(), gas_used, cur_lt, collated_data_stat.estimate_proof_size());
|
||||
}
|
||||
|
||||
bool BlockLimitStatus::fits(unsigned cls) const {
|
||||
return cls >= ParamLimits::limits_cnt ||
|
||||
(limits.gas.fits(cls, gas_used) && limits.lt_delta.fits(cls, cur_lt - limits.start_lt) &&
|
||||
limits.bytes.fits(cls, estimate_block_size()));
|
||||
limits.bytes.fits(cls, estimate_block_size()) &&
|
||||
limits.bytes.fits(cls, collated_data_stat.estimate_proof_size()));
|
||||
}
|
||||
|
||||
bool BlockLimitStatus::would_fit(unsigned cls, ton::LogicalTime end_lt, td::uint64 more_gas,
|
||||
const vm::NewCellStorageStat::Stat* extra) const {
|
||||
return cls >= ParamLimits::limits_cnt || (limits.gas.fits(cls, gas_used + more_gas) &&
|
||||
limits.lt_delta.fits(cls, std::max(cur_lt, end_lt) - limits.start_lt) &&
|
||||
limits.bytes.fits(cls, estimate_block_size(extra)));
|
||||
limits.bytes.fits(cls, estimate_block_size(extra)) &&
|
||||
limits.bytes.fits(cls, collated_data_stat.estimate_proof_size()));
|
||||
}
|
||||
|
||||
// SETS: account_dict, shard_libraries_, mc_state_extra
|
||||
|
|
|
@ -252,8 +252,9 @@ struct BlockLimits {
|
|||
int classify_size(td::uint64 size) const;
|
||||
int classify_gas(td::uint64 gas) const;
|
||||
int classify_lt(ton::LogicalTime lt) const;
|
||||
int classify(td::uint64 size, td::uint64 gas, ton::LogicalTime lt) const;
|
||||
bool fits(unsigned cls, td::uint64 size, td::uint64 gas, ton::LogicalTime lt) const;
|
||||
int classify_collated_data_size(td::uint64 size) const;
|
||||
int classify(td::uint64 size, td::uint64 gas, ton::LogicalTime lt, td::uint64 collated_size) const;
|
||||
bool fits(unsigned cls, td::uint64 size, td::uint64 gas, ton::LogicalTime lt, td::uint64 collated_size) const;
|
||||
};
|
||||
|
||||
struct BlockLimitStatus {
|
||||
|
@ -262,6 +263,7 @@ struct BlockLimitStatus {
|
|||
td::uint64 gas_used{};
|
||||
vm::NewCellStorageStat st_stat;
|
||||
unsigned accounts{}, transactions{}, extra_out_msgs{};
|
||||
vm::ProofStorageStat collated_data_stat;
|
||||
BlockLimitStatus(const BlockLimits& limits_, ton::LogicalTime lt = 0)
|
||||
: limits(limits_), cur_lt(std::max(limits_.start_lt, lt)) {
|
||||
}
|
||||
|
@ -271,6 +273,7 @@ struct BlockLimitStatus {
|
|||
transactions = accounts = 0;
|
||||
gas_used = 0;
|
||||
extra_out_msgs = 0;
|
||||
collated_data_stat = {};
|
||||
}
|
||||
td::uint64 estimate_block_size(const vm::NewCellStorageStat::Stat* extra = nullptr) const;
|
||||
int classify() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue