From ac0ea24532f0037e796bfb1b65a8fe7a38ee566a Mon Sep 17 00:00:00 2001 From: Alon-Lukatch-Starkware Date: Wed, 21 Aug 2024 14:53:13 +0300 Subject: [PATCH] docs: running papyrus using p2p sync (#339) * docs: running papyrus using p2p sync * docs: fix CR comments --- docs/papyrus/README.adoc | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/docs/papyrus/README.adoc b/docs/papyrus/README.adoc index bc35124b7b..07474f0986 100644 --- a/docs/papyrus/README.adoc +++ b/docs/papyrus/README.adoc @@ -225,6 +225,61 @@ docker run --rm --name papyrus\ For more information, see https://docs.docker.com/config/containers/resource_constraints/#limit-a-containers-access-to-memory[Limit a container's access to memory] in the Docker documentation. +=== Running Papyrus using p2p sync + +.For this configuration, we will use the following flags: +. `--network.#is_none false` will turn on the p2p networking component for this node and allow it to serve incoming requests. +. `--sync.#is_none true` will turn off central syncing. +. `--p2p_sync.#is_none false` will turn on p2p syncing, meaning the node will make sync requests to other connected nodes. +. A pair of flags `--bootstrap_peer_multiaddr` and `--bootstrap_peer_multiaddr.#is_none` are used to inform the node of some other node that exists in the network, from which your node will discover other peers in the network. +.. As a non-bootstrap node, you need to set `--bootstrap_peer_multiaddr.#is_none false` and provide an address to a bootstrap node in `--bootstrap_peer_multiaddr `. +.. As a bootstrap node, you should not set values for these flags. + +* it is usually custom to have a single or few bootstrap nodes in the network with predetermined addresses and have new nodes join the network using them. + +.Here are three examples of running p2p nodes with various configurations: +1. Boostrap node without sync - can be used by other nodes for discovery but not for syncing. +2. Syncing from central gateway, and connected to bootstrap peer. +3. Syncing using p2p and connected to bootstrap peer (it will discover 2 and sync from it). + +==== Boostrap node without sync +[source, bash] +---- +cargo run --release --package papyrus_node --bin papyrus_node -- \ + --base_layer.node_url \ + --network.secret_key \ + --sync.#is_none true +---- + +==== Central Sync (with bootstrap connection) +[source, bash] +---- +cargo run --release --package papyrus_node --bin papyrus_node -- \ + --base_layer.node_url \ + --network.bootstrap_peer_multiaddr.#is_none false \ + --network.bootstrap_peer_multiaddr /ip4//tcp//p2p/ +---- + +==== P2P Sync (with bootstrap connection) +[source, bash] +---- +cargo run --release --package papyrus_node --bin papyrus_node -- \ + --base_layer.node_url \ + --network.bootstrap_peer_multiaddr.#is_none false \ + --network.bootstrap_peer_multiaddr /ip4//tcp//p2p/ \ + --sync.#is_none true \ + --p2p_sync.#is_none false +---- + +[NOTE] +==== +.In case you are running more than one node on the same machine, notice you will have to specify the following fields (to avoid collisions): +* network.tcp_port +* monitoring_gateway.server_address +* rpc.server_address +* storage.db_config.path_prefix +==== + == Sending API requests to the node When sending API requests, send them to the path `/rpc/`.