diff --git a/chain/actors/builtin/market/diff.go b/chain/actors/builtin/market/diff.go index 7d112f85..6a5ef41a 100644 --- a/chain/actors/builtin/market/diff.go +++ b/chain/actors/builtin/market/diff.go @@ -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 diff --git a/tasks/actorstate/market/deal_state.go b/tasks/actorstate/market/deal_state.go index 902046a2..fee901df 100644 --- a/tasks/actorstate/market/deal_state.go +++ b/tasks/actorstate/market/deal_state.go @@ -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 }