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)
|
return err(txInfoErrUnspecified)
|
||||||
current = rc.value.data
|
current = rc.value.data
|
||||||
|
|
||||||
# verify whether replacing is allowed, at all
|
# TODO: To unblock `kurtosis-tech/ethereum-package` based testing,
|
||||||
let bumpPrice = (current.tx.gasPrice * xp.priceBump.GasInt + 99) div 100
|
# we have to accept superseding transactions temporarily until `rpc_utils.nim`
|
||||||
if item.tx.gasPrice < current.tx.gasPrice + bumpPrice:
|
# supports the 'pending' tag by incorporating pending transactions from the
|
||||||
return err(txInfoErrReplaceUnderpriced)
|
# 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
|
# make space, delete item
|
||||||
if not xp.txDB.dispose(current, txInfoSenderNonceSuperseded):
|
if not xp.txDB.dispose(current, txInfoSenderNonceSuperseded):
|
||||||
|
|
|
@ -301,11 +301,12 @@ proc runTxPoolTests(noisy = true) =
|
||||||
check xq.nItems.total == testTxs.len
|
check xq.nItems.total == testTxs.len
|
||||||
check xq.nItems.disposed == testTxs.len
|
check xq.nItems.disposed == testTxs.len
|
||||||
|
|
||||||
# last update item was underpriced, so it must not have been
|
if false: # Temporarily disabled, see `supersede` in `tx_add.nim`
|
||||||
# replaced
|
# last update item was underpriced, so it must not have been
|
||||||
var altLst = testTxs.toSeq.mapIt("alt " & it[0].info)
|
# replaced
|
||||||
altLst[^1] = testTxs[^1][0].info
|
var altLst = testTxs.toSeq.mapIt("alt " & it[0].info)
|
||||||
check altLst.sorted == xq.toItems.toSeq.mapIt(it.info).sorted
|
altLst[^1] = testTxs[^1][0].info
|
||||||
|
check altLst.sorted == xq.toItems.toSeq.mapIt(it.info).sorted
|
||||||
|
|
||||||
test &"Deleting tx => also delete higher nonces":
|
test &"Deleting tx => also delete higher nonces":
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue