Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flamenco: partitioned epoch rewards/rewards re-work #2253

Merged
merged 1 commit into from
Aug 13, 2024
Merged
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
1 change: 0 additions & 1 deletion contrib/test/instr-fixtures.list
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,6 @@ dump/test-vectors/instr/fixtures/stake/instr-11JMaFqtRHm1AmGZheH12hBtd6PXPeMHup5
dump/test-vectors/instr/fixtures/stake/instr-11JMezVj9uGqwHR1fsJFLP7nX5XNRvH2GyaVBFzn7Dw2rXAPc7Mt5xhQwdQLH1rAhQQgasf8EAQnw7jEu9fe2b-0837.fix
dump/test-vectors/instr/fixtures/stake/crash-07f2f688f82c8c33ee50302b71fb3c057c41a434.fix
dump/test-vectors/instr/fixtures/stake/crash-20ce38c3517c8466df5a5cbc5adf6ed5d1fd61a9.fix
dump/test-vectors/instr/fixtures/stake/crash-69a7d999158549209b2a9aecc8535c4e465cab7a.fix
dump/test-vectors/instr/fixtures/stake/crash-7c91a7f6fd2fae3516bea36d344110d9e2bda7ff.fix
dump/test-vectors/instr/fixtures/stake/crash-f706da836efde5073bea149eb5a7d7f4d711fbd2.fix
dump/test-vectors/instr/fixtures/stake/30572e1204a480dadbfb5881d24274d68c41de5b_1512750.fix
Expand Down
4 changes: 3 additions & 1 deletion src/flamenco/capture/fd_solcap_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ typedef struct fd_solcap_account_tbl fd_solcap_account_tbl_t;
#define FD_SOLCAP_FHDR_SZ (256UL)

/* FD_SOLCAP_ACC_TBL_CNT is the number of entries that fit in the in-
memory buffer for the account table. */
memory buffer for the account table.

N.b: to support epoch boundaries increase this number to 2097152 */

#define FD_SOLCAP_ACC_TBL_CNT (8192U)

Expand Down
8 changes: 3 additions & 5 deletions src/flamenco/capture/fd_solcap_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,8 @@ fd_solcap_writer_init( fd_solcap_writer_t * writer,
}

/* Init writer */

*writer = (fd_solcap_writer_t) {
.file = (FILE *)file,
.stream_goff = (ulong)stream_goff
};
writer->file = file;
writer->stream_goff = stream_goff;

return writer;
}
Expand Down Expand Up @@ -285,6 +282,7 @@ fd_solcap_flush_account_table( fd_solcap_writer_t * writer ) {

/* FIXME: This breaks account recording for epoch boundaries and needs to be fixed */
if( writer->account_idx >= FD_SOLCAP_ACC_TBL_CNT ) {
FD_LOG_WARNING(( "too many records in solcap accounts table - try increasing FD_SOLCAP_ACC_TBL_CNT" ));
writer->account_idx = 0UL;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/flamenco/rewards/Local.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ifdef FD_HAS_INT128
$(call add-hdrs,fd_rewards.h fd_rewards_types.h)
$(call add-hdrs,fd_rewards.h)
$(call add-objs,fd_rewards,fd_flamenco)
endif
1,664 changes: 865 additions & 799 deletions src/flamenco/rewards/fd_rewards.c

Large diffs are not rendered by default.

24 changes: 10 additions & 14 deletions src/flamenco/rewards/fd_rewards.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,22 @@ FD_PROTOTYPES_BEGIN

void
fd_update_rewards( fd_exec_slot_ctx_t * slot_ctx,
ulong prev_epoch );
ulong parent_epoch );

void
fd_begin_partitioned_rewards( fd_exec_slot_ctx_t * slot_ctx,
ulong parent_epoch );
fd_begin_partitioned_rewards(
fd_exec_slot_ctx_t * slot_ctx,
const fd_hash_t * parent_blockhash,
ulong parent_epoch );

void
fd_distribute_partitioned_epoch_rewards( fd_exec_slot_ctx_t * slot_ctx );

struct fd_inflation_rates {
ulong epoch;
double foundation;
double total;
double validator;
};
typedef struct fd_inflation_rates fd_inflation_rates_t;
fd_rewards_recalculate_partitioned_rewards(
fd_exec_slot_ctx_t * slot_ctx,
const fd_hash_t * parent_blockhash
);

void
fd_calculate_inflation_rates( fd_exec_slot_ctx_t * slot_ctx,
fd_inflation_rates_t * rates );
fd_distribute_partitioned_epoch_rewards( fd_exec_slot_ctx_t * slot_ctx );

FD_PROTOTYPES_END

Expand Down
121 changes: 0 additions & 121 deletions src/flamenco/rewards/fd_rewards_types.h

This file was deleted.

5 changes: 3 additions & 2 deletions src/flamenco/runtime/context/fd_exec_slot_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ fd_exec_slot_ctx_new( void * mem,
self->sysvar_cache = fd_sysvar_cache_new( fd_valloc_malloc( valloc, fd_sysvar_cache_align(), fd_sysvar_cache_footprint() ), valloc );
self->account_compute_table = fd_account_compute_table_join( fd_account_compute_table_new( fd_valloc_malloc( valloc, fd_account_compute_table_align(), fd_account_compute_table_footprint( 10000 ) ), 10000, 0 ) );

/* This is inactive by default */
self->epoch_reward_status.discriminant = fd_epoch_reward_status_enum_Inactive;

FD_COMPILER_MFENCE();
self->magic = FD_EXEC_SLOT_CTX_MAGIC;
FD_COMPILER_MFENCE();
Expand Down Expand Up @@ -393,7 +396,5 @@ fd_exec_slot_ctx_free( fd_exec_slot_ctx_t * slot_ctx ) {
fd_slot_hashes_destroy( slot_ctx->sysvar_cache_old.slot_hashes, &ctx );

/* leader points to a caller-allocated leader schedule */

fd_stake_rewards_vector_destroy( slot_ctx->epoch_reward_status.stake_rewards_by_partition );
fd_exec_slot_ctx_delete( fd_exec_slot_ctx_leave( slot_ctx ) );
}
1 change: 0 additions & 1 deletion src/flamenco/runtime/context/fd_exec_slot_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "../../../util/rng/fd_rng.h"
#include "../../../util/wksp/fd_wksp.h"

#include "../../rewards/fd_rewards_types.h"
#include "../sysvar/fd_sysvar_cache.h"
#include "../sysvar/fd_sysvar_cache_old.h"
#include "../../types/fd_types.h"
Expand Down
Loading
Loading