Skip to content

Commit 64f4d2f

Browse files
committed
OEV-679 Add separate pricing for empty txs
1 parent 81ef8e6 commit 64f4d2f

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

pkg/chains/legacyevm/evm_txm.go

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

pkg/txm/attempt_builder.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,30 @@ func (a *attemptBuilder) NewAgnosticBumpAttempt(ctx context.Context, lggr logger
6767
if err != nil {
6868
return nil, err
6969
}
70-
bumps := min(maxBumpThreshold, tx.AttemptCount)
71-
for range bumps {
72-
bumpedAttempt, err := a.NewBumpAttempt(ctx, lggr, tx, *attempt)
73-
if err != nil {
74-
lggr.Errorf("error bumping attempt: %v for txID: %v", err, tx.ID)
75-
return attempt, nil
70+
71+
// bump purge attempts
72+
if tx.IsPurgeable {
73+
for {
74+
// TODO: add better handling
75+
bumpedAttempt, err := a.NewBumpAttempt(ctx, lggr, tx, *attempt)
76+
if err != nil {
77+
return attempt, nil
78+
}
79+
attempt = bumpedAttempt
80+
}
81+
} else {
82+
// bump regular attempts
83+
bumps := min(maxBumpThreshold, tx.AttemptCount)
84+
for range bumps {
85+
bumpedAttempt, err := a.NewBumpAttempt(ctx, lggr, tx, *attempt)
86+
if err != nil {
87+
lggr.Errorf("error bumping attempt: %v for txID: %v", err, tx.ID)
88+
return attempt, nil
89+
}
90+
attempt = bumpedAttempt
7691
}
77-
attempt = bumpedAttempt
7892
}
93+
7994
return attempt, nil
8095
}
8196

pkg/txmgr/builder.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package txmgr
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"math/big"
78
"time"
@@ -113,7 +114,7 @@ func NewTxmV2(
113114
logPoller logpoller.LogPoller,
114115
keyStore keys.ChainStore,
115116
estimator gas.EvmFeeEstimator,
116-
emptyTxLimitDefault uint64,
117+
gasEstimatorConfig config.GasEstimator,
117118
) (TxManager, error) {
118119
var fwdMgr *forwarders.FwdMgr
119120
if txConfig.ForwardersEnabled() {
@@ -138,14 +139,19 @@ func NewTxmV2(
138139
stuckTxDetector = txm.NewStuckTxDetector(lggr, chainConfig.ChainType(), stuckTxDetectorConfig)
139140
}
140141

141-
attemptBuilder := txm.NewAttemptBuilder(fCfg.PriceMaxKey, estimator, keyStore, emptyTxLimitDefault)
142+
// TODO: temporary check until we implement the required methods on the estimator interface
143+
if gasEstimatorConfig.Mode() != "BlockHistory" || gasEstimatorConfig.BlockHistory().CheckInclusionBlocks() == 0 {
144+
return nil, errors.New("only BlockHistory mode with CheckInclusionBlocks > 0 is supported for TXMv2")
145+
}
146+
147+
attemptBuilder := txm.NewAttemptBuilder(fCfg.PriceMaxKey, estimator, keyStore, gasEstimatorConfig.LimitTransfer())
142148
inMemoryStoreManager := storage.NewInMemoryStoreManager(lggr, chainID)
143149
config := txm.Config{
144150
EIP1559: fCfg.EIP1559DynamicFees(),
145151
BlockTime: *txmV2Config.BlockTime(),
146152
//nolint:gosec // reuse existing config until migration
147153
RetryBlockThreshold: uint16(fCfg.BumpThreshold()),
148-
EmptyTxLimitDefault: emptyTxLimitDefault,
154+
EmptyTxLimitDefault: gasEstimatorConfig.LimitTransfer(),
149155
}
150156
var eh txm.ErrorHandler
151157
var c txm.Client

0 commit comments

Comments
 (0)