Skip to content

Commit

Permalink
attempt to reduce flakiness of bold virtual block tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Jan 28, 2025
1 parent 3235413 commit a4831d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion system_tests/bold_challenge_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ func makeBoldBatch(
if i == divergeAtIndex {
value++
}
err := writeTxToBatchBold(batchBuffer, l2Info.PrepareTx("Owner", "Destination", 1000000, big.NewInt(value), []byte{}))
err := writeTxToBatchBold(batchBuffer, l2Info.PrepareTx("Owner", "Faucet", 1000000, big.NewInt(value), []byte{}))
Require(t, err)
}
compressed, err := arbcompress.CompressWell(batchBuffer.Bytes())
Expand Down
22 changes: 20 additions & 2 deletions system_tests/bold_new_challenge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,23 @@ func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bo
builder.L1Info.GenerateAccount("EvilAsserter")
fundBoldStaker(t, ctx, builder, "EvilAsserter")

TransferBalance(t, "Faucet", "Faucet", common.Big0, builder.L2Info, builder.L2.Client, ctx)

// Wait for both nodes' chains to catch up to at least a batch that includes the self-transfer
// from above. This makes sure that nodes have at least caught up to the required rollup chain state
// by reading batches from the parent chain.
nodeAExec := builder.L2.ExecNode
nodeBExec := evilNode.ExecNode
for {
nodeALatest := nodeAExec.Backend.APIBackend().CurrentHeader()
nodeBLatest := nodeBExec.Backend.APIBackend().CurrentHeader()
isCaughtUp := nodeALatest.Number.Uint64() == 2
areEqual := nodeALatest.Number.Uint64() == nodeBLatest.Number.Uint64()
if isCaughtUp && areEqual {
break
}
}

assertionChain, cleanupHonestChallengeManager := startBoldChallengeManager(t, ctx, builder, builder.L2, "HonestAsserter", nil)
defer cleanupHonestChallengeManager()

Expand All @@ -173,8 +190,6 @@ func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bo
})
defer cleanupEvilChallengeManager()

TransferBalance(t, "Faucet", "Faucet", common.Big0, builder.L2Info, builder.L2.Client, ctx)

// Everything's setup, now just wait for the challenge to complete and ensure the honest party won

chalManager := assertionChain.SpecChallengeManager()
Expand Down Expand Up @@ -245,12 +260,14 @@ func fundBoldStaker(t *testing.T, ctx context.Context, builder *NodeBuilder, nam
txOpts.Value = nil

tx, err = stakeTokenWeth.Approve(&txOpts, builder.addresses.Rollup, balance)
Require(t, err)
_, err = builder.L1.EnsureTxSucceeded(tx)
Require(t, err)

challengeManager, err := rollupUserLogic.ChallengeManager(&bind.CallOpts{Context: ctx})
Require(t, err)
tx, err = stakeTokenWeth.Approve(&txOpts, challengeManager, balance)
Require(t, err)
_, err = builder.L1.EnsureTxSucceeded(tx)
Require(t, err)
}
Expand Down Expand Up @@ -335,6 +352,7 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB
&txOpts,
butil.NewBackendWrapper(builder.L1.Client, rpc.LatestBlockNumber),
bold.NewDataPosterTransactor(dp),
solimpl.WithRpcHeadBlockNumber(rpc.LatestBlockNumber),
)
Require(t, err)

Expand Down

0 comments on commit a4831d1

Please sign in to comment.