Skip to content

Commit f4dc8d2

Browse files
eskimoreskimorseadanda
authored
Broker new price adapter (#4521)
Fixes #4360 Also rename: AllowedRenewals -> PotentialRenewals to avoid confusion of future readers. (An entry in `AllowedRenewals` is not enough to allow a renewal, the assignment also has to be complete, which is only checked afterwards.) - [x] Does not work with renewals as is - fix. - [x] More tests - [x] PR docs Edit 1: (Relevant blog post: https://grillapp.net/12935/agile-coretime-pricing-explained-166522?ref=29715) --------- Co-authored-by: eskimor <[email protected]> Co-authored-by: Dónal Murray <[email protected]> Co-authored-by: command-bot <>
1 parent d5053ac commit f4dc8d2

File tree

21 files changed

+703
-395
lines changed

21 files changed

+703
-395
lines changed

Cargo.lock

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

cumulus/parachains/runtimes/coretime/coretime-rococo/src/coretime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,5 +232,5 @@ impl pallet_broker::Config for Runtime {
232232
type WeightInfo = weights::pallet_broker::WeightInfo<Runtime>;
233233
type PalletId = BrokerPalletId;
234234
type AdminOrigin = EnsureRoot<AccountId>;
235-
type PriceAdapter = pallet_broker::Linear;
235+
type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
236236
}

cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ pub type Migrations = (
112112
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
113113
cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
114114
pallet_broker::migration::MigrateV0ToV1<Runtime>,
115+
pallet_broker::migration::MigrateV1ToV2<Runtime>,
115116
// permanent
116117
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
117118
);

cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/pallet_broker.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ impl<T: frame_system::Config> pallet_broker::WeightInfo for WeightInfo<T> {
154154
/// Proof: `Broker::Status` (`max_values`: Some(1), `max_size`: Some(18), added: 513, mode: `MaxEncodedLen`)
155155
/// Storage: `Broker::SaleInfo` (r:1 w:1)
156156
/// Proof: `Broker::SaleInfo` (`max_values`: Some(1), `max_size`: Some(57), added: 552, mode: `MaxEncodedLen`)
157-
/// Storage: `Broker::AllowedRenewals` (r:1 w:2)
158-
/// Proof: `Broker::AllowedRenewals` (`max_values`: None, `max_size`: Some(1233), added: 3708, mode: `MaxEncodedLen`)
157+
/// Storage: `Broker::PotentialRenewals` (r:1 w:2)
158+
/// Proof: `Broker::PotentialRenewals` (`max_values`: None, `max_size`: Some(1233), added: 3708, mode: `MaxEncodedLen`)
159159
/// Storage: `System::Account` (r:1 w:0)
160160
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
161161
/// Storage: `Broker::Workplan` (r:0 w:1)
@@ -337,8 +337,8 @@ impl<T: frame_system::Config> pallet_broker::WeightInfo for WeightInfo<T> {
337337
}
338338
/// Storage: `Broker::Status` (r:1 w:0)
339339
/// Proof: `Broker::Status` (`max_values`: Some(1), `max_size`: Some(18), added: 513, mode: `MaxEncodedLen`)
340-
/// Storage: `Broker::AllowedRenewals` (r:1 w:1)
341-
/// Proof: `Broker::AllowedRenewals` (`max_values`: None, `max_size`: Some(1233), added: 3708, mode: `MaxEncodedLen`)
340+
/// Storage: `Broker::PotentialRenewals` (r:1 w:1)
341+
/// Proof: `Broker::PotentialRenewals` (`max_values`: None, `max_size`: Some(1233), added: 3708, mode: `MaxEncodedLen`)
342342
fn drop_renewal() -> Weight {
343343
// Proof Size summary in bytes:
344344
// Measured: `957`

cumulus/parachains/runtimes/coretime/coretime-westend/src/coretime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,5 @@ impl pallet_broker::Config for Runtime {
245245
type WeightInfo = weights::pallet_broker::WeightInfo<Runtime>;
246246
type PalletId = BrokerPalletId;
247247
type AdminOrigin = EnsureRoot<AccountId>;
248-
type PriceAdapter = pallet_broker::Linear;
248+
type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
249249
}

cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ pub type Migrations = (
111111
pallet_collator_selection::migration::v2::MigrationToV2<Runtime>,
112112
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
113113
pallet_broker::migration::MigrateV0ToV1<Runtime>,
114+
pallet_broker::migration::MigrateV1ToV2<Runtime>,
114115
// permanent
115116
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
116117
);

cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/pallet_broker.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ impl<T: frame_system::Config> pallet_broker::WeightInfo for WeightInfo<T> {
152152
/// Proof: `Broker::Status` (`max_values`: Some(1), `max_size`: Some(18), added: 513, mode: `MaxEncodedLen`)
153153
/// Storage: `Broker::SaleInfo` (r:1 w:1)
154154
/// Proof: `Broker::SaleInfo` (`max_values`: Some(1), `max_size`: Some(57), added: 552, mode: `MaxEncodedLen`)
155-
/// Storage: `Broker::AllowedRenewals` (r:1 w:2)
156-
/// Proof: `Broker::AllowedRenewals` (`max_values`: None, `max_size`: Some(1233), added: 3708, mode: `MaxEncodedLen`)
155+
/// Storage: `Broker::PotentialRenewals` (r:1 w:2)
156+
/// Proof: `Broker::PotentialRenewals` (`max_values`: None, `max_size`: Some(1233), added: 3708, mode: `MaxEncodedLen`)
157157
/// Storage: `System::Account` (r:1 w:0)
158158
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
159159
/// Storage: `Broker::Workplan` (r:0 w:1)
@@ -335,8 +335,8 @@ impl<T: frame_system::Config> pallet_broker::WeightInfo for WeightInfo<T> {
335335
}
336336
/// Storage: `Broker::Status` (r:1 w:0)
337337
/// Proof: `Broker::Status` (`max_values`: Some(1), `max_size`: Some(18), added: 513, mode: `MaxEncodedLen`)
338-
/// Storage: `Broker::AllowedRenewals` (r:1 w:1)
339-
/// Proof: `Broker::AllowedRenewals` (`max_values`: None, `max_size`: Some(1233), added: 3708, mode: `MaxEncodedLen`)
338+
/// Storage: `Broker::PotentialRenewals` (r:1 w:1)
339+
/// Proof: `Broker::PotentialRenewals` (`max_values`: None, `max_size`: Some(1233), added: 3708, mode: `MaxEncodedLen`)
340340
fn drop_renewal() -> Weight {
341341
// Proof Size summary in bytes:
342342
// Measured: `556`

prdoc/pr_4521.prdoc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
title: AdaptPrice trait is now price controlled
2+
3+
doc:
4+
- audience: Runtime Dev
5+
description: |
6+
The broker pallet price adaptation interface is changed to be less opinionated and more
7+
information is made available to the `AdaptPrice` trait. A new example impl is included which
8+
adapts the price based not on the number of cores sold, but rather on the price that was
9+
achieved during the sale to mitigate a potential price manipulation vector. More information
10+
here:
11+
12+
https://github.com/paritytech/polkadot-sdk/issues/4360
13+
14+
- audience: Runtime User
15+
description: |
16+
The price controller of the Rococo and Westend Coretime chain will be
17+
adjusted with this release. This will very likely be used in the
18+
fellowship production runtime to have a much larger leadin. This fixes a
19+
price manipulation issue we discovered with the Kusama launch.
20+
21+
crates:
22+
- name: pallet-broker
23+
bump: minor
24+
- name: coretime-rococo-runtime
25+
bump: minor
26+
- name: coretime-westend-runtime
27+
bump: minor
28+

substrate/bin/node/runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ impl pallet_broker::Config for Runtime {
21452145
type WeightInfo = ();
21462146
type PalletId = BrokerPalletId;
21472147
type AdminOrigin = EnsureRoot<AccountId>;
2148-
type PriceAdapter = pallet_broker::Linear;
2148+
type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
21492149
}
21502150

21512151
parameter_types! {

substrate/frame/broker/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ frame-system = { path = "../system", default-features = false }
3030

3131
[dev-dependencies]
3232
sp-io = { path = "../../primitives/io" }
33+
sp-tracing = { path = "../../primitives/tracing" }
3334
pretty_assertions = "1.3.0"
3435

3536
[features]

0 commit comments

Comments
 (0)