-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add the possibility to specify an offset for the read value in StorageRead::read #863
Conversation
…emory implementation
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.
LGTM!=) Do I understand correct, that after this change is merged, you will rework #847 ?
fuel-storage/src/impls.rs
Outdated
key: &<Type as Mappable>::Key, | ||
buf: &mut [u8], | ||
) -> Result<Option<usize>, T::Error> { | ||
self.0.read(key, buf) | ||
self.0.read(key, 0, buf) |
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.
We can specify offset here as well or add read_with_offset
=)
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.
Done here: b2335f9
Is there any reason why StorageRef
does not implement StorageRead
btw? The only thing I see is that it does not implement StorageSize
, which is a requirement for StorageRead
.
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 doesn't implement any traits because it is used like storage::<Mapable>().read
without importing the trait(just calling of the function). This structure is used as a syntax sugar to simplify the work within the code
fuel-vm/src/storage.rs
Outdated
pub use memory::MemoryStorage; | ||
#[cfg(feature = "test-helpers")] | ||
pub use memory::MemoryStorageError; |
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.
pub use memory::MemoryStorage; | |
#[cfg(feature = "test-helpers")] | |
pub use memory::MemoryStorageError; | |
pub use memory::{ | |
MemoryStorage, | |
MemoryStorageError, | |
}; |
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.
Changed here: 8855eab
CHANGELOG.md
Outdated
- [863](https://github.com/FuelLabs/fuel-vm/pull/863): Changed StorageRead::read to load a serialized value starting from a offset. The function returns an optional value equal to the number of bytes read when defined, or none if the offset specified in input is outside the boundaries of the serialized value read. | ||
## [Version 0.58.2] |
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.
- [863](https://github.com/FuelLabs/fuel-vm/pull/863): Changed StorageRead::read to load a serialized value starting from a offset. The function returns an optional value equal to the number of bytes read when defined, or none if the offset specified in input is outside the boundaries of the serialized value read. | |
## [Version 0.58.2] | |
- [863](https://github.com/FuelLabs/fuel-vm/pull/863): Changed StorageRead::read to load a serialized value starting from a offset. The function returns an optional value equal to the number of bytes read when defined, or none if the offset specified in input is outside the boundaries of the serialized value read. | |
## [Version 0.58.2] |
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.
Thanks, changed in 5b91da4
Yes, I'll start working on that shortly. IIUC After the release of the next fuel-vm version I'll also have to update |
Yes |
…ull update to 0.59.1) (#2438) ## Linked Issues/PRs <!-- List of related issues/PRs --> Related to FuelLabs/fuel-vm#681 ## Description In order to load contracts from a given offset efficiently, we have changed the interface of `StorageRead::read` to accept a n offset in input (see FuelLabs/fuel-vm#863). This PR refactors the fuel-core repo to make use of the new StorageRead trait. ## Checklist - [ ] Breaking changes are clearly marked as such in the PR description and changelog - [ ] New behavior is reflected in tests - [ ] [The specification](https://github.com/FuelLabs/fuel-specs/) matches the implemented behavior (link update PR if changes are needed) ### Before requesting review - [ ] I have reviewed the code myself - [ ] I have created follow-up issues caused by this PR and linked them here ### After merging, notify other teams [Add or remove entries as needed] - [ ] [Rust SDK](https://github.com/FuelLabs/fuels-rs/) - [ ] [Sway compiler](https://github.com/FuelLabs/sway/) - [ ] [Platform documentation](https://github.com/FuelLabs/devrel-requests/issues/new?assignees=&labels=new+request&projects=&template=NEW-REQUEST.yml&title=%5BRequest%5D%3A+) (for out-of-organization contributors, the person merging the PR will do this) - [ ] Someone else? --------- Co-authored-by: AurelienFT <[email protected]> Co-authored-by: AurelienFT <[email protected]> Co-authored-by: AurelienFT <[email protected]> Co-authored-by: green <[email protected]>
[Link to related issue(s) here, if any]
[Short description of the changes.]
Checklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]