quorum icon indicating copy to clipboard operation
quorum copied to clipboard

How is the Storage map populated in the genesis.json?

Open subramen opened this issue 9 years ago • 5 comments

System information

Geth version: geth version OS & Version: Linux Ubuntu

Expected behaviour

PRIVATE_CONFIG=tm1.conf nohup geth --datadir qdata/issuer1 $GLOBAL_ARGS --rpcport 22000 --port 21000 --unlock "0x93546f0314bf8eacb3ea45ba75dfcd1a2341e59b" --voteaccount "0x8a19fcbf7150d5ede014fd706ff246176a2c85fa" --votepassword "" --password passwords.txt 2>>qdata/logs/1.log &

should assign voting privileges to 0x8a19..59b

Actual behaviour

E1221 20:00:04.904205 core/quorum/block_voting.go:280] Unable to vote: 0x8a19fcbf7150d5ede014fd706ff246176a2c85fa is not allowed to vote

Is the solution to this in populating the storage map? If so, how is the storage key:value pairs calculated? What is the <256 bit variable index> mentioned in https://github.com/jpmorganchase/quorum/blob/master/docs/running.md

subramen avatar Dec 21 '16 20:12 subramen

Disclaimer: I'm not an expert or affiliated with quorum

I think the documentation and/or tooling around how to create custom implementation of a private quorum cluster needs more work. I'm guessing you are following the quorum-examples repo instructions on how to set up a cluster. The shell scripts they use take care of initializing the blockchain with a custom genesis.json file.

In this file, voting contract is set at the address 0x0000000000000000000000000000000000000020. Besides the byte code of the contract, we also have the option of setting state variables in storage on the contract in the genesis file. As you can see, at index 0x01 of the storage the value stored is 0x02 - this corresponds to line 36 of the solidity code storing the uint of voteThreshold with an integer "2". Index 0x02 stores another uint which corresponds to line 39 of the solidity code - uint public voterCount.

Essentially they're hardcoding state vars of the contract this way. For the canVote mapping (index 0x03), the next 4 lines store boolean values for given addresses at index 0x03. The way that these storage addresses are arrived at is by concatenating the left padded 32 byte mapping key (in this case an address) with the left padded index (in this case 0000000000000000000000000000000000000000000000000000000000000003) and taking the sha3 of the result - be sure to specify the encoding as hex when you perform the sha3:

> web3.sha3(key, {"encoding": "hex"})

Your address is being rejected because it was not hardcoded into the block_voting contract (in the genesis block) as an address that canVote. You'll need to modify the gensis.json file and update it with your own hardcoded values that you want in the voting contract.

joeb000 avatar Dec 25 '16 21:12 joeb000

Thanks Joe, your answer gave me some much needed clarity!

Quorurm team, you should consider linking to this answer in your wiki.

subramen avatar Dec 26 '16 07:12 subramen

@joeb000 thanks for chiming in, you are correct.

The current documentation is intentionally light around setting up a quorum node/cluster from scratch as the aim was to have users start with quorum-examples so that setup issues could be largely mitigated and enable people to get up and running quickly. Providing the full documentation, including documenting the genesis.json file is definitely in the pipeline and should be out early in the new year.

Thanks for the help!

tylobban avatar Dec 26 '16 12:12 tylobban

Thanks Joe and further documentation on the genesis.json file will be added to our wiki soon.

davoell avatar Jan 06 '17 19:01 davoell

Hi all, I understand that we have to define the all the the makers, voters node in the storage section of the genesis json file.

Is it possible to create a new and late coming node and join an existing quorum network that is actively running and was previously initialized based on a genesis json file which doesn't contain the storage info of the new node?

Thank you.

alexpee avatar Oct 20 '17 10:10 alexpee