-
Notifications
You must be signed in to change notification settings - Fork 174
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
flamenco: adds txn generation methods #1692
Conversation
0691dc8
to
210ce8d
Compare
210ce8d
to
1375ef7
Compare
1375ef7
to
055076a
Compare
@ptaffet-jump thank you for the review, this should have been marked as a draft actually. Started cleaning up the code and will look into simplifying these APIs. The first version was just hacked up a few months ago to prove we could send votes to solana. The design comments will be particularly helpful as we start thinking about how we'll use these again |
d1711fe
to
a9c25fe
Compare
ef53516
to
d1b764d
Compare
b62adff
to
54052c1
Compare
54052c1
to
ee2e75e
Compare
ee2e75e
to
b602c52
Compare
write_ptr += compact_instr_cnt_sz; | ||
|
||
/* Calculate offset of next instruction. */ | ||
if ( FD_UNLIKELY( txn_meta->instr_cnt > 1 ) ) { |
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.
I am not sure why this is txn_meta->instr_cnt > 1
instead of txn_meta->instr_cnt > 0
. It seems that, even if txn_meta->instr_cnt == 1
, we should recalculate write_ptr
.
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.
the write_ptr is already at the right offset for that case
program_id, | ||
(ushort)accounts_sz, | ||
data_sz, acct_off, data_off ); | ||
return (ulong)(instr_start - out_txn_payload); |
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.
It seems that you are returning the old txn size instead of the new txn size. Is this deliberate? It seems more natural to return the new txn size.
Also, you never check whether we are writing more than FD_TXN_MTU
bytes to out_txn_payload
. It may be useful to guarantee that this function never writes overflow out_txn_payload
, for security purposes.
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.
this returns the size of the just added instr
} | ||
|
||
void | ||
fd_txn_reset_instrs( uchar * txn_meta_ptr, |
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.
Maybe call it fd_txn_remove_instrs
?
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.
remove is used for removing a single element across firedancer so i steered clear of that for this
txn_meta->readonly_unsigned_cnt = accounts->readonly_unsigned_cnt; | ||
/* Number of signatures is encoded as a compact u16 but | ||
can always be encoded using 1 byte here. */ | ||
txn_meta->message_off = (ushort)(num_signatures * FD_TXN_SIGNATURE_SZ + 1); |
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.
If num_signatures is higher than 20, then this offset is already going beyond FD_TXN_MTU
(20*64=1280>1232). It seems useful to guarantee that this function would never write beyond FD_TXN_MTU
bytes from out_txn_payload
.
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.
We have it setup such that the caller can specify a larger buffer. That can be changed in a follow up PR if you'd like to take a look at that
Transaction generation for sending votes etc