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
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
more checks
  • Loading branch information
Szegoo committed May 24, 2024
commit 5d29cd3bb22a3e4cbf2cd86b3b960098ac8238d9
30 changes: 23 additions & 7 deletions substrate/frame/broker/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,31 +1483,47 @@ fn enable_auto_renewal_with_end_hint_works() {
};
// Each lease-holding task should be allowed to renew. Although the `when` field will
// likely be set to a later timeslice.
AllowedRenewals::<Test>::insert(AllowedRenewalId { core: 1, when: 10 }, &record);
AllowedRenewals::<Test>::insert(AllowedRenewalId { core: 0, when: 10 }, &record);

endow(1001, 1000);

// Will fail if we don't provide the end hint since it expects it to be at next sale start
// or end.
assert_noop!(Broker::do_enable_auto_renew(1001, 1, None), Error::<Test>::NotAllowed);
assert_noop!(Broker::do_enable_auto_renew(1001, 0, None), Error::<Test>::NotAllowed);

assert_ok!(Broker::do_enable_auto_renew(1001, 1, Some(10)));
assert_ok!(Broker::do_enable_auto_renew(1001, 0, Some(10)));
assert_eq!(
AutoRenewals::<Test>::get().to_vec(),
vec![AutoRenewalRecord { core: 1, task: 1001, begin: 10 },]
vec![AutoRenewalRecord { core: 0, task: 1001, begin: 10 },]
);
System::assert_has_event(Event::<Test>::AutoRenewalEnabled { core: 1, task: 1001 }.into());
System::assert_has_event(Event::<Test>::AutoRenewalEnabled { core: 0, task: 1001 }.into());

// Next cycle starting at 7.
advance_to(7);

// Ensure that the renewal didn't happen by checking that the balance remained the same, as
// the task has a lease until ts 13.
// Ensure that the renewal didn't happen by checking that the balance remained the same
// since it still has a lease.
assert_eq!(balance(1001), 1000);

// The next sale starts at 13. The renewal should happen now and the task should be charged.
advance_to(13);
assert_eq!(balance(1001), 900);

System::assert_has_event(
Event::<Test>::Renewed {
who: 1001, // sovereign account
old_core: 0,
core: 0,
price: 100,
begin: 10,
duration: 3,
workload: Schedule::truncate_from(vec![ScheduleItem {
assignment: Task(1001),
mask: CoreMask::complete(),
}]),
}
.into(),
);
});
}

Expand Down
Loading