Skip to content

Commit

Permalink
feat: add anvil_setMinGasPrice as an unimplemented method (#438)
Browse files Browse the repository at this point in the history
* add `anvil_setMinGasPrice` as an unsupported method

* clarify unsupported comment
  • Loading branch information
itegulov authored Nov 26, 2024
1 parent 7f5b663 commit 45b9fd4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion SUPPORTED_APIS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The `status` options are:

| Namespace | API | <div style="width:130px">Status</div> | Description |
| --- | --- | --- | --- |
| `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_setLoggingEnabled` | `SUPPORTED` | Enables or disables logging |
| `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 |
Expand Down Expand Up @@ -111,7 +112,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 |
Expand Down
9 changes: 9 additions & 0 deletions src/namespaces/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ use crate::utils::Numeric;

#[rpc]
pub trait AnvilNamespaceT {
/// Set the minimum gas price for the node. Unsupported for ZKsync as it is only relevant for
/// pre-EIP1559 chains.
///
/// # Arguments
///
/// * `gas` - The minimum gas price to be set
#[rpc(name = "anvil_setMinGasPrice")]
fn set_min_gas_price(&self, gas: U256) -> RpcResult<()>;

/// Enable or disable logging.
///
/// # Arguments
Expand Down
5 changes: 5 additions & 0 deletions src/node/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ use crate::{
impl<S: ForkSource + std::fmt::Debug + Clone + Send + Sync + 'static> AnvilNamespaceT
for InMemoryNode<S>
{
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 set_logging_enabled(&self, enable: bool) -> RpcResult<()> {
self.set_logging_enabled(enable)
.map_err(|err| {
Expand Down

0 comments on commit 45b9fd4

Please sign in to comment.