Skip to content

Commit

Permalink
Migration fixes and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Oct 2, 2022
1 parent 6b83c10 commit ed7f7a0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
28 changes: 18 additions & 10 deletions builtin/v9/migration/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package migration
import (
"context"

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

adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -192,20 +194,26 @@ func (m minerMigrator) migratePrecommits(ctx context.Context, wrappedStore adt8.
var info miner8.SectorPreCommitOnChainInfo
err = oldPrecommitOnChainInfos.ForEach(&info, func(key string) error {
var unsealedCid *cid.Cid
if len(info.Info.DealIDs) != 0 {
pieces := make([]abi.PieceInfo, len(info.Info.DealIDs))
for i, dealID := range info.Info.DealIDs {
deal, err := m.proposals.GetDealProposal(dealID)
if err != nil {
return xerrors.Errorf("error getting deal proposal: %w", err)
var pieces []abi.PieceInfo
for _, dealID := range info.Info.DealIDs {
deal, err := m.proposals.GetDealProposal(dealID)
if err != nil {
// Possible for the proposal to be missing if it's expired (but the deal is still in a precommit that's yet to be cleaned up)
// Just continue in this case, the sector is unProveCommitable anyway, will just fail later
if exitcode.Unwrap(err, exitcode.ErrIllegalState) != exitcode.ErrNotFound {
return xerrors.Errorf("error getting deal proposal for sector: %d: %w", info.Info.SectorNumber, err)
}

pieces[i] = abi.PieceInfo{
PieceCID: deal.PieceCID,
Size: deal.PieceSize,
}
continue
}

pieces = append(pieces, abi.PieceInfo{
PieceCID: deal.PieceCID,
Size: deal.PieceSize,
})
}

if len(pieces) != 0 {
commd, err := commp.GenerateUnsealedCID(info.Info.SealProof, pieces)
if err != nil {
return xerrors.Errorf("failed to generate unsealed CID: %w", err)
Expand Down
8 changes: 8 additions & 0 deletions builtin/v9/migration/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID

// Create the Datacap actor

log.Log(rt.INFO, "Migrating datacap actor")

verifregActorV8, ok, err := actorsIn.GetActor(builtin.VerifiedRegistryActorAddr)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to get verifreg actor: %w", err)
Expand Down Expand Up @@ -456,6 +458,8 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID

// Migrate the Verified Registry Actor

log.Log(rt.INFO, "Migrating the verified registry actor")

initActorV9, ok, err := actorsOut.GetActor(builtin.InitActorAddr)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to load init actor: %w", err)
Expand Down Expand Up @@ -600,6 +604,8 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID

// Migrate the Market Actor

log.Log(rt.INFO, "Migrating the market actor")

pendingDealAllocationIdsMap, err := adt9.AsMap(adtStore, emptyMapCid, builtin.DefaultHamtBitwidth)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to load empty map: %w", err)
Expand Down Expand Up @@ -650,6 +656,8 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
return cid.Undef, xerrors.Errorf("failed to set market actor: %w", err)
}

log.Log(rt.INFO, "Done all migrations, flushing state root")

return actorsOut.Flush()
}

Expand Down

0 comments on commit ed7f7a0

Please sign in to comment.