Skip to content

Commit 177b039

Browse files
authored
[AHM] Make stuff public and derive (#9384)
Make some stuff public and derive traits. Also removes one silently truncating constructor from ParaId. --------- Signed-off-by: Oliver Tale-Yazdi <[email protected]>
1 parent fec2a91 commit 177b039

File tree

14 files changed

+131
-20
lines changed

14 files changed

+131
-20
lines changed

polkadot/parachain/src/primitives.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ impl From<u32> for Id {
190190
}
191191
}
192192

193+
#[cfg(any(feature = "std", feature = "runtime-benchmarks"))]
193194
impl From<usize> for Id {
194195
fn from(x: usize) -> Self {
195196
// can't panic, so need to truncate

polkadot/runtime/common/src/claims/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ impl<'de> Deserialize<'de> for EthereumAddress {
174174
}
175175
}
176176

177+
impl AsRef<[u8]> for EthereumAddress {
178+
fn as_ref(&self) -> &[u8] {
179+
&self.0[..]
180+
}
181+
}
182+
177183
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, TypeInfo, MaxEncodedLen)]
178184
pub struct EcdsaSignature(pub [u8; 65]);
179185

polkadot/runtime/common/src/paras_registrar/mod.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use polkadot_runtime_parachains::{
3838
};
3939

4040
use crate::traits::{OnSwap, Registrar};
41-
use codec::{Decode, Encode};
41+
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
4242
pub use pallet::*;
4343
use polkadot_runtime_parachains::paras::{OnNewHead, ParaKind};
4444
use scale_info::TypeInfo;
@@ -47,15 +47,26 @@ use sp_runtime::{
4747
RuntimeDebug,
4848
};
4949

50-
#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, RuntimeDebug, TypeInfo)]
50+
#[derive(
51+
Encode,
52+
Decode,
53+
Clone,
54+
PartialEq,
55+
Eq,
56+
Default,
57+
RuntimeDebug,
58+
TypeInfo,
59+
MaxEncodedLen,
60+
DecodeWithMemTracking,
61+
)]
5162
pub struct ParaInfo<Account, Balance> {
5263
/// The account that has placed a deposit for registering this para.
53-
pub(crate) manager: Account,
64+
pub manager: Account,
5465
/// The amount reserved by the `manager` account for the registration.
55-
deposit: Balance,
66+
pub deposit: Balance,
5667
/// Whether the para registration should be locked from being controlled by the manager.
5768
/// None means the lock had not been explicitly set, and should be treated as false.
58-
locked: Option<bool>,
69+
pub locked: Option<bool>,
5970
}
6071

6172
impl<Account, Balance> ParaInfo<Account, Balance> {

polkadot/runtime/parachains/src/inclusion/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ pub trait RewardValidators {
197197
fn reward_bitfields(validators: impl IntoIterator<Item = ValidatorIndex>);
198198
}
199199

200+
impl RewardValidators for () {
201+
fn reward_backing(_: impl IntoIterator<Item = ValidatorIndex>) {}
202+
fn reward_bitfields(_: impl IntoIterator<Item = ValidatorIndex>) {}
203+
}
204+
200205
/// Reads the footprint of queues for a specific origin type.
201206
pub trait QueueFootprinter {
202207
type Origin;

prdoc/pr_9384.prdoc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
title: '[AHM] Make stuff public and derive'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |
5+
Preparation for Asset hub migration by making fields public and doing some tweaks.
6+
Also hide one silently truncating constructor from `ParaId``.
7+
8+
crates:
9+
- name: pallet-delegated-staking
10+
bump: minor
11+
- name: pallet-staking-async
12+
bump: minor
13+
- name: polkadot-runtime-parachains
14+
bump: minor
15+
- name: pallet-referenda
16+
bump: minor
17+
- name: pallet-bounties
18+
bump: major
19+
- name: polkadot-runtime-common
20+
bump: major
21+
- name: polkadot-parachain-primitives
22+
bump: major
23+
- name: pallet-bags-list
24+
bump: minor
25+
- name: pallet-multisig
26+
bump: minor
27+
- name: pallet-nomination-pools
28+
bump: minor
29+
- name: pallet-preimage
30+
bump: minor
31+
- name: pallet-scheduler
32+
bump: major

substrate/frame/bags-list/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ use sp_runtime::TryRuntimeError;
136136
#[cfg(any(feature = "runtime-benchmarks", test))]
137137
mod benchmarks;
138138

139-
mod list;
139+
pub mod list;
140140
pub mod migrations;
141141
#[cfg(any(test, feature = "fuzz"))]
142142
pub mod mock;

substrate/frame/bounties/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ type BlockNumberFor<T, I = ()> =
140140
)]
141141
pub struct Bounty<AccountId, Balance, BlockNumber> {
142142
/// The account proposing it.
143-
proposer: AccountId,
143+
pub proposer: AccountId,
144144
/// The (total) amount that should be paid if the bounty is rewarded.
145-
value: Balance,
145+
pub value: Balance,
146146
/// The curator fee. Included in value.
147-
fee: Balance,
147+
pub fee: Balance,
148148
/// The deposit of curator.
149-
curator_deposit: Balance,
149+
pub curator_deposit: Balance,
150150
/// The amount held on deposit (reserved) for making this proposal.
151151
bond: Balance,
152152
/// The status of this bounty.

substrate/frame/delegated-staking/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub mod migration;
131131
mod mock;
132132
#[cfg(test)]
133133
mod tests;
134-
mod types;
134+
pub mod types;
135135

136136
extern crate alloc;
137137

substrate/frame/multisig/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,18 @@ pub struct Timepoint<BlockNumber> {
104104
}
105105

106106
/// An open multisig operation.
107-
#[derive(Clone, Eq, PartialEq, Encode, Decode, Default, RuntimeDebug, TypeInfo, MaxEncodedLen)]
107+
#[derive(
108+
Clone,
109+
Eq,
110+
PartialEq,
111+
Encode,
112+
Decode,
113+
Default,
114+
RuntimeDebug,
115+
TypeInfo,
116+
MaxEncodedLen,
117+
DecodeWithMemTracking,
118+
)]
108119
#[scale_info(skip_type_params(MaxApprovals))]
109120
pub struct Multisig<BlockNumber, Balance, AccountId, MaxApprovals>
110121
where

substrate/frame/nomination-pools/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,7 @@ impl<T: Config> BondedPool<T> {
13571357
Encode,
13581358
Decode,
13591359
MaxEncodedLen,
1360+
DecodeWithMemTracking,
13601361
TypeInfo,
13611362
CloneNoBound,
13621363
PartialEqNoBound,
@@ -1526,6 +1527,7 @@ impl<T: Config> RewardPool<T> {
15261527
Encode,
15271528
Decode,
15281529
MaxEncodedLen,
1530+
DecodeWithMemTracking,
15291531
TypeInfo,
15301532
DefaultNoBound,
15311533
RuntimeDebugNoBound,
@@ -1578,6 +1580,7 @@ impl<T: Config> UnbondPool<T> {
15781580
Encode,
15791581
Decode,
15801582
MaxEncodedLen,
1583+
DecodeWithMemTracking,
15811584
TypeInfo,
15821585
DefaultNoBound,
15831586
RuntimeDebugNoBound,

0 commit comments

Comments
 (0)