Skip to content

Commit

Permalink
program: reorder lamport deduction on close (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec authored Nov 13, 2024
1 parent 247039b commit 654736b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
26 changes: 26 additions & 0 deletions program/benches/compute_units.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
#### Compute Units: 2024-11-13 16:51:07.839873 UTC

| Name | CUs | Delta |
|------|------|-------|
| create_lookup_table | 10756 | -- |
| freeze_lookup_table | 1518 | -- |
| extend_lookup_table_from_0_to_1 | 6227 | -- |
| extend_lookup_table_from_0_to_10 | 8846 | -- |
| extend_lookup_table_from_0_to_38 | 17082 | -- |
| extend_lookup_table_from_1_to_2 | 6227 | -- |
| extend_lookup_table_from_1_to_10 | 8552 | -- |
| extend_lookup_table_from_1_to_39 | 17082 | -- |
| extend_lookup_table_from_5_to_6 | 6227 | -- |
| extend_lookup_table_from_5_to_15 | 8847 | -- |
| extend_lookup_table_from_5_to_43 | 17082 | -- |
| extend_lookup_table_from_25_to_26 | 6230 | -- |
| extend_lookup_table_from_25_to_35 | 8849 | -- |
| extend_lookup_table_from_25_to_63 | 17085 | -- |
| extend_lookup_table_from_50_to_88 | 17088 | -- |
| extend_lookup_table_from_100_to_138 | 17094 | -- |
| extend_lookup_table_from_150_to_188 | 17101 | -- |
| extend_lookup_table_from_200_to_238 | 17107 | -- |
| extend_lookup_table_from_255_to_256 | 6259 | -- |
| deactivate_lookup_table | 3152 | -- |
| close_lookup_table | 2227 | -1 |

#### Compute Units: 2024-11-13 09:15:26.655388 UTC

| Name | CUs | Delta |
Expand Down
3 changes: 1 addition & 2 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,10 @@ fn process_close_lookup_table(program_id: &Pubkey, accounts: &[AccountInfo]) ->
.lamports()
.checked_add(recipient_info.lamports())
.ok_or::<ProgramError>(ProgramError::ArithmeticOverflow)?;

**lookup_table_info.try_borrow_mut_lamports()? = 0;
**recipient_info.try_borrow_mut_lamports()? = new_recipient_lamports;

// Lookup tables are _not_ reassigned when closed.
**lookup_table_info.try_borrow_mut_lamports()? = 0;
lookup_table_info.realloc(0, true)?;

Ok(())
Expand Down

0 comments on commit 654736b

Please sign in to comment.