Skip to content

Commit b02f0f9

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

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)