Skip to content

Commit

Permalink
flamenco: change hardcoded to use cluster version
Browse files Browse the repository at this point in the history
  • Loading branch information
kbhargava-jump authored and lheeger-jump committed Jul 12, 2024
1 parent 7e9eac4 commit 2170356
Show file tree
Hide file tree
Showing 12 changed files with 320 additions and 314 deletions.
2 changes: 1 addition & 1 deletion src/app/fddev/configure/genesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ create_genesis( config_t * const config,

fd_features_t features[1];
fd_features_disable_all( features );
fd_features_enable_hardcoded( features );
fd_features_enable_hardcoded( features, FD_DEFAULT_AGAVE_CLUSTER_VERSION );
default_enable_features( features );

options->features = features;
Expand Down
3 changes: 2 additions & 1 deletion src/app/ledger/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ replay( fd_ledger_args_t * args ) {
args->epoch_ctx = fd_exec_epoch_ctx_join( fd_exec_epoch_ctx_new( epoch_ctx_mem, args->vote_acct_max ) );

args->epoch_ctx->epoch_bank.cluster_version = args->cluster_version;
fd_features_enable_hardcoded( &args->epoch_ctx->features, args->epoch_ctx->epoch_bank.cluster_version );

args->slot_ctx = fd_exec_slot_ctx_join( fd_exec_slot_ctx_new( slot_ctx_mem, valloc ) );
args->slot_ctx->epoch_ctx = args->epoch_ctx;
Expand Down Expand Up @@ -1332,7 +1333,7 @@ initial_setup( int argc, char ** argv, fd_ledger_args_t * args ) {
int use_funk_wksp = fd_env_strip_cmdline_int ( &argc, &argv, "--use-funk-wksp", NULL, 1 );
char const * rocksdb_list = fd_env_strip_cmdline_cstr ( &argc, &argv, "--rocksdb", NULL, NULL );
char const * rocksdb_list_starts = fd_env_strip_cmdline_cstr ( &argc, &argv, "--rocksdb-starts", NULL, NULL );
uint cluster_version = fd_env_strip_cmdline_uint ( &argc, &argv, "--cluster-version", NULL, 2000 );
uint cluster_version = fd_env_strip_cmdline_uint ( &argc, &argv, "--cluster-version", NULL, FD_DEFAULT_AGAVE_CLUSTER_VERSION );


#ifdef _ENABLE_LTHASH
Expand Down
6 changes: 6 additions & 0 deletions src/flamenco/fd_flamenco_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#define FD_FUNK_KEY_TYPE_ACC ((uchar)1)
#define FD_FUNK_KEY_TYPE_ELF_CACHE ((uchar)2)

/* CLUSTER_VERSION is the default value for the cluster version
in the epoch context. This value will foll forward to the
latest version.
*/
#define FD_DEFAULT_AGAVE_CLUSTER_VERSION (2000)

/* Forward declarations */

struct fd_exec_epoch_ctx;
Expand Down
2 changes: 1 addition & 1 deletion src/flamenco/features/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# python3.8 -m pip install fd58 --user
# PYTHON=python3.8 make

PYTHON?=python3
PYTHON?=python3.8
BLACK?=$(PYTHON) -m black

.PHONY: generate
Expand Down
6 changes: 4 additions & 2 deletions src/flamenco/features/fd_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ fd_features_disable_all( fd_features_t * f ) {
}

void
fd_features_enable_hardcoded( fd_features_t * f ) {
fd_features_enable_hardcoded( fd_features_t * f, uint cluster_version ) {
for( fd_feature_id_t const * id = fd_feature_iter_init();
!fd_feature_iter_done( id );
id = fd_feature_iter_next( id ) ) {
if( id->hardcoded ) {
if( id->hardcoded && id->hardcoded <= cluster_version ) {
fd_features_set( f, id, 0UL );
} else {
fd_features_set( f, id, FD_FEATURE_DISABLED );
}
}
}
4 changes: 2 additions & 2 deletions src/flamenco/features/fd_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct fd_feature_id {
ulong index; /* index of feature in fd_features_t */
fd_pubkey_t id; /* pubkey of feature */
char const * name; /* feature name cstr */
uint hardcoded : 1; /* is always enabled in Firedancer? */
uint hardcoded; /* hardcoded cluster version for feature */
};
typedef struct fd_feature_id fd_feature_id_t;

Expand All @@ -69,7 +69,7 @@ fd_features_enable_all( fd_features_t * );
of the Firedancer software and can't be disabled. */

void
fd_features_enable_hardcoded( fd_features_t * );
fd_features_enable_hardcoded( fd_features_t *, uint );

/* fd_feature_iter_{...} is an iterator-style API over all supported
features in this version of Firedancer. Usage:
Expand Down
254 changes: 128 additions & 126 deletions src/flamenco/features/fd_features_generated.c

Large diffs are not rendered by default.

252 changes: 126 additions & 126 deletions src/flamenco/features/feature_map.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/flamenco/features/gen_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def pubkey_to_c_array(pubkey):
file=body,
end="",
)
if x.get("hardcoded") == 1:
print(f",\n .hardcoded = 1", file=body, end="")
if x.get("hardcoded"):
print(f",\n .hardcoded = {x.get('hardcoded')}", file=body, end="")
print(" },\n", file=body)
print(
f""" {{ .index = ULONG_MAX }}
Expand Down
4 changes: 2 additions & 2 deletions src/flamenco/runtime/context/fd_exec_epoch_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ fd_exec_epoch_ctx_new( void * mem,
self->layout = *layout;

fd_features_disable_all( &self->features );
fd_features_enable_hardcoded( &self->features );
fd_features_enable_hardcoded( &self->features, self->epoch_bank.cluster_version );

fd_epoch_bank_new( &self->epoch_bank );

self->epoch_bank.cluster_version = 2000;
self->epoch_bank.cluster_version = FD_DEFAULT_AGAVE_CLUSTER_VERSION;

void * stake_votes_mem = (void *)( (ulong)mem + layout->stake_votes_off );
void * stake_delegations_mem = (void *)( (ulong)mem + layout->stake_delegations_off );
Expand Down
8 changes: 1 addition & 7 deletions src/flamenco/runtime/tests/run_ledger_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
--cluster-version)
-c|--cluster-version)
CLUSTER_VERSION="--cluster-version $2"
shift
shift
Expand Down Expand Up @@ -125,23 +125,17 @@ fi
echo_notice "Starting on-demand ingest and replay"
set -x
"$OBJDIR"/bin/fd_ledger \
--reset 1 \
--cmd replay \
--rocksdb dump/$LEDGER/rocksdb \
$RESTORE_ARCHIVE \
$TRASH_HASH \
$INDEX_MAX \
$END_SLOT \
$CLUSTER_VERSION \
--funk-only 1 \
--txn-max 100 \
$PAGES \
$FUNK_PAGES \
$SNAPSHOT \
--slot-history 5000 \
--copy-txn-status 0 \
--allocator wksp \
--on-demand-block-ingest 1 \
$TILE_CPUS >& $LOG

status=$?
Expand Down
Loading

0 comments on commit 2170356

Please sign in to comment.