misc crates: drop SysvarSerialize - #14284
Conversation
| { | ||
| let mut account = AccountSharedData::new(1, solana_epoch_schedule::SIZE, &sysvar::id()); | ||
| bincode::serialize_into(account.data_as_mut_slice(), &EpochSchedule::default()).unwrap(); | ||
| wincode::serialize_into(account.data_as_mut_slice(), &EpochSchedule::default()).unwrap(); |
| // Slot History | ||
| // (Not fixed-size, but also not supported) | ||
| msg!("SlotHistory identifier:"); | ||
| sysvar::slot_history::id().log(); | ||
| assert_eq!( | ||
| Err(ProgramError::UnsupportedSysvar), | ||
| SlotHistory::from_account_info(&accounts[8]) | ||
| ); |
There was a problem hiding this comment.
Not something we can assert anymore as SlotHistory::from_account_info() isn't used anymore. But it anyway just existed to test that SysvarSerialize method couldn't be used for this sysvar.
There was a problem hiding this comment.
The purpose of this test is to demonstrate that the syscall doesn't support SlotHistory, not the API:
agave/program-runtime/src/sysvar_cache.rs
Lines 107 to 126 in 7976b4a
There was a problem hiding this comment.
The intent of the test is to make sure that using the syscalls is the same as deserializing from the account passed in.
In that spirit, it would be good to compare some slice of the sysvar account with the corresponding slice from the result of the syscall.
There was a problem hiding this comment.
The rest of the assertions in this section are comparing deserialized account sysvars are equivalent to the syscall values. We can't quite do that cleanly for SlotHistory, but I can manually inspect some account bytes as suggested and also assert a failure in the syscall.
| solana-svm-type-overrides = { path = "../../svm-type-overrides", version = "=4.3.0-alpha.2" } | ||
| solana-system-interface = { version = "=3.2", features = ["bincode"] } | ||
| solana-sysvar = "=4.1.0" | ||
| solana-sysvar-id = "=3.1.0" |
There was a problem hiding this comment.
Sdk libraries seems to require = here
There was a problem hiding this comment.
They're just tests, so it's not a huge deal. We could probably relax all those deps in a future PR
| solana-vote-program = { path = "../../programs/vote", version = "=4.3.0-alpha.2" } | ||
| test-case = "3.3.1" | ||
| thiserror = "2.0" | ||
| wincode = { version = "0.5.5", default-features = false } |
There was a problem hiding this comment.
default-features = false to avoid bringing in std given this is programs context
a6430ae to
ca002d8
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #14284 +/- ##
=======================================
Coverage 81.9% 81.9%
=======================================
Files 914 914
Lines 356973 356976 +3
=======================================
+ Hits 292617 292626 +9
+ Misses 64356 64350 -6 🚀 New features to boost your workflow:
|
| solana-core = { workspace = true, features = ["dev-context-only-utils"] } | ||
| solana-cost-model = { workspace = true } | ||
| solana-entry = { workspace = true } | ||
| solana-epoch-schedule = { version = "3.2.0", features = ["wincode"] } |
There was a problem hiding this comment.
True. It's workspace is the dev-bins. Moved.
| // Slot History | ||
| // (Not fixed-size, but also not supported) | ||
| msg!("SlotHistory identifier:"); | ||
| sysvar::slot_history::id().log(); | ||
| assert_eq!( | ||
| Err(ProgramError::UnsupportedSysvar), | ||
| SlotHistory::from_account_info(&accounts[8]) | ||
| ); |
There was a problem hiding this comment.
The purpose of this test is to demonstrate that the syscall doesn't support SlotHistory, not the API:
agave/program-runtime/src/sysvar_cache.rs
Lines 107 to 126 in 7976b4a
joncinque
left a comment
There was a problem hiding this comment.
Looks good to me with Joe's comments resolved!
| solana-svm-type-overrides = { path = "../../svm-type-overrides", version = "=4.3.0-alpha.2" } | ||
| solana-system-interface = { version = "=3.2", features = ["bincode"] } | ||
| solana-sysvar = "=4.1.0" | ||
| solana-sysvar-id = "=3.1.0" |
There was a problem hiding this comment.
They're just tests, so it's not a huge deal. We could probably relax all those deps in a future PR
| // Slot History | ||
| // (Not fixed-size, but also not supported) | ||
| msg!("SlotHistory identifier:"); | ||
| sysvar::slot_history::id().log(); | ||
| assert_eq!( | ||
| Err(ProgramError::UnsupportedSysvar), | ||
| SlotHistory::from_account_info(&accounts[8]) | ||
| ); |
There was a problem hiding this comment.
The intent of the test is to make sure that using the syscalls is the same as deserializing from the account passed in.
In that spirit, it would be good to compare some slice of the sysvar account with the corresponding slice from the result of the syscall.
ca002d8 to
5dc6572
Compare
Removes the last bit of direct SysvarSerialize usage. Next is remaining test helpers.
Continuing to break down #12245. Progresses #10672.