Skip to content
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

Merged
merged 6 commits into from
Oct 27, 2023

Conversation

pause125
Copy link
Collaborator

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.

@vercel
Copy link

vercel bot commented Oct 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Visit Preview Oct 27, 2023 0:55am

}

/// Replace given module's name to the new name
public fun replace_module_name(
Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

pub base: InternalGas,
pub per_byte: InternalGasPerByte,
}

fn remap_module_addresses_inner(
gas_params: &RemapAddressesGasParameters,
fn replace_addresses_constant(
Copy link
Collaborator

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 ?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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`.
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@jolestar jolestar merged commit 8066026 into rooch-network:main Oct 27, 2023
@pause125 pause125 deleted the replace_identifier branch November 3, 2023 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MoveosStd] Bytecode module template
3 participants