Consensys / quorum

A permissioned implementation of Ethereum supporting data privacy
https://www.goquorum.com/
GNU Lesser General Public License v3.0
4.69k stars 1.3k forks source link

Issues while electing leader on a single node quorum cluster. #931

Closed navdeep-kaur closed 4 years ago

navdeep-kaur commented 4 years ago

Hi there,

On upgrading to quorum 2.4, when we are starting up the cluster with a single node, the raft_cluster is responding with {"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"no leader is currently elected"}}. The single node is unable to elect itself as the leader and is always chosen as a candidate instead.

Expected behaviour

The single node should be elected as the leader.

The idea is to spin up a single boot node and run add peer for all the other nodes that we want to add to the quorum network.

vsmk98 commented 4 years ago

Hi @navdeep-kaur - I checked in 2.4.0 version bringing up a single node cluster and it works fine for me.

➜  7nodes git:(master) ✗ geth attach qdata/dd1/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.18-stable(quorum-v2.4.0)/darwin-amd64/go1.11.13
coinbase: 0xed9d02e382b34818e88b88a309c7fe71e65f419d
at block: 0 (Thu, 01 Jan 1970 07:30:00 +0730)
 datadir: /Users/saiv/temp/quorum-examples/examples/7nodes/qdata/dd1
 modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 raft:1.0 rpc:1.0 txpool:1.0 web3:1.0

> raft.cluster
[{
    hostname: "127.0.0.1",
    nodeId: "ac6b1096ca56b9f6d004b779ae3728bf83f8e22453404cc3cef16a3d9b96608bc67c4b30db88e0a5a6c6390213f7acbe1153ff6d23ce57380104288ae19373ef",
    p2pPort: 21000,
    raftId: 1,
    raftPort: 50401,
    role: "minter"
}]

Can you please check if the static-nodes.json is having only one entry (the node which you are bringing up)?

navdeep-kaur commented 4 years ago

@vsmk98 we have entries for all nodes (that will be added ) in the quorum network in the static-nodes.json when we start the network with a single node. This used to work in v2.2.3. Has something changed around this?

MrHmP commented 4 years ago

@vsmk98 this used to work in v2.2.3, has something updated in v2.4.0 @jpmsam @felixonmars

vsmk98 commented 4 years ago

@MrHmP, @navdeep-kaur , there is no change in the raft consensus behaviour between 2.2.3 and 2.4.0. In both versions, the minter election will not happen and if you check the logs in version 2.2.3 you will see that the 1 node which is up is continuously trying to elect a leader. Further if you check the raft.role for this node in version 2.2.3 it will be shown as verifier and no transactions can be processed from this node. This is because raft algorithm considers the entries in static-nodes.json as the initial quorum and would expect majority voting from this quorum for electing leader.

In 2.4.0 as a part of the API response we also wanted to return the role of the node in the network. Because of this if there is no leader in the network, the api returns an error.

For your scenario, my suggestion will be to

  1. bring up a single node network with one entry in static-nodes.json
  2. As the new nodes come, use raft.addPeer to add the new node
  3. Bring up the new node with --raftjoinexistsing <<raftid>> to join the network

Please let me know if this is workable for your scenario.

vsmk98 commented 4 years ago

I am closing this issue. Please re-open if necessary.

Himanshu-Pandey commented 4 years ago

I don't understand why it doesn't work with the new version if it was working for older version. Sure we have a different way of provisioning our network now, but we have to change our code for cluster deployment. We are forced to use older version because of this. @vsmk98

vsmk98 commented 4 years ago

@Himanshu-Pandey, at I mentioned, at network level it was not working with one node in 2.2.3 and its the same behaviour in 2.4.0. The only difference is raft.cluster used to return an incorrect raft quorum based on static-nodes.json in version 2.2.3, though the actual raft quorum was not there. e.g. with a single node in version 2.2.3, you will not be able to process any transactions as there will be no leader at the network level. I understand the api response causes changes at your end. I am discussing the same and will revert back. Thanks

jpmsam commented 4 years ago

@Himanshu-Pandey thanks for your feedback. @vsmk98 is working on resolving this. The api will not return an error going forward, but it will return the cluster details with a nil for the role until a leader is elected.

vsmk98 commented 4 years ago

@Himanshu-Pandey I have created the PR to resolve this. Please refer to raft api documentation page https://github.com/jpmorganchase/quorum/blob/fix/raft-cluster-api/docs/Consensus/raft/raft-rpc-api.md for details of the raft.cluster api with this change.

Himanshu-Pandey commented 4 years ago

Thanks @vsmk98

vsmk98 commented 4 years ago

Closing this issue as the PR is merged.