-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat!: add support for dynamic configurables #1555
base: master
Are you sure you want to change the base?
Conversation
…set (#1593) <!-- List the issues this PR closes (if any) in a bullet list format, e.g.: - Closes #ABCD - Closes #EFGH --> <!-- Use this only if this PR requires a mention in the Release Notes Summary. Valuable features and critical fixes are good examples. For everything else, please delete the whole section. --> In this release, we: ~~- Previously deployed blobs are no longer accessible due to changes in blob ID calculation. Redeployment is required.~~ Updates blob ID calculation to use the configurable offset instead of the data offset, aligning with the updated design for scripts and predicates. `has_configurable_section_offset` function checks bytes 4 and 7 to distinguish binary versions. If byte 4 is 0x74 (JMPF), it considers byte 7: 0x02 means legacy, 0x04 means new, and any other value results in an error. <!-- Please write a summary of your changes and why you made them. Not all PRs will be complex or substantial enough to require this section, so you can remove it if you think it's unnecessary. --> - [x] All **changes** are **covered** by **tests** (or not applicable) - [x] All **changes** are **documented** (or not applicable) - [x] I **reviewed** the **entire PR** myself (preferably, on GH UI) - [x] I **described** all **Breaking Changes** (or there's none) --------- Co-authored-by: hal3e <[email protected]> Co-authored-by: Ahmed Sagdati <[email protected]>
Updated the way we access storage slots in the example.
|
||
#[tokio::test] | ||
async fn contract_configurables_reader_manual() -> Result<()> { | ||
// TODO: add documentatio |
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.
todo
|
||
#[tokio::test] | ||
async fn contract_configurables_reader_runtime() -> Result<()> { | ||
// TODO: add documentatio |
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.
.
Ok(()) | ||
} | ||
|
||
fn dynamic_section_start(&self, binary: &[u8], data_offset: usize) -> Result<Option<usize>> { |
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.
A short docstring here would be helpful
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.
added docstring 40afe0e
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 should probably hold off on merging this until the sway branch catches up with sway master.
I have a feeling it's a bit behind seeing how the configurables offset is 8..16
and not 16..24
seeing as we already support the latter.
Either wait or integrate with the work done in the PR mentioned above so that we detect the compiler version used to generate the sway binary and use 16..24
if it is a modern compiler or 8..16
if it is the older one.
|
||
#[tokio::test] | ||
async fn contract_configurables_reader_manual() -> Result<()> { | ||
// TODO: add documentatio |
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.
?
|
||
#[tokio::test] | ||
async fn contract_configurables_reader_runtime() -> Result<()> { | ||
// TODO: add documentatio |
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.
?
packages/fuels-code-gen/src/program_bindings/abigen/configurables.rs
Outdated
Show resolved
Hide resolved
@@ -51,10 +51,11 @@ mod code_types { | |||
} | |||
} | |||
|
|||
pub(crate) fn code(&self) -> Vec<u8> { | |||
pub(crate) fn code(&self) -> Result<Vec<u8>> { |
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.
Wdyt about having with_code
and with_configurables
return a Result
, trying to apply the old configurables to the new code or the new configurables to the old code.
If that passes then we can .expect
on all the getters and not have Result
everywhere.
Nice consequence is that it will fail closer to the thing that made it fail -- ie the code or the configurables that were invalid, not later on when you try and calculate the contract id.
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 like the idea.
improve tests with comments Co-authored-by: Ahmed Sagdati <[email protected]>
closes: #1481
closes: #1328 as we can read the configurables directly from the binary
Release notes
In this release, we:
str
configurables.abigen
that can read configurables directly form the binary.ConfigurablesReader
that can be used to read direct and indirect configurables at runtime and compile time.Summary
Breaking Changes
Contract
Regular
andLoader
methodscode()
,contract_id()
,code_root
,state_root
returnResult
Executable
Regular
andLoader
methodscode()
,data_offset_in_code
,loader_code
returnResult
Configurables
'supdate_constants_in
returnsResult
Predicate
'swith_configurable
returnsResult
AbiFormatter
'sdecode_configurables
argumentconfigurable_data
now accepts a&[u8]
Checklist