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

Add feature to TXM to detect and purge stuck transactions #12881

Merged
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
246b04d
Added the EVM stuck tx detector component
amit-momin Apr 18, 2024
d47d88f
Added stuck tx handling in Confirmer
amit-momin Apr 19, 2024
8c713dc
Fixed linting
amit-momin Apr 19, 2024
05c5a11
Fixed toml config decoding
amit-momin Apr 19, 2024
360d9fa
Fixed config tests
amit-momin Apr 19, 2024
0a04fff
Fixed web resolver config tests
amit-momin Apr 19, 2024
d26473c
Fixed config docs test
amit-momin Apr 19, 2024
1541c5a
Added zkEVM overflow detection and added unit tests for the detector
amit-momin Apr 23, 2024
1d4113d
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin Apr 23, 2024
c71ac14
Fixed broken tests after merge
amit-momin Apr 23, 2024
2e46dde
Reverted AutoPurgeConfig validation changes and fixed config tests
amit-momin Apr 23, 2024
8185dc8
Added changeset and fixed config validation logic
amit-momin Apr 23, 2024
20bfb9d
Fixed linting
amit-momin Apr 23, 2024
82e3a5d
Fixed linting
amit-momin Apr 23, 2024
db5264e
Fixed purge attempt builder and added tests
amit-momin Apr 24, 2024
0d5b318
Updated evm.txes contraint to allow non-null nonce if fatal_error
amit-momin Apr 24, 2024
25105a1
Added confirmer test
amit-momin Apr 24, 2024
491f9e3
Adjusted confirmer test to better reflect actual process
amit-momin Apr 24, 2024
338ab26
Fixed linting
amit-momin Apr 24, 2024
dc17b98
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin Apr 25, 2024
468b73b
Added purge block num loading on Confirmer startup
amit-momin Apr 25, 2024
736eb89
Updated EVM tx store mock
amit-momin Apr 25, 2024
b2902c6
Fixed linting and testdata
amit-momin Apr 25, 2024
6eb5dc5
Updated stuck tx fatal error messages
amit-momin Apr 25, 2024
a5663ee
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin Apr 25, 2024
0cea37b
Updated sql migration file sequence
amit-momin Apr 25, 2024
a3cd9b7
Skipped loading purge block num if auto-purge feature disabled and fi…
amit-momin Apr 26, 2024
02306fe
Fixed linting
amit-momin Apr 26, 2024
a13605b
Renamed function and moved log
amit-momin Apr 26, 2024
c2deae5
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin Apr 26, 2024
a5ea4aa
Added stricter config validation
amit-momin Apr 26, 2024
1cfb5cc
Fixed linting
amit-momin Apr 27, 2024
335033a
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin Apr 29, 2024
a5ba3a0
Updated auto-purge feature configs to adhere to config naming standards
amit-momin Apr 29, 2024
7513d36
Fixed config doc test and updated changeset
amit-momin Apr 29, 2024
4b41b4b
Updated Scroll and zkEVM config defaults and linted common config
amit-momin Apr 29, 2024
cc5764d
Updated config doc
amit-momin Apr 29, 2024
b1faa07
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin Apr 30, 2024
d67d79b
Generated config doc and fixed linting
amit-momin Apr 30, 2024
c4062f5
Updated config description for AutoPurge.MinAttempts
amit-momin May 9, 2024
54b9c7c
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin May 9, 2024
d244012
Fixed sql migration conflict
amit-momin May 9, 2024
0915400
Fixed linting
amit-momin May 9, 2024
c95d261
Updated stuck tx detector to use PriceMax config and added comments
amit-momin May 13, 2024
db5e5d9
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin May 13, 2024
31d69ba
Fixed linting
amit-momin May 13, 2024
90ec4a3
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin May 22, 2024
d81da52
Updated DetectionApiUrl config example
amit-momin May 22, 2024
a33460b
Merge branch 'develop' into BCI-2941-Implement-auto-purge-stuck-trans…
amit-momin May 23, 2024
c08504b
Fixed issues from latest merge
amit-momin May 23, 2024
88826a7
Renumbered sql migration file
amit-momin May 23, 2024
e400a36
Fixed testdata
amit-momin May 24, 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
Prev Previous commit
Next Next commit
Fixed broken tests after merge
  • Loading branch information
amit-momin committed Apr 23, 2024
commit c71ac14057a9562b5870b822a0c2e6d8bfc477e2
44 changes: 13 additions & 31 deletions core/chains/evm/txmgr/stuck_tx_detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@
t.Parallel()

db := pgtest.NewSqlxDB(t)
config := newTestChainScopedConfig(t)
txStore := cltest.NewTestTxStore(t, db)
ethKeyStore := cltest.NewKeyStore(t, db, config.Database()).Eth()
ethKeyStore := cltest.NewKeyStore(t, db).Eth()
_, fromAddress := cltest.MustInsertRandomKey(t, ethKeyStore)

estimator := gasmocks.NewEvmEstimator(t)
newEst := func(logger.Logger) gas.EvmEstimator { return estimator }
lggr := logger.Test(t)
ge := config.EVM().GasEstimator()
feeEstimator := gas.NewWrappedEvmEstimator(lggr, newEst, ge.EIP1559DynamicFees(), nil, ge)
ethClient := evmtest.NewEthClientMockWithDefaultChain(t)
feeEstimator := gasmocks.NewEvmFeeEstimator(t)
autoPurgeCfg := testAutoPurgeConfig{
autoPurgeStuckTxs: false,
}
Expand All @@ -63,17 +59,14 @@
t.Parallel()

db := pgtest.NewSqlxDB(t)
config := newTestChainScopedConfig(t)
_, config := newTestChainScopedConfig(t)
txStore := cltest.NewTestTxStore(t, db)
ethKeyStore := cltest.NewKeyStore(t, db, config.Database()).Eth()
ethKeyStore := cltest.NewKeyStore(t, db).Eth()
ctx := testutils.Context(t)

estimator := gasmocks.NewEvmEstimator(t)
newEst := func(logger.Logger) gas.EvmEstimator { return estimator }
lggr := logger.Test(t)
ge := config.EVM().GasEstimator()
feeEstimator := gas.NewWrappedEvmEstimator(lggr, newEst, ge.EIP1559DynamicFees(), nil, ge)
ethClient := evmtest.NewEthClientMockWithDefaultChain(t)
feeEstimator := gasmocks.NewEvmFeeEstimator(t)
stuckTxDetector := txmgr.NewStuckTxDetector(lggr, testutils.FixtureChainID, "", config.EVM().Transactions().AutoPurge(), feeEstimator, txStore, ethClient)

t.Run("returns empty list if no unconfimed transactions found", func(t *testing.T) {
Expand Down Expand Up @@ -120,19 +113,16 @@
t.Parallel()

db := pgtest.NewSqlxDB(t)
config := newTestChainScopedConfig(t)
txStore := cltest.NewTestTxStore(t, db)
ethKeyStore := cltest.NewKeyStore(t, db, config.Database()).Eth()
ethKeyStore := cltest.NewKeyStore(t, db).Eth()
ctx := testutils.Context(t)

estimator := gasmocks.NewEvmEstimator(t)
newEst := func(logger.Logger) gas.EvmEstimator { return estimator }
lggr := logger.Test(t)
ge := config.EVM().GasEstimator()
feeEstimator := gas.NewWrappedEvmEstimator(lggr, newEst, ge.EIP1559DynamicFees(), nil, ge)
feeEstimator := gasmocks.NewEvmFeeEstimator(t)
// Return 10 gwei as market gas price
marketGasPrice := tenGwei
estimator.On("GetLegacyGas", mock.Anything, []byte{}, uint64(0), mock.Anything).Return(marketGasPrice, uint64(0), nil)
fee := gas.EvmFee{Legacy: marketGasPrice}
feeEstimator.On("GetFee", mock.Anything, []byte{}, uint64(0), mock.Anything).Return(fee, uint64(0), nil)
ethClient := evmtest.NewEthClientMockWithDefaultChain(t)
autoPurgeThreshold := uint32(5)
autoPurgeMinAttempts := uint32(3)
Expand Down Expand Up @@ -222,16 +212,12 @@
t.Parallel()

db := pgtest.NewSqlxDB(t)
config := newTestChainScopedConfig(t)
txStore := cltest.NewTestTxStore(t, db)
ethKeyStore := cltest.NewKeyStore(t, db, config.Database()).Eth()
ethKeyStore := cltest.NewKeyStore(t, db).Eth()
ctx := testutils.Context(t)

estimator := gasmocks.NewEvmEstimator(t)
newEst := func(logger.Logger) gas.EvmEstimator { return estimator }
lggr := logger.Test(t)
ge := config.EVM().GasEstimator()
feeEstimator := gas.NewWrappedEvmEstimator(lggr, newEst, ge.EIP1559DynamicFees(), nil, ge)
feeEstimator := gasmocks.NewEvmFeeEstimator(t)
ethClient := evmtest.NewEthClientMockWithDefaultChain(t)
autoPurgeCfg := testAutoPurgeConfig{
autoPurgeStuckTxs: true,
Expand Down Expand Up @@ -288,16 +274,12 @@
t.Parallel()

db := pgtest.NewSqlxDB(t)
config := newTestChainScopedConfig(t)
txStore := cltest.NewTestTxStore(t, db)
ethKeyStore := cltest.NewKeyStore(t, db, config.Database()).Eth()
ethKeyStore := cltest.NewKeyStore(t, db).Eth()
ctx := testutils.Context(t)

estimator := gasmocks.NewEvmEstimator(t)
newEst := func(logger.Logger) gas.EvmEstimator { return estimator }
lggr := logger.Test(t)
ge := config.EVM().GasEstimator()
feeEstimator := gas.NewWrappedEvmEstimator(lggr, newEst, ge.EIP1559DynamicFees(), nil, ge)
feeEstimator := gasmocks.NewEvmFeeEstimator(t)
ethClient := evmtest.NewEthClientMockWithDefaultChain(t)
blockNum := int64(100)

Expand All @@ -313,7 +295,7 @@
attempts2 := tx2.TxAttempts[0]

testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.Write([]byte(fmt.Sprintf(`{"errcode": 0,"errmsg": "","data": {"%s": 1, "%s": 0}}`, attempts1.Hash, attempts2.Hash)))

Check failure on line 298 in core/chains/evm/txmgr/stuck_tx_detector_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `res.Write` is not checked (errcheck)
}))
defer func() { testServer.Close() }()
testUrl, err := url.Parse(testServer.URL)
Expand Down
Loading