Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tudor/flakyness and perf fixes #1559

Merged
merged 2 commits into from
Sep 27, 2023
Merged

Conversation

tudor-malene
Copy link
Collaborator

Why this change is needed

  • The in-mem sim is flaky because there was a bug with chaining the batches when there is a reorg.
  • Rollup decompression is slow on the sepolia testnet because of the inefficient block fetching. Which is now cached

}

for _, rollup := range rollups {
l1CompressionBlock, err := rc.storage.FetchBlock(rollup.Header.CompressionL1Head)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some sanity checks here

@@ -35,8 +35,8 @@ func TestInMemoryMonteCarloSimulation(t *testing.T) {
StartPort: integration.StartPortSimulationInMem,
IsInMem: true,
L1SetupData: &params.L1SetupData{},
ReceiptTimeout: 30 * time.Second,
StoppingDelay: 10 * time.Second,
ReceiptTimeout: 5 * time.Second,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those timeouts were too long for the in-mem sim

@@ -374,14 +406,27 @@ func (rc *RollupCompression) executeAndSaveIncompleteBatches(calldataRollupHeade
// check whether the batch is already stored in the database
b, err := rc.storage.FetchBatchBySeqNo(incompleteBatch.seqNo.Uint64())
if err == nil {
parentHash = b.Hash()
// chain to a parent only if the batch is not a reorg
if incompleteBatch.header == nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the bug that was causing the flakyness

continue
}
if !errors.Is(err, errutil.ErrNotFound) {
return err
}

switch {
// this batch was re-orged
case incompleteBatch.header != nil:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another rare flakyness issue, when the genesis itself was reorged


// a cache of the l1 blocks used by the current rollup, indexed by their height
l1BlocksAtHeight := make(map[uint64]*types.Block)
err = rc.calcL1AncestorsOfHeight(big.NewInt(int64(slices.Min(l1Heights))), rollupL1Block, l1BlocksAtHeight)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the performance fix to avoid traversing blocks

Copy link
Collaborator

@BedrockSquirrel BedrockSquirrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tudor-malene tudor-malene merged commit a97b835 into main Sep 27, 2023
@tudor-malene tudor-malene deleted the tudor/flakyness_and_perf_fixes branch September 27, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants