Skip to content

Commit

Permalink
Avoid concurrent use of statedb (#252)
Browse files Browse the repository at this point in the history
The call to get exchange rates was sharing a statedb instance between
many goroutines. Now we make the call once up front and share the
exchange rates between goroutines, this is ok since we use the same set
of exchange rates for the entire block.

Co-authored-by: Piers Powlesland <[email protected]>
  • Loading branch information
karlb and piersy authored Oct 7, 2024
1 parent c4b4dba commit 48d7851
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,14 +677,14 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat
if threads > len(txs) {
threads = len(txs)
}
exchangeRates := core.GetExchangeRates(block.Header(), api.backend.ChainConfig(), statedb)
jobs := make(chan *txTraceTask, threads)
for th := 0; th < threads; th++ {
pend.Add(1)
go func() {
defer pend.Done()
// Fetch and execute the next transaction trace tasks
for task := range jobs {
exchangeRates := core.GetExchangeRates(block.Header(), api.backend.ChainConfig(), statedb)
msg, _ := core.TransactionToMessage(txs[task.index], signer, block.BaseFee(), exchangeRates)
txctx := &Context{
BlockHash: blockHash,
Expand Down

0 comments on commit 48d7851

Please sign in to comment.