Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.

Commit abc74a5

Browse files
accounts/abi/bind/backends: fix race condition in simulated backend (ethereum#23898)
Now that `SimulatedBackend.SuggestGasPrice` inspects member values, a lock needs to be added to prevent a race condition.
1 parent e9294a7 commit abc74a5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

accounts/abi/bind/backends/simulated.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account common.Ad
462462
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
463463
// chain doesn't have miners, we just return a gas price of 1 for any call.
464464
func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
465+
b.mu.Lock()
466+
defer b.mu.Unlock()
467+
465468
if b.pendingBlock.Header().BaseFee != nil {
466469
return b.pendingBlock.Header().BaseFee, nil
467470
}

0 commit comments

Comments
 (0)