feat: Enhanced StateDB logs
for Concurrency Safety
#1727
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
During execution such as simulation calls, Quorum attempts to copy the state trie from
stateDb.go
via a goroutine, this involves copying thelogs
mapping fromstateDb
Inside the stateDb
Copy()
function, it acquires a mutex but releases it just before copying the logs mapping which was introduced in this [PR] https://github.com/Consensys/quorum/pull/1331/files#diff-c3757dc9e9d868f63bc84a0cc67159c1d5c22cc5d8c9468757098f0492e0658c)With no guard in place for
logs
mapping, we experienced a race condition when accessing & writing tologs
as seen belowSolution
This PR replaces
logs
implementation ofmap
withsync.Map
to ensure accessing / modifyinglogs
is done in a concurrency safe manner