-
Notifications
You must be signed in to change notification settings - Fork 732
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
pallet_broker: Support renewing leases expired in a previous period #4089
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits, but logic wise looks good.
|
||
/// Ensure that a lease that ended before `start_sales` was called can be renewed. | ||
#[test] | ||
fn renewal_works_leases_ended_before_start_sales() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more like renewal_works_for_leases_ended_before_period_1()
?
And description:
Bootstrapping: Ensure that leases that end right in the first sale period can still be renewed, despite the fact that renewal rights are determined one period before the corresponding sale period.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean this lease ends before start_sales
:P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but the issue is wider than that. Even leases after start_sales
would not have renewal rights, without your fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha I just called them short_leases
in mine
)); | ||
|
||
// This intializes the first sale and the period 0. | ||
assert_ok!(Broker::do_start_sales(100, 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really want those newtypes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean wtf. We can also start coding binary directly:
000111011110000011111000111
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At that stage we could rewrite it all in VHDL and run it on FPGAs
// Will the lease expire at the end of the period? | ||
let expire = until < region_end; | ||
if expire { | ||
// last time for this one - make it renewable in this sale. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the next sale actually.
|
||
/// Ensure that a lease that ended before `start_sales` was called can be renewed. | ||
#[test] | ||
fn renewal_works_leases_ended_before_start_sales() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha I just called them short_leases
in mine
Part of: #4107 Co-authored-by: Bastian Köcher <[email protected]>
Part of: #4107