From a2fd927343179ec85b4e53ab7eff49e628789ca7 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 15 Oct 2024 03:43:32 +1100 Subject: [PATCH] fix(miner): fix new bug in StateMinerPreCommitDepositForPower calculation (#12595) Regression introduced by refactoring in https://github.com/filecoin-project/lotus/pull/12384 where the NV16 special case was missed and the full sector weight calculation was applied. The lack of this special case essentially reverts FIP-0034 for this API, but not for actors which would have a different PCD calculation. --- node/impl/full/state.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 7498f1dd083..05a65cd0484 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -1504,9 +1504,17 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr return types.EmptyInt, xerrors.Errorf("loading reward actor state: %w", err) } - sectorWeight, err := a.calculateSectorWeight(ctx, maddr, pci, ts.Height(), state) - if err != nil { - return types.EmptyInt, err + var sectorWeight abi.StoragePower + if a.StateManager.GetNetworkVersion(ctx, ts.Height()) <= network.Version16 { + if sectorWeight, err = a.calculateSectorWeight(ctx, maddr, pci, ts.Height(), state); err != nil { + return types.EmptyInt, err + } + } else { + ssize, err := pci.SealProof.SectorSize() + if err != nil { + return types.EmptyInt, xerrors.Errorf("failed to resolve sector size for seal proof: %w", err) + } + sectorWeight = miner.QAPowerMax(ssize) } _, powerSmoothed, err := a.pledgeCalculationInputs(ctx, state)