From 5f157affdddef86c8a38e2f39cd02f0e722d0a1e Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sat, 8 Aug 2020 17:09:47 +0200 Subject: [PATCH] Add GasLimitOverestimation to mpool config Signed-off-by: Jakub Sztandera --- chain/messagepool/config.go | 14 ++++++++++---- chain/types/mpool.go | 11 ++++++----- node/impl/full/mpool.go | 3 +-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/chain/messagepool/config.go b/chain/messagepool/config.go index 4e1b07062..eaf6ca75b 100644 --- a/chain/messagepool/config.go +++ b/chain/messagepool/config.go @@ -14,6 +14,7 @@ var ( MemPoolSizeLimitHiDefault = 30000 MemPoolSizeLimitLoDefault = 20000 PruneCooldownDefault = time.Minute + GasLimitOverestimation = 1.25 ConfigKey = datastore.NewKey("/mpool/config") ) @@ -34,6 +35,10 @@ func loadConfig(ds dtypes.MetadataDS) (*types.MpoolConfig, error) { } cfg := new(types.MpoolConfig) err = json.Unmarshal(cfgBytes, cfg) + if cfg.GasLimitOverestimation == 0 { + // TODO: remove in next reset + cfg.GasLimitOverestimation = GasLimitOverestimation + } return cfg, err } @@ -65,9 +70,10 @@ func (mp *MessagePool) SetConfig(cfg *types.MpoolConfig) { func DefaultConfig() *types.MpoolConfig { return &types.MpoolConfig{ - SizeLimitHigh: MemPoolSizeLimitHiDefault, - SizeLimitLow: MemPoolSizeLimitLoDefault, - ReplaceByFeeRatio: ReplaceByFeeRatioDefault, - PruneCooldown: PruneCooldownDefault, + SizeLimitHigh: MemPoolSizeLimitHiDefault, + SizeLimitLow: MemPoolSizeLimitLoDefault, + ReplaceByFeeRatio: ReplaceByFeeRatioDefault, + PruneCooldown: PruneCooldownDefault, + GasLimitOverestimation: GasLimitOverestimation, } } diff --git a/chain/types/mpool.go b/chain/types/mpool.go index cd6a99a47..cf08177e9 100644 --- a/chain/types/mpool.go +++ b/chain/types/mpool.go @@ -7,11 +7,12 @@ import ( ) type MpoolConfig struct { - PriorityAddrs []address.Address - SizeLimitHigh int - SizeLimitLow int - ReplaceByFeeRatio float64 - PruneCooldown time.Duration + PriorityAddrs []address.Address + SizeLimitHigh int + SizeLimitLow int + ReplaceByFeeRatio float64 + PruneCooldown time.Duration + GasLimitOverestimation float64 } func (mc *MpoolConfig) Clone() *MpoolConfig { diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index ac1bb58eb..3d2e7cfd2 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -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 -var GasMargin = 1.5 func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*types.SignedMessage, error) { if msg.Nonce != 0 { @@ -117,7 +116,7 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t if err != nil { 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 {