feat: account loader. refactor light_program macro#2222
feat: account loader. refactor light_program macro#2222sergeytimoshin merged 21 commits intomainfrom
Conversation
|
Important Review skippedToo many files! This PR contains 165 files, which is 15 over the limit of 150. You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
26e379b to
402c1d1
Compare
| - Field must be named `compression_info` | ||
| - Type must be `CompressionInfo` (not `Option<CompressionInfo>`) | ||
| - Must be **first or last** field in the struct | ||
| - Excluded from `PackedT` struct (saves 24 bytes in compressed form) |
There was a problem hiding this comment.
can clients still deserialize the compressed acc data using their regular UserRecord struct? is "compressed form" here != "when the account is compressed/cold"?
There was a problem hiding this comment.
yeah compressed account and account state both have CompressionInfo we just dont send it in instruction data
The LightAccount macro generates structs with non-Option CompressionInfo as the first field, but extract_compression_info was trying to deserialize Option<CompressionInfo>. This caused all PDA tracking to fail silently.
| // TODO: make compression_authority a signer and validate against config | ||
| let _compression_authority = | ||
| account_iter | ||
| .next_account("compression_authority") | ||
| .map_err(|e| { | ||
| solana_msg::msg!("compress: compression_authority failed: {:?}", e); | ||
| ProgramError::from(e) | ||
| })?; | ||
|
|
||
| // Load and validate config | ||
| let light_config = LightConfig::load_checked(config, program_id).map_err(|e| { | ||
| solana_msg::msg!("compress: LightConfig::load_checked failed: {:?}", e); | ||
| ProgramError::InvalidAccountData | ||
| })?; | ||
|
|
||
| // Validate rent_sponsor matches config | ||
| let _ = light_config | ||
| .validate_rent_sponsor(rent_sponsor) | ||
| .map_err(|e| { | ||
| solana_msg::msg!("compress: validate_rent_sponsor failed: {:?}", e); | ||
| e | ||
| })?; | ||
| // TODO: validate compression_authority matches config | ||
| // if *compression_authority.key != light_config.compression_authority { | ||
| // return Err(ProgramError::InvalidAccountData); | ||
| // } |
There was a problem hiding this comment.
it seems compression_authority isn't checked against config / nor signer checked
There was a problem hiding this comment.
yes its not used yet, I want to set compression authority to a pda of a proxy program but thats not implemented yet
e6b2434 to
d467cd4
Compare
fc6166b to
550b42d
Compare
a992229 to
3f2fe31
Compare
New Features
light_accountrenametoken::authority->token::owner_seedsowner_seedsto be constant. Otherwise we cannot know that we are decompressing to the correct owner.light_accountrequiretoken::seedslight_accountattribute (all in one place now and explicit)pda_rent_sponsoraccount info iflight_account(init)is presentvalidation.rsfiles in macros/src/light_pdas/account and accounts to make it easier to review validationscreate_accountsyscallCreateAccountsProofResultaddsystem_accounts_offsetCOMPRESSIBLE_CONFIG_V1->LIGHT_TOKEN_CONFIGLightConfigRefactors
from Rust AST
dependencies