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

Coretime auto-renew #4424

Merged
merged 53 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
afb5e75
start
Szegoo May 4, 2024
2716e0f
setup
Szegoo May 8, 2024
e443c9e
outlining the main logic
Szegoo May 9, 2024
2a8a68b
bounded vec
Szegoo May 10, 2024
8df2f81
resolvinig some todos
Szegoo May 11, 2024
82859ad
auto-renew for legacy leases
Szegoo May 11, 2024
e2a4dd5
init test
Szegoo May 11, 2024
9c1c7e3
more tests
Szegoo May 12, 2024
c7ccf5a
enable_auto_renew_renews
Szegoo May 12, 2024
c3eaa21
different approach
Szegoo May 12, 2024
edffbfc
docs
Szegoo May 13, 2024
68f244c
enable_auto_renewal_with_end_hint_works
Szegoo May 13, 2024
893fa9d
auto_renewal_works
Szegoo May 15, 2024
0b50a58
progress
Szegoo May 15, 2024
9dc9b6a
store account instead of task
Szegoo May 15, 2024
9baa77a
fix builds
Szegoo May 15, 2024
ee7e3c4
disable auto-renewal
Szegoo May 17, 2024
e0f1c71
disable auto renew test
Szegoo May 17, 2024
1a46abc
docs
Szegoo May 17, 2024
2f17544
account for changing core indices
Szegoo May 23, 2024
63b6f66
fix
Szegoo May 23, 2024
aaba50d
bench enable_auto_renew
Szegoo May 23, 2024
7d682e6
bench disable & auto_renew
Szegoo May 23, 2024
af8f109
weights
Szegoo May 23, 2024
f22c451
fix
Szegoo May 23, 2024
a6c0676
dummy weights
Szegoo May 23, 2024
a4f3b6c
don't auto renew when not needed
Szegoo May 24, 2024
4f18949
fix auto renewal
Szegoo May 24, 2024
5d29cd3
more checks
Szegoo May 24, 2024
0d9e91d
test fixes/improvements
Szegoo May 27, 2024
dad2b91
merge
Szegoo May 30, 2024
88c9ce1
merge fix
Szegoo May 30, 2024
17e0ee5
cleanup | benchmarks: TODO
Szegoo May 30, 2024
8be2d02
Update substrate/frame/broker/src/dispatchable_impls.rs
Szegoo May 31, 2024
c8fa5f8
Update substrate/frame/broker/src/types.rs
Szegoo May 31, 2024
7d887ab
Update substrate/frame/broker/src/lib.rs
Szegoo May 31, 2024
78a203f
resolve comments
Szegoo May 31, 2024
5f02e32
cleanup
Szegoo May 31, 2024
b0aa972
rename
Szegoo May 31, 2024
de89f30
comment
Szegoo May 31, 2024
7259f41
fix benchmarks
Szegoo May 31, 2024
9a23b2f
cleanup
Szegoo Jun 3, 2024
0c4e651
simplify logic
Szegoo Jun 3, 2024
ef9c4fb
fix benchmarks
Szegoo Jul 1, 2024
4d35d2b
Merge branch 'master' into auto-renew
Szegoo Jul 1, 2024
15d9e1b
merge fixes
Szegoo Jul 1, 2024
eff4ee7
benchmark fix
Szegoo Jul 1, 2024
61f466d
resolve conflicts
Szegoo Jul 30, 2024
d2041f1
prdoc
Szegoo Jul 30, 2024
7155233
improve docs
Szegoo Jul 30, 2024
9a90fbd
improve comments
Szegoo Aug 1, 2024
0cf0dad
Merge branch 'master' into auto-renew
Szegoo Aug 1, 2024
c1fc125
Merge branch 'master' into auto-renew
Szegoo Aug 3, 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
Prev Previous commit
Next Next commit
merge fixes
  • Loading branch information
Szegoo committed Jul 1, 2024
commit 15d9e1b6c0aff5bd535d57c9b7ef15296014240f
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use frame_support::{
},
};
use frame_system::Pallet as System;
use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, RCBlockNumberOf, TaskId};
use pallet_broker::{
CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, RCBlockNumberOf, TaskId,
};
use parachains_common::{AccountId, Balance};
use rococo_runtime_constants::system_parachain::coretime;
use sp_runtime::traits::{AccountIdConversion, MaybeConvert};
Expand Down
10 changes: 5 additions & 5 deletions substrate/frame/broker/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ mod benches {
advance_to::<T>(2);

// We assume max auto renewals for worst case.
(0..T::MaxAutoRenewals::get()-1).try_for_each(|indx| -> Result<(), BenchmarkError> {
(0..T::MaxAutoRenewals::get() - 1).try_for_each(|indx| -> Result<(), BenchmarkError> {
let task = 1000 + indx;
let caller: T::AccountId = T::SovereignAccountOf::maybe_convert(task)
.expect("Failed to get sovereign account");
Expand Down Expand Up @@ -1077,7 +1077,7 @@ mod benches {
advance_to::<T>(2);

// We assume max auto renewals for worst case.
(0..T::MaxAutoRenewals::get()-1).try_for_each(|indx| -> Result<(), BenchmarkError> {
(0..T::MaxAutoRenewals::get() - 1).try_for_each(|indx| -> Result<(), BenchmarkError> {
let task = 1000 + indx;
let caller: T::AccountId = T::SovereignAccountOf::maybe_convert(task)
.expect("Failed to get sovereign account");
Expand All @@ -1097,14 +1097,14 @@ mod benches {
Ok(())
})?;

let caller: T::AccountId = T::SovereignAccountOf::maybe_convert(1000)
.expect("Failed to get sovereign account");
let caller: T::AccountId =
T::SovereignAccountOf::maybe_convert(1000).expect("Failed to get sovereign account");
#[extrinsic_call]
_(RawOrigin::Signed(caller), _core, 1000);

assert_last_event::<T>(Event::AutoRenewalDisabled { core: _core, task: 1000 }.into());

Ok(())
Ok(())
}

fn on_new_timeslice() -> Result<(), BenchmarkError> {
Expand Down
30 changes: 15 additions & 15 deletions substrate/frame/broker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,17 @@ pub mod pallet {
Ok(())
}

#[pallet::call_index(20)]
#[pallet::weight(T::WeightInfo::notify_revenue())]
pub fn notify_revenue(
origin: OriginFor<T>,
revenue: OnDemandRevenueRecordOf<T>,
) -> DispatchResult {
T::AdminOrigin::ensure_origin_or_root(origin)?;
Self::do_notify_revenue(revenue)?;
Ok(())
}

/// Extrinsic for enabling auto renewal.
///
/// Callable by the sovereign account of the task on the specified core. This account
Expand All @@ -883,8 +894,8 @@ pub mod pallet {
/// - `task`: The task for which we want to enable auto renewal.
/// - `workload_end_hint` parameter should be used when enabling auto-renewal for
/// the core which holds a legacy lease, as it would be inefficient to look it up otherwise.
#[pallet::call_index(20)]
#[pallet::weight(T::WeightInfo::notify_core_count())]
#[pallet::call_index(21)]
#[pallet::weight(T::WeightInfo::enable_auto_renew())]
pub fn enable_auto_renew(
origin: OriginFor<T>,
core: CoreIndex,
Expand All @@ -909,8 +920,8 @@ pub mod pallet {
/// - `origin`: Must be the sovereign account of the task.
/// - `core`: The core for which we want to disable auto renewal.
/// - `task`: The task for which we want to disable auto renewal.
#[pallet::call_index(21)]
#[pallet::weight(T::WeightInfo::notify_core_count())]
#[pallet::call_index(22)]
#[pallet::weight(T::WeightInfo::disable_auto_renew())]
pub fn disable_auto_renew(
origin: OriginFor<T>,
core: CoreIndex,
Expand All @@ -925,17 +936,6 @@ pub mod pallet {

Self::do_disable_auto_renew(core, task)?;

Ok(())
}

#[pallet::call_index(20)]
#[pallet::weight(T::WeightInfo::notify_revenue())]
pub fn notify_revenue(
origin: OriginFor<T>,
revenue: OnDemandRevenueRecordOf<T>,
) -> DispatchResult {
T::AdminOrigin::ensure_origin_or_root(origin)?;
Self::do_notify_revenue(revenue)?;
Ok(())
}

Expand Down
36 changes: 36 additions & 0 deletions substrate/frame/broker/src/weights.rs

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

Loading