Commit 9a4f9ad2 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Merge pull request #2077 from ethereum-optimism/feat/non-blocking-sync

l2geth: don't block read rpc when doing initial sync
parents db81b8e3 1187dc9a
---
'@eth-optimism/l2geth': patch
---
Don't block read rpc requests when syncing
...@@ -52,6 +52,7 @@ import ( ...@@ -52,6 +52,7 @@ import (
var ( var (
errNoSequencerURL = errors.New("sequencer transaction forwarding not configured") errNoSequencerURL = errors.New("sequencer transaction forwarding not configured")
errStillSyncing = errors.New("sequencer still syncing, cannot accept transactions")
) )
const ( const (
...@@ -1611,6 +1612,12 @@ func (args *SendTxArgs) toTransaction() *types.Transaction { ...@@ -1611,6 +1612,12 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
// SubmitTransaction is a helper function that submits tx to txPool and logs a message. // SubmitTransaction is a helper function that submits tx to txPool and logs a message.
func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error) { func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error) {
// Do not accept transactions if running as the sequencer and
// the node is still syncing.
if !b.IsVerifier() && b.IsSyncing() {
return common.Hash{}, errStillSyncing
}
if err := b.SendTx(ctx, tx); err != nil { if err := b.SendTx(ctx, tx); err != nil {
return common.Hash{}, err return common.Hash{}, err
} }
......
...@@ -245,17 +245,16 @@ func (s *SyncService) Start() error { ...@@ -245,17 +245,16 @@ func (s *SyncService) Start() error {
if s.verifier { if s.verifier {
go s.VerifierLoop() go s.VerifierLoop()
} else { } else {
// The sequencer must sync the transactions to the tip and the go func() {
// pending queue transactions on start before setting sync status if err := s.syncTransactionsToTip(); err != nil {
// to false and opening up the RPC to accept transactions. log.Crit("Sequencer cannot sync transactions to tip: %w", err)
if err := s.syncTransactionsToTip(); err != nil { }
return fmt.Errorf("Sequencer cannot sync transactions to tip: %w", err) if err := s.syncQueueToTip(); err != nil {
} log.Crit("Sequencer cannot sync queue to tip: %w", err)
if err := s.syncQueueToTip(); err != nil { }
return fmt.Errorf("Sequencer cannot sync queue to tip: %w", err) s.setSyncStatus(false)
} go s.SequencerLoop()
s.setSyncStatus(false) }()
go s.SequencerLoop()
} }
return nil 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