Skip to content

Commit

Permalink
docs: running papyrus using p2p sync (#339)
Browse files Browse the repository at this point in the history
* docs: running papyrus using p2p sync

* docs: fix CR comments
  • Loading branch information
AlonLStarkWare authored Aug 21, 2024
1 parent c38f31c commit ac0ea24
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions docs/papyrus/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <bootstrap_node_address>`.
.. 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 <ethereum_node_url> \
--network.secret_key <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 <ethereum_node_url> \
--network.bootstrap_peer_multiaddr.#is_none false \
--network.bootstrap_peer_multiaddr /ip4/<other_peer_ip_address>/tcp/<tcp_port>/p2p/<peer_id>
----

==== P2P Sync (with bootstrap connection)
[source, bash]
----
cargo run --release --package papyrus_node --bin papyrus_node -- \
--base_layer.node_url <ethereum_node_url> \
--network.bootstrap_peer_multiaddr.#is_none false \
--network.bootstrap_peer_multiaddr /ip4/<other_peer_ip_address>/tcp/<tcp_port>/p2p/<peer_id> \
--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/<starknet-rpc-version-id>`.
Expand Down

0 comments on commit ac0ea24

Please sign in to comment.