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

pallet_broker: Support renewing leases expired in a previous period #4089

Merged
merged 8 commits into from
Apr 15, 2024

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Apr 11, 2024

Part of: #4107

@bkchr bkchr requested a review from a team as a code owner April 11, 2024 16:19
Copy link
Member

@eskimor eskimor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@bkchr bkchr added the T2-pallets This PR/Issue is related to a particular pallet. label Apr 12, 2024
@bkchr bkchr changed the title pallet_broker: Fix renew for expired leases pallet_broker: Support renewing leases expired in a previous period Apr 12, 2024
@bkchr bkchr requested review from seadanda and eskimor April 12, 2024 14:21
Copy link
Member

@eskimor eskimor left a 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() {
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Contributor

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));
Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor

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.
Copy link
Member

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() {
Copy link
Contributor

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

substrate/frame/broker/src/mock.rs Show resolved Hide resolved
@bkchr bkchr enabled auto-merge April 12, 2024 17:41
@bkchr bkchr added this pull request to the merge queue Apr 15, 2024
Merged via the queue into master with commit 6f73b74 Apr 15, 2024
133 of 137 checks passed
@bkchr bkchr deleted the bkchr-broker-renew-leases branch April 15, 2024 13:32
seadanda added a commit that referenced this pull request Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants