From 191a05da4872bf9849f178e6db5c0d6e87d05baa Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Sun, 28 Feb 2021 02:10:22 -0500 Subject: [PATCH] Fixup get-cc-collateral command --- cmd/lotus-storage-miner/sectors.go | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-storage-miner/sectors.go b/cmd/lotus-storage-miner/sectors.go index fb9358382..6bb3ca166 100644 --- a/cmd/lotus-storage-miner/sectors.go +++ b/cmd/lotus-storage-miner/sectors.go @@ -655,18 +655,45 @@ var sectorsCapacityCollateralCmd = &cli.Command{ return err } + mi, err := nApi.StateMinerInfo(ctx, maddr, types.EmptyTSK) + if err != nil { + return err + } + + nv, err := nApi.StateNetworkVersion(ctx, types.EmptyTSK) + if err != nil { + return err + } + + spt, err := miner.PreferredSealProofTypeFromWindowPoStType(nv, mi.WindowPoStProofType) + if err != nil { + return err + } + pci := miner.SectorPreCommitInfo{ + SealProof: spt, Expiration: abi.ChainEpoch(cctx.Uint64("expiration")), } if pci.Expiration == 0 { - pci.Expiration = policy.GetMaxSectorExpirationExtension() + h, err := nApi.ChainHead(ctx) + if err != nil { + return err + } + + pci.Expiration = policy.GetMaxSectorExpirationExtension() + h.Height() } + pc, err := nApi.StateMinerInitialPledgeCollateral(ctx, maddr, pci, types.EmptyTSK) if err != nil { return err } - fmt.Printf("Estimated collateral: %s\n", types.FIL(pc)) + pcd, err := nApi.StateMinerPreCommitDepositForPower(ctx, maddr, pci, types.EmptyTSK) + if err != nil { + return err + } + + fmt.Printf("Estimated collateral: %s\n", types.FIL(big.Max(pc, pcd))) return nil },