Skip to content

Commit

Permalink
feat: Implement evm_increaseTime, evm_setNextBlockTimestamp, and evm_…
Browse files Browse the repository at this point in the history
…setTime (#93)
  • Loading branch information
nbaztec committed Sep 11, 2023
1 parent fee3152 commit 40cf025
Show file tree
Hide file tree
Showing 4 changed files with 541 additions and 7 deletions.
82 changes: 75 additions & 7 deletions SUPPORTED_APIS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The `status` options are:
| `ETH` | `eth_uninstallFilter` | `NOT IMPLEMENTED`<br />[GitHub Issue #38](https://github.com/matter-labs/era-test-node/issues/38) | Uninstalls a filter with given id |
| `ETH` | `eth_unsubscribe` | `NOT IMPLEMENTED` | Cancel a subscription to a particular event |
| `EVM` | `evm_addAccount` | `NOT IMPLEMENTED` | Adds any arbitrary account |
| `EVM` | `evm_increaseTime` | `NOT IMPLEMENTED`<br />[GitHub Issue #66](https://github.com/matter-labs/era-test-node/issues/66) | Jump forward in time by the given amount of time, in seconds |
| [`EVM`](#evm-namespace) | [`evm_increaseTime`](#evm_increasetime) | `SUPPORTED` | Jump forward in time by the given amount of time, in seconds |
| `EVM` | `evm_mine` | `NOT IMPLEMENTED`<br />[GitHub Issue #67](https://github.com/matter-labs/era-test-node/issues/67) | Force a single block to be mined |
| `EVM` | `evm_removeAccount` | `NOT IMPLEMENTED` | Removes an account |
| `EVM` | `evm_revert` | `NOT IMPLEMENTED`<br />[GitHub Issue #70](https://github.com/matter-labs/era-test-node/issues/70) | Revert the state of the blockchain to a previous snapshot |
Expand All @@ -85,8 +85,8 @@ The `status` options are:
| `EVM` | `evm_setAutomine` | `NOT IMPLEMENTED` | Enables or disables the automatic mining of new blocks with each new transaction submitted to the network |
| `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 |
| [`EVM`](#evm-namespace) | [`evm_setNextBlockTimestamp`](#evm_setnextblocktimestamp) | `SUPPORTED` | Works like `evm_increaseTime`, but takes the exact timestamp that you want in the next block, and increases the time accordingly |
| [`EVM`](#evm-namespace) | [`evm_setTime`](#evm_settime) | `SUPPORTED` | Sets the internal clock time to the given timestamp |
| `EVM` | `evm_snapshot` | `NOT IMPLEMENTED`<br />[GitHub Issue #69](https://github.com/matter-labs/era-test-node/issues/69) | Snapshot the state of the blockchain at the current block |
| `HARDHAT` | `hardhat_addCompilationResult` | `NOT IMPLEMENTED` | Add information about compiled contracts |
| `HARDHAT` | `hardhat_dropTransaction` | `NOT IMPLEMENTED` | Remove a transaction from the mempool |
Expand Down Expand Up @@ -753,10 +753,6 @@ The new nonce must be greater than the existing nonce.
+ `address: Address` - The `Address` whose nonce is to be changed
+ `nonce: U256` - The new nonce

#### Status

`SUPPORTED`

#### Example

```bash
Expand All @@ -774,6 +770,78 @@ curl --request POST \
}'
```

## `EVM NAMESPACE`

### `evm_increaseTime`

[source](src/evm.rs)

Increase the current timestamp for the node

#### Arguments

+ `time_delta_seconds: U64`

#### Status

`SUPPORTED`

#### Example

```bash
curl --request POST \
--url http://localhost:8011/ \
--header 'content-type: application/json' \
--data '{"jsonrpc": "2.0","id": "1","method": "evm_increaseTime","params": [10]}'
```

### `evm_setNextBlockTimestamp`

[source](src/evm.rs)

Sets the timestamp of the next block but doesn't mine one..

#### Arguments

+ `timestamp: U64`

#### Status

`SUPPORTED`

#### Example

```bash
curl --request POST \
--url http://localhost:8011/ \
--header 'content-type: application/json' \
--data '{"jsonrpc": "2.0","id": "1","method": "evm_setNextBlockTimestamp","params": [1672527600]}'
```

### `evm_setTime`

[source](src/evm.rs)

Set the current timestamp for the node. Warning: This will allow you to move _backwards_ in time, which
may cause new blocks to appear to be mined before old blocks. This will result in an invalid state.

#### Arguments

+ `time: U64`

#### Status

`SUPPORTED`

#### Example

```bash
curl --request POST \
--url http://localhost:8011/ \
--header 'content-type: application/json' \
--data '{"jsonrpc": "2.0","id": "1","method": "evm_setTime","params": [1672527600]}'
```

## `ZKS NAMESPACE`

### `zks_estimateFee`
Expand Down
Loading

0 comments on commit 40cf025

Please sign in to comment.