Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/choreo/voter/fd_voter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

#define FD_VOTER_V2 (1)
#define FD_VOTER_V3 (2)
#define FD_VOTER_V4 (3)
FD_STATIC_ASSERT( FD_VOTER_V2==fd_vote_state_versioned_enum_v1_14_11, FD_VOTER_V2 );
FD_STATIC_ASSERT( FD_VOTER_V3==fd_vote_state_versioned_enum_current, FD_VOTER_V3 );
FD_STATIC_ASSERT( FD_VOTER_V3==fd_vote_state_versioned_enum_v3, FD_VOTER_V3 );
FD_STATIC_ASSERT( FD_VOTER_V4==fd_vote_state_versioned_enum_v4, FD_VOTER_V4 );

/* fd_voter describes the layout of a vote state stored in a vote
/* TODO: Update for vote state v4
fd_voter describes the layout of a vote state stored in a vote
account. These structs are used to support zero-copy access (direct
casts) of byte arrays containing the vote account data.
Expand Down
8 changes: 8 additions & 0 deletions src/flamenco/features/fd_features_generated.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,12 @@ fd_feature_id_t const ids[] = {
.name = "increase_cpi_account_info_limit",
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },

{ .index = offsetof(fd_features_t, vote_state_v4)>>3,
.id = {"\xec\xfa\x3a\xf2\xab\xa3\x21\x89\x19\xf4\xc3\x4c\x05\xdf\x88\xf0\x79\x57\x48\xf1\x3e\x35\x12\x0b\x7b\x56\xaa\xae\x3f\xe9\x98\x58"},
/* Gx4XFcrVMt4HUvPzTpTSVkdDVgcDSjKhDN1RqRS6KDuZ */
.name = "vote_state_v4",
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },

{ .index = ULONG_MAX }
};
/* TODO replace this with fd_map_perfect */
Expand Down Expand Up @@ -1972,6 +1978,7 @@ fd_feature_id_query( ulong prefix ) {
case 0x7c4802b8ba3fa849: return &ids[ 248 ];
case 0xab2a2311ca83eb09: return &ids[ 249 ];
case 0x55792888a8cf31ef: return &ids[ 250 ];
case 0x8921a3abf23afaec: return &ids[ 251 ];
default: break;
}
return NULL;
Expand Down Expand Up @@ -2228,4 +2235,5 @@ FD_STATIC_ASSERT( offsetof( fd_features_t, relax_intrabatch_account_locks
FD_STATIC_ASSERT( offsetof( fd_features_t, provide_instruction_data_offset_in_vm_r2 )>>3==248UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, enforce_fixed_fec_set )>>3==249UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, increase_cpi_account_info_limit )>>3==250UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, vote_state_v4 )>>3==251UL, layout );
FD_STATIC_ASSERT( sizeof( fd_features_t )>>3==FD_FEATURE_ID_CNT, layout );
5 changes: 3 additions & 2 deletions src/flamenco/features/fd_features_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#endif

/* FEATURE_ID_CNT is the number of features in ids */
#define FD_FEATURE_ID_CNT (251UL)
#define FD_FEATURE_ID_CNT (252UL)

/* Feature set ID calculated from all feature names */
#define FD_FEATURE_SET_ID (1776864602U)
#define FD_FEATURE_SET_ID (4221067627U)

union fd_features {
ulong f[ FD_FEATURE_ID_CNT ];
Expand Down Expand Up @@ -267,5 +267,6 @@ union fd_features {
/* 0x7c4802b8ba3fa849 */ ulong provide_instruction_data_offset_in_vm_r2;
/* 0xab2a2311ca83eb09 */ ulong enforce_fixed_fec_set;
/* 0x55792888a8cf31ef */ ulong increase_cpi_account_info_limit;
/* 0x8921a3abf23afaec */ ulong vote_state_v4;
};
};
3 changes: 2 additions & 1 deletion src/flamenco/features/feature_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,6 @@
{"name":"relax_intrabatch_account_locks","pubkey":"ENTRYnPAoT5Swwx73YDGzMp3XnNH1kxacyvLosRHza1i"},
{"name":"provide_instruction_data_offset_in_vm_r2","pubkey":"5xXZc66h4UdB6Yq7FzdBxBiRAFMMScMLwHxk2QZDaNZL"},
{"name":"enforce_fixed_fec_set","pubkey":"fixfecLZYMfkGzwq6NJA11Yw6KYztzXiK9QcL3K78in"},
{"name":"increase_cpi_account_info_limit","pubkey":"H6iVbVaDZgDphcPbcZwc5LoznMPWQfnJ1AM7L1xzqvt5"}
{"name":"increase_cpi_account_info_limit","pubkey":"H6iVbVaDZgDphcPbcZwc5LoznMPWQfnJ1AM7L1xzqvt5"},
{"name":"vote_state_v4","pubkey":"Gx4XFcrVMt4HUvPzTpTSVkdDVgcDSjKhDN1RqRS6KDuZ"}
]
4 changes: 2 additions & 2 deletions src/flamenco/genesis/fd_genesis_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ genesis_create( void * buf,

FD_SCRATCH_SCOPE_BEGIN {
fd_vote_state_versioned_t vsv[1];
fd_vote_state_versioned_new_disc( vsv, fd_vote_state_versioned_enum_current );
fd_vote_state_versioned_new_disc( vsv, fd_vote_state_versioned_enum_v3 );

fd_vote_state_t * vs = &vsv->inner.current;
fd_vote_state_v3_t * vs = &vsv->inner.v3;
vs->node_pubkey = options->identity_pubkey;
vs->authorized_withdrawer = options->identity_pubkey;
vs->commission = 100;
Expand Down
7 changes: 5 additions & 2 deletions src/flamenco/rewards/fd_rewards.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ get_vote_credits( uchar const * account_data,
case fd_vote_state_versioned_enum_v1_14_11:
*credits = vsv->inner.v1_14_11.epoch_credits;
break;
case fd_vote_state_versioned_enum_current:
*credits = vsv->inner.current.epoch_credits;
case fd_vote_state_versioned_enum_v3:
*credits = vsv->inner.v3.epoch_credits;
break;
case fd_vote_state_versioned_enum_v4:
*credits = vsv->inner.v4.epoch_credits;
break;
default:
__builtin_unreachable();
Expand Down
1 change: 1 addition & 0 deletions src/flamenco/runtime/fd_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct fd_runtime {
uchar authorized_voters_mem [ FD_AUTHORIZED_VOTERS_FOOTPRINT ] __attribute__((aligned(FD_AUTHORIZED_VOTERS_ALIGN)));
uchar vote_state_landed_votes_mem[ FD_LANDED_VOTES_FOOTPRINT ] __attribute__((aligned(FD_LANDED_VOTES_ALIGN)));
uchar tower_sync_landed_votes_mem[ FD_LANDED_VOTES_FOOTPRINT ] __attribute__((aligned(FD_LANDED_VOTES_ALIGN)));
uchar vote_lockout_mem [ FD_VOTE_LOCKOUTS_FOOTPRINT ] __attribute__((aligned(FD_VOTE_LOCKOUTS_ALIGN)));
} tower_sync;

struct {
Expand Down
20 changes: 10 additions & 10 deletions src/flamenco/runtime/program/fd_stake_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ get_stake_status( fd_exec_instr_ctx_t const * invoke_context,

// https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/sdk/program/src/vote/state/mod.rs#L740
static ulong
get_credits( fd_vote_state_t const * vote_state ) {
get_credits( fd_vote_state_v3_t const * vote_state ) {

return ( deq_fd_vote_epoch_credits_t_empty( vote_state->epoch_credits )
? 0
Expand All @@ -1205,7 +1205,7 @@ redelegate_stake( fd_exec_instr_ctx_t const * ctx,
fd_stake_t * stake,
ulong stake_lamports,
fd_pubkey_t const * voter_pubkey,
fd_vote_state_t const * vote_state,
fd_vote_state_v3_t const * vote_state,
fd_sol_sysvar_clock_t const * clock,
fd_stake_history_t const * stake_history,
uint * custom_err ) {
Expand Down Expand Up @@ -1247,10 +1247,10 @@ redelegate_stake( fd_exec_instr_ctx_t const * ctx,

// https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_state.rs#L202
static fd_stake_t
new_stake( ulong stake,
fd_pubkey_t const * voter_pubkey,
fd_vote_state_t const * vote_state,
ulong activation_epoch ) {
new_stake( ulong stake,
fd_pubkey_t const * voter_pubkey,
fd_vote_state_v3_t const * vote_state,
ulong activation_epoch ) {
// https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_state.rs#L208
return ( fd_stake_t ){
.delegation = {.voter_pubkey = *voter_pubkey,
Expand Down Expand Up @@ -1465,7 +1465,7 @@ delegate( fd_exec_instr_ctx_t const * ctx,
ctx->runtime->stake_program.delegate.landed_votes_mem );
fd_stake_t stake = new_stake( stake_amount,
vote_pubkey,
&vote_state->inner.current,
&vote_state->inner.v3,
clock->epoch );
// https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_state.rs#L343
fd_stake_state_v2_t new_stake_state = { .discriminant = fd_stake_state_v2_enum_stake,
Expand Down Expand Up @@ -1502,7 +1502,7 @@ delegate( fd_exec_instr_ctx_t const * ctx,
&stake,
stake_amount,
vote_pubkey,
&vote_state->inner.current,
&vote_state->inner.v3,
clock,
stake_history,
&ctx->txn_out->err.custom_err );
Expand Down Expand Up @@ -2443,7 +2443,7 @@ deactivate_delinquent( fd_exec_instr_ctx_t * ctx,
fd_vote_convert_to_current( delinquent_vote_state_versioned,
ctx->runtime->stake_program.deactivate_delinquent.delinquent_authorized_voters_mem,
ctx->runtime->stake_program.deactivate_delinquent.delinquent_landed_votes_mem );
fd_vote_state_t delinquent_vote_state = delinquent_vote_state_versioned->inner.current;
fd_vote_state_v3_t delinquent_vote_state = delinquent_vote_state_versioned->inner.v3;

/* https://github.com/anza-xyz/agave/blob/v2.1.14/programs/stake/src/stake_state.rs#L924 */
fd_guarded_borrowed_account_t reference_vote_account = {0};
Expand All @@ -2459,7 +2459,7 @@ deactivate_delinquent( fd_exec_instr_ctx_t * ctx,
fd_vote_convert_to_current( reference_vote_state_versioned,
ctx->runtime->stake_program.deactivate_delinquent.reference_authorized_voters_mem,
ctx->runtime->stake_program.deactivate_delinquent.reference_landed_votes_mem );
fd_vote_state_t reference_vote_state = reference_vote_state_versioned->inner.current;
fd_vote_state_v3_t reference_vote_state = reference_vote_state_versioned->inner.v3;

// https://github.com/anza-xyz/agave/blob/c8685ce0e1bb9b26014f1024de2cd2b8c308cbde/programs/stake/src/stake_state.rs#L933
if( !acceptable_reference_epoch_credits( reference_vote_state.epoch_credits, current_epoch ) ) {
Expand Down
Loading