From 76090193ea774853a0775ae2357b07ec6ad65791 Mon Sep 17 00:00:00 2001 From: Aayush Date: Fri, 9 Sep 2022 21:40:03 -0400 Subject: [PATCH] Tweak StateMinerPreCommitDepositForPower based on network version --- node/impl/full/state.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 97308dcc9..1c062d6d6 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -1186,16 +1186,20 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr store := a.Chain.ActorStore(ctx) var sectorWeight abi.StoragePower - if act, err := state.GetActor(market.Address); err != nil { - return types.EmptyInt, xerrors.Errorf("loading market actor %s: %w", maddr, err) - } else if s, err := market.Load(store, act); err != nil { - return types.EmptyInt, xerrors.Errorf("loading market actor state %s: %w", maddr, err) - } else if w, vw, err := s.VerifyDealsForActivation(maddr, pci.DealIDs, ts.Height(), pci.Expiration); err != nil { - return types.EmptyInt, xerrors.Errorf("verifying deals for activation: %w", err) + if a.StateManager.GetNetworkVersion(ctx, ts.Height()) <= network.Version16 { + if act, err := state.GetActor(market.Address); err != nil { + return types.EmptyInt, xerrors.Errorf("loading market actor %s: %w", maddr, err) + } else if s, err := market.Load(store, act); err != nil { + return types.EmptyInt, xerrors.Errorf("loading market actor state %s: %w", maddr, err) + } else if w, vw, err := s.VerifyDealsForActivation(maddr, pci.DealIDs, ts.Height(), pci.Expiration); err != nil { + return types.EmptyInt, xerrors.Errorf("verifying deals for activation: %w", err) + } else { + // NB: not exactly accurate, but should always lead us to *over* estimate, not under + duration := pci.Expiration - ts.Height() + sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw) + } } else { - // NB: not exactly accurate, but should always lead us to *over* estimate, not under - duration := pci.Expiration - ts.Height() - sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw) + sectorWeight = minertypes.QAPowerMax(ssize) } var powerSmoothed builtin.FilterEstimate