Skip to content

Commit 72eab3b

Browse files
Wi1l-B0tajara87shargoncschuchardt88superboyiii
authored
Add: script to run localnet nodes (#4199)
* Add: script to run localnet nodes * Sleep 1s after node started * Don't show rpc-port if no RpcServer plugin * Enable HF_Faun for localnet * Update scripts/run-localnet-nodes.sh Co-authored-by: Owen <[email protected]> * Add more tips * Install DBFT, RpcServer, ApplicationLogs plugins automaticly --------- Co-authored-by: Alvaro <[email protected]> Co-authored-by: Shargon <[email protected]> Co-authored-by: Christopher Schuchardt <[email protected]> Co-authored-by: Owen <[email protected]> Co-authored-by: Vitor Nazário Coelho <[email protected]>
1 parent 272af62 commit 72eab3b

File tree

3 files changed

+616
-0
lines changed

3 files changed

+616
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,4 @@ launchSettings.json
267267
# Benchmarks
268268
**/BenchmarkDotNet.Artifacts/
269269
/src/Neo.CLI/neo-cli/
270+
**/localnet_nodes/

scripts/run-localnet-nodes.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Localnet Node Management Script
2+
3+
This script helps you create and manage multiple Neo localnet nodes for development and testing purposes.
4+
5+
## Features
6+
7+
- **Automatic Configuration Generation**: Creates individual configuration files for each node
8+
- **Port Management**: Automatically assigns unique ports for P2P and RPC communication
9+
- **Node Management**: Start, stop, restart, and monitor multiple nodes
10+
- **Data Isolation**: Each node has its own data directory and storage
11+
- **Process Management**: Tracks running processes with PID files
12+
13+
## Usage
14+
15+
### Basic Commands
16+
17+
```bash
18+
# Start 7 nodes (default)
19+
./run-localnet-nodes.sh start
20+
21+
# Check status of all nodes
22+
./run-localnet-nodes.sh status
23+
24+
# Stop all nodes
25+
./run-localnet-nodes.sh stop
26+
27+
# Restart all nodes
28+
./run-localnet-nodes.sh restart
29+
30+
# Clean up all data
31+
./run-localnet-nodes.sh clean
32+
```
33+
34+
### Node Configuration
35+
36+
Each node gets:
37+
- **Unique P2P Port**: Starting from 20333 (Node0: 20333, Node1: 20334, etc.)
38+
- **Unique RPC Port**: Starting from 10330 (Node0: 10330, Node1: 10331, etc.)
39+
- **Isolated Data Directory**: `localnet_nodes/node_X/`
40+
- **Individual Configuration**: `localnet_nodes/node_X/config.json`
41+
- **Process Logs**: `localnet_nodes/node_X/neo.log`
42+
43+
### Network Configuration
44+
45+
- **Network ID**: 1234567890 (localnet)
46+
- **Block Time**: 15 seconds
47+
- **Validators**: 7 validators configured
48+
- **Seed List**: All nodes are configured to connect to each other
49+
50+
## Directory Structure
51+
52+
```
53+
localnet_nodes/
54+
├── node_0/
55+
│ ├── config.json
56+
│ ├── neo.log
57+
│ ├── neo.pid
58+
│ └── Data_LevelDB_Node0/
59+
├── node_1/
60+
│ ├── config.json
61+
│ ├── neo.log
62+
│ ├── neo.pid
63+
│ └── Data_LevelDB_Node1/
64+
└── ...
65+
```
66+
67+
## Prerequisites
68+
69+
1. **Build Neo Project**: Make sure the project is built
70+
```bash
71+
dotnet build
72+
```
73+
74+
2. **Neo-CLI Available**: The script looks for `neo-cli` or `neo-cli.dll` in the `bin/` directory
75+
76+
## Troubleshooting
77+
78+
### Node Won't Start
79+
- Check if neo-cli is built: `ls bin/neo-cli*`
80+
- Check logs: `cat localnet_nodes/node_X/neo.log`
81+
- Verify ports are not in use: `netstat -an | grep 20333`
82+
83+
### Port Conflicts
84+
- The script uses ports 20333+ for P2P and 10330+ for RPC
85+
- Make sure these ports are available
86+
- You can modify `BASE_PORT` and `BASE_RPC_PORT` in the script
87+
88+
### Process Management
89+
- Each node runs as a background process
90+
- PID files are stored in each node's directory
91+
- Use `./run-localnet-nodes.sh status` to check running nodes
92+
93+
## Development Tips
94+
95+
1. **Start with 7 Nodes**: For development, 7 nodes is best configuration for testing.
96+
2. **Monitor Logs**: Check individual node logs for debugging
97+
3. **Clean Restart**: Use `clean` command to start fresh
98+
4. **Network Connectivity**: Nodes automatically discover each other via seed list
99+
100+
## Example Workflow
101+
102+
```bash
103+
# 1. Build the project
104+
dotnet build
105+
106+
# 2. Start 3 localnet nodes
107+
./run-localnet-nodes.sh start 3
108+
109+
# 3. Check status
110+
./run-localnet-nodes.sh status
111+
112+
# 4. Monitor a specific node
113+
tail -f localnet_nodes/node_0/neo.log
114+
115+
# 5. Stop all nodes
116+
./run-localnet-nodes.sh stop
117+
118+
# 6. Clean up when done
119+
./run-localnet-nodes.sh clean
120+
```

0 commit comments

Comments
 (0)