Skip to content

Commit

Permalink
Compiles and ready to test
Browse files Browse the repository at this point in the history
  • Loading branch information
mjain-jump committed Nov 20, 2024
1 parent 3574ac5 commit b37a5a8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
16 changes: 16 additions & 0 deletions src/flamenco/features/fd_features_generated.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,18 @@ fd_feature_id_t const ids[] = {
.name = "migrate_feature_gate_program_to_core_bpf",
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },

{ .index = offsetof(fd_features_t, migrate_config_program_to_core_bpf)>>3,
.id = {"\x12\xa9\x4d\x90\xf1\x0d\xa9\xa9\x6c\x4d\xaf\xf9\x3b\x8e\xf5\xcb\x23\xef\xa4\xa9\x27\xee\x5c\x59\xc4\xef\x9c\x08\x45\x65\xdf\xac"},
/* 2Fr57nzzkLYXW695UdDxDeR5fhnZWSttZeZYemrnpGFV */
.name = "migrate_config_program_to_core_bpf",
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },

{ .index = offsetof(fd_features_t, migrate_address_lookup_table_program_to_core_bpf)>>3,
.id = {"\xa5\x84\xb6\xe5\x4b\xa8\x34\x24\x94\xbb\xa3\x5d\x43\x00\x19\x22\x7e\x11\x1e\xb6\xba\xc9\x95\x77\xf9\xe1\x83\xa5\x46\x5d\xff\x48"},
/* C97eKZygrkU4JxJsZdjgbUY7iQR7rKTr4NyDWo2E5pRm */
.name = "migrate_address_lookup_table_program_to_core_bpf",
.cleaned_up = {UINT_MAX, UINT_MAX, UINT_MAX} },

{ .index = ULONG_MAX }
};

Expand Down Expand Up @@ -1464,6 +1476,8 @@ fd_feature_id_query( ulong prefix ) {
case 0x2c38e34ff071060d: return &ids[ 203 ];
case 0x829062f252ef5ba8: return &ids[ 204 ];
case 0xf46b1f18665c4236: return &ids[ 205 ];
case 0xa9a90df1904da912: return &ids[ 206 ];
case 0x2434a84be5b684a5: return &ids[ 207 ];
default: break;
}

Expand Down Expand Up @@ -1678,5 +1692,7 @@ FD_STATIC_ASSERT( offsetof( fd_features_t, partitioned_epoch_rewards_superfeatur
FD_STATIC_ASSERT( offsetof( fd_features_t, enable_secp256r1_precompile )>>3==203UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, get_sysvar_syscall_enabled )>>3==204UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, migrate_feature_gate_program_to_core_bpf )>>3==205UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, migrate_config_program_to_core_bpf )>>3==206UL, layout );
FD_STATIC_ASSERT( offsetof( fd_features_t, migrate_address_lookup_table_program_to_core_bpf )>>3==207UL, layout );

FD_STATIC_ASSERT( sizeof( fd_features_t )>>3==FD_FEATURE_ID_CNT, layout );
4 changes: 3 additions & 1 deletion src/flamenco/features/fd_features_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/* FEATURE_ID_CNT is the number of features in ids */

#define FD_FEATURE_ID_CNT (206UL)
#define FD_FEATURE_ID_CNT (208UL)

union fd_features {

Expand Down Expand Up @@ -219,6 +219,8 @@ union fd_features {
/* 0x2c38e34ff071060d */ ulong enable_secp256r1_precompile;
/* 0x829062f252ef5ba8 */ ulong get_sysvar_syscall_enabled;
/* 0xf46b1f18665c4236 */ ulong migrate_feature_gate_program_to_core_bpf;
/* 0xa9a90df1904da912 */ ulong migrate_config_program_to_core_bpf;
/* 0x2434a84be5b684a5 */ ulong migrate_address_lookup_table_program_to_core_bpf;
};

};
4 changes: 3 additions & 1 deletion src/flamenco/features/feature_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,7 @@
{"name":"partitioned_epoch_rewards_superfeature","pubkey":"PERzQrt5gBD1XEe2c9XdFWqwgHY3mr7cYWbm5V772V8"},
{"name":"enable_secp256r1_precompile","pubkey":"sr11RdZWgbHTHxSroPALe6zgaT5A1K9LcE4nfsZS4gi"},
{"name":"get_sysvar_syscall_enabled","pubkey":"CLCoTADvV64PSrnR6QXty6Fwrt9Xc6EdxSJE4wLRePjq"},
{"name":"migrate_feature_gate_program_to_core_bpf","pubkey":"4eohviozzEeivk1y9UbrnekbAFMDQyJz5JjA9Y6gyvky"}
{"name":"migrate_feature_gate_program_to_core_bpf","pubkey":"4eohviozzEeivk1y9UbrnekbAFMDQyJz5JjA9Y6gyvky"},
{"name":"migrate_config_program_to_core_bpf","pubkey":"2Fr57nzzkLYXW695UdDxDeR5fhnZWSttZeZYemrnpGFV"},
{"name":"migrate_address_lookup_table_program_to_core_bpf","pubkey":"C97eKZygrkU4JxJsZdjgbUY7iQR7rKTr4NyDWo2E5pRm"}
]
18 changes: 12 additions & 6 deletions src/flamenco/runtime/fd_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -4259,7 +4259,9 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx,
- if NOT stateless: the existing account (for us its called `target_program_account`)
- target.program_data_address: `target_program_data_address` for us, derived below. */

/* https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/target_builtin.rs#L23-L50 */
/* These checks will fail if the core program has already been migrated to BPF, since the account will exist + the program owner
will no longer be the native loader.
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank/builtins/core_bpf_migration/target_builtin.rs#L23-L50 */
FD_BORROWED_ACCOUNT_DECL( target_program_account );
uchar program_exists = ( fd_acc_mgr_view( slot_ctx->acc_mgr, slot_ctx->funk_txn, builtin_program_id, target_program_account )==FD_ACC_MGR_SUCCESS );
if( !stateless ) {
Expand Down Expand Up @@ -4423,19 +4425,23 @@ fd_migrate_builtin_to_core_bpf( fd_exec_slot_ctx_t * slot_ctx,
static void
fd_apply_builtin_program_feature_transitions( fd_exec_slot_ctx_t * slot_ctx ) {
FD_SCRATCH_SCOPE_BEGIN {
/* TODO: For new BPF programs, check if the feature is active and add logic to migrate them
to core BPF */

/* TODO: Set the upgrade authority properly from the core bpf migration config
/* TODO: Set the upgrade authority properly from the core bpf migration config. Right now it's set to None.
Migrate any necessary stateless builtins to core BPF. So far, the only "stateless" builtin
is the Feature program.
is the Feature program. Beginning checks in the `migrate_builtin_to_core_bpf` function will
fail if the program has already been migrated to BPF.
https://github.com/anza-xyz/agave/blob/v2.1.0/runtime/src/bank.rs#L6776-L6793 */
if( FD_FEATURE_ACTIVE( slot_ctx, migrate_feature_gate_program_to_core_bpf ) ) {
fd_migrate_builtin_to_core_bpf( slot_ctx, NULL, &fd_solana_feature_program_id, &fd_solana_feature_program_buffer_address, 1 );
}

if( FD_FEATURE_ACTIVE( slot_ctx, migrate_config_program_to_core_bpf ) ) {
fd_migrate_builtin_to_core_bpf( slot_ctx, NULL, &fd_solana_config_program_id, &fd_solana_config_program_buffer_address, 0 );
}

if( FD_FEATURE_ACTIVE( slot_ctx, migrate_address_lookup_table_program_to_core_bpf ) ) {
fd_migrate_builtin_to_core_bpf( slot_ctx, NULL, &fd_solana_address_lookup_table_program_id, &fd_solana_address_lookup_table_program_buffer_address, 0 );
}
} FD_SCRATCH_SCOPE_END;
}

Expand Down

0 comments on commit b37a5a8

Please sign in to comment.