Skip to content

Commit

Permalink
Test that the output feed of a node that isn't the sequencer is prope…
Browse files Browse the repository at this point in the history
…rly processed
  • Loading branch information
diegoximenes committed May 9, 2024
1 parent b7e698e commit 8894481
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions system_tests/seq_coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import (
"github.com/go-redis/redis/v8"

"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/arbutil"
"github.com/offchainlabs/nitro/execution"
"github.com/offchainlabs/nitro/execution/gethexec"
"github.com/offchainlabs/nitro/util/redisutil"
"github.com/offchainlabs/nitro/util/testhelpers"
)

func initRedisForTest(t *testing.T, ctx context.Context, redisUrl string, nodeNames []string) {
Expand Down Expand Up @@ -271,6 +273,8 @@ func TestRedisSeqCoordinatorPriorities(t *testing.T) {
}

func testCoordinatorMessageSync(t *testing.T, successCase bool) {
logHandler := testhelpers.InitTestLog(t, log.LvlTrace)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down Expand Up @@ -305,16 +309,25 @@ func testCoordinatorMessageSync(t *testing.T, successCase bool) {

nodeConfigDup := *builder.nodeConfig
builder.nodeConfig = &nodeConfigDup

builder.nodeConfig.Feed.Output = *newBroadcasterConfigTest()
builder.nodeConfig.SeqCoordinator.MyUrl = nodeNames[1]
if !successCase {
builder.nodeConfig.SeqCoordinator.Signer.ECDSA.AcceptSequencer = false
builder.nodeConfig.SeqCoordinator.Signer.ECDSA.AllowedAddresses = []string{builder.L2Info.GetAddress("User2").Hex()}
}

testClientB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: builder.nodeConfig})
defer cleanupB()

// Build nodeBOutputFeedReader.
// nodeB doesn't sequence transactions, but adds messages related to them to its output feed.
// nodeBOutputFeedReader reads those messages from this feed and processes them.
// nodeBOutputFeedReader doesn't read messages from L1 since none of the nodes posts to L1.
nodeBPort := testClientB.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port
nodeConfigNodeBOutputFeedReader := arbnode.ConfigDefaultL1NonSequencerTest()
nodeConfigNodeBOutputFeedReader.Feed.Input = *newBroadcastClientConfigTest(nodeBPort)
testClientNodeBOutputFeedReader, cleanupNodeBOutputFeedReader := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: nodeConfigNodeBOutputFeedReader})
defer cleanupNodeBOutputFeedReader()

tx := builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil)

err = builder.L2.Client.SendTransaction(ctx, tx)
Expand All @@ -331,6 +344,19 @@ func testCoordinatorMessageSync(t *testing.T, successCase bool) {
if l2balance.Cmp(big.NewInt(1e12)) != 0 {
t.Fatal("Unexpected balance:", l2balance)
}

// check that nodeBOutputFeedReader also processed the transaction
_, err = WaitForTx(ctx, testClientNodeBOutputFeedReader.Client, tx.Hash(), time.Second*5)
Require(t, err)
l2balance, err = testClientNodeBOutputFeedReader.Client.BalanceAt(ctx, builder.L2Info.GetAddress("User2"), nil)
Require(t, err)
if l2balance.Cmp(big.NewInt(1e12)) != 0 {
t.Fatal("Unexpected balance:", l2balance)
}

if logHandler.WasLogged("block_hash_mismatch") {
t.Fatal("block_hash_mismatch was logged unexpectedly")
}
} else {
_, err = WaitForTx(ctx, testClientB.Client, tx.Hash(), time.Second)
if err == nil {
Expand Down

0 comments on commit 8894481

Please sign in to comment.