Allow program accounts to be passed as program and parameter (#8907)
This commit is contained in:
		@@ -158,6 +158,14 @@ pub fn process_instruction(
 | 
			
		||||
    if is_executable(keyed_accounts)? {
 | 
			
		||||
        let mut keyed_accounts_iter = keyed_accounts.iter();
 | 
			
		||||
        let program = next_keyed_account(&mut keyed_accounts_iter)?;
 | 
			
		||||
 | 
			
		||||
        let parameter_accounts = keyed_accounts_iter.as_slice();
 | 
			
		||||
        let parameter_bytes = serialize_parameters(
 | 
			
		||||
            program.unsigned_key(),
 | 
			
		||||
            parameter_accounts,
 | 
			
		||||
            &instruction_data,
 | 
			
		||||
        )?;
 | 
			
		||||
        {
 | 
			
		||||
            let program_account = program.try_account_ref_mut()?;
 | 
			
		||||
            let (mut vm, heap_region) = match create_vm(&program_account.data) {
 | 
			
		||||
                Ok(info) => info,
 | 
			
		||||
@@ -166,12 +174,6 @@ pub fn process_instruction(
 | 
			
		||||
                    return Err(BPFLoaderError::VirtualMachineCreationFailed.into());
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
        let parameter_accounts = keyed_accounts_iter.as_slice();
 | 
			
		||||
        let parameter_bytes = serialize_parameters(
 | 
			
		||||
            program.unsigned_key(),
 | 
			
		||||
            parameter_accounts,
 | 
			
		||||
            &instruction_data,
 | 
			
		||||
        )?;
 | 
			
		||||
 | 
			
		||||
            info!("Call BPF program");
 | 
			
		||||
            match vm.execute_program(parameter_bytes.as_slice(), &[], &[heap_region]) {
 | 
			
		||||
@@ -187,6 +189,7 @@ pub fn process_instruction(
 | 
			
		||||
                    return Err(BPFLoaderError::VirtualMachineFailedToRunProgram.into());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        deserialize_parameters(parameter_accounts, ¶meter_bytes)?;
 | 
			
		||||
        info!("BPF program success");
 | 
			
		||||
    } else if !keyed_accounts.is_empty() {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										693
									
								
								programs/librapay/Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										693
									
								
								programs/librapay/Cargo.lock
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user