ChainSafe / ChainSafe/gossamer

fix(dot/state): change tries map access and disk access to be atomic

Open
#2,242 0 comments 1 reaction 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.