Skip to content

Commit a743b28

Browse files
replay, runtime: fix genesis booting
1 parent f6eb797 commit a743b28

File tree

5 files changed

+133
-97
lines changed

5 files changed

+133
-97
lines changed

src/discof/replay/fd_replay_tile.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ block_finalize_tiles_cb( void * para_arg_1,
505505
break;
506506
}
507507
}
508+
509+
508510
}
509511

510512

@@ -1015,8 +1017,13 @@ prepare_new_block_execution( fd_replay_tile_ctx_t * ctx,
10151017
static void
10161018
init_poh( fd_replay_tile_ctx_t * ctx ) {
10171019
FD_LOG_INFO(( "sending init msg" ));
1020+
1021+
FD_LOG_WARNING(( "hashes_per_tick: %lu, ticks_per_slot: %lu",
1022+
fd_bank_hashes_per_tick_get( ctx->slot_ctx->bank ),
1023+
fd_bank_ticks_per_slot_get( ctx->slot_ctx->bank ) ));
1024+
10181025
fd_replay_out_link_t * bank_out = &ctx->bank_out[ 0UL ];
1019-
fd_poh_init_msg_t * msg = fd_chunk_to_laddr( bank_out->mem, bank_out->chunk );
1026+
fd_poh_init_msg_t * msg = fd_chunk_to_laddr( bank_out->mem, bank_out->chunk ); // FIXME: msg is NULL
10201027
msg->hashcnt_per_tick = fd_bank_hashes_per_tick_get( ctx->slot_ctx->bank );
10211028
msg->ticks_per_slot = fd_bank_ticks_per_slot_get( ctx->slot_ctx->bank );
10221029
msg->tick_duration_ns = (ulong)(fd_bank_ns_per_slot_get( ctx->slot_ctx->bank )) / fd_bank_ticks_per_slot_get( ctx->slot_ctx->bank );

src/flamenco/runtime/fd_runtime.c

Lines changed: 115 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,11 +2920,15 @@ fd_runtime_init_bank_from_genesis( fd_exec_slot_ctx_t * slot_ctx,
29202920

29212921
/* Derive epoch stakes */
29222922

2923-
fd_vote_accounts_pair_t_mapnode_t * vacc_pool = NULL;
2924-
fd_vote_accounts_pair_t_mapnode_t * vacc_root = NULL;
2925-
FD_TEST( vacc_pool );
2923+
fd_stakes_global_t * stakes_global = fd_bank_stakes_locking_modify( slot_ctx->bank );
29262924

2927-
fd_delegation_pair_t_mapnode_t * sacc_pool = NULL;
2925+
uchar * vacc_pool_mem = (uchar *)fd_ulong_align_up( (ulong)stakes_global + sizeof(fd_stakes_global_t), fd_vote_accounts_pair_global_t_map_align() );
2926+
fd_vote_accounts_pair_global_t_mapnode_t * vacc_pool = fd_vote_accounts_pair_global_t_map_join( fd_vote_accounts_pair_global_t_map_new( vacc_pool_mem, 5000UL ) );
2927+
fd_vote_accounts_pair_global_t_mapnode_t * vacc_root = NULL;
2928+
2929+
2930+
uchar * sacc_pool_mem = (uchar *)fd_ulong_align_up( (ulong)vacc_pool + fd_vote_accounts_pair_global_t_map_footprint( 5000UL ), fd_delegation_pair_t_map_align() );
2931+
fd_delegation_pair_t_mapnode_t * sacc_pool = fd_delegation_pair_t_map_join( fd_delegation_pair_t_map_new( sacc_pool_mem, 5000UL ) );
29282932
fd_delegation_pair_t_mapnode_t * sacc_root = NULL;
29292933

29302934
fd_acc_lamports_t capitalization = 0UL;
@@ -2939,59 +2943,22 @@ fd_runtime_init_bank_from_genesis( fd_exec_slot_ctx_t * slot_ctx,
29392943

29402944
if( !memcmp(acc->account.owner.key, fd_solana_vote_program_id.key, sizeof(fd_pubkey_t)) ) {
29412945
/* Vote Program Account */
2942-
fd_vote_accounts_pair_t_mapnode_t *node = fd_vote_accounts_pair_t_map_acquire(vacc_pool);
2946+
fd_vote_accounts_pair_global_t_mapnode_t * node = fd_vote_accounts_pair_global_t_map_acquire(vacc_pool);
29432947
FD_TEST( node );
29442948

2945-
/* FIXME: Reimplement when we try to fix genesis. */
2946-
// fd_vote_block_timestamp_t last_timestamp = {0};
2947-
// fd_pubkey_t node_pubkey = {0};
2948-
// FD_SPAD_FRAME_BEGIN( runtime_spad ) {
2949-
// /* Deserialize content */
2950-
// fd_vote_state_versioned_t vs[1];
2951-
// fd_bincode_decode_ctx_t decode = {
2952-
// .data = acc->account.data,
2953-
// .dataend = acc->account.data + acc->account.data_len,
2954-
// .valloc = fd_spad_virtual( runtime_spad )
2955-
// };
2956-
// int decode_err = fd_vote_state_versioned_decode( vs, &decode );
2957-
// if( FD_UNLIKELY( decode_err!=FD_BINCODE_SUCCESS ) ) {
2958-
// FD_LOG_WARNING(( "fd_vote_state_versioned_decode failed (%d)", decode_err ));
2959-
// return;
2960-
// }
2961-
2962-
// switch( vs->discriminant )
2963-
// {
2964-
// case fd_vote_state_versioned_enum_current:
2965-
// last_timestamp = vs->inner.current.last_timestamp;
2966-
// node_pubkey = vs->inner.current.node_pubkey;
2967-
// break;
2968-
// case fd_vote_state_versioned_enum_v0_23_5:
2969-
// last_timestamp = vs->inner.v0_23_5.last_timestamp;
2970-
// node_pubkey = vs->inner.v0_23_5.node_pubkey;
2971-
// break;
2972-
// case fd_vote_state_versioned_enum_v1_14_11:
2973-
// last_timestamp = vs->inner.v1_14_11.last_timestamp;
2974-
// node_pubkey = vs->inner.v1_14_11.node_pubkey;
2975-
// break;
2976-
// default:
2977-
// __builtin_unreachable();
2978-
// }
2979-
2980-
// } FD_SPAD_FRAME_END;
2981-
2982-
// fd_memcpy(node->elem.key.key, acc->key.key, sizeof(fd_pubkey_t));
2983-
// node->elem.stake = acc->account.lamports;
2984-
// node->elem.value = (fd_solana_vote_account_t){
2985-
// .lamports = acc->account.lamports,
2986-
// .node_pubkey = node_pubkey,
2987-
// .last_timestamp_ts = last_timestamp.timestamp,
2988-
// .last_timestamp_slot = last_timestamp.slot,
2989-
// .owner = acc->account.owner,
2990-
// .executable = acc->account.executable,
2991-
// .rent_epoch = acc->account.rent_epoch
2992-
// };
2993-
2994-
fd_vote_accounts_pair_t_map_insert( vacc_pool, &vacc_root, node );
2949+
fd_memcpy(node->elem.key.key, acc->key.key, sizeof(fd_pubkey_t));
2950+
node->elem.stake = acc->account.lamports;
2951+
node->elem.value = (fd_solana_account_global_t){
2952+
.lamports = acc->account.lamports,
2953+
.data_len = acc->account.data_len,
2954+
.data_offset = 0UL, /* FIXME: remove this field from the cache altogether. */
2955+
.owner = acc->account.owner,
2956+
.executable = acc->account.executable,
2957+
.rent_epoch = acc->account.rent_epoch
2958+
};
2959+
fd_solana_account_data_update( &node->elem.value, acc->account.data );
2960+
2961+
fd_vote_accounts_pair_global_t_map_insert( vacc_pool, &vacc_root, node );
29952962

29962963
FD_LOG_INFO(( "Adding genesis vote account: key=%s stake=%lu",
29972964
FD_BASE58_ENC_32_ALLOCA( node->elem.key.key ),
@@ -3062,51 +3029,104 @@ fd_runtime_init_bank_from_genesis( fd_exec_slot_ctx_t * slot_ctx,
30623029
// slot_ctx->slot_bank.epoch_stakes.vote_accounts_pool = fd_vote_accounts_pair_t_map_join( fd_vote_accounts_pair_t_map_new( pool_mem, FD_HASH_FOOTPRINT * 400 ) );
30633030
// slot_ctx->slot_bank.epoch_stakes.vote_accounts_root = NULL;
30643031

3065-
// fd_vote_accounts_pair_t_mapnode_t * next_pool = fd_exec_epoch_ctx_next_epoch_stakes_join( slot_ctx->epoch_ctx );
3066-
// fd_vote_accounts_pair_t_mapnode_t * next_root = NULL;
30673032

3068-
// for( fd_vote_accounts_pair_t_mapnode_t *n = fd_vote_accounts_pair_t_map_minimum( vacc_pool, vacc_root );
3069-
// n;
3070-
// n = fd_vote_accounts_pair_t_map_successor( vacc_pool, n )) {
3071-
// fd_vote_accounts_pair_t_mapnode_t * e = fd_vote_accounts_pair_t_map_acquire( slot_ctx->slot_bank.epoch_stakes.vote_accounts_pool );
3072-
// e->elem = n->elem;
3073-
// fd_vote_accounts_pair_t_map_insert( slot_ctx->slot_bank.epoch_stakes.vote_accounts_pool, &slot_ctx->slot_bank.epoch_stakes.vote_accounts_root, e );
3033+
fd_vote_accounts_global_t * epoch_stakes = fd_bank_epoch_stakes_locking_modify( slot_ctx->bank );
3034+
uchar * pool_mem = (uchar *)fd_ulong_align_up( (ulong)epoch_stakes + sizeof(fd_vote_accounts_global_t), fd_vote_accounts_pair_t_map_align() );
3035+
fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_pool = fd_vote_accounts_pair_global_t_map_join( fd_vote_accounts_pair_global_t_map_new( pool_mem, 50000UL ) );
3036+
fd_vote_accounts_pair_global_t_mapnode_t * vote_accounts_root = NULL;
30743037

3075-
// fd_vote_accounts_pair_t_mapnode_t * next_e = fd_vote_accounts_pair_t_map_acquire( next_pool );
3076-
// next_e->elem = n->elem;
3077-
// fd_vote_accounts_pair_t_map_insert( next_pool, &next_root, next_e );
3078-
// }
3038+
uchar * epoch_stakes_vote_acc_region_curr = (uchar *)fd_ulong_align_up( (ulong)vote_accounts_pool + fd_vote_accounts_pair_global_t_map_footprint( 50000UL ), 8UL );
3039+
3040+
fd_vote_accounts_global_t * next_epoch_stakes = fd_bank_next_epoch_stakes_locking_modify( slot_ctx->bank );
3041+
uchar * next_pool_mem = (uchar *)fd_ulong_align_up( (ulong)next_epoch_stakes + sizeof(fd_vote_accounts_global_t), fd_vote_accounts_pair_t_map_align() );
3042+
fd_vote_accounts_pair_global_t_mapnode_t * next_pool = fd_vote_accounts_pair_global_t_map_join( fd_vote_accounts_pair_global_t_map_new( next_pool_mem, 50000UL ) );
3043+
fd_vote_accounts_pair_global_t_mapnode_t * next_root = NULL;
3044+
3045+
uchar * next_epoch_stakes_acc_region_curr = (uchar *)fd_ulong_align_up( (ulong)next_pool + fd_vote_accounts_pair_global_t_map_footprint( 50000UL ), 8UL );
3046+
3047+
for( ulong i=0UL; i<genesis_block->accounts_len; i++ ) {
3048+
fd_pubkey_account_pair_t const * acc = &genesis_block->accounts[i];
3049+
3050+
if( !memcmp( acc->account.owner.key, fd_solana_vote_program_id.key, sizeof(fd_pubkey_t) ) ) {
3051+
3052+
/* Insert into the epoch_stakes vote accounts map */
3053+
fd_vote_accounts_pair_global_t_mapnode_t * e = fd_vote_accounts_pair_global_t_map_acquire( vote_accounts_pool );
3054+
FD_TEST( e );
3055+
e->elem.key = acc->key;
3056+
e->elem.stake = acc->account.lamports;
3057+
e->elem.value = (fd_solana_account_global_t){
3058+
.lamports = acc->account.lamports,
3059+
.data_len = acc->account.data_len,
3060+
.data_offset = 0UL, /* FIXME: remove this field from the cache altogether. */
3061+
.owner = acc->account.owner,
3062+
.executable = acc->account.executable,
3063+
.rent_epoch = acc->account.rent_epoch
3064+
};
3065+
3066+
memcpy( epoch_stakes_vote_acc_region_curr, acc->account.data, acc->account.data_len );
3067+
e->elem.value.data_offset = (ulong)(epoch_stakes_vote_acc_region_curr - (uchar *)&e->elem.value);
3068+
epoch_stakes_vote_acc_region_curr += acc->account.data_len;
3069+
3070+
fd_vote_accounts_pair_global_t_map_insert( vote_accounts_pool, &vote_accounts_root, e );
3071+
3072+
/* Insert into the next_epoch_stakes vote accounts map */
3073+
/* FIXME: is this correct? */
3074+
fd_vote_accounts_pair_global_t_mapnode_t * next_e = fd_vote_accounts_pair_global_t_map_acquire( next_pool );
3075+
FD_TEST( next_e );
3076+
next_e->elem.key = acc->key;
3077+
next_e->elem.stake = acc->account.lamports;
3078+
next_e->elem.value = (fd_solana_account_global_t){
3079+
.lamports = acc->account.lamports,
3080+
.data_len = acc->account.data_len,
3081+
.data_offset = 0UL, /* FIXME: remove this field from the cache altogether. */
3082+
.owner = acc->account.owner,
3083+
.executable = acc->account.executable,
3084+
.rent_epoch = acc->account.rent_epoch
3085+
};
3086+
3087+
memcpy( next_epoch_stakes_acc_region_curr, acc->account.data, acc->account.data_len );
3088+
next_e->elem.value.data_offset = (ulong)(next_epoch_stakes_acc_region_curr - (uchar *)&next_e->elem.value);
3089+
next_epoch_stakes_acc_region_curr += acc->account.data_len;
3090+
3091+
fd_vote_accounts_pair_global_t_map_insert( next_pool, &next_root, next_e );
3092+
}
3093+
3094+
}
30793095

30803096
for( fd_delegation_pair_t_mapnode_t *n = fd_delegation_pair_t_map_minimum( sacc_pool, sacc_root );
30813097
n;
30823098
n = fd_delegation_pair_t_map_successor( sacc_pool, n )) {
3083-
fd_vote_accounts_pair_t_mapnode_t query_voter = {0};
3099+
fd_vote_accounts_pair_global_t_mapnode_t query_voter = {0};
30843100
query_voter.elem.key = n->elem.delegation.voter_pubkey;
30853101

3086-
fd_vote_accounts_pair_t_mapnode_t * voter = fd_vote_accounts_pair_t_map_find( vacc_pool, vacc_root, &query_voter );
3102+
fd_vote_accounts_pair_global_t_mapnode_t * voter = fd_vote_accounts_pair_global_t_map_find( vacc_pool, vacc_root, &query_voter );
30873103

30883104
if( !!voter ) {
30893105
voter->elem.stake = fd_ulong_sat_add( voter->elem.stake, n->elem.delegation.stake );
30903106
}
30913107
}
30923108

3093-
// epoch_bank->next_epoch_stakes = (fd_vote_accounts_t){
3094-
// .vote_accounts_pool = next_pool,
3095-
// .vote_accounts_root = next_root,
3096-
// };
3109+
fd_vote_accounts_vote_accounts_pool_update( epoch_stakes, vote_accounts_pool );
3110+
fd_vote_accounts_vote_accounts_root_update( epoch_stakes, vote_accounts_root );
3111+
3112+
3113+
fd_vote_accounts_vote_accounts_pool_update( next_epoch_stakes, next_pool );
3114+
fd_vote_accounts_vote_accounts_root_update( next_epoch_stakes, next_root );
3115+
3116+
fd_bank_epoch_stakes_end_locking_modify( slot_ctx->bank );
3117+
3118+
fd_bank_next_epoch_stakes_end_locking_modify( slot_ctx->bank );
3119+
3120+
3121+
3122+
stakes_global->epoch = 0UL;
3123+
stakes_global->unused = 0UL;
30973124

3098-
/* Initializes the stakes cache in the Bank structure. */
3099-
// epoch_bank->stakes = (fd_stakes_t){
3100-
// .stake_delegations_pool = sacc_pool,
3101-
// .stake_delegations_root = sacc_root,
3102-
// .epoch = 0UL,
3103-
// .unused = 0UL,
3104-
// .vote_accounts = (fd_vote_accounts_t){
3105-
// .vote_accounts_pool = vacc_pool,
3106-
// .vote_accounts_root = vacc_root
3107-
// },
3108-
// .stake_history = {0}
3109-
// };
3125+
fd_vote_accounts_vote_accounts_pool_update( &stakes_global->vote_accounts, vacc_pool );
3126+
fd_vote_accounts_vote_accounts_root_update( &stakes_global->vote_accounts, vacc_root );
3127+
fd_stakes_stake_delegations_pool_update( stakes_global, sacc_pool );
3128+
fd_stakes_stake_delegations_root_update( stakes_global, sacc_root );
3129+
fd_bank_stakes_end_locking_modify( slot_ctx->bank );
31103130

31113131
fd_bank_capitalization_set( slot_ctx->bank, capitalization );
31123132

@@ -3144,6 +3164,8 @@ fd_runtime_process_genesis_block( fd_exec_slot_ctx_t * slot_ctx,
31443164

31453165
fd_bank_total_compute_units_used_set( slot_ctx->bank, 0UL );
31463166

3167+
fd_runtime_init_program( slot_ctx, runtime_spad );
3168+
31473169
fd_sysvar_slot_history_update( slot_ctx, runtime_spad );
31483170

31493171
fd_runtime_update_leaders( slot_ctx->bank, 0, runtime_spad );
@@ -3220,13 +3242,19 @@ fd_runtime_read_genesis( fd_exec_slot_ctx_t * slot_ctx,
32203242
fd_memcpy( genesis_hash_bm, buf, sizeof(fd_hash_t) );
32213243

32223244
if( !is_snapshot ) {
3245+
/* Create a new Funk transaction for slot 0 */
3246+
fd_funk_txn_start_write( slot_ctx->funk );
3247+
fd_funk_txn_xid_t xid = { 0 };
3248+
xid.ul[1] = 0UL;
3249+
xid.ul[0] = 0UL;
3250+
slot_ctx->funk_txn = fd_funk_txn_prepare( slot_ctx->funk, NULL, &xid, 1 );
3251+
fd_funk_txn_end_write( slot_ctx->funk );
3252+
32233253
fd_runtime_init_bank_from_genesis( slot_ctx,
32243254
genesis_block,
32253255
&genesis_hash,
32263256
runtime_spad );
32273257

3228-
fd_runtime_init_program( slot_ctx, runtime_spad );
3229-
32303258
FD_LOG_DEBUG(( "start genesis accounts - count: %lu", genesis_block->accounts_len ));
32313259

32323260
for( ulong i=0; i<genesis_block->accounts_len; i++ ) {

src/flamenco/runtime/sysvar/fd_sysvar_slot_history.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fd_sysvar_slot_history_set( fd_slot_history_global_t * history,
2626
ulong blocks_len = history->bits_bitvec_len;
2727

2828
// Skipped slots, delete them from history
29+
if( FD_UNLIKELY( blocks_len == 0 ) ) return;
2930
for( ulong j = history->next_slot; j < i; j++ ) {
3031
ulong block_idx = (j / bits_per_block) % (blocks_len);
3132
blocks[ block_idx ] &= ~( 1UL << ( j % bits_per_block ) );
@@ -52,6 +53,7 @@ fd_sysvar_slot_history_write_history( fd_exec_slot_ctx_t * slot_ctx,
5253
}
5354

5455
/* https://github.com/solana-labs/solana/blob/8f2c8b8388a495d2728909e30460aa40dcc5d733/sdk/program/src/slot_history.rs#L16 */
56+
5557
void
5658
fd_sysvar_slot_history_init( fd_exec_slot_ctx_t * slot_ctx, fd_spad_t * runtime_spad ) {
5759
FD_SPAD_FRAME_BEGIN( runtime_spad ) {
@@ -97,12 +99,12 @@ fd_sysvar_slot_history_update( fd_exec_slot_ctx_t * slot_ctx, fd_spad_t * runtim
9799
ulong total_sz = 0UL;
98100
err = fd_slot_history_decode_footprint( &ctx, &total_sz );
99101
if( FD_UNLIKELY( err ) ) {
100-
FD_LOG_ERR(( "fd_slot_history_decode_footprint failed" ));
102+
FD_LOG_CRIT(( "fd_slot_history_decode_footprint failed %d", err ));
101103
}
102104

103105
uchar * mem = fd_spad_alloc( runtime_spad, fd_slot_history_align(), total_sz );
104106
if( FD_UNLIKELY( !mem ) ) {
105-
FD_LOG_ERR(( "Unable to allocate memory for slot history" ));
107+
FD_LOG_CRIT(( "Unable to allocate memory for slot history" ));
106108
}
107109

108110
fd_slot_history_global_t * history = fd_slot_history_decode_global( mem, &ctx );

src/flamenco/types/fd_types.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9015,7 +9015,7 @@ static int fd_slot_history_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx
90159015
ulong len;
90169016
err = fd_bincode_uint64_decode( &len, ctx );
90179017
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;
9018-
if( len > inner_len * sizeof(ulong) * 8UL ) return FD_BINCODE_ERR_ENCODING;
9018+
if( o && len > inner_len * sizeof(ulong) * 8UL ) return FD_BINCODE_ERR_ENCODING;
90199019
}
90209020
err = fd_bincode_uint64_decode_footprint( ctx );
90219021
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;
@@ -19476,7 +19476,7 @@ static int fd_gossip_slots_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx
1947619476
ulong len;
1947719477
err = fd_bincode_uint64_decode( &len, ctx );
1947819478
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;
19479-
if( len > inner_len * sizeof(uchar) * 8UL ) return FD_BINCODE_ERR_ENCODING;
19479+
if( o && len > inner_len * sizeof(uchar) * 8UL ) return FD_BINCODE_ERR_ENCODING;
1948019480
}
1948119481
return 0;
1948219482
}
@@ -20909,7 +20909,7 @@ static int fd_restart_raw_offsets_decode_footprint_inner( fd_bincode_decode_ctx_
2090920909
ulong len;
2091020910
err = fd_bincode_uint64_decode( &len, ctx );
2091120911
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;
20912-
if( len > inner_len * sizeof(uchar) * 8UL ) return FD_BINCODE_ERR_ENCODING;
20912+
if( o && len > inner_len * sizeof(uchar) * 8UL ) return FD_BINCODE_ERR_ENCODING;
2091320913
}
2091420914
return 0;
2091520915
}
@@ -21829,7 +21829,7 @@ static int fd_crds_bloom_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx,
2182921829
ulong len;
2183021830
err = fd_bincode_uint64_decode( &len, ctx );
2183121831
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;
21832-
if( len > inner_len * sizeof(ulong) * 8UL ) return FD_BINCODE_ERR_ENCODING;
21832+
if( o && len > inner_len * sizeof(ulong) * 8UL ) return FD_BINCODE_ERR_ENCODING;
2183321833
}
2183421834
err = fd_bincode_uint64_decode_footprint( ctx );
2183521835
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;

src/flamenco/types/gen_stubs.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,7 @@ def emitWalk(self, inner, indent=''):
780780
print(f'{indent} fun( w, NULL, "{self.name}", FD_FLAMENCO_TYPE_ARR_END, "array", level--, 0 );', file=body)
781781
print(f'{indent} }}', file=body)
782782

783-
# A BitVector can be modeled as an Option<Vector<some type>>
784-
# See https://github.com/tov/bv-rs/blob/master/src/bit_vec/inner.rs#L8
783+
# A BitVector is a [Option<Vector<some type>>, len]
785784
# TODO: it would be ideal to use an OptionMember that contains a VectorMember,
786785
# but we can't do this yet. Hence, BitVectorMember re-implements the
787786
# OptionMember implementation with the element set to VectorMember
@@ -832,7 +831,7 @@ def emitDecodeFootprint(self):
832831
print(' ulong len;', file=body)
833832
print(' err = fd_bincode_uint64_decode( &len, ctx );', file=body)
834833
print(' if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;', file=body)
835-
print(f' if( len > inner_len * sizeof({self.vector_element}) * 8UL ) return FD_BINCODE_ERR_ENCODING;', file=body)
834+
print(f' if( o && len > inner_len * sizeof({self.vector_element}) * 8UL ) return FD_BINCODE_ERR_ENCODING;', file=body)
836835
print(' }', file=body)
837836

838837
def emitDecodeInner(self):

0 commit comments

Comments
 (0)