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

how to lightchain Start multi-node ??? #197

Open
liuqihang opened this issue Aug 17, 2019 · 5 comments
Open

how to lightchain Start multi-node ??? #197

liuqihang opened this issue Aug 17, 2019 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@liuqihang
Copy link

I would like to ask how to start lightchain multi-node
I start mainnet or Sirius, the console will appear err="dial TCP 88.198.36.61:26656: I /o timeout"
Or err="auth failure:secret conn failed: EOF"

@ggarri
Copy link
Contributor

ggarri commented Aug 19, 2019

Hi @liuqihang

You can run as many local nodes as you wish but you have to manually specify different ports for each of the connectivities across inner services and across peers. You can see more about which ports are being used here.

You can try to run two nodes using the following flags.

// Launch Node 1
$> lightchain run --rpc --rpcport 8545 --ws --wsport 8556 --tmt_rpc_port=26657 --tmt_p2p_port=26656

// Launch Node 2
$> lightchain run --rpc --rpcport 9545 --ws --wsport 9556 --tmt_rpc_port=26757 --tmt_p2p_port=26756

@ggarri ggarri added the question Further information is requested label Aug 19, 2019
@ggarri ggarri self-assigned this Aug 19, 2019
@liuqihang
Copy link
Author

@ggarri ,Thank you for your answer。
I want to achieve synchronization between two nodes.
such as:
ethereum :Ether's admin.addPeers("nodeinfo") module,I tried it through the "geth" and "leth" in the lightchain, but, Viewed by net.peers(), did not see an increase in the number of nodes。
How can lightchain achieve synchronization between nodes? thanks

@ggarri
Copy link
Contributor

ggarri commented Aug 19, 2019

Hi @liuqihang

I am not sure of what is your issue. Are you trying to create a private network using lightchain? If so, you need to create your own:

  • Genesis ethereum block: $DATADIR/database/genesis.json
  • Genesis consensus block: $DATADIR/consensus/config/genesis.json

To do that you could initialize two new nodes using:

$ lightchain init --datadir=${DATADIR_NODE1} --standalone
$ lightchain init --datadir=${DATADIR_NODE2} --standalone

Then you have to copy those two genesis files from node1 to node2 (or in the other way around):

$> cp ${DATADIR_NODE1}/database/genesis.json ${DATADIR_NODE2}/database/genesis.json
$> cp ${DATADIR_NODE1}/consensus/config/genesis.json ${DATADIR_NODE2}/consensus/config/genesis.json

And at last you need to edit the consensus config of both nodes to add the peer ids by editing ${DATADIR}/consensus/config/config.json as follow:

...
persistent_peers = ${CONSENSUS_NODE_ID}@localhost:26656
...

To know which is the CONSENSUS_NODE_ID, having the lightchain node running($lightchain run...) you can run the following curl request

$> curl -s localhost:26657/status
{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "node_info": {
      "protocol_version": {
        "p2p": "7",
        "block": "9",
        "app": "0"
      },
      "id": "33aae239346419a3e57ff7119ecf8eb53b7fa2cc",
...

Then, at the output you have the "id", which corresponds to the CONSENSUS_NODE_ID. Remember that you need to repeat that process for both nodes and the ports might change depending on your lightchain run command

@liuqihang
Copy link
Author

I follow this method, starting the standalone mode。
` ./lightchain init --datadir ${DATADIR_NODE1}/lightchain --standalone
./lightchain run --datadir= ${DATADIR_NODE1}/lightchain --rpc --rpcaddr=0.0.0.0 --ws --rpcport 8545 --wsport 8546 --tmt_p2p_port 26656 --tmt_rpc_port 26657

./lightchain init --datadir ${DATADIR_NODE2}/lightchain2 --standalone`
./lightchain run --datadir= ${DATADIR_NODE2}/lightchain2 --rpc --rpcaddr=0.0.0.0 --ws --rpcport 7545 --wsport 7546 --tmt_p2p_port 46656 --tmt_rpc_port 46657

Guaranteed the same genesis.json。
update ${DATADIR_NODE1}lightchain/consensus/config/config.toml
--> curl -s localhost:26657/status { "jsonrpc": "2.0", "id": "", "result": { "node_info": { "protocol_version": { "p2p": "7", "block": "9", "app": "0" }, "id": "f4fef2b81aab2cf08001a4bc88ba4c225f9db34e", "listen_addr": "tcp://0.0.0.0:26656", "network": "lightstreams-sirius-testnet",
persistent_peers="[email protected]:26656"

update ${DATADIR_NODE2}lightchain2/consensus/config/config.toml
--> curl -s localhost:46657/status { "jsonrpc": "2.0", "id": "", "result": { "node_info": { "protocol_version": { "p2p": "7", "block": "9", "app": "0" }, "id": "16c7db43491b9becf37783bb363798395df33038", "listen_addr": "tcp://0.0.0.0:46656", "network": "lightstreams-sirius-testnet",

persistent_peers="[email protected]:46656"

Then enter the "geth" console:
${DATADIR_NODE1}lightchain/database/geth.ipc
`admin
{
datadir: "/home/lqh/lightchain/database",
nodeInfo: {
enode: "enode://f953909de4806eabaa0e2a85a3793ec445dd68d7a7b0a6793d000e98e3b5727fd8dd10b961c23c6854bc07b7c7bb527f6459de49a62eb324b8e6d7113fc7a0bb@121.71.185.114:30303?discport=0",
enr: "0xf889b84047c6d4a9dfdc920877c9f570d0364b5d55e3aec5904bb1348f4aeeb6b20e971425304f8bc875889b175a166f3dbf9bc4c24f3805f91ddbc294631c4b3550629a0383636170c0826964827634826970847947b97289736563703235366b31a103f953909de4806eabaa0e2a85a3793ec445dd68d7a7b0a6793d000e98e3b5727f8374637082765f",
id: "9edfe04a28bdf5d5c08275b718d9293009e176a1ae5d2d31fb542467f23684bc",
ip: "121.71.185.114",
listenAddr: "[::]:30303",
name: "./v1.8.27/linux-amd64/go1.12.5",
ports: {
discovery: 0,
listener: 30303
},
protocols: {}
},

admin.addPeer("enode://550481d4f08c7d6ea7bf1acd3c4ea84c04d89e36d78942e5f3c5c56feba65394f52367e34d44be6c042bbd32529bd4c2ef271fd1e13e380550875ef69f0fd4f4@121.71.185.114:30303?discport=0")
true

net
{
listening: true,
peerCount: 0,
version: "162",
getListening: function(callback),
getPeerCount: function(callback),
getVersion: function(callback)
}

**`net.peerCount is 0 **

${DATADIR_NODE2}lightchain2/database/geth.ipc

admin
{
datadir: "/home/lqh/lightchain2/database",
nodeInfo: {
enode: "enode://550481d4f08c7d6ea7bf1acd3c4ea84c04d89e36d78942e5f3c5c56feba65394f52367e34d44be6c042bbd32529bd4c2ef271fd1e13e380550875ef69f0fd4f4@121.71.185.114:30303?discport=0",
enr: "0xf889b840d775ae737a5aa2f419fc3d059d304358e512ba545ba1b3f07b298ec3dbad145027537dbc1dbcc8be9518b642d902aee8600805512c835e8464aae1aea1a21cd50383636170c0826964827634826970847947b97289736563703235366b31a102550481d4f08c7d6ea7bf1acd3c4ea84c04d89e36d78942e5f3c5c56feba653948374637082765f",
id: "63958a38d24f6833143be0911bf4c45405da35aea4302a26b4a9f68456f589ec",
ip: "121.71.185.114",
listenAddr: "[::]:30303",
name: "./v1.8.27/linux-amd64/go1.12.5",
ports: {
discovery: 0,
listener: 30303
},
protocols: {}
},

Where can I operate incorrectly? ggarri。I want to see each other's information in two nodes. For example, node1 can query the account balance of node2.
Ethereum can be queried after synchronization of two private chain nodes, I think lightchain is also possible

@ggarri
Copy link
Contributor

ggarri commented Aug 19, 2019

as fas as I can see there is only one incorrect step, when you added the persistent_peers at the consensus/config/config.toml you have to cross the peers in order to find each, I mean.

  1. At ${DATADIR_NODE1}lightchain/consensus/config/config.toml you should have:
persistent_peers="[email protected]:46656"
  1. At ${DATADIR_NODE2}lightchain/consensus/config/config.toml you should have:
persistent_peers="[email protected]:46656"

In addition, just to mention that the method admin.addPeer() is not operative for now in our network because we replaced the original ethereum PoW by the tendermint PoC and we didn't have time to implement that integration (#198) and the call to net.peers was implemented very recently 1209e6e so please ensure you are using the latest version available at the master branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants