more info in audit outputs

This commit is contained in:
whyrusleeping 2020-10-07 17:01:01 -07:00
parent 8f4911ac0d
commit cd9af278b4
2 changed files with 60 additions and 26 deletions

View File

@ -18,7 +18,7 @@ func (f FIL) String() string {
func (f FIL) Unitless() string { func (f FIL) Unitless() string {
r := new(big.Rat).SetFrac(f.Int, big.NewInt(int64(build.FilecoinPrecision))) r := new(big.Rat).SetFrac(f.Int, big.NewInt(int64(build.FilecoinPrecision)))
if r.Sign() == 0 { if r.Sign() == 0 {
return "0 FIL" return "0"
} }
return strings.TrimRight(strings.TrimRight(r.FloatString(18), "0"), ".") return strings.TrimRight(strings.TrimRight(r.FloatString(18), "0"), ".")
} }

View File

@ -7,6 +7,7 @@ import (
"github.com/docker/go-units" "github.com/docker/go-units"
lotusbuiltin "github.com/filecoin-project/lotus/chain/actors/builtin" 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/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/reward" "github.com/filecoin-project/lotus/chain/actors/builtin/reward"
@ -33,16 +34,19 @@ import (
) )
type accountInfo struct { type accountInfo struct {
Address address.Address Address address.Address
Balance types.FIL Balance types.FIL
Type string Type string
Power abi.StoragePower Power abi.StoragePower
Worker address.Address Worker address.Address
Owner address.Address Owner address.Address
InitialPledge types.FIL InitialPledge types.FIL
PreCommits types.FIL PreCommits types.FIL
LockedFunds types.FIL LockedFunds types.FIL
Sectors uint64 Sectors uint64
VestingStart abi.ChainEpoch
VestingDuration abi.ChainEpoch
VestingAmount types.FIL
} }
var auditsCmd = &cli.Command{ var auditsCmd = &cli.Command{
@ -115,10 +119,8 @@ var chainBalanceCmd = &cli.Command{
infos = append(infos, ai) infos = append(infos, ai)
} }
fmt.Printf("Address,Balance,Type,Power,Worker,Owner\n") printAccountInfos(infos, false)
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)
}
return nil return nil
}, },
} }
@ -196,6 +198,7 @@ var chainBalanceStateCmd = &cli.Command{
LockedFunds: types.FIL(big.NewInt(0)), LockedFunds: types.FIL(big.NewInt(0)),
InitialPledge: types.FIL(big.NewInt(0)), InitialPledge: types.FIL(big.NewInt(0)),
PreCommits: types.FIL(big.NewInt(0)), PreCommits: types.FIL(big.NewInt(0)),
VestingAmount: types.FIL(big.NewInt(0)),
} }
if minerInfo && act.IsStorageMinerActor() { if minerInfo && act.IsStorageMinerActor() {
@ -234,6 +237,32 @@ var chainBalanceStateCmd = &cli.Command{
ai.Worker = minfo.Worker ai.Worker = minfo.Worker
ai.Owner = minfo.Owner 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) infos = append(infos, ai)
return nil return nil
}) })
@ -241,22 +270,27 @@ var chainBalanceStateCmd = &cli.Command{
return xerrors.Errorf("failed to loop over actors: %w", err) return xerrors.Errorf("failed to loop over actors: %w", err)
} }
if minerInfo { printAccountInfos(infos, 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)
}
}
return nil 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{ var chainPledgeCmd = &cli.Command{
Name: "stateroot-pledge", Name: "stateroot-pledge",
Description: "Calculate sector pledge numbers", Description: "Calculate sector pledge numbers",