Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.