Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,6 @@ impl pallet_staking_async_rc_client::Config for Runtime {
// | beefy | ECDSA | 33 bytes | 65 bytes |
// | Total | | 193 bytes | 385 bytes |
// We add some buffer for SCALE encoding overhead and future expansions
type MaxSessionKeysLength = ConstU32<256>;
type MaxSessionKeysProofLength = ConstU32<512>;
type WeightInfo = weights::pallet_staking_async_rc_client::WeightInfo<Runtime>;
}

Expand Down
11 changes: 11 additions & 0 deletions prdoc/pr_11115.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Remove MaxSessionKeysLength and MaxSessionKeysProofLength
doc:
- audience: Runtime Dev
description: |-
fixes the issue #11083 where MaxSessionKeysLength and MaxSessionKeysProofLength were unnecessary because there are not stored, just validated.
crates:
- name: pallet-staking-async-rc-client
bump: patch
validate: false
- name: asset-hub-westend-runtime
bump: patch
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,6 @@ impl pallet_staking_async_rc_client::Config for Runtime {
type ValidatorSetExportSession = ValidatorSetExportSession;
type RelayChainSessionKeys = RCSessionKeys;
type Balance = Balance;
type MaxSessionKeysLength = ConstU32<256>;
type MaxSessionKeysProofLength = ConstU32<512>;
type WeightInfo = ();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1419,11 +1419,11 @@ mod session_keys {
SetKeysExecutionCost,
};
use codec::Encode;
use frame_support::{assert_noop, BoundedVec};
use frame_support::assert_noop;
use rc_client::AHStakingInterface;

type Keys = BoundedVec<u8, <T as rc_client::Config>::MaxSessionKeysLength>;
type Proof = BoundedVec<u8, <T as rc_client::Config>::MaxSessionKeysProofLength>;
type Keys = Vec<u8>;
type Proof = Vec<u8>;

/// Helper to create properly encoded session keys and ownership proof.
fn make_session_keys_and_proof(owner: AccountId) -> (Keys, Proof) {
Expand All @@ -1437,7 +1437,7 @@ mod session_keys {
// GIVEN: Account 1 is a validator with delivery fees configured
let validator: AccountId = 1;
let (keys, proof) = make_session_keys_and_proof(validator);
let keys_raw: Vec<u8> = keys.clone().into_inner();
let keys_raw: Vec<u8> = keys.clone();
let delivery_fee: u128 = 50;
XcmDeliveryFee::set(delivery_fee);
let execution_cost = SetKeysExecutionCost::get();
Expand Down
5 changes: 0 additions & 5 deletions substrate/frame/staking-async/rc-client/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,12 @@ pub trait Config: crate::Config {
#[benchmarks]
mod benchmarks {
use super::*;
use frame_support::BoundedVec;
use xcm_executor::traits::FeeReason;

#[benchmark]
fn set_keys() -> Result<(), BenchmarkError> {
let stash = T::setup_validator();
let (keys, proof) = T::generate_session_keys_and_proof(stash.clone());
let keys: BoundedVec<u8, <T as crate::Config>::MaxSessionKeysLength> =
keys.try_into().expect("keys should fit in bounded vec");
let proof: BoundedVec<u8, <T as crate::Config>::MaxSessionKeysProofLength> =
proof.try_into().expect("proof should fit in bounded vec");

// Ensure XCM delivery will succeed by setting up required fees/accounts.
let stash_location = T::account_to_location(stash.clone());
Expand Down
14 changes: 3 additions & 11 deletions substrate/frame/staking-async/rc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,14 +1056,6 @@ pub mod pallet {
/// The balance type used for delivery fee limits.
type Balance: BalanceTrait;

/// Maximum length of encoded session keys.
#[pallet::constant]
type MaxSessionKeysLength: Get<u32>;

/// Maximum length of the session keys ownership proof.
#[pallet::constant]
type MaxSessionKeysProofLength: Get<u32>;

/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
Expand Down Expand Up @@ -1294,8 +1286,8 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::set_keys())]
pub fn set_keys(
origin: OriginFor<T>,
keys: BoundedVec<u8, T::MaxSessionKeysLength>,
proof: BoundedVec<u8, T::MaxSessionKeysProofLength>,
keys: Vec<u8>,
proof: Vec<u8>,
max_delivery_and_remote_execution_fee: Option<BalanceOf<T>>,
) -> DispatchResult {
let stash = ensure_signed(origin)?;
Expand All @@ -1316,7 +1308,7 @@ pub mod pallet {
// Forward validated keys to RC (no proof needed, already validated)
let fees = T::SendToRelayChain::set_keys(
stash.clone(),
keys.into_inner(),
keys,
max_delivery_and_remote_execution_fee,
)
.map_err(|e| match e {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,6 @@ impl pallet_staking_async_rc_client::Config for Runtime {
type ValidatorSetExportSession = ConstU32<4>;
type RelayChainSessionKeys = RelayChainSessionKeys;
type Balance = Balance;
type MaxSessionKeysLength = ConstU32<256>;
type MaxSessionKeysProofLength = ConstU32<512>;
type WeightInfo = ();
}

Expand Down
Loading