Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you provide a tutorial on building a private chain please? #292

Open
VictorECDSA opened this issue May 9, 2020 · 9 comments
Open
Labels
enhancement An enhancement to existing implementation

Comments

@VictorECDSA
Copy link

VictorECDSA commented May 9, 2020

🚀 Feature Request

Could you provide a tutorial on building a private chain please?

@VictorECDSA VictorECDSA added the enhancement An enhancement to existing implementation label May 9, 2020
@VictorECDSA VictorECDSA changed the title Can you provide a tutorial on building a private chain? Could you provide a tutorial on building a private chain please? May 9, 2020
@honeycrypto
Copy link
Contributor

@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

@VictorECDSA
Copy link
Author

VictorECDSA commented May 10, 2020

@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?

@orogvany
Copy link
Collaborator

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.

@VictorECDSA
Copy link
Author

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!

@orogvany
Copy link
Collaborator

orogvany commented May 11, 2020

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.

@VictorECDSA
Copy link
Author

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!

@orogvany
Copy link
Collaborator

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.

@VictorECDSA
Copy link
Author

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

@orogvany
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to existing implementation
Projects
None yet
Development

No branches or pull requests

3 participants