Skip to content

Commit c07c5f9

Browse files
authored
feat: make the upgrade epoch input from the client (#252)
1 parent 9c5492f commit c07c5f9

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

builtin/v13/migration/market.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ import (
2121

2222
type marketMigrator struct {
2323
providerSectors *providerSectors
24+
upgradeEpoch abi.ChainEpoch
2425
OutCodeCID cid.Cid
2526
}
2627

27-
func newMarketMigrator(ctx context.Context, store cbor.IpldStore, outCode cid.Cid, ps *providerSectors) (*marketMigrator, error) {
28+
func newMarketMigrator(ctx context.Context, store cbor.IpldStore, outCode cid.Cid, ps *providerSectors, upgradeEpoch abi.ChainEpoch) (*marketMigrator, error) {
2829
return &marketMigrator{
2930
providerSectors: ps,
31+
upgradeEpoch: upgradeEpoch,
3032
OutCodeCID: outCode,
3133
}, nil
3234
}
@@ -329,7 +331,7 @@ func (m *marketMigrator) migrateProviderSectorsAndStatesFromScratch(ctx context.
329331
}
330332

331333
// FIP: For each unexpired deal state object in the market actor state that has a terminated epoch set to -1:
332-
if oldState.SlashEpoch == -1 && proposal.EndEpoch >= UpgradeHeight {
334+
if oldState.SlashEpoch == -1 && proposal.EndEpoch >= m.upgradeEpoch {
333335
// FIP: find the corresponding deal proposal object and extract the provider's actor ID;
334336
// - we do this by collecting all dealIDs in providerSectors in miner migration
335337

builtin/v13/migration/miner.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ type providerSectors struct {
3333
// minerMigration is technically a no-op, but it collects a cache for market migration
3434
type minerMigrator struct {
3535
providerSectors *providerSectors
36-
37-
OutCodeCID cid.Cid
36+
upgradeEpoch abi.ChainEpoch
37+
OutCodeCID cid.Cid
3838
}
3939

40-
func newMinerMigrator(ctx context.Context, store cbor.IpldStore, outCode cid.Cid, ps *providerSectors) (*minerMigrator, error) {
40+
func newMinerMigrator(ctx context.Context, store cbor.IpldStore, outCode cid.Cid, ps *providerSectors, upgradeEpoch abi.ChainEpoch) (*minerMigrator, error) {
4141
return &minerMigrator{
4242
providerSectors: ps,
43-
44-
OutCodeCID: outCode,
43+
upgradeEpoch: upgradeEpoch,
44+
OutCodeCID: outCode,
4545
}, nil
4646
}
4747

@@ -73,7 +73,7 @@ func (m *minerMigrator) MigrateState(ctx context.Context, store cbor.IpldStore,
7373
// no cached migration, so we simply iterate all sectors and collect deal IDs
7474

7575
err = inSectors.ForEach(&sector, func(i int64) error {
76-
if len(sector.DealIDs) == 0 || sector.Expiration < UpgradeHeight {
76+
if len(sector.DealIDs) == 0 || sector.Expiration < m.upgradeEpoch {
7777
return nil
7878
}
7979

builtin/v13/migration/top.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ import (
1717
"golang.org/x/xerrors"
1818
)
1919

20-
// TODO: Make input to migration
21-
const UpgradeHeight = abi.ChainEpoch(3654004)
22-
2320
// MigrateStateTree Migrates the filecoin state tree starting from the global state tree and upgrading all actor state.
2421
// The store must support concurrent writes (even if the configured worker count is 1).
2522
func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID cid.Cid, actorsRootIn cid.Cid, priorEpoch abi.ChainEpoch, cfg migration.Config, log migration.Logger, cache migration.MigrationCache) (cid.Cid, error) {
@@ -119,7 +116,7 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
119116
updatesToMinerToSectorToDeals: map[abi.ActorID]map[abi.SectorNumber][]abi.DealID{},
120117
}
121118

122-
minerMig, err := newMinerMigrator(ctx, store, miner13Cid, ps)
119+
minerMig, err := newMinerMigrator(ctx, store, miner13Cid, ps, cfg.UpgradeEpoch)
123120
if err != nil {
124121
return cid.Undef, xerrors.Errorf("failed to create miner migrator: %w", err)
125122
}
@@ -132,7 +129,7 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
132129
return cid.Undef, xerrors.Errorf("code cid for market actor not found in new manifest")
133130
}
134131

135-
marketMig, err := newMarketMigrator(ctx, store, market13Cid, ps)
132+
marketMig, err := newMarketMigrator(ctx, store, market13Cid, ps, cfg.UpgradeEpoch)
136133
if err != nil {
137134
return cid.Undef, xerrors.Errorf("failed to create market migrator: %w", err)
138135
}

migration/util.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"sync"
66
"time"
77

8+
"github.com/filecoin-project/go-state-types/abi"
9+
810
"github.com/filecoin-project/go-address"
911
"github.com/filecoin-project/go-state-types/rt"
1012
cbor "github.com/ipfs/go-ipld-cbor"
@@ -83,6 +85,8 @@ type Config struct {
8385
// Time between progress logs to emit.
8486
// Zero (the default) results in no progress logs.
8587
ProgressLogPeriod time.Duration
88+
// The epoch at which the upgrade will run.
89+
UpgradeEpoch abi.ChainEpoch
8690
}
8791

8892
type Logger interface {

0 commit comments

Comments
 (0)