Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Bank: Add function to replace empty account with upgradeable program on feature activation #32783

Merged
merged 33 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4ab4bf1
replace program account
buffalojoec Aug 9, 2023
fb1d4c9
modify for all cases
buffalojoec Aug 16, 2023
99eb96e
remove non-data swap
buffalojoec Aug 17, 2023
acbca38
address tests & conditional feedback
buffalojoec Aug 18, 2023
a8800b8
get the rent involved
buffalojoec Aug 18, 2023
86833f9
mix in owner & executable
buffalojoec Aug 18, 2023
637dd83
feature-related cases
buffalojoec Aug 18, 2023
e6bfb43
stripped back to feature-specific case only
buffalojoec Aug 18, 2023
24e75d5
added feature
buffalojoec Aug 18, 2023
a573a97
address initial feedback
buffalojoec Aug 21, 2023
c221038
added more lamport checks
buffalojoec Aug 21, 2023
b36f56a
condense tests
buffalojoec Aug 21, 2023
9a61900
using test_case
buffalojoec Aug 21, 2023
67986b4
add fail cases to tests
buffalojoec Aug 21, 2023
453dc8a
more cleanup
buffalojoec Aug 22, 2023
7d3f877
add verifiably built program
buffalojoec Aug 22, 2023
a6dd68e
update program account state
buffalojoec Aug 22, 2023
59a4132
cleaned up serializing logic
buffalojoec Aug 23, 2023
acfa993
use full word capitalization
buffalojoec Sep 15, 2023
6ef8353
rename old & new to dst & src
buffalojoec Sep 15, 2023
069dd53
swap src and dst in parameters
buffalojoec Sep 15, 2023
f044890
add warnings and errors
buffalojoec Sep 15, 2023
1e7b4e5
rename feature to programify
buffalojoec Sep 20, 2023
251b9a9
test suite description clarity
buffalojoec Sep 20, 2023
1b37cdc
remove strings from datapoints
buffalojoec Sep 20, 2023
5b280fd
spell out source and destination
buffalojoec Sep 29, 2023
6ccf0f1
more verbose comments in account replace functions
buffalojoec Sep 29, 2023
0392ad8
move lamport calculation
buffalojoec Sep 29, 2023
41c9c40
swap lamport check for state check
buffalojoec Sep 29, 2023
5cadf5b
move replace functions to helper module
buffalojoec Sep 29, 2023
3e7dc30
make replace_account methods fallible
buffalojoec Oct 3, 2023
19b35de
refactor error handling
buffalojoec Oct 4, 2023
91bfec7
add test for source program state
buffalojoec Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more verbose comments in account replace functions
  • Loading branch information
buffalojoec committed Oct 4, 2023
commit 6ccf0f13d947ebc42797de55f1d01f2cac69ae60
15 changes: 10 additions & 5 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8206,8 +8206,8 @@ impl Bank {
}

/// Moves one account in place of another
/// `source`: the program to replace with
/// `destination`: the program to be replaced
/// `source`: the account to replace with
/// `destination`: the account to be replaced
fn move_account<U, V>(
&mut self,
source_address: &Pubkey,
Expand Down Expand Up @@ -8241,9 +8241,9 @@ impl Bank {
);
}

/// Use to replace programs by feature activation
/// `source`: the program to replace with
/// `destination`: the program to be replaced
/// Use to replace non-upgradeable programs by feature activation
/// `source`: the non-upgradeable program account to replace with
/// `destination`: the non-upgradeable program account to be replaced
#[allow(dead_code)]
fn replace_non_upgradeable_program_account(
&mut self,
Expand Down Expand Up @@ -8281,6 +8281,11 @@ impl Bank {
}

/// Use to replace an empty account with a program by feature activation
/// Note: The upgradeable program should have both:
/// - Program account
/// - Program data account
/// `source`: the upgradeable program account to replace with
/// `destination`: the empty account to be replaced
fn replace_empty_account_with_upgradeable_program(
&mut self,
source_address: &Pubkey,
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8084,7 +8084,7 @@ fn test_replace_non_upgradeable_program_account() {
assert_eq!(destination_account.owner(), &bpf_id);
assert!(destination_account.executable());

// Lamports from the source program account were burnt
// The destination account's original lamports balance was burnt
assert_eq!(
bank.capitalization(),
original_capitalization - destination_lamports
Expand Down