-
Notifications
You must be signed in to change notification settings - Fork 229
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
sdk: Extract solana-sysvar-id
crate
#3309
Conversation
Maybe I missed something, but my current understanding is that we would still need to use both the sysvar specific crate + |
That's correct. The cc @buffalojoec since he's been looking at |
The current Sysvar trait is used as a constraint in a few places in SDK code, for example:
Changing this constraint would be a breaking change. So the current Sysvar trait would have to stick around for quite some time, so we'd still want to pull it out of solana-program |
Hm, yeah I see what you mean. In that case, I can change this to But then I'm not sure where the blocks like Since the current |
I think until the next breaking change we'll have a solana-sysvar crate that is larger than we'd like, because it'll include all the impls of the trait. Also I have not confirmed this but I think it will need to include We can check if this is correct but basically I think program_stubs and Sysvar need to be in the same crate for program_stubs to work. So I would just move program_stubs to the new solana-sysvar crate unless you can think of a catchy name that conveys "sysvar and program_stubs" |
Yep, this sounds great! This encompasses mine and @2501babe's plan for the others. |
yep, theres also a note in i havent looked at the code here yet but we should plan any new sysvar trait around the removal of the |
Gotcha, yeah I think that makes the most sense. I'll change this to Thanks to everyone for chiming in! |
02065bb
to
5a44394
Compare
solana-sysvar
cratesolana-sysvar-id
crate
This should be ready for another look |
#### Problem The sysvars in `solana-program` are tightly coupled with types that exist in `solana-program`. For example, all of the special sysvar getters like `Rent::get()` are implemented through a macro that falls back to using `program_stubs`. Because of this tight coupling, it's difficult to pull out bits for the sysvars. #### Summary of changes After numerous attempts, I've decided to keep it simple and only extract `SysvarId`, its helper macros, and `get_sysvar`. To go along with that, all of the separated sysvar crates now implement the sysvar ids themselves under a new `sysvar` feature. This new feature might be overkill, so let me know if we should just include the sysvar ids by default. I went with a feature to include an implementation using the `sol_get_sysvar` syscall in the future. It was really messy to include the `Sysvar` trait from `solana-program` because it falls back to using `bincode`, which we know performs poorly for on-chain programs. So the future idea is to create a new `Sysvar` trait in `solana-sysvar` which will require fewer bits to deserialize sysvars. Let me know what you think about this PR and the future idea! Note that I'll need to rebase this on top of solana-labs#3249 and solana-labs#3272 when they land.
b0ad1c4
to
b731ba0
Compare
Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis. |
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 good!
Ok great! I sent over |
* sdk: Extract `solana-sysvar` crate #### Problem The sysvars in `solana-program` are tightly coupled with types that exist in `solana-program`. For example, all of the special sysvar getters like `Rent::get()` are implemented through a macro that falls back to using `program_stubs`. Because of this tight coupling, it's difficult to pull out bits for the sysvars. #### Summary of changes After numerous attempts, I've decided to keep it simple and only extract `SysvarId`, its helper macros, and `get_sysvar`. To go along with that, all of the separated sysvar crates now implement the sysvar ids themselves under a new `sysvar` feature. This new feature might be overkill, so let me know if we should just include the sysvar ids by default. I went with a feature to include an implementation using the `sol_get_sysvar` syscall in the future. It was really messy to include the `Sysvar` trait from `solana-program` because it falls back to using `bincode`, which we know performs poorly for on-chain programs. So the future idea is to create a new `Sysvar` trait in `solana-sysvar` which will require fewer bits to deserialize sysvars. Let me know what you think about this PR and the future idea! Note that I'll need to rebase this on top of #3249 and #3272 when they land. * Add solana-define-syscall for solana builds * Rename solana-sysvar -> solana-sysvar-id * Move back `get_sysvar` to solana-program * Update lockfile for v2.2 (cherry picked from commit 838c195) # Conflicts: # Cargo.toml
* sdk: Extract `solana-sysvar` crate #### Problem The sysvars in `solana-program` are tightly coupled with types that exist in `solana-program`. For example, all of the special sysvar getters like `Rent::get()` are implemented through a macro that falls back to using `program_stubs`. Because of this tight coupling, it's difficult to pull out bits for the sysvars. #### Summary of changes After numerous attempts, I've decided to keep it simple and only extract `SysvarId`, its helper macros, and `get_sysvar`. To go along with that, all of the separated sysvar crates now implement the sysvar ids themselves under a new `sysvar` feature. This new feature might be overkill, so let me know if we should just include the sysvar ids by default. I went with a feature to include an implementation using the `sol_get_sysvar` syscall in the future. It was really messy to include the `Sysvar` trait from `solana-program` because it falls back to using `bincode`, which we know performs poorly for on-chain programs. So the future idea is to create a new `Sysvar` trait in `solana-sysvar` which will require fewer bits to deserialize sysvars. Let me know what you think about this PR and the future idea! Note that I'll need to rebase this on top of #3249 and #3272 when they land. * Add solana-define-syscall for solana builds * Rename solana-sysvar -> solana-sysvar-id * Move back `get_sysvar` to solana-program * Update lockfile for v2.2 (cherry picked from commit 838c195) # Conflicts: # Cargo.toml
sdk: Extract `solana-sysvar-id` crate (#3309) * sdk: Extract `solana-sysvar` crate #### Problem The sysvars in `solana-program` are tightly coupled with types that exist in `solana-program`. For example, all of the special sysvar getters like `Rent::get()` are implemented through a macro that falls back to using `program_stubs`. Because of this tight coupling, it's difficult to pull out bits for the sysvars. #### Summary of changes After numerous attempts, I've decided to keep it simple and only extract `SysvarId`, its helper macros, and `get_sysvar`. To go along with that, all of the separated sysvar crates now implement the sysvar ids themselves under a new `sysvar` feature. This new feature might be overkill, so let me know if we should just include the sysvar ids by default. I went with a feature to include an implementation using the `sol_get_sysvar` syscall in the future. It was really messy to include the `Sysvar` trait from `solana-program` because it falls back to using `bincode`, which we know performs poorly for on-chain programs. So the future idea is to create a new `Sysvar` trait in `solana-sysvar` which will require fewer bits to deserialize sysvars. Let me know what you think about this PR and the future idea! Note that I'll need to rebase this on top of #3249 and #3272 when they land. * Add solana-define-syscall for solana builds * Rename solana-sysvar -> solana-sysvar-id * Move back `get_sysvar` to solana-program * Update lockfile for v2.2 (cherry picked from commit 838c195) # Conflicts: # Cargo.toml Co-authored-by: Jon C <[email protected]>
* sdk: Extract `solana-sysvar` crate #### Problem The sysvars in `solana-program` are tightly coupled with types that exist in `solana-program`. For example, all of the special sysvar getters like `Rent::get()` are implemented through a macro that falls back to using `program_stubs`. Because of this tight coupling, it's difficult to pull out bits for the sysvars. #### Summary of changes After numerous attempts, I've decided to keep it simple and only extract `SysvarId`, its helper macros, and `get_sysvar`. To go along with that, all of the separated sysvar crates now implement the sysvar ids themselves under a new `sysvar` feature. This new feature might be overkill, so let me know if we should just include the sysvar ids by default. I went with a feature to include an implementation using the `sol_get_sysvar` syscall in the future. It was really messy to include the `Sysvar` trait from `solana-program` because it falls back to using `bincode`, which we know performs poorly for on-chain programs. So the future idea is to create a new `Sysvar` trait in `solana-sysvar` which will require fewer bits to deserialize sysvars. Let me know what you think about this PR and the future idea! Note that I'll need to rebase this on top of anza-xyz#3249 and anza-xyz#3272 when they land. * Add solana-define-syscall for solana builds * Rename solana-sysvar -> solana-sysvar-id * Move back `get_sysvar` to solana-program * Update lockfile for v2.2
Problem
The sysvars in
solana-program
are tightly coupled with types that exist insolana-program
. For example, all of the special sysvar getters likeRent::get()
are implemented through a macro that falls back to usingprogram_stubs
.Because of this tight coupling, it's difficult to pull out bits for the sysvars.
Summary of changes
After numerous attempts, I've decided to keep it simple and only extract
SysvarId
, its helper macros, andget_sysvar
.To go along with that, all of the separated sysvar crates now implement the sysvar ids themselves under a new
sysvar
feature. This new feature might be overkill, so let me know if we should just include the sysvar ids by default. I went with a feature to include an implementation using thesol_get_sysvar
syscall in the future.It was really messy to include the
Sysvar
trait fromsolana-program
because it falls back to usingbincode
, which we know performs poorly for on-chain programs. So the future idea is to create a newSysvar
trait insolana-sysvar
which will require fewer bits to deserialize sysvars.Let me know what you think about this PR and the future idea! Note that I'll need to rebase this on top of #3249 and #3272 when they land.