1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-15 04:32:21 +00:00

Separate limits for collated data

This commit is contained in:
SpyCheese 2024-03-26 12:50:01 +03:00
parent 3190c67f18
commit 103eb9aad5
5 changed files with 20 additions and 11 deletions

View file

@ -678,10 +678,19 @@ bool BlockLimits::deserialize(vm::CellSlice& cs) {
}
// block_limits#5d
// block_limits_v2#5e
return bytes.deserialize(cs) // bytes:ParamLimits
&& gas.deserialize(cs) // gas:ParamLimits
&& lt_delta.deserialize(cs) // lt_delta:ParamLimits
&& (tag == 0x5d || imported_msg_queue.deserialize(cs)); // imported_msg_queue:ImportedMsgQueueLimits
bool ok = bytes.deserialize(cs) // bytes:ParamLimits
&& gas.deserialize(cs) // gas:ParamLimits
&& lt_delta.deserialize(cs); // lt_delta:ParamLimits
if (!ok) {
return false;
}
if (tag == 0x5d) {
return collated_data.deserialize(cs) && // collated_data:ParamLimits
imported_msg_queue.deserialize(cs); // imported_msg_queue:ImportedMsgQueueLimits
} else {
collated_data = bytes;
return true;
}
}
int ParamLimits::classify(td::uint64 value) const {
@ -714,7 +723,7 @@ int BlockLimits::classify_lt(ton::LogicalTime lt) const {
}
int BlockLimits::classify_collated_data_size(td::uint64 size) const {
return bytes.classify(size); // TODO: Maybe separate limits in config
return collated_data.classify(size);
}
int BlockLimits::classify(td::uint64 size, td::uint64 gas, ton::LogicalTime lt, td::uint64 collated_size) const {
@ -725,7 +734,7 @@ int BlockLimits::classify(td::uint64 size, td::uint64 gas, ton::LogicalTime lt,
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);
collated_data.fits(cls, collated_size);
}
td::uint64 BlockLimitStatus::estimate_block_size(const vm::NewCellStorageStat::Stat* extra) const {
@ -745,7 +754,7 @@ 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, collated_data_stat.estimate_proof_size()));
limits.collated_data.fits(cls, collated_data_stat.estimate_proof_size()));
}
bool BlockLimitStatus::would_fit(unsigned cls, ton::LogicalTime end_lt, td::uint64 more_gas,
@ -753,7 +762,7 @@ bool BlockLimitStatus::would_fit(unsigned cls, ton::LogicalTime end_lt, td::uint
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, collated_data_stat.estimate_proof_size()));
limits.collated_data.fits(cls, collated_data_stat.estimate_proof_size()));
}
// SETS: account_dict, shard_libraries_, mc_state_extra

View file

@ -255,7 +255,7 @@ struct ParamLimits {
};
struct BlockLimits {
ParamLimits bytes, gas, lt_delta;
ParamLimits bytes, gas, lt_delta, collated_data;
ton::LogicalTime start_lt{0};
ImportedMsgQueueLimits imported_msg_queue;
const vm::CellUsageTree* usage_tree{nullptr};

View file

@ -708,7 +708,7 @@ imported_msg_queue_limits#d3 max_bytes:# max_msgs:# = ImportedMsgQueueLimits;
block_limits#5d bytes:ParamLimits gas:ParamLimits lt_delta:ParamLimits
= BlockLimits;
block_limits_v2#5e bytes:ParamLimits gas:ParamLimits lt_delta:ParamLimits
imported_msg_queue:ImportedMsgQueueLimits
collated_data:ParamLimits imported_msg_queue:ImportedMsgQueueLimits
= BlockLimits;
config_mc_block_limits#_ BlockLimits = ConfigParam 22;

View file

@ -41,7 +41,6 @@ class NewCellStorageStat {
Stat(td::uint64 cells_, td::uint64 bits_, td::uint64 internal_refs_ = 0, td::uint64 external_refs_ = 0)
: cells(cells_), bits(bits_), internal_refs(internal_refs_), external_refs(external_refs_) {
}
Stat(const Stat&) = default;
td::uint64 cells{0};
td::uint64 bits{0};
td::uint64 internal_refs{0};
@ -53,6 +52,7 @@ class NewCellStorageStat {
bool operator==(const Stat& other) const {
return key() == other.key();
}
Stat(const Stat& other) = default;
Stat& operator=(const Stat& other) = default;
Stat& operator+=(const Stat& other) {
cells += other.cells;