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;
    }
}
3
  • 2
    Possible duplicate of Race conditions when calling remote contracts
    – Ayushya
    Commented Jul 29, 2018 at 17:23
  • @Ayushya Perhaps. But that question is for PoW. Every article I can find about PoA says that race cannot occur in a PoA network. Commented Jul 30, 2018 at 15:12
  • That refers to the race for blocks to become part of the chain. For transactions, there is never a race condition
    – Ayushya
    Commented Jul 30, 2018 at 20:22

1 Answer 1

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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