Skip to content

Commit a7996e6

Browse files
committed
flameco,types: Fix invariant check for BitVectors
1 parent e3d24f9 commit a7996e6

File tree

7 files changed

+212
-47
lines changed

7 files changed

+212
-47
lines changed

src/flamenco/runtime/sysvar/fd_sysvar_slot_history.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fd_sysvar_slot_history_init( fd_exec_slot_ctx_t * slot_ctx, fd_spad_t * runtime_
7171
history->bits_bitvec_offset = (ulong)((uchar*)blocks - (uchar*)history);
7272
history->bits_len = slot_history_max_entries;
7373
history->bits_bitvec_len = blocks_len;
74+
history->has_bits = 1;
7475
memset( blocks, 0, sizeof(ulong) * blocks_len );
7576

7677
/* TODO: handle slot != 0 init case */

src/flamenco/types/fd_types.c

Lines changed: 4 additions & 7 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( o && len > inner_len * sizeof(ulong) * 8UL ) return FD_BINCODE_ERR_ENCODING;
9018+
if( 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( o && len > inner_len * sizeof(uchar) * 8UL ) return FD_BINCODE_ERR_ENCODING;
19479+
if( len > inner_len * sizeof(uchar) * 8UL ) return FD_BINCODE_ERR_ENCODING;
1948019480
}
1948119481
return 0;
1948219482
}
@@ -20270,9 +20270,6 @@ int fd_gossip_duplicate_shred_encode( fd_gossip_duplicate_shred_t const * self,
2027020270
static int fd_gossip_duplicate_shred_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx, ulong * total_sz ) {
2027120271
if( ctx->data>=ctx->dataend ) { return FD_BINCODE_ERR_OVERFLOW; };
2027220272
int err = 0;
20273-
err = fd_gossip_duplicate_shred_validator( ctx );
20274-
if( FD_UNLIKELY( err != FD_BINCODE_SUCCESS ) )
20275-
return err;
2027620273
err = fd_bincode_uint16_decode_footprint( ctx );
2027720274
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;
2027820275
err = fd_pubkey_decode_footprint_inner( ctx, total_sz );
@@ -20909,7 +20906,7 @@ static int fd_restart_raw_offsets_decode_footprint_inner( fd_bincode_decode_ctx_
2090920906
ulong len;
2091020907
err = fd_bincode_uint64_decode( &len, ctx );
2091120908
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;
20912-
if( o && len > inner_len * sizeof(uchar) * 8UL ) return FD_BINCODE_ERR_ENCODING;
20909+
if( len > inner_len * sizeof(uchar) * 8UL ) return FD_BINCODE_ERR_ENCODING;
2091320910
}
2091420911
return 0;
2091520912
}
@@ -21829,7 +21826,7 @@ static int fd_crds_bloom_decode_footprint_inner( fd_bincode_decode_ctx_t * ctx,
2182921826
ulong len;
2183021827
err = fd_bincode_uint64_decode( &len, ctx );
2183121828
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;
21832-
if( o && len > inner_len * sizeof(ulong) * 8UL ) return FD_BINCODE_ERR_ENCODING;
21829+
if( len > inner_len * sizeof(ulong) * 8UL ) return FD_BINCODE_ERR_ENCODING;
2183321830
}
2183421831
err = fd_bincode_uint64_decode_footprint( ctx );
2183521832
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;

src/flamenco/types/fd_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,6 +3041,7 @@ struct fd_gossip_node_instance {
30413041
typedef struct fd_gossip_node_instance fd_gossip_node_instance_t;
30423042
#define FD_GOSSIP_NODE_INSTANCE_ALIGN alignof(fd_gossip_node_instance_t)
30433043

3044+
/* https://github.com/firedancer-io/agave/blob/540d5bc56cd44e3cc61b179bd52e9a782a2c99e4/gossip/src/duplicate_shred.rs#L25 */
30443045
/* Encoded Size: Dynamic */
30453046
struct fd_gossip_duplicate_shred {
30463047
ushort duplicate_shred_index;
@@ -3077,6 +3078,7 @@ struct fd_gossip_socket_entry {
30773078
typedef struct fd_gossip_socket_entry fd_gossip_socket_entry_t;
30783079
#define FD_GOSSIP_SOCKET_ENTRY_ALIGN alignof(fd_gossip_socket_entry_t)
30793080

3081+
/* https://github.com/firedancer-io/agave/blob/540d5bc56cd44e3cc61b179bd52e9a782a2c99e4/gossip/src/contact_info.rs#L85 */
30803082
/* Encoded Size: Dynamic */
30813083
struct fd_gossip_contact_info_v2 {
30823084
fd_pubkey_t from;

src/flamenco/types/fd_types.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,6 @@
20472047
{
20482048
"name": "gossip_duplicate_shred",
20492049
"type": "struct",
2050-
"validator": "fd_gossip_duplicate_shred_validator",
20512050
"fields": [
20522051
{ "name": "duplicate_shred_index", "type": "ushort" },
20532052
{ "name": "from", "type": "pubkey" },

src/flamenco/types/fd_types_custom.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,6 @@ fd_rust_duration_footprint_validator ( fd_bincode_decode_ctx_t * ctx ) {
293293
return FD_BINCODE_SUCCESS;
294294
}
295295

296-
int
297-
fd_gossip_duplicate_shred_validator ( fd_bincode_decode_ctx_t * ctx ) {
298-
#if 1
299-
(void) ctx;
300-
#else
301-
fd_gossip_duplicate_shred_t *d = (fd_gossip_duplicate_shred_t *) ctx->data;
302-
if( FD_UNLIKELY( (d->_unused_shred_type != 0x5a) || (d->_unused_shred_type != 0xa5) ) )
303-
return FD_BINCODE_ERR_ENCODING;
304-
#endif
305-
return FD_BINCODE_SUCCESS;
306-
}
307-
308296
void fd_vote_accounts_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx ) {
309297
fd_vote_accounts_t * self = (fd_vote_accounts_t *)struct_mem;
310298
ulong vote_accounts_len;

src/flamenco/types/fd_types_custom.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ fd_rust_duration_normalize ( fd_rust_duration_t * );
197197
int
198198
fd_rust_duration_footprint_validator ( fd_bincode_decode_ctx_t * ctx );
199199

200-
int
201-
fd_gossip_duplicate_shred_validator ( fd_bincode_decode_ctx_t * ctx );
202-
203200
void fd_vote_accounts_decode_inner( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx );
204201
void fd_vote_accounts_decode_inner_global( void * struct_mem, void * * alloc_mem, fd_bincode_decode_ctx_t * ctx );
205202

0 commit comments

Comments
 (0)