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 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))