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 4 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/loud-shoes-unite.md
silaslenihan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Applied LimitMultiplier to chainSpecificGasLimit in all gas estimators. Updated TestArbitrumEstimator and TestSuggestedPriceEstimator to reflect this addition.
silaslenihan marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 5 additions & 1 deletion core/chains/evm/gas/arbitrum_estimator.go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unused changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just cleaned this up, additionally, I removed any reference to LimitMultiplier() where they already existed in the block history estimator and fixed price estimator since those aren't being used anymore, the LimitMultiplier() only needs to be in the gas estimator config stored by the WrappedEvmEstimator

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink-common/pkg/utils"

commonfee "github.com/smartcontractkit/chainlink/v2/common/fee"
feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
Expand All @@ -26,6 +27,7 @@ type ArbConfig interface {
LimitMax() uint64
BumpPercent() uint16
BumpMin() *assets.Wei
LimitMultiplier() float32
}

//go:generate mockery --quiet --name ethClient --output ./mocks/ --case=underscore --structname ETHClient
Expand Down Expand Up @@ -134,7 +136,9 @@ func (a *arbitrumEstimator) GetLegacyGas(ctx context.Context, calldata []byte, l
}
}
perL2Tx, perL1CalldataUnit := a.getPricesInArbGas()
chainSpecificGasLimit = l2GasLimit + uint64(perL2Tx) + uint64(len(calldata))*uint64(perL1CalldataUnit)
originalGasLimit := l2GasLimit + uint64(perL2Tx) + uint64(len(calldata))*uint64(perL1CalldataUnit)
chainSpecificGasLimit, err = commonfee.ApplyMultiplier(originalGasLimit, a.cfg.LimitMultiplier())
silaslenihan marked this conversation as resolved.
Show resolved Hide resolved

a.logger.Debugw("GetLegacyGas", "l2GasLimit", l2GasLimit, "calldataLen", len(calldata), "perL2Tx", perL2Tx,
"perL1CalldataUnit", perL1CalldataUnit, "chainSpecificGasLimit", chainSpecificGasLimit)
})
Expand Down
22 changes: 14 additions & 8 deletions core/chains/evm/gas/arbitrum_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import (
)

type arbConfig struct {
v uint64
bumpPercent uint16
bumpMin *assets.Wei
v uint64
bumpPercent uint16
bumpMin *assets.Wei
limitMultiplier float32
}

func (a *arbConfig) LimitMax() uint64 {
Expand All @@ -40,6 +41,10 @@ func (a *arbConfig) BumpMin() *assets.Wei {
return a.bumpMin
}

func (a *arbConfig) LimitMultiplier() float32 {
return a.limitMultiplier
}

func TestArbitrumEstimator(t *testing.T) {
t.Parallel()

Expand All @@ -50,6 +55,7 @@ func TestArbitrumEstimator(t *testing.T) {
const gasPriceBufferPercentage = 50
const bumpPercent = 10
var bumpMin = assets.NewWei(big.NewInt(1))
const limitMultiplier = 1.5

t.Run("calling GetLegacyGas on unstarted estimator returns error", func(t *testing.T) {
rpcClient := mocks.NewRPCClient(t)
Expand Down Expand Up @@ -78,13 +84,13 @@ func TestArbitrumEstimator(t *testing.T) {
assert.Equal(t, big.NewInt(-1), blockNumber)
}).Return(zeros.Bytes(), nil)

o := gas.NewArbitrumEstimator(logger.Test(t), &arbConfig{v: maxGasLimit, bumpPercent: bumpPercent, bumpMin: bumpMin}, rpcClient, ethClient)
o := gas.NewArbitrumEstimator(logger.Test(t), &arbConfig{v: maxGasLimit, bumpPercent: bumpPercent, bumpMin: bumpMin, limitMultiplier: limitMultiplier}, rpcClient, ethClient)
servicetest.RunHealthy(t, o)
gasPrice, chainSpecificGasLimit, err := o.GetLegacyGas(testutils.Context(t), calldata, gasLimit, maxGasPrice)
require.NoError(t, err)
// Expected price for a standard l2_suggested_estimator would be 42, but we add a fixed gasPriceBufferPercentage.
assert.Equal(t, assets.NewWeiI(42).AddPercentage(gasPriceBufferPercentage), gasPrice)
assert.Equal(t, gasLimit, chainSpecificGasLimit)
assert.Equal(t, uint64(float32(gasLimit)*limitMultiplier), chainSpecificGasLimit)
})

t.Run("gas price is lower than user specified max gas price", func(t *testing.T) {
Expand Down Expand Up @@ -209,14 +215,14 @@ func TestArbitrumEstimator(t *testing.T) {
assert.Equal(t, big.NewInt(-1), blockNumber)
}).Return(b.Bytes(), nil)

o := gas.NewArbitrumEstimator(logger.Test(t), &arbConfig{v: maxGasLimit, bumpPercent: bumpPercent, bumpMin: bumpMin}, rpcClient, ethClient)
o := gas.NewArbitrumEstimator(logger.Test(t), &arbConfig{v: maxGasLimit, bumpPercent: bumpPercent, bumpMin: bumpMin, limitMultiplier: limitMultiplier}, rpcClient, ethClient)
servicetest.RunHealthy(t, o)
gasPrice, chainSpecificGasLimit, err := o.GetLegacyGas(testutils.Context(t), calldata, gasLimit, maxGasPrice)
require.NoError(t, err)
require.NotNil(t, gasPrice)
// Again, a normal l2_suggested_estimator would return 42, but arbitrum_estimator adds a buffer.
assert.Equal(t, "63 wei", gasPrice.String())
assert.Equal(t, expLimit, chainSpecificGasLimit, "expected %d but got %d", expLimit, chainSpecificGasLimit)
assert.Equal(t, uint64(float32(expLimit)*limitMultiplier), chainSpecificGasLimit, "expected %d but got %d", expLimit, chainSpecificGasLimit)
})

t.Run("limit exceeds max", func(t *testing.T) {
Expand All @@ -243,7 +249,7 @@ func TestArbitrumEstimator(t *testing.T) {
assert.Equal(t, big.NewInt(-1), blockNumber)
}).Return(b.Bytes(), nil)

o := gas.NewArbitrumEstimator(logger.Test(t), &arbConfig{v: maxGasLimit, bumpPercent: bumpPercent, bumpMin: bumpMin}, rpcClient, ethClient)
o := gas.NewArbitrumEstimator(logger.Test(t), &arbConfig{v: maxGasLimit, bumpPercent: bumpPercent, bumpMin: bumpMin, limitMultiplier: limitMultiplier}, rpcClient, ethClient)
servicetest.RunHealthy(t, o)
gasPrice, chainSpecificGasLimit, err := o.GetLegacyGas(testutils.Context(t), calldata, gasLimit, maxGasPrice)
require.Error(t, err, "expected error but got (%s, %d)", gasPrice, chainSpecificGasLimit)
Expand Down
11 changes: 8 additions & 3 deletions core/chains/evm/gas/cmd/arbgas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ func withEstimator(ctx context.Context, lggr logger.SugaredLogger, url string, f
var _ gas.ArbConfig = &config{}

type config struct {
max uint64
bumpPercent uint16
bumpMin *assets.Wei
max uint64
bumpPercent uint16
bumpMin *assets.Wei
limitMultiplier float32
}

func (c *config) LimitMax() uint64 {
Expand All @@ -83,3 +84,7 @@ func (c *config) BumpPercent() uint16 {
func (c *config) BumpMin() *assets.Wei {
return c.bumpMin
}

func (c *config) LimitMultiplier() float32 {
return c.limitMultiplier
}
6 changes: 4 additions & 2 deletions core/chains/evm/gas/suggested_price_estimator.go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling out that there is a weird interaction going on here that seems to take place in the BHE as well. If we apply the multiplier during each bumping it means that successive bumping requests will result in multiple gas limit bumps, which is usually not the desired behaviour. We haven't encountered this issue yet because LimitMultiplier was set to 1 so far.

Copy link
Contributor Author

@silaslenihan silaslenihan Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, since the multiplier should already be included in the originalFee when bumping the gas, it probably doesn't make sense to include the multiplier again in the gas bumping. Am I understanding this correctly @dimriou?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can ensure gas bumping will reuse the already multiplied gas limit value from the previous attempt, same as it does for the BHE, then yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that familiar with the codebase atp, but isn't the only way to calculate that original fee used in BumpLegacyGas to use getLegacyGas which accounts for the multiplier? From my understanding, BumpLegacyGas implies there was a previous attempt where the limit multiplier was applied.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feeLimit param sent to BumpFee() and thus to BumpLegacyGas() and BumpDynamicFee(), is actually the original feeLimit sent by the user.
It is sent from here:

bumpedFee, bumpedFeeLimit, err = c.EvmFeeEstimator.BumpFee(ctx, previousAttempt.TxFee, etx.FeeLimit, keySpecificMaxGasPriceWei, newEvmPriorAttempts(priorAttempts))

I would think the easiest and best approach to apply the limitMultiplier would actually be in this above file(attempts.go) which controls all Fee calculations.
Everywhere that it sends etx.FeeLimit, we should already apply the multiplier. Then the various gas estimators don't need to separately account for it. It will be cleaner like this.
I see 2 functions in this file where we send the limit. NewTxAttemptWithType() and NewBumpTxAttempt().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prashantkumar1982 I don't think we can remove this responsibility from gas estimator. Like for Arbitrum, the tx.FeeLimit might just be a piece of a calculated gas limit that needs to be multiplied in the end. I agree that making sure individual estimators are applying this multiplier probably isn't the best though. What if we store a copy of the gas estimator config in the WrappedEvmEstimator and apply this multiplier in the GetFee and BumpFee methods? Then estimators that don't require calculations can just pass the gas limit through like chainSpecificGasLimit = GasLimit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we store a copy of the gas estimator config in the WrappedEvmEstimator and apply this multiplier in the GetFee and BumpFee methods?

@amit-momin Agreed, this seems like the cleanest solution.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we pass the original etx fee limit why isn't the original solution sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the original solution do you mean, applying the multiplier in the individual estimators? If so, that would work too but applying the multiplier in a centralized place in WrappedEvmEstimator seems like the better place for it. It would help us avoid the reason we needed this PR where the multiplier was only applied in some estimator even though the expectation is should always be applied.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, makes sense.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
bigmath "github.com/smartcontractkit/chainlink-common/pkg/utils/big_math"

"github.com/smartcontractkit/chainlink/v2/common/fee"
commonfee "github.com/smartcontractkit/chainlink/v2/common/fee"
feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
evmclient "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
Expand All @@ -29,6 +30,7 @@ var (
type suggestedPriceConfig interface {
BumpPercent() uint16
BumpMin() *assets.Wei
LimitMultiplier() float32
}

//go:generate mockery --quiet --name rpcClient --output ./mocks/ --case=underscore --structname RPCClient
Expand Down Expand Up @@ -165,7 +167,7 @@ func (*SuggestedPriceEstimator) BumpDynamicFee(_ context.Context, _ DynamicFee,
}

func (o *SuggestedPriceEstimator) GetLegacyGas(ctx context.Context, _ []byte, GasLimit uint64, maxGasPriceWei *assets.Wei, opts ...feetypes.Opt) (gasPrice *assets.Wei, chainSpecificGasLimit uint64, err error) {
chainSpecificGasLimit = GasLimit
chainSpecificGasLimit, err = commonfee.ApplyMultiplier(GasLimit, o.cfg.LimitMultiplier())
silaslenihan marked this conversation as resolved.
Show resolved Hide resolved
ok := o.IfStarted(func() {
if slices.Contains(opts, feetypes.OptForceRefetch) {
err = o.forceRefresh(ctx)
Expand Down Expand Up @@ -193,7 +195,7 @@ func (o *SuggestedPriceEstimator) GetLegacyGas(ctx context.Context, _ []byte, Ga
// The only reason bumping logic would be called on the SuggestedPriceEstimator is if there was a significant price spike
// between the last price update and when the tx was submitted. Refreshing the price helps ensure the latest market changes are accounted for.
func (o *SuggestedPriceEstimator) BumpLegacyGas(ctx context.Context, originalFee *assets.Wei, feeLimit uint64, maxGasPriceWei *assets.Wei, _ []EvmPriorAttempt) (newGasPrice *assets.Wei, chainSpecificGasLimit uint64, err error) {
chainSpecificGasLimit = feeLimit
chainSpecificGasLimit, err = commonfee.ApplyMultiplier(feeLimit, o.cfg.LimitMultiplier())
silaslenihan marked this conversation as resolved.
Show resolved Hide resolved
ok := o.IfStarted(func() {
// Immediately return error if original fee is greater than or equal to the max gas price
// Prevents a loop of resubmitting the attempt with the max gas price
Expand Down
17 changes: 9 additions & 8 deletions core/chains/evm/gas/suggested_price_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ func TestSuggestedPriceEstimator(t *testing.T) {

calldata := []byte{0x00, 0x00, 0x01, 0x02, 0x03}
const gasLimit uint64 = 80000
const limitMultiplier = 1.5
amit-momin marked this conversation as resolved.
Show resolved Hide resolved

cfg := &gas.MockGasEstimatorConfig{BumpPercentF: 10, BumpMinF: assets.NewWei(big.NewInt(1)), BumpThresholdF: 1}
cfg := &gas.MockGasEstimatorConfig{BumpPercentF: 10, BumpMinF: assets.NewWei(big.NewInt(1)), BumpThresholdF: 1, LimitMultiplierF: limitMultiplier}

t.Run("calling GetLegacyGas on unstarted estimator returns error", func(t *testing.T) {
client := mocks.NewRPCClient(t)
Expand All @@ -47,7 +48,7 @@ func TestSuggestedPriceEstimator(t *testing.T) {
gasPrice, chainSpecificGasLimit, err := o.GetLegacyGas(testutils.Context(t), calldata, gasLimit, maxGasPrice)
require.NoError(t, err)
assert.Equal(t, assets.NewWeiI(42), gasPrice)
assert.Equal(t, gasLimit, chainSpecificGasLimit)
assert.Equal(t, uint64(float32(gasLimit)*limitMultiplier), chainSpecificGasLimit)
})

t.Run("gas price is lower than user specified max gas price", func(t *testing.T) {
Expand Down Expand Up @@ -132,7 +133,7 @@ func TestSuggestedPriceEstimator(t *testing.T) {
gasPrice, chainSpecificGasLimit, err := o.BumpLegacyGas(testutils.Context(t), assets.NewWeiI(10), gasLimit, maxGasPrice, nil)
require.NoError(t, err)
assert.Equal(t, assets.NewWeiI(44), gasPrice)
assert.Equal(t, gasLimit, chainSpecificGasLimit)
assert.Equal(t, uint64(float32(gasLimit)*limitMultiplier), chainSpecificGasLimit)
})

t.Run("calling BumpLegacyGas on started estimator returns new price buffered with bumpMin", func(t *testing.T) {
Expand All @@ -142,13 +143,13 @@ func TestSuggestedPriceEstimator(t *testing.T) {
(*big.Int)(res).SetInt64(40)
})

testCfg := &gas.MockGasEstimatorConfig{BumpPercentF: 1, BumpMinF: assets.NewWei(big.NewInt(1)), BumpThresholdF: 1}
testCfg := &gas.MockGasEstimatorConfig{BumpPercentF: 1, BumpMinF: assets.NewWei(big.NewInt(1)), BumpThresholdF: 1, LimitMultiplierF: limitMultiplier}
o := gas.NewSuggestedPriceEstimator(logger.Test(t), client, testCfg)
servicetest.RunHealthy(t, o)
gasPrice, chainSpecificGasLimit, err := o.BumpLegacyGas(testutils.Context(t), assets.NewWeiI(10), gasLimit, maxGasPrice, nil)
require.NoError(t, err)
assert.Equal(t, assets.NewWeiI(41), gasPrice)
assert.Equal(t, gasLimit, chainSpecificGasLimit)
assert.Equal(t, uint64(float32(gasLimit)*limitMultiplier), chainSpecificGasLimit)
})

t.Run("calling BumpLegacyGas on started estimator returns original price when lower than previous", func(t *testing.T) {
Expand All @@ -163,7 +164,7 @@ func TestSuggestedPriceEstimator(t *testing.T) {
gasPrice, chainSpecificGasLimit, err := o.BumpLegacyGas(testutils.Context(t), assets.NewWeiI(10), gasLimit, maxGasPrice, nil)
require.NoError(t, err)
assert.Equal(t, assets.NewWeiI(10), gasPrice)
assert.Equal(t, gasLimit, chainSpecificGasLimit)
assert.Equal(t, uint64(float32(gasLimit)*limitMultiplier), chainSpecificGasLimit)
})

t.Run("calling BumpLegacyGas on started estimator returns error, suggested gas price is higher than max gas price", func(t *testing.T) {
Expand Down Expand Up @@ -196,7 +197,7 @@ func TestSuggestedPriceEstimator(t *testing.T) {
gasPrice, chainSpecificGasLimit, err := o.BumpLegacyGas(testutils.Context(t), assets.NewWeiI(10), gasLimit, assets.NewWeiI(40), nil)
require.NoError(t, err)
assert.Equal(t, assets.NewWeiI(40), gasPrice)
assert.Equal(t, gasLimit, chainSpecificGasLimit)
assert.Equal(t, uint64(float32(gasLimit)*limitMultiplier), chainSpecificGasLimit)
})

t.Run("calling BumpLegacyGas on started estimator if initial call failed returns error", func(t *testing.T) {
Expand Down Expand Up @@ -226,6 +227,6 @@ func TestSuggestedPriceEstimator(t *testing.T) {
gasPrice, chainSpecificGasLimit, err := o.BumpLegacyGas(testutils.Context(t), assets.NewWeiI(10), gasLimit, maxGasPrice, nil)
require.NoError(t, err)
assert.Equal(t, assets.NewWeiI(44), gasPrice)
assert.Equal(t, gasLimit, chainSpecificGasLimit)
assert.Equal(t, uint64(float32(gasLimit)*limitMultiplier), chainSpecificGasLimit)
})
}
Loading