docs: fix memory layout comment in instructions sysvar#238
docs: fix memory layout comment in instructions sysvar#238joncinque merged 2 commits intoanza-xyz:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes inaccuracies in the memory layout documentation for the serialize_instructions function in the instructions sysvar. The corrections address incorrect byte offsets and improve clarity by accounting for variable numbers of accounts in the serialization format.
Key changes:
- Corrected byte offset calculations throughout the memory layout comment
- Added explicit handling for variable account numbers in offset calculations
- Improved comment structure to show relative offsets within instruction and account sections
e668339 to
68bf4d4
Compare
joncinque
left a comment
There was a problem hiding this comment.
Thanks for your contribution! This is definitely clearer, but I still had a slightly hard time with one part of it
| // 2 + (33 * num_accounts)..34 + (33 * num_accounts) - program_id - 32 bytes | ||
| // 34 + (33 * num_accounts)..36 + (33 * num_accounts) - data_len - 2 bytes | ||
| // 36 + (33 * num_accounts)..36 + (33 * num_accounts) + data_len - data - variable length |
There was a problem hiding this comment.
nit: I had a bit of a hard time reading these, do you think this might be clearer? We could also use square brackets, but that might make things worse
| // 2 + (33 * num_accounts)..34 + (33 * num_accounts) - program_id - 32 bytes | |
| // 34 + (33 * num_accounts)..36 + (33 * num_accounts) - data_len - 2 bytes | |
| // 36 + (33 * num_accounts)..36 + (33 * num_accounts) + data_len - data - variable length | |
| // (2 + (33 * num_accounts))..(34 + (33 * num_accounts)) - program_id - 32 bytes | |
| // (34 + (33 * num_accounts))..(36 + (33 * num_accounts)) - data_len - 2 bytes | |
| // (36 + (33 * num_accounts))..(36 + (33 * num_accounts) + data_len) - data - variable length |
There was a problem hiding this comment.
@joncinque thanks so much for reviewing this. I took your feedback and rewrote the instruction layout comment to improve clarity. I hope it is easier to follow now.
23fc1f3 to
e4f1e42
Compare
e4f1e42 to
a56f1e5
Compare
joncinque
left a comment
There was a problem hiding this comment.
Even better, thanks again!
* docs: fix memory layout comment in instructions sysvar * rewrite
This patch fixes the inaccuracies in the memory layout description for the
serialize_instructionsfunction.Specifically, it addresses incorrect byte offsets (e.g. incorrect starting offset for table of sets) and not taking variable number of accounts into consideration.