diff --git a/src/flamenco/runtime/program/fd_vote_program.c b/src/flamenco/runtime/program/fd_vote_program.c index 5a4a06a1d8..b61746b7bb 100644 --- a/src/flamenco/runtime/program/fd_vote_program.c +++ b/src/flamenco/runtime/program/fd_vote_program.c @@ -1933,7 +1933,7 @@ do_process_vote_state_update( fd_vote_state_t * vote_state, } // ?? -static ulong +ulong query_pubkey_stake( fd_pubkey_t const * pubkey, fd_vote_accounts_t const * vote_accounts ) { fd_vote_accounts_pair_t_mapnode_t key = { 0 }; key.elem.key = *pubkey; diff --git a/src/flamenco/runtime/program/fd_vote_program.h b/src/flamenco/runtime/program/fd_vote_program.h index 622ea2aed1..e685ee5c29 100644 --- a/src/flamenco/runtime/program/fd_vote_program.h +++ b/src/flamenco/runtime/program/fd_vote_program.h @@ -77,6 +77,12 @@ void fd_vote_store_account( fd_exec_slot_ctx_t * slot_ctx, fd_borrowed_account_t * vote_account ); +/* Queries the delegated stake amount for the given vote account pubkey, + given the vote accounts map. */ +ulong +query_pubkey_stake( fd_pubkey_t const * pubkey, + fd_vote_accounts_t const * vote_accounts ); + FD_PROTOTYPES_END #endif /* HEADER_fd_src_flamenco_runtime_program_fd_vote_program_h */ diff --git a/src/flamenco/vm/syscall/fd_vm_syscall_runtime.c b/src/flamenco/vm/syscall/fd_vm_syscall_runtime.c index 0235f0e29b..9ad3b8359e 100644 --- a/src/flamenco/vm/syscall/fd_vm_syscall_runtime.c +++ b/src/flamenco/vm/syscall/fd_vm_syscall_runtime.c @@ -6,6 +6,7 @@ #include "../../runtime/sysvar/fd_sysvar_rent.h" #include "../../runtime/sysvar/fd_sysvar_last_restart_slot.h" #include "../../runtime/context/fd_exec_txn_ctx.h" +#include "../../runtime/program/fd_vote_program.h" #include "../../runtime/context/fd_exec_instr_ctx.h" int @@ -497,7 +498,7 @@ fd_vm_syscall_sol_get_epoch_stake( Get the epoch stakes used to calculate the leader schedule for the current epoch. https://github.com/firedancer-io/agave/blob/a68325a4264f4907067bd2f48526944347c606d4/runtime/src/bank.rs#L6269 */ - for ( ) + /* FIXME: get total epoch stake */ *ret = epoch_total_stake; return FD_VM_SUCCESS; @@ -518,13 +519,15 @@ fd_vm_syscall_sol_get_epoch_stake( /* Look up the amount of stake this vote account has, and return this. https://github.com/firedancer-io/agave/blob/a68325a4264f4907067bd2f48526944347c606d4/programs/bpf_loader/src/syscalls/mod.rs#L2097 */ - ulong vote_account_stake = 0UL; - fd_pubkey_t * vote_pubkey = FD_VM_MEM_HADDR_LD( + fd_pubkey_t const * vote_pubkey = FD_VM_MEM_HADDR_LD( vm, var_vaddr, FD_VM_ALIGN_RUST_PUBKEY, FD_PUBKEY_FOOTPRINT ); + ulong vote_account_stake = query_pubkey_stake( + vote_pubkey, &instr_ctx->epoch_ctx->epoch_bank.stakes.vote_accounts ); + *ret = vote_account_stake; return FD_VM_SUCCESS; }