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

feat: FIP-0076: add new invariants #245

Merged
merged 2 commits into from
Feb 14, 2024
Merged

feat: FIP-0076: add new invariants #245

merged 2 commits into from
Feb 14, 2024

Conversation

arajasek
Copy link
Contributor

These are new invariants that cover FIP-0076 changes.

Partly extracted from #236, with additional invariants based on filecoin-project/builtin-actors#1520.

continue
}

sector := minerSummary.SectorsWithDeals[sectorID.Number]
Copy link
Member

Choose a reason for hiding this comment

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

This is going to break soon after the upgrade as new sectors are added (which won't record deal IDs). This also won't catch deals we failed to migrate.

IMO, we'd be better off if we:

  1. Iterated over the ProviderSectors to create a reverse deal -> sector ID index, checking for duplicates as we do that.
  2. Then, iterate over all miners, then all SectorsWithDeals for each miner, making sure that the deal got migrated into the ProviderSectors table.

Copy link
Member

Choose a reason for hiding this comment

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

I guess there's a TODO below, but we might as well make this "correct" to start with (unless I'm missing something). I.e., the invariant is: every deal in a sector is also listed in the market. (is that correct? even when they expire?)

If we do want to catch "unknown" deals, we could, e.g., count the found deals and make sure the lengths match. (then we can remove that additional check when we're all done with the migration, or maybe have a way to print a warning?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Stebalien Unfortunately, I don't think your proposed invariant works -- deals might have left the market (both its Proposals and ProviderSectors fields), while still being in the miner sector data. So really all I can think to do here is:

  • ensure no duplicates
  • ensure that for the immediately-after-migration state anything in ProviderSectors is in the corresponding miner's sector data

After that, I think this entire invariant kinda goes out the window due to the decoupling. There will be deals in sector data that aren't in either the market's proposals or ProviderSectors fields. And there will be deals in the proposals and ProviderSectors fields that are NOT in miner sector data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anorth If you could chime in here, that would be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding making it "correct" to start with, I do somewhat strongly want to keep as much migration-specific invariants here, it'll make testing the migration significantly easier, and that is very important IMO.

Copy link
Member

Choose a reason for hiding this comment

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

Hm. Yeah, you're right. However, I still think going from miner -> market is better than going from market -> miner because it'll help us identify deals that haven't been migrated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But IIUC we don't want every deal found in miner data to be in ProviderSectors, only the specific subset as detailed here. I could implement that very specific check, but at that point the "invariant" is just rewriting the migration, I think.

Copy link
Member

Choose a reason for hiding this comment

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

Ah... you're right. We don't have a 1:1 mapping anyways.

builtin/v13/market/invariants.go Outdated Show resolved Hide resolved
builtin/v13/market/invariants.go Show resolved Hide resolved
@arajasek arajasek merged commit 4f42fc7 into master Feb 14, 2024
5 checks passed
@arajasek arajasek deleted the asr/fip0076-invariants branch February 14, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ☑️ Done (Archive)
Development

Successfully merging this pull request may close these issues.

2 participants