1

I have the following contract deployed on my PoA network with two sealers, node1 and node2.

Let's assume a user, user1, submits a transaction with call to process() method to node1 and another user, user2, submits a similar transaction with call to same contract method to node2.

If node1 seals the block first, What will happen to user2's transaction? It won't be included in the block?

If a user knows which signer will seal a block next, He can submit a transaction to that sealer to win the race. Does PoA/Clique consensus employ some mechanism to overcome this?

pragma solidity ^0.4.7;

contract raceTest {

    uint8 x;
    constructor () {
       x = 1;
    }

    function process() public {
        require(x == 1);

        x = 0;
    }
}

1 Answers1

1

From my experience, "race conditions" can still happen in PoA.

In your example: If we are assuming, by node1 sealing the block first that it is the block that is accepted into the canonical chain, then node2's block would then become an uncle. user2's transaction would be in this uncle and therefore not appear in the canonical chain. However, since you through the "require" in there, I'll talk to that as well. If user1 called proccess() on the new contract, then user2 called process() BEFORE the new block had been mined, user2 would NOT fail the require. user2 would effectively set x to be 0. Who gets the honor of being the the setter depends on which transaction makes it into the final chain.

I have run into several instances where unexpected results occur due to similar circumstances.

Hope this helps!