diff --git a/docs/docs/_config-options.md b/docs/docs/_config-options.md index a9ff883a5d..54e1ccd2e1 100644 --- a/docs/docs/_config-options.md +++ b/docs/docs/_config-options.md @@ -11,9 +11,10 @@ | `cn-unverifiable-range` | `[]` | Custom network range of blocks to skip hash verifications (e.g. `0,100`) | | `colour` | `true` | Use `--colour=false` command to disable colourized outputs (ANSI Escape Codes) | | `config` | | The YAML configuration file | -| `db-cache-size` | `8` | Determines the amount of memory (in megabytes) allocated for caching data in the database | +| `db-cache-size` | `1024` | Determines the amount of memory (in megabytes) allocated for caching data in the database | | `db-max-handles` | `1024` | A soft limit on the number of open files that can be used by the DB | | `db-path` | `juno` | Location of the database files | +| `disable-l1-verification` | `false` | Disables L1 verification since an Ethereum node is not provided | | `eth-node` | | WebSocket endpoint of the Ethereum node. To verify the correctness of the L2 chain, Juno must connect to an Ethereum node and parse events in the Starknet contract | | `grpc` | `false` | Enable the HTTP gRPC server on the default port | | `grpc-host` | `localhost` | The interface on which the gRPC server will listen for requests | @@ -37,6 +38,7 @@ | `p2p-private-key` | | EXPERIMENTAL: Hexadecimal representation of a private key on the Ed25519 elliptic curve | | `p2p-public-addr` | | EXPERIMENTAL: Specify p2p public address as multiaddr. Example: /ip4/35.243.XXX.XXX/tcp/7777 | | `pending-poll-interval` | `5` | Sets how frequently pending block will be updated (0s will disable fetching of pending block) | +| `plugin-path` | | Path to the plugin .so file | | `pprof` | `false` | Enables the pprof endpoint on the default port | | `pprof-host` | `localhost` | The interface on which the pprof HTTP server will listen for requests | | `pprof-port` | `6062` | The port on which the pprof HTTP server will listen for requests | diff --git a/docs/docs/staking-validator.md b/docs/docs/staking-validator.md new file mode 100644 index 0000000000..92520cfbdb --- /dev/null +++ b/docs/docs/staking-validator.md @@ -0,0 +1,32 @@ +# Become a Staking Validator + +Staking on Starknet provides an opportunity to contribute to network security and earn rewards by becoming a validator. Check out the [Becoming a Validator](https://docs.starknet.io/staking/entering-staking/) guide to learn more about the validator process. + +## Prerequisites + +- **STRK Tokens**: At least 20,000 STRK is required for staking. For the latest details, check out the [Staking Protocol Details](https://docs.starknet.io/staking/overview/#protocol_details). +- **Node Setup**: The [latest version of Juno](updating) installed and running on your machine. +- **Starknet Wallet**: A compatible wallet, like [Braavos](https://braavos.app/wallet-features/ledger-on-braavos/) or [Argent](https://www.argent.xyz/blog/how-to-use-your-hardware-wallet-with-argent). +- **Access to CLI/Block Explorer**: Tools like [Voyager](https://voyager.online) for interacting with contracts. + +## 1. Set up Juno + +Juno is a reliable choice for running a Starknet node. Follow the [Running Juno](running-juno) guide to configure Juno using Docker, binaries, source builds, or Google Cloud Platform (GCP). + +## 2. Stake STRK tokens + +Register as a validator by staking STRK tokens through the Starknet staking contract. Check out the [Becoming a Validator](https://docs.starknet.io/staking/entering-staking/) guide for complete instructions. The staking process includes: + +- **Pre-approving STRK Transfer**: Allow the staking contract to lock your tokens. +- **Calling the `stake` Function**: Register operational and reward addresses, set commission rates, and enable pooling if desired. + +## 3. Finalising your validator + +Once Juno is running and your STRK tokens are staked: + +1. Monitor your validator's status via dashboards like [Voyager](https://voyager.online/). +2. Stay updated for future network requirements or configurations. + +:::info +You're now a staking validator! With your node running and tokens staked, you support Starknet's security and earn rewards. The network manages most operations, though future updates may require additional setup. +::: diff --git a/docs/sidebars.js b/docs/sidebars.js index b98fd7bacf..38e4582379 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -36,6 +36,7 @@ const sidebars = { }, ], }, + "staking-validator", "monitoring", "snapshots", "faq", diff --git a/docs/versioned_docs/version-0.12.4/_config-options.md b/docs/versioned_docs/version-0.12.4/_config-options.md new file mode 100644 index 0000000000..54e1ccd2e1 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/_config-options.md @@ -0,0 +1,52 @@ + + +| Config Option | Default Value | Description | +| - | - | - | +| `cn-core-contract-address` | | Custom network core contract address | +| `cn-feeder-url` | | Custom network feeder URL | +| `cn-gateway-url` | | Custom network gateway URL | +| `cn-l1-chain-id` | | Custom network L1 chain id | +| `cn-l2-chain-id` | | Custom network L2 chain id | +| `cn-name` | | Custom network name | +| `cn-unverifiable-range` | `[]` | Custom network range of blocks to skip hash verifications (e.g. `0,100`) | +| `colour` | `true` | Use `--colour=false` command to disable colourized outputs (ANSI Escape Codes) | +| `config` | | The YAML configuration file | +| `db-cache-size` | `1024` | Determines the amount of memory (in megabytes) allocated for caching data in the database | +| `db-max-handles` | `1024` | A soft limit on the number of open files that can be used by the DB | +| `db-path` | `juno` | Location of the database files | +| `disable-l1-verification` | `false` | Disables L1 verification since an Ethereum node is not provided | +| `eth-node` | | WebSocket endpoint of the Ethereum node. To verify the correctness of the L2 chain, Juno must connect to an Ethereum node and parse events in the Starknet contract | +| `grpc` | `false` | Enable the HTTP gRPC server on the default port | +| `grpc-host` | `localhost` | The interface on which the gRPC server will listen for requests | +| `grpc-port` | `6064` | The port on which the gRPC server will listen for requests | +| `gw-api-key` | | API key for gateway endpoints to avoid throttling | +| `gw-timeout` | `5` | Timeout for requests made to the gateway | +| `http` | `false` | Enables the HTTP RPC server on the default port and interface | +| `http-host` | `localhost` | The interface on which the HTTP RPC server will listen for requests | +| `http-port` | `6060` | The port on which the HTTP server will listen for requests | +| `log-level` | `info` | Options: trace, debug, info, warn, error | +| `max-vm-queue` | `2 * max-vms` | Maximum number for requests to queue after reaching max-vms before starting to reject incoming requests | +| `max-vms` | `3 * CPU Cores` | Maximum number for VM instances to be used for RPC calls concurrently | +| `metrics` | `false` | Enables the Prometheus metrics endpoint on the default port | +| `metrics-host` | `localhost` | The interface on which the Prometheus endpoint will listen for requests | +| `metrics-port` | `9090` | The port on which the Prometheus endpoint will listen for requests | +| `network` | `mainnet` | Options: mainnet, sepolia, sepolia-integration | +| `p2p` | `false` | EXPERIMENTAL: Enables p2p server | +| `p2p-addr` | | EXPERIMENTAL: Specify p2p listening source address as multiaddr. Example: /ip4/0.0.0.0/tcp/7777 | +| `p2p-feeder-node` | `false` | EXPERIMENTAL: Run juno as a feeder node which will only sync from feeder gateway and gossip the new blocks to the network | +| `p2p-peers` | | EXPERIMENTAL: Specify list of p2p peers split by a comma. These peers can be either Feeder or regular nodes | +| `p2p-private-key` | | EXPERIMENTAL: Hexadecimal representation of a private key on the Ed25519 elliptic curve | +| `p2p-public-addr` | | EXPERIMENTAL: Specify p2p public address as multiaddr. Example: /ip4/35.243.XXX.XXX/tcp/7777 | +| `pending-poll-interval` | `5` | Sets how frequently pending block will be updated (0s will disable fetching of pending block) | +| `plugin-path` | | Path to the plugin .so file | +| `pprof` | `false` | Enables the pprof endpoint on the default port | +| `pprof-host` | `localhost` | The interface on which the pprof HTTP server will listen for requests | +| `pprof-port` | `6062` | The port on which the pprof HTTP server will listen for requests | +| `remote-db` | | gRPC URL of a remote Juno node | +| `rpc-call-max-steps` | `4000000` | Maximum number of steps to be executed in starknet_call requests. The upper limit is 4 million steps, and any higher value will still be capped at 4 million | +| `rpc-cors-enable` | `false` | Enable CORS on RPC endpoints | +| `rpc-max-block-scan` | `18446744073709551615` | Maximum number of blocks scanned in single starknet_getEvents call | +| `versioned-constants-file` | | Use custom versioned constants from provided file | +| `ws` | `false` | Enables the WebSocket RPC server on the default port | +| `ws-host` | `localhost` | The interface on which the WebSocket RPC server will listen for requests | +| `ws-port` | `6061` | The port on which the WebSocket server will listen for requests | diff --git a/docs/versioned_docs/version-0.12.4/configuring.md b/docs/versioned_docs/version-0.12.4/configuring.md new file mode 100644 index 0000000000..f05104da4f --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/configuring.md @@ -0,0 +1,125 @@ +--- +title: Configuring Juno +--- + +# Configuring Juno :gear: + +Juno can be configured using several methods, with the following order of precedence: + +1. [Command line parameters (flags)](#command-line-params) +2. [Environment variables](#environment-variables) +3. [Configuration file](#configuration-file) + +## Command line params + +Juno can be configured directly on the command line by prefixing `--` to each option name: + +```bash +./build/juno --http --http-port 6060 --http-host 0.0.0.0 +``` + +When using Docker, append the command line parameters after the image name to configure Juno: + +```bash +docker run nethermind/juno --http --http-port 6060 --http-host 0.0.0.0 +``` + +:::tip +Command line parameters override [environment variables](#environment-variables) and [configuration file](#configuration-file). +::: + +## Environment variables + +Juno can be configured through environment variables by prefixing the variable names with `JUNO_` and using the configuration options in [SCREAMING_SNAKE_CASE](https://en.wiktionary.org/wiki/screaming_snake_case) format. + +To set the `http`, `http-port`, and `http-host` configurations, Juno should be run in this format: + +```bash +JUNO_HTTP=true JUNO_HTTP_PORT=6060 JUNO_HTTP_HOST=0.0.0.0 ./build/juno +``` + +When using Docker, start Juno using the `-e` command option: + +```bash +docker run \ + -e "JUNO_HTTP=true JUNO_HTTP_PORT=6060 JUNO_HTTP_HOST=0.0.0.0" \ + nethermind/juno +``` + +:::tip +Environment variables rank second in configuration precedence. [Command line parameters](#command-line-params) override environment variables. +::: + +## Configuration file + +Juno can be configured using a [YAML](https://en.wikipedia.org/wiki/YAML) file: + +```yaml title="Sample YAML File" showLineNumbers +log-level: info +network: mainnet +http: true +http-port: 6060 +metrics: true +metrics-port: 9090 +``` + +To run Juno with a configuration file, use the `config` option to specify the path of the configuration file: + +```bash +# Standalone binary +./build/juno --config + +# Docker container +docker run nethermind/juno --config +``` + +:::info +By default, Juno looks for the configuration file in the `$XDG_CONFIG_HOME` directory. +::: + +:::tip +Configuration file rank third in configuration precedence. [Command line parameters](#command-line-params) and [environment variables](#environment-variables) override configuration file. +::: + +## Configuration options + +To list all available command line options, you can use the `--help` parameter: + +```bash +# Standalone binary +./build/juno --help + +# Docker container +docker run nethermind/juno --help +``` + +Below is a list of all configuration options available in Juno, along with their default values and descriptions: + +```mdx-code-block +import ConfigOptions from "./_config-options.md"; + + +``` + +## Subcommands + +Juno provides several subcommands to perform specific tasks or operations. Here are the available ones: + +- `genp2pkeypair`: Generate a private key pair for p2p. +- `db`: Perform database-related operations + - `db info`: Retrieve information about the database. + - `db size`: Calculate database size information for each data type. + - `db revert`: Reverts the database to a specific block number. + +To use a subcommand, append it when running Juno: + +```bash +# Running a subcommand +./build/juno + +# Running the genp2pkeypair subcommand +./build/juno genp2pkeypair + +# Running the db info subcommand +./build/juno db info +``` diff --git a/docs/versioned_docs/version-0.12.4/faq.md b/docs/versioned_docs/version-0.12.4/faq.md new file mode 100644 index 0000000000..78828677ce --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/faq.md @@ -0,0 +1,125 @@ +--- +title: Frequently Asked Questions +--- + +# Frequently Asked Questions :question: + +
+ What is Juno? + +Juno is a Go implementation of a Starknet full-node client created by Nethermind to allow node operators to easily and reliably support the network and advance its decentralisation goals. Juno supports various node setups, from casual to production-grade indexers. + +
+ +
+ How can I run Juno? + +Check out the [Running Juno](running-juno) guide to learn the simplest and fastest ways to run a Juno node. You can also check the [Running Juno on GCP](running-on-gcp) guide to learn how to run Juno on GCP. + +
+ +
+ What are the hardware requirements for running Juno? + +We recommend running Juno with at least 4GB of RAM and 250GB of SSD storage. Check out the [Hardware Requirements](hardware-requirements) for more information. + +
+ +
+ How can I configure my Juno node? + +You can configure Juno using [command line parameters](configuring#command-line-params), [environment variables](configuring#environment-variables), and a [YAML configuration file](configuring#configuration-file). Check out the [Configuring Juno](configuring) guide to learn their usage and precedence. + +
+ +
+ How can I update my Juno node? + +Check out the [Updating Juno](updating) guide for instructions on updating your node to the latest version. + +
+ +
+ How can I interact with my Juno node? + +You can interact with a running Juno node using the [JSON-RPC](json-rpc) and [WebSocket](websocket) interfaces. + +
+ +
+ How can I monitor my Juno node? + +Juno captures metrics data using [Prometheus](https://prometheus.io), and you can visualise them using [Grafana](https://grafana.com). Check out the [Monitoring Juno](monitoring) guide to get started. + +
+ +
+ Do node operators receive any rewards, or is participation solely to support the network? + +Presently, running a node does not come with direct rewards; its primary purpose is contributing to the network's functionality and stability. However, operating a node provides valuable educational benefits and deepens your knowledge of the network's operation. + +
+ +
+ How can I view Juno logs from Docker? + +You can view logs from the Docker container using the following command: + +```bash +docker logs -f juno +``` + +
+ +
+ How can I get real-time updates of new blocks? + +The [WebSocket](websocket#subscribe-to-newly-created-blocks) interface provides a `juno_subscribeNewHeads` method that emits an event when new blocks are added to the blockchain. + +
+ +
+ Does Juno provide snapshots to sync with Starknet quickly? + +Yes, Juno provides snapshots for both the Starknet Mainnet and Sepolia networks. Check out the [Database Snapshots](snapshots) guide to get started. + +
+ +
+ How can I contribute to Juno? + +You can contribute to Juno by running a node, starring on GitHub, reporting bugs, and suggesting new features. Check out the [Contributions and Partnerships](/#contributions-and-partnerships) page for more information. + +
+ +
+ I noticed a warning in my logs saying: **Failed storing Block \{"err": "unsupported block version"\}**. How should I proceed? + +You can fix this problem by [updating to the latest version](updating) of Juno. Check for updates and install them to maintain compatibility with the latest block versions. + +
+ +
+ After updating Juno, I receive **error while migrating DB.** How should I proceed? + +This error suggests your database is corrupted, likely due to the node being interrupted during migration. This can occur if there are insufficient system resources, such as RAM, to finish the process. The only solution is to resynchronise the node from the beginning. To avoid this issue in the future, ensure your system has adequate resources and that the node remains uninterrupted during upgrades. + +
+ +
+ I receive **Error: unable to verify latest block hash; are the database and --network option compatible?** while running Juno. How should I proceed? + +To resolve this issue, ensure that the `eth-node` configuration aligns with the `network` option for the Starknet network. + +
+ +
+ I receive **process \ killed** and **./build/juno: invalid signature (code or signature have been modified)** while running the binary on macOS. How should I proceed? + +You need to re-sign the binary to resolve this issue using the following command: + +```bash +codesign --sign - ./build/juno +``` + +
diff --git a/docs/versioned_docs/version-0.12.4/hardware-requirements.md b/docs/versioned_docs/version-0.12.4/hardware-requirements.md new file mode 100644 index 0000000000..d980364051 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/hardware-requirements.md @@ -0,0 +1,23 @@ +--- +title: Hardware Requirements +--- + +# Hardware Requirements :computer: + +The following specifications outline the hardware required to run a Juno node. These specifications are categorised into minimal and recommended requirements for different usage scenarios. + +## Minimal requirements + +- **CPU**: At least 2 cores +- **RAM**: 4GB or more +- **Storage**: 250GB or more (SSD recommended; note: storage needs will grow over time) + +## Recommended requirements + +- **CPU**: High-performance CPU with 4 or more cores +- **RAM**: 8GB or more +- **Storage**: High-performance SSD with at least 250GB to accommodate future growth + +:::tip +We intend the above specifications as a guideline. The minimal requirements support basic node operations, and the recommended settings ensure optimal performance and scalability for future needs. +::: diff --git a/docs/versioned_docs/version-0.12.4/intro.md b/docs/versioned_docs/version-0.12.4/intro.md new file mode 100644 index 0000000000..e51ce1fee3 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/intro.md @@ -0,0 +1,78 @@ +--- +slug: / +title: Introduction +--- + +# Welcome to Juno :wave: + +Juno is a Go implementation of a Starknet full-node client created by Nethermind to allow node operators to easily and reliably support the network and advance its decentralisation goals. Juno supports various node setups, from casual to production-grade indexers. + +- :cd: **Small database footprint**: Approximately 182GB on mainnet. +- :zap: **Ultra-fast synchronisation**: Limited only by your hardware and the sequencer. +- :100: **Complete [JSON-RPC spec](https://github.com/starkware-libs/starknet-specs/tree/master) compliance**: Everything Starknet, accessible from a single point. +- :mag_right: **Minimal RPC response latency**: Ensuring your applications run smoothly. +- :globe_with_meridians: **Websocket interface**: For seamless real-time updates of the network. + +## Getting started + +Learn how to configure and manage your Juno node with the following resources: + +```mdx-code-block +import GuideCard from '@site/src/components/GuideCard'; + + + + + + + + +``` + +:::tip +You can access the Nethermind Starknet RPC service for free at https://data.voyager.online. +::: + +## Community and support + +Join our community for support, engaging discussions, and updates: + +- [Discord](https://discord.gg/SZkKcmmChJ): Connect in real-time with the Juno team and community. +- [X (Twitter)](https://x.com/NethermindStark): Follow for the latest news and insights from Nethermind. +- [Telegram](https://t.me/+LHRF4H8iQ3c5MDY0): Share ideas and stay informed with fellow Juno users. + +## Contributions and partnerships + +We value community contributions and are eager to support your involvement. Here’s how you can contribute: + +- :rocket: [Run a Juno node](running-juno) to strengthen the Starknet network. +- :star: Give Juno a [star on GitHub](https://github.com/NethermindEth/juno/stargazers). +- :memo: Share your thoughts on [X (Twitter)](https://twitter.com/intent/tweet?url=https%3A%2F%2Fgithub.com%2FNethermindEth%2Fjuno&via=nethermindeth&text=Juno%20is%20Awesome%2C%20they%20are%20working%20hard%20to%20bring%20decentralization%20to%20StarkNet&hashtags=StarkNet%2CJuno%2CEthereum). +- :beetle: [Report bugs](https://github.com/NethermindEth/juno/issues/new) or [suggest new features](https://github.com/NethermindEth/juno/issues/new). +- :mega: Encourage others to explore and use Juno. + +:::tip +If you're ready to make PRs but unsure where to start, join our [Discord](https://discord.gg/TcHbSZ9ATd), and we'll guide you through some beginner-friendly issues. +::: + +If you're interested in forming a partnership with the Juno team or have any suggestions or special requests, please don't hesitate to contact us via juno@nethermind.io diff --git a/docs/versioned_docs/version-0.12.4/json-rpc.md b/docs/versioned_docs/version-0.12.4/json-rpc.md new file mode 100644 index 0000000000..188c06a879 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/json-rpc.md @@ -0,0 +1,250 @@ +--- +title: JSON-RPC Interface +--- + +# JSON-RPC Interface :globe_with_meridians: + +Interacting with Juno requires sending requests to specific JSON-RPC API methods. Juno supports all of [Starknet's Node API Endpoints](https://playground.open-rpc.org/?uiSchema%5BappBar%5D%5Bui:splitView%5D=false&schemaUrl=https://raw.githubusercontent.com/starkware-libs/starknet-specs/v0.7.0/api/starknet_api_openrpc.json&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:darkMode%5D=true&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false) over HTTP and [WebSocket](websocket). + +## Enable the JSON-RPC server + +To enable the JSON-RPC interface, use the following configuration options: + +- `http`: Enables the HTTP RPC server on the default port and interface (disabled by default). +- `http-host`: The interface on which the HTTP RPC server will listen for requests. If skipped, it defaults to `localhost`. +- `http-port`: The port on which the HTTP server will listen for requests. If skipped, it defaults to `6060`. + +```bash +# Docker container +docker run -d \ + --name juno \ + -p 6060:6060 \ + nethermind/juno \ + --http \ + --http-port 6060 \ + --http-host 0.0.0.0 + +# Standalone binary +./build/juno --http --http-port 6060 --http-host 0.0.0.0 +``` + +## Making JSON-RPC requests + +You can use any of [Starknet's Node API Endpoints](https://playground.open-rpc.org/?uiSchema%5BappBar%5D%5Bui:splitView%5D=false&schemaUrl=https://raw.githubusercontent.com/starkware-libs/starknet-specs/v0.7.0/api/starknet_api_openrpc.json&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:darkMode%5D=true&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false) with Juno. Check the availability of Juno with the `juno_version` method: + +```mdx-code-block +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +``` + + + + +```json +{ + "jsonrpc": "2.0", + "method": "juno_version", + "params": [], + "id": 1 +} +``` + + + + +```bash +curl --location 'http://localhost:6060' \ +--header 'Content-Type: application/json' \ +--data '{ + "jsonrpc": "2.0", + "method": "juno_version", + "params": [], + "id": 1 +}' +``` + + + + +```json +{ + "jsonrpc": "2.0", + "result": "v0.11.7", + "id": 1 +} +``` + + + + +Get the most recent accepted block hash and number with the `starknet_blockHashAndNumber` method: + + + + +```json +{ + "jsonrpc": "2.0", + "method": "starknet_blockHashAndNumber", + "params": [], + "id": 1 +} +``` + + + + +```bash +curl --location 'http://localhost:6060' \ +--header 'Content-Type: application/json' \ +--data '{ + "jsonrpc": "2.0", + "method": "starknet_blockHashAndNumber", + "params": [], + "id": 1 +}' +``` + + + + +```js +const { RpcProvider } = require("starknet"); + +const provider = new RpcProvider({ + nodeUrl: "http://localhost:6060", +}); + +provider.getBlockLatestAccepted().then((blockHashAndNumber) => { + console.log(blockHashAndNumber); +}); +``` + + + + +```go +package main + +import ( + "context" + "fmt" + "log" + "github.com/NethermindEth/juno/core/felt" + "github.com/NethermindEth/starknet.go/rpc" + "github.com/NethermindEth/starknet.go/utils" +) + +func main() { + rpcUrl := "http://localhost:6060" + client, err := rpc.NewClient(rpcUrl) + if err != nil { + log.Fatal(err) + } + + provider := rpc.NewProvider(client) + result, err := provider.BlockHashAndNumber(context.Background()) + if err != nil { + log.Fatal(err) + } + fmt.Println("BlockHashAndNumber:", result) +} +``` + + + + +```rust +use starknet::providers::{ + jsonrpc::{HttpTransport, JsonRpcClient}, + Provider, Url, +}; + +#[tokio::main] +async fn main() { + let provider = JsonRpcClient::new(HttpTransport::new( + Url::parse("http://localhost:6060").unwrap(), + )); + + let result = provider.block_hash_and_number().await; + match result { + Ok(block_hash_and_number) => { + println!("{block_hash_and_number:#?}"); + } + Err(err) => { + eprintln!("Error: {err}"); + } + } +} +``` + + + + +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "0x637ae4d7468bb603c2f16ba7f9118d58c7d7c98a8210260372e83e7c9df443a", + "block_number": 640827 + }, + "id": 1 +} +``` + + + + +## Supported Starknet API versions + +Juno supports the following Starknet API versions: + +- **v0.7.0**: Accessible via endpoints `/v0_7`, `/rpc/v0_7`, or the default `/` +- **v0.6.0**: Accessible via endpoints `/v0_6` or `/rpc/v0_6` + +To use a specific API version, specify the version endpoint in your RPC calls: + + + + +```bash +curl --location 'http://localhost:6060' \ +--header 'Content-Type: application/json' \ +--data '{ + "jsonrpc": "2.0", + "method": "starknet_chainId", + "params": [], + "id": 1 +}' +``` + + + + +```bash +curl --location 'http://localhost:6060/v0_7' \ +--header 'Content-Type: application/json' \ +--data '{ + "jsonrpc": "2.0", + "method": "starknet_chainId", + "params": [], + "id": 1 +}' +``` + + + + +```bash +curl --location 'http://localhost:6060/v0_6' \ +--header 'Content-Type: application/json' \ +--data '{ + "jsonrpc": "2.0", + "method": "starknet_chainId", + "params": [], + "id": 1 +}' +``` + + + diff --git a/docs/versioned_docs/version-0.12.4/monitoring.md b/docs/versioned_docs/version-0.12.4/monitoring.md new file mode 100644 index 0000000000..f0abb49b35 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/monitoring.md @@ -0,0 +1,87 @@ +--- +title: Monitoring Juno +--- + +# Monitoring Juno :bar_chart: + +Juno uses [Prometheus](https://prometheus.io/) to monitor and collect metrics data, which you can visualise with [Grafana](https://grafana.com/). You can use these insights to understand what is happening when Juno is running. + +## Enable the metrics server + +To enable the metrics server, use the following configuration options: + +- `metrics`: Enables the Prometheus metrics endpoint on the default port (disabled by default). +- `metrics-host`: The interface on which the Prometheus endpoint will listen for requests. If skipped, it defaults to `localhost`. +- `metrics-port`: The port on which the Prometheus endpoint will listen for requests. If skipped, it defaults to `9090`. + +```bash +# Docker container +docker run -d \ + --name juno \ + -p 9090:9090 \ + nethermind/juno \ + --metrics \ + --metrics-port 9090 \ + --metrics-host 0.0.0.0 + +# Standalone binary +./build/juno --metrics --metrics-port 9090 --metrics-host=0.0.0.0 +``` + +## Configure Grafana dashboard + +### 1. Set up Grafana + +- Follow the [Set up Grafana](https://grafana.com/docs/grafana/latest/setup-grafana/) guide to install Grafana. +- Download and [configure](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#configuration-file-location) the [Grafana dashboard file](/juno_grafana.json). + +### 2. Set up Prometheus + +- Follow the [First steps with Prometheus](https://prometheus.io/docs/introduction/first_steps/) guide to install Prometheus. +- Add the Juno metrics endpoint in the `prometheus.yml` configuration file: + +```yaml title="prometheus.yml" showLineNumbers +scrape_configs: + - job_name: "juno" + static_configs: + - targets: ["localhost:9090"] +``` + +### 3. Set up Grafana Loki + +- Follow the [Get started with Grafana Loki](https://grafana.com/docs/loki/latest/get-started/) guide to install [Loki](https://grafana.com/oss/loki/). +- Configure Loki to [collect logs](https://grafana.com/docs/loki/latest/send-data/) from Juno. You might need to configure log paths or use [Promtail](https://grafana.com/docs/loki/latest/send-data/promtail/) (Loki's agent) to send logs to Loki: + +```yaml title="Sample Loki Configuration" showLineNumbers +scrape_configs: + - job_name: "juno-logs" + labels: + job: "juno" + __path__: "/path/to/juno/logs/*" +``` + +:::tip +To have Juno write logs to a file, use the command: + +```bash +./build/juno >> /path/juno.log 2>&1 +``` + +::: + +### 4. Configure the data sources + +1. Follow the [Grafana data sources](https://grafana.com/docs/grafana/latest/datasources/) guide to add data sources. +2. Choose **Prometheus** as a data source: + +- Enter the URL where Prometheus is running, e.g., `http://localhost:9090`. +- Click the **"Save & Test"** button. + +3. Choose **Loki** as a data source: + +- Enter the URL where Loki is running, e.g., `http://localhost:3100`. +- Click the **"Save & Test"** button. + +![Grafana dashboard](/img/grafana-1.png) + +![Grafana dashboard](/img/grafana-2.png) diff --git a/docs/versioned_docs/version-0.12.4/plugins.md b/docs/versioned_docs/version-0.12.4/plugins.md new file mode 100644 index 0000000000..816f028906 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/plugins.md @@ -0,0 +1,82 @@ +--- +title: Juno Plugins +--- + +Juno supports plugins that satisfy the `JunoPlugin` interface, enabling developers to extend and customize Juno's behaviour and functionality by dynamically loading external plugins during runtime. + +The `JunoPlugin` interface provides a structured way for plugins to interact with the blockchain by sending notifications when new blocks are added or reverted. This ensures state consistency, especially during blockchain reorganizations, while abstracting away the complexity of implementing block syncing and revert logic. + +## JunoPlugin Interface + +Your plugin must implement the `JunoPlugin` interface, which includes methods for initializing, shutting down, and handling new and reverted blocks. + +```go +type JunoPlugin interface { + Init() error + Shutdown() error + NewBlock(block *core.Block, stateUpdate *core.StateUpdate, newClasses map[felt.Felt]core.Class) error + RevertBlock(from, to *BlockAndStateUpdate, reverseStateDiff *core.StateDiff) error +} +``` + +**Init**: Called when the plugin is initialized. This can be used to set up database connections or any other necessary resources. + +**Shutdown**: Called when the Juno node is shut down. This can be used to clean up resources like database connections. + +**NewBlock**: Triggered when a new block is synced by the Juno client. Juno will send the block, the corresponding state update, and any new classes. Importantly, Juno waits for the plugin to finish processing this function call before continuing. This ensures that the plugin completes its task before Juno proceeds with the blockchain sync. + +**RevertBlock**: Called during a blockchain reorganization (reorg). Juno will invoke this method for each block that needs to be reverted. Similar to NewBlock, the client will wait for the plugin to finish handling the revert before moving on to the next block. + +## Example plugin + +Here is a basic example of a plugin that satisfies the `JunoPlugin` interface: + +```go +// go:generate go build -buildmode=plugin -o ../../build/plugin.so ./example.go +type examplePlugin string + +// Important: "JunoPluginInstance" needs to be exported for Juno to load the plugin correctly +var JunoPluginInstance examplePlugin + +var _ junoplugin.JunoPlugin = (*examplePlugin)(nil) + +func (p *examplePlugin) Init() error { + fmt.Println("ExamplePlugin initialized") + return nil +} + +func (p *examplePlugin) Shutdown() error { + fmt.Println("ExamplePlugin shutdown") + return nil +} + +func (p *examplePlugin) NewBlock(block *core.Block, stateUpdate *core.StateUpdate, newClasses map[felt.Felt]core.Class) error { + fmt.Println("ExamplePlugin NewBlock called") + return nil +} + +func (p *examplePlugin) RevertBlock(from, to *junoplugin.BlockAndStateUpdate, reverseStateDiff *core.StateDiff) error { + fmt.Println("ExamplePlugin RevertBlock called") + return nil +} +``` + +The `JunoPluginInstance` variable must be exported for Juno to correctly load the plugin: +`var JunoPluginInstance examplePlugin` + +We ensure the plugin implements the `JunoPlugin` interface, with the following line: +`var _ junoplugin.JunoPlugin = (*examplePlugin)(nil)` + +## Building and loading the plugin + +Once you have written your plugin, you can compile it into a shared object file (.so) using the following command: + +```shell +go build -buildmode=plugin -o ./plugin.so /path/to/your/plugin.go +``` + +This command compiles the plugin into a shared object file (`plugin.so`), which can then be loaded by the Juno client using the `--plugin-path` flag. + +## Running Juno with the plugin + +Once your plugin has been compiled into a `.so` file, you can run Juno with your plugin by providing the `--plugin-path` flag. This flag tells Juno where to find and load your plugin at runtime. diff --git a/docs/versioned_docs/version-0.12.4/running-juno.md b/docs/versioned_docs/version-0.12.4/running-juno.md new file mode 100644 index 0000000000..9646be8f36 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/running-juno.md @@ -0,0 +1,153 @@ +--- +title: Running Juno +--- + +# Running Juno :rocket: + +You can run a Juno node using several methods: + +- [Docker container](#docker-container) +- [Standalone binary](#standalone-binary) +- [Building from source](#building-from-source) +- [Google Cloud Platform (GCP)](running-on-gcp) + +:::tip +You can use a snapshot to quickly synchronise your node with the network. Check out the [Database Snapshots](snapshots) guide to get started. +::: + +## Docker container + +### 1. Get the Docker image + +Juno Docker images can be found at the [nethermind/juno](https://hub.docker.com/r/nethermind/juno) repository on Docker Hub. Download the latest image: + +```bash +docker pull nethermind/juno +``` + +You can also build the image locally: + +```bash +# Clone the Juno repository +git clone https://github.com/NethermindEth/juno +cd juno + +# Build the Docker image +docker build -t nethermind/juno:latest . +``` + +### 2. Run the Docker container + +```bash +# Prepare the snapshots directory +mkdir -p $HOME/snapshots + +# Run the container +docker run -d \ + --name juno \ + -p 6060:6060 \ + -v $HOME/snapshots/juno_mainnet:/snapshots/juno_mainnet \ + nethermind/juno \ + --http \ + --http-port 6060 \ + --http-host 0.0.0.0 \ + --db-path /snapshots/juno_mainnet +``` + +You can view logs from the Docker container using the following command: + +```bash +docker logs -f juno +``` + +## Standalone binary + +Download standalone binaries from [Juno's GitHub Releases](https://github.com/NethermindEth/juno/releases/latest) as ZIP archives for Linux (amd64 and arm64) and macOS (amd64). For macOS (arm64) or Windows users, consider [running Juno using Docker](#docker-container). + +```bash +# Prepare the snapshots directory +mkdir -p $HOME/snapshots + +# Run the binary +./juno \ + --http \ + --http-port 6060 \ + --http-host 0.0.0.0 \ + --db-path $HOME/snapshots/juno_mainnet +``` + +## Building from source + +You can build the Juno binary or Docker image from the source code to access the latest updates or specific versions. + +### Prerequisites + +- [Golang 1.23](https://go.dev/doc/install) or later +- [Rust](https://www.rust-lang.org/tools/install) +- C compiler: `gcc` or `clang` +- [jemalloc](https://github.com/jemalloc/jemalloc) + +```mdx-code-block +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +``` + + + + +```bash +sudo apt-get install -y libjemalloc-dev +``` + + + + +```bash +brew install jemalloc +``` + + + + +### 1. Clone the repository + +Clone Juno's source code from our [GitHub repository](https://github.com/NethermindEth/juno): + +```bash +git clone https://github.com/NethermindEth/juno +cd juno +``` + +:::tip +You can use `git tag -l` to view specific version tags. +::: + +### 2. Build the binary or Docker image + +```bash +# Build the binary +make juno + +# Build the Docker image +docker build -t nethermind/juno:latest . +``` + +### 3. Run the binary + +Locate the standalone binary in the `./build/` directory: + +```bash +# Prepare the snapshots directory +mkdir -p $HOME/snapshots + +# Run the binary +./build/juno \ + --http \ + --http-port 6060 \ + --http-host 0.0.0.0 \ + --db-path $HOME/snapshots/juno_mainnet +``` + +:::tip +To learn how to configure Juno, check out the [Configuring Juno](configuring) guide. +::: diff --git a/docs/versioned_docs/version-0.12.4/running-on-gcp.md b/docs/versioned_docs/version-0.12.4/running-on-gcp.md new file mode 100644 index 0000000000..a589526f34 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/running-on-gcp.md @@ -0,0 +1,76 @@ +--- +title: Running Juno on GCP +--- + +# Running Juno on GCP :cloud: + +To run Juno on the Google Cloud Platform (GCP), you can use the Starknet RPC Virtual Machine (VM) developed by Nethermind. + +## 1. Install the Starknet RPC Node + +Head to the [Google Marketplace](https://console.cloud.google.com/marketplace/browse?q=Starknet%20RPC%20Node) and search for **"Starknet RPC Node"**. Then, click the **"GET STARTED"** button to begin the deployment process. + +![Starknet RPC Node overview](/img/installing_on_gcp/overview.png) + +## 2. Configure the Juno client + +Choose the configuration settings for the Juno client and click the **"DEPLOY"** button. + +![Starknet RPC Node configuration](/img/installing_on_gcp/config.png) + +## 3. Post-configuration and testing + +![Starknet RPC Node testing](/img/installing_on_gcp/testing.png) + +## 4. Enable Juno during startup + +1. Click on the name of the newly created VM instance to view its details. +2. Click the **"Edit"** button. +3. Head to the **"Automation"** section and enter the following startup script: + ```bash + #! /bin/bash + sudo /usr/local/bin/run_juno.sh + ``` +4. Click the **"Save"** button. +5. Restart the VM. + +## 5. Interact with the Juno node + +You can interact with Juno using its [JSON-RPC Interface](json-rpc). Here's an example to check the availability of Juno: + +```mdx-code-block +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +``` + + + + +```bash +curl --location 'http://localhost:6060' \ +--header 'Content-Type: application/json' \ +--data '{ + "jsonrpc": "2.0", + "method": "juno_version", + "params": [], + "id": 1 +}' +``` + + + + +```json +{ + "jsonrpc": "2.0", + "result": "v0.11.7", + "id": 1 +} +``` + + + + +:::tip +To learn how to configure Juno, check out the [Configuring Juno](configuring) guide. +::: diff --git a/docs/versioned_docs/version-0.12.4/running-p2p.md b/docs/versioned_docs/version-0.12.4/running-p2p.md new file mode 100644 index 0000000000..e78ec3a557 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/running-p2p.md @@ -0,0 +1,11 @@ +--- +title: Running a Juno P2P Node +--- + +# Running a Juno P2P Node + +Juno can be run as a peer-to-peer node for decentralised data synchronisation and to enhance the resilience and reliability of the Starknet network. Check out the [Juno peer-to-peer launch](https://medium.com/nethermind-eth/junos-experimental-peer-to-peer-launch-3040e195550d) guide to learn how it works. + +:::caution +The P2P feature is currently under active development and is being tested on smaller Juno networks. As a result, syncing with non-Juno nodes may be unstable. +::: diff --git a/docs/versioned_docs/version-0.12.4/snapshots.md b/docs/versioned_docs/version-0.12.4/snapshots.md new file mode 100644 index 0000000000..9feb3769f7 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/snapshots.md @@ -0,0 +1,88 @@ +--- +title: Database Snapshots +--- + +# Database Snapshots :camera_flash: + +You can download a snapshot of the Juno database to reduce the network syncing time. Only the blocks created after the snapshot will be synced when you run the node. + +## Mainnet + +| Version | Download Link | +| ------- | ------------- | +| **>=v0.9.2** | [**juno_mainnet.tar**](https://juno-snapshots.nethermind.dev/files/mainnet/latest) | + +## Sepolia + +| Version | Download Link | +| ------- | ------------- | +| **>=v0.9.2** | [**juno_sepolia.tar**](https://juno-snapshots.nethermind.dev/files/sepolia/latest) | + +## Sepolia-Integration + +| Version | Download Link | +| ------- | ------------- | +| **>=v0.9.2** | [**juno_sepolia_integration.tar**](https://juno-snapshots.nethermind.dev/files/sepolia-integration/latest) | + +## Getting snapshot sizes + +```console +$date +Thu 1 Aug 2024 09:49:30 BST + +$curl -s -I -L https://juno-snapshots.nethermind.dev/files/mainnet/latest | gawk -v IGNORECASE=1 '/^Content-Length/ { printf "%.2f GB\n", $2/1024/1024/1024 }' +172.47 GB + +$curl -s -I -L https://juno-snapshots.nethermind.dev/files/sepolia/latest | gawk -v IGNORECASE=1 '/^Content-Length/ { printf "%.2f GB\n", $2/1024/1024/1024 }' +5.67 GB + +$curl -s -I -L https://juno-snapshots.nethermind.dev/files/sepolia-integration/latest | gawk -v IGNORECASE=1 '/^Content-Length/ { printf "%.2f GB\n", $2/1024/1024/1024 }' +2.4 GB +``` + +## Run Juno with a snapshot + +### 1. Download the snapshot + +First, download a snapshot from one of the provided URLs: + +```bash +wget -O juno_mainnet.tar https://juno-snapshots.nethermind.dev/files/mainnet/latest +``` + +### 2. Prepare a directory + +Ensure you have a directory to store the snapshots. We will use the `$HOME/snapshots` directory: + +```bash +mkdir -p $HOME/snapshots +``` + +### 3. Extract the snapshot + +Extract the contents of the downloaded `.tar` file into the directory: + +```bash +tar -xvf juno_mainnet.tar -C $HOME/snapshots +``` + +### 4. Run Juno + +Run the Docker command to start Juno and provide the path to the snapshot using the `db-path` option: + +```bash +docker run -d \ + --name juno \ + -p 6060:6060 \ + -v $HOME/snapshots/juno_mainnet:/snapshots/juno_mainnet \ + nethermind/juno \ + --http \ + --http-port 6060 \ + --http-host 0.0.0.0 \ + --db-path /snapshots/juno_mainnet + --eth-node +``` + +:::info +Replace \ with the WebSocket endpoint of your Ethereum node. For Infura users, your address should be: `wss://mainnet.infura.io/ws/v3/your-infura-project-id`. Ensure you use the WebSocket URL (`ws`/`wss`) instead of the HTTP URL (`http`/`https`). +::: diff --git a/docs/versioned_docs/version-0.12.4/staking-validator.md b/docs/versioned_docs/version-0.12.4/staking-validator.md new file mode 100644 index 0000000000..92520cfbdb --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/staking-validator.md @@ -0,0 +1,32 @@ +# Become a Staking Validator + +Staking on Starknet provides an opportunity to contribute to network security and earn rewards by becoming a validator. Check out the [Becoming a Validator](https://docs.starknet.io/staking/entering-staking/) guide to learn more about the validator process. + +## Prerequisites + +- **STRK Tokens**: At least 20,000 STRK is required for staking. For the latest details, check out the [Staking Protocol Details](https://docs.starknet.io/staking/overview/#protocol_details). +- **Node Setup**: The [latest version of Juno](updating) installed and running on your machine. +- **Starknet Wallet**: A compatible wallet, like [Braavos](https://braavos.app/wallet-features/ledger-on-braavos/) or [Argent](https://www.argent.xyz/blog/how-to-use-your-hardware-wallet-with-argent). +- **Access to CLI/Block Explorer**: Tools like [Voyager](https://voyager.online) for interacting with contracts. + +## 1. Set up Juno + +Juno is a reliable choice for running a Starknet node. Follow the [Running Juno](running-juno) guide to configure Juno using Docker, binaries, source builds, or Google Cloud Platform (GCP). + +## 2. Stake STRK tokens + +Register as a validator by staking STRK tokens through the Starknet staking contract. Check out the [Becoming a Validator](https://docs.starknet.io/staking/entering-staking/) guide for complete instructions. The staking process includes: + +- **Pre-approving STRK Transfer**: Allow the staking contract to lock your tokens. +- **Calling the `stake` Function**: Register operational and reward addresses, set commission rates, and enable pooling if desired. + +## 3. Finalising your validator + +Once Juno is running and your STRK tokens are staked: + +1. Monitor your validator's status via dashboards like [Voyager](https://voyager.online/). +2. Stay updated for future network requirements or configurations. + +:::info +You're now a staking validator! With your node running and tokens staked, you support Starknet's security and earn rewards. The network manages most operations, though future updates may require additional setup. +::: diff --git a/docs/versioned_docs/version-0.12.4/updating.md b/docs/versioned_docs/version-0.12.4/updating.md new file mode 100644 index 0000000000..54f449e351 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/updating.md @@ -0,0 +1,88 @@ +--- +title: Updating Juno +--- + +# Updating Juno :arrows_counterclockwise: + +It is important to run the latest version of Juno as each update brings new features, security patches, and improvements over previous versions. Follow these steps to update Juno: + +- [Docker container](#docker-container) +- [Standalone binary](#standalone-binary) +- [Updating from source](#updating-from-source) + +:::info +When running an updated node, use the same `db-path` as before to avoid restarting the sync and use the already synced database. +::: + +## Docker container + +### 1. Get the latest Docker image + +Download the latest Juno Docker image from the [nethermind/juno](https://hub.docker.com/r/nethermind/juno) repository: + +```bash +docker pull nethermind/juno:latest +``` + +### 2. Stop and remove the current Juno container + +Stop the currently running Juno container. If you're unsure of the container name, use `docker ps` to view all running containers: + +```bash +docker stop juno +``` + +Remove the old container to prevent any conflicts with the new version: + +```bash +docker rm juno +``` + +### 3. Start a new container with the updated image + +Run a new container using the updated Docker image: + +```bash +# Prepare the snapshots directory +mkdir -p $HOME/snapshots + +# Run the container +docker run -d \ + --name juno \ + -p 6060:6060 \ + -v $HOME/snapshots/juno_mainnet:/snapshots/juno_mainnet \ + nethermind/juno \ + --http \ + --http-port 6060 \ + --http-host 0.0.0.0 \ + --db-path /snapshots/juno_mainnet +``` + +Verify that the node is running correctly with the updated version: + +```bash +docker logs juno +``` + +## Standalone binary + +Download the latest binary from the [Juno GitHub Releases](https://github.com/NethermindEth/juno/releases/latest) page and replace the existing one. + +## Updating from source + +```bash +# Pull the latest updates to the codebase +git pull + +# Rebuild the binary +make juno + +# OR + +# Rebuild the Docker image +docker build -t nethermind/juno:latest . +``` + +:::tip +To learn how to configure Juno, check out the [Configuring Juno](configuring) guide. +::: diff --git a/docs/versioned_docs/version-0.12.4/websocket.md b/docs/versioned_docs/version-0.12.4/websocket.md new file mode 100644 index 0000000000..ba55e24db8 --- /dev/null +++ b/docs/versioned_docs/version-0.12.4/websocket.md @@ -0,0 +1,207 @@ +--- +title: WebSocket Interface +--- + +# WebSocket Interface :globe_with_meridians: + +Juno provides a WebSocket RPC interface that supports all of [Starknet's JSON-RPC API](https://playground.open-rpc.org/?uiSchema%5BappBar%5D%5Bui:splitView%5D=false&schemaUrl=https://raw.githubusercontent.com/starkware-libs/starknet-specs/v0.7.0/api/starknet_api_openrpc.json&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:darkMode%5D=true&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false) endpoints and allows you to [subscribe to newly created blocks](#subscribe-to-newly-created-blocks). + +## Enable the WebSocket server + +To enable the WebSocket RPC server, use the following configuration options: + +- `ws`: Enables the Websocket RPC server on the default port (disabled by default). +- `ws-host`: The interface on which the Websocket RPC server will listen for requests. If skipped, it defaults to `localhost`. +- `ws-port`: The port on which the WebSocket server will listen for requests. If skipped, it defaults to `6061`. + +```bash +# Docker container +docker run -d \ + --name juno \ + -p 6061:6061 \ + nethermind/juno \ + --ws \ + --ws-port 6061 \ + --ws-host 0.0.0.0 + +# Standalone binary +./build/juno --ws --ws-port 6061 --ws-host 0.0.0.0 +``` + +## Making WebSocket requests + +You can use any of [Starknet's Node API Endpoints](https://playground.open-rpc.org/?uiSchema%5BappBar%5D%5Bui:splitView%5D=false&schemaUrl=https://raw.githubusercontent.com/starkware-libs/starknet-specs/v0.7.0/api/starknet_api_openrpc.json&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:darkMode%5D=true&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false) with Juno. Check the availability of Juno with the `juno_version` method: + +```mdx-code-block +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +``` + + + + +```json +{ + "jsonrpc": "2.0", + "method": "juno_version", + "params": [], + "id": 1 +} +``` + + + + +```json +{ + "jsonrpc": "2.0", + "result": "v0.11.7", + "id": 1 +} +``` + + + + +Get the most recent accepted block hash and number with the `starknet_blockHashAndNumber` method: + + + + +```json +{ + "jsonrpc": "2.0", + "method": "starknet_blockHashAndNumber", + "params": [], + "id": 1 +} +``` + + + + +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "0x637ae4d7468bb603c2f16ba7f9118d58c7d7c98a8210260372e83e7c9df443a", + "block_number": 640827 + }, + "id": 1 +} +``` + + + + +## Subscribe to newly created blocks + +The WebSocket server provides a `juno_subscribeNewHeads` method that emits an event when new blocks are added to the blockchain: + + + + +```json +{ + "jsonrpc": "2.0", + "method": "juno_subscribeNewHeads", + "params": [], + "id": 1 +} +``` + + + + +```json +{ + "jsonrpc": "2.0", + "result": 16570962336122680234, + "id": 1 +} +``` + + + + +When a new block is added, you will receive a message like this: + +```json +{ + "jsonrpc": "2.0", + "method": "juno_subscribeNewHeads", + "params": { + "result": { + "block_hash": "0x840660a07a17ae6a55d39fb6d366698ecda11e02280ca3e9ca4b4f1bad741c", + "parent_hash": "0x529ca67a127e4f40f3ae637fc54c7a56c853b2e085011c64364911af74c9a5c", + "block_number": 65644, + "new_root": "0x4e88ddf34b52091611b34d72849e230d329902888eb57c8e3c1b9cc180a426c", + "timestamp": 1715451809, + "sequencer_address": "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8", + "l1_gas_price": { + "price_in_fri": "0x3727bcc63f1", + "price_in_wei": "0x5f438c77" + }, + "l1_data_gas_price": { + "price_in_fri": "0x230e40e8866c6e", + "price_in_wei": "0x3c8c4a9ea51" + }, + "l1_da_mode": "BLOB", + "starknet_version": "0.13.1.1" + }, + "subscription": 16570962336122680234 + } +} +``` + +## Unsubscribe from newly created blocks + +Use the `juno_unsubscribe` method with the `result` value from the subscription response or the `subscription` field from any new block event to stop receiving updates for new blocks: + + + + +```json +{ + "jsonrpc": "2.0", + "method": "juno_unsubscribe", + "params": { + "id": 16570962336122680234 + }, + "id": 1 +} +``` + + + + +```json +{ + "jsonrpc": "2.0", + "result": true, + "id": 1 +} +``` + + + + +## Testing the WebSocket connection + +You can test your WebSocket connection using tools like [wscat](https://github.com/websockets/wscat) or [websocat](https://github.com/vi/websocat): + +```bash +# wscat +$ wscat -c ws://localhost:6061 + > {"jsonrpc": "2.0", "method": "juno_version", "id": 1} + < {"jsonrpc": "2.0", "result": "v0.11.7", "id": 1} + +# websocat +$ websocat -v ws://localhost:6061 + [INFO websocat::lints] Auto-inserting the line mode + [INFO websocat::stdio_threaded_peer] get_stdio_peer (threaded) + [INFO websocat::ws_client_peer] get_ws_client_peer + [INFO websocat::ws_client_peer] Connected to ws + {"jsonrpc": "2.0", "method": "juno_version", "id": 1} + {"jsonrpc": "2.0", "result": "v0.11.7", "id": 1} +``` diff --git a/docs/versioned_docs/version-0.6.3/example_config.md b/docs/versioned_docs/version-0.6.3/example_config.md deleted file mode 100644 index 45c20163e8..0000000000 --- a/docs/versioned_docs/version-0.6.3/example_config.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -slug: /config -sidebar_position: 3 -title: Example Configuration ---- - -The Juno binary uses reasonable defaults and can be used without configuration. -For basic fine-tuning, the `--db-path` and `--http-port` options are usually sufficient. - -All available options are in the YAML file below with their default values. -Provide the config using the `--config ` option (Juno looks in `$XDG_CONFIG_HOME` by default). - -Juno can also be configured using command line params by prepending `--` to the option name (e.g., `--log-level info`). -Command line params override values in the configuration file. - -```yaml -# Enable colored logs -colour: true - -# Path to the database. -# Juno uses `$XDG_DATA_HOME/juno` by default, which is usually something like the value below on Linux. -db-path: /home//.local/share/juno - -# Websocket endpoint of the Ethereum node used to verify the L2 chain. -# If using Infura, it looks something like `wss://mainnet.infura.io/ws/v3/your-infura-project-id` -eth-node: "" - -# Enables the HTTP RPC server. -http: false -# Interface on which the HTTP RPC server will listen for requests. -http-host: localhost -# Port on which the HTTP RPC server will listen for requests. -http-port: 6060 - -# The options below are similar to the HTTP RPC options above. -ws: false # Websocket RPC server -ws-host: localhost -ws-port: 6061 -pprof: false -pprof-host: localhost -pprof-port: 6062 -metrics: false -metrics-host: localhost -metrics-port: 9090 -grpc: false -grpc-host: localhost -grpc-port: 6064 - -# Options: debug, info, warn, error -log-level: info - -# Options: mainnet, goerli, goerli2, integration -network: mainnet - -# How often to fetch the pending block when synced to the head of the chain. -# Provide a duration like 5s (five seconds) or 10m (10 minutes). -# Disabled by default. -pending-poll-interval: 0s - -# Experimental p2p options; there is currently no standardized Starknet p2p testnet. -p2p: false # Enable the p2p server -p2p-addr: "" # Source address -p2p-boot-peers: "" # Boot nodes -``` \ No newline at end of file diff --git a/docs/versioned_docs/version-0.6.3/intro.md b/docs/versioned_docs/version-0.6.3/intro.md deleted file mode 100644 index 381e96b0d2..0000000000 --- a/docs/versioned_docs/version-0.6.3/intro.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -slug: / -sidebar_position: 1 -title: Quick Start ---- - -*Juno is your fast and featureful Starknet client implementation.* - -Suitable for casual setups, production-grade indexers, and everything in between. - -- :floppy_disk: **Tiny database size**: ~71Gb on mainnet -- :zap: **Blazing fast sync**: constrained only by hardware and the sequencer -- :100: **100% [JSON-RPC spec](https://github.com/starkware-libs/starknet-specs/tree/master) compliance**: all things Starknet, in one place -- :racing_car: **Minimal RPC response latency**: to keep your applications moving -- :mag_right: **Low-level GRPC database API**: for the most demanding workloads - -# Sync Starknet in Two Commands - -```shell -# Juno's database directory. Can be any directory on the machine. -mkdir -p junodb - -# Juno's HTTP server listens on port 6060. -docker run -d --name juno -p 6060:6060 -v junodb:/var/lib/juno nethermind/juno:latest --db-path /var/lib/juno --http -``` - -For a complete list of options and their explanations, see the [Example Configuration](config) or run: - -```shell -docker run nethermind/juno --help -``` - -# Looking for a Starknet RPC Provider? - -If you are looking for a Starknet RPC provider, Nethermind will offer a Starknet RPC service before the upcoming feeder gateway deprecation. You can register your interest on [this Google Form](https://docs.google.com/forms/d/e/1FAIpQLSf2Bl4fc9-38E-fpWf0tnMWc3jSeOFkpjSPMN_j1en1WmEgKg/viewform?usp=sf_link). - -# Questions, Discussions, Community - -Find active Juno team members and users in the following places. - -- [GitHub](https://github.com/NethermindEth/juno) -- [Discord](https://discord.gg/SZkKcmmChJ) -- [Telegram](https://t.me/+LHRF4H8iQ3c5MDY0) \ No newline at end of file diff --git a/docs/versioned_docs/version-0.6.3/snapshots.md b/docs/versioned_docs/version-0.6.3/snapshots.md deleted file mode 100644 index acda6227d5..0000000000 --- a/docs/versioned_docs/version-0.6.3/snapshots.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -slug: /snapshots -sidebar_position: 4 -title: Database Snapshots ---- - -To decrease sync times, users may opt to download a Juno database snapshot. -After downloading a snapshot and starting a Juno node, only recent blocks must be synced. - -## Mainnet - -| Version | Size | Block | Download Link | -| ------- | ---- | ----- | ------------- | -| **>=v0.6.0** | **76 GB** | **247401** | [**juno_mainnet_247401.tar**](https://juno-snapshots.nethermind.dev/mainnet/juno_mainnet_v0.6.3_247401.tar) | - -## Goerli - -| Version | Size | Block | Download Link | -| ------- | ---- | ----- | ------------- | -| **>=v0.6.0** | **36 GB** | **850192** | [**juno_goerli_850192.tar**](https://juno-snapshots.nethermind.dev/goerli/juno_goerli_v0.6.0_850192.tar) | - -## Goerli2 - -| Version | Size | Block | Download Link | -| ------- | ---- | ----- | ------------- | -| **>=v0.6.0** | **4.6 GB** | **139043** | [**juno_goerli2_135973.tar**](https://juno-snapshots.nethermind.dev/goerli2/juno_goerli2_v0.6.0_139043.tar) | - -## Run Juno Using Snapshot - -1. **Download Snapshot** - - Fetch a snapshot from one of the provided URLs: - - ```bash - curl -o juno_mainnet_247401.tar https://juno-snapshots.nethermind.dev/mainnet/juno_mainnet_v0.6.3_247401.tar - ``` - -2. **Prepare Directory** - - Ensure you have a directory where you will store the snapshots. We will use `$HOME/snapshots`. - - ```bash - mkdir -p $HOME/snapshots - ``` - -3. **Extract Tarball** - - Extract the contents of the `.tar` file: - - ```bash - tar -xvf juno_mainnet_247401.tar -C $HOME/snapshots - ``` - -4. **Run Juno** - - Execute the Docker command to run Juno, ensuring that you're using the correct snapshot path `$HOME/snapshots/juno_mainnet`: - - ```bash - docker run -d \ - --name juno \ - -p 6060:6060 \ - -v $HOME/snapshots/juno_mainnet:/var/lib/juno \ - nethermind/juno \ - --http \ - --http-port 6060 \ - --http-host 0.0.0.0 \ - --db-path /var/lib/juno - ``` - -After following these steps, Juno should be up and running on your machine, utilizing the provided snapshot. diff --git a/docs/versioned_docs/version-0.7.0/example_config.md b/docs/versioned_docs/version-0.7.0/example_config.md deleted file mode 100644 index 45c20163e8..0000000000 --- a/docs/versioned_docs/version-0.7.0/example_config.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -slug: /config -sidebar_position: 3 -title: Example Configuration ---- - -The Juno binary uses reasonable defaults and can be used without configuration. -For basic fine-tuning, the `--db-path` and `--http-port` options are usually sufficient. - -All available options are in the YAML file below with their default values. -Provide the config using the `--config ` option (Juno looks in `$XDG_CONFIG_HOME` by default). - -Juno can also be configured using command line params by prepending `--` to the option name (e.g., `--log-level info`). -Command line params override values in the configuration file. - -```yaml -# Enable colored logs -colour: true - -# Path to the database. -# Juno uses `$XDG_DATA_HOME/juno` by default, which is usually something like the value below on Linux. -db-path: /home//.local/share/juno - -# Websocket endpoint of the Ethereum node used to verify the L2 chain. -# If using Infura, it looks something like `wss://mainnet.infura.io/ws/v3/your-infura-project-id` -eth-node: "" - -# Enables the HTTP RPC server. -http: false -# Interface on which the HTTP RPC server will listen for requests. -http-host: localhost -# Port on which the HTTP RPC server will listen for requests. -http-port: 6060 - -# The options below are similar to the HTTP RPC options above. -ws: false # Websocket RPC server -ws-host: localhost -ws-port: 6061 -pprof: false -pprof-host: localhost -pprof-port: 6062 -metrics: false -metrics-host: localhost -metrics-port: 9090 -grpc: false -grpc-host: localhost -grpc-port: 6064 - -# Options: debug, info, warn, error -log-level: info - -# Options: mainnet, goerli, goerli2, integration -network: mainnet - -# How often to fetch the pending block when synced to the head of the chain. -# Provide a duration like 5s (five seconds) or 10m (10 minutes). -# Disabled by default. -pending-poll-interval: 0s - -# Experimental p2p options; there is currently no standardized Starknet p2p testnet. -p2p: false # Enable the p2p server -p2p-addr: "" # Source address -p2p-boot-peers: "" # Boot nodes -``` \ No newline at end of file diff --git a/docs/versioned_docs/version-0.7.0/intro.md b/docs/versioned_docs/version-0.7.0/intro.md deleted file mode 100644 index d14770cf1d..0000000000 --- a/docs/versioned_docs/version-0.7.0/intro.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -slug: / -sidebar_position: 1 -title: Quick Start ---- - -*Juno is your fast and featureful Starknet client implementation.* - -Suitable for casual setups, production-grade indexers, and everything in between. - -- :floppy_disk: **Tiny database size**: ~91Gb on mainnet -- :zap: **Blazing fast sync**: constrained only by hardware and the sequencer -- :100: **100% [JSON-RPC spec](https://github.com/starkware-libs/starknet-specs/tree/master) compliance**: all things Starknet, in one place -- :racing_car: **Minimal RPC response latency**: to keep your applications moving -- :mag_right: **Low-level GRPC database API**: for the most demanding workloads - -# Sync Starknet in Two Commands - -```shell -# Juno's database directory. Can be any directory on the machine. -mkdir -p junodb - -# Juno's HTTP server listens on port 6060. -docker run -d --name juno -p 6060:6060 -v junodb:/var/lib/juno nethermind/juno:latest --db-path /var/lib/juno --http --http-host 0.0.0.0 -``` - -For a complete list of options and their explanations, see the [Example Configuration](config) or run: - -```shell -docker run nethermind/juno --help -``` - -# Juno is compatible with the following Starknet API versions: - -- **v0.5.0** (Endpoint: `/v0_5`) -- **v0.4.0** (Endpoint: `/v0_4`) - -To interact with a specific API version, you can specify the version endpoint in your RPC calls. For example: - -```shell -curl -X POST http://localhost:6060/v0_5 -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"juno_version","id":1}' -``` - -# Looking for a Starknet RPC Provider? - -Access Nethermind's Starknet RPC service for free at [data.voyager.online](https://data.voyager.online). - -# Questions, Discussions, Community - -Find active Juno team members and users in the following places. - -- [GitHub](https://github.com/NethermindEth/juno) -- [Discord](https://discord.gg/SZkKcmmChJ) -- [Telegram](https://t.me/+LHRF4H8iQ3c5MDY0) diff --git a/docs/versioned_docs/version-0.7.0/snapshots.md b/docs/versioned_docs/version-0.7.0/snapshots.md deleted file mode 100644 index ed1258fa58..0000000000 --- a/docs/versioned_docs/version-0.7.0/snapshots.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -slug: /snapshots -sidebar_position: 4 -title: Database Snapshots ---- - -To decrease sync times, users may opt to download a Juno database snapshot. -After downloading a snapshot and starting a Juno node, only recent blocks must be synced. - -## Mainnet - -| Version | Size | Block | Download Link | -| ------- | ---- | ----- | ------------- | -| **>=v0.6.0** | **92 GB** | **313975** | [**juno_mainnet_313975.tar**](https://juno-snapshots.nethermind.dev/mainnet/juno_mainnet_v0.6.5_313975.tar) | - -## Goerli - -| Version | Size | Block | Download Link | -| ------- | ---- | ----- | ------------- | -| **>=v0.6.0** | **36 GB** | **850192** | [**juno_goerli_850192.tar**](https://juno-snapshots.nethermind.dev/goerli/juno_goerli_v0.6.0_850192.tar) | - -## Goerli2 - -| Version | Size | Block | Download Link | -| ------- | ---- | ----- | ------------- | -| **>=v0.6.0** | **4.6 GB** | **139043** | [**juno_goerli2_135973.tar**](https://juno-snapshots.nethermind.dev/goerli2/juno_goerli2_v0.6.0_139043.tar) | - -## Run Juno Using Snapshot - -1. **Download Snapshot** - - Fetch a snapshot from one of the provided URLs: - - ```bash - wget -O juno_mainnet_313975.tar https://juno-snapshots.nethermind.dev/mainnet/juno_mainnet_v0.6.5_313975.tar - ``` - -2. **Prepare Directory** - - Ensure you have a directory where you will store the snapshots. We will use `$HOME/snapshots`. - - ```bash - mkdir -p $HOME/snapshots - ``` - -3. **Extract Tarball** - - Extract the contents of the `.tar` file: - - ```bash - tar -xvf juno_mainnet_313975.tar -C $HOME/snapshots - ``` - -4. **Run Juno** - - Execute the Docker command to run Juno, ensuring that you're using the correct snapshot path `$HOME/snapshots/juno_mainnet`: - - ```bash - docker run -d \ - --name juno \ - -p 6060:6060 \ - -v $HOME/snapshots/juno_mainnet:/var/lib/juno \ - nethermind/juno \ - --http \ - --http-port 6060 \ - --http-host 0.0.0.0 \ - --db-path /var/lib/juno - ``` - -After following these steps, Juno should be up and running on your machine, utilizing the provided snapshot. diff --git a/docs/versioned_sidebars/version-0.12.4-sidebars.json b/docs/versioned_sidebars/version-0.12.4-sidebars.json new file mode 100644 index 0000000000..77abeb11f2 --- /dev/null +++ b/docs/versioned_sidebars/version-0.12.4-sidebars.json @@ -0,0 +1,39 @@ +{ + "main": [ + "intro", + { + "type": "category", + "label": "Installation and Setup", + "collapsed": false, + "items": [ + "hardware-requirements", + "running-juno", + "configuring", + "plugins", + "running-on-gcp", + "updating" + ] + }, + { + "type": "category", + "label": "Interacting with Juno", + "collapsed": false, + "items": [ + "json-rpc", + "websocket", + { + "type": "html", + "value": "Starknet Node API Endpoints " + }, + { + "type": "html", + "value": "Starknet RPC Request Builder " + } + ] + }, + "staking-validator", + "monitoring", + "snapshots", + "faq" + ] +} diff --git a/docs/versioned_sidebars/version-0.6.3-sidebars.json b/docs/versioned_sidebars/version-0.6.3-sidebars.json deleted file mode 100644 index 1c5d5e44ea..0000000000 --- a/docs/versioned_sidebars/version-0.6.3-sidebars.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "main": [ - { - "type": "autogenerated", - "dirName": "." - } - ] -} diff --git a/docs/versioned_sidebars/version-0.7.0-sidebars.json b/docs/versioned_sidebars/version-0.7.0-sidebars.json deleted file mode 100644 index 1c5d5e44ea..0000000000 --- a/docs/versioned_sidebars/version-0.7.0-sidebars.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "main": [ - { - "type": "autogenerated", - "dirName": "." - } - ] -} diff --git a/docs/versions.json b/docs/versions.json index f27ac452b6..5baeaa4f10 100644 --- a/docs/versions.json +++ b/docs/versions.json @@ -1 +1 @@ -["0.11.8", "0.11.0", "0.9.3", "0.8.0", "0.7.0", "0.6.3"] +["0.12.4", "0.11.8", "0.11.0", "0.9.3", "0.8.0"]