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

fix(market): clean up provider_sectors when empty #1539

Merged
merged 2 commits into from
May 22, 2024

Conversation

rvagg
Copy link
Member

@rvagg rvagg commented May 16, 2024

We have this invariant complaining with nv22, no deal ids in sector X for the new ProviderSectors mapping: https://github.com/filecoin-project/go-state-types/blob/ad909a3d6ebef5ebc5688b4310e954e27da2203b/builtin/v13/market/invariants.go#L294

I don't think it's the migration that's the cause of this since it's checking the len==0 case: https://github.com/filecoin-project/go-state-types/blob/ad909a3d6ebef5ebc5688b4310e954e27da2203b/builtin/v13/migration/miner.go#L76-L78

We have 2 ways that we remove items from provider_sectors in actors, pop_sector_deal_ids and remove_sector_deal_ids. The former does cleanup when empty. But the latter just removes and saves. This PR proposes removing in both cases when we get to an empty DealID array.

Before I write any tests for this I want to check if this is correct. Also, if this is correct, should we propose a small cleanup migration for nv23 to get rid of the empty ones?

@rvagg rvagg requested review from Stebalien and anorth May 16, 2024 05:26
@rvagg rvagg force-pushed the rvagg/cleanup-provider-sectors branch 3 times, most recently from 7740632 to 88fda7f Compare May 16, 2024 05:34
@rvagg rvagg force-pushed the rvagg/cleanup-provider-sectors branch from 88fda7f to 20a3b45 Compare May 16, 2024 05:34
@Stebalien
Copy link
Member

Before I write any tests for this I want to check if this is correct.

It looks correct, yes.

Also, if this is correct, should we propose a small cleanup migration for nv23 to get rid of the empty ones?

IIRc, we need to do another cleanup of dead deals. I'd do that all at the same time.

Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this

actors/market/src/state.rs Outdated Show resolved Hide resolved
@rvagg
Copy link
Member Author

rvagg commented May 17, 2024

Also, if this is correct, should we propose a small cleanup migration for nv23 to get rid of the empty ones?

IIRc, we need to do another cleanup of dead deals. I'd do that all at the same time.

This would become a FIP thing, wouldn't it? Should I open a discussion about it? And why do we have dead deals to clean up? Was there some old behaviour we're still living with?

filecoin-project/FIPs#956 exists, do we just add it to the list in there?

@Stebalien
Copy link
Member

This would become a FIP thing, wouldn't it? Should I open a discussion about it? And why do we have dead deals to clean up? Was there some old behaviour we're still living with?

I'm talking about the change made in filecoin-project/FIPs#950.

But... that's a more complex migration than simply removing empty records. Honestly, I'd do nothing for now and add it to the todo list for the next time we touch this state.

@rvagg
Copy link
Member Author

rvagg commented May 21, 2024

OK, this is cleaned up now and has test coverage. I didn't need to add any more tests, just make it much more strict about what it expected to be in ProvidersSectors in the various cases.

With the new test changes but with the old logic in place, these tests would fail as they hit the case where a removal ends up with a zero-length list:

  • deal_is_correctly_processed_if_first_cron_after_expiry
  • expired_deal_should_unlock_the_remaining_client_and_provider_locked_balance_after_payment_and_deal_should_be_deleted
  • payment_for_a_deal_if_deal_is_already_expired_before_a_cron_tick
  • regular_payments_till_deal_expires_and_then_locked_funds_are_unlocked

@rvagg rvagg requested a review from anorth May 21, 2024 01:57
@rvagg rvagg force-pushed the rvagg/cleanup-provider-sectors branch from 83b5a3c to da20b65 Compare May 21, 2024 02:00
@rvagg rvagg force-pushed the rvagg/cleanup-provider-sectors branch from da20b65 to 444a205 Compare May 21, 2024 02:20
@rvagg rvagg added this pull request to the merge queue May 22, 2024
Merged via the queue into master with commit ab2818e May 22, 2024
14 checks passed
@rvagg rvagg deleted the rvagg/cleanup-provider-sectors branch May 22, 2024 03:05
ZenGround0 pushed a commit that referenced this pull request Jun 25, 2024
* fix(market): clean up provider_sectors when empty

* fix(market): extend tests to ensure no empty sector/deal map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants