Skip to content

Commit

Permalink
Sim flakiness (#2123)
Browse files Browse the repository at this point in the history
* reorder sim test shutdown and more efficient hash lookup on rollup verification
  • Loading branch information
badgersrus authored Nov 5, 2024
1 parent d1b658a commit bdb6d17
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
18 changes: 15 additions & 3 deletions go/enclave/components/rollup_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,22 @@ func (rc *rollupConsumerImpl) extractAndVerifyRollups(br *common.BlockAndReceipt
return rollups, nil
}

// there may be many rollups in one block so the blobHashes array, so it is possible that the rollupHashes array is a
// subset of the blobHashes array
func verifyBlobHashes(rollupHashes *ethadapter.L1RollupHashes, blobHashes []gethcommon.Hash) error {
for i, hash := range rollupHashes.BlobHashes {
if hash != blobHashes[i] {
return fmt.Errorf("hash mismatch at index %d: rollupHash (%s) != blobHash (%s)", i, hash.Hex(), blobHashes[i].Hex())
// more efficient lookup
blobHashSet := make(map[gethcommon.Hash]struct{}, len(blobHashes))
for _, h := range blobHashes {
blobHashSet[h] = struct{}{}
}

for i, rollupHash := range rollupHashes.BlobHashes {
if _, exists := blobHashSet[rollupHash]; !exists {
return fmt.Errorf(
"rollupHash at index %d (%s) not found in blobHashes",
i,
rollupHash.Hex(),
)
}
}
return nil
Expand Down
9 changes: 4 additions & 5 deletions integration/simulation/simulation_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,13 @@ func testSimulation(t *testing.T, netw network.Network, params *params.SimParams
// run tests
fmt.Printf("Validating simulation results\n")
testlog.Logger().Info("Validating simulation results")

checkNetworkValidity(t, &simulation)

fmt.Printf("Stopping simulation\n")
testlog.Logger().Info("Stopping simulation")
simulation.Stop()

// generate and print the final stats
t.Logf("Simulation results:%+v", NewOutputStats(&simulation))
testlog.Logger().Info(fmt.Sprintf("Simulation results:%+v", NewOutputStats(&simulation)))

fmt.Printf("Stopping simulation\n")
testlog.Logger().Info("Stopping simulation")
simulation.Stop()
}

0 comments on commit bdb6d17

Please sign in to comment.