1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

Move msg queue limits to config

This commit is contained in:
SpyCheese 2023-07-24 15:29:55 +03:00
parent 66b98b6d6a
commit f1e62d0075
21 changed files with 109 additions and 48 deletions

View file

@ -655,6 +655,12 @@ bool EnqueuedMsgDescr::check_key(td::ConstBitPtr key) const {
hash_ == key + 96;
}
bool ImportedMsgQueueLimits::deserialize(vm::CellSlice& cs) {
return cs.fetch_ulong(8) == 0xd3 // imported_msg_queue_limits#d3
&& cs.fetch_uint_to(32, max_bytes) // max_bytes:#
&& cs.fetch_uint_to(32, max_msgs); // max_msgs:#
}
bool ParamLimits::deserialize(vm::CellSlice& cs) {
return cs.fetch_ulong(8) == 0xc3 // param_limits#c3
&& cs.fetch_uint_to(32, limits_[0]) // underload:uint32
@ -666,10 +672,16 @@ bool ParamLimits::deserialize(vm::CellSlice& cs) {
}
bool BlockLimits::deserialize(vm::CellSlice& cs) {
return cs.fetch_ulong(8) == 0x5d // block_limits#5d
&& bytes.deserialize(cs) // bytes:ParamLimits
&& gas.deserialize(cs) // gas:ParamLimits
&& lt_delta.deserialize(cs); // lt_delta:ParamLimits
auto tag = cs.fetch_ulong(8);
if (tag != 0x5d && tag != 0x5e) {
return false;
}
// 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
}
int ParamLimits::classify(td::uint64 value) const {

View file

@ -216,6 +216,13 @@ static inline std::ostream& operator<<(std::ostream& os, const MsgProcessedUptoC
return proc_coll.print(os);
}
struct ImportedMsgQueueLimits {
// Default values
td::uint32 max_bytes = 1 << 18;
td::uint32 max_msgs = 40;
bool deserialize(vm::CellSlice& cs);
};
struct ParamLimits {
enum { limits_cnt = 4 };
enum { cl_underload = 0, cl_normal = 1, cl_soft = 2, cl_medium = 3, cl_hard = 4 };
@ -247,6 +254,7 @@ struct ParamLimits {
struct BlockLimits {
ParamLimits bytes, gas, lt_delta;
ton::LogicalTime start_lt{0};
ImportedMsgQueueLimits imported_msg_queue;
const vm::CellUsageTree* usage_tree{nullptr};
bool deserialize(vm::CellSlice& cs);
int classify_size(td::uint64 size) const;

View file

@ -704,9 +704,13 @@ config_gas_prices#_ GasLimitsPrices = ConfigParam 21;
param_limits#c3 underload:# soft_limit:# { underload <= soft_limit }
hard_limit:# { soft_limit <= hard_limit } = ParamLimits;
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
= BlockLimits;
config_mc_block_limits#_ BlockLimits = ConfigParam 22;
config_block_limits#_ BlockLimits = ConfigParam 23;