diff --git a/.changeset/chilly-wasps-divide.md b/.changeset/chilly-wasps-divide.md new file mode 100644 index 000000000000..c2ff51d44eef --- /dev/null +++ b/.changeset/chilly-wasps-divide.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/l2geth': patch +--- + +Handle policy/consensus race condition for balance check diff --git a/l2geth/core/state_transition.go b/l2geth/core/state_transition.go index a768c218c664..1cba56f0ac70 100644 --- a/l2geth/core/state_transition.go +++ b/l2geth/core/state_transition.go @@ -185,7 +185,15 @@ func (st *StateTransition) buyGas() error { } } if st.state.GetBalance(st.msg.From()).Cmp(mgval) < 0 { - return errInsufficientBalanceForGas + if rcfg.UsingOVM { + // Hack to prevent race conditions with the `gas-oracle` + // where policy level balance checks pass and then fail + // during consensus. The user gets some free gas + // in this case. + mgval = st.state.GetBalance(st.msg.From()) + } else { + return errInsufficientBalanceForGas + } } if err := st.gp.SubGas(st.msg.Gas()); err != nil { return err