@@ -3685,85 +3685,91 @@ fd_runtime_read_genesis( fd_exec_slot_ctx_t * slot_ctx,
3685
3685
FD_LOG_ERR (("cannot open %s : %s" , genesis_filepath , strerror (errno )));
3686
3686
}
3687
3687
3688
- fd_genesis_solana_t genesis_block = {0 };
3689
- fd_hash_t genesis_hash ;
3690
-
3691
3688
fd_epoch_bank_t * epoch_bank = fd_exec_epoch_ctx_epoch_bank ( slot_ctx -> epoch_ctx );
3692
3689
3693
3690
FD_SPAD_FRAME_BEGIN ( runtime_spad ) {
3691
+ fd_genesis_solana_t * genesis_block ;
3692
+ fd_hash_t genesis_hash ;
3694
3693
uchar * buf = fd_spad_alloc ( runtime_spad , alignof(ulong ), (ulong )sbuf .st_size );
3695
3694
ssize_t n = read ( fd , buf , (ulong )sbuf .st_size );
3696
3695
close ( fd );
3697
3696
3698
- /* FIXME: This needs to be patched to support new decoder properly */
3699
3697
fd_bincode_decode_ctx_t decode_ctx = {
3700
3698
.data = buf ,
3701
3699
.dataend = buf + n ,
3702
3700
};
3703
3701
3704
- fd_genesis_solana_decode ( & genesis_block , & decode_ctx );
3702
+ ulong decoded_sz = 0UL ;
3703
+ int err = fd_genesis_solana_decode_footprint ( & decode_ctx , & decoded_sz );
3704
+ if ( FD_UNLIKELY ( err != FD_BINCODE_SUCCESS ) ) {
3705
+ FD_LOG_ERR (( "fd_genesis_solana_decode_footprint failed (%d)" , err ));
3706
+ }
3707
+
3708
+ uchar * mem = fd_spad_alloc ( runtime_spad , fd_genesis_solana_align (), decoded_sz );
3709
+ genesis_block = fd_genesis_solana_decode ( mem , & decode_ctx );
3705
3710
3706
3711
// The hash is generated from the raw data... don't mess with this..
3707
3712
fd_sha256_hash ( buf , (ulong )n , genesis_hash .uc );
3708
3713
3709
- } FD_SPAD_FRAME_END ;
3710
-
3711
- fd_memcpy ( epoch_bank -> genesis_hash .uc , genesis_hash .uc , sizeof (fd_hash_t ) );
3712
- epoch_bank -> cluster_type = genesis_block .cluster_type ;
3714
+ fd_memcpy ( epoch_bank -> genesis_hash .uc , genesis_hash .uc , sizeof (fd_hash_t ) );
3715
+ epoch_bank -> cluster_type = genesis_block -> cluster_type ;
3713
3716
3714
- if ( !is_snapshot ) {
3715
- fd_runtime_init_bank_from_genesis ( slot_ctx ,
3716
- & genesis_block ,
3717
- & genesis_hash ,
3718
- runtime_spad );
3717
+ if ( !is_snapshot ) {
3718
+ fd_runtime_init_bank_from_genesis ( slot_ctx ,
3719
+ genesis_block ,
3720
+ & genesis_hash ,
3721
+ runtime_spad );
3719
3722
3720
- fd_runtime_init_program ( slot_ctx , runtime_spad );
3723
+ fd_runtime_init_program ( slot_ctx , runtime_spad );
3721
3724
3722
- FD_LOG_DEBUG (( "start genesis accounts - count: %lu" , genesis_block . accounts_len ));
3725
+ FD_LOG_DEBUG (( "start genesis accounts - count: %lu" , genesis_block -> accounts_len ));
3723
3726
3724
- for ( ulong i = 0 ; i < genesis_block . accounts_len ; i ++ ) {
3725
- fd_pubkey_account_pair_t * a = & genesis_block . accounts [i ];
3727
+ for ( ulong i = 0 ; i < genesis_block -> accounts_len ; i ++ ) {
3728
+ fd_pubkey_account_pair_t * a = & genesis_block -> accounts [i ];
3726
3729
3727
- FD_TXN_ACCOUNT_DECL ( rec );
3730
+ FD_TXN_ACCOUNT_DECL ( rec );
3728
3731
3729
- int err = fd_txn_account_init_from_funk_mutable ( rec ,
3730
- & a -> key ,
3731
- slot_ctx -> funk ,
3732
- slot_ctx -> funk_txn ,
3733
- 1 , /* do_create */
3734
- a -> account .data_len );
3732
+ int err = fd_txn_account_init_from_funk_mutable ( rec ,
3733
+ & a -> key ,
3734
+ slot_ctx -> funk ,
3735
+ slot_ctx -> funk_txn ,
3736
+ 1 , /* do_create */
3737
+ a -> account .data_len );
3735
3738
3736
- if ( FD_UNLIKELY ( err ) ) {
3737
- FD_LOG_ERR (( "fd_txn_account_init_from_funk_mutable failed (%d)" , err ));
3738
- }
3739
+ if ( FD_UNLIKELY ( err ) ) {
3740
+ FD_LOG_ERR (( "fd_txn_account_init_from_funk_mutable failed (%d)" , err ));
3741
+ }
3739
3742
3740
- rec -> vt -> set_data ( rec , a -> account .data , a -> account .data_len );
3741
- rec -> vt -> set_lamports ( rec , a -> account .lamports );
3742
- rec -> vt -> set_rent_epoch ( rec , a -> account .rent_epoch );
3743
- rec -> vt -> set_executable ( rec , a -> account .executable );
3744
- rec -> vt -> set_owner ( rec , & a -> account .owner );
3743
+ rec -> vt -> set_data ( rec , a -> account .data , a -> account .data_len );
3744
+ rec -> vt -> set_lamports ( rec , a -> account .lamports );
3745
+ rec -> vt -> set_rent_epoch ( rec , a -> account .rent_epoch );
3746
+ rec -> vt -> set_executable ( rec , a -> account .executable );
3747
+ rec -> vt -> set_owner ( rec , & a -> account .owner );
3745
3748
3746
- fd_txn_account_mutable_fini ( rec , slot_ctx -> funk , slot_ctx -> funk_txn );
3747
- }
3749
+ fd_txn_account_mutable_fini ( rec , slot_ctx -> funk , slot_ctx -> funk_txn );
3750
+ }
3748
3751
3749
- FD_LOG_DEBUG (( "end genesis accounts" ));
3752
+ FD_LOG_DEBUG (( "end genesis accounts" ));
3750
3753
3751
- FD_LOG_DEBUG (( "native instruction processors - count: %lu" , genesis_block . native_instruction_processors_len ));
3754
+ FD_LOG_DEBUG (( "native instruction processors - count: %lu" , genesis_block -> native_instruction_processors_len ));
3752
3755
3753
- for ( ulong i = 0UL ; i < genesis_block . native_instruction_processors_len ; i ++ ) {
3754
- fd_string_pubkey_pair_t * a = & genesis_block . native_instruction_processors [i ];
3755
- fd_write_builtin_account ( slot_ctx , a -> pubkey , (const char * ) a -> string , a -> string_len );
3756
- }
3756
+ for ( ulong i = 0UL ; i < genesis_block -> native_instruction_processors_len ; i ++ ) {
3757
+ fd_string_pubkey_pair_t * a = & genesis_block -> native_instruction_processors [i ];
3758
+ fd_write_builtin_account ( slot_ctx , a -> pubkey , (const char * ) a -> string , a -> string_len );
3759
+ }
3757
3760
3758
- fd_features_restore ( slot_ctx , runtime_spad );
3761
+ fd_features_restore ( slot_ctx , runtime_spad );
3759
3762
3760
- slot_ctx -> slot_bank .slot = 0UL ;
3763
+ slot_ctx -> slot_bank .slot = 0UL ;
3761
3764
3762
- int err = fd_runtime_process_genesis_block ( slot_ctx , capture_ctx , tpool , runtime_spad );
3763
- if ( FD_UNLIKELY ( err ) ) {
3764
- FD_LOG_ERR (( "Genesis slot 0 execute failed with error %d" , err ));
3765
+ int err = fd_runtime_process_genesis_block ( slot_ctx , capture_ctx , tpool , runtime_spad );
3766
+ if ( FD_UNLIKELY ( err ) ) {
3767
+ FD_LOG_ERR (( "Genesis slot 0 execute failed with error %d" , err ));
3768
+ }
3765
3769
}
3766
- }
3770
+
3771
+ fd_genesis_solana_destroy ( genesis_block );
3772
+ } FD_SPAD_FRAME_END ;
3767
3773
3768
3774
slot_ctx -> slot_bank .stake_account_keys .account_keys_root = NULL ;
3769
3775
uchar * pool_mem = fd_spad_alloc ( runtime_spad , fd_account_keys_pair_t_map_align (), fd_account_keys_pair_t_map_footprint ( 100000UL ) );
@@ -3773,7 +3779,6 @@ fd_runtime_read_genesis( fd_exec_slot_ctx_t * slot_ctx,
3773
3779
pool_mem = fd_spad_alloc ( runtime_spad , fd_account_keys_pair_t_map_align (), fd_account_keys_pair_t_map_footprint ( 100000UL ) );
3774
3780
slot_ctx -> slot_bank .vote_account_keys .account_keys_pool = fd_account_keys_pair_t_map_join ( fd_account_keys_pair_t_map_new ( pool_mem , 100000UL ) );
3775
3781
3776
- fd_genesis_solana_destroy ( & genesis_block );
3777
3782
}
3778
3783
3779
3784
/******************************************************************************/
0 commit comments