diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index c2b2e3a0d6..dbb4ddd73c 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -18,6 +18,12 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) +// Unchanged between v0 and v1 actors +var PreCommitChallengeDelay = miner0.PreCommitChallengeDelay +var WPoStProvingPeriod = miner0.WPoStProvingPeriod + +const MinSectorExpiration = miner0.MinSectorExpiration + func Load(store adt.Store, act *types.Actor) (st State, err error) { switch act.Code { case builtin0.StorageMinerActorCodeID: diff --git a/cmd/lotus-pcr/main.go b/cmd/lotus-pcr/main.go index c8179d9b65..fed42427c4 100644 --- a/cmd/lotus-pcr/main.go +++ b/cmd/lotus-pcr/main.go @@ -396,24 +396,13 @@ func (r *refunder) ProcessTipset(ctx context.Context, tipset *types.TipSet, refu var sn abi.SectorNumber - nv, err := r.api.StateNetworkVersion(ctx, tipset.Key()) - if err != nil { - log.Warnw("failed to get network version") + var proveCommitSector miner0.ProveCommitSectorParams + if err := proveCommitSector.UnmarshalCBOR(bytes.NewBuffer(m.Params)); err != nil { + log.Warnw("failed to decode provecommit params", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To) continue } - if nv < build.ActorUpgradeNetworkVersion { - var proveCommitSector miner0.ProveCommitSectorParams - if err := proveCommitSector.UnmarshalCBOR(bytes.NewBuffer(m.Params)); err != nil { - log.Warnw("failed to decode provecommit params", "err", err, "method", messageMethod, "cid", msg.Cid, "miner", m.To) - continue - } - - sn = proveCommitSector.SectorNumber - } else { - // TODO: ActorUpgrade - sn = 0 - } + sn = proveCommitSector.SectorNumber // We use the parent tipset key because precommit information is removed when ProveCommitSector is executed precommitChainInfo, err := r.api.StateSectorPreCommitInfo(ctx, m.To, sn, tipset.Parents()) diff --git a/extern/storage-sealing/checks.go b/extern/storage-sealing/checks.go index 27b62f49a7..3d9aedeb40 100644 --- a/extern/storage-sealing/checks.go +++ b/extern/storage-sealing/checks.go @@ -4,6 +4,8 @@ import ( "bytes" "context" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/lotus/build" miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" @@ -104,7 +106,7 @@ func checkPrecommit(ctx context.Context, maddr address.Address, si SectorInfo, t if nv < build.ActorUpgradeNetworkVersion { msd = miner0.MaxSealDuration[si.SectorType] } else { - // TODO: ActorUpgrade + // TODO: ActorUpgrade(use MaxProveCommitDuration) msd = 0 } @@ -154,13 +156,8 @@ func (m *Sealing) checkCommit(ctx context.Context, si SectorInfo, proof []byte, return &ErrNoPrecommit{xerrors.Errorf("precommit info not found on-chain")} } - pccd, err := m.getPreCommitChallengeDelay(ctx, tok) - if err != nil { - return xerrors.Errorf("failed to get precommit challenge delay: %w", err) - } - - if pci.PreCommitEpoch+pccd != si.SeedEpoch { - return &ErrBadSeed{xerrors.Errorf("seed epoch doesn't match on chain info: %d != %d", pci.PreCommitEpoch+pccd, si.SeedEpoch)} + if pci.PreCommitEpoch+miner.PreCommitChallengeDelay != si.SeedEpoch { + return &ErrBadSeed{xerrors.Errorf("seed epoch doesn't match on chain info: %d != %d", pci.PreCommitEpoch+miner.PreCommitChallengeDelay, si.SeedEpoch)} } buf := new(bytes.Buffer) diff --git a/extern/storage-sealing/precommit_policy.go b/extern/storage-sealing/precommit_policy.go index 2ee6c1afc2..658fad370f 100644 --- a/extern/storage-sealing/precommit_policy.go +++ b/extern/storage-sealing/precommit_policy.go @@ -3,11 +3,11 @@ package sealing import ( "context" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/go-state-types/abi" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" ) type PreCommitPolicy interface { @@ -80,20 +80,7 @@ func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, ps ...Piece) (abi end = &tmp } - nv, err := p.api.StateNetworkVersion(ctx, tok) - if err != nil { - return 0, err - } - - var wpp abi.ChainEpoch - if nv < build.ActorUpgradeNetworkVersion { - wpp = miner0.WPoStProvingPeriod - } else { - // TODO: ActorUpgrade - wpp = 0 - } - - *end += wpp - (*end % wpp) + p.provingBoundary - 1 + *end += miner.WPoStProvingPeriod - (*end % miner.WPoStProvingPeriod) + p.provingBoundary - 1 return *end, nil } diff --git a/extern/storage-sealing/sealing.go b/extern/storage-sealing/sealing.go index d5772e1d61..1ba53661a6 100644 --- a/extern/storage-sealing/sealing.go +++ b/extern/storage-sealing/sealing.go @@ -8,9 +8,6 @@ import ( "sync" "time" - "github.com/filecoin-project/lotus/build" - miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner" - "github.com/filecoin-project/go-state-types/network" "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" @@ -422,17 +419,3 @@ func getDealPerSectorLimit(size abi.SectorSize) uint64 { } return 512 } - -func (m *Sealing) getPreCommitChallengeDelay(ctx context.Context, tok TipSetToken) (abi.ChainEpoch, error) { - nv, err := m.api.StateNetworkVersion(ctx, tok) - if err != nil { - return -1, xerrors.Errorf("failed to get network version: %w", err) - } - - if nv < build.ActorUpgradeNetworkVersion { - return miner0.PreCommitChallengeDelay, nil - } - - // TODO: ActorUpgrade - return -1, nil -} diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index 0109326fb1..4433651600 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -189,17 +189,14 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf } var msd abi.ChainEpoch - var mse abi.ChainEpoch if nv < build.ActorUpgradeNetworkVersion { msd = miner0.MaxSealDuration[sector.SectorType] - mse = miner0.MinSectorExpiration } else { - // TODO: ActorUpgrade + // TODO: ActorUpgrade(use MaxProveCommitDuration) msd = 0 - mse = 0 } - if minExpiration := height + msd + mse + 10; expiration < minExpiration { + if minExpiration := height + msd + miner.MinSectorExpiration + 10; expiration < minExpiration { expiration = minExpiration } // TODO: enforce a reasonable _maximum_ sector lifetime? @@ -284,12 +281,7 @@ func (m *Sealing) handleWaitSeed(ctx statemachine.Context, sector SectorInfo) er return ctx.Send(SectorChainPreCommitFailed{error: xerrors.Errorf("precommit info not found on chain")}) } - pccd, err := m.getPreCommitChallengeDelay(ctx.Context(), tok) - if err != nil { - return ctx.Send(SectorChainPreCommitFailed{xerrors.Errorf("failed to get precommit challenge delay: %w", err)}) - } - - randHeight := pci.PreCommitEpoch + pccd + randHeight := pci.PreCommitEpoch + miner.PreCommitChallengeDelay err = m.events.ChainAt(func(ectx context.Context, _ TipSetToken, curH abi.ChainEpoch) error { // in case of null blocks the randomness can land after the tipset we @@ -380,24 +372,14 @@ func (m *Sealing) handleSubmitCommit(ctx statemachine.Context, sector SectorInfo return ctx.Send(SectorCommitFailed{xerrors.Errorf("commit check error: %w", err)}) } - nv, err := m.api.StateNetworkVersion(ctx.Context(), tok) - if err != nil { - return ctx.Send(SectorCommitFailed{xerrors.Errorf("failed to get network version: %w", err)}) - } - enc := new(bytes.Buffer) - if nv < build.ActorUpgradeNetworkVersion { - params := &miner0.ProveCommitSectorParams{ - SectorNumber: sector.SectorNumber, - Proof: sector.Proof, - } + params := &miner.ProveCommitSectorParams{ + SectorNumber: sector.SectorNumber, + Proof: sector.Proof, + } - if err := params.MarshalCBOR(enc); err != nil { - return ctx.Send(SectorCommitFailed{xerrors.Errorf("could not serialize commit sector parameters: %w", err)}) - } - } else { - // TODO: ActorUpgrade - enc = nil + if err := params.MarshalCBOR(enc); err != nil { + return ctx.Send(SectorCommitFailed{xerrors.Errorf("could not serialize commit sector parameters: %w", err)}) } waddr, err := m.api.StateMinerWorkerAddress(ctx.Context(), m.maddr, tok)