reth icon indicating copy to clipboard operation
reth copied to clipboard

feat: Sanitize block gaps in eth_simulateV1

Open iTranscend opened this issue 8 months ago • 3 comments

This PR:

  • fills up block gaps with empty Calls execution in eth_simulateV1
  • ensures the block number doesn't decrease during simulation

resolves https://github.com/paradigmxyz/reth/issues/15460

iTranscend avatar Apr 07 '25 04:04 iTranscend

@iTranscend do you have capacity to get this over the finish line?

jenpaff avatar Apr 18 '25 10:04 jenpaff

Hey @jenpaff. Yeah, I can get this finished in the next day or two. I'll just need to write a simpler version of my proposed solution.

The current solution is the most efficient way of solving this that I could think of by taking advantage of Iterators laziness, but I understand that it may be a bit hard to read.

iTranscend avatar Apr 19 '25 04:04 iTranscend

Hey @mattsse, I've done away with the iterator approach and used a while loop to fill up the gaps

iTranscend avatar Apr 21 '25 05:04 iTranscend

Hey @mattsse, got a chance to take a look at this?

iTranscend avatar Apr 28 '25 10:04 iTranscend

Hey @mattsse

I took the stack based approached as suggested, but reversed block_state_calls so that I could emulate popping from the front.

This mimics the behavior of a VecDeque without incurring the cost of an extra allocation.

The reversal is O(n/2) as compared to the VecDeque approach which would have been O(n) plus an extra allocation.

This also guarantees that the Vec only ever shrinks by reusing an existing slot.

iTranscend avatar May 16 '25 06:05 iTranscend