Skip to content

Commit 0d63865

Browse files
authored
Merge pull request #236 from bane-labs/prepare-to-0.2.0
Prepare to 0.2.0 release
2 parents 92584e7 + 2f83eb2 commit 0d63865

File tree

15 files changed

+839
-755
lines changed

15 files changed

+839
-755
lines changed

Makefile

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# with Go source code. If you know what GOPATH is then you probably
33
# don't need to bother with make.
44

5-
.PHONY: geth android ios evm all test clean privnet_init privnet_nodes_stop privnet_bootnode_stop privnet_stop privnet_clean privnet_start privnet_start_four privnet_start_seven
5+
.PHONY: geth android ios evm all test clean privnet_nodes_stop privnet_bootnode_stop privnet_stop privnet_clean privnet_start privnet_start_four privnet_start_seven
66

77
GETHBIN = ./build/bin
88
GO ?= latest
@@ -71,33 +71,6 @@ BOOTNODE_LOGLEVEL = 5
7171
RESTRICTED_NETWORK = 127.0.0.0/24
7272
NAT_POLICY = none
7373

74-
define generate_bootnode
75-
@mkdir -p $(1)/$(BOOTNODE)
76-
@$(GETHBIN)/bootnode -genkey $(1)/$(BOOTNODE)/bootnode.key
77-
@echo $$($(GETHBIN)/bootnode --writeaddress -nodekey $(1)/$(BOOTNODE)/bootnode.key) > $(1)/$(BOOTNODE)/bootnode_address.txt
78-
endef
79-
80-
define generate_password
81-
$$(</dev/urandom tr -dc '12345qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c$(PASSWORD_LEN); echo "")
82-
endef
83-
84-
define replace_chainid
85-
@sed -i "s/_chain_id_/$$(cat $(1)/networkid.txt)/gI" $(1)/$(GENESIS_WORK_JSON)
86-
endef
87-
88-
define replace_node_address
89-
@echo $$(cat $(1)/$(2)/keystore/* | sed -En 's/.*"address":"([^"]*).*/\1/p') > $(1)/$(2)/node_address.txt
90-
@sed -i "s/$(2)/$$(cat $(1)/$(2)/node_address.txt)/gI" $(1)/$(GENESIS_WORK_JSON)
91-
endef
92-
93-
define create_account
94-
@mkdir -p $(1)/$(2)
95-
@echo $(call generate_password) > $(1)/$(2)/password.txt
96-
@$(GETHBIN)/geth --datadir $(1)/$(2) account new --password $(1)/$(2)/password.txt
97-
$(call replace_node_address,$(1),$(2))
98-
@echo "Account $(1): "$$(cat $(1)/$(2)/node_address.txt)
99-
endef
100-
10174
define run_bootnode
10275
@$(GETHBIN)/bootnode -nodekey $(1)/$(BOOTNODE)/bootnode.key \
10376
-addr :$(BOOTNODE_PORT) \
@@ -165,60 +138,6 @@ devtools:
165138

166139
# Privnet targets
167140

168-
privnet_init: privnet_clean
169-
@find $(SINGLE_DIR)/* -type d -name 'keystore' -exec rm -rf {} +
170-
@mkdir -p $(SINGLE_DIR)
171-
@echo "Generate $(GENESIS_WORK_JSON) file"
172-
@cp $(SINGLE_DIR)/genesis_template.json $(SINGLE_DIR)/$(GENESIS_WORK_JSON)
173-
@echo $$(date +'%y%m%d%H%M') > $(SINGLE_DIR)/networkid.txt
174-
@echo "Network ID is "$$(cat $(SINGLE_DIR)/networkid.txt)
175-
@echo "Generate bootnode"
176-
$(call generate_bootnode,$(SINGLE_DIR))
177-
$(call replace_chainid,$(SINGLE_DIR))
178-
@echo "Create accounts"
179-
$(call create_account,$(SINGLE_DIR),$(NODE1))
180-
$(call create_account,$(SINGLE_DIR),$(NODE2))
181-
@echo "OK! For starting use 'make privnet_start'"
182-
183-
privnet_init_four: privnet_clean
184-
@find $(FOUR_DIR)/* -type d -name 'keystore' -exec rm -rf {} +
185-
@mkdir -p $(FOUR_DIR)
186-
@echo "Generate $(GENESIS_WORK_JSON) file"
187-
@cp $(FOUR_DIR)/genesis_template.json $(FOUR_DIR)/$(GENESIS_WORK_JSON)
188-
@echo $$(date +'%y%m%d%H%M') > $(FOUR_DIR)/networkid.txt
189-
@echo "Network ID is "$$(cat $(FOUR_DIR)/networkid.txt)
190-
@echo "Generate bootnode"
191-
$(call generate_bootnode,$(FOUR_DIR))
192-
$(call replace_chainid,$(FOUR_DIR))
193-
@echo "Create accounts"
194-
$(call create_account,$(FOUR_DIR),$(NODE1))
195-
$(call create_account,$(FOUR_DIR),$(NODE2))
196-
$(call create_account,$(FOUR_DIR),$(NODE3))
197-
$(call create_account,$(FOUR_DIR),$(NODE4))
198-
$(call create_account,$(FOUR_DIR),$(NODE5))
199-
@echo "OK! For starting use 'make privnet_start_four'"
200-
201-
privnet_init_seven: privnet_clean
202-
@find $(SEVEN_DIR)/* -type d -name 'keystore' -exec rm -rf {} +
203-
@mkdir -p $(SEVEN_DIR)
204-
@echo "Generate $(GENESIS_WORK_JSON) file"
205-
@cp $(SEVEN_DIR)/genesis_template.json $(SEVEN_DIR)/$(GENESIS_WORK_JSON)
206-
@echo $$(date +'%y%m%d%H%M') > $(SEVEN_DIR)/networkid.txt
207-
@echo "Network ID is "$$(cat $(SEVEN_DIR)/networkid.txt)
208-
@echo "Generate bootnode"
209-
$(call generate_bootnode,$(SEVEN_DIR))
210-
$(call replace_chainid,$(SEVEN_DIR))
211-
@echo "Create accounts"
212-
$(call create_account,$(SEVEN_DIR),$(NODE1))
213-
$(call create_account,$(SEVEN_DIR),$(NODE2))
214-
$(call create_account,$(SEVEN_DIR),$(NODE3))
215-
$(call create_account,$(SEVEN_DIR),$(NODE4))
216-
$(call create_account,$(SEVEN_DIR),$(NODE5))
217-
$(call create_account,$(SEVEN_DIR),$(NODE6))
218-
$(call create_account,$(SEVEN_DIR),$(NODE7))
219-
$(call create_account,$(SEVEN_DIR),$(NODE8))
220-
@echo "OK! For starting use 'make privnet_start_seven'"
221-
222141
privnet_nodes_stop:
223142
@echo "Killing nodes processes"
224143
@killall -w -v -INT geth || :

README.md

Lines changed: 151 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
## Go Ethereum
1+
## Neo X node based on Go Ethereum
22

3-
Golang execution layer implementation of the Ethereum protocol.
3+
Golang implementation of the Neo X node based on the [Ethereum protocol
4+
execution layer implementation](https://github.com/ethereum/go-ethereum) written in
5+
Go.
46

5-
[![API Reference](
6-
https://pkg.go.dev/badge/github.com/ethereum/go-ethereum
7-
)](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
8-
[![Go Report Card](https://goreportcard.com/badge/github.com/ethereum/go-ethereum)](https://goreportcard.com/report/github.com/ethereum/go-ethereum)
9-
[![Travis](https://travis-ci.com/ethereum/go-ethereum.svg?branch=master)](https://travis-ci.com/ethereum/go-ethereum)
10-
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/nthXNEv)
7+
[![GoDoc](https://godoc.org/github.com/bane-labs/go-ethereum?status.svg)](https://godoc.org/github.com/bane-labs/go-ethereum)
8+
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/bane-labs/go-ethereum?sort=semver)
9+
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/n2QmWW9b)
1110

12-
Automated builds are available for stable releases and the unstable master branch. Binary
13-
archives are published at https://geth.ethereum.org/downloads/.
11+
Automated builds are available for stable releases only. Binary archives are
12+
published at https://github.com/bane-labs/go-ethereum/releases.
1413

1514
## Building the source
1615

17-
For prerequisites and detailed build instructions please read the [Installation Instructions](https://geth.ethereum.org/docs/getting-started/installing-geth).
16+
For prerequisites and detailed build instructions please read the [Installation Instructions](https://docs.banelabs.org/development/running-a-node-in-testnet).
1817

1918
Building `geth` requires both a Go (version 1.19 or later) and a C compiler. You can install
2019
them using your favourite package manager. Once the dependencies are installed, run
@@ -57,7 +56,7 @@ Minimum:
5756

5857
* CPU with 2+ cores
5958
* 4GB RAM
60-
* 1TB free storage space to sync the Mainnet
59+
* 200GB free storage space to sync the Testnet
6160
* 8 MBit/sec download Internet service
6261

6362
Recommended:
@@ -67,55 +66,146 @@ Recommended:
6766
* High-performance SSD with at least 1TB of free space
6867
* 25+ MBit/sec download Internet service
6968

70-
### Full node on the main Ethereum network
71-
72-
By far the most common scenario is people wanting to simply interact with the Ethereum
73-
network: create accounts; transfer funds; deploy and interact with contracts. For this
74-
particular use case, the user doesn't care about years-old historical data, so we can
75-
sync quickly to the current state of the network. To do so:
76-
77-
```shell
78-
$ geth console
79-
```
80-
81-
This command will:
82-
* Start `geth` in snap sync mode (default, can be changed with the `--syncmode` flag),
83-
causing it to download more data in exchange for avoiding processing the entire history
84-
of the Ethereum network, which is very CPU intensive.
85-
* Start the built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interacting-with-geth/javascript-console),
86-
(via the trailing `console` subcommand) through which you can interact using [`web3` methods](https://github.com/ChainSafe/web3.js/blob/0.20.7/DOCUMENTATION.md)
87-
(note: the `web3` version bundled within `geth` is very old, and not up to date with official docs),
88-
as well as `geth`'s own [management APIs](https://geth.ethereum.org/docs/interacting-with-geth/rpc).
89-
This tool is optional and if you leave it out you can always attach it to an already running
90-
`geth` instance with `geth attach`.
91-
92-
### A Full node on the Görli test network
93-
94-
Transitioning towards developers, if you'd like to play around with creating Ethereum
95-
contracts, you almost certainly would like to do that without any real money involved until
96-
you get the hang of the entire system. In other words, instead of attaching to the main
97-
network, you want to join the **test** network with your node, which is fully equivalent to
98-
the main network, but with play-Ether only.
99-
100-
```shell
101-
$ geth --goerli console
102-
```
103-
104-
The `console` subcommand has the same meaning as above and is equally
105-
useful on the testnet too.
106-
107-
Specifying the `--goerli` flag, however, will reconfigure your `geth` instance a bit:
108-
109-
* Instead of connecting to the main Ethereum network, the client will connect to the Görli
110-
test network, which uses different P2P bootnodes, different network IDs and genesis
111-
states.
112-
* Instead of using the default data directory (`~/.ethereum` on Linux for example), `geth`
113-
will nest itself one level deeper into a `goerli` subfolder (`~/.ethereum/goerli` on
114-
Linux). Note, on OSX and Linux this also means that attaching to a running testnet node
115-
requires the use of a custom endpoint since `geth attach` will try to attach to a
116-
production node endpoint by default, e.g.,
117-
`geth attach <datadir>/goerli/geth.ipc`. Windows users are not affected by
118-
this.
69+
### Full node on the Testnet Neo X network
70+
71+
To run a full node on the Neo X Testnet network follow the steps below.
72+
73+
1. Download the binaries from https://github.com/bane-labs/go-ethereum/releases or
74+
build the node with the following command:
75+
```shell
76+
make geth
77+
```
78+
2. Download the corresponding Neo X Testnet configuration from the
79+
[GitHub repository](https://github.com/bane-labs/go-ethereum/blob/bane-main/config/genesis_testnet.json).
80+
3. Initialize node database with the downloaded Neo X testnet genesis configuration:
81+
```shell
82+
./geth init --datadir ./nodes/node1 ./genesis_testnet.json
83+
```
84+
4. Create an account for the node operation or use an existing one. The following
85+
command may be used to create a new account (you'll be prompted for a password):
86+
```shell
87+
./geth --datadir ./nodes/node1 account new
88+
```
89+
5. Run the node either as a consensus member or as a seed node.
90+
1. **Running a seed node.** Seed node is a network member that does not take part
91+
in a consensus process. This node may be used to interact with the Neo X
92+
network: create accounts; transfer funds; deploy and interact with contracts;
93+
query node APIs.
94+
95+
To start the seed node use the following shell script as a template:
96+
```shell
97+
#!/bin/bash
98+
99+
node="nodes/node1"
100+
101+
startP2PPort=30300
102+
startHttpPort=8545
103+
startRPCPort=8561
104+
105+
port=`expr $startP2PPort + 1`
106+
httpport=`expr $startHttpPort + 1`
107+
rpcport=`expr $startRPCPort + 1`
108+
wsport=8570
109+
110+
miner=$(<$node/node_address.txt)
111+
echo "$node and the node address is $miner, rpc port $rpcport, p2p port $port"
112+
113+
nohup ./geth \
114+
--networkid 12227331 \
115+
--nat extip:10.148.0.2 \
116+
--port $port \
117+
--authrpc.port $rpcport \
118+
--identity=$node \
119+
--maxpeers=50 \
120+
--syncmode full \
121+
--gcmode archive \
122+
--datadir $node \
123+
--bootnodes "enr:-KO4QFuNbtvEaHsiOpEe22LyYJ9FBNDfsvzhBcohnpLcOmopXlk9sKE9JJlT9_JjVb3K0KTPvfNjjArb8c8Qe-geeoaGAY7rxy0Wg2V0aMfGhBL8z2aAgmlkgnY0gmlwhCO764eJc2VjcDI1NmsxoQNhL5qj-6ycHfDYoD3oujZuxH20AOLdU1aoT5gGGSLSaoRzbmFwwIN0Y3CCdl2DdWRwgnZd" \
124+
--http.api admin,eth,debug,miner,net,txpool,personal,web3,dbft \
125+
--http --http.addr 0.0.0.0 --http.port $httpport --http.vhosts "*" --http.corsdomain '*' \
126+
--ws --ws.addr 0.0.0.0 --ws.port $wsport --ws.api eth,net,web3 --ws.origins '*' \
127+
--verbosity 3 >> $node/node.log 2>&1 &
128+
129+
sleep 3s;
130+
ps -ef|grep geth|grep mine|grep -v grep;
131+
```
132+
You may need to change the P2P/HTTP/RPC/WS ports to avoid conflicts. Please,
133+
remember to change the `--nat` flag's extip if you want other nodes to be able
134+
to find yours. Refer to
135+
https://geth.ethereum.org/docs/fundamentals/command-line-options for more
136+
details about start options.
137+
138+
This script expects node DB directory to be `./node/node1` and the address of
139+
your account to be stored at `./node/node1/node_address.txt`.
140+
141+
Once all necessary flags are applied to the `./geth` command, you may run the
142+
seed node by running this script.
143+
144+
2. **Running a consensus node.** Consensus node is a network member that takes
145+
part in a block acceptance process. Every node is allowed take part in the
146+
consensus process in watch-only mode. However, to become a block-producing
147+
validator the candidate must register itself via Governance contract and earn
148+
enough votes from the Neo X users. Please refer to the
149+
[Neo X Governance documentation](https://docs.banelabs.org/governance/governance-in-neo-x)
150+
and to the [Neo X candidate registration documentation](https://docs.banelabs.org/development/running-a-node-in-testnet#id-6.-registering-as-a-candidate)
151+
for more details.
152+
153+
To start a consensus node use `--mine` flag with addition to the script for the
154+
seed node. The following script may be used as a template:
155+
```shell
156+
#!/bin/bash
157+
158+
node="nodes/node1"
159+
160+
startP2PPort=30300
161+
startRPCPort=8561
162+
163+
port=`expr $startP2PPort + $nodeIndex`
164+
rpcport=`expr $startRPCPort + $nodeIndex`
165+
166+
miner=$(<$node/node_address.txt)
167+
echo "$node and miner is $miner, rpc port $rpcport, p2p port $port"
168+
169+
nohup ./geth \
170+
--networkid 12227331 \
171+
--nat extip:10.148.0.2 \
172+
--port $port \
173+
--mine --miner.etherbase=$miner \
174+
--unlock $miner \
175+
--password $node/password.txt \
176+
--authrpc.port $rpcport \
177+
--identity=$node \
178+
--maxpeers=50 \
179+
--syncmode full \
180+
--gcmode archive \
181+
--datadir $node \
182+
--bootnodes "enr:-KO4QFuNbtvEaHsiOpEe22LyYJ9FBNDfsvzhBcohnpLcOmopXlk9sKE9JJlT9_JjVb3K0KTPvfNjjArb8c8Qe-geeoaGAY7rxy0Wg2V0aMfGhBL8z2aAgmlkgnY0gmlwhCO764eJc2VjcDI1NmsxoQNhL5qj-6ycHfDYoD3oujZuxH20AOLdU1aoT5gGGSLSaoRzbmFwwIN0Y3CCdl2DdWRwgnZd" \
183+
--verbosity 3 >> $node/node.log 2>&1 &
184+
185+
sleep 3s;
186+
ps -ef|grep geth|grep mine|grep -v grep;
187+
```
188+
You may need to change the P2P/HTTP/RPC/WS ports to avoid conflicts. Please,
189+
remember to change the `--nat` flag's extip if you want other nodes to be able
190+
to find yours. Refer to
191+
https://geth.ethereum.org/docs/fundamentals/command-line-options for more
192+
details about start options.
193+
194+
This script expects node DB directory to be `./node/node1`, the address of
195+
the consensus node account to be stored at `./node/node1/node_address.txt` and
196+
the password to be stored at `./node/node1/password.txt`.
197+
198+
Once all necessary flags are applied to the `./geth` command, you may run the
199+
seed node by running this script.
200+
201+
6. You may also start the built-in interactive
202+
[JavaScript console](https://geth.ethereum.org/docs/interacting-with-geth/javascript-console),
203+
(via the trailing `console` subcommand) through which you can interact using
204+
[`web3` methods](https://github.com/ChainSafe/web3.js/blob/0.20.7/DOCUMENTATION.md)
205+
(note: the `web3` version bundled within `geth` is very old, and not up to date
206+
with official docs), as well as `geth`'s own [management APIs](https://geth.ethereum.org/docs/interacting-with-geth/rpc).
207+
This tool is optional and if you leave it out you can always attach it to an
208+
already running `geth` instance with `geth attach`.
119209
120210
*Note: Although some internal protective measures prevent transactions from
121211
crossing over between the main network and test network, you should always

0 commit comments

Comments
 (0)