-
Couldn't load subscription status.
- Fork 140
account-view: Add new crate #390
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
Conversation
* Use macro rules * Update directory structure
* Add map and filter_map to Ref and RefMut * Add unit tests * Apply suggestions
* Add bit flag * Remove declarative macro
* Add unchecked helper * Fix lint * Add inline * Rename to checked * Cosmetics * Fix sol log params
* Added close and based_close * added docs comments + wrapped up and tested both function * cargo clippy and fmt * added the new close and changed the name for * fixed and tested after comments
* Fixed compiler bitching about realloc * Added a better alterantive to the black_box * Fixed latest comments * deleted some line after the refactor
* [wip]: Add new scripts * [wip]: Use matric strategy * [wip]: Fix members parsing * [wip]: Add CI env variables * [wip]: Remove nothrow * [wip]: Filter changes * [wip]: Add audit step * [wip]: Add semver checks * [wip]: Refactor publish workflow * [wip]: Refactor * [wip]: Fix commands * Fix formatting * Remove detect changes step * Review comments * Fix lint comments * Expand crate comment * Ignore crate comment tests * Add missing docs * More missing docs * Add missing release component * Pin cargo-release version * Fix merge * Review comments
* [wip]: Add new scripts * [wip]: Add CI env variables * [wip]: Remove nothrow * [wip]: Filter changes * [wip]: Add audit step * [wip]: Add semver checks * [wip]: Refactor publish workflow * [wip]: Refactor * [wip]: Fix commands * Fix formatting * Remove detect changes step * Add check methods * Use check variant on close * Fix merge
* [wip]: Address review comments * [wip]: Fix pointer reference * [wip]: Add logger buffer size tests * Remove unused * More logger tests * Rename program to cpi * Remove dynamic allocation * Fixed signed tests * Fix review comments * Fix unsigned test case * Add is_owner_by helper
* Improve fallback and docs * Add borrow state check * Add inline * Review comments * Revert doc link merge change
* Update doc comments * Update sdk/pinocchio/src/account_info.rs Co-authored-by: Jon C <[email protected]> * Update sdk/pinocchio/src/account_info.rs Co-authored-by: Jon C <[email protected]> --------- Co-authored-by: Jon C <[email protected]>
* Add miri step * Fix miri issues * Install miri component
* Add resize * Deprecate realloc
* Fix review comments * Revert offset increment change * Add invoke instruction helper * Typos * Remove new helpers * Remove unused * Address review comments * Tweak inline attributes * Use invoke signed unchecked * Refactor inline * Renamed to with_bounds * Update docs * Revert change * Add constant length check * Simplify accounts deserialization * Invert borrow state logic * Use expr instead * Add missing import * Address review comments * Revert unnecessary repr * Fix rebase * Tweak docs * Fix doc reference * Fix miri errors * More review comments
* Simplify realloc logic * Address review comments
* Fix assign unsoundness * Remove unsafe
* Add invoke instruction helper * Typos * Remove new helpers * Remove unused * Address review comments * Tweak inline attributes * Use invoke signed unchecked * Refactor inline * Renamed to with_bounds * Update docs * Revert change * Add constant length check * Add spellcheck step * Tweak action * Fix typos * More fixes * Yet more fixes * Fixes * Add j1 option * More and more fixes * Add missing acronym * Fix merge * Fix spelling * Fix spelling
* Add comments on constants * Improve offset comments * Add bitmask to dictionary * Renamed to field_at_offset
Ignore zero_init parameter
* make data_ptr public * Update sdk/pinocchio/src/account_info.rs Co-authored-by: Fernando Otero <[email protected]> * add some tests for data ptr * Fix spelling --------- Co-authored-by: Fernando Otero <[email protected]>
* Add try_maps on AccountInfo Ref/RefMut * update tests and api for try map ref
Move NON_DUP_MARKER const
Signed-off-by: vetclippy <[email protected]>
* Add pubkey_eq helper * Fix typo * Update pubkey comparison * Add proptest * Add unlikely * Replace proptest
Add invariant details
2846515 to
c73db50
Compare
account-view/src/lib.rs
Outdated
| #[repr(C)] | ||
| #[cfg_attr(feature = "copy", derive(Copy))] | ||
| #[derive(Clone, Default)] | ||
| pub struct Account { |
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.
There is already a public Account type defined in solana-account. We could name this one as RuntimeAccount or another name to avoid the name clash. It is not really used directly in programs, only the entrypoint uses it.
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.
A new name might be better to be safe, especially if it won't really be consumed from the outside. RuntimeAccount is pretty good, I also came up with EntrypointAccount or RuntimeSerializedAccount or OnchainAccount
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.
Just looked at the crate definition and your comment, but it looks good! Feel free to do the rename or not
account-view/src/lib.rs
Outdated
| #[repr(C)] | ||
| #[cfg_attr(feature = "copy", derive(Copy))] | ||
| #[derive(Clone, Default)] | ||
| pub struct Account { |
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.
A new name might be better to be safe, especially if it won't really be consumed from the outside. RuntimeAccount is pretty good, I also came up with EntrypointAccount or RuntimeSerializedAccount or OnchainAccount
b9cc55b to
e7ba5b2
Compare
Renamed to |
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.
Looks great!
Problem
Currently, Pinocchio uses its own zero-copy representation of
AccountandAccountInfo, which saves CUs on entrypoint definitions. By using the same name to represent anAccountInfo, it is cumbersome to write code that uses both types at the same time.These types are useful for other entrypoint definitions and they will have greater visibility if they are added to the SDK.
Solution
Add a new
solana-account-viewcrate with two new types:AccountandAccountView. TheAccounttype has the same memory layout than the serialized account data provided by the runtime to a program entrypoint. Therefore, it can be used to represent the account data in a zero-copy fashion. TheAccountViewis the equivalent of anAccountInfo, wrapping anAccountand providing safe borrow methods.Note: This PR moves the code from pinocchio repository maintaining history.