-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Customizable ink address #10521
Customizable ink address #10521
Conversation
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.
Looks good. Just missing rust doc.
@@ -136,6 +136,43 @@ type BalanceOf<T> = | |||
/// The current storage version. | |||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(6); | |||
|
|||
/// The address generator function used to determine the address of a contract. | |||
pub trait AddressGenerator<T: frame_system::Config> { | |||
fn generate_address( |
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.
Every public item needs rust doc.
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
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.
Thanks. I think we need to document some warnings here though:
- Implementer must make sure that there are no collisions (same output for different inputs).
- Implementer must make sure that the same inputs lead to the same output (including environmental inputs like your storage location).
- Changing the implementation through a runtime upgrade without a proper storage migration would be a a catastrophic event.
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.
Thanks for the suggestion. Appended them to the doc.
9b87c56
to
9ca34d0
Compare
LGTM |
9ca34d0
to
4570bc0
Compare
bot merge |
* Bump Cumulus, Polkadot, and Substrate Also bumps some other depenencies * Remove duplicate `polkadot` dependency * Update `service.rs` Changes related to: paritytech/cumulus#835 * Update `command.rs` * Add `AddressGenerator` config type From: paritytech/substrate#10521 * Allow Root to execute overweight XCMP messages From: paritytech/cumulus#799 * Add `header` argument to `collect_collation_info` From: paritytech/cumulus#882 * Update Cumulus and friends again * Add Fork ID to genesis config paritytech/cumulus#870 * Add `state_version` field paritytech/substrate#9732 * Add `MaxConsumers` config parameter paritytech/substrate#10382 * Update Substrate compatibility note in README
Background
We are using the pallet-contracts to implement phala's smart contract. We constructed a minimal substrate runtime which include only pallet-contracts and it's dependencies. The runtime then can runs on multiple seperate storage instance. The problem is that contracts instantiated in different storage instance can have the same address, and we want the address to be unique in global.
Summary
To solve the problem, this PR adds a type parameter to generate ink addresses. The DefaultAddressGenerator keeps the original formula. And users can customize the address generation formula by implement a custom AddressGenerator.