diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index ebccd602..8567580a 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -19,7 +19,7 @@ jobs: - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: nightly-2023-08-21 + toolchain: nightly-2024-01-01 components: rustfmt, clippy - uses: actions/setup-node@v3 @@ -44,7 +44,7 @@ jobs: - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: nightly-2023-08-21 + toolchain: nightly-2024-01-01 - name: Build Code run: make all diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 4e8ceeba..870161b1 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -33,7 +33,7 @@ jobs: - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: nightly-2023-08-21 + toolchain: nightly-2024-01-01 - name: Setup Pages uses: actions/configure-pages@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e50ae41..4f23d664 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,7 @@ jobs: - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: nightly-2023-08-21 + toolchain: nightly-2024-01-01 - name: Install target run: rustup target add ${{ matrix.arch }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 973f28b1..4fa5eb8b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -24,7 +24,7 @@ jobs: - name: Install Rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: - toolchain: nightly-2023-08-21 + toolchain: nightly-2024-01-01 - name: Install cargo-nextest run: cargo install cargo-nextest diff --git a/SUPPORTED_APIS.md b/SUPPORTED_APIS.md index e560c0fb..f0ffe7b8 100644 --- a/SUPPORTED_APIS.md +++ b/SUPPORTED_APIS.md @@ -129,7 +129,7 @@ The `status` options are: | [`ZKS`](#zks-namespace) | [`zks_getTokenPrice`](#zks_getTokenPrice) | `SUPPORTED` | Gets the USD price of a token
_(`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_L1ChainId` | `NOT IMPLEMENTED` | Returns the chain id of the underlying L1 | +| [`ZKS`](#zks-namespace) | [`zks_L1ChainId`](#zks_l1chainid) | `IMPLEMENTED` | Returns the chain id of the underlying L1 | ## `CONFIG NAMESPACE` @@ -1979,3 +1979,26 @@ curl --request POST \ "params": ["0x364d6D0333432C3Ac016Ca832fb8594A8cE43Ca6"] }' ``` + +### `zks_L1ChainId` + +[source](src/node/zks.rs) + +Returns the chain id of the underlying L1. + +#### Arguments + ++ _NONE_ + +#### Status + +`SUPPORTED` + +#### Example + +```bash +curl --request POST \ + --url http://localhost:8011/ \ + --header 'content-type: application/json' \ + --data '{"jsonrpc": "2.0","id": "1","method": "zks_L1ChainId","params": []}' +``` diff --git a/etc/system-contracts/bootloader/test_infra/rust-toolchain b/etc/system-contracts/bootloader/test_infra/rust-toolchain index 9a87fb21..5951a259 100644 --- a/etc/system-contracts/bootloader/test_infra/rust-toolchain +++ b/etc/system-contracts/bootloader/test_infra/rust-toolchain @@ -1 +1 @@ -nightly-2023-08-21 +nightly-2024-01-01 diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 14381872..d07be424 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-08-21" +channel = "nightly-2024-01-01" components = ["rustfmt", "clippy"] \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 8637bbd0..46aae730 100644 --- a/src/main.rs +++ b/src/main.rs @@ -372,7 +372,7 @@ async fn main() -> anyhow::Result<()> { tracing::info!(""); tracing::info!("Rich Accounts"); tracing::info!("============="); - for (_, wallet) in LEGACY_RICH_WALLETS.iter().enumerate() { + for wallet in LEGACY_RICH_WALLETS.iter() { let address = wallet.0; node.set_rich_account(H160::from_str(address).unwrap()); } diff --git a/src/node/zks.rs b/src/node/zks.rs index 7b83b540..4b26ab6d 100644 --- a/src/node/zks.rs +++ b/src/node/zks.rs @@ -176,7 +176,8 @@ impl ZksNamespa } fn l1_chain_id(&self) -> RpcResult { - not_implemented("zks_L1ChainId") + use crate::namespaces::EthNamespaceT; + self.chain_id() } fn get_confirmed_tokens( @@ -515,6 +516,7 @@ mod tests { use crate::cache::CacheConfig; use crate::fork::ForkDetails; + use crate::node::TEST_NODE_NETWORK_ID; use crate::testing; use crate::testing::{ForkBlockConfig, MockServer}; use crate::{http_fork_source::HttpForkSource, node::InMemoryNode}; @@ -1043,6 +1045,13 @@ mod tests { assert_eq!(&balances[0].name, "Ether"); } + #[tokio::test] + async fn test_get_l1_chain_id() { + let node = InMemoryNode::::default(); + let chain_id = node.l1_chain_id().await.expect("get chain id").as_u32(); + assert_eq!(TEST_NODE_NETWORK_ID, chain_id); + } + #[tokio::test] async fn test_get_all_account_balances_forked() { let cbeth_address = Address::from_str("0x75af292c1c9a37b3ea2e6041168b4e48875b9ed5") diff --git a/test_endpoints.http b/test_endpoints.http index 5a2d56ff..91ac0cad 100644 --- a/test_endpoints.http +++ b/test_endpoints.http @@ -751,6 +751,17 @@ content-type: application/json POST http://localhost:8011 content-type: application/json +{ + "jsonrpc": "2.0", + "id": "1", + "method": "zks_L1ChainId", + "params": [] +} + +### +POST http://localhost:8011 +content-type: application/json + { "jsonrpc": "2.0", "id": "1",