Fixup new command

This commit is contained in:
Aayush Rajasekaran 2020-09-14 01:23:29 -04:00
parent d1850ea27d
commit 0edcae9e04
4 changed files with 32 additions and 16 deletions

View File

@ -1344,12 +1344,12 @@ var stateMsgCostCmd = &cli.Command{
} }
if mgc != nil { if mgc != nil {
fmt.Printf("\nMessage CID: %d", mgc.Message) fmt.Printf("Message CID: %s", mgc.Message)
fmt.Printf("\nGas Used: %d", mgc.GasUsed) fmt.Printf("\nGas Used: %d", mgc.GasUsed)
fmt.Printf("\nBase Fee Burn: %d", mgc.BaseFeeBurn) fmt.Printf("\nBase Fee Burn: %d", mgc.BaseFeeBurn)
fmt.Printf("\nOverestimation Burn: %d", mgc.OverEstimationBurn) fmt.Printf("\nOverestimation Burn: %d", mgc.OverEstimationBurn)
fmt.Printf("\nMiner Tip: %d", mgc.MinerTip) fmt.Printf("\nMiner Tip: %d", mgc.MinerTip)
fmt.Printf("\nRefundd: %d", mgc.Refund) fmt.Printf("\nRefund: %d", mgc.Refund)
fmt.Printf("\nTotal Cost: %d", mgc.TotalCost) fmt.Printf("\nTotal Cost: %d", mgc.TotalCost)
fmt.Printf("\nMiner Penalty: %d", mgc.MinerPenalty) fmt.Printf("\nMiner Penalty: %d", mgc.MinerPenalty)
} else { } else {

View File

@ -3743,7 +3743,15 @@ Inputs:
[ [
{ {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
} },
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
}
]
] ]
``` ```
@ -3753,16 +3761,13 @@ Response:
"Message": { "Message": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4" "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}, },
"Receipt": { "GasUsed": "0",
"ExitCode": 0,
"Return": "Ynl0ZSBhcnJheQ==",
"GasUsed": 9
},
"BaseFeeBurn": "0", "BaseFeeBurn": "0",
"OverEstimationBurn": "0", "OverEstimationBurn": "0",
"MinerPenalty": "0", "MinerPenalty": "0",
"MinerTip": "0", "MinerTip": "0",
"Refund": "0" "Refund": "0",
"TotalCost": "0"
} }
``` ```

View File

@ -67,6 +67,8 @@ func (m *Sealing) tryUpgradeSector(ctx context.Context, params *miner.SectorPreC
params.ReplaceSectorDeadline = loc.Deadline params.ReplaceSectorDeadline = loc.Deadline
params.ReplaceSectorPartition = loc.Partition params.ReplaceSectorPartition = loc.Partition
log.Infof("replacing sector %d with %d", *replace, params.SectorNumber)
ri, err := m.api.StateSectorGetInfo(ctx, m.maddr, *replace, nil) ri, err := m.api.StateSectorGetInfo(ctx, m.maddr, *replace, nil)
if err != nil { if err != nil {
log.Errorf("error calling StateSectorGetInfo for replaced sector: %+v", err) log.Errorf("error calling StateSectorGetInfo for replaced sector: %+v", err)

View File

@ -1238,15 +1238,25 @@ func (a *StateAPI) StateMsgGasCost(ctx context.Context, inputMsg cid.Cid, tsk ty
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
} }
} else { } else {
msg, err := a.StateSearchMsg(ctx, inputMsg) mlkp, err := a.StateSearchMsg(ctx, inputMsg)
if err != nil { if err != nil {
return nil, xerrors.Errorf("searching for msg %s: %w", inputMsg, err) return nil, xerrors.Errorf("searching for msg %s: %w", inputMsg, err)
} }
if mlkp == nil {
ts, err = a.Chain.GetTipSetFromKey(msg.TipSet) return nil, xerrors.Errorf("didn't find msg %s", inputMsg)
if err != nil {
return nil, xerrors.Errorf("loading tipset %s: %w", msg.TipSet, err)
} }
executionTs, err := a.Chain.GetTipSetFromKey(mlkp.TipSet)
if err != nil {
return nil, xerrors.Errorf("loading tipset %s: %w", mlkp.TipSet, err)
}
ts, err = a.Chain.LoadTipSet(executionTs.Parents())
if err != nil {
return nil, xerrors.Errorf("loading parent tipset %s: %w", mlkp.TipSet, err)
}
msg = mlkp.Message
} }
m, r, err := a.StateManager.Replay(ctx, ts, msg) m, r, err := a.StateManager.Replay(ctx, ts, msg)
@ -1254,7 +1264,6 @@ func (a *StateAPI) StateMsgGasCost(ctx context.Context, inputMsg cid.Cid, tsk ty
return nil, err return nil, err
} }
gasSpent := big.Sub(big.NewInt(m.GasLimit), r.GasCosts.Refund)
return &api.MsgGasCost{ return &api.MsgGasCost{
Message: msg, Message: msg,
GasUsed: big.NewInt(r.GasUsed), GasUsed: big.NewInt(r.GasUsed),
@ -1263,6 +1272,6 @@ func (a *StateAPI) StateMsgGasCost(ctx context.Context, inputMsg cid.Cid, tsk ty
MinerPenalty: r.GasCosts.MinerPenalty, MinerPenalty: r.GasCosts.MinerPenalty,
MinerTip: r.GasCosts.MinerTip, MinerTip: r.GasCosts.MinerTip,
Refund: r.GasCosts.Refund, Refund: r.GasCosts.Refund,
TotalCost: big.Mul(gasSpent, m.GasFeeCap), TotalCost: big.Sub(m.RequiredFunds(), r.GasCosts.Refund),
}, nil }, nil
} }