From 8f4911ac0d558a978acd3981d526c07792f8e65f Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 7 Oct 2020 16:00:52 -0700 Subject: [PATCH 1/2] dont print fil suffix in lotus shed audit balances --- chain/types/fil.go | 6 +++++- cmd/lotus-shed/balances.go | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/chain/types/fil.go b/chain/types/fil.go index 99a896e38..64f6a52b3 100644 --- a/chain/types/fil.go +++ b/chain/types/fil.go @@ -12,11 +12,15 @@ import ( type FIL BigInt func (f FIL) String() string { + return f.Unitless() + " FIL" +} + +func (f FIL) Unitless() string { r := new(big.Rat).SetFrac(f.Int, big.NewInt(int64(build.FilecoinPrecision))) if r.Sign() == 0 { return "0 FIL" } - return strings.TrimRight(strings.TrimRight(r.FloatString(18), "0"), ".") + " FIL" + return strings.TrimRight(strings.TrimRight(r.FloatString(18), "0"), ".") } func (f FIL) Format(s fmt.State, ch rune) { diff --git a/cmd/lotus-shed/balances.go b/cmd/lotus-shed/balances.go index 1c89a00cf..3aeb0c879 100644 --- a/cmd/lotus-shed/balances.go +++ b/cmd/lotus-shed/balances.go @@ -117,7 +117,7 @@ var chainBalanceCmd = &cli.Command{ fmt.Printf("Address,Balance,Type,Power,Worker,Owner\n") for _, acc := range infos { - fmt.Printf("%s,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance, acc.Type, acc.Power, acc.Worker, acc.Owner) + fmt.Printf("%s,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type, acc.Power, acc.Worker, acc.Owner) } return nil }, @@ -244,12 +244,12 @@ var chainBalanceStateCmd = &cli.Command{ if minerInfo { fmt.Printf("Address,Balance,Type,Sectors,Worker,Owner,InitialPledge,Locked,PreCommits\n") for _, acc := range infos { - fmt.Printf("%s,%s,%s,%d,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance, acc.Type, acc.Sectors, acc.Worker, acc.Owner, acc.InitialPledge, acc.LockedFunds, acc.PreCommits) + fmt.Printf("%s,%s,%s,%d,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type, acc.Sectors, acc.Worker, acc.Owner, acc.InitialPledge, acc.LockedFunds, acc.PreCommits) } } else { fmt.Printf("Address,Balance,Type\n") for _, acc := range infos { - fmt.Printf("%s,%s,%s\n", acc.Address, acc.Balance, acc.Type) + fmt.Printf("%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type) } } From cd9af278b46b172e9f918835348f09023bb8b074 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 7 Oct 2020 17:01:01 -0700 Subject: [PATCH 2/2] more info in audit outputs --- chain/types/fil.go | 2 +- cmd/lotus-shed/balances.go | 84 ++++++++++++++++++++++++++------------ 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/chain/types/fil.go b/chain/types/fil.go index 64f6a52b3..7eac8ce93 100644 --- a/chain/types/fil.go +++ b/chain/types/fil.go @@ -18,7 +18,7 @@ func (f FIL) String() string { func (f FIL) Unitless() string { r := new(big.Rat).SetFrac(f.Int, big.NewInt(int64(build.FilecoinPrecision))) if r.Sign() == 0 { - return "0 FIL" + return "0" } return strings.TrimRight(strings.TrimRight(r.FloatString(18), "0"), ".") } diff --git a/cmd/lotus-shed/balances.go b/cmd/lotus-shed/balances.go index 3aeb0c879..8aedbedf6 100644 --- a/cmd/lotus-shed/balances.go +++ b/cmd/lotus-shed/balances.go @@ -7,6 +7,7 @@ import ( "github.com/docker/go-units" lotusbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" + "github.com/filecoin-project/lotus/chain/actors/builtin/multisig" "github.com/filecoin-project/lotus/chain/actors/builtin/power" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" @@ -33,16 +34,19 @@ import ( ) type accountInfo struct { - Address address.Address - Balance types.FIL - Type string - Power abi.StoragePower - Worker address.Address - Owner address.Address - InitialPledge types.FIL - PreCommits types.FIL - LockedFunds types.FIL - Sectors uint64 + Address address.Address + Balance types.FIL + Type string + Power abi.StoragePower + Worker address.Address + Owner address.Address + InitialPledge types.FIL + PreCommits types.FIL + LockedFunds types.FIL + Sectors uint64 + VestingStart abi.ChainEpoch + VestingDuration abi.ChainEpoch + VestingAmount types.FIL } var auditsCmd = &cli.Command{ @@ -115,10 +119,8 @@ var chainBalanceCmd = &cli.Command{ infos = append(infos, ai) } - fmt.Printf("Address,Balance,Type,Power,Worker,Owner\n") - for _, acc := range infos { - fmt.Printf("%s,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type, acc.Power, acc.Worker, acc.Owner) - } + printAccountInfos(infos, false) + return nil }, } @@ -196,6 +198,7 @@ var chainBalanceStateCmd = &cli.Command{ LockedFunds: types.FIL(big.NewInt(0)), InitialPledge: types.FIL(big.NewInt(0)), PreCommits: types.FIL(big.NewInt(0)), + VestingAmount: types.FIL(big.NewInt(0)), } if minerInfo && act.IsStorageMinerActor() { @@ -234,6 +237,32 @@ var chainBalanceStateCmd = &cli.Command{ ai.Worker = minfo.Worker ai.Owner = minfo.Owner } + + if act.IsMultisigActor() { + mst, err := multisig.Load(store, act) + if err != nil { + return err + } + + ai.VestingStart, err = mst.StartEpoch() + if err != nil { + return err + } + + ib, err := mst.InitialBalance() + if err != nil { + return err + } + + ai.VestingAmount = types.FIL(ib) + + ai.VestingDuration, err = mst.UnlockDuration() + if err != nil { + return err + } + + } + infos = append(infos, ai) return nil }) @@ -241,22 +270,27 @@ var chainBalanceStateCmd = &cli.Command{ return xerrors.Errorf("failed to loop over actors: %w", err) } - if minerInfo { - fmt.Printf("Address,Balance,Type,Sectors,Worker,Owner,InitialPledge,Locked,PreCommits\n") - for _, acc := range infos { - fmt.Printf("%s,%s,%s,%d,%s,%s,%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type, acc.Sectors, acc.Worker, acc.Owner, acc.InitialPledge, acc.LockedFunds, acc.PreCommits) - } - } else { - fmt.Printf("Address,Balance,Type\n") - for _, acc := range infos { - fmt.Printf("%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type) - } - } + printAccountInfos(infos, minerInfo) return nil }, } +func printAccountInfos(infos []accountInfo, minerInfo bool) { + if minerInfo { + fmt.Printf("Address,Balance,Type,Sectors,Worker,Owner,InitialPledge,Locked,PreCommits,VestingStart,VestingDuration,VestingAmount\n") + for _, acc := range infos { + fmt.Printf("%s,%s,%s,%d,%s,%s,%s,%s,%s,%d,%d,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type, acc.Sectors, acc.Worker, acc.Owner, acc.InitialPledge.Unitless(), acc.LockedFunds.Unitless(), acc.PreCommits.Unitless(), acc.VestingStart, acc.VestingDuration, acc.VestingAmount.Unitless()) + } + } else { + fmt.Printf("Address,Balance,Type\n") + for _, acc := range infos { + fmt.Printf("%s,%s,%s\n", acc.Address, acc.Balance.Unitless(), acc.Type) + } + } + +} + var chainPledgeCmd = &cli.Command{ Name: "stateroot-pledge", Description: "Calculate sector pledge numbers",