Skip to content
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

refactor: migrate to jsonrpsee + zksync_web3_decl #497

Merged
merged 19 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
489 changes: 123 additions & 366 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[workspace]
members = [
"crates/api_decl",
"crates/api_server",
"crates/cli",
"crates/config",
"crates/core",
"crates/types",
]
resolver = "2"

Expand Down Expand Up @@ -38,7 +41,6 @@ zksync_web3_decl = { git = "https://github.com/matter-labs/zksync-era.git", rev
anyhow = "1.0"
alloy-signer-local = { version = "0.5.4", features = ["mnemonic"] }
alloy-signer = { version = "0.5.4", default-features = false }
bigdecimal = { version = "0.3.0", features = ["serde"] }
chrono = { version = "0.4.31", default-features = false }
clap = { version = "4.2.4", features = ["derive", "env"] }
colored = "2"
Expand All @@ -47,12 +49,10 @@ eyre = "0.6"
flate2 = "1.0"
futures = { version = "0.3", features = ["compat"] }
hex = "0.4"
http = "1.1.0"
indexmap = "2.0.1"
itertools = "0.13"
jsonrpc-http-server = { git = "https://github.com/matter-labs/jsonrpc.git", branch = "master" }
jsonrpc-core = { git = "https://github.com/matter-labs/jsonrpc.git", branch = "master" }
jsonrpc-core-client = { git = "https://github.com/matter-labs/jsonrpc.git", branch = "master" }
jsonrpc-derive = { git = "https://github.com/matter-labs/jsonrpc.git", branch = "master" }
jsonrpsee = "0.23"
lazy_static = "1.4"
once_cell = "1.7"
rand = "0.8"
Expand All @@ -63,6 +63,8 @@ serde_json = "1.0"
thiserror = "1"
time = "0.3.36"
tokio = { version = "1", features = ["full", "tracing"] }
tower = "0.4"
tower-http = { version = "0.6.2", features = ["cors"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", features = [
"fmt",
Expand All @@ -75,5 +77,8 @@ tracing-subscriber = { version = "0.3", features = [
#########################
# Local dependencies #
#########################
anvil_zksync_api_decl = { path = "crates/api_decl" }
anvil_zksync_api_server = { path = "crates/api_server" }
anvil_zksync_config = { path = "crates/config" }
anvil_zksync_core = { path = "crates/core" }
anvil_zksync_types = { path = "crates/types" }
8 changes: 7 additions & 1 deletion SUPPORTED_APIS.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,28 @@ The `status` options are:
| [`ZKS`](#zks-namespace) | [`zks_estimateFee`](#zks_estimateFee) | `SUPPORTED` | Gets the Fee estimation data for a given Request |
| `ZKS` | `zks_estimateGasL1ToL2` | `NOT IMPLEMENTED` | Estimate of the gas required for a L1 to L2 transaction |
| [`ZKS`](#zks-namespace) | [`zks_getAllAccountBalances`](#zks_getallaccountbalances) | `SUPPORTED` | Returns all balances for confirmed tokens given by an account address |
| `ZKS` | `zks_getBatchFeeInput` | `NOT IMPLEMENTED` | Retrieves current batch's fee input |
| [`ZKS`](#zks-namespace) | [`zks_getBridgeContracts`](#zks_getbridgecontracts) | `SUPPORTED` | Returns L1/L2 addresses of default bridges |
| [`ZKS`](#zks-namespace) | [`zks_getBridgehubContract`](#zks_getbridgecontracts) | `NOT IMPLEMENTED` | Retrieves the bridge hub contract address |
| [`ZKS`](#zks-namespace) | [`zks_getBlockDetails`](#zks_getblockdetails) | `SUPPORTED` | Returns additional zkSync-specific information about the L2 block |
| `ZKS` | `zks_getBytecodeByHash` | `NOT IMPLEMENTED` | Returns bytecode of a transaction given by its hash |
| [`ZKS`](#zks-namespace) | [`zks_getConfirmedTokens`](#zks_getconfirmedtokens) | `SUPPORTED` | Returns [address, symbol, name, and decimal] information of all tokens within a range of ids given by parameters `from` and `limit` |
| [`ZKS`](#zks-namespace) | [`zks_getBaseTokenL1Address`](#zks_getBaseTokenL1Address) | `SUPPORTED` | Returns the L1 base token address <br/>_(hard-coded to `0x0000000000000000000000000000000000000001`)_ |
| `ZKS` | `zks_getFeeParams` | `NOT IMPLEMENTED` | Retrieves the current fee parameters |
| `ZKS` | `zks_getL1BatchBlockRange` | `NOT IMPLEMENTED` | Returns the range of blocks contained within a batch given by batch number |
| `ZKS` | `zks_getL1BatchDetails` | `NOT IMPLEMENTED` | Returns data pertaining to a given batch |
| `ZKS` | `zks_getL1GasPrice` | `NOT IMPLEMENTED` | Retrieves the current L1 gas price |
| `ZKS` | `zks_getL2ToL1LogProof` | `NOT IMPLEMENTED` | Given a transaction hash, and an index of the L2 to L1 log produced within the transaction, it returns the proof for the corresponding L2 to L1 log |
| `ZKS` | `zks_getL2ToL1MsgProof` | `NOT IMPLEMENTED` | Given a block, a sender, a message, and an optional message log index in the block containing the L1->L2 message, it returns the proof for the message sent via the L1Messenger system contract |
| `ZKS` | `zks_getMainContract` | `NOT IMPLEMENTED` | Returns the address of the zkSync Era contract |
| `ZKS` | `zks_getProof` | `NOT IMPLEMENTED` | Generates Merkle proofs for one or more storage values associated with a specific account |
| `ZKS` | `zks_getProtocolVersion` | `NOT IMPLEMENTED` | Gets the protocol version |
| [`ZKS`](#zks-namespace) | [`zks_getRawBlockTransactions`](#zks_getrawblocktransactions) | `SUPPORTED` | Returns data of transactions in a block |
| `ZKS` | `zks_getTestnetPaymaster` | `NOT IMPLEMENTED` | Returns the address of the testnet paymaster |
| [`ZKS`](#zks-namespace) | [`zks_getTokenPrice`](#zks_getTokenPrice) | `SUPPORTED` | Gets the USD price of a token <br />_(`ETH` is hard-coded to `1_500`, while some others are `1`)_ |
| [`ZKS`](#zks-namespace) | [`zks_getTransactionDetails`](#zks_gettransactiondetails) | `SUPPORTED` | Returns data from a specific transaction given by the transaction hash |
| `ZKS` | `zks_L1BatchNumber` | `NOT IMPLEMENTED` | Returns the latest L1 batch number |
| [`ZKS`](#zks-namespace) | [`zks_L1ChainId`](#zks_l1chainid) | `IMPLEMENTED` | Returns the chain id of the underlying L1 |
| `ZKS` | `zks_sendRawTransactionWithDetailedOutput` | `NOT IMPLEMENTED` | Executes a transaction with detailed output |

## `CONFIG NAMESPACE`

Expand Down
19 changes: 19 additions & 0 deletions crates/api_decl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "anvil_zksync_api_decl"
description = "anvil-zksync API declarations"
version.workspace = true
edition.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true

[dependencies]
anvil_zksync_types.workspace = true

zksync_types.workspace = true
zksync_web3_decl.workspace = true

jsonrpsee.workspace = true
11 changes: 11 additions & 0 deletions crates/api_decl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mod namespaces;

pub use namespaces::{
AnvilNamespaceServer, ConfigNamespaceServer, EthTestNamespaceServer, EvmNamespaceServer,
};

// Re-export available namespaces from zksync-era
pub use zksync_web3_decl::namespaces::{
DebugNamespaceServer, EthNamespaceServer, NetNamespaceServer, Web3NamespaceServer,
ZksNamespaceServer,
};
Loading
Loading