Skip to content

Commit 475b033

Browse files
Make TestEthSyncing not flaky (#3920)
1 parent 56f5c6d commit 475b033

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

arbnode/consensus_execution_syncer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ var DefaultConsensusExecutionSyncerConfig = ConsensusExecutionSyncerConfig{
2828
SyncInterval: 300 * time.Millisecond,
2929
}
3030

31+
var TestConsensusExecutionSyncerConfig = ConsensusExecutionSyncerConfig{
32+
SyncInterval: TestSyncMonitorConfig.MsgLag / 2,
33+
}
34+
3135
// We don't define a Test config. For most tests we want the Syncer to behave
3236
// the same as in production.
3337

arbnode/node.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func ConfigDefaultL1NonSequencerTest() *Config {
208208
config.SeqCoordinator.Enable = false
209209
config.BlockValidator = staker.TestBlockValidatorConfig
210210
config.SyncMonitor = TestSyncMonitorConfig
211+
config.ConsensusExecutionSyncer = TestConsensusExecutionSyncerConfig
211212
config.Staker = legacystaker.TestL1ValidatorConfig
212213
config.Staker.Enable = false
213214
config.BlockValidator.ValidationServerConfigs = []rpcclient.ClientConfig{{URL: ""}}
@@ -227,6 +228,7 @@ func ConfigDefaultL2Test() *Config {
227228
config.SeqCoordinator.Signer.ECDSA.Dangerous.AcceptMissing = true
228229
config.Staker = legacystaker.TestL1ValidatorConfig
229230
config.SyncMonitor = TestSyncMonitorConfig
231+
config.ConsensusExecutionSyncer = TestConsensusExecutionSyncerConfig
230232
config.Staker.Enable = false
231233
config.BlockValidator.ValidationServerConfigs = []rpcclient.ClientConfig{{URL: ""}}
232234
config.TransactionStreamer = DefaultTransactionStreamerConfig

system_tests/eth_sync_test.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"testing"
77
"time"
88

9-
"github.com/ethereum/go-ethereum/core/types"
9+
"github.com/offchainlabs/nitro/arbutil"
1010
)
1111

1212
func TestEthSyncing(t *testing.T) {
@@ -18,6 +18,7 @@ func TestEthSyncing(t *testing.T) {
1818
cleanup := builder.Build(t)
1919
defer cleanup()
2020

21+
builder.execConfig.SyncMonitor.MsgLag = builder.nodeConfig.SyncMonitor.MsgLag
2122
testClientB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{})
2223
defer cleanupB()
2324

@@ -29,33 +30,26 @@ func TestEthSyncing(t *testing.T) {
2930

3031
builder.L2Info.GenerateAccount("User2")
3132

32-
tx := builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil)
33-
34-
err = builder.L2.Client.SendTransaction(ctx, tx)
35-
Require(t, err)
36-
37-
_, err = builder.L2.EnsureTxSucceeded(tx)
38-
Require(t, err)
33+
numTxs := uint64(5)
34+
for range numTxs {
35+
builder.L2.TransferBalance(t, "Owner", "User2", big.NewInt(1e12), builder.L2Info)
36+
}
3937

40-
// give the inbox reader a bit of time to pick up the delayed message
41-
time.Sleep(time.Millisecond * 100)
38+
// Give the inbox reader of testClientB a bit of time to pick up batches from L1 and add it to the consensus db
39+
time.Sleep(time.Millisecond * 500)
4240

43-
// sending l1 messages creates l1 blocks.. make enough to get that delayed inbox message in
44-
for i := 0; i < 30; i++ {
45-
builder.L1.SendWaitTestTransactions(t, []*types.Transaction{
46-
builder.L1Info.PrepareTx("Faucet", "User", 30000, big.NewInt(1e12), nil),
47-
})
48-
}
41+
// Advance parent chain enough to get the batches in
42+
AdvanceL1(t, ctx, builder.L1.Client, builder.L1Info, 30)
4943

5044
attempt := 0
5145
for {
5246
if attempt > 30 {
53-
Fatal(t, "2nd node didn't get tx on time")
47+
Fatal(t, "2nd node didn't get all txs on time")
5448
}
5549
Require(t, ctx.Err())
5650
countAfter, err := testClientB.ConsensusNode.TxStreamer.GetMessageCount()
5751
Require(t, err)
58-
if countAfter > countBefore {
52+
if countAfter >= countBefore+arbutil.MessageIndex(numTxs) {
5953
break
6054
}
6155
select {

0 commit comments

Comments
 (0)