Skip to content

Commit 9c5492f

Browse files
authored
feat: FIP-0076: implement migration to populate ProviderSectors (#246)
* 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
1 parent a4dca91 commit 9c5492f

File tree

21 files changed

+878
-60
lines changed

21 files changed

+878
-60
lines changed

Diff for: builtin/v10/migration/init.go

+4
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ func (m initActorMigrator) MigrateState(ctx context.Context, store cbor.IpldStor
6868
NewHead: outHead,
6969
}, nil
7070
}
71+
72+
func (m initActorMigrator) Deferred() bool {
73+
return false
74+
}

Diff for: builtin/v10/migration/system.go

+4
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ func (m systemActorMigrator) MigrateState(ctx context.Context, store cbor.IpldSt
3434
NewHead: stateHead,
3535
}, nil
3636
}
37+
38+
func (m systemActorMigrator) Deferred() bool {
39+
return false
40+
}

Diff for: builtin/v11/migration/miner.go

+4
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,7 @@ func (m minerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore, i
8787
NewHead: newHead,
8888
}, nil
8989
}
90+
91+
func (m minerMigrator) Deferred() bool {
92+
return false
93+
}

Diff for: builtin/v11/migration/power.go

+4
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,7 @@ func (m powerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore, i
112112
NewHead: newHead,
113113
}, nil
114114
}
115+
116+
func (m powerMigrator) Deferred() bool {
117+
return false
118+
}

Diff for: builtin/v11/migration/system.go

+4
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ func (m systemActorMigrator) MigrateState(ctx context.Context, store cbor.IpldSt
3434
NewHead: stateHead,
3535
}, nil
3636
}
37+
38+
func (m systemActorMigrator) Deferred() bool {
39+
return false
40+
}

Diff for: builtin/v12/migration/miner.go

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ func (m minerMigrator) MigratedCodeCID() cid.Cid {
7979
return m.OutCodeCID
8080
}
8181

82+
func (m minerMigrator) Deferred() bool {
83+
return false
84+
}
85+
8286
func (m minerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore, in migration.ActorMigrationInput) (*migration.ActorMigrationResult, error) {
8387
var inState miner11.State
8488
if err := store.Get(ctx, in.Head, &inState); err != nil {

Diff for: builtin/v12/migration/system.go

+4
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ func (m systemActorMigrator) MigrateState(ctx context.Context, store cbor.IpldSt
3333
NewHead: stateHead,
3434
}, nil
3535
}
36+
37+
func (m systemActorMigrator) Deferred() bool {
38+
return false
39+
}

Diff for: builtin/v13/market/invariants.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ func CheckStateInvariants(st *State, store adt.Store, balance abi.TokenAmount, c
265265
//
266266
// Provider Sectors
267267
// Provider->sector->deal mapping
268-
// Each entry corresponds to non-terminated deal state.
269268
// A deal may have expired but remain in the mapping until settlement.
270269

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

307308
_, ok := expectedProviderSectors[dealID]

0 commit comments

Comments
 (0)