Commit 637ee207 authored by Joshua Gutow's avatar Joshua Gutow Committed by GitHub

op-e2e: Try to make TestELSync more stable (#9370)

parent a09c0068
...@@ -142,6 +142,10 @@ func (s *L2Engine) AddPeers(peers ...*enode.Node) { ...@@ -142,6 +142,10 @@ func (s *L2Engine) AddPeers(peers ...*enode.Node) {
} }
} }
func (s *L2Engine) PeerCount() int {
return s.node.Server().PeerCount()
}
func (s *L2Engine) EthClient() *ethclient.Client { func (s *L2Engine) EthClient() *ethclient.Client {
cl := s.node.Attach() cl := s.node.Attach()
return ethclient.NewClient(cl) return ethclient.NewClient(cl)
......
...@@ -174,9 +174,6 @@ func TestELSync(gt *testing.T) { ...@@ -174,9 +174,6 @@ func TestELSync(gt *testing.T) {
// Enable engine P2P sync // Enable engine P2P sync
verEng, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync}) verEng, verifier := setupVerifier(t, sd, log, miner.L1Client(t, sd.RollupCfg), miner.BlobStore(), &sync.Config{SyncMode: sync.ELSync})
seqEng.AddPeers(verEng.Enode())
verEng.AddPeers(seqEng.Enode())
seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) seqEngCl, err := sources.NewEngineClient(seqEng.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg))
require.NoError(t, err) require.NoError(t, err)
...@@ -189,6 +186,10 @@ func TestELSync(gt *testing.T) { ...@@ -189,6 +186,10 @@ func TestELSync(gt *testing.T) {
sequencer.ActL2EndBlock(t) sequencer.ActL2EndBlock(t)
} }
// Wait longer to peer. This tests flakes or takes a long time when the op-geth instances are not able to peer.
seqEng.AddPeers(verEng.Enode())
verEng.AddPeers(seqEng.Enode())
// Insert it on the verifier // Insert it on the verifier
seqHead, err := seqEngCl.PayloadByLabel(t.Ctx(), eth.Unsafe) seqHead, err := seqEngCl.PayloadByLabel(t.Ctx(), eth.Unsafe)
require.NoError(t, err) require.NoError(t, err)
...@@ -196,6 +197,14 @@ func TestELSync(gt *testing.T) { ...@@ -196,6 +197,14 @@ func TestELSync(gt *testing.T) {
require.NoError(t, err) require.NoError(t, err)
verifier.ActL2InsertUnsafePayload(seqHead)(t) verifier.ActL2InsertUnsafePayload(seqHead)(t)
require.Eventually(t,
func() bool {
return seqEng.PeerCount() > 0 && verEng.PeerCount() > 0
},
60*time.Second, 1500*time.Millisecond,
"Sequencer & Verifier must peer with each other for snap sync to work",
)
// Expect snap sync to download & execute the entire chain // Expect snap sync to download & execute the entire chain
// Verify this by checking that the verifier has the correct value for block 1 // Verify this by checking that the verifier has the correct value for block 1
require.Eventually(t, require.Eventually(t,
...@@ -207,6 +216,7 @@ func TestELSync(gt *testing.T) { ...@@ -207,6 +216,7 @@ func TestELSync(gt *testing.T) {
return seqStart.ExecutionPayload.BlockHash == block.Hash return seqStart.ExecutionPayload.BlockHash == block.Hash
}, },
60*time.Second, 1500*time.Millisecond, 60*time.Second, 1500*time.Millisecond,
"verifier did not snap sync",
) )
} }
......
...@@ -350,7 +350,7 @@ func (ea *L2EngineAPI) forkchoiceUpdated(ctx context.Context, state *eth.Forkcho ...@@ -350,7 +350,7 @@ func (ea *L2EngineAPI) forkchoiceUpdated(ctx context.Context, state *eth.Forkcho
return STATUS_SYNCING, nil return STATUS_SYNCING, nil
} }
ea.log.Info("Forkchoice requested sync to new head", "number", header.Number, "hash", header.Hash()) ea.log.Info("Forkchoice requested sync to new head", "number", header.Number(), "hash", header.Hash())
if err := ea.downloader.BeaconSync(downloader.SnapSync, header.Header(), nil); err != nil { if err := ea.downloader.BeaconSync(downloader.SnapSync, header.Header(), nil); err != nil {
return STATUS_SYNCING, err return STATUS_SYNCING, 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