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

Cherry-Picked Dynamic Gas Estimation for Mantle #1460

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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/great-timers-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Updated gas limit estimation feature to set From address #internal
5 changes: 5 additions & 0 deletions .changeset/loud-windows-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Added gas limit estimation feature to EVM gas estimators. Introduced a new config `EVM.GasEstimator.EstimateLimit` to toggle this feature. #added
1 change: 1 addition & 0 deletions common/fee/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
ErrBumpFeeExceedsLimit = errors.New("fee bump exceeds limit")
ErrBump = errors.New("fee bump failed")
ErrConnectivity = errors.New("transaction propagation issue: transactions are not being mined")
ErrFeeLimitTooLow = errors.New("provided fee limit too low")
)

func IsBumpErr(err error) bool {
Expand Down
7 changes: 6 additions & 1 deletion common/txmgr/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/utils"

"github.com/smartcontractkit/chainlink/v2/common/client"
commonfee "github.com/smartcontractkit/chainlink/v2/common/fee"
feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types"
txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types"
"github.com/smartcontractkit/chainlink/v2/common/types"
Expand Down Expand Up @@ -434,7 +435,11 @@ func (eb *Broadcaster[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) hand
}

attempt, _, _, retryable, err := eb.NewTxAttempt(ctx, *etx, eb.lggr)
if err != nil {
// Mark transaction as fatal if provided gas limit is set too low
if errors.Is(err, commonfee.ErrFeeLimitTooLow) {
etx.Error = null.StringFrom(commonfee.ErrFeeLimitTooLow.Error())
return eb.saveFatallyErroredTransaction(eb.lggr, etx), false
} else if err != nil {
return fmt.Errorf("processUnstartedTxs failed on NewAttempt: %w", err), retryable
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ func (g *TestGasEstimatorConfig) LimitJobType() evmconfig.LimitJobType {
func (g *TestGasEstimatorConfig) PriceMaxKey(addr common.Address) *assets.Wei {
return assets.GWei(1)
}
func (g *TestGasEstimatorConfig) EstimateLimit() bool { return false }

func (e *TestEvmConfig) GasEstimator() evmconfig.GasEstimator {
return &TestGasEstimatorConfig{bumpThreshold: e.BumpThreshold}
Expand Down
4 changes: 4 additions & 0 deletions core/chains/evm/config/chain_scoped_gas_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func (g *gasEstimatorConfig) LimitJobType() LimitJobType {
return &limitJobTypeConfig{c: g.c.LimitJobType}
}

func (g *gasEstimatorConfig) EstimateLimit() bool {
return *g.c.EstimateLimit
}

type limitJobTypeConfig struct {
c toml.GasLimitJobType
}
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ type GasEstimator interface {
PriceMin() *assets.Wei
Mode() string
PriceMaxKey(gethcommon.Address) *assets.Wei
EstimateLimit() bool
}

type LimitJobType interface {
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func TestChainScopedConfig_GasEstimator(t *testing.T) {
assert.Equal(t, assets.GWei(100), ge.FeeCapDefault())
assert.Equal(t, assets.NewWeiI(1), ge.TipCapDefault())
assert.Equal(t, assets.NewWeiI(1), ge.TipCapMin())
assert.Equal(t, false, ge.EstimateLimit())
}

func TestChainScopedConfig_BSCDefaults(t *testing.T) {
Expand Down
45 changes: 45 additions & 0 deletions core/chains/evm/config/mocks/gas_estimator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ type GasEstimator struct {
LimitMultiplier *decimal.Decimal
LimitTransfer *uint64
LimitJobType GasLimitJobType `toml:",omitempty"`
EstimateLimit *bool

BumpMin *assets.Wei
BumpPercent *uint16
Expand Down Expand Up @@ -641,6 +642,9 @@ func (e *GasEstimator) setFrom(f *GasEstimator) {
if v := f.LimitTransfer; v != nil {
e.LimitTransfer = v
}
if v := f.EstimateLimit; v != nil {
e.EstimateLimit = v
}
if v := f.PriceDefault; v != nil {
e.PriceDefault = v
}
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/toml/defaults/fallback.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ EIP1559DynamicFees = false
FeeCapDefault = '100 gwei'
TipCapDefault = '1'
TipCapMin = '1'
EstimateLimit = false

[GasEstimator.BlockHistory]
BatchSize = 25
Expand Down
5 changes: 5 additions & 0 deletions core/chains/evm/gas/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ type MockGasEstimatorConfig struct {
FeeCapDefaultF *assets.Wei
LimitMaxF uint64
ModeF string
EstimateLimitF bool
}

func NewMockGasConfig() *MockGasEstimatorConfig {
Expand Down Expand Up @@ -214,3 +215,7 @@ func (m *MockGasEstimatorConfig) LimitMax() uint64 {
func (m *MockGasEstimatorConfig) Mode() string {
return m.ModeF
}

func (m *MockGasEstimatorConfig) EstimateLimit() bool {
return m.EstimateLimitF
}
78 changes: 42 additions & 36 deletions core/chains/evm/gas/mocks/evm_fee_estimator.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading