Skip to content

Commit 435107b

Browse files
Mechanix97tomip01mpaulucci
authored
docs(p2p): Update network docs (#2613)
**Motivation** The network example was outdated and it was not working **Description** Modified the commands to use diferents datadirs in order to generate distincts node_id <!-- Link to issues: Resolves #111, Resolves #222 --> Closes #2608 --------- Co-authored-by: Tomás Paradelo <112426153+tomip01@users.noreply.github.com> Co-authored-by: Martin Paulucci <martin.c.paulucci@gmail.com>
1 parent af8f6ec commit 435107b

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

crates/networking/docs/Network.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,43 @@ Finally, here is an example of how you could build a network and see how they co
103103
We'll have three nodes: `a`, `b`, and `c`, we'll start `a`, then `b` setting `a` as a bootnode, and finally we'll start `c` with `b` as bootnode we should see that `c` connects to both `a` and `b` and so all the network should be connected.
104104

105105
**node a**:
106-
`cargo run --bin ethrex --network test_data/kurtosis.json`
106+
```bash
107+
cargo run --bin ethrex -- --network test_data/genesis-kurtosis.json
108+
```
107109

108-
We get the `enode` by querying the node_info:
109-
`curl http://localhost:8545 \
110-
-X POST \
111-
-H "Content-Type: application/json" \
112-
--data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}'`
110+
We get the `enode` by querying the node_info and using jq:
111+
```bash
112+
curl -s http://localhost:8545 \
113+
-X POST \
114+
-H "Content-Type: application/json" \
115+
--data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' \
116+
| jq '.result.enode'
117+
```
113118

114119
**node b**
115-
We start a new server passing the `node_a` `enode` as bootnodes
120+
121+
We start a new server passing the enode from node `a` as an argument. Also changing the database dir and the ports is needed to avoid conflicts.
116122

117123
```bash
118-
cargo run --bin ethrex --network ./test_data/kurtosis.json --bootnodes=`NODE_A_ENODE` \
119-
--authrpc.port=8552 --http.port=8546 --p2p.port=30305 --discovery.port=3036
124+
cargo run --bin ethrex -- --network ./test_data/genesis-kurtosis.json --bootnodes=`NODE_A_ENODE` \
125+
--datadir=ethrex_b --authrpc.port=8552 --http.port=8546 --p2p.port=30305 --discovery.port=30306
120126
```
121127

122128
**node c**
123129
Finally, with `node_c` we connect to `node_b`. When the lookup runs, `node_c` should end up connecting to `node_a`:
124130

125131
```bash
126-
cargo run --bin ethrex --network ./test_data/kurtosis.json --bootnodes=`NODE_B_ENODE`" \
127-
--authrpc.port=8553 --http.port=8547 --p2p.port=30308 --discovery.port=30310
132+
cargo run --bin ethrex -- --network ./test_data/genesis-kurtosis.json --bootnodes=`NODE_B_ENODE` \
133+
--datadir=ethrex_c --authrpc.port=8553 --http.port=8547 --p2p.port=30308 --discovery.port=30310
134+
```
135+
136+
We get the `enode` by querying the node_info and using jq:
137+
```bash
138+
curl -s http://localhost:8546 \
139+
-X POST \
140+
-H "Content-Type: application/json" \
141+
--data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' \
142+
| jq '.result.enode'
128143
```
129144

130145
You could also spawn nodes from other clients and it should work as well.

0 commit comments

Comments
 (0)