ChainSafe / ChainSafe/gossamer
fix(dot/state): change tries map access and disk access to be atomic
- Dominant language
- Go
- Stars
- 454
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
## Issue summary
For now we access the memory map of tries thread-safely. However we do not have atomic operations when accessing both the memory map and the persistent database.
For example we can have a problem if:
1. goroutine A gets root hash XYZ from memory, it's not found
2. goroutine B sets trie at root hash XYZ in memory
3. goroutine A gets stored trie for root hash XYZ from disk
4. goroutine A sets trie for root hash XYZ in memory
Then the trie set by goroutine B gets overridden where it shouldn't be really.
We want to change it so that goroutine A has exclusive access for 1., 3. and 4.
The same applies for about 3 operations that should be atomic to make sense in terms of thread safety.
Contributor guide
Assessment
This issue has not been assessed yet.