matter-labs / era-test-node

In-memory node that can be used for integration testing and debugging.
https://matter-labs.github.io/era-test-node
Apache License 2.0
313 stars 76 forks source link

feat: add `anvil_{set,remove}BlockTimestampInterval` #442

Closed itegulov closed 2 days ago

itegulov commented 3 days ago

What :computer:

Closes #423

This kind of snowballed out of control as I had to refactor time management in a way that unties it from relying on +1 everywhere. The gist is that I introduced two new traits:

Sealing blocks requires a TimeExclusive instance to be passed now and we have some flexibility in what we can pass. This fixes a few TOCTOU bugs that we used to have (we rely on clock not progressing between us constructing the new block and applying it, which was not always the case before but it is not with TimeExclusive). This also made mine_blocks more robust as it enforces the provided offsets now.

Additionally this PR removes time from snapshot state (See https://github.com/matter-labs/era-test-node/issues/414 why I think this is movement in the right direction)

New functionality is covered with an e2e test, but the refactoring is critically lacking in tests. I am open to adding some tests for the time module, but have already spent too much time on this so might just add this to the long list of TODOs.

Why :hand:

Feature parity with anvil