Resolve some unnecessary actor upgrade TODOs

This commit is contained in:
Aayush Rajasekaran 2020-09-22 00:35:15 -04:00
parent d56da1b014
commit 1dc69e397e
6 changed files with 28 additions and 84 deletions

View File

@ -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:

View File

@ -396,13 +396,6 @@ 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")
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)
@ -410,10 +403,6 @@ func (r *refunder) ProcessTipset(ctx context.Context, tipset *types.TipSet, refu
}
sn = proveCommitSector.SectorNumber
} else {
// TODO: ActorUpgrade
sn = 0
}
// 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())

View File

@ -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)

View File

@ -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 {
@ -52,7 +52,7 @@ func NewBasicPreCommitPolicy(api Chain, duration abi.ChainEpoch, provingBoundary
// Expiration produces the pre-commit sector expiration epoch for an encoded
// replica containing the provided enumeration of pieces and deals.
func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, ps ...Piece) (abi.ChainEpoch, error) {
tok, epoch, err := p.api.ChainHead(ctx)
_, epoch, err := p.api.ChainHead(ctx)
if err != nil {
return 0, err
}
@ -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
}

View File

@ -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
}

View File

@ -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,14 +372,8 @@ 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{
params := &miner.ProveCommitSectorParams{
SectorNumber: sector.SectorNumber,
Proof: sector.Proof,
}
@ -395,10 +381,6 @@ func (m *Sealing) handleSubmitCommit(ctx statemachine.Context, sector SectorInfo
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
}
waddr, err := m.api.StateMinerWorkerAddress(ctx.Context(), m.maddr, tok)
if err != nil {