From 500fae6a525022895377a506ae50171940b79b4a Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 10 Jun 2021 10:26:43 -0700 Subject: [PATCH] fix(lotus-sim): less indentation in info --- cmd/lotus-sim/info.go | 61 ++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/cmd/lotus-sim/info.go b/cmd/lotus-sim/info.go index 9523b5936..9f3c81dca 100644 --- a/cmd/lotus-sim/info.go +++ b/cmd/lotus-sim/info.go @@ -126,41 +126,42 @@ var infoCommitGasSimCommand = &cli.Command{ var gasAggMax, proofsAggMax uint64 var gasSingle, proofsSingle uint64 - sim.Walk(cctx.Context, cctx.Int64("lookback"), - func(sm *stmgr.StateManager, ts *types.TipSet, stCid cid.Cid, - messages []*simulation.AppliedMessage) error { - for _, m := range messages { - if m.ExitCode != exitcode.Ok { - continue + sim.Walk(cctx.Context, cctx.Int64("lookback"), func( + sm *stmgr.StateManager, ts *types.TipSet, stCid cid.Cid, + messages []*simulation.AppliedMessage, + ) error { + for _, m := range messages { + if m.ExitCode != exitcode.Ok { + continue + } + if m.Method == builtin.MethodsMiner.ProveCommitAggregate { + param := miner.ProveCommitAggregateParams{} + err := param.UnmarshalCBOR(bytes.NewReader(m.Params)) + if err != nil { + log("failed to decode params: %+v", err) + return nil } - if m.Method == builtin.MethodsMiner.ProveCommitAggregate { - param := miner.ProveCommitAggregateParams{} - err := param.UnmarshalCBOR(bytes.NewReader(m.Params)) - if err != nil { - log("failed to decode params: %+v", err) - return nil - } - c, err := param.SectorNumbers.Count() - if err != nil { - log("failed to count sectors") - return nil - } - gasAgg += uint64(m.GasUsed) - proofsAgg += c - if c == 819 { - gasAggMax += uint64(m.GasUsed) - proofsAggMax += c - } + c, err := param.SectorNumbers.Count() + if err != nil { + log("failed to count sectors") + return nil } - - if m.Method == builtin.MethodsMiner.ProveCommitSector { - gasSingle += uint64(m.GasUsed) - proofsSingle++ + gasAgg += uint64(m.GasUsed) + proofsAgg += c + if c == 819 { + gasAggMax += uint64(m.GasUsed) + proofsAggMax += c } } - return nil - }) + if m.Method == builtin.MethodsMiner.ProveCommitSector { + gasSingle += uint64(m.GasUsed) + proofsSingle++ + } + } + + return nil + }) idealGassUsed := float64(gasAggMax) / float64(proofsAggMax) * float64(proofsAgg+proofsSingle) fmt.Printf("Gas usage efficiency in comparison to all 819: %f%%\n", 100*idealGassUsed/float64(gasAgg+gasSingle))