Workaround for disallowed transaction superseding (#2181)
* Workaround for disallowed transaction superseding The transaction spammer from Kurtosis keeps spamming transactions with the same nonce because report 'pending' account nocne based on 'latest' rather than actually considering the mempool. To avoid errors from rejecting those, disable the required gas price bump when replacing a transaction with a new nonce. * Lint * Skip superseding negative test
This commit is contained in:
parent
b7a7745e24
commit
741fcca9b6
|
@ -77,10 +77,18 @@ proc supersede(xp: TxPoolRef; item: TxItemRef): Result[void,TxInfo]
|
|||
return err(txInfoErrUnspecified)
|
||||
current = rc.value.data
|
||||
|
||||
# verify whether replacing is allowed, at all
|
||||
let bumpPrice = (current.tx.gasPrice * xp.priceBump.GasInt + 99) div 100
|
||||
if item.tx.gasPrice < current.tx.gasPrice + bumpPrice:
|
||||
return err(txInfoErrReplaceUnderpriced)
|
||||
# TODO: To unblock `kurtosis-tech/ethereum-package` based testing,
|
||||
# we have to accept superseding transactions temporarily until `rpc_utils.nim`
|
||||
# supports the 'pending' tag by incorporating pending transactions from the
|
||||
# mempool when returning the current account nonce. Until that is fixed,
|
||||
# we keep telling the transaction spammer that their nonce has not changed,
|
||||
# and it keeps spamming transactions with the same nonce repeatedly.
|
||||
# Note: When this is fixed, update `tests/test_txpool.nim` and
|
||||
# re-enable the "Superseding txs with sender and nonce variants" test case.
|
||||
if false:
|
||||
let bumpPrice = (current.tx.gasPrice * xp.priceBump.GasInt + 99) div 100
|
||||
if item.tx.gasPrice < current.tx.gasPrice + bumpPrice:
|
||||
return err(txInfoErrReplaceUnderpriced)
|
||||
|
||||
# make space, delete item
|
||||
if not xp.txDB.dispose(current, txInfoSenderNonceSuperseded):
|
||||
|
|
|
@ -301,11 +301,12 @@ proc runTxPoolTests(noisy = true) =
|
|||
check xq.nItems.total == testTxs.len
|
||||
check xq.nItems.disposed == testTxs.len
|
||||
|
||||
# last update item was underpriced, so it must not have been
|
||||
# replaced
|
||||
var altLst = testTxs.toSeq.mapIt("alt " & it[0].info)
|
||||
altLst[^1] = testTxs[^1][0].info
|
||||
check altLst.sorted == xq.toItems.toSeq.mapIt(it.info).sorted
|
||||
if false: # Temporarily disabled, see `supersede` in `tx_add.nim`
|
||||
# last update item was underpriced, so it must not have been
|
||||
# replaced
|
||||
var altLst = testTxs.toSeq.mapIt("alt " & it[0].info)
|
||||
altLst[^1] = testTxs[^1][0].info
|
||||
check altLst.sorted == xq.toItems.toSeq.mapIt(it.info).sorted
|
||||
|
||||
test &"Deleting tx => also delete higher nonces":
|
||||
|
||||
|
|
Loading…
Reference in New Issue