Skip to content

Conversation

ucwong
Copy link
Member

@ucwong ucwong commented May 5, 2025

This PR makes filtermaps.ChainView thread safe because it is used concurrently both by the indexer and multiple matcher threads. Even though it represents an immutable view of the chain, adding a mutex lock to the blockHash function is necessary because it does so by extending its list of non-canonical hashes if the underlying blockchain is changed.

The unsafe concurrency did cause a panic once after running the unit tests for several hours and it could also happen during live operation.

This PR makes `filtermaps.ChainView` thread safe because it is used
concurrently both by the indexer and multiple matcher threads. Even
though it represents an immutable view of the chain, adding a mutex lock
to the `blockHash` function is necessary because it does so by extending
its list of non-canonical hashes if the underlying blockchain is
changed.

The unsafe concurrency did cause a panic once after running the unit
tests for several hours and it could also happen during live operation.
@ucwong ucwong marked this pull request as ready for review May 5, 2025 09:15
@ucwong ucwong merged commit 8409a6d into master May 5, 2025
1 check passed
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