-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Refactor fuel-core to use version of StorageRead::read with offset #2438
base: master
Are you sure you want to change the base?
Conversation
I find it suspicious that I never had to hardcode the offset value to |
@@ -546,7 +546,8 @@ impl TryFrom<VmBench> for VmBenchPrepared { | |||
} | |||
let storage_diff = vm.storage_diff(); | |||
let mut vm = vm.remove_recording(); | |||
let mut diff = start_vm.diff(&vm); | |||
// TODO: Check if this is the intended use of rollback_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.
@xgreenx please check that this is how we intend to use the new rollback_to
funciton, in which case we can remove the TODO
@@ -4084,6 +4084,7 @@ dependencies = [ | |||
"sha3", | |||
"static_assertions", | |||
"strum 0.24.1", | |||
"substrate-bn", |
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.
Check, do we want this?
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.
i think it is a side-effect of bumping fuel-vm. the ecc operations under the hood use substrate-bn
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.
Yes I confirm
dependencies = [ | ||
"spin 0.9.8", | ||
] |
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.
same: do we need this?
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 comes from lazy static from the substra-bn
.map_err(|e| DatabaseError::Other(anyhow::anyhow!(e)))?; | ||
StorageResult::Ok(read) | ||
if let Some(read) = value.len().checked_sub(offset) { | ||
std::io::Write::write_all(&mut buf, value[offset..].as_ref()) |
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.
this can panic if offset
is out of bounds maybe we should use .get
?
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.
If offset
is out of bounds, then value.len().checked_sub(offset)
should return None
and this code won't be executed.
But I agree that it is not immediate from the code, so maybe there's a better way to write this? 🤔
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.
yeah i missed it a comment is fine
Linked 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.Do not merge
we should first wait for the changes to
StorageRead
to be released infuel-vm
, after which we can update the dependencies in this PRChecklist
Before requesting review
After merging, notify other teams
[Add or remove entries as needed]