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

feat: make the upgrade epoch input from the client #252

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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
6 changes: 4 additions & 2 deletions builtin/v13/migration/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import (

type marketMigrator struct {
providerSectors *providerSectors
upgradeEpoch abi.ChainEpoch
OutCodeCID cid.Cid
}

func newMarketMigrator(ctx context.Context, store cbor.IpldStore, outCode cid.Cid, ps *providerSectors) (*marketMigrator, error) {
func newMarketMigrator(ctx context.Context, store cbor.IpldStore, outCode cid.Cid, ps *providerSectors, upgradeEpoch abi.ChainEpoch) (*marketMigrator, error) {
return &marketMigrator{
providerSectors: ps,
upgradeEpoch: upgradeEpoch,
OutCodeCID: outCode,
}, nil
}
Expand Down Expand Up @@ -329,7 +331,7 @@ func (m *marketMigrator) migrateProviderSectorsAndStatesFromScratch(ctx context.
}

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

Expand Down
12 changes: 6 additions & 6 deletions builtin/v13/migration/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ type providerSectors struct {
// minerMigration is technically a no-op, but it collects a cache for market migration
type minerMigrator struct {
providerSectors *providerSectors

OutCodeCID cid.Cid
upgradeEpoch abi.ChainEpoch
OutCodeCID cid.Cid
}

func newMinerMigrator(ctx context.Context, store cbor.IpldStore, outCode cid.Cid, ps *providerSectors) (*minerMigrator, error) {
func newMinerMigrator(ctx context.Context, store cbor.IpldStore, outCode cid.Cid, ps *providerSectors, upgradeEpoch abi.ChainEpoch) (*minerMigrator, error) {
return &minerMigrator{
providerSectors: ps,

OutCodeCID: outCode,
upgradeEpoch: upgradeEpoch,
OutCodeCID: outCode,
}, nil
}

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

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

Expand Down
7 changes: 2 additions & 5 deletions builtin/v13/migration/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import (
"golang.org/x/xerrors"
)

// TODO: Make input to migration
const UpgradeHeight = abi.ChainEpoch(3654004)

// MigrateStateTree Migrates the filecoin state tree starting from the global state tree and upgrading all actor state.
// The store must support concurrent writes (even if the configured worker count is 1).
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) {
Expand Down Expand Up @@ -119,7 +116,7 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
updatesToMinerToSectorToDeals: map[abi.ActorID]map[abi.SectorNumber][]abi.DealID{},
}

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

marketMig, err := newMarketMigrator(ctx, store, market13Cid, ps)
marketMig, err := newMarketMigrator(ctx, store, market13Cid, ps, cfg.UpgradeEpoch)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create market migrator: %w", err)
}
Expand Down
4 changes: 4 additions & 0 deletions migration/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"sync"
"time"

"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/rt"
cbor "github.com/ipfs/go-ipld-cbor"
Expand Down Expand Up @@ -83,6 +85,8 @@ type Config struct {
// Time between progress logs to emit.
// Zero (the default) results in no progress logs.
ProgressLogPeriod time.Duration
// The epoch at which the upgrade will run.
UpgradeEpoch abi.ChainEpoch
}

type Logger interface {
Expand Down