4

The Clique consensus seems to be always sealing a new block at fixed intervals of period seconds, where period is the setting in the genesis block (config.clique.period).

That seems wasteful, indeed Parity's Aura only signs empty blocks when a transaction is recorded or a transfer to another node takes place (normally every 120 seconds, see --reseal-on-txs and --reseal-min-period args).

Is it possible to get geth to work like that? I don't care about immediate resealing, but it would be really nice to skip empty blocks, even if not completely.

  • 6
    In geth if you set clique period to 0, it will only create new block when there is transaction. – jadd22 Aug 9 '18 at 13:10
4

Geth doesn't have a predefined flag to achieve this but you can write and then --preload .js files in geth - I use this approach on our private network to only seal blocks when there are new transactions.

  • hyperlink fixed, sorry - I don't use eth-mine-when-needed, I use a JS file very similar to the answer linked to above. We use Clique as we have no need for PoW on our private network – TC8 Apr 8 '18 at 14:13
  • Interesting, thanks. I got a variant of it to work, though for "X confirmations" I had to run the script on only one of the 2 signer nodes. It probably won't work at all in a 3+ signer setup. – rustyx Apr 9 '18 at 7:35
  • it can work on all signers in a network if you modify the script slightly - if(eth.getBlock("pending").transactions.length > 0 || eth.getBlock("latest").transactions.length > 0) {<start mining>.... This means all sealers will start sealing whenever a new tx is added, even if they miss the trigger in the tx pool – TC8 Apr 9 '18 at 9:42
0

AFAIK it's not possible to do that with GETH without making significant modifications to the source code. There are some "tricks" that you can use on PoW networks to only mine when transactions have been committed to the blockchain. I imagine you could do the same with PoA. That being said, if you want to skip empty blocks, why not just go with Aura and Parity?

How to stop mining unwanted blocks on private net on geth ethrereum

0

All you have to do is set period:0 in the genesis.json file to achieve this sealing behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.