Merge pull request #9746 from filecoin-project/feat/maximize-feecap-cfg
feat: mpool/wdpost: Maximize feecap config
This commit is contained in:
commit
9fc3c3351a
@ -56,9 +56,17 @@ type PubsubScore struct {
|
|||||||
Score *pubsub.PeerScoreSnapshot
|
Score *pubsub.PeerScoreSnapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MessageSendSpec contains optional fields which modify message sending behavior
|
||||||
type MessageSendSpec struct {
|
type MessageSendSpec struct {
|
||||||
|
// MaxFee specifies a cap on network fees related to this message
|
||||||
MaxFee abi.TokenAmount
|
MaxFee abi.TokenAmount
|
||||||
|
|
||||||
|
// MsgUuid specifies a unique message identifier which can be used on node (or node cluster)
|
||||||
|
// level to prevent double-sends of messages even when nonce generation is not handled by sender
|
||||||
MsgUuid uuid.UUID
|
MsgUuid uuid.UUID
|
||||||
|
|
||||||
|
// MaximizeFeeCap makes message FeeCap be based entirely on MaxFee
|
||||||
|
MaximizeFeeCap bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type MpoolMessageWhole struct {
|
type MpoolMessageWhole struct {
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -210,8 +210,10 @@ func ComputeRBF(curPrem abi.TokenAmount, replaceByFeeRatio types.Percent) abi.To
|
|||||||
|
|
||||||
func CapGasFee(mff dtypes.DefaultMaxFeeFunc, msg *types.Message, sendSpec *api.MessageSendSpec) {
|
func CapGasFee(mff dtypes.DefaultMaxFeeFunc, msg *types.Message, sendSpec *api.MessageSendSpec) {
|
||||||
var maxFee abi.TokenAmount
|
var maxFee abi.TokenAmount
|
||||||
|
var maximizeFeeCap bool
|
||||||
if sendSpec != nil {
|
if sendSpec != nil {
|
||||||
maxFee = sendSpec.MaxFee
|
maxFee = sendSpec.MaxFee
|
||||||
|
maximizeFeeCap = sendSpec.MaximizeFeeCap
|
||||||
}
|
}
|
||||||
if maxFee.Int == nil || maxFee.Equals(big.Zero()) {
|
if maxFee.Int == nil || maxFee.Equals(big.Zero()) {
|
||||||
mf, err := mff()
|
mf, err := mff()
|
||||||
@ -222,15 +224,12 @@ func CapGasFee(mff dtypes.DefaultMaxFeeFunc, msg *types.Message, sendSpec *api.M
|
|||||||
maxFee = mf
|
maxFee = mf
|
||||||
}
|
}
|
||||||
|
|
||||||
gl := types.NewInt(uint64(msg.GasLimit))
|
gaslimit := types.NewInt(uint64(msg.GasLimit))
|
||||||
totalFee := types.BigMul(msg.GasFeeCap, gl)
|
totalFee := types.BigMul(msg.GasFeeCap, gaslimit)
|
||||||
|
if maximizeFeeCap || totalFee.GreaterThan(maxFee) {
|
||||||
if totalFee.LessThanEqual(maxFee) {
|
msg.GasFeeCap = big.Div(maxFee, gaslimit)
|
||||||
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.GasFeeCap = big.Div(maxFee, gl)
|
|
||||||
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
|
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2289,7 +2289,8 @@ Inputs:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"MaxFee": "0",
|
"MaxFee": "0",
|
||||||
"MsgUuid": "07070707-0707-0707-0707-070707070707"
|
"MsgUuid": "07070707-0707-0707-0707-070707070707",
|
||||||
|
"MaximizeFeeCap": true
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -2766,7 +2767,8 @@ Inputs:
|
|||||||
],
|
],
|
||||||
{
|
{
|
||||||
"MaxFee": "0",
|
"MaxFee": "0",
|
||||||
"MsgUuid": "07070707-0707-0707-0707-070707070707"
|
"MsgUuid": "07070707-0707-0707-0707-070707070707",
|
||||||
|
"MaximizeFeeCap": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
@ -3025,7 +3027,8 @@ Inputs:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"MaxFee": "0",
|
"MaxFee": "0",
|
||||||
"MsgUuid": "07070707-0707-0707-0707-070707070707"
|
"MsgUuid": "07070707-0707-0707-0707-070707070707",
|
||||||
|
"MaximizeFeeCap": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
@ -3357,7 +3357,8 @@ Inputs:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"MaxFee": "0",
|
"MaxFee": "0",
|
||||||
"MsgUuid": "07070707-0707-0707-0707-070707070707"
|
"MsgUuid": "07070707-0707-0707-0707-070707070707",
|
||||||
|
"MaximizeFeeCap": true
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -3834,7 +3835,8 @@ Inputs:
|
|||||||
],
|
],
|
||||||
{
|
{
|
||||||
"MaxFee": "0",
|
"MaxFee": "0",
|
||||||
"MsgUuid": "07070707-0707-0707-0707-070707070707"
|
"MsgUuid": "07070707-0707-0707-0707-070707070707",
|
||||||
|
"MaximizeFeeCap": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
@ -4226,7 +4228,8 @@ Inputs:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"MaxFee": "0",
|
"MaxFee": "0",
|
||||||
"MsgUuid": "07070707-0707-0707-0707-070707070707"
|
"MsgUuid": "07070707-0707-0707-0707-070707070707",
|
||||||
|
"MaximizeFeeCap": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
@ -775,6 +775,10 @@
|
|||||||
# env var: LOTUS_FEES_MAXMARKETBALANCEADDFEE
|
# env var: LOTUS_FEES_MAXMARKETBALANCEADDFEE
|
||||||
#MaxMarketBalanceAddFee = "0.007 FIL"
|
#MaxMarketBalanceAddFee = "0.007 FIL"
|
||||||
|
|
||||||
|
# type: bool
|
||||||
|
# env var: LOTUS_FEES_MAXIMIZEWINDOWPOSTFEECAP
|
||||||
|
#MaximizeWindowPoStFeeCap = true
|
||||||
|
|
||||||
[Fees.MaxPreCommitBatchGasFee]
|
[Fees.MaxPreCommitBatchGasFee]
|
||||||
# type: types.FIL
|
# type: types.FIL
|
||||||
# env var: LOTUS_FEES_MAXPRECOMMITBATCHGASFEE_BASE
|
# env var: LOTUS_FEES_MAXPRECOMMITBATCHGASFEE_BASE
|
||||||
|
@ -253,6 +253,8 @@ func DefaultStorageMiner() *StorageMiner {
|
|||||||
MaxWindowPoStGasFee: types.MustParseFIL("5"),
|
MaxWindowPoStGasFee: types.MustParseFIL("5"),
|
||||||
MaxPublishDealsFee: types.MustParseFIL("0.05"),
|
MaxPublishDealsFee: types.MustParseFIL("0.05"),
|
||||||
MaxMarketBalanceAddFee: types.MustParseFIL("0.007"),
|
MaxMarketBalanceAddFee: types.MustParseFIL("0.007"),
|
||||||
|
|
||||||
|
MaximizeWindowPoStFeeCap: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
Addresses: MinerAddressConfig{
|
Addresses: MinerAddressConfig{
|
||||||
|
@ -721,6 +721,12 @@ over the worker address if this flag is set.`,
|
|||||||
Name: "MaxMarketBalanceAddFee",
|
Name: "MaxMarketBalanceAddFee",
|
||||||
Type: "types.FIL",
|
Type: "types.FIL",
|
||||||
|
|
||||||
|
Comment: ``,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "MaximizeWindowPoStFeeCap",
|
||||||
|
Type: "bool",
|
||||||
|
|
||||||
Comment: ``,
|
Comment: ``,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -490,6 +490,8 @@ type MinerFeeConfig struct {
|
|||||||
MaxWindowPoStGasFee types.FIL
|
MaxWindowPoStGasFee types.FIL
|
||||||
MaxPublishDealsFee types.FIL
|
MaxPublishDealsFee types.FIL
|
||||||
MaxMarketBalanceAddFee types.FIL
|
MaxMarketBalanceAddFee types.FIL
|
||||||
|
|
||||||
|
MaximizeWindowPoStFeeCap bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type MinerAddressConfig struct {
|
type MinerAddressConfig struct {
|
||||||
|
@ -650,7 +650,7 @@ func (s *WindowPoStScheduler) submitPoStMessage(ctx context.Context, proof *mine
|
|||||||
Params: enc,
|
Params: enc,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
}
|
}
|
||||||
spec := &api.MessageSendSpec{MaxFee: abi.TokenAmount(s.feeCfg.MaxWindowPoStGasFee)}
|
spec := &api.MessageSendSpec{MaxFee: abi.TokenAmount(s.feeCfg.MaxWindowPoStGasFee), MaximizeFeeCap: s.feeCfg.MaximizeWindowPoStFeeCap}
|
||||||
if err := s.prepareMessage(ctx, msg, spec); err != nil {
|
if err := s.prepareMessage(ctx, msg, spec); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -168,11 +168,11 @@ func (s *WindowPoStScheduler) declareRecoveries(ctx context.Context, dlIdx uint6
|
|||||||
Params: enc,
|
Params: enc,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
}
|
}
|
||||||
spec := &api.MessageSendSpec{MaxFee: abi.TokenAmount(s.feeCfg.MaxWindowPoStGasFee)}
|
spec := &api.MessageSendSpec{MaxFee: abi.TokenAmount(s.feeCfg.MaxWindowPoStGasFee), MaximizeFeeCap: s.feeCfg.MaximizeWindowPoStFeeCap}
|
||||||
if err := s.prepareMessage(ctx, msg, spec); err != nil {
|
if err := s.prepareMessage(ctx, msg, spec); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
sm, err := s.api.MpoolPushMessage(ctx, msg, &api.MessageSendSpec{MaxFee: abi.TokenAmount(s.feeCfg.MaxWindowPoStGasFee)})
|
sm, err := s.api.MpoolPushMessage(ctx, msg, spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("pushing message to mpool: %w", err)
|
return nil, nil, xerrors.Errorf("pushing message to mpool: %w", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user