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: use the correct equal function in DiffDealStates #1319

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion chain/actors/builtin/market/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ func (d *marketStatesDiffContainer) Modify(key uint64, from, to *cbg.Deferred) e
if err != nil {
return err
}
if dsFrom != dsTo {

log.Warnf("got the modify: key: %v, slash_epoch: %v", key, dsTo.SlashEpoch())
if !dsFrom.Equals(dsTo) {
d.Results.Modified = append(d.Results.Modified, DealStateChange{abi.DealID(key), dsFrom, dsTo})
}
return nil
Expand Down
114 changes: 79 additions & 35 deletions tasks/actorstate/market/deal_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,87 @@ func (DealStateExtractor) Extract(ctx context.Context, a actorstate.ActorInfo, n
return out, nil
}

changed, err := ec.CurrState.StatesChanged(ec.PrevState)
if err != nil {
return nil, fmt.Errorf("checking for deal state changes: %w", err)
}
// Test
// Store the whole deal and check
var out marketmodel.MarketDealStates
totalDeal := 0
matchCount := 0
currDealStates.ForEach(func(id abi.DealID, ds market.DealState) error {
totalDeal += 1

if !changed {
return nil, nil
}
// After nv22, we can not get the slash_epoch
// After nv23, we can not get the last_updated_epoch
if ds.SlashEpoch() >= 3855360 || ds.LastUpdatedEpoch() > 4154640 {
log.Infof("Got the updated deal state: [deal id=%v], last_updated_epoch=%v, slash_epoch=%v", id, ds.LastUpdatedEpoch(), ds.SlashEpoch())
out = append(out, &marketmodel.MarketDealState{
Height: int64(ec.CurrTs.Height()),
DealID: uint64(id),
SectorStartEpoch: int64(ds.SectorStartEpoch()),
LastUpdateEpoch: int64(ds.LastUpdatedEpoch()),
SlashEpoch: int64(ds.SlashEpoch()),
StateRoot: ec.CurrTs.ParentState().String(),
})
matchCount += 1
}

changes, err := market.DiffDealStates(ctx, ec.Store, ec.PrevState, ec.CurrState)
if err != nil {
return nil, fmt.Errorf("diffing deal states: %w", err)
}
return nil
})

out := make(marketmodel.MarketDealStates, len(changes.Added)+len(changes.Modified))
idx := 0
for _, add := range changes.Added {
out[idx] = &marketmodel.MarketDealState{
Height: int64(ec.CurrTs.Height()),
DealID: uint64(add.ID),
SectorStartEpoch: int64(add.Deal.SectorStartEpoch()),
LastUpdateEpoch: int64(add.Deal.LastUpdatedEpoch()),
SlashEpoch: int64(add.Deal.SlashEpoch()),
StateRoot: ec.CurrTs.ParentState().String(),
}
idx++
}
for _, mod := range changes.Modified {
out[idx] = &marketmodel.MarketDealState{
Height: int64(ec.CurrTs.Height()),
DealID: uint64(mod.ID),
SectorStartEpoch: int64(mod.To.SectorStartEpoch()),
LastUpdateEpoch: int64(mod.To.LastUpdatedEpoch()),
SlashEpoch: int64(mod.To.SlashEpoch()),
StateRoot: ec.CurrTs.ParentState().String(),
}
idx++
}
log.Infof("Got total deal %v and get the %v match deal", totalDeal, matchCount)
return out, nil

//changed, err := ec.CurrState.StatesChanged(ec.PrevState)
//if err != nil {
// return nil, fmt.Errorf("checking for deal state changes: %w", err)
//}

//if !changed {
// return nil, nil
//}

//changes, err := market.DiffDealStates(ctx, ec.Store, ec.PrevState, ec.CurrState)
//if err != nil {
// return nil, fmt.Errorf("diffing deal states: %w", err)
//}

// out := make(marketmodel.MarketDealStates, len(changes.Added)+len(changes.Modified)+len(changes.Removed))
// idx := 0
//
// for _, add := range changes.Added {
// out[idx] = &marketmodel.MarketDealState{
// Height: int64(ec.CurrTs.Height()),
// DealID: uint64(add.ID),
// SectorStartEpoch: int64(add.Deal.SectorStartEpoch()),
// LastUpdateEpoch: int64(add.Deal.LastUpdatedEpoch()),
// SlashEpoch: int64(add.Deal.SlashEpoch()),
// StateRoot: ec.CurrTs.ParentState().String(),
// }
// idx++
// }
//
// for _, mod := range changes.Modified {
// out[idx] = &marketmodel.MarketDealState{
// Height: int64(ec.CurrTs.Height()),
// DealID: uint64(mod.ID),
// SectorStartEpoch: int64(mod.To.SectorStartEpoch()),
// LastUpdateEpoch: int64(mod.To.LastUpdatedEpoch()),
// SlashEpoch: int64(mod.To.SlashEpoch()),
// StateRoot: ec.CurrTs.ParentState().String(),
// }
// idx++
// }
//
// for _, mod := range changes.Removed {
// out[idx] = &marketmodel.MarketDealState{
// Height: int64(ec.CurrTs.Height()),
// DealID: uint64(mod.ID),
// SectorStartEpoch: int64(mod.Deal.SectorStartEpoch()),
// LastUpdateEpoch: int64(mod.Deal.LastUpdatedEpoch()),
// SlashEpoch: int64(mod.Deal.SlashEpoch()),
// StateRoot: ec.CurrTs.ParentState().String(),
// }
// idx++
// }
//
// return out, nil
}