-
Notifications
You must be signed in to change notification settings - Fork 38
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
DDO types, nv22 edition #236
Conversation
7ef7f4a
to
dda87e7
Compare
dda87e7
to
0e53b05
Compare
7a85e6f
to
3fa8f86
Compare
403d021
to
0439243
Compare
231a5d9
to
8092cb6
Compare
b5cf7b2
to
8092cb6
Compare
54df042
to
4abc56a
Compare
4d13729
to
b4466b2
Compare
…ProveReplicaUpdates3Params Ref: filecoin-project/FIPs#934
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.
Some notes.
|
||
fmt.Println("sector before: ", string(pjsonb)) | ||
fmt.Println("sector after: ", string(pjson)) | ||
return nil, xerrors.Errorf("WHAT?! sector %d modified, this not supported and not supposed to happen", i) // todo: is it? Can't happen w/o a deep, deep reorg, and even then we wouldn't use the cache?? |
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 agree with all of this, but why not just deal with this case too? You know what sectorBefore and sectorAfter's deals are, so you can:
- set the mapping for
sectorAfter
s deals easily - look up the entries for
sectorBefore
's deals- if they map to
sectorNo
, delete them -- if they need to get updated to something else, that will happen later - if they map to something other than
sectorNo
leave them alone, they've presumably already been cleaned up
- if they map to
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.
or alternatively, add sectorBefore
s deals to removedDealToSector
?
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.
Do we even use the cache through reorgs? If not this really can't happen, and if we do use the cache through reorgs I imagine the market migrator makes a lot of invalid assumptions too.
(also this reminds me that removedDealToSector is actually no longer used)
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.
Yes, we use the cache through reorgs, and should be fully reorg-resistant. There is no assumption that the state it ran on is an ancestor of the current state tree. Instead, the assumption is just that if we cached that X -> Y, we can use that information to calculate X' -> Y', where X and X' probably have some commonalities.
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.
What are some of the invalid assumptions you're concerned about?
We could tweak how Lotus uses the cache to wipe it if we know its base state was re-orged out, but I'd rather not do that.
addProviderSectorEntry := func(deal abi.DealID, newState *market13.DealState) (abi.SectorNumber, error) { | ||
sid, ok := m.providerSectors.dealToSector[deal] | ||
if !ok { | ||
return 0, xerrors.Errorf("deal %d not found in providerSectors", deal) // todo is this normal and possible?? |
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 don't think so, but I'm not sure.
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.
Isn't this the case annotated "// FIP: if such a sector cannot be found, assert that the deal's end epoch has passed and use sector ID 0" in the FromScratch case (in which case yes)?
Adding the FIP spec as comments in this version too would be helpful. Though this code isn't setting the deal state sector number.
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.
This function is called inside of a oldState.SlashEpoch != -1
so I believe that this isn't this case, there the sector number will correctly be set to zero
case amt.Add: // both in case of chain going forward and chain reorg this is just new deals
var oldState market12.DealState
if err := oldState.UnmarshalCBOR(bytes.NewReader(change.After.Raw)); err != nil {
return cid.Cid{}, cid.Cid{}, xerrors.Errorf("failed to unmarshal old state: %w", err)
}
var newState market13.DealState
newState.SlashEpoch = oldState.SlashEpoch
newState.LastUpdatedEpoch = oldState.LastUpdatedEpoch
newState.SectorStartEpoch = oldState.SectorStartEpoch
newState.SectorNumber = 0 // terminated / not found (?)
if oldState.SlashEpoch == -1 {
si, err := addProviderSectorEntry(deal)
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.
The case annotated "// todo is this normal and possible??" seems to be returning an error where it shouldn't.
The FromScratch version looks good but is lacking an assertion that the FIP specifies.
The complexity of the Diff version makes it much harder to verify. I didn't see anything wrong from a FIP specification point of view, but I don't understand the diff mechanics in depth.
} else { | ||
//fmt.Printf("deal %d not found in providerSectors: %v\n", deal, oldState) | ||
|
||
newState.SectorNumber = 0 // FIP: if such a sector cannot be found, assert that the deal's end epoch has passed and use sector ID 0 |
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.
This isn't making the assertion that the FIP specifies. If there's a good reason for that, can it be written in the comment? Should the FIP be changed?
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 believe the assert is caught by this invariant
acc.Require((deal.SectorNumber == sectorDeal.SectorNumber) || (deal.SectorNumber == 0 && deal.SlashEpoch != -1),
"deal sector number %d does not match sector %d for miner %v (ds: %#v; ss %#v)",
Will add a comment here
addProviderSectorEntry := func(deal abi.DealID, newState *market13.DealState) (abi.SectorNumber, error) { | ||
sid, ok := m.providerSectors.dealToSector[deal] | ||
if !ok { | ||
return 0, xerrors.Errorf("deal %d not found in providerSectors", deal) // todo is this normal and possible?? |
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.
Isn't this the case annotated "// FIP: if such a sector cannot be found, assert that the deal's end epoch has passed and use sector ID 0" in the FromScratch case (in which case yes)?
Adding the FIP spec as comments in this version too would be helpful. Though this code isn't setting the deal state sector number.
846d70c
to
11fc27c
Compare
Closing in favour of #246 |
For filecoin-project/lotus#11226
Resurrects #209 for nv22
On top of #234