Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 committed Feb 14, 2023
1 parent 5466755 commit a349b74
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
14 changes: 1 addition & 13 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ impl Debug for LoadedProgramType {
pub struct LoadedProgram {
/// The program of this entry
pub program: LoadedProgramType,
/// Size of account that stores the program
/// Size of account that stores the program and program data
pub account_size: usize,
/// Pubkey of programdata account, if the program uses bpf_loader_upgradeable
pub maybe_programdata: Option<Pubkey>,
/// Size of programdata account
pub programdata_account_size: usize,
/// Slot in which the program was (re)deployed
pub deployment_slot: Slot,
/// Slot in which this entry will become active (can be in the future)
Expand All @@ -92,8 +88,6 @@ impl LoadedProgram {
deployment_slot: Slot,
elf_bytes: &[u8],
account_size: usize,
programdata_key: Option<Pubkey>,
programdata_size: usize,
) -> Result<Self, EbpfError> {
let program = if bpf_loader_deprecated::check_id(loader_key) {
let executable = Executable::load(elf_bytes, loader.clone())?;
Expand All @@ -107,8 +101,6 @@ impl LoadedProgram {
Ok(Self {
deployment_slot,
account_size,
maybe_programdata: programdata_key,
programdata_account_size: programdata_size,
effective_slot: deployment_slot.saturating_add(1),
usage_counter: AtomicU64::new(0),
program,
Expand All @@ -123,8 +115,6 @@ impl LoadedProgram {
Self {
deployment_slot,
account_size: 0,
maybe_programdata: None,
programdata_account_size: 0,
effective_slot: deployment_slot.saturating_add(1),
usage_counter: AtomicU64::new(0),
program: LoadedProgramType::BuiltIn(program),
Expand Down Expand Up @@ -397,8 +387,6 @@ mod tests {
Arc::new(LoadedProgram {
program: LoadedProgramType::Invalid,
account_size: 0,
maybe_programdata: None,
programdata_account_size: 0,
deployment_slot,
effective_slot,
usage_counter: AtomicU64::default(),
Expand Down
14 changes: 2 additions & 12 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,9 @@ fn get_programdata_offset(
) -> Result<usize, InstructionError> {
if bpf_loader_upgradeable::check_id(program.get_owner()) {
if let UpgradeableLoaderState::Program {
programdata_address,
programdata_address: _,
} = program.get_state()?
{
if &programdata_address != programdata.get_key() {
ic_logger_msg!(
log_collector,
"Wrong ProgramData account for this Program account"
);
return Err(InstructionError::InvalidArgument);
}
if !matches!(
programdata.get_state()?,
UpgradeableLoaderState::ProgramData {
Expand All @@ -223,7 +216,6 @@ pub fn load_program_from_account(
compute_budget: &ComputeBudget,
log_collector: Option<Rc<RefCell<LogCollector>>>,
program: &BorrowedAccount,
programdata_key: Option<Pubkey>,
programdata: &BorrowedAccount,
) -> Result<(LoadedProgram, Option<CreateMetrics>), InstructionError> {
if !check_loader_id(program.get_owner()) {
Expand Down Expand Up @@ -264,9 +256,7 @@ pub fn load_program_from_account(
.get_data()
.get(programdata_offset..)
.ok_or(InstructionError::AccountDataTooSmall)?,
program.get_data().len(),
programdata_key,
programdata_size,
program.get_data().len().saturating_add(programdata_size),
)
.map_err(|err| {
ic_logger_msg!(log_collector, "{}", err);
Expand Down

0 comments on commit a349b74

Please sign in to comment.