Skip to content

Commit

Permalink
runtime: add System Program nonce instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
riptl authored and ripatel-fd committed Feb 27, 2024
1 parent a45d0f5 commit 7db31c8
Show file tree
Hide file tree
Showing 3 changed files with 815 additions and 18 deletions.
13 changes: 12 additions & 1 deletion src/flamenco/runtime/info/fd_instr_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,23 @@ fd_instr_acc_is_writable( fd_instr_info_t const * instr,
return 0;
}

FD_FN_PURE static inline uint
FD_FN_PURE static inline int
fd_instr_acc_is_signer_idx( fd_instr_info_t const * instr,
uchar idx ) {
return !!(instr->acct_flags[idx] & FD_INSTR_ACCT_FLAGS_IS_SIGNER);
}

static inline int
fd_instr_acc_is_signer( fd_instr_info_t const * instr,
fd_pubkey_t const * acc ) {

for( ulong i=0UL; i < instr->acct_cnt; i++ )
if( 0==memcmp( &instr->acct_pubkeys[i], acc, sizeof(fd_pubkey_t) ) )
return fd_instr_acc_is_signer_idx( instr, (uchar)i );

return 0;
}

/* fd_instr_acc_is_owned_by_current_program returns 1 if the given
account is owned by the program invoked in the current instruction.
Otherwise, returns 0. Mirrors Anza's
Expand Down
4 changes: 2 additions & 2 deletions src/flamenco/runtime/program/fd_config_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _process_config_instr( fd_exec_instr_ctx_t ctx ) {

if( FD_UNLIKELY( ctx.instr->acct_cnt < 1UL ) )
return FD_EXECUTOR_INSTR_ERR_NOT_ENOUGH_ACC_KEYS;
# define ACC_IDX_CONFIG (0UL)
# define ACC_IDX_CONFIG ((uchar)0)
fd_borrowed_account_t * config_acc_rec = NULL;
fd_instr_borrowed_account_view_idx( &ctx, ACC_IDX_CONFIG, &config_acc_rec );

Expand All @@ -43,7 +43,7 @@ _process_config_instr( fd_exec_instr_ctx_t ctx ) {

/* https://github.com/solana-labs/solana/blob/v1.17.17/programs/config/src/config_processor.rs#L27 */

uint is_config_account_signer = fd_instr_acc_is_signer_idx( ctx.instr, ACC_IDX_CONFIG );
int is_config_account_signer = fd_instr_acc_is_signer_idx( ctx.instr, ACC_IDX_CONFIG );

/* https://github.com/solana-labs/solana/blob/v1.17.17/programs/config/src/config_processor.rs#L29-L31 */

Expand Down
Loading

0 comments on commit 7db31c8

Please sign in to comment.