diff --git a/broadcastclient/broadcastclient.go b/broadcastclient/broadcastclient.go index 9baec85082..254df230fc 100644 --- a/broadcastclient/broadcastclient.go +++ b/broadcastclient/broadcastclient.go @@ -462,6 +462,7 @@ func (bc *BroadcastClient) startBackgroundReader(earlyFrameData io.Reader) { } if res.Version == 1 { if len(res.Messages) > 0 { + isValidSignature := true for _, message := range res.Messages { if message == nil { log.Warn("ignoring nil feed message") @@ -471,12 +472,16 @@ func (bc *BroadcastClient) startBackgroundReader(earlyFrameData io.Reader) { err := bc.isValidSignature(ctx, message) if err != nil { log.Error("error validating feed signature", "error", err, "sequence number", message.SequenceNumber) - bc.fatalErrChan <- fmt.Errorf("error validating feed signature %v: %w", message.SequenceNumber, err) - continue + isValidSignature = false + break } bc.nextSeqNum = message.SequenceNumber + 1 } + if !isValidSignature { + log.Error("error validating one or more feed signatures, skipping the message") + continue + } if err := bc.txStreamer.AddBroadcastMessages(res.Messages); err != nil { if errors.Is(err, TransactionStreamerBlockCreationStopped) { log.Info("stopping block creation in broadcast client because transaction streamer has stopped") diff --git a/broadcastclient/broadcastclient_test.go b/broadcastclient/broadcastclient_test.go index 123d20db2e..88c3091082 100644 --- a/broadcastclient/broadcastclient_test.go +++ b/broadcastclient/broadcastclient_test.go @@ -5,7 +5,6 @@ package broadcastclient import ( "context" - "crypto/ecdsa" "errors" "fmt" "net" @@ -110,77 +109,6 @@ func testReceiveMessages(t *testing.T, clientCompression bool, serverCompression } -func TestInvalidSignature(t *testing.T) { - t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - settings := wsbroadcastserver.DefaultTestBroadcasterConfig - - messageCount := 1 - chainId := uint64(9742) - - privateKey, err := crypto.GenerateKey() - Require(t, err) - dataSigner := signature.DataSignerFromPrivateKey(privateKey) - - fatalErrChan := make(chan error, 10) - b := broadcaster.NewBroadcaster(func() *wsbroadcastserver.BroadcasterConfig { return &settings }, chainId, fatalErrChan, dataSigner) - - Require(t, b.Initialize()) - Require(t, b.Start(ctx)) - defer b.StopAndWait() - - badPrivateKey, err := crypto.GenerateKey() - Require(t, err) - badPublicKey := badPrivateKey.Public() - badECDSA, ok := badPublicKey.(*ecdsa.PublicKey) - if !ok { - t.Fatal("badPublicKey is not an ecdsa.PublicKey") - } - badSequencerAddr := crypto.PubkeyToAddress(*badECDSA) - config := DefaultTestConfig - - ts := NewDummyTransactionStreamer(chainId, &badSequencerAddr) - broadcastClient, err := newTestBroadcastClient( - config, - b.ListenerAddr(), - chainId, - 0, - ts, - nil, - fatalErrChan, - &badSequencerAddr, - t, - ) - Require(t, err) - broadcastClient.Start(ctx) - - go func() { - for i := 0; i < messageCount; i++ { - // #nosec G115 - Require(t, b.BroadcastSingle(testMessage(), arbutil.MessageIndex(i))) - } - }() - - timer := time.NewTimer(2 * time.Second) - select { - case err := <-fatalErrChan: - if errors.Is(err, signature.ErrSignatureNotVerified) { - t.Log("feed error found as expected") - return - } - t.Errorf("unexpected error occurred: %v", err) - return - case <-timer.C: - t.Error("no feed errors detected") - return - case <-ctx.Done(): - timer.Stop() - return - } -} - type dummyTransactionStreamer struct { messageReceiver chan message.BroadcastFeedMessage chainId uint64