Skip to content

Commit

Permalink
improve locking in merging deletion proof
Browse files Browse the repository at this point in the history
  • Loading branch information
noel2004 committed Mar 28, 2023
1 parent 7471d45 commit 1aeac4e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions eth/tracers/api_blocktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,17 @@ func (api *API) getTxResult(env *traceEnv, state *state.StateDB, index int, bloc
}

deletionProofs := tracer.DeletionProofs()
// calc key and cache first, so we lock env shorter
// while merging
mergedProofs := make(map[common.Hash][]byte)
for _, bt := range deletionProofs {
key := crypto.Keccak256Hash(bt)
env.sMu.Lock()
mergedProofs[crypto.Keccak256Hash(bt)] = bt
}
env.sMu.Lock()
for key, bt := range mergedProofs {
env.deletionProofAgg[key] = bt
env.sMu.Unlock()
}
env.sMu.Unlock()

var l1Fee uint64
if result.L1Fee != nil {
Expand Down

0 comments on commit 1aeac4e

Please sign in to comment.