Skip to content

Commit

Permalink
feat: FIP-0076: implement migration to populate ProviderSectors (#246)
Browse files Browse the repository at this point in the history
* feat: FIP-0076: implement migration to populate ProviderSectors

v13: Address migration review

v13: Handle deal proposal in case of reorgs

v13: organize imports

v13: perf nit: avoid repeated map lookups

implement new rules for uncached operations

implement new rules for cached operations

* Map: Add and test IsEmpty method

* address review

* fixup invariant, fix lint
  • Loading branch information
arajasek authored Feb 28, 2024
1 parent a4dca91 commit 9c5492f
Show file tree
Hide file tree
Showing 21 changed files with 878 additions and 60 deletions.
4 changes: 4 additions & 0 deletions builtin/v10/migration/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ func (m initActorMigrator) MigrateState(ctx context.Context, store cbor.IpldStor
NewHead: outHead,
}, nil
}

func (m initActorMigrator) Deferred() bool {
return false
}
4 changes: 4 additions & 0 deletions builtin/v10/migration/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ func (m systemActorMigrator) MigrateState(ctx context.Context, store cbor.IpldSt
NewHead: stateHead,
}, nil
}

func (m systemActorMigrator) Deferred() bool {
return false
}
4 changes: 4 additions & 0 deletions builtin/v11/migration/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ func (m minerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore, i
NewHead: newHead,
}, nil
}

func (m minerMigrator) Deferred() bool {
return false
}
4 changes: 4 additions & 0 deletions builtin/v11/migration/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,7 @@ func (m powerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore, i
NewHead: newHead,
}, nil
}

func (m powerMigrator) Deferred() bool {
return false
}
4 changes: 4 additions & 0 deletions builtin/v11/migration/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ func (m systemActorMigrator) MigrateState(ctx context.Context, store cbor.IpldSt
NewHead: stateHead,
}, nil
}

func (m systemActorMigrator) Deferred() bool {
return false
}
4 changes: 4 additions & 0 deletions builtin/v12/migration/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func (m minerMigrator) MigratedCodeCID() cid.Cid {
return m.OutCodeCID
}

func (m minerMigrator) Deferred() bool {
return false
}

func (m minerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore, in migration.ActorMigrationInput) (*migration.ActorMigrationResult, error) {
var inState miner11.State
if err := store.Get(ctx, in.Head, &inState); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions builtin/v12/migration/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ func (m systemActorMigrator) MigrateState(ctx context.Context, store cbor.IpldSt
NewHead: stateHead,
}, nil
}

func (m systemActorMigrator) Deferred() bool {
return false
}
5 changes: 3 additions & 2 deletions builtin/v13/market/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ func CheckStateInvariants(st *State, store adt.Store, balance abi.TokenAmount, c
//
// Provider Sectors
// Provider->sector->deal mapping
// Each entry corresponds to non-terminated deal state.
// A deal may have expired but remain in the mapping until settlement.

providerSectors := make(map[abi.SectorID][]abi.DealID)
Expand Down Expand Up @@ -301,7 +300,9 @@ func CheckStateInvariants(st *State, store adt.Store, balance abi.TokenAmount, c
// check against proposalStats
for _, dealID := range dealIDsCopy {
st, found := proposalStats[dealID]
acc.Require(found, "deal id %d in provider sectors not found in proposals", dealID)
if !found {
continue
}
acc.Require(st.SectorNumber == abi.SectorNumber(sectorNumber), "deal id %d sector number %d does not match sector id %d", dealID, st.SectorNumber, sectorNumber)

_, ok := expectedProviderSectors[dealID]
Expand Down
Loading

0 comments on commit 9c5492f

Please sign in to comment.