semux-core
semux-core copied to clipboard
Could you provide a tutorial on building a private chain please?
🚀 Feature Request
Could you provide a tutorial on building a private chain please?
@fenghaoming take a look at devnet: https://github.com/semuxproject/semux-core/blob/master/docs/Devnet.md
You can import private key and run your local private chain with 1 validator
@fenghaoming take a look at devnet: https://github.com/semuxproject/semux-core/blob/master/docs/Devnet.md
You can import private key and run your local private chain with 1 validator
Thank you for your answer! Again, can I build a devnet with multiple nodes(validators)? How do I do that?
For a totally new chain, you need to generate a new genesis block, and you will need seed nodes so your new peers can find each other.
For a totally new chain, you need to generate a new genesis block, and you will need seed nodes so your new peers can find each other.
Thank you for your answer! I would like to ask the following questions: How do I create a genesis block, and in which directory should I put it? Can I run multiple nodes(validators) on the same Linux machine? How should the properties files(semux.properties) for these nodes be configured? Thank you!
There's a utility to generate one in the code
You cannot run multiple nodes on one box. What would be point? If you want one node/box run devnet as above
The properties file would be same as now, just with a new seed host. To start a new mainnet, you need to run 2-4+ nodes afaik.
There's a utility to generate one in the code
You cannot run multiple nodes on one box. What would be point? If you want one node/box run devnet as above
The properties file would be same as now, just with a new seed host. To start a new mainnet, you need to run 2-4+ nodes afaik.
Could you tell me the name of the utility or which code function? Can I start multiple nodes on a single Linux machine by assigning different file directories and different ports to each node? Thank you!
As already stated, for a new mainnet, you cannot run multiple nodes on one box, regardless how you set up ports.
You could fork and remove such protections from the code,but you'd have to track them down and remove.
As already stated, for a new mainnet, you cannot run multiple nodes on one box, regardless how you set up ports.
You could fork and remove such protections from the code,but you'd have to track them down and remove.
Thanks for your advice. After experimenting, I found a way to start multiple nodes on the same LINUX platform to form a private network. The steps to share are as follows:
1. Build with source
git clone https://github.com/semuxproject/semux-core
cd semux-core
mvn install -DskipTests
Note: mvn install may not be able to download these three files, but you can manually download them and put them in: semux-core/dist/cache https://github.com/semuxproject/jvm/releases/download/v1.1.0/jvm-11-windows.zip https://github.com/semuxproject/jvm/releases/download/v1.1.0/jvm-11-linux.tar.gz https://github.com/semuxproject/jvm/releases/download/v1.1.0/jvm-11-macos.tar.gz
2. Create 4 nodes directory
cp -R dist/linux dist/linux_0
cp -R dist/linux dist/linux_1
cp -R dist/linux dist/linux_2
cp -R dist/linux dist/linux_3
3. Modify the properties
vim dist/linux_0/config/semux.properties
p2p.listenIp = 0.0.0.0
p2p.listenPort = 5161
p2p.seedNodes =
api.enabled = true
api.listenIp = 0.0.0.0
api.listenPort = 5171
api.username = fenghm
api.password = fenghm
vim dist/linux_1/config/semux.properties
p2p.listenIp = 0.0.0.0
p2p.listenPort = 6161
p2p.seedNodes = 127.0.0.1:5161
api.enabled = true
api.listenIp = 0.0.0.0
api.listenPort = 6171
api.username = fenghm
api.password = fenghm
vim dist/linux_2/config/semux.properties
p2p.listenIp = 0.0.0.0
p2p.listenPort = 7161
p2p.seedNodes = 127.0.0.1:5161
api.enabled = true
api.listenIp = 0.0.0.0
api.listenPort = 7171
api.username = fenghm
api.password = fenghm
vim dist/linux_3/config/semux.properties
p2p.listenIp = 0.0.0.0
p2p.listenPort = 8161
p2p.seedNodes = 127.0.0.1:5161
api.enabled = true
api.listenIp = 0.0.0.0
api.listenPort = 8171
api.username = fenghm
api.password = fenghm
4. Import and create accounts
dist/linux_0/semux-cli.sh --importprivatekey 0x302e020100300506032b657004220420acbd5f2cb2b6053f704376d12df99f2aa163d267a755c7f1d9fe55d2a2dc5405
dist/linux_1/semux-cli.sh --account create
dist/linux_2/semux-cli.sh --account create
dist/linux_3/semux-cli.sh --account create
5. Run
dist/linux_0/semux-cli.sh -network devnet --coinbase 0
dist/linux_1/semux-cli.sh -network devnet --coinbase 0
dist/linux_2/semux-cli.sh -network devnet --coinbase 0
dist/linux_3/semux-cli.sh -network devnet --coinbase 0
Congrats! It is interesting that you were able to do this with just different ports. There are supposed to be protections in place. Maybe there's an exception to that rule for 0.0.0.0?
The original author really was against multiple nodes of network running from single ip/point of failure, so it is very surprising.
Glad you found way to make it work