From 0c75dcef591a98cac91fb536cfc28ffe6c2594da Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Tue, 26 Nov 2024 18:29:07 +1100 Subject: [PATCH 1/2] add `anvil_setMinGasPrice` as an unsupported method --- SUPPORTED_APIS.md | 3 ++- src/namespaces/anvil.rs | 8 ++++++++ src/node/anvil.rs | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/SUPPORTED_APIS.md b/SUPPORTED_APIS.md index a76d569d..77912d69 100644 --- a/SUPPORTED_APIS.md +++ b/SUPPORTED_APIS.md @@ -14,6 +14,7 @@ The `status` options are: | Namespace | API |
Status
| Description | | --- | --- | --- | --- | +| `ANVIL` | `anvil_setMinGasPrice` | `NOT IMPLEMENTED` | Set the minimum gas price for the node. Unsupported by design | | `ANVIL` | `anvil_snapshot` | `SUPPORTED` | Snapshot the state of the blockchain at the current block | | `ANVIL` | `anvil_revert` | `SUPPORTED` | Revert the state of the blockchain to a previous snapshot | | `ANVIL` | `anvil_setTime` | `SUPPORTED` | Sets the internal clock time to the given timestamp | @@ -110,7 +111,7 @@ The `status` options are: | `HARDHAT` | `hardhat_addCompilationResult` | `NOT IMPLEMENTED` | Add information about compiled contracts | | `HARDHAT` | `hardhat_dropTransaction` | `NOT IMPLEMENTED` | Remove a transaction from the mempool | | [`HARDHAT`](#hardhat-namespace) | [`hardhat_impersonateAccount`](#hardhat_impersonateaccount) | `SUPPORTED` | Impersonate an account | -| [`HARDHAT`](#hardhat-namespace) | [`hardhat_getAutomine`](#hardhat_getautomine) | `PARTIAL` | Currently always returns `true` as era-test-node by default mines new blocks with each new transaction. | +| [`HARDHAT`](#hardhat-namespace) | [`hardhat_getAutomine`](#hardhat_getautomine) | `PARTIAL` | Currently always returns `true` as era-test-node by default mines new blocks with each new transaction. | | `HARDHAT` | `hardhat_metadata` | `NOT IMPLEMENTED` | Returns the metadata of the current network | | [`HARDHAT`](#hardhat-namespace) | [`hardhat_mine`](#hardhat_mine) | Mine any number of blocks at once, in constant time | | [`HARDHAT`](#hardhat-namespace) | [`hardhat_reset`](#hardhat_reset) | `PARTIALLY` | Resets the state of the network; cannot revert to past block numbers, unless they're in a fork | diff --git a/src/namespaces/anvil.rs b/src/namespaces/anvil.rs index 39c802a0..e7ab0633 100644 --- a/src/namespaces/anvil.rs +++ b/src/namespaces/anvil.rs @@ -6,6 +6,14 @@ use crate::utils::Numeric; #[rpc] pub trait AnvilNamespaceT { + /// Set the minimum gas price for the node. Unsupported by design. + /// + /// # Arguments + /// + /// * `gas` - The minimum gas price to be set + #[rpc(name = "anvil_setMinGasPrice")] + fn set_min_gas_price(&self, gas: U256) -> RpcResult<()>; + /// Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot /// that was created. A snapshot can only be reverted once. After a successful `anvil_revert`, the same snapshot id cannot /// be used again. Consider creating a new snapshot after each `anvil_revert` if you need to revert to the same diff --git a/src/node/anvil.rs b/src/node/anvil.rs index a3251f5a..70f426ab 100644 --- a/src/node/anvil.rs +++ b/src/node/anvil.rs @@ -12,6 +12,11 @@ use crate::{ impl AnvilNamespaceT for InMemoryNode { + fn set_min_gas_price(&self, _gas: U256) -> RpcResult<()> { + tracing::info!("anvil_setMinGasPrice is unsupported as ZKsync is a post-EIP1559 chain"); + Err(into_jsrpc_error(Web3Error::MethodNotImplemented)).into_boxed_future() + } + fn snapshot(&self) -> RpcResult { self.snapshot() .map_err(|err| { From 810ff4160adf773d0804832b02b7aef3192e328e Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Tue, 26 Nov 2024 19:19:25 +1100 Subject: [PATCH 2/2] clarify unsupported comment --- SUPPORTED_APIS.md | 2 +- src/namespaces/anvil.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SUPPORTED_APIS.md b/SUPPORTED_APIS.md index 77912d69..087c932b 100644 --- a/SUPPORTED_APIS.md +++ b/SUPPORTED_APIS.md @@ -14,7 +14,7 @@ The `status` options are: | Namespace | API |
Status
| Description | | --- | --- | --- | --- | -| `ANVIL` | `anvil_setMinGasPrice` | `NOT IMPLEMENTED` | Set the minimum gas price for the node. Unsupported by design | +| `ANVIL` | `anvil_setMinGasPrice` | `NOT IMPLEMENTED` | Set the minimum gas price for the node. Unsupported for ZKsync as it is only relevant for pre-EIP1559 chains | | `ANVIL` | `anvil_snapshot` | `SUPPORTED` | Snapshot the state of the blockchain at the current block | | `ANVIL` | `anvil_revert` | `SUPPORTED` | Revert the state of the blockchain to a previous snapshot | | `ANVIL` | `anvil_setTime` | `SUPPORTED` | Sets the internal clock time to the given timestamp | diff --git a/src/namespaces/anvil.rs b/src/namespaces/anvil.rs index e7ab0633..842a66fe 100644 --- a/src/namespaces/anvil.rs +++ b/src/namespaces/anvil.rs @@ -6,7 +6,8 @@ use crate::utils::Numeric; #[rpc] pub trait AnvilNamespaceT { - /// Set the minimum gas price for the node. Unsupported by design. + /// Set the minimum gas price for the node. Unsupported for ZKsync as it is only relevant for + /// pre-EIP1559 chains. /// /// # Arguments ///