Skip to content

Commit a822f17

Browse files
committed
OEV-675 Reduce empty transaction gas limit
1 parent e533378 commit a822f17

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

pkg/chains/legacyevm/evm_txm.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func newEvmTxm(
6060
logPoller,
6161
opts.KeyStore,
6262
estimator,
63+
cfg.GasEstimator().LimitTransfer(),
6364
)
6465
if cfg.Transactions().TransactionManagerV2().DualBroadcast() == nil || !*cfg.Transactions().TransactionManagerV2().DualBroadcast() {
6566
return txmv2, err

pkg/txm/attempt_builder.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,26 @@ import (
1717

1818
type attemptBuilder struct {
1919
gas.EvmFeeEstimator
20-
priceMaxKey func(common.Address) *assets.Wei
21-
keystore keys.TxSigner
20+
priceMaxKey func(common.Address) *assets.Wei
21+
keystore keys.TxSigner
22+
emptyTxLimitDefault uint64
2223
}
2324

24-
func NewAttemptBuilder(priceMaxKey func(common.Address) *assets.Wei, estimator gas.EvmFeeEstimator, keystore keys.TxSigner) *attemptBuilder {
25+
func NewAttemptBuilder(priceMaxKey func(common.Address) *assets.Wei, estimator gas.EvmFeeEstimator, keystore keys.TxSigner, emptyTxLimitDefault uint64) *attemptBuilder {
2526
return &attemptBuilder{
26-
priceMaxKey: priceMaxKey,
27-
EvmFeeEstimator: estimator,
28-
keystore: keystore,
27+
priceMaxKey: priceMaxKey,
28+
EvmFeeEstimator: estimator,
29+
keystore: keystore,
30+
emptyTxLimitDefault: emptyTxLimitDefault,
2931
}
3032
}
3133

3234
func (a *attemptBuilder) NewAttempt(ctx context.Context, lggr logger.Logger, tx *types.Transaction, dynamic bool) (*types.Attempt, error) {
33-
fee, estimatedGasLimit, err := a.EvmFeeEstimator.GetFee(ctx, tx.Data, tx.SpecifiedGasLimit, a.priceMaxKey(tx.FromAddress), &tx.FromAddress, &tx.ToAddress)
35+
gasLimit := tx.SpecifiedGasLimit
36+
if tx.IsPurgeable {
37+
gasLimit = a.emptyTxLimitDefault
38+
}
39+
fee, estimatedGasLimit, err := a.EvmFeeEstimator.GetFee(ctx, tx.Data, gasLimit, a.priceMaxKey(tx.FromAddress), &tx.FromAddress, &tx.ToAddress)
3440
if err != nil {
3541
return nil, err
3642
}
@@ -42,7 +48,11 @@ func (a *attemptBuilder) NewAttempt(ctx context.Context, lggr logger.Logger, tx
4248
}
4349

4450
func (a *attemptBuilder) NewBumpAttempt(ctx context.Context, lggr logger.Logger, tx *types.Transaction, previousAttempt types.Attempt) (*types.Attempt, error) {
45-
bumpedFee, bumpedFeeLimit, err := a.EvmFeeEstimator.BumpFee(ctx, previousAttempt.Fee, tx.SpecifiedGasLimit, a.priceMaxKey(tx.FromAddress), nil)
51+
gasLimit := tx.SpecifiedGasLimit
52+
if tx.IsPurgeable {
53+
gasLimit = a.emptyTxLimitDefault
54+
}
55+
bumpedFee, bumpedFeeLimit, err := a.EvmFeeEstimator.BumpFee(ctx, previousAttempt.Fee, gasLimit, a.priceMaxKey(tx.FromAddress), nil)
4656
if err != nil {
4757
return nil, err
4858
}

pkg/txm/attempt_builder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
func TestAttemptBuilder_newLegacyAttempt(t *testing.T) {
19-
ab := NewAttemptBuilder(nil, nil, keystest.TxSigner(nil))
19+
ab := NewAttemptBuilder(nil, nil, keystest.TxSigner(nil), 100)
2020
address := testutils.NewAddress()
2121
lggr := logger.Test(t)
2222
var gasLimit uint64 = 100
@@ -51,7 +51,7 @@ func TestAttemptBuilder_newLegacyAttempt(t *testing.T) {
5151
}
5252

5353
func TestAttemptBuilder_newDynamicFeeAttempt(t *testing.T) {
54-
ab := NewAttemptBuilder(nil, nil, keystest.TxSigner(nil))
54+
ab := NewAttemptBuilder(nil, nil, keystest.TxSigner(nil), 100)
5555
address := testutils.NewAddress()
5656

5757
lggr := logger.Test(t)

pkg/txmgr/builder.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func NewTxmV2(
113113
logPoller logpoller.LogPoller,
114114
keyStore keys.ChainStore,
115115
estimator gas.EvmFeeEstimator,
116+
emptyTxLimitDefault uint64,
116117
) (TxManager, error) {
117118
var fwdMgr *forwarders.FwdMgr
118119
if txConfig.ForwardersEnabled() {
@@ -137,14 +138,14 @@ func NewTxmV2(
137138
stuckTxDetector = txm.NewStuckTxDetector(lggr, chainConfig.ChainType(), stuckTxDetectorConfig)
138139
}
139140

140-
attemptBuilder := txm.NewAttemptBuilder(fCfg.PriceMaxKey, estimator, keyStore)
141+
attemptBuilder := txm.NewAttemptBuilder(fCfg.PriceMaxKey, estimator, keyStore, emptyTxLimitDefault)
141142
inMemoryStoreManager := storage.NewInMemoryStoreManager(lggr, chainID)
142143
config := txm.Config{
143144
EIP1559: fCfg.EIP1559DynamicFees(),
144145
BlockTime: *txmV2Config.BlockTime(),
145146
//nolint:gosec // reuse existing config until migration
146147
RetryBlockThreshold: uint16(fCfg.BumpThreshold()),
147-
EmptyTxLimitDefault: fCfg.LimitDefault(),
148+
EmptyTxLimitDefault: emptyTxLimitDefault,
148149
}
149150
var c txm.Client
150151
if txmV2Config.DualBroadcast() != nil && *txmV2Config.DualBroadcast() && txmV2Config.CustomURL() != nil {

0 commit comments

Comments
 (0)