-
Notifications
You must be signed in to change notification settings - Fork 76
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
feat: Implement evm_increaseTime and evm_setNextBlockTimestamp #93
feat: Implement evm_increaseTime and evm_setNextBlockTimestamp #93
Conversation
@MexicanAce I changed the return types to native types |
@@ -86,7 +86,7 @@ The `status` options are: | |||
| `EVM` | `evm_setBlockGasLimit` | `NOT IMPLEMENTED` | Sets the Block Gas Limit of the network | | |||
| `EVM` | `evm_setIntervalMining` | `NOT IMPLEMENTED` | Enables (with a numeric argument greater than 0) or disables (with a numeric argument equal to 0), the automatic mining of blocks at a regular interval of milliseconds, each of which will include all pending transactions | | |||
| `EVM` | `evm_setNextBlockTimestamp` | `NOT IMPLEMENTED`<br />[GitHub Issue #68](https://github.com/matter-labs/era-test-node/issues/68) | Works like `evm_increaseTime`, but takes the exact timestamp that you want in the next block, and increases the time accordingly | | |||
| `EVM` | `evm_setTime` | `NOT IMPLEMENTED` | Sets the internal clock time to the given timestamp | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's actually a need for both here. Ganache only supports evm_setTime, while Hardhat only support evm_setNextBlockTimestamp ... but I think they both do the same thing. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can either implement evm_setTime
in this PR, or leave the line here in this table.
Also, it looks like this change leaves 2 rows/entries for evm_setNextBlockTimestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's actually a need for both here. Ganache only supports evm_setTime, while Hardhat only support evm_setNextBlockTimestamp ... but I think they both do the same thing. Thoughts?
Yeah they do exactly the same thing with the following differences:
setNextBlockTimestamp
allows only setting a timestamp forward in future, whilesetTime
supports setting it backwards.setNextBlockTimestamp
returns the newly set timestamp in response, whereassetTime
returns the difference between the current and the new timestamp.
AFAIK setTime
can be seen as a superset of setNextBlockTimestamp
and from most examples out there no one seems to be using the return value to do anything meaningful.
I'm fine with supporting both, though it must be explicitly mentioned (to avoid any confusion for users) that these two achieve the same result and are mostly arising out of API differences between hardhat and ganache - though it does tend to make our API interface a bit messy.
@nbaztec thanks for the contribution! Can you address the conflicts on this PR please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What π»
Adds the following EVM rpc methods to the test node:
evm_increaseTime
evm_setNextBlockTimestamp
evm_setTime
Why β
Evidence π·
Passing unit tests:
Notes π
Fixes #66 & #68