From 7903981b5f4be8ea58a4e83127ec06b394029c5f Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 11 Feb 2022 19:42:12 +0800 Subject: [PATCH 1/3] Ensure `accept_paying_key` is called by `user_key` Improve description of errors. --- pallets/relayer/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pallets/relayer/src/lib.rs b/pallets/relayer/src/lib.rs index 49dd248bf5..4361877740 100644 --- a/pallets/relayer/src/lib.rs +++ b/pallets/relayer/src/lib.rs @@ -127,7 +127,7 @@ decl_module! { /// - `AuthorizationError::Expired` if `auth_id` the authorization has expired. /// - `AuthorizationError::BadType` if `auth_id` was not a `AddRelayerPayingKey` authorization. /// - `NotAuthorizedForUserKey` if `origin` is not authorized to accept the authorization for the `user_key`. - /// - `NotAuthorizedForPayingKey` if the authorization was created by a signer that isn't authorized by the `paying_key`. + /// - `NotAuthorizedForPayingKey` if the authorization was created an identity different from the `paying_key`'s identity. /// - `UserKeyCddMissing` if the `user_key` is not attached to a CDD'd identity. /// - `PayingKeyCddMissing` if the `paying_key` is not attached to a CDD'd identity. /// - `UnauthorizedCaller` if `origin` is not authorized to call this extrinsic. @@ -238,15 +238,18 @@ impl Module { } fn base_accept_paying_key(origin: T::Origin, auth_id: u64) -> DispatchResult { - let user_key = ensure_signed(origin)?; + let caller_key = ensure_signed(origin)?; let user_did = - >::get_identity(&user_key).ok_or(Error::::UserKeyCddMissing)?; - let signer = Signatory::Account(user_key); + >::get_identity(&caller_key).ok_or(Error::::UserKeyCddMissing)?; + let signer = Signatory::Account(caller_key.clone()); >::accept_auth_with(&signer, auth_id, |data, auth_by| -> DispatchResult { let (user_key, paying_key, polyx_limit) = extract_auth!(data, AddRelayerPayingKey(user_key, paying_key, polyx_limit)); + // Allow: `origin == user_key`. + ensure!(user_key == caller_key, Error::::NotAuthorizedForUserKey); + Self::auth_accept_paying_key( user_did, auth_by, From 374d3d4cc1612fe768653ec4ea4a380210827912 Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 11 Feb 2022 20:04:20 +0800 Subject: [PATCH 2/3] Add missing weight. --- pallets/bridge/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pallets/bridge/src/lib.rs b/pallets/bridge/src/lib.rs index 4b11ce35ed..9a70235559 100644 --- a/pallets/bridge/src/lib.rs +++ b/pallets/bridge/src/lib.rs @@ -415,7 +415,11 @@ decl_module! { /// /// ## Errors /// - `BadAdmin` if `origin` is not `Self::admin()` account. - #[weight = (500_000_000, DispatchClass::Operational, Pays::Yes)] + #[weight =( + 500_000_000 + 7_000_000 * u64::try_from(exempted.len()).unwrap_or_default(), + DispatchClass::Operational, + Pays::Yes + )] pub fn change_bridge_exempted(origin, exempted: Vec<(IdentityId, bool)>) -> DispatchResult { Self::base_change_bridge_exempted(origin, exempted) } From f05b29ffe3bdce5cd073ed70171a66c44046fd2c Mon Sep 17 00:00:00 2001 From: "Robert G. Jakabosky" Date: Fri, 11 Feb 2022 20:07:58 +0800 Subject: [PATCH 3/3] Bump versions. --- Cargo.lock | 2 +- Cargo.toml | 2 +- pallets/runtime/ci/src/runtime.rs | 2 +- pallets/runtime/develop/src/runtime.rs | 2 +- pallets/runtime/mainnet/src/runtime.rs | 2 +- pallets/runtime/testnet/src/runtime.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75c21233d8..c066217d55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5686,7 +5686,7 @@ dependencies = [ [[package]] name = "polymesh" -version = "4.1.0" +version = "4.1.1" dependencies = [ "chrono", "ed25519-dalek", diff --git a/Cargo.toml b/Cargo.toml index 211c30c14c..e853e79bb3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polymesh" -version = "4.1.0" +version = "4.1.1" authors = ["Polymath"] build = "build.rs" edition = "2018" diff --git a/pallets/runtime/ci/src/runtime.rs b/pallets/runtime/ci/src/runtime.rs index 0d6e6f74e7..b7d7dd43ed 100644 --- a/pallets/runtime/ci/src/runtime.rs +++ b/pallets/runtime/ci/src/runtime.rs @@ -61,7 +61,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 3002, + spec_version: 3010, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, diff --git a/pallets/runtime/develop/src/runtime.rs b/pallets/runtime/develop/src/runtime.rs index de3afb2084..04d4b45ef0 100644 --- a/pallets/runtime/develop/src/runtime.rs +++ b/pallets/runtime/develop/src/runtime.rs @@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 3002, + spec_version: 3010, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, diff --git a/pallets/runtime/mainnet/src/runtime.rs b/pallets/runtime/mainnet/src/runtime.rs index 355f3c0774..c3c8de80bf 100644 --- a/pallets/runtime/mainnet/src/runtime.rs +++ b/pallets/runtime/mainnet/src/runtime.rs @@ -57,7 +57,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 3002, + spec_version: 3010, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, diff --git a/pallets/runtime/testnet/src/runtime.rs b/pallets/runtime/testnet/src/runtime.rs index 5724ec19ed..76fbc6e9f0 100644 --- a/pallets/runtime/testnet/src/runtime.rs +++ b/pallets/runtime/testnet/src/runtime.rs @@ -61,7 +61,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 3002, + spec_version: 3010, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2,