-
Notifications
You must be signed in to change notification settings - Fork 92
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
Support replacing identifier, address and string constant in module bytecodes #1042
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
} | ||
|
||
/// Replace given module's name to the new name | ||
public fun replace_module_name( |
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.
The name may be some other identifier, so should we rename this function to replace_module_identiner
to avoid misuse?
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
308cdfd
to
b53caa3
Compare
pub base: InternalGas, | ||
pub per_byte: InternalGasPerByte, | ||
} | ||
|
||
fn remap_module_addresses_inner( | ||
gas_params: &RemapAddressesGasParameters, | ||
fn replace_addresses_constant( |
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.
What is the different between replace_addresses_constant
and replace_address_identifiers
?
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.
address_identifier: module rooch_examples::move_module { }
, use std::vector
, the exact address of rooch_examples
and std
are identifiers.
address_constant: let old_address = @0x42
, account_storage::borrow_global(@rooch_examples)
, the exact address of rooch_examples
and @0x42
are address constants.
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.
The native implementations of replace_addresses_constant
and replace_address_identifiers
are almost the same. Perhaps abstraction and code reuse can be considered in the next PR.
bytes: vector<vector<u8>>, | ||
old_addresses: vector<address>, | ||
new_addresses: vector<address>, | ||
): vector<vector<u8>>; | ||
|
||
/// Native function to replace constant bytes in module binary where the length of | ||
/// `old_addresses` must equal to that of `new_addresses`. |
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.
typo in comment : old_addresses
-> old_bytes
, new_addresses
-> new_bytes
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.
fixed
b53caa3
to
a98173f
Compare
Summary
Support replacing identifier, address and string constant in module bytecodes.
Now we can replace the module address, module name, struct name and string constant of the given module bytecodes in Move contracts. So devs can dynamic deployment contracts.