fix(zktrie): copy trie properly for concurrent access (#747)

This commit is contained in:
Ömer Faruk Irmak 2024-05-13 15:57:14 +03:00 committed by GitHub
parent 12871c7745
commit 6038ac8753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 3 deletions

View file

@ -24,7 +24,7 @@ import (
const ( const (
VersionMajor = 5 // Major version component of the current release VersionMajor = 5 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release VersionMinor = 3 // Minor version component of the current release
VersionPatch = 15 // Patch version component of the current release VersionPatch = 16 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string VersionMeta = "mainnet" // Version metadata to append to the version string
) )

View file

@ -129,8 +129,7 @@ func TestZkTrieConcurrency(t *testing.T) {
threads := runtime.NumCPU() threads := runtime.NumCPU()
tries := make([]*ZkTrie, threads) tries := make([]*ZkTrie, threads)
for i := 0; i < threads; i++ { for i := 0; i < threads; i++ {
cpy := *trie tries[i] = trie.Copy()
tries[i] = &cpy
} }
// Start a batch of goroutines interactng with the trie // Start a batch of goroutines interactng with the trie
pend := new(sync.WaitGroup) pend := new(sync.WaitGroup)