@@ -10,9 +10,9 @@ use solana_rbpf::{memory_region::MemoryRegion, EbpfVm};
1010use solana_sdk:: {
1111 account:: KeyedAccount ,
1212 entrypoint:: SUCCESS ,
13- instruction:: InstructionError ,
1413 loader_instruction:: LoaderInstruction ,
1514 program_utils:: DecodeError ,
15+ program_error:: ProgramError ,
1616 program_utils:: { is_executable, limited_deserialize, next_keyed_account} ,
1717 pubkey:: Pubkey ,
1818 sysvar:: rent,
@@ -75,7 +75,7 @@ pub fn serialize_parameters(
7575 program_id : & Pubkey ,
7676 keyed_accounts : & [ KeyedAccount ] ,
7777 data : & [ u8 ] ,
78- ) -> Result < Vec < u8 > , InstructionError > {
78+ ) -> Result < Vec < u8 > , ProgramError > {
7979 assert_eq ! ( 32 , mem:: size_of:: <Pubkey >( ) ) ;
8080
8181 let mut v: Vec < u8 > = Vec :: new ( ) ;
@@ -108,7 +108,7 @@ pub fn serialize_parameters(
108108pub fn deserialize_parameters (
109109 keyed_accounts : & [ KeyedAccount ] ,
110110 buffer : & [ u8 ] ,
111- ) -> Result < ( ) , InstructionError > {
111+ ) -> Result < ( ) , ProgramError > {
112112 assert_eq ! ( 32 , mem:: size_of:: <Pubkey >( ) ) ;
113113
114114 let mut start = mem:: size_of :: < u64 > ( ) ; // number of accounts
@@ -139,12 +139,12 @@ pub fn process_instruction(
139139 program_id : & Pubkey ,
140140 keyed_accounts : & [ KeyedAccount ] ,
141141 instruction_data : & [ u8 ] ,
142- ) -> Result < ( ) , InstructionError > {
142+ ) -> Result < ( ) , ProgramError > {
143143 solana_logger:: setup_with_default ( "solana=info" ) ;
144144
145145 if keyed_accounts. is_empty ( ) {
146146 warn ! ( "No account keys" ) ;
147- return Err ( InstructionError :: NotEnoughAccountKeys ) ;
147+ return Err ( ProgramError :: NotEnoughAccountKeys ) ;
148148 }
149149
150150 if is_executable ( keyed_accounts) ? {
@@ -166,7 +166,7 @@ pub fn process_instruction(
166166 match vm. execute_program ( parameter_bytes. as_slice ( ) , & [ ] , & [ heap_region] ) {
167167 Ok ( status) => {
168168 if status != SUCCESS {
169- let error: InstructionError = status. into ( ) ;
169+ let error: ProgramError = status. into ( ) ;
170170 warn ! ( "BPF program failed: {:?}" , error) ;
171171 return Err ( error) ;
172172 }
@@ -185,14 +185,14 @@ pub fn process_instruction(
185185 let program = next_keyed_account ( & mut keyed_accounts_iter) ?;
186186 if program. signer_key ( ) . is_none ( ) {
187187 warn ! ( "key[0] did not sign the transaction" ) ;
188- return Err ( InstructionError :: MissingRequiredSignature ) ;
188+ return Err ( ProgramError :: MissingRequiredSignature ) ;
189189 }
190190 let offset = offset as usize ;
191191 let len = bytes. len ( ) ;
192192 trace ! ( "Write: offset={} length={}" , offset, len) ;
193193 if program. data_len ( ) ? < offset + len {
194194 warn ! ( "Write overflow: {} < {}" , program. data_len( ) ?, offset + len) ;
195- return Err ( InstructionError :: AccountDataTooSmall ) ;
195+ return Err ( ProgramError :: AccountDataTooSmall ) ;
196196 }
197197 program. try_account_ref_mut ( ) ?. data [ offset..offset + len] . copy_from_slice ( & bytes) ;
198198 }
@@ -203,12 +203,12 @@ pub fn process_instruction(
203203
204204 if program. signer_key ( ) . is_none ( ) {
205205 warn ! ( "key[0] did not sign the transaction" ) ;
206- return Err ( InstructionError :: MissingRequiredSignature ) ;
206+ return Err ( ProgramError :: MissingRequiredSignature ) ;
207207 }
208208
209209 if let Err ( e) = check_elf ( & program. try_account_ref ( ) ?. data ) {
210210 warn ! ( "Invalid ELF: {}" , e) ;
211- return Err ( InstructionError :: InvalidAccountData ) ;
211+ return Err ( ProgramError :: InvalidAccountData ) ;
212212 }
213213
214214 rent:: verify_rent_exemption ( & program, & rent) ?;
@@ -259,13 +259,13 @@ mod tests {
259259
260260 // Case: Empty keyed accounts
261261 assert_eq ! (
262- Err ( InstructionError :: NotEnoughAccountKeys ) ,
262+ Err ( ProgramError :: NotEnoughAccountKeys ) ,
263263 process_instruction( & program_id, & vec![ ] , & instruction_data)
264264 ) ;
265265
266266 // Case: Not signed
267267 assert_eq ! (
268- Err ( InstructionError :: MissingRequiredSignature ) ,
268+ Err ( ProgramError :: MissingRequiredSignature ) ,
269269 process_instruction( & program_id, & keyed_accounts, & instruction_data)
270270 ) ;
271271
@@ -285,7 +285,7 @@ mod tests {
285285 let mut keyed_accounts = vec ! [ KeyedAccount :: new( & program_key, true , & program_account) ] ;
286286 keyed_accounts[ 0 ] . account . borrow_mut ( ) . data = vec ! [ 0 ; 5 ] ;
287287 assert_eq ! (
288- Err ( InstructionError :: AccountDataTooSmall ) ,
288+ Err ( ProgramError :: AccountDataTooSmall ) ,
289289 process_instruction( & program_id, & keyed_accounts, & instruction_data)
290290 ) ;
291291 }
@@ -306,7 +306,7 @@ mod tests {
306306
307307 // Case: Empty keyed accounts
308308 assert_eq ! (
309- Err ( InstructionError :: NotEnoughAccountKeys ) ,
309+ Err ( ProgramError :: NotEnoughAccountKeys ) ,
310310 process_instruction( & program_id, & vec![ ] , & instruction_data)
311311 ) ;
312312
@@ -315,7 +315,7 @@ mod tests {
315315
316316 // Case: Not signed
317317 assert_eq ! (
318- Err ( InstructionError :: MissingRequiredSignature ) ,
318+ Err ( ProgramError :: MissingRequiredSignature ) ,
319319 process_instruction( & program_id, & keyed_accounts, & instruction_data)
320320 ) ;
321321
@@ -339,7 +339,7 @@ mod tests {
339339 KeyedAccount :: new( & rent_key, false , & rent_account) ,
340340 ] ;
341341 assert_eq ! (
342- Err ( InstructionError :: InvalidAccountData ) ,
342+ Err ( ProgramError :: InvalidAccountData ) ,
343343 process_instruction( & program_id, & keyed_accounts, & instruction_data)
344344 ) ;
345345 }
@@ -363,7 +363,7 @@ mod tests {
363363
364364 // Case: Empty keyed accounts
365365 assert_eq ! (
366- Err ( InstructionError :: NotEnoughAccountKeys ) ,
366+ Err ( ProgramError :: NotEnoughAccountKeys ) ,
367367 process_instruction( & program_id, & vec![ ] , & vec![ ] )
368368 ) ;
369369
@@ -376,7 +376,7 @@ mod tests {
376376 // Case: Account not executable
377377 keyed_accounts[ 0 ] . account . borrow_mut ( ) . executable = false ;
378378 assert_eq ! (
379- Err ( InstructionError :: InvalidInstructionData ) ,
379+ Err ( ProgramError :: InvalidInstructionData ) ,
380380 process_instruction( & program_id, & keyed_accounts, & vec![ ] )
381381 ) ;
382382 keyed_accounts[ 0 ] . account . borrow_mut ( ) . executable = true ;
0 commit comments