-
Notifications
You must be signed in to change notification settings - Fork 243
flamenco: Add BitVector type #4942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
301c20b
to
59497c3
Compare
@cali-jumptrading I think it might be easier to make the bitvec type an opaque type. Then implement it in fd_types_custom. That way, you can just write the bitvec-specific logic in C, and can avoid the gen_stubs.py script. (see fd_flamenco_txn for an example) |
59497c3
to
0811ced
Compare
I would have to have at least two different definitions of the bitvec type though... because we currently use a u8 bitvec and a u64 bitvec. Unless I used a macro to define the bitvec type as an opaque type... |
From a consistency standpoint, it makes more sense to implement the |
c9d4f02
to
83ff6d2
Compare
510f4dc
to
e0365d4
Compare
print(' ulong len;', file=body) | ||
print(' err = fd_bincode_uint64_decode( &len, ctx );', file=body) | ||
print(' if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;', file=body) | ||
print(f' if( len > inner_len * sizeof({self.vector_element}) * 8UL ) return FD_BINCODE_ERR_ENCODING;', file=body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the len < inner_len
case impossible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len can be less than inner_len * sizeof(element) * 8, we actually have a testcase called gossip_pull_req.yml
that has this case. I think len might refer to the valid bits len?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i see
inner->blocks_len = blocks_len; | ||
inner->blocks_offset = (ulong)((uchar*)blocks - (uchar*)inner); | ||
history->next_slot = slot_ctx->slot_bank.slot + 1UL; | ||
history->bits_bitvec_offset = (ulong)((uchar*)history - (uchar*)history); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
history->bits_bitvec_offset = (ulong)((uchar*)history - (uchar*)history); | |
history->bits_bitvec_offset = (ulong)((uchar*)blocks - (uchar*)history); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah, nice catch!
e0365d4
to
5290dcf
Compare
I swear I implemented bitVectors before but obviously that was in my previous job of implementing a solana validator... :) |
5290dcf
to
0a0449d
Compare
0a0449d
to
76368f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gossip side looks good
baa8c00
76368f3
to
baa8c00
Compare
print(' err = fd_bincode_bool_decode( &o, ctx );', file=body) | ||
print(' if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) return err;', file=body) | ||
print(' if( o ) {', file=body) | ||
self.vector_member.emitDecodeFootprint(' ') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using numerical value to do indents instead of manual spaces
|
||
print(f' fun( w, NULL, "{self.name}", FD_FLAMENCO_TYPE_ARR_END, "array", level-- );', file=body) | ||
# A BitVector can be modeled as an Option<Vector<some type>> | ||
# See https://github.com/tov/bv-rs/blob/master/src/bit_vec/inner.rs#L8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: tagged permalink
Fixes Types Fuzzer mismatch by adding support for a
BitVector
member type ingen_stubs.py
andgen_fuzz.py
. We need a BitVector type because there is an invariant check that the length of the bitvector matches the length of the number of bits.Verified that this fixes the types fuzzer mismatch locally in solfuzz.