-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(miner): add DDO-friendly StateMinerInitialPledgeForSector #12384
Conversation
d37b243
to
16ba134
Compare
Also needs some testing .. gotta figure out a good path to testing this API. |
16ba134
to
c57daac
Compare
More background as I dig further on this: filecoin-project/builtin-actors#1573 |
As per filecoin-project/builtin-actors#1573 I think we can simplify the API even further; here are the options as I see them:
|
3rd would be the best implementation in my opinion. It disconnects the API from how sector metadata is handled by any implementation. Finding verified size and size are easy enough. This would also allow external parties (not miner implementations) to find collateral requirements without looking at the chain history. |
4357d93
to
53ab3da
Compare
Still not sure how to test this, I started writing a unit test but got hung up on trying to build a usable state tree to run this against! |
7c23132
to
9bb78b0
Compare
I came up with a way to test this in an itest, described in there like so: // TestPledgeCalculations tests the pledge calculations for sectors with different piece combinations
// and verified deals.
// We first verify that the deprecated pledge calculation that uses PreCommit with Deal information
// matches the new one that just uses sector size, duration and a simple verified size.
// Then we compare the pledge calculations for sectors with different piece combinations and
// verified deals according to expected rules about verified pieces requiring 10x pledge.
// Most of the complication in this test is for setting up verified deals and allocations so we can
// run the deprecated pledge calculation on a valid precommit. We onboard and test the following types of sectors:
Then we compare the outputs of Then we compare our expectations on the pledge outputs from them:
|
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 haven't reviewed the calculation itself as I don't know how that is supposed to work. Rest of it looks good. Thank you doing the miner side as well. I love the test. Simple and efficient.
759a6e8
to
a032c1b
Compare
Added some more documentation both in the itest and in the API so a future confused maintainer will understand what's going on with this DealID thing. |
bfbb4fa
to
6f0cd11
Compare
6f0cd11
to
a0d2ae8
Compare
Calling for objections before I land this. |
Not at the moment because we don't have a choice. Existing method is broken. If this method created/fixed both Curio and miner will depend on it instead of doing calculations themselves. |
|
There are no open issues because we are tracking this one. Once this is merged, we will be switching immediately to this method instead of doing the calculation on miner side. This PR already has changes for lotus-miner courtesy Rod. I will be switching to latest lotus dependency in Curio as soon as this is merged and get rid the manual calculation there. This API is not only useful for storage implementations but will also allow external parties to calculate pledges as discussed before. This will open up a whole new set of use cases. |
c55777c
to
b714b82
Compare
Fixes: #12369 deprecate StateMinerInitialPledgeCollateral since it only accounts for deals in PCI, which aren't present in a DDO world
a2fdf86
to
f7244dd
Compare
f7244dd
to
910288c
Compare
…tion Regression introduced by refactoring in #12384 where the NV16 special case was missed and the full sector weight calculation was applied. The lack of this special case essentially reverts FIP-0034 for this API, but not for actors which would have a different PCD calculation.
Fixes: #12369
Here's the QAP calculation in actors that we have to work around for pledge calculation: https://github.com/filecoin-project/builtin-actors/blob/82d02e58f9ef456aeaf2a6c737562ac97b22b244/actors/miner/src/lib.rs#L5530-L5539
When PreCommits contained deal information, the QAP calculation works out the ~same because the deals can tells us how much verified vs unverified space there is because the deals contain that information. This calculation is still done in actors for
ProveCommitAggregate
andProveReplicaUpdates
, but from what I can tell we don't even use them anymore in lotus-miner (I'd like confirmation of this from someone that knows for sure beyond my simple grepping). So currently the only path to QAP calculation that we take is with piece manifests, which don't have deal information, they only have (1) size and (2) verified or not.In Actors, the piece manifest path goes through here: https://github.com/filecoin-project/builtin-actors/blob/82d02e58f9ef456aeaf2a6c737562ac97b22b244/actors/miner/src/lib.rs#L5784-L5798 where we're simply adding up piece size and verified claim size (the caveat here is that we're actually doing the claim in actors so it must be successful, here are don't know for sure it will work out). If we're using filler pieces to pad out an un-full sector then that would come in to play here too I suppose, the piece manifest doesn't care about deals.
So, for pledge calculation, we only need the current reward state and info about the sector being onboarded: it's size, duration and the piece list. We don't actually need the PreCommit for that sector to work this out, although we could use it to figure out duration and size if we wanted. But without the piece manifest, which isn't on the PreCommit for DDO, we don't get an accurate result: there are no deals, so both "unverified space" and "verified space" end up being zero, hence the under-calculation of pledge. We at least need to supply the piece manifest, which has the information we need.
I've opted here for introducing a new API,
StateMinerInitialPledgeForSector
, which does this, but I've made some choices here which could be debated and I'd like feedback please:SectorActivationManifest
which contains the piece manifests and the sector number, and then we can look up the precommit. It would make the args simpler, but make the method less flexible.StateMinerInitialPledgeCollateral
did. It does some basic checks on deals to make sure they can activate: https://github.com/filecoin-project/go-state-types/blob/ee0897a7c86ea81d6a0d3b4ca3cc90cb81a1a99d/builtin/v14/market/market_state.go#L207-L219 - do we want to do something like this for claims?Additionally, storage/pipeline/pledge.go does some of this work already. It's used for PRU3 collateral diff calculation: https://github.com/filecoin-project/lotus/blob/release/v1.28.1/storage/pipeline/states_replica_update.go#L134-L150, and I think that's wrong. I think we should be able to use this same API to supply the new piece manifest. But I'd like confirmation and help from @filecoin-project/curio team on that please. Note that in pledge.go it counts deals, not pieces, so it's going to get messed up on filler pieces, which would make partially-full sectors problematic.