Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename assigner_on_demand to on_demand #4706

Merged
merged 85 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
aabcb4b
Start implementing request revenue info
antonva Mar 20, 2024
d8df101
Add revenue tracking to on demand pallet
antonva Mar 20, 2024
8f7c179
Add revenue call to broker pallet
antonva Apr 2, 2024
54e0326
Partial impl of revenue from relay chain
antonva Apr 2, 2024
d8bfb72
Move xcm sending from ondemand to coretime pallet
antonva Apr 4, 2024
f3dfe44
Move ondemand types into separate module
antonva Apr 4, 2024
4f1a44d
Add pallet id to on demand
antonva Apr 4, 2024
ef1174b
Fix tests for on demand
antonva Apr 4, 2024
21f9657
Rework get_revenue
antonva Apr 4, 2024
4d00c85
Add empty weight implementations
antonva Apr 4, 2024
8251ede
Add revenueinbox for broker pallet
antonva Apr 4, 2024
af93286
Merge branch 'master' into ava-request-revenue-info
antonva Apr 5, 2024
7dd6a34
Add log target to coretime pallet
antonva Apr 17, 2024
d5d84e3
Fix coretime benchmarking
antonva Apr 17, 2024
aecc034
Remove check notify revenue info
antonva Apr 19, 2024
1f9a4de
Update broker pallet for revenue info
antonva Apr 19, 2024
6879dd7
Remove negative imbalance shorthand
antonva Apr 19, 2024
7a1f198
Update revenue info calls
antonva Apr 19, 2024
c7d586d
Remove unused imports
antonva Apr 19, 2024
74c88b1
Fix benchmarks
antonva Apr 19, 2024
ff69a3d
Merge branch 'master' into ava-request-revenue-info
antonva Apr 19, 2024
aa137da
Fix tests
antonva Apr 19, 2024
f255e47
Update revenue_until fn
antonva Apr 23, 2024
a6be112
Remove unused imports
antonva Apr 26, 2024
f8da2cd
Adress minor discussions
s0me0ne-unkn0wn May 25, 2024
0e99692
Merge remote-tracking branch 'origin/master' into ava-request-revenue…
s0me0ne-unkn0wn May 25, 2024
2e0e3ef
Fix revenue calculation
s0me0ne-unkn0wn May 25, 2024
0f6a2ba
Propose different implementation of revenue reporting
s0me0ne-unkn0wn May 26, 2024
af899e2
Minor fix
s0me0ne-unkn0wn May 26, 2024
f1b9000
Rename call
s0me0ne-unkn0wn May 26, 2024
dd8ed91
Merge remote-tracking branch 'origin/master' into ava-request-revenue…
s0me0ne-unkn0wn May 29, 2024
65af55c
Fix weights
s0me0ne-unkn0wn May 29, 2024
84151b1
Move constants
s0me0ne-unkn0wn May 29, 2024
6df281b
Improve error handling
s0me0ne-unkn0wn May 29, 2024
8f482fe
Fix and improve test
s0me0ne-unkn0wn May 29, 2024
724b7a5
Fix benchmarking code
s0me0ne-unkn0wn May 30, 2024
00fd411
Add benchmark
s0me0ne-unkn0wn May 30, 2024
d5d668b
Minor fixes
s0me0ne-unkn0wn May 30, 2024
36d9cef
Fix clippy
s0me0ne-unkn0wn May 30, 2024
cd559af
Merge remote-tracking branch 'origin/master' into ava-request-revenue…
s0me0ne-unkn0wn May 30, 2024
fac55b0
Fix broker benchmark
s0me0ne-unkn0wn May 30, 2024
3f8482a
Fix mock impl
s0me0ne-unkn0wn May 31, 2024
338316e
Fix tests
s0me0ne-unkn0wn May 31, 2024
bf4ed2e
Improve revenue collection implementation
s0me0ne-unkn0wn May 31, 2024
d8b4ad1
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
May 31, 2024
14e4bc2
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 31, 2024
3130df8
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 31, 2024
d90b4cb
Accumulate overdue revenue instead of burning it
s0me0ne-unkn0wn May 31, 2024
93f98d6
Merge remote-tracking branch 'origin/ava-request-revenue-info' into a…
s0me0ne-unkn0wn May 31, 2024
f52bf9b
Merge branch 'master' into ava-request-revenue-info
s0me0ne-unkn0wn May 31, 2024
8744d5d
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 31, 2024
884c077
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 31, 2024
db2bb27
Add missing benchmark
s0me0ne-unkn0wn May 31, 2024
42914c5
Merge remote-tracking branch 'origin/ava-request-revenue-info' into a…
s0me0ne-unkn0wn May 31, 2024
7dd59f6
Add stub weights
s0me0ne-unkn0wn May 31, 2024
b794eec
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
May 31, 2024
3d67f5d
Sort out weights mess
s0me0ne-unkn0wn Jun 1, 2024
f6c23cc
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jun 1, 2024
c3468bb
Add prdoc
s0me0ne-unkn0wn Jun 1, 2024
1b60cbf
Fix prdoc
s0me0ne-unkn0wn Jun 1, 2024
832ee90
Add constant docs
s0me0ne-unkn0wn Jun 1, 2024
ddd9f1e
Properly propagate `fast-runtime` feature
s0me0ne-unkn0wn Jun 4, 2024
d59f8ec
Implement parachain-side end of revenue teleport
s0me0ne-unkn0wn Jun 4, 2024
3fb3f6a
Fix test values and add explanation
s0me0ne-unkn0wn Jun 4, 2024
4be7536
Address discussions
s0me0ne-unkn0wn Jun 5, 2024
250e480
Merge branch 'master' into ava-request-revenue-info
s0me0ne-unkn0wn Jun 5, 2024
4e30a57
Rename `assigner_on_demand` to `on_demand`
s0me0ne-unkn0wn Jun 5, 2024
7eca0a0
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jun 5, 2024
50916c9
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Jun 5, 2024
7de6355
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Jun 5, 2024
bcfcf64
Add logs and simplify tests
s0me0ne-unkn0wn Jun 5, 2024
cd3b769
Merge remote-tracking branch 'origin/master' into ava-request-revenue…
s0me0ne-unkn0wn Jun 5, 2024
29d723a
Merge branch 'ava-request-revenue-info' into s0me0ne/rename-assigner-…
s0me0ne-unkn0wn Jun 5, 2024
70e511f
Add comments addressing commented out code
s0me0ne-unkn0wn Jun 6, 2024
76cff00
Merge branch 'master' into ava-request-revenue-info
s0me0ne-unkn0wn Jun 8, 2024
1f319d1
Merge branch 'ava-request-revenue-info' into s0me0ne/rename-assigner-…
s0me0ne-unkn0wn Jun 8, 2024
d1d199b
Update Cargo.lock
s0me0ne-unkn0wn Jun 8, 2024
bf45699
Merge remote-tracking branch 'origin/master' into s0me0ne/rename-assi…
s0me0ne-unkn0wn Jul 18, 2024
b25396e
Add prdoc
s0me0ne-unkn0wn Jul 18, 2024
a142540
Fix merge
s0me0ne-unkn0wn Jul 18, 2024
6250b8b
Merge remote-tracking branch 'origin/master' into s0me0ne/rename-assi…
s0me0ne-unkn0wn Jul 18, 2024
2c5bc98
A bunch of minor fixes
s0me0ne-unkn0wn Jul 18, 2024
db8f23d
Update prdoc
s0me0ne-unkn0wn Jul 19, 2024
d5fb704
Merge branch 'master' into s0me0ne/rename-assigner-on-demand
s0me0ne-unkn0wn Jul 19, 2024
2ffd833
Fix semver in prdoc
s0me0ne-unkn0wn Jul 22, 2024
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
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions polkadot/runtime/parachains/src/assigner_coretime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod mock_helpers;
mod tests;

use crate::{
assigner_on_demand, configuration,
configuration, on_demand,
paras::AssignCoretime,
scheduler::common::{Assignment, AssignmentProvider},
ParaId,
Expand Down Expand Up @@ -201,10 +201,7 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::config]
pub trait Config:
frame_system::Config + configuration::Config + assigner_on_demand::Config
{
}
pub trait Config: frame_system::Config + configuration::Config + on_demand::Config {}

/// Scheduled assignment sets.
///
Expand Down Expand Up @@ -281,8 +278,7 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pallet<T> {

match a_type {
CoreAssignment::Idle => None,
CoreAssignment::Pool =>
assigner_on_demand::Pallet::<T>::pop_assignment_for_core(core_idx),
CoreAssignment::Pool => on_demand::Pallet::<T>::pop_assignment_for_core(core_idx),
CoreAssignment::Task(para_id) => Some(Assignment::Bulk((*para_id).into())),
}
})
Expand All @@ -291,7 +287,7 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pallet<T> {
fn report_processed(assignment: Assignment) {
match assignment {
Assignment::Pool { para_id, core_index } =>
assigner_on_demand::Pallet::<T>::report_processed(para_id, core_index),
on_demand::Pallet::<T>::report_processed(para_id, core_index),
Assignment::Bulk(_) => {},
}
}
Expand All @@ -304,7 +300,7 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pallet<T> {
fn push_back_assignment(assignment: Assignment) {
match assignment {
Assignment::Pool { para_id, core_index } =>
assigner_on_demand::Pallet::<T>::push_back_assignment(para_id, core_index),
on_demand::Pallet::<T>::push_back_assignment(para_id, core_index),
Assignment::Bulk(_) => {
// Session changes are rough. We just drop assignments that did not make it on a
// session boundary. This seems sensible as bulk is region based. Meaning, even if
Expand Down
12 changes: 4 additions & 8 deletions polkadot/runtime/parachains/src/assigner_coretime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use crate::{
assigner_coretime::{mock_helpers::GenesisConfigBuilder, pallet::Error, Schedule},
initializer::SessionChangeNotification,
mock::{
new_test_ext, Balances, CoretimeAssigner, OnDemandAssigner, Paras, ParasShared,
RuntimeOrigin, Scheduler, System, Test,
new_test_ext, Balances, CoretimeAssigner, OnDemand, Paras, ParasShared, RuntimeOrigin,
Scheduler, System, Test,
},
paras::{ParaGenesisArgs, ParaKind},
scheduler::common::Assignment,
Expand Down Expand Up @@ -75,7 +75,7 @@ fn run_to_block(
Scheduler::initializer_initialize(b + 1);

// Update the spot traffic and revenue on every block.
OnDemandAssigner::on_initialize(b + 1);
OnDemand::on_initialize(b + 1);

// In the real runtime this is expected to be called by the `InclusionInherent` pallet.
Scheduler::free_cores_and_fill_claim_queue(BTreeMap::new(), b + 1);
Expand Down Expand Up @@ -527,11 +527,7 @@ fn pop_assignment_for_core_works() {
schedule_blank_para(para_id, ParaKind::Parathread);
Balances::make_free_balance_be(&alice, amt);
run_to_block(1, |n| if n == 1 { Some(Default::default()) } else { None });
assert_ok!(OnDemandAssigner::place_order_allow_death(
RuntimeOrigin::signed(alice),
amt,
para_id
));
assert_ok!(OnDemand::place_order_allow_death(RuntimeOrigin::signed(alice), amt, para_id));

// Case 1: Assignment idle
assert_ok!(CoretimeAssigner::assign_core(
Expand Down
12 changes: 6 additions & 6 deletions polkadot/runtime/parachains/src/coretime/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ mod benchmarks {
#[benchmark]
fn request_revenue_at() {
let root_origin = <T as frame_system::Config>::RuntimeOrigin::root();
let mhr = <T as assigner_on_demand::Config>::MaxHistoricalRevenue::get();
let mhr = <T as on_demand::Config>::MaxHistoricalRevenue::get();
frame_system::Pallet::<T>::set_block_number((mhr + 2).into());
let minimum_balance = <T as assigner_on_demand::Config>::Currency::minimum_balance();
let minimum_balance = <T as on_demand::Config>::Currency::minimum_balance();
let rev: BoundedVec<
<<T as assigner_on_demand::Config>::Currency as frame_support::traits::Currency<
<<T as on_demand::Config>::Currency as frame_support::traits::Currency<
T::AccountId,
>>::Balance,
T::MaxHistoricalRevenue,
> = BoundedVec::try_from((1..=mhr).map(|v| minimum_balance * v.into()).collect::<Vec<_>>())
.unwrap();
assigner_on_demand::Revenue::<T>::put(rev);
on_demand::Revenue::<T>::put(rev);

<T as assigner_on_demand::Config>::Currency::make_free_balance_be(
&<assigner_on_demand::Pallet<T>>::account_id(),
<T as on_demand::Config>::Currency::make_free_balance_be(
&<on_demand::Pallet<T>>::account_id(),
minimum_balance * (mhr * (mhr + 1)).into(),
);

Expand Down
16 changes: 8 additions & 8 deletions polkadot/runtime/parachains/src/coretime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ use xcm_executor::traits::TransactAsset;

use crate::{
assigner_coretime::{self, PartsOf57600},
assigner_on_demand,
initializer::{OnNewSession, SessionChangeNotification},
on_demand,
origin::{ensure_parachain, Origin},
};

Expand Down Expand Up @@ -116,6 +116,7 @@ enum CoretimeCalls {

#[frame_support::pallet]
pub mod pallet {

use crate::configuration;
use sp_runtime::traits::TryConvert;
use xcm::v4::InteriorLocation;
Expand All @@ -128,9 +129,7 @@ pub mod pallet {
pub struct Pallet<T>(_);

#[pallet::config]
pub trait Config:
frame_system::Config + assigner_coretime::Config + assigner_on_demand::Config
{
pub trait Config: frame_system::Config + assigner_coretime::Config + on_demand::Config {
type RuntimeOrigin: From<<Self as frame_system::Config>::RuntimeOrigin>
+ Into<result::Result<Origin, <Self as Config>::RuntimeOrigin>>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
Expand Down Expand Up @@ -308,7 +307,7 @@ impl<T: Config> Pallet<T> {
// When cannot be in the future.
ensure!(until_bnf <= now, Error::<T>::RequestedFutureRevenue);

let amount = <assigner_on_demand::Pallet<T>>::claim_revenue_until(until_bnf);
let amount = <on_demand::Pallet<T>>::claim_revenue_until(until_bnf);
log::debug!(target: LOG_TARGET, "Revenue info requested: {:?}", amount);

let raw_revenue: Balance = amount.try_into().map_err(|_| {
Expand Down Expand Up @@ -365,14 +364,15 @@ fn do_notify_revenue<T: Config>(when: BlockNumber, raw_revenue: Balance) -> Resu

if raw_revenue > 0 {
let on_demand_pot =
T::AccountToLocation::try_convert(&<assigner_on_demand::Pallet<T>>::account_id())
.map_err(|err| {
T::AccountToLocation::try_convert(&<on_demand::Pallet<T>>::account_id()).map_err(
|err| {
log::error!(
target: LOG_TARGET,
"Failed to convert on-demand pot account to XCM location: {err:?}",
);
XcmError::InvalidLocation
})?;
},
)?;

let withdrawn = T::AssetTransactor::withdraw_asset(&asset, &on_demand_pot, None)?;

Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/parachains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod assigner_coretime;
pub mod assigner_on_demand;
pub mod assigner_parachains;
pub mod configuration;
pub mod coretime;
Expand All @@ -34,6 +33,7 @@ pub mod hrmp;
pub mod inclusion;
pub mod initializer;
pub mod metrics;
pub mod on_demand;
pub mod origin;
pub mod paras;
pub mod paras_inherent;
Expand Down
13 changes: 6 additions & 7 deletions polkadot/runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
//! Mocks for all the traits.

use crate::{
assigner_coretime, assigner_on_demand, assigner_parachains, configuration, coretime, disputes,
dmp, hrmp,
assigner_coretime, assigner_parachains, configuration, coretime, disputes, dmp, hrmp,
inclusion::{self, AggregateMessageOrigin, UmpQueueId},
initializer, origin, paras,
initializer, on_demand, origin, paras,
paras::ParaKind,
paras_inherent, scheduler,
scheduler::common::AssignmentProvider,
Expand Down Expand Up @@ -78,7 +77,7 @@ frame_support::construct_runtime!(
Scheduler: scheduler,
MockAssigner: mock_assigner,
ParachainsAssigner: assigner_parachains,
OnDemandAssigner: assigner_on_demand,
OnDemand: on_demand,
CoretimeAssigner: assigner_coretime,
Coretime: coretime,
Initializer: initializer,
Expand Down Expand Up @@ -401,11 +400,11 @@ parameter_types! {
pub const OnDemandPalletId: PalletId = PalletId(*b"py/ondmd");
}

impl assigner_on_demand::Config for Test {
impl on_demand::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type TrafficDefaultValue = OnDemandTrafficDefaultValue;
type WeightInfo = crate::assigner_on_demand::TestWeightInfo;
type WeightInfo = crate::on_demand::TestWeightInfo;
type MaxHistoricalRevenue = MaxHistoricalRevenue;
type PalletId = OnDemandPalletId;
}
Expand Down Expand Up @@ -540,7 +539,7 @@ pub mod mock_assigner {
// We don't care about core affinity in the test assigner
fn report_processed(_assignment: Assignment) {}

// The results of this are tested in assigner_on_demand tests. No need to represent it
// The results of this are tested in on_demand tests. No need to represent it
// in the mock assigner.
fn push_back_assignment(_assignment: Assignment) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ mod benchmarks {
impl_benchmark_test_suite!(
Pallet,
crate::mock::new_test_ext(
crate::assigner_on_demand::mock_helpers::GenesisConfigBuilder::default().build()
crate::on_demand::mock_helpers::GenesisConfigBuilder::default().build()
),
crate::mock::Test
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod v0 {
mod v1 {
use super::*;

use crate::assigner_on_demand::LOG_TARGET;
use crate::on_demand::LOG_TARGET;

/// Migration to V1
pub struct UncheckedMigrateToV1<T>(core::marker::PhantomData<T>);
Expand Down Expand Up @@ -142,7 +142,7 @@ pub type MigrateV0ToV1<T> = VersionedMigration<
#[cfg(test)]
mod tests {
use super::{v0, v1, UncheckedOnRuntimeUpgrade, Weight};
use crate::mock::{new_test_ext, MockGenesisConfig, OnDemandAssigner, Test};
use crate::mock::{new_test_ext, MockGenesisConfig, OnDemand, Test};
use polkadot_primitives::Id as ParaId;

#[test]
Expand All @@ -159,7 +159,7 @@ mod tests {
let old_queue = v0::OnDemandQueue::<Test>::get();
assert_eq!(old_queue.len(), 5);
// New queue has 0 orders
assert_eq!(OnDemandAssigner::get_queue_status().size(), 0);
assert_eq!(OnDemand::get_queue_status().size(), 0);

// For tests, db weight is zero.
assert_eq!(
Expand All @@ -168,10 +168,10 @@ mod tests {
);

// New queue has 5 orders
assert_eq!(OnDemandAssigner::get_queue_status().size(), 5);
assert_eq!(OnDemand::get_queue_status().size(), 5);

// Compare each entry from the old queue with the entry in the new queue.
old_queue.iter().zip(OnDemandAssigner::get_free_entries().iter()).for_each(
old_queue.iter().zip(OnDemand::get_free_entries().iter()).for_each(
|(old_enq, new_enq)| {
assert_eq!(old_enq.para_id, new_enq.para_id);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use types::{
SpotTrafficCalculationErr,
};

const LOG_TARGET: &str = "runtime::parachains::assigner-on-demand";
const LOG_TARGET: &str = "runtime::parachains::on-demand";

pub use pallet::*;

Expand Down
Loading
Loading