mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 19:22:37 +00:00
Fix setting gas limits in transaction.cpp (#864)
Co-authored-by: SpyCheese <mikle98@yandex.ru>
This commit is contained in:
parent
6f277b40bf
commit
b1f2160510
2 changed files with 9 additions and 7 deletions
|
@ -1220,7 +1220,6 @@ bool Transaction::compute_gas_limits(ComputePhase& cp, const ComputePhaseConfig&
|
|||
} else {
|
||||
cp.gas_max = gas_bought_for(cfg, balance.grams);
|
||||
}
|
||||
cp.gas_credit = 0;
|
||||
if (trans_type != tr_ord || (account.is_special && cfg.special_gas_full)) {
|
||||
// may use all gas that can be bought using remaining balance
|
||||
cp.gas_limit = cp.gas_max;
|
||||
|
@ -1228,10 +1227,12 @@ bool Transaction::compute_gas_limits(ComputePhase& cp, const ComputePhaseConfig&
|
|||
// originally use only gas bought using remaining message balance
|
||||
// if the message is "accepted" by the smart contract, the gas limit will be set to gas_max
|
||||
cp.gas_limit = std::min(gas_bought_for(cfg, msg_balance_remaining.grams), cp.gas_max);
|
||||
if (!block::tlb::t_Message.is_internal(in_msg)) {
|
||||
// external messages carry no balance, give them some credit to check whether they are accepted
|
||||
cp.gas_credit = std::min(cfg.gas_credit, cp.gas_max);
|
||||
}
|
||||
}
|
||||
if (trans_type == tr_ord && !block::tlb::t_Message.is_internal(in_msg)) {
|
||||
// external messages carry no balance, give them some credit to check whether they are accepted
|
||||
cp.gas_credit = std::min(cfg.gas_credit, cp.gas_max);
|
||||
} else {
|
||||
cp.gas_credit = 0;
|
||||
}
|
||||
LOG(DEBUG) << "gas limits: max=" << cp.gas_max << ", limit=" << cp.gas_limit << ", credit=" << cp.gas_credit;
|
||||
return true;
|
||||
|
|
|
@ -102,7 +102,7 @@ void ExtMessageQ::run_message(td::BufferSlice data, block::SizeLimitsConfig::Ext
|
|||
|
||||
run_fetch_account_state(
|
||||
wc, addr, manager,
|
||||
[promise = std::move(promise), msg_root = root, wc,
|
||||
[promise = std::move(promise), msg_root = root, wc, addr,
|
||||
M](td::Result<std::tuple<td::Ref<vm::CellSlice>, UnixTime, LogicalTime, std::unique_ptr<block::ConfigInfo>>>
|
||||
res) mutable {
|
||||
if (res.is_error()) {
|
||||
|
@ -114,7 +114,8 @@ void ExtMessageQ::run_message(td::BufferSlice data, block::SizeLimitsConfig::Ext
|
|||
auto utime = std::get<1>(tuple);
|
||||
auto lt = std::get<2>(tuple);
|
||||
auto config = std::move(std::get<3>(tuple));
|
||||
if (!acc.unpack(shard_acc, utime, false)) {
|
||||
bool special = wc == masterchainId && config->is_special_smartcontract(addr);
|
||||
if (!acc.unpack(shard_acc, utime, special)) {
|
||||
promise.set_error(td::Status::Error(PSLICE() << "Failed to unpack account state"));
|
||||
} else {
|
||||
auto status = run_message_on_account(wc, &acc, utime, lt + 1, msg_root, std::move(config));
|
||||
|
|
Loading…
Reference in a new issue