Duplication of events in permissioned geth Chain with clique PoA consensus algorithm

by Henk van der Sloot   Last Updated September 10, 2019 14:28 PM

I have an Ethereum chain running on my local host via geth and i am using the clique PoA Algorithm. I have 4 authority nodes so the number of Nodes allowed to sign a block should always be 1 because of ( N - (N/2 + 1)) with N being the number of authority nodes. I also have a Node.js script that is syncing with the events happening in the chain. I am using an eventListener like this:

AboStoreContract.events.allEvents({fromBlock: "latest"})
    .on('data', (event) => { handleEvent(); }).on("error", console.error);

The connection between node.js and my node running on localHost is made through the geth.ipc file like this:

const web3 = new Web3("\\\\.\\pipe\\geth.ipc", net);

Now my issue is that often the same event gets duplicated. its always 3 times if duplicated. I started inspecting the transactionHash and blockHash and it seemed like 2 duplications have the same transactionHash + blockHash and then the 3rd duplication has the same transactionHash but a different blockHash.

The only reason how i can explain this is due to a chainreorganization going on, but as i only have 4 authority/signing nodes there can, due to clique consensus algorithm, at all times be only one node allowed to sign. So there cant be a race going on that leads to making use of the GHOST protocol to see which fork has the higher "value"

I know that i am supposed to wait for a certain number of Blocks so i can be sure that the events are not lying in a forked chain that gets thrown away, but in my usecase blocks are only created when a transaction happens, so i have to react to events right away.

So the question is: why do i get duplicated events, when chain reorg is impossible? or is it still possible and i dont understand the clique algorithm?

thanks in advance



Related Questions


Updated June 14, 2018 18:28 PM

Updated May 01, 2019 15:28 PM

Updated August 11, 2017 20:28 PM

Updated September 05, 2017 11:28 AM

Updated February 11, 2018 21:28 PM