Merge pull request #3578 from filecoin-project/misc/debug-info-premium

Add additional info about gas premium
This commit is contained in:
Łukasz Magiera 2020-09-05 21:45:57 +02:00 committed by GitHub
commit 2297c58ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@ package full
import ( import (
"context" "context"
"encoding/json"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
@ -113,6 +114,7 @@ func (a *MpoolAPI) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (ci
} }
func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error) { func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec) (*types.SignedMessage, error) {
inMsg := *msg
{ {
fromA, err := a.Stmgr.ResolveToKeyAddress(ctx, msg.From, nil) fromA, err := a.Stmgr.ResolveToKeyAddress(ctx, msg.From, nil)
if err != nil { if err != nil {
@ -134,6 +136,13 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message, spe
return nil, xerrors.Errorf("GasEstimateMessageGas error: %w", err) return nil, xerrors.Errorf("GasEstimateMessageGas error: %w", err)
} }
if msg.GasPremium.GreaterThan(msg.GasFeeCap) {
inJson, _ := json.Marshal(inMsg)
outJson, _ := json.Marshal(msg)
return nil, xerrors.Errorf("After estimation, GasPremium is greater than GasFeeCap, inmsg: %s, outmsg: %s",
inJson, outJson)
}
sign := func(from address.Address, nonce uint64) (*types.SignedMessage, error) { sign := func(from address.Address, nonce uint64) (*types.SignedMessage, error) {
msg.Nonce = nonce msg.Nonce = nonce
if msg.From.Protocol() == address.ID { if msg.From.Protocol() == address.ID {