Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracted Gas Limit Multiplier from gas estimators to WrappedEvmEstimator #12534

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
49a0a1c
Applied LimitMultiplier to chainSpecificGasLimit in all gas estimators
silaslenihan Mar 21, 2024
9d0da6f
Added changeset
silaslenihan Mar 21, 2024
d65615f
altered tests to use a limit multiplier of 1.5 rather than 1
silaslenihan Mar 21, 2024
f3415c1
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 21, 2024
cf9002e
improve some nits and refactor foundry tests (#12522)
FelixFan1992 Mar 21, 2024
933524f
Added error checks
silaslenihan Mar 21, 2024
58f0336
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 21, 2024
87cf9e9
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 22, 2024
843766f
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 22, 2024
c39b995
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 22, 2024
a91e13f
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 22, 2024
33447f6
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 22, 2024
4971c26
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 25, 2024
4a0d405
updated existing tests
silaslenihan Mar 25, 2024
d37b71f
Extracted fee limit multiplier out of indivudal gas estimators, into …
silaslenihan Mar 25, 2024
da7d128
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 25, 2024
c0964fd
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 25, 2024
0c2a4bb
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 25, 2024
ffc2cf2
Cleaned up unused LimitMultipliers
silaslenihan Mar 26, 2024
ef5e761
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 26, 2024
ed5a50f
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 26, 2024
773d9b0
Removed unused limit multipliers in tests and cleaned up
silaslenihan Mar 26, 2024
ebf465a
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 26, 2024
d84c214
removed chainSpecificGasLimit from BumpDynamicFee, GetDynamicFee
silaslenihan Mar 26, 2024
da360f7
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 26, 2024
b9a0cce
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 26, 2024
3d5a0cb
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 26, 2024
ea6e6a4
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 26, 2024
4ad0d7e
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 27, 2024
2a62ed1
Fixed failing tests
silaslenihan Mar 27, 2024
f313676
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 27, 2024
1d20f79
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 27, 2024
6362c28
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 27, 2024
1c7b57c
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 27, 2024
ca8e467
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 28, 2024
b6dfef6
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 28, 2024
c25b2ca
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
silaslenihan Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wicked-suits-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Extracted Gas Limit Multiplier from gas estimators to WrappedEvmEstimator.
4 changes: 2 additions & 2 deletions core/chains/evm/gas/arbitrum_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestArbitrumEstimator(t *testing.T) {
rpcClient := mocks.NewRPCClient(t)
ethClient := mocks.NewETHClient(t)
o := gas.NewArbitrumEstimator(logger.Test(t), &arbConfig{}, rpcClient, ethClient)
_, _, err := o.GetDynamicFee(testutils.Context(t), gasLimit, maxGasPrice)
_, err := o.GetDynamicFee(testutils.Context(t), maxGasPrice)
assert.EqualError(t, err, "dynamic fees are not implemented for this estimator")
})

Expand All @@ -180,7 +180,7 @@ func TestArbitrumEstimator(t *testing.T) {
FeeCap: assets.NewWeiI(42),
TipCap: assets.NewWeiI(5),
}
_, _, err := o.BumpDynamicFee(testutils.Context(t), fee, gasLimit, maxGasPrice, nil)
_, err := o.BumpDynamicFee(testutils.Context(t), fee, maxGasPrice, nil)
assert.EqualError(t, err, "dynamic fees are not implemented for this estimator")
})

Expand Down
27 changes: 13 additions & 14 deletions core/chains/evm/gas/block_history_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ type chainConfig interface {
type estimatorGasEstimatorConfig interface {
EIP1559DynamicFees() bool
BumpThreshold() uint64
LimitMultiplier() float32
PriceDefault() *assets.Wei
TipCapDefault() *assets.Wei
TipCapMin() *assets.Wei
Expand Down Expand Up @@ -264,7 +263,7 @@ func (b *BlockHistoryEstimator) GetLegacyGas(_ context.Context, _ []byte, gasLim
gasPrice = b.eConfig.PriceDefault()
}
gasPrice = capGasPrice(gasPrice, maxGasPriceWei, b.eConfig.PriceMax())
chainSpecificGasLimit, err = commonfee.ApplyMultiplier(gasLimit, b.eConfig.LimitMultiplier())
chainSpecificGasLimit = gasLimit
return
}

Expand Down Expand Up @@ -298,7 +297,11 @@ func (b *BlockHistoryEstimator) BumpLegacyGas(_ context.Context, originalGasPric
return nil, 0, err
}
}
return BumpLegacyGasPriceOnly(b.eConfig, b.logger, b.getGasPrice(), originalGasPrice, gasLimit, maxGasPriceWei)
bumpedGasPrice, err = BumpLegacyGasPriceOnly(b.eConfig, b.logger, b.getGasPrice(), originalGasPrice, maxGasPriceWei)
if err != nil {
return nil, 0, err
}
return bumpedGasPrice, gasLimit, err
}

// checkConnectivity detects if the transaction is not being included due to
Expand Down Expand Up @@ -388,18 +391,14 @@ func (b *BlockHistoryEstimator) checkConnectivity(attempts []EvmPriorAttempt) er
return nil
}

func (b *BlockHistoryEstimator) GetDynamicFee(_ context.Context, gasLimit uint64, maxGasPriceWei *assets.Wei) (fee DynamicFee, chainSpecificGasLimit uint64, err error) {
func (b *BlockHistoryEstimator) GetDynamicFee(_ context.Context, maxGasPriceWei *assets.Wei) (fee DynamicFee, err error) {
if !b.eConfig.EIP1559DynamicFees() {
return fee, 0, pkgerrors.New("Can't get dynamic fee, EIP1559 is disabled")
return fee, pkgerrors.New("Can't get dynamic fee, EIP1559 is disabled")
}

var feeCap *assets.Wei
var tipCap *assets.Wei
ok := b.IfStarted(func() {
chainSpecificGasLimit, err = commonfee.ApplyMultiplier(gasLimit, b.eConfig.LimitMultiplier())
if err != nil {
return
}
b.priceMu.RLock()
defer b.priceMu.RUnlock()
tipCap = b.tipCap
Expand Down Expand Up @@ -431,10 +430,10 @@ func (b *BlockHistoryEstimator) GetDynamicFee(_ context.Context, gasLimit uint64
}
})
if !ok {
return fee, 0, pkgerrors.New("BlockHistoryEstimator is not started; cannot estimate gas")
return fee, pkgerrors.New("BlockHistoryEstimator is not started; cannot estimate gas")
}
if err != nil {
return fee, 0, err
return fee, err
}
fee.FeeCap = feeCap
fee.TipCap = tipCap
Expand All @@ -461,18 +460,18 @@ func calcFeeCap(latestAvailableBaseFeePerGas *assets.Wei, bufferBlocks int, tipC
return feeCap
}

func (b *BlockHistoryEstimator) BumpDynamicFee(_ context.Context, originalFee DynamicFee, originalGasLimit uint64, maxGasPriceWei *assets.Wei, attempts []EvmPriorAttempt) (bumped DynamicFee, chainSpecificGasLimit uint64, err error) {
func (b *BlockHistoryEstimator) BumpDynamicFee(_ context.Context, originalFee DynamicFee, maxGasPriceWei *assets.Wei, attempts []EvmPriorAttempt) (bumped DynamicFee, err error) {
if b.bhConfig.CheckInclusionBlocks() > 0 {
if err = b.checkConnectivity(attempts); err != nil {
if pkgerrors.Is(err, commonfee.ErrConnectivity) {
b.logger.Criticalw(BumpingHaltedLabel, "err", err)
b.SvcErrBuffer.Append(err)
promBlockHistoryEstimatorConnectivityFailureCount.WithLabelValues(b.chainID.String(), "eip1559").Inc()
}
return bumped, 0, err
return bumped, err
}
}
return BumpDynamicFeeOnly(b.eConfig, b.bhConfig.EIP1559FeeCapBufferBlocks(), b.logger, b.getTipCap(), b.getCurrentBaseFee(), originalFee, originalGasLimit, maxGasPriceWei)
return BumpDynamicFeeOnly(b.eConfig, b.bhConfig.EIP1559FeeCapBufferBlocks(), b.logger, b.getTipCap(), b.getCurrentBaseFee(), originalFee, maxGasPriceWei)
}

func (b *BlockHistoryEstimator) runLoop() {
Expand Down
Loading
Loading