From 8ccdb70946bbef4b0c39bb1185164b5b672231e0 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 9 May 2024 16:43:42 -0300 Subject: [PATCH] improves TestBlockHashFeedMismatch --- system_tests/seqfeed_test.go | 84 +++++++++--------------------------- 1 file changed, 21 insertions(+), 63 deletions(-) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index e56514a6d5b..2bfa741c14d 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -11,13 +11,9 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbnode" - "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/broadcastclient" - "github.com/offchainlabs/nitro/broadcaster/backlog" - "github.com/offchainlabs/nitro/broadcaster/message" "github.com/offchainlabs/nitro/relay" "github.com/offchainlabs/nitro/util/signature" "github.com/offchainlabs/nitro/util/testhelpers" @@ -268,66 +264,28 @@ func TestBlockHashFeedMismatch(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - backlogConfiFetcher := func() *backlog.Config { - return &backlog.DefaultTestConfig - } - bklg := backlog.NewBacklog(backlogConfiFetcher) - - feedErrChan := make(chan error) - wsBroadcastServer := wsbroadcastserver.NewWSBroadcastServer( - newBroadcasterConfigTest, - bklg, - 412346, - feedErrChan, - ) - err := wsBroadcastServer.Initialize() - if err != nil { - t.Fatal("error initializing wsBroadcastServer:", err) - } - err = wsBroadcastServer.Start(ctx) - if err != nil { - t.Fatal("error starting wsBroadcastServer:", err) - } - defer wsBroadcastServer.StopAndWait() - - port := wsBroadcastServer.ListenerAddr().(*net.TCPAddr).Port - - builder := NewNodeBuilder(ctx).DefaultConfig(t, false) - builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port) - cleanup := builder.Build(t) - defer cleanup() - - poster := common.HexToAddress("0xa4b000000000000000000073657175656e636572") - blockHash := common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111") - l2msg := []byte{4, 2, 248, 111, 131, 6, 74, 186, 128, 128, 132, 11, 235, 194, 0, 131, 122, 18, 0, 148, 12, 112, 159, 52, 15, 11, 178, 227, 97, 34, 158, 52, 91, 126, 38, 153, 157, 9, 105, 171, 133, 232, 212, 165, 16, 0, 128, 192, 1, 160, 75, 109, 200, 183, 223, 114, 85, 128, 133, 94, 26, 103, 145, 247, 47, 0, 114, 132, 133, 234, 222, 235, 102, 45, 2, 109, 83, 65, 210, 142, 242, 209, 160, 96, 90, 108, 188, 197, 195, 43, 222, 103, 155, 153, 81, 119, 74, 177, 103, 110, 134, 94, 221, 72, 236, 20, 86, 94, 226, 94, 5, 206, 196, 122, 119} - broadcastMessage := message.BroadcastMessage{ - Version: 1, - Messages: []*message.BroadcastFeedMessage{ - { - SequenceNumber: 2, - Message: arbostypes.MessageWithMetadata{ - Message: &arbostypes.L1IncomingMessage{ - Header: &arbostypes.L1IncomingMessageHeader{ - Kind: arbostypes.L1MessageType_L2Message, - Poster: poster, - BlockNumber: 29, - Timestamp: 1715136502, - RequestId: nil, - L1BaseFee: big.NewInt(0), - }, - L2msg: l2msg, - }, - DelayedMessagesRead: 1, - }, - BlockHash: &blockHash, - Signature: nil, - }, - }, - } - wsBroadcastServer.Broadcast(&broadcastMessage) - - time.Sleep(time.Second * 2) + builder1 := NewNodeBuilder(ctx).DefaultConfig(t, true) + builder1.nodeConfig.Feed.Output = *newBroadcasterConfigTest() + cleanup1 := builder1.Build(t) + defer cleanup1() + testClient1 := builder1.L2 + + builder2 := NewNodeBuilder(ctx).DefaultConfig(t, true) + node1Port := testClient1.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + builder2.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(node1Port) + cleanup2 := builder2.Build(t) + defer cleanup2() + + // Send a transaction to the first node + builder1.L2Info.GenerateAccount("User2") + tx := builder1.L2Info.PrepareTx("Owner", "User2", builder1.L2Info.TransferGas, big.NewInt(1e12), nil) + err := testClient1.Client.SendTransaction(ctx, tx) + Require(t, err) + _, err = testClient1.EnsureTxSucceeded(tx) + Require(t, err) + // Since both nodes are related to different L1s, ensure the transaction causes a block hash mismatch in second node + time.Sleep(time.Second * 4) if !logHandler.WasLogged("block_hash_mismatch") { t.Fatal("Failed to log block_hash_mismatch") }