Skip to content

Commit b25db0b

Browse files
authored
OEV-699 Introduce relayConfig.GasLimit to override gas limit on job level (#302)
1 parent 31bd57b commit b25db0b

File tree

6 files changed

+445
-10
lines changed

6 files changed

+445
-10
lines changed

pkg/.mockery.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ packages:
2424
ChainScopedConfig:
2525
EVM:
2626
Workflow:
27+
LimitJobType:
2728
github.com/smartcontractkit/chainlink-evm/pkg/gas:
2829
interfaces:
2930
EvmFeeEstimator:

pkg/config/mocks/limit_job_type.go

Lines changed: 314 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ type RelayConfig struct {
205205
// DualTransmission specific
206206
EnableDualTransmission bool `json:"enableDualTransmission" toml:"enableDualTransmission"`
207207
DualTransmissionConfig *DualTransmissionConfig `json:"dualTransmission" toml:"dualTransmission"`
208+
209+
// GasLimit is the gas limit to use for transactions, it has a higher precedence than the gas limit in the node toml config
210+
GasLimit *uint32 `json:"gasLimit"`
208211
}
209212

210213
var ErrBadRelayConfig = errors.New("bad relay config")

pkg/config/types_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ func Test_RelayConfig(t *testing.T) {
3232
cid := testutils.NewRandomEVMChainID()
3333
fromBlock := uint64(2222)
3434
feedID := utils.NewHash()
35+
gasLimit := uint32(444444)
3536
rawToml := fmt.Sprintf(`
3637
ChainID = "%s"
3738
FromBlock = %d
3839
FeedID = "0x%x"
39-
`, cid, fromBlock, feedID[:])
40+
GasLimit = %d
41+
`, cid, fromBlock, feedID[:], gasLimit)
4042

4143
var rc RelayConfig
4244
err := toml.Unmarshal([]byte(rawToml), &rc)
@@ -45,6 +47,7 @@ FeedID = "0x%x"
4547
assert.Equal(t, cid.String(), rc.ChainID.String())
4648
assert.Equal(t, fromBlock, rc.FromBlock)
4749
assert.Equal(t, feedID.Hex(), rc.FeedID.Hex())
50+
assert.Equal(t, gasLimit, *rc.GasLimit)
4851
}
4952

5053
func Test_ChainReaderConfig(t *testing.T) {

pkg/transmitter/util.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package transmitter
22

33
import (
4+
"cmp"
45
"context"
56
"encoding/json"
67

@@ -134,15 +135,7 @@ func generateTransmitterFrom(ctx context.Context, rargs types.RelayArgs, ethKeys
134135
checker.CheckerType = evmtxmgr.TransmitCheckerTypeSimulate
135136
}
136137

137-
gasLimit := chain.Config().EVM().GasEstimator().LimitDefault()
138-
ocr2Limit := chain.Config().EVM().GasEstimator().LimitJobType().OCR2()
139-
if ocr2Limit != nil {
140-
gasLimit = uint64(*ocr2Limit)
141-
}
142-
if opts.PluginGasLimit != nil {
143-
gasLimit = uint64(*opts.PluginGasLimit)
144-
}
145-
138+
gasLimit := getGasLimitFrom(chain.Config().EVM().GasEstimator(), opts, relayConfig.GasLimit)
146139
var transmitter Transmitter
147140
var err error
148141

@@ -186,3 +179,12 @@ func generateTransmitterFrom(ctx context.Context, rargs types.RelayArgs, ethKeys
186179
}
187180
return transmitter, nil
188181
}
182+
183+
func getGasLimitFrom(gasEstimator config.GasEstimator, opts ConfigTransmitterOpts, relayConfigGasLimit *uint32) uint64 {
184+
gasLimit := gasEstimator.LimitDefault()
185+
override := cmp.Or(opts.PluginGasLimit, relayConfigGasLimit, gasEstimator.LimitJobType().OCR2())
186+
if override != nil {
187+
gasLimit = uint64(*override)
188+
}
189+
return gasLimit
190+
}

0 commit comments

Comments
 (0)