2

i'm writing in go-lang and using go-ethereum package to interact with nodes. For testing purposes go-ethereum provides blockhchain simulation via SimulatedBackend (https://github.com/ethereum/go-ethereum/blob/master/accounts/abi/bind/backends/simulated.go) that a lot of forums recommend to use. So i built a local node that use the SimulatedBackend to simulate blockchain interactions and it works perfectly, however i have a problem to test transaction replacement (cancellation, acceleration) because the sendTransaction method on the simulated blockchain inserts the transaction to a pending block and not to mempool thus i can't send a replacement transaction with same nonce from the client because the first transaction already included in pending block. Couldn't find any simulated/mocked mempool in go-ethereum package. My question is should i implement the mempool by myself or there is some work around?

2
  • just create a SendTransactionReplacement() function , which is going to be a copy of SendTransaction() but with your transaction replaced (remove the old and add the new) in the pending block.
    – Nulik
    Commented Feb 2, 2023 at 14:48
  • @Nulik i dont want the client to be affected by this change, the client should call sendTransaction method only. But maybe as you suggested in my mocked node i can check if transaction with same nonce is in pending block i can switch them if fee is higher Commented Feb 2, 2023 at 15:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.