From e04965c40093f836ef38581e7c14fb76f98fd48b Mon Sep 17 00:00:00 2001 From: SpyCheese Date: Fri, 20 Sep 2024 15:16:46 +0300 Subject: [PATCH] Fix setting original_balance in transaction.cpp --- common/global-version.h | 2 +- crypto/block/transaction.cpp | 9 ++++++++- doc/GlobalVersions.md | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/common/global-version.h b/common/global-version.h index a3032ebf2..533e5e8d7 100644 --- a/common/global-version.h +++ b/common/global-version.h @@ -19,6 +19,6 @@ namespace ton { // See doc/GlobalVersions.md -const int SUPPORTED_VERSION = 8; +const int SUPPORTED_VERSION = 9; } diff --git a/crypto/block/transaction.cpp b/crypto/block/transaction.cpp index dbf0199e7..9830ac86d 100644 --- a/crypto/block/transaction.cpp +++ b/crypto/block/transaction.cpp @@ -1555,7 +1555,14 @@ bool Transaction::prepare_compute_phase(const ComputePhaseConfig& cfg) { // ... compute_phase = std::make_unique(); ComputePhase& cp = *(compute_phase.get()); - original_balance -= total_fees; + if (cfg.global_version >= 9) { + original_balance = balance; + if (msg_balance_remaining.is_valid()) { + original_balance -= msg_balance_remaining; + } + } else { + original_balance -= total_fees; + } if (td::sgn(balance.grams) <= 0) { // no gas cp.skip_reason = ComputePhase::sk_no_gas; diff --git a/doc/GlobalVersions.md b/doc/GlobalVersions.md index e649c009a..5feb49d8b 100644 --- a/doc/GlobalVersions.md +++ b/doc/GlobalVersions.md @@ -109,4 +109,9 @@ Operations for working with Merkle proofs, where cells can have non-zero level a - Slightly change random seed generation to fix mix of `addr_rewrite` and `addr`. - Fill in `skipped_actions` for both invalid and valid messages with `IGNORE_ERROR` mode that can't be sent. - Allow unfreeze through external messages. -- Don't use user-provided `fwd_fee` and `ihr_fee` for internal messages. \ No newline at end of file +- Don't use user-provided `fwd_fee` and `ihr_fee` for internal messages. + +## Version 9 + +- Fix `RAWRESERVE` action with flag `4` (use original balance of the account) by explicitly setting `original_balance` to `balance - msg_balance_remaining`. + - Previously it did not work if storage fee was greater than the original balance. \ No newline at end of file