Add GasLimitOverestimation to mpool config
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
44551124e2
commit
5f157affdd
@ -14,6 +14,7 @@ var (
|
|||||||
MemPoolSizeLimitHiDefault = 30000
|
MemPoolSizeLimitHiDefault = 30000
|
||||||
MemPoolSizeLimitLoDefault = 20000
|
MemPoolSizeLimitLoDefault = 20000
|
||||||
PruneCooldownDefault = time.Minute
|
PruneCooldownDefault = time.Minute
|
||||||
|
GasLimitOverestimation = 1.25
|
||||||
|
|
||||||
ConfigKey = datastore.NewKey("/mpool/config")
|
ConfigKey = datastore.NewKey("/mpool/config")
|
||||||
)
|
)
|
||||||
@ -34,6 +35,10 @@ func loadConfig(ds dtypes.MetadataDS) (*types.MpoolConfig, error) {
|
|||||||
}
|
}
|
||||||
cfg := new(types.MpoolConfig)
|
cfg := new(types.MpoolConfig)
|
||||||
err = json.Unmarshal(cfgBytes, cfg)
|
err = json.Unmarshal(cfgBytes, cfg)
|
||||||
|
if cfg.GasLimitOverestimation == 0 {
|
||||||
|
// TODO: remove in next reset
|
||||||
|
cfg.GasLimitOverestimation = GasLimitOverestimation
|
||||||
|
}
|
||||||
return cfg, err
|
return cfg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,9 +70,10 @@ func (mp *MessagePool) SetConfig(cfg *types.MpoolConfig) {
|
|||||||
|
|
||||||
func DefaultConfig() *types.MpoolConfig {
|
func DefaultConfig() *types.MpoolConfig {
|
||||||
return &types.MpoolConfig{
|
return &types.MpoolConfig{
|
||||||
SizeLimitHigh: MemPoolSizeLimitHiDefault,
|
SizeLimitHigh: MemPoolSizeLimitHiDefault,
|
||||||
SizeLimitLow: MemPoolSizeLimitLoDefault,
|
SizeLimitLow: MemPoolSizeLimitLoDefault,
|
||||||
ReplaceByFeeRatio: ReplaceByFeeRatioDefault,
|
ReplaceByFeeRatio: ReplaceByFeeRatioDefault,
|
||||||
PruneCooldown: PruneCooldownDefault,
|
PruneCooldown: PruneCooldownDefault,
|
||||||
|
GasLimitOverestimation: GasLimitOverestimation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MpoolConfig struct {
|
type MpoolConfig struct {
|
||||||
PriorityAddrs []address.Address
|
PriorityAddrs []address.Address
|
||||||
SizeLimitHigh int
|
SizeLimitHigh int
|
||||||
SizeLimitLow int
|
SizeLimitLow int
|
||||||
ReplaceByFeeRatio float64
|
ReplaceByFeeRatio float64
|
||||||
PruneCooldown time.Duration
|
PruneCooldown time.Duration
|
||||||
|
GasLimitOverestimation float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MpoolConfig) Clone() *MpoolConfig {
|
func (mc *MpoolConfig) Clone() *MpoolConfig {
|
||||||
|
@ -106,7 +106,6 @@ func (a *MpoolAPI) MpoolPush(ctx context.Context, smsg *types.SignedMessage) (ci
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GasMargin sets by how much should gas used be increased over test execution
|
// GasMargin sets by how much should gas used be increased over test execution
|
||||||
var GasMargin = 1.5
|
|
||||||
|
|
||||||
func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*types.SignedMessage, error) {
|
func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*types.SignedMessage, error) {
|
||||||
if msg.Nonce != 0 {
|
if msg.Nonce != 0 {
|
||||||
@ -117,7 +116,7 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("estimating gas used: %w", err)
|
return nil, xerrors.Errorf("estimating gas used: %w", err)
|
||||||
}
|
}
|
||||||
msg.GasLimit = int64(float64(gasLimit) * GasMargin)
|
msg.GasLimit = int64(float64(gasLimit) * a.Mpool.GetConfig().GasLimitOverestimation)
|
||||||
}
|
}
|
||||||
|
|
||||||
if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 {
|
if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user