Skip to content

Conversation

@ecPablo
Copy link
Contributor

@ecPablo ecPablo commented Aug 12, 2025

Add support to call the advance time from anvil. This will be useful in the MCMS fork test use cases where we need to advance the timelock time in order to not wait the elapsed time during fork tests.

AI Summary

This pull request adds support for advancing the EVM time in Anvil via the evm_increaseTime RPC method. It introduces a new method in the RPCClient and a corresponding integration test to verify its functionality.

EVM time manipulation support:

  • Added a new method EVMIncreaseTime to the RPCClient in rpc.go to send the evm_increaseTime RPC call, allowing tests to programmatically advance the EVM's internal clock.

Testing:

  • Added an integration test in rpc_test.go that verifies the evm_increaseTime method correctly advances the blockchain timestamp when used with Anvil. The test mines a block, advances time, mines another block, and checks the timestamp difference.

Below is a summarization created by an LLM (gpt-4-0125-preview). Be mindful of hallucinations and verify accuracy.

Why

The changes introduce a new function for advancing the EVM's time in tests, update the import path for the math/rand package to math/rand/v2, and add a comprehensive test to validate the EVMIncreaseTime function's behavior. These changes are aimed at enhancing testing capabilities in blockchain simulations, particularly for scenarios that require time manipulation.

What

  • framework/rpc/rpc.go

    • Import path for math/rand updated to math/rand/v2. This change modernizes the codebase by adopting the latest version of the math/rand package, which may include optimizations or new features.
    • Added the EVMIncreaseTime function. This function allows advancing the EVM's virtual time by a specified number of seconds, enabling more dynamic and temporal test scenarios.
  • framework/rpc/rpc_test.go

    • Added a test case (anvil) evm_increaseTime advances timestamp to validate the behavior of the newly introduced EVMIncreaseTime function. This test ensures that the blockchain's timestamp advances correctly when the function is invoked, enhancing confidence in time-dependent contract testing.

@ecPablo ecPablo marked this pull request as ready for review August 14, 2025 14:34
@ecPablo ecPablo requested a review from a team as a code owner August 14, 2025 14:34
@ecPablo ecPablo enabled auto-merge (squash) August 14, 2025 14:59
@ecPablo ecPablo merged commit 1621141 into main Aug 14, 2025
66 checks passed
@ecPablo ecPablo deleted the ecpablo/time-advance branch August 14, 2025 15:04
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