We are using private ethereum network(1 node). We have a couple transaction per second. But mining is too slow. It takes about 10-60 seconds for every transaction. Could you provide some advice settings for genesis or maybe geth start options?
[Ethereum] Ethereum private network performance
go-ethereumprivate-blockchain
Related Solutions
Private blockchain Everyone is equal, and can mine the transactions. Basically you need to share your genesis block with the other party and once they initialize their chain, you have to add their enode addrees as peer.
Permissioned blockchain Permission is built into your blockchain client, where you can decide based on the other party cryptographic information what access will they have. Monax, Hyperledger fabric, jpmorgan quorum are some examples of permissioned chains.. Based on your comment , you are trying to create a private blockchain.
- Initialize your blockchain in Node A as, geth --datadir geth_data init genesis.json Note : Alloc section should be empty in your genesis block This will initialize your chain in your data directory.
- Now start the geth again , this time without the init geth --datadir geth_data --port 54259 console
Note, Once geth starts in console mode, enable personal API and create your 1st account, seed your account with some ether in your genesis alloc block. For adding a peer via console you should enable admin API.
- Get your enode address of Node A with the command
admin.nodeInfo.enode
"enode://fc542dd3209dd73da7b4282990e1ad39ad9d61d772bc844d416d58ae97bdbb02aa40f65 5f7565276dab552e9cc363376a6e76ebbf08f7f665b9b9d4a8b286d18@[::]:54259"
replace the [::] with your IP of Node A. Now you are ready to connect to another Node B.
4.In Node B,keep your genesis.json , your A node's enode address handy. Initialize the chain with the genesis block that you have from A.
Once initialized, you can check in either machines if they have any peers
admin.peers []
- Then add in Node B, Node A
admin.addPeer("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303") true
Once this is done, the two Nodes now are connected and would receive any contracts or events happening in either A or B.
You can check this by,
admin.peers
- Please note this linkage between the nodes would only stay until one of the node goes down. To make the linkage permanent- Add the node as a static peer.
- Create a file static_nodes.json and place it your data directory. Please refer to the links below.
References -
https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network How to use static-nodes.json / trusted-nodes.json to prevent connection loss on private network? https://github.com/ethereum/go-ethereum/wiki/Management-APIs
It's web3j
feature/issue and you can change this behaviour: https://github.com/web3j/web3j/issues/231
Best Answer
When you create a new test network, you define a genesis block in a JSON file. In that JSON file you can set difficulty. If you set difficulty very low, the blocks will be discovered very fast for the first 100 or so blocks.
However, the difficulty is automatically adjusted such that a new block is found on average every 13 seconds. So a fasst computer will just increase the difficulty, it will, in the long run, not mine faster. You may need to change the source code of Geth and recompile in order to change the 13 second average. Maybe you could lower it to for example 2 seconds? Alternatively, you can start a new genesis block with low difficulty every time you need to test something and then make a new genesis block when the difficulty becomes too high for your patience.
On a mid range laptop a starting difficulty of
0x400
will mine a new block once every second or so.Do not increase the numbers of threads you use for mining. You will just use more power and you will not find blocks faster since the difficulty adjusts automatically.