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

feat: Enhanced StateDB logs for Concurrency Safety #1727

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matthew-alexander-partior

Problem

During execution such as simulation calls, Quorum attempts to copy the state trie from stateDb.go via a goroutine, this involves copying the logs mapping from stateDb

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 to logs as seen below

fatal error: concurrent map iteration and map write

goroutine 22214 [running]:
github.com/ethereum/go-ethereum/core/state.(*StateDB).Copy(0xc000f216c0)
	github.com/ethereum/go-ethereum/core/state/statedb.go:869 +0xae5

Solution

This PR replaces logs implementation of map with sync.Map to ensure accessing / modifying logs is done in a concurrency safe manner

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