From 4d6a0f7b8c510e83b862be4639804e8bec9c54bb Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Tue, 6 Oct 2020 05:26:25 -0400 Subject: [PATCH] Set WinningPoStSectorSetLookback to finality post-v2 actors --- build/params_shared_vals.go | 2 -- build/params_testground.go | 3 +-- chain/actors/policy/policy.go | 8 ++++++++ chain/stmgr/utils.go | 7 ++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/build/params_shared_vals.go b/build/params_shared_vals.go index cc711b7bc..722590575 100644 --- a/build/params_shared_vals.go +++ b/build/params_shared_vals.go @@ -56,8 +56,6 @@ const SealRandomnessLookback = policy.SealRandomnessLookback // Epochs const TicketRandomnessLookback = abi.ChainEpoch(1) -const WinningPoStSectorSetLookback = abi.ChainEpoch(10) - // ///// // Address diff --git a/build/params_testground.go b/build/params_testground.go index 162b3477c..bd064b3d6 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -50,8 +50,7 @@ var ( SealRandomnessLookback = policy.SealRandomnessLookback - TicketRandomnessLookback = abi.ChainEpoch(1) - WinningPoStSectorSetLookback = abi.ChainEpoch(10) + TicketRandomnessLookback = abi.ChainEpoch(1) FilBase uint64 = 2_000_000_000 FilAllocStorageMining uint64 = 1_400_000_000 diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index e7f213687..ba09e4424 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -106,3 +106,11 @@ func SetWPoStChallengeWindow(period abi.ChainEpoch) { miner2.WPoStChallengeWindow = period miner2.WPoStProvingPeriod = period * abi.ChainEpoch(miner2.WPoStPeriodDeadlines) } + +func GetWinningPoStSectorSetLookback(nwVer network.Version) abi.ChainEpoch { + if nwVer <= network.Version3 { + return 10 + } + + return ChainFinality +} diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index f2e2bfd19..2c9c5ad94 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -12,6 +12,7 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/chain/actors/policy" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" @@ -29,7 +30,6 @@ import ( exported2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/exported" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/build" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/actors/builtin/market" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" @@ -413,8 +413,9 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch, func GetLookbackTipSetForRound(ctx context.Context, sm *StateManager, ts *types.TipSet, round abi.ChainEpoch) (*types.TipSet, error) { var lbr abi.ChainEpoch - if round > build.WinningPoStSectorSetLookback { - lbr = round - build.WinningPoStSectorSetLookback + lb := policy.GetWinningPoStSectorSetLookback(sm.GetNtwkVersion(ctx, round)) + if round > lb { + lbr = round - lb } // more null blocks than our lookback