Commit 5c0e90aa authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

l2geth: fix for `gas-oracle` race condition

Prevent the error being returned in consensus for when
the user does not have enough balance. The policy level
check *must* filter out transactions that do not have
enough gas to pay for their execution. The policy
level check happens in the `SyncService`. This change
gracefully handles the race condition where a user transaction
passes the policy level check as a `gas-oracle` transaction
is executing and updating the gas prices. If the gas price
goes up and the user transaction no longer can afford execution,
then it will return an error from consensus.
parent 1344e37d
---
'@eth-optimism/l2geth': patch
---
Handle policy/consensus race condition for balance check
...@@ -185,7 +185,15 @@ func (st *StateTransition) buyGas() error { ...@@ -185,7 +185,15 @@ func (st *StateTransition) buyGas() error {
} }
} }
if st.state.GetBalance(st.msg.From()).Cmp(mgval) < 0 { 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 { if err := st.gp.SubGas(st.msg.Gas()); err != nil {
return err return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment