Skip to content

Commit

Permalink
Use Config 8 to activate new gas limit behavior instead of new GasLim…
Browse files Browse the repository at this point in the history
…itsPrices constructor (#867)

* Remove gas_prices_v3, enable new gas limits by GlobalVersion = 5

* Change final date for higher gas limit

---------

Co-authored-by: SpyCheese <[email protected]>
  • Loading branch information
EmelyanenkoK and SpyCheese authored Jan 21, 2024
1 parent b1f2160 commit 128a85b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion common/global-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
namespace ton {

// See doc/GlobalVersions.md
const int SUPPORTED_VERSION = 4;
const int SUPPORTED_VERSION = 5;

}
5 changes: 0 additions & 5 deletions crypto/block/block.tlb
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,6 @@ gas_prices_ext#de gas_price:uint64 gas_limit:uint64 special_gas_limit:uint64 gas
block_gas_limit:uint64 freeze_due_limit:uint64 delete_due_limit:uint64
= GasLimitsPrices;

// same fields as gas_prices_ext; behavior differs
gas_prices_v3#df gas_price:uint64 gas_limit:uint64 special_gas_limit:uint64 gas_credit:uint64
block_gas_limit:uint64 freeze_due_limit:uint64 delete_due_limit:uint64
= GasLimitsPrices;

gas_flat_pfx#d1 flat_gas_limit:uint64 flat_gas_price:uint64 other:GasLimitsPrices
= GasLimitsPrices;

Expand Down
4 changes: 0 additions & 4 deletions crypto/block/mc-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,13 +654,9 @@ td::Result<GasLimitsPrices> Config::do_get_gas_limits_prices(td::Ref<vm::Cell> c
res.delete_due_limit = r.delete_due_limit;
};
block::gen::GasLimitsPrices::Record_gas_prices_ext rec;
block::gen::GasLimitsPrices::Record_gas_prices_v3 rec_v3;
vm::CellSlice cs0 = cs;
if (tlb::unpack(cs, rec)) {
f(rec, rec.special_gas_limit);
} else if (tlb::unpack(cs = cs0, rec_v3)) {
f(rec_v3, rec_v3.special_gas_limit);
res.special_full_limit = true;
} else {
block::gen::GasLimitsPrices::Record_gas_prices rec0;
if (tlb::unpack(cs = cs0, rec0)) {
Expand Down
1 change: 0 additions & 1 deletion crypto/block/mc-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ struct GasLimitsPrices {
td::uint64 block_gas_limit{0};
td::uint64 freeze_due_limit{0};
td::uint64 delete_due_limit{0};
bool special_full_limit{false};

td::RefInt256 compute_gas_price(td::uint64 gas_used) const;
};
Expand Down
13 changes: 5 additions & 8 deletions crypto/block/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,12 +1039,8 @@ bool ComputePhaseConfig::parse_GasLimitsPrices_internal(Ref<vm::CellSlice> cs, t
delete_due_limit = td::make_refint(r.delete_due_limit);
};
block::gen::GasLimitsPrices::Record_gas_prices_ext rec;
block::gen::GasLimitsPrices::Record_gas_prices_v3 rec_v3;
if (tlb::csr_unpack(cs, rec)) {
f(rec, rec.special_gas_limit);
} else if (tlb::csr_unpack(cs, rec_v3)) {
f(rec_v3, rec_v3.special_gas_limit);
special_gas_full = true;
} else {
block::gen::GasLimitsPrices::Record_gas_prices rec0;
if (tlb::csr_unpack(std::move(cs), rec0)) {
Expand Down Expand Up @@ -1153,8 +1149,8 @@ namespace transaction {
* not enough to clean up old queires, thus locking funds inside.
* See comment in crypto/smartcont/highload-wallet-v2-code.fc for details on why this happened.
* Account address: EQD_v9j1rlsuHHw2FIhcsCFFSD367ldfDdCKcsNmNpIRzUlu
* It was proposed to validators to increase gas limit for this account for a limited amount of time (until 2024-02-16).
* It is activated by setting gas_prices_v3 in ConfigParam 20 (config_mc_gas_prices).
* It was proposed to validators to increase gas limit for this account for a limited amount of time (until 2024-02-29).
* It is activated by setting global version to 5 in ConfigParam 8.
* This config change also activates new behavior for special accounts in masterchain.
*
* @param cfg The compute phase configuration.
Expand All @@ -1164,10 +1160,10 @@ namespace transaction {
* @returns True if gas_limit override is required, false otherwise
*/
static bool override_gas_limit(const ComputePhaseConfig& cfg, ton::UnixTime now, const Account& account) {
if (!cfg.mc_gas_prices.special_full_limit) {
if (!cfg.special_gas_full) {
return false;
}
ton::UnixTime until = 1708041600; // 2024-02-16 00:00:00 UTC
ton::UnixTime until = 1709164800; // 2024-02-29 00:00:00 UTC
ton::WorkchainId wc = 0;
const char* addr_hex = "FFBFD8F5AE5B2E1C7C3614885CB02145483DFAEE575F0DD08A72C366369211CD";
return now < until && account.workchain == wc && account.addr.to_hex() == addr_hex;
Expand Down Expand Up @@ -3533,6 +3529,7 @@ td::Status FetchConfigParams::fetch_config_params(
TRY_RESULT_PREFIX(mc_gas_prices, config.get_gas_limits_prices(true),
"cannot unpack masterchain gas prices and limits: ");
compute_phase_cfg->mc_gas_prices = std::move(mc_gas_prices);
compute_phase_cfg->special_gas_full = config.get_global_version() >= 5;
storage_phase_cfg->enable_due_payment = config.get_global_version() >= 4;
compute_phase_cfg->block_rand_seed = *rand_seed;
compute_phase_cfg->max_vm_data_depth = size_limits.max_vm_data_depth;
Expand Down
12 changes: 11 additions & 1 deletion doc/GlobalVersions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@ intermediate value before division (e.g. `(xy+w)/z`).
* Flag +16 in actions "Send message", "Reserve", "Change library" causes bounce if action fails.

### Storage phase
* Unpaid storage fee is now saved to `due_payment`
* Unpaid storage fee is now saved to `due_payment`

## Version 5
Version 5 enables higher gas limits for special contracts.

* Gas limit for all transactions on special contracts is set to `special_gas_limit` from `ConfigParam 20` (which is 35M at the moment of writing).
Previously only ticktock transactions had this limit, while ordinary transactions could use up to `gas_limit` gas (1M).
* Gas usage of special contracts is not taken into account when checking block limits. This allows keeping masterchain block limits low
while having high gas limits for elector.
* Gas limit on `EQD_v9j1rlsuHHw2FIhcsCFFSD367ldfDdCKcsNmNpIRzUlu` is increased to `special_gas_limit * 2` until 2024-02-29.
See [this post](https://t.me/tonstatus/88) for details.
1 change: 1 addition & 0 deletions validator/impl/validate-query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,7 @@ bool ValidateQuery::fetch_config_params() {
return fatal_error(mc_gas_prices.move_as_error_prefix("cannot unpack masterchain gas prices and limits: "));
}
compute_phase_cfg_.mc_gas_prices = mc_gas_prices.move_as_ok();
compute_phase_cfg_.special_gas_full = config_->get_global_version() >= 5;
storage_phase_cfg_.enable_due_payment = config_->get_global_version() >= 4;
compute_phase_cfg_.block_rand_seed = rand_seed_;
compute_phase_cfg_.libraries = std::make_unique<vm::Dictionary>(config_->get_libraries_root(), 256);
Expand Down

0 comments on commit 128a85b

Please sign in to comment.