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

cherry-pick: fix: use mutex lock for tx removal (#51) #13

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

bharath-123
Copy link
Collaborator

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

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 <vedabharath12345@gmail.com>
@bharath-123 bharath-123 merged commit 459cc3d into main Oct 16, 2024
1 of 2 checks passed
@bharath-123 bharath-123 deleted the bharath/cherry-pick-fix-mempool branch October 16, 2024 10:57
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.

2 participants