Skip to content

Commit

Permalink
Fix impl alloc/write macro (#43)
Browse files Browse the repository at this point in the history
* update impl for writealloc size limits

I'm not certain, but my hunch is that we need to add some margin to data_len to account for the AccountMeta we're passing into the instruction.  We have 3 of them at 34 bytes ea (Pubkey + 2 bool) = 102 bytes above our limit.
edit pretty sure this is the case. check out: https://github.com/solana-labs/solana/blob/15d18a03e5203aec6452605cf6381afca46983fa/programs/bpf_loader/src/syscalls.rs#L2750-L2763
(34 * ix.accounts.len() + ix.data.len() <= 1280)

* chore: hardcode const

* fix impl accounts_metas size

* Update impls.rs

* Update impls.rs
  • Loading branch information
amilz authored Mar 29, 2024
1 parent 0740035 commit f1f582a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clients/rust/asset/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ macro_rules! allocate_update_data_length {
macro_rules! allocate_and_write {
( $program:expr, $asset:expr, $payer:expr, $system_program:expr, $extension_type:expr, $data:expr, $signers_seeds:expr ) => {{
const CPI_LIMIT: usize = 1280;
const ACCOUNT_METAS_SIZE: usize = 102; // 3 X (32 bytes for pubkey + 1 byte for is_signer + 1 byte for is_writable)
const ACCOUNT_METAS_SIZE: usize = 106; // 3 X (32 bytes for pubkey + 1 byte for is_signer + 1 byte for is_writable) + 4 bytes for vec prefix
let total_data_len = $data.len();
// (1) discriminator
// (1) extension type
Expand Down

0 comments on commit f1f582a

Please sign in to comment.