Merge pull request #6631 from filecoin-project/feat/shed-agg-fees

shed tool to estimate aggregate network fees
This commit is contained in:
Łukasz Magiera 2021-06-30 11:13:19 +02:00 committed by GitHub
commit ed2d7964ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,8 +8,10 @@ import (
"strings" "strings"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner"
) )
var mathCmd = &cli.Command{ var mathCmd = &cli.Command{
@ -17,6 +19,7 @@ var mathCmd = &cli.Command{
Usage: "utility commands around doing math on a list of numbers", Usage: "utility commands around doing math on a list of numbers",
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
mathSumCmd, mathSumCmd,
mathAggFeesCmd,
}, },
} }
@ -101,3 +104,30 @@ var mathSumCmd = &cli.Command{
return nil return nil
}, },
} }
var mathAggFeesCmd = &cli.Command{
Name: "agg-fees",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "size",
Required: true,
},
&cli.StringFlag{
Name: "base-fee",
Usage: "baseFee aFIL",
Required: true,
},
},
Action: func(cctx *cli.Context) error {
as := cctx.Int("size")
bf, err := types.BigFromString(cctx.String("base-fee"))
if err != nil {
return xerrors.Errorf("parsing basefee: %w", err)
}
fmt.Println(types.FIL(miner5.AggregateNetworkFee(as, bf)))
return nil
},
}