1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# Running a RPC node
## Content
- [Overview](#overview)
- [System Requirement](#system-requirement)
- [Software Instruction](#software-instruction)
## Overview
A RPC node is the data access layer of blockchains. It usually won't join the mining process but only try to sync the latest confirmed state from other nodes. With those datum in hands, a RPC node can provide these functionalities:
- Pack and send transactions
- Allow other services (like **wallet** or **explorer**) to access states on blockchains in standard way, like **jsonrpc**.
## System Requirement
Refer to [System requirement](BP-Node-Operation-Guide.md#system-requirement) section in BP node operation guide.
## Software Instruction
Different from running a BP node, you don't have to
- create a node key
- register your node
The command line to start a RPC node is different, too:
```
docker run -v $PWD:/mnt -it byzantinelab/go-tangerine \
--datadir=/mnt/datadir \
--syncmode=fast \
--rpc \
--rpcapi=eth,net,web3 \
--rpcaddr=0.0.0.0 \
--rpcvhosts=* \
--rpccorsdomain=* \
--ws \
--wsapi=eth,net,web3 \
--wsaddr=0.0.0.0 \
--wsorigins=* \
--cache=1024 \
--gcmode=archive \
--metrics \
--pprof \
--pprofaddr=0.0.0.0
```
You should be able to see these logs, which simply means your RPC node tries to sync blocks from other peers and it would take a while. If not, make sure tcp/30303 and udp/30303 is not blocked by the firewall.
```
...
INFO [04-18|12:23:33.783] Imported new state entries ...
INFO [04-18|12:23:35.647] Imported new state entries ...
INFO [04-18|12:23:37.714] Imported new block receipts ...
INFO [04-18|12:23:38.471] Imported new block receipts ...
...
```
To make sure your RPC node is ready for usage, you can try to get the count of blocks it received via this command:
```
curl -X POST \
-H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
http://localhost:8545
```
You should be able to see something similar in return (**0xd482e** is the hex form of **870062**):
```
{"jsonrpc":"2.0","id":1,"result":"0xd482e"}
```
### RPC Node for Testnet
It simply to launch a RPC node for testnet by adding network flag `--testnet`:
```
docker run -v $PWD:/mnt -it byzantinelab/go-tangerine \
--testnet \
--datadir=/mnt/datadir \
--syncmode=fast \
--rpc \
--rpcapi=eth,net,web3 \
--rpcaddr=0.0.0.0 \
--rpcvhosts=* \
--rpccorsdomain=* \
--ws \
--wsapi=eth,net,web3 \
--wsaddr=0.0.0.0 \
--wsorigins=* \
--cache=1024 \
--gcmode=archive \
--metrics \
--pprof \
--pprofaddr=0.0.0.0
```
|