mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 07:31:02 +00:00
Make Account Derivation More Unique (#686)
* Use more unique prefix when generating account IDs * Update derived addresses used in tests * Make `account` prefix more unique Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * Update test account IDs again Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
b921a485fb
commit
e4f195d14c
@@ -185,6 +185,6 @@ fn derived_dave_account_is_as_expected() {
|
||||
let derived: AccountId = derive_account_from_rialto_id(bp_runtime::SourceAccount::Account(dave));
|
||||
assert_eq!(
|
||||
derived.to_string(),
|
||||
"5G81vRqUUysQGtN5aEThD5UsLdt4rZWSbVLkjuZzLHadp8ZD".to_string()
|
||||
"5DNW6UVnb7TN6wX5KwXtDYR3Eccecbdzuw89HqjyNfkzce6J".to_string()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -203,6 +203,6 @@ fn derived_dave_account_is_as_expected() {
|
||||
let derived: AccountId = derive_account_from_millau_id(bp_runtime::SourceAccount::Account(dave));
|
||||
assert_eq!(
|
||||
derived.to_string(),
|
||||
"5Hg7WQyk8C1FmPzxY3xSjR7S6zZZC5sAL35vMr6NpW17jBhQ".to_string()
|
||||
"5HZhdv53gSJmWWtD8XR5Ypu4PgbT5JNWwGw2mkE75cN61w9t".to_string()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,12 @@ pub const CALL_DISPATCH_MODULE_PREFIX: &[u8] = b"pallet-bridge/call-dispatch";
|
||||
/// Message-lane module prefix.
|
||||
pub const MESSAGE_LANE_MODULE_PREFIX: &[u8] = b"pallet-bridge/message-lane";
|
||||
|
||||
/// A unique prefix for entropy when generating cross-chain account IDs.
|
||||
pub const ACCOUNT_DERIVATION_PREFIX: &[u8] = b"pallet-bridge/account-derivation/account";
|
||||
|
||||
/// A unique prefix for entropy when generating a cross-chain account ID for the Root account.
|
||||
pub const ROOT_ACCOUNT_DERIVATION_PREFIX: &[u8] = b"pallet-bridge/account-derivation/root";
|
||||
|
||||
/// Id of deployed module instance. We have a bunch of pallets that may be used in
|
||||
/// different bridges. E.g. message-lane pallet may be deployed twice in the same
|
||||
/// runtime to bridge ThisChain with Chain1 and Chain2. Sometimes we need to be able
|
||||
@@ -80,8 +86,8 @@ where
|
||||
AccountId: Encode,
|
||||
{
|
||||
match id {
|
||||
SourceAccount::Root => ("root", bridge_id).using_encoded(blake2_256),
|
||||
SourceAccount::Account(id) => ("account", bridge_id, id).using_encoded(blake2_256),
|
||||
SourceAccount::Root => (ROOT_ACCOUNT_DERIVATION_PREFIX, bridge_id).using_encoded(blake2_256),
|
||||
SourceAccount::Account(id) => (ACCOUNT_DERIVATION_PREFIX, bridge_id, id).using_encoded(blake2_256),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user