3
3
crate :: declare_syscall,
4
4
solana_sdk:: {
5
5
feature_set:: enable_bpf_loader_set_authority_checked_ix,
6
+ stable_layout:: stable_instruction:: StableInstruction ,
6
7
syscalls:: {
7
8
MAX_CPI_ACCOUNT_INFOS , MAX_CPI_INSTRUCTION_ACCOUNTS , MAX_CPI_INSTRUCTION_DATA_LEN ,
8
9
} ,
@@ -211,7 +212,7 @@ trait SyscallInvokeSigned {
211
212
addr : u64 ,
212
213
memory_mapping : & mut MemoryMapping ,
213
214
invoke_context : & mut InvokeContext ,
214
- ) -> Result < Instruction , EbpfError > ;
215
+ ) -> Result < StableInstruction , EbpfError > ;
215
216
fn translate_accounts < ' a > (
216
217
instruction_accounts : & [ InstructionAccount ] ,
217
218
program_indices : & [ IndexOfAccount ] ,
@@ -258,8 +259,8 @@ impl SyscallInvokeSigned for SyscallInvokeSignedRust {
258
259
addr : u64 ,
259
260
memory_mapping : & mut MemoryMapping ,
260
261
invoke_context : & mut InvokeContext ,
261
- ) -> Result < Instruction , EbpfError > {
262
- let ix = translate_type :: < Instruction > (
262
+ ) -> Result < StableInstruction , EbpfError > {
263
+ let ix = translate_type :: < StableInstruction > (
263
264
memory_mapping,
264
265
addr,
265
266
invoke_context. get_check_aligned ( ) ,
@@ -296,10 +297,11 @@ impl SyscallInvokeSigned for SyscallInvokeSignedRust {
296
297
invoke_context. get_check_size ( ) ,
297
298
) ?
298
299
. to_vec ( ) ;
299
- Ok ( Instruction {
300
+
301
+ Ok ( StableInstruction {
302
+ accounts : accounts. into ( ) ,
303
+ data : data. into ( ) ,
300
304
program_id : ix. program_id ,
301
- accounts,
302
- data,
303
305
} )
304
306
}
305
307
@@ -469,7 +471,7 @@ impl SyscallInvokeSigned for SyscallInvokeSignedC {
469
471
addr : u64 ,
470
472
memory_mapping : & mut MemoryMapping ,
471
473
invoke_context : & mut InvokeContext ,
472
- ) -> Result < Instruction , EbpfError > {
474
+ ) -> Result < StableInstruction , EbpfError > {
473
475
let ix_c = translate_type :: < SolInstruction > (
474
476
memory_mapping,
475
477
addr,
@@ -530,10 +532,10 @@ impl SyscallInvokeSigned for SyscallInvokeSignedC {
530
532
} )
531
533
. collect :: < Result < Vec < AccountMeta > , EbpfError > > ( ) ?;
532
534
533
- Ok ( Instruction {
535
+ Ok ( StableInstruction {
536
+ accounts : accounts. into ( ) ,
537
+ data : data. into ( ) ,
534
538
program_id : * program_id,
535
- accounts,
536
- data,
537
539
} )
538
540
}
539
541
@@ -1128,6 +1130,7 @@ mod tests {
1128
1130
solana_sdk:: {
1129
1131
account:: { Account , AccountSharedData } ,
1130
1132
clock:: Epoch ,
1133
+ instruction:: Instruction ,
1131
1134
rent:: Rent ,
1132
1135
transaction_context:: { TransactionAccount , TransactionContext } ,
1133
1136
} ,
@@ -1693,12 +1696,12 @@ mod tests {
1693
1696
fn into_region ( self , vm_addr : u64 ) -> ( Vec < u8 > , MemoryRegion ) {
1694
1697
let accounts_len = mem:: size_of :: < AccountMeta > ( ) * self . accounts . len ( ) ;
1695
1698
1696
- let size = mem:: size_of :: < Instruction > ( ) + accounts_len + self . data . len ( ) ;
1699
+ let size = mem:: size_of :: < StableInstruction > ( ) + accounts_len + self . data . len ( ) ;
1697
1700
1698
1701
let mut data = vec ! [ 0 ; size] ;
1699
1702
1700
1703
let vm_addr = vm_addr as usize ;
1701
- let accounts_addr = vm_addr + mem:: size_of :: < Instruction > ( ) ;
1704
+ let accounts_addr = vm_addr + mem:: size_of :: < StableInstruction > ( ) ;
1702
1705
let data_addr = accounts_addr + accounts_len;
1703
1706
1704
1707
let ins = Instruction {
@@ -1714,6 +1717,7 @@ mod tests {
1714
1717
Vec :: from_raw_parts ( data_addr as * mut _ , self . data . len ( ) , self . data . len ( ) )
1715
1718
} ,
1716
1719
} ;
1720
+ let ins = StableInstruction :: from ( ins) ;
1717
1721
1718
1722
unsafe {
1719
1723
ptr:: write_unaligned ( data. as_mut_ptr ( ) . cast ( ) , ins) ;
0 commit comments