Skip to content

Commit

Permalink
Serhii/bugs (#38)
Browse files Browse the repository at this point in the history
* fix send all balance

* changelog

* update

* fix

* Fix formating

---------

Co-authored-by: Alexander <alexander.s@gosh.sh>
  • Loading branch information
SeHor05 and SilkovAlexander authored Oct 7, 2024
1 parent 1c5674e commit 4615cfe
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 47 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [2.2.9] – 2024-08-19

### Fixed
- Fix SEND_ALL_BALANCE_FLAG

## [2.2.8] – 2024-08-19

### Improved
Expand Down
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ members = [
"tvm_vm",
]
[workspace.package]
version = "2.2.8"
version = "2.2.9"
rust-version = "1.76.0"

authors = ["TVM Labs <hello@tvmlabs.io>"]
Expand Down
66 changes: 40 additions & 26 deletions tvm_executor/src/transaction_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ pub trait TransactionExecutor {
OutAction::ReserveCurrency { mode, mut value } => {
if is_reserve_burn == false {
value.grams.add(&Grams::from(need_to_burn))?;
is_reserve_burn = true
is_reserve_burn = true;
}
match reserve_action_handler(
mode,
Expand Down Expand Up @@ -911,32 +911,46 @@ pub trait TransactionExecutor {
out_msgs.push(out_msg);
continue;
}
log::debug!(target: "executor", "\nSend message with all balance:\nInitial balance: {}",
balance_to_string(&acc_remaining_balance));
let result = outmsg_action_handler(
&mut phase,
mode,
&mut out_msg,
&mut acc_remaining_balance,
msg_remaining_balance,
compute_phase_fees,
self.config(),
is_special,
my_addr,
&total_reserved_value,
&mut account_deleted,
);
log::debug!(target: "executor", "Final balance: {}", balance_to_string(&acc_remaining_balance));
let err_code = match result {
Ok(_) => {
phase.msgs_created += 1;
out_msgs.push(out_msg);
0
let mut free_to_send = acc_remaining_balance.clone();
if acc_remaining_balance.grams > Grams::from(need_to_burn) || is_reserve_burn == true {
if is_reserve_burn == false {
free_to_send.grams.sub(&Grams::from(need_to_burn))?;
}
log::debug!(target: "executor", "\nSend message with all balance:\nInitial balance: {}",
balance_to_string(&acc_remaining_balance));
let result = outmsg_action_handler(
&mut phase,
mode,
&mut out_msg,
&mut free_to_send,
msg_remaining_balance,
compute_phase_fees,
self.config(),
is_special,
my_addr,
&total_reserved_value,
&mut account_deleted,
);
if is_reserve_burn == false {
free_to_send.grams.add(&Grams::from(need_to_burn))?;
}
acc_remaining_balance = free_to_send.clone();
log::debug!(target: "executor", "Final balance: {}", balance_to_string(&acc_remaining_balance));
let err_code = match result {
Ok(_) => {
phase.msgs_created += 1;
out_msgs.push(out_msg);
0
}
Err(code) => code,
};
if process_err_code(err_code, i, &mut phase)? {
return Ok(ActionPhaseResult::new(phase, vec![], copyleft_reward));
}
} else {
if process_err_code(RESULT_CODE_NOT_ENOUGH_GRAMS, i, &mut phase)? {
return Ok(ActionPhaseResult::new(phase, vec![], copyleft_reward));
}
Err(code) => code,
};
if process_err_code(err_code, i, &mut phase)? {
return Ok(ActionPhaseResult::new(phase, vec![], copyleft_reward));
}
}

Expand Down

0 comments on commit 4615cfe

Please sign in to comment.