Commit 6bb040b7 authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

l2geth: clean up mutex logic

Reverts 341580e8f4e7c83d0382fc7d40281b5ac973e568 in favor of more simple
logic. A longer term solution needs to be implemented for the race
condition where the `gas-oracle` front runs a tx that has already passed
gas validation at the policy layer.

The `gas-oracle` tx can increase the L1 gas portion of the fee,
causing the tx that already passed the policy check to fail during
consensus execution. This should never happen.
parent c39165f8
---
'@eth-optimism/l2geth': patch
---
Remove complex mutex logic in favor of simple mutex logic in the `SyncService`
......@@ -817,20 +817,9 @@ func (s *SyncService) applyTransactionToTip(tx *types.Transaction) error {
owner := s.GasPriceOracleOwnerAddress()
if owner != nil && sender == *owner {
if err := s.updateGasPriceOracleCache(nil); err != nil {
if tx.QueueOrigin() == types.QueueOriginSequencer {
s.txLock.Unlock()
}
return err
}
}
// Unlock the txLock after the transaction is added to the chain.
// This is locked up the stack on incoming queue origin sequencer
// transactions. For L1 to L2 transactions, there are no race
// conditions with the fees
if tx.QueueOrigin() == types.QueueOriginSequencer {
s.txLock.Unlock()
}
return nil
}
......@@ -939,27 +928,21 @@ func (s *SyncService) ValidateAndApplySequencerTransaction(tx *types.Transaction
if tx == nil {
return errors.New("nil transaction passed to ValidateAndApplySequencerTransaction")
}
// Grab the txLock. This must be unlocked manually in all error cases
// to prevent race conditions with updating the gas prices. In the happy
// path case, it is unlocked after the transaction is confirmed in the chain
s.txLock.Lock()
defer s.txLock.Unlock()
if err := s.verifyFee(tx); err != nil {
s.txLock.Unlock()
return err
}
log.Trace("Sequencer transaction validation", "hash", tx.Hash().Hex())
qo := tx.QueueOrigin()
if qo != types.QueueOriginSequencer {
s.txLock.Unlock()
return fmt.Errorf("invalid transaction with queue origin %s", qo.String())
}
if err := s.txpool.ValidateTx(tx); err != nil {
s.txLock.Unlock()
return fmt.Errorf("invalid transaction: %w", err)
}
if err := s.applyTransaction(tx); err != nil {
s.txLock.Unlock()
return err
}
return nil
......
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