fix(lotus-sim): less indentation in info

This commit is contained in:
Steven Allen 2021-06-10 10:26:43 -07:00
parent ab59474c4c
commit 500fae6a52

View File

@ -126,41 +126,42 @@ var infoCommitGasSimCommand = &cli.Command{
var gasAggMax, proofsAggMax uint64 var gasAggMax, proofsAggMax uint64
var gasSingle, proofsSingle uint64 var gasSingle, proofsSingle uint64
sim.Walk(cctx.Context, cctx.Int64("lookback"), sim.Walk(cctx.Context, cctx.Int64("lookback"), func(
func(sm *stmgr.StateManager, ts *types.TipSet, stCid cid.Cid, sm *stmgr.StateManager, ts *types.TipSet, stCid cid.Cid,
messages []*simulation.AppliedMessage) error { messages []*simulation.AppliedMessage,
for _, m := range messages { ) error {
if m.ExitCode != exitcode.Ok { for _, m := range messages {
continue 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 { c, err := param.SectorNumbers.Count()
param := miner.ProveCommitAggregateParams{} if err != nil {
err := param.UnmarshalCBOR(bytes.NewReader(m.Params)) log("failed to count sectors")
if err != nil { return 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
}
} }
gasAgg += uint64(m.GasUsed)
if m.Method == builtin.MethodsMiner.ProveCommitSector { proofsAgg += c
gasSingle += uint64(m.GasUsed) if c == 819 {
proofsSingle++ 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) 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)) fmt.Printf("Gas usage efficiency in comparison to all 819: %f%%\n", 100*idealGassUsed/float64(gasAgg+gasSingle))