Skip to content

Commit

Permalink
accounts/abi/bind/backends: fix race condition in simulated backend (e…
Browse files Browse the repository at this point in the history
…thereum#23898)

Now that `SimulatedBackend.SuggestGasPrice` inspects member values, a lock needs to be added to prevent a race condition.
  • Loading branch information
joshuacolvin0 authored and zzyalbert committed Nov 26, 2021
1 parent c86cbf9 commit b02f0f9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions accounts/abi/bind/backends/simulated.go
Expand Up @@ -462,6 +462,9 @@ func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account common.Ad
// SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated
// chain doesn't have miners, we just return a gas price of 1 for any call.
func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
b.mu.Lock()
defer b.mu.Unlock()

if b.pendingBlock.Header().BaseFee != nil {
return b.pendingBlock.Header().BaseFee, nil
}
Expand Down

0 comments on commit b02f0f9

Please sign in to comment.