-
Notifications
You must be signed in to change notification settings - Fork 96
Dynamic storage support #982
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
base: master
Are you sure you want to change the base?
Conversation
PR SummaryEnables variable-sized contract storage with new instructions and bounds enforcement, updating parameters and gas model.
Written by Cursor Bugbot for commit a00f21a. This will update automatically on new commits. Configure here. |
| self, | ||
| interpreter: &mut Interpreter<M, S, Tx, Ecal, V>, | ||
| ) -> IoResult<ExecuteState, S::DataError> { | ||
| let (a, b, c, d) = self.unpack(); |
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 would be nice if we used readable names here like in hte opcode definition
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 in eec4b1d
fuel-vm/src/interpreter/storage.rs
Outdated
| .storage | ||
| .contract_state(&contract_id, &key) | ||
| .map_err(RuntimeError::Storage)? | ||
| .map(|v| v.as_ref().as_ref().to_vec()) |
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.
You can convert the value into owned type (because, under the hood, it is already owned). Overwise you create vector two times(one when we create value, and another here).
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.
Sure. f07f99e
| let offset = if offset == u64::MAX { | ||
| value.len() | ||
| } else { |
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.
Did we specif this behaviour in the specification?
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.
Yep.
Passing in
u64::MAXin$rCwill cause the write to happen at the end of the slot, without needing to read the slot length first.
| let dst = self.memory.as_mut().write(owner, dst_ptr, len)?; | ||
| let value = self | ||
| .storage | ||
| .contract_state(&contract_id, &key) |
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.
Maybe it is better to use read_bytes here? In this case we will avoud creation of the vector on the fuel-core side
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.
Not sure which read_bytes you're talking about?
Implements dynamic storage instructions as described in FuelLabs/fuel-specs#640
The storage initialization in
Createtransactions is left as-is, i.e. it only allows 32 byte slots. This feature isn't used much, and I don't think it's worth it to continue supporting.Checklist
Before requesting review