Skip to content

Commit 4cc0eb8

Browse files
Neopalliumadamdossa
authored andcommitted
MESH-1787 relayer fixes (#1209)
* Ensure `accept_paying_key` is called by `user_key` Improve description of errors. * Add missing weight. * Bump versions.
1 parent 057d981 commit 4cc0eb8

File tree

8 files changed

+18
-11
lines changed

8 files changed

+18
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "polymesh"
3-
version = "4.1.0"
3+
version = "4.1.1"
44
authors = ["Polymath"]
55
build = "build.rs"
66
edition = "2018"

pallets/bridge/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,11 @@ decl_module! {
411411
///
412412
/// ## Errors
413413
/// - `BadAdmin` if `origin` is not `Self::admin()` account.
414-
#[weight = (500_000_000, DispatchClass::Operational, Pays::Yes)]
414+
#[weight =(
415+
500_000_000 + 7_000_000 * u64::try_from(exempted.len()).unwrap_or_default(),
416+
DispatchClass::Operational,
417+
Pays::Yes
418+
)]
415419
pub fn change_bridge_exempted(origin, exempted: Vec<(IdentityId, bool)>) -> DispatchResult {
416420
Self::base_change_bridge_exempted(origin, exempted)
417421
}

pallets/relayer/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ decl_module! {
125125
/// - `AuthorizationError::Expired` if `auth_id` the authorization has expired.
126126
/// - `AuthorizationError::BadType` if `auth_id` was not a `AddRelayerPayingKey` authorization.
127127
/// - `NotAuthorizedForUserKey` if `origin` is not authorized to accept the authorization for the `user_key`.
128-
/// - `NotAuthorizedForPayingKey` if the authorization was created by a signer that isn't authorized by the `paying_key`.
128+
/// - `NotAuthorizedForPayingKey` if the authorization was created an identity different from the `paying_key`'s identity.
129129
/// - `UserKeyCddMissing` if the `user_key` is not attached to a CDD'd identity.
130130
/// - `PayingKeyCddMissing` if the `paying_key` is not attached to a CDD'd identity.
131131
/// - `UnauthorizedCaller` if `origin` is not authorized to call this extrinsic.
@@ -236,15 +236,18 @@ impl<T: Config> Module<T> {
236236
}
237237

238238
fn base_accept_paying_key(origin: T::Origin, auth_id: u64) -> DispatchResult {
239-
let user_key = ensure_signed(origin)?;
239+
let caller_key = ensure_signed(origin)?;
240240
let user_did =
241-
<Identity<T>>::get_identity(&user_key).ok_or(Error::<T>::UserKeyCddMissing)?;
242-
let signer = Signatory::Account(user_key);
241+
<Identity<T>>::get_identity(&caller_key).ok_or(Error::<T>::UserKeyCddMissing)?;
242+
let signer = Signatory::Account(caller_key.clone());
243243

244244
<Identity<T>>::accept_auth_with(&signer, auth_id, |data, auth_by| -> DispatchResult {
245245
let (user_key, paying_key, polyx_limit) =
246246
extract_auth!(data, AddRelayerPayingKey(user_key, paying_key, polyx_limit));
247247

248+
// Allow: `origin == user_key`.
249+
ensure!(user_key == caller_key, Error::<T>::NotAuthorizedForUserKey);
250+
248251
Self::auth_accept_paying_key(
249252
user_did,
250253
auth_by,

pallets/runtime/ci/src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
6161
// and set impl_version to 0. If only runtime
6262
// implementation changes and behavior does not, then leave spec_version as
6363
// is and increment impl_version.
64-
spec_version: 3002,
64+
spec_version: 3010,
6565
impl_version: 0,
6666
apis: RUNTIME_API_VERSIONS,
6767
transaction_version: 2,

pallets/runtime/develop/src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
5959
// and set impl_version to 0. If only runtime
6060
// implementation changes and behavior does not, then leave spec_version as
6161
// is and increment impl_version.
62-
spec_version: 3002,
62+
spec_version: 3010,
6363
impl_version: 0,
6464
apis: RUNTIME_API_VERSIONS,
6565
transaction_version: 2,

pallets/runtime/mainnet/src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
5757
// and set impl_version to 0. If only runtime
5858
// implementation changes and behavior does not, then leave spec_version as
5959
// is and increment impl_version.
60-
spec_version: 3002,
60+
spec_version: 3010,
6161
impl_version: 0,
6262
apis: RUNTIME_API_VERSIONS,
6363
transaction_version: 2,

pallets/runtime/testnet/src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
6161
// and set impl_version to 0. If only runtime
6262
// implementation changes and behavior does not, then leave spec_version as
6363
// is and increment impl_version.
64-
spec_version: 3002,
64+
spec_version: 3010,
6565
impl_version: 0,
6666
apis: RUNTIME_API_VERSIONS,
6767
transaction_version: 2,

0 commit comments

Comments
 (0)