Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
topointon-jump committed Nov 11, 2024
1 parent b4d0a49 commit b402da7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/flamenco/runtime/program/fd_vote_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/flamenco/runtime/program/fd_vote_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
9 changes: 6 additions & 3 deletions src/flamenco/vm/syscall/fd_vm_syscall_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

0 comments on commit b402da7

Please sign in to comment.