Skip to content

Commit

Permalink
Fix lamport calculation and transfer for loader-v4 program upgrade (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 authored Sep 16, 2023
1 parent 6300a43 commit 6db57f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions programs/loader-v4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ pub fn process_instruction_deploy(
load_program_metrics.submit_datapoint(&mut invoke_context.timings);
if let Some(mut source_program) = source_program {
let rent = invoke_context.get_sysvar_cache().get_rent()?;
let required_lamports = rent.minimum_balance(program.get_data().len());
let transfer_lamports = program.get_lamports().saturating_sub(required_lamports);
let required_lamports = rent.minimum_balance(source_program.get_data().len());
let transfer_lamports = required_lamports.saturating_sub(program.get_lamports());
program.set_data_from_slice(source_program.get_data())?;
source_program.set_data_length(0)?;
source_program.checked_sub_lamports(transfer_lamports)?;
Expand Down

0 comments on commit 6db57f8

Please sign in to comment.