Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_instructions_h 2 : #define HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_instructions_h 3 : 4 : #include "../../fd_flamenco_base.h" 5 : #include "../../accdb/fd_accdb.h" 6 : #include "../../../ballet/txn/fd_txn.h" 7 : 8 : FD_PROTOTYPES_BEGIN 9 : 10 : /* fd_sysvar_instructions_offsets_overflow returns 1 if serializing the 11 : instructions sysvar for the given txn would cause the offset to 12 : overflow. This is only possible for V1 transactions. This mirrors 13 : Agave's semantics. 14 : 15 : https://github.com/anza-xyz/solana-sdk/blob/instructions-sysvar@v4.0.0/instructions-sysvar/src/lib.rs#L97-L156 */ 16 : FD_FN_PURE static inline int 17 9 : fd_sysvar_instructions_offsets_overflow( fd_txn_t const * txn ) { 18 9 : ulong off = sizeof(ushort) + (ulong)sizeof(ushort)*txn->instr_cnt; 19 21 : for( ushort i=0; i<txn->instr_cnt; i++ ) { 20 18 : if( FD_UNLIKELY( off>(ulong)USHORT_MAX ) ) return 1; 21 12 : off += sizeof(ushort) 22 12 : + (ulong)txn->instr[i].acct_cnt*( sizeof(uchar)+sizeof(fd_pubkey_t) ) 23 12 : + sizeof(fd_pubkey_t) + sizeof(ushort) + txn->instr[i].data_sz; 24 12 : } 25 3 : return 0; 26 9 : } 27 : 28 : int 29 : fd_sysvar_instructions_serialize_account( fd_txn_in_t const * txn_in, 30 : fd_txn_out_t * txn_out, 31 : ulong txn_idx ); 32 : 33 : void 34 : fd_sysvar_instructions_update_current_instr_idx( fd_acc_t * acc, 35 : ushort current_instr_idx ); 36 : 37 : FD_PROTOTYPES_END 38 : 39 : #endif /* HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_instructions_h */