Skip to content

Fixes to MEDIUM severity issues from Jeb's report#382

Closed
philippecamacho wants to merge 9 commits intocelo-integration-rebase-16.2from
philippe/jeb-audit
Closed

Fixes to MEDIUM severity issues from Jeb's report#382
philippecamacho wants to merge 9 commits intocelo-integration-rebase-16.2from
philippe/jeb-audit

Conversation

@philippecamacho
Copy link
Copy Markdown
Collaborator

@philippecamacho philippecamacho commented Mar 26, 2026

Closes tickets related to the MEDIUM severity issues from Jeb's report

This PR:

  • Remove capacity-based overflow handling from batch buffer: replaced the skipPos/rewind mechanism with a simpler approach — batches whose number exceeds BatchPos + MaxBatchOutOfOrder are dropped on arrival in processEspressoTransaction. This bounds the buffer to at most MaxBatchOutOfOrder entries without needing the ErrAtCapacity / skipPos / rewind machinery.
  • Fix fallbackBatchPos initialization bug: NewEspressoStreamer previously set fallbackBatchPos = originBatchPos + 1, but Reset() computes BatchPos = fallbackBatchPos + 1. This meant a New followed by Reset would set BatchPos to originBatchPos + 2, skipping one batch. Fixed by setting fallbackBatchPos = originBatchPos so New and Reset produce the same BatchPos
  • Add t.Parallel() to integration tests: all Espresso integration tests now declare t.Parallel()
  • Add espresso-streamer-unit-tests justfile target for fast iteration on streamer/buffer unit tests

This PR does not:

Address other fixes suggestions from Jeb's report. Another PR will be created for the low severity issues.

Key places to review:

Changes to the streamer

How to test this PR:

  • streamer unit tests pass (just espresso-streamer-unit-tests)
  • Check CI is green

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Espresso batch buffering and streaming logic by replacing internal capacity-based limits with a MaxBatchOutOfOrder bound. This change simplifies the BatchStreamer by removing the complex skip and rewind mechanisms previously used when the buffer was full. The PR also significantly improves the testing infrastructure by enabling parallel execution for integration tests and reorganizing the justfile with more granular test groups. Documentation has been updated to reflect the new test commands and parallel execution options. One piece of feedback suggests cleaning up the NewBatchBuffer constructor by removing the now-unused capacity parameter.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@philippecamacho philippecamacho marked this pull request as ready for review March 27, 2026 12:52
@philippecamacho philippecamacho changed the title Simplify batch buffer overflow handling in streamer Fixes to MEDIUM severity issues from Jeb's report Mar 27, 2026
func NewBatchBuffer[B Batch](capacity uint64) BatchBuffer[B] {
return BatchBuffer[B]{
batches: []B{},
capacity: capacity,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I find this previously implementation a bit baffling.

I was unaware of this previous implementation. I'm not sure why we'd store the capacity of the buffer separately from the buffer since the slice type in golang has a builtin capacity already.

We could have easily created the buffer with the given capacity via:

batches: make([]B, 0, capacity)

Then we would have been able to check the stored capacity with:

cap(x.batches)

@QuentinI
Copy link
Copy Markdown
Collaborator

Remove capacity-based overflow handling from batch buffer: replaced the skipPos/rewind mechanism with a simpler approach — batches whose number exceeds BatchPos + MaxBatchOutOfOrder are dropped on arrival in processEspressoTransaction. This bounds the buffer to at most MaxBatchOutOfOrder entries without needing the ErrAtCapacity / skipPos / rewind machinery.

We would need corresponding machinery on the batcher side to ensure it detects this situation. Otherwise as soon as one batch gets sufficiently delayed for whatever reason, the chain will stall.

fallbackBatchPos: originBatchPos + 1,
BatchBuffer: NewBatchBuffer[B](BatchBufferCapacity),
fallbackBatchPos: originBatchPos,
BatchBuffer: NewBatchBuffer[B](MaxBatchOutOfOrder),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems odd to replace the parameter for the NewBatchBuffer call, when we've removed the capacity value that gets stored.

We should probably just remove the parameter entirely, as it this makes it seem that the value passed here is important.

@philippecamacho
Copy link
Copy Markdown
Collaborator Author

Closed in favor of EspressoSystems/espresso-streamers#5

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.

4 participants