From ee20d3048055934d4aa5f6bef60b43bdaf6c777d Mon Sep 17 00:00:00 2001 From: He Weidong Date: Fri, 23 Apr 2021 19:06:54 +0800 Subject: [PATCH 1/3] reasonable min and max value for initial sector expiration --- extern/storage-sealing/states_sealing.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index 5334fc72e74..3aef55f5d44 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -304,8 +304,6 @@ func (m *Sealing) preCommitParams(ctx statemachine.Context, sector SectorInfo) ( return nil, big.Zero(), nil, ctx.Send(SectorSealPreCommit1Failed{xerrors.Errorf("handlePreCommitting: failed to compute pre-commit expiry: %w", err)}) } - // Sectors must last _at least_ MinSectorExpiration + MaxSealDuration. - // TODO: The "+10" allows the pre-commit to take 10 blocks to be accepted. nv, err := m.api.StateNetworkVersion(ctx.Context(), tok) if err != nil { return nil, big.Zero(), nil, ctx.Send(SectorSealPreCommit1Failed{xerrors.Errorf("failed to get network version: %w", err)}) @@ -313,10 +311,15 @@ func (m *Sealing) preCommitParams(ctx statemachine.Context, sector SectorInfo) ( msd := policy.GetMaxProveCommitDuration(actors.VersionForNetwork(nv), sector.SectorType) - if minExpiration := sector.TicketEpoch + policy.MaxPreCommitRandomnessLookback + msd + miner.MinSectorExpiration; expiration < minExpiration { - expiration = minExpiration + // Assume: both precommit msg & commit msg land on chain as late as possible + minExpiration := sector.TicketEpoch + policy.MaxPreCommitRandomnessLookback + msd + miner.MinSectorExpiration + if expiration < minExpiration { + + // Assume: both precommit msg & commit msg land on chain as early as possible + maxExpiration := height + policy.GetPreCommitChallengeDelay() + policy.GetMaxSectorExpirationExtension() + if expiration > maxExpiration { + expiration = maxExpiration } - // TODO: enforce a reasonable _maximum_ sector lifetime? params := &miner.SectorPreCommitInfo{ Expiration: expiration, From ef6620ad8e56d22acdd63492a64839c3c8006fe2 Mon Sep 17 00:00:00 2001 From: He Weidong Date: Wed, 14 Jul 2021 11:52:18 +0800 Subject: [PATCH 2/3] reasonable max value for initial sector expiration --- extern/storage-sealing/states_sealing.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index 3aef55f5d44..587ad59378a 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -311,9 +311,9 @@ func (m *Sealing) preCommitParams(ctx statemachine.Context, sector SectorInfo) ( msd := policy.GetMaxProveCommitDuration(actors.VersionForNetwork(nv), sector.SectorType) - // Assume: both precommit msg & commit msg land on chain as late as possible - minExpiration := sector.TicketEpoch + policy.MaxPreCommitRandomnessLookback + msd + miner.MinSectorExpiration - if expiration < minExpiration { + if minExpiration := height + msd + miner.MinSectorExpiration + 10; expiration < minExpiration { + expiration = minExpiration + } // Assume: both precommit msg & commit msg land on chain as early as possible maxExpiration := height + policy.GetPreCommitChallengeDelay() + policy.GetMaxSectorExpirationExtension() From 4273fb067cae156fe24410bd4c113fd6b3778b92 Mon Sep 17 00:00:00 2001 From: He Weidong Date: Thu, 29 Jul 2021 15:01:52 +0800 Subject: [PATCH 3/3] reduce diff --- extern/storage-sealing/states_sealing.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index 587ad59378a..0935823eba2 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -311,7 +311,7 @@ func (m *Sealing) preCommitParams(ctx statemachine.Context, sector SectorInfo) ( msd := policy.GetMaxProveCommitDuration(actors.VersionForNetwork(nv), sector.SectorType) - if minExpiration := height + msd + miner.MinSectorExpiration + 10; expiration < minExpiration { + if minExpiration := sector.TicketEpoch + policy.MaxPreCommitRandomnessLookback + msd + miner.MinSectorExpiration; expiration < minExpiration { expiration = minExpiration }