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

fix: use mutex lock for tx removal #51

Merged
merged 5 commits into from
Oct 9, 2024

Conversation

joroshiba
Copy link
Member

@joroshiba joroshiba commented Oct 3, 2024

Acquire a mutex lock and unlock while removing transactions from the mempool to avoid concurrent errors on the underlying maps.

Changes made:

  1. Acquire the pool mutex lock in ClearAstriaOrdered
  2. Add a test in legacypool_test.go called TestRemoveTxSanity which adds a bunch of pending txs and removes them using removeTx. We use ValidatePoolInternals method to ensure that the pool state is not corrupted. This test is a sanity check for us to validate that removeTx works as intended and does not have adverse side effects.
  3. Add a test in for the ExecutionAPI where we add an invalid tx which will have to be removed. We verify that the mempool is cleared completely after it

@bharath-123 bharath-123 marked this pull request as ready for review October 8, 2024 10:50
@bharath-123 bharath-123 merged commit b43daa1 into main Oct 9, 2024
2 checks passed
@bharath-123 bharath-123 deleted the joroshiba/mutex-lock-remove-txs branch October 9, 2024 12:43
bharath-123 added a commit that referenced this pull request Oct 11, 2024
Acquire a mutex lock and unlock while removing transactions from the
mempool to avoid concurrent errors on the underlying maps.

Changes made:
1. Acquire the pool mutex lock in `ClearAstriaOrdered`
2. Add a test in `legacypool_test.go` called `TestRemoveTxSanity` which
adds a bunch of pending txs and removes them using `removeTx`. We use
`ValidatePoolInternals` method to ensure that the pool state is not
corrupted. This test is a sanity check for us to validate that
`removeTx` works as intended and does not have adverse side effects.
3. Add a test in for the ExecutionAPI where we add an invalid tx which
will have to be removed. We verify that the mempool is cleared
completely after it

---------

Co-authored-by: Bharath <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants