-
Notifications
You must be signed in to change notification settings - Fork 87
feat: account loader. refactor light_program macro #2222
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?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems compression_authority isn't checked against config / nor signer checked
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.
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
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