-
Notifications
You must be signed in to change notification settings - Fork 71
feat: add support of address-lookup-table program #94
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
base: main
Are you sure you want to change the base?
feat: add support of address-lookup-table program #94
Conversation
// - [0]: Instruction discriminator (1 byte, u8) (2 for Extend) | ||
|
||
// LOOKUP_TABLE_MAX_ADDRESSES == u8::MAX + 1. | ||
let mut instruction_data = [0; 8196]; // TODO: huge for stack, maybe forget about no_std and use vector |
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.
@febo What do you think about such a huge array initialization?
Max addresses to extend is 256 x 32
+ 4
for discriminator.
Otherwise I can use Vec<Pubkey>
, as it's done in the original program, but we lose no_std
for this.
Maybe you have other, better approaches to tackle it? Maybe use features
and make 2 realizations for std
and no_std
ways?
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.
Vec
is just a wrapper for the allocation. both alloc::boxed::Box
or alloc::alloc::alloc
would allocate on the heap.
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.
8196
won't fit on the stack, so it needs to be less than 4096
(a bit less than that since there are other things that will go on the stack). Perhaps it would be easier if we define a trait Addresses
that represents the instruction data in this case. Then we can have no_std
and std
implementations for it.
We can use a alloc::vec::Vec
for the std
variant.
// - [0]: Instruction discriminator (1 byte, u8) (2 for Extend) | ||
|
||
// LOOKUP_TABLE_MAX_ADDRESSES == u8::MAX + 1. | ||
let mut instruction_data = [0; 8196]; // TODO: huge for stack, maybe forget about no_std and use vector |
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.
Vec
is just a wrapper for the allocation. both alloc::boxed::Box
or alloc::alloc::alloc
would allocate on the heap.
// Instruction data: | ||
// - [0]: Instruction discriminator (1 byte, u8) (4 for Close) | ||
|
||
let instruction_data = [4u8]; |
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 size is 4 bytes
// - [0..4 ]: Instruction discriminator (1 byte, u8) (0 for Create) | ||
// - [4..12]: Recent Slot | ||
// - [12 ]: bump seed | ||
let mut instruction_data = [0; 13]; |
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.
use MaybeUninit
to reduce unnecessary zeroed-out
// Instruction data: | ||
// - [0]: Instruction discriminator (1 byte, u8) (3 for Deactivate) | ||
|
||
let instruction_data = [3u8]; |
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.
size is 4 bytes
// Instruction data: | ||
// - [0]: Instruction discriminator (1 byte, u8) (1 for Freeze) | ||
|
||
let instruction_data = [1u8]; |
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.
size is 4 bytes
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 is a native program, so instruction discriminators have 4
bytes.
No description provided.