Skip to content

Commit

Permalink
drop total_size
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Mar 26, 2024
1 parent 41cde30 commit 6aea930
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub(crate) struct SourceUpgradeableBpf {
pub program_account: AccountSharedData,
pub program_data_address: Pubkey,
pub program_data_account: AccountSharedData,
pub total_data_size: usize,
}

impl SourceUpgradeableBpf {
Expand Down Expand Up @@ -91,20 +90,11 @@ impl SourceUpgradeableBpf {
*program_address,
))?;

// The total data size is the size of the program account's data plus
// the size of the program data account's data.
let total_data_size = program_account
.data()
.len()
.checked_add(program_data_account.data().len())
.ok_or(CoreBpfMigrationError::ArithmeticOverflow)?;

let source_upgradeable_bpf = Self {
program_address: *program_address,
program_account,
program_data_address,
program_data_account,
total_data_size,
};

source_upgradeable_bpf.check_program_account()?;
Expand Down Expand Up @@ -235,10 +225,6 @@ mod tests {
source_upgradeable_bpf.program_data_account,
check_program_data_account
);
assert_eq!(
source_upgradeable_bpf.total_data_size,
check_program_account_data_len + check_program_data_account_data_len
);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub(crate) struct TargetBuiltin {
pub program_address: Pubkey,
pub program_account: AccountSharedData,
pub program_data_address: Pubkey,
pub total_data_size: usize,
}

impl TargetBuiltin {
Expand Down Expand Up @@ -62,14 +61,10 @@ impl TargetBuiltin {
));
}

// The total data size is the size of the program account's data.
let total_data_size = program_account.data().len();

Ok(Self {
program_address: *program_address,
program_account,
program_data_address,
total_data_size,
})
}
}
Expand Down Expand Up @@ -150,7 +145,6 @@ mod tests {
assert_eq!(target_builtin.program_address, program_address);
assert_eq!(target_builtin.program_account, program_account);
assert_eq!(target_builtin.program_data_address, program_data_address);
assert_eq!(target_builtin.total_data_size, program_account.data().len());

// Fail if the program account is not owned by the native loader
store_account(
Expand Down Expand Up @@ -214,7 +208,6 @@ mod tests {
assert_eq!(target_builtin.program_address, program_address);
assert_eq!(target_builtin.program_account, program_account);
assert_eq!(target_builtin.program_data_address, program_data_address);
assert_eq!(target_builtin.total_data_size, program_account.data().len());

// Fail if the program data account exists
store_account(
Expand Down

0 comments on commit 6aea930

Please sign in to comment.