1

If there are three nodes, and the contract is like that

contract IncentiveMechanism{
    uint public money;
    function setMoney(uint m){
        money = money+m;
    }
}

if three nodes call the function setMoney to set the value of money at the same time, can blockchain get the sum of these three operation?

Lance li
  • 33
  • 5
  • 1
    The value of money will become the sum of all 3 inputs if and only if all 3 transactions complete successfully AND no arithmetic overflow occurs in either one of them. – goodvibration Apr 01 '19 at 12:21
  • three different nodes will also get the sum of all 3 inputs? They don't need to mine and get one of the value? like information in this page https://ethereum.stackexchange.com/questions/62160/how-blockchain-can-handle-the-concurrency – Lance li Apr 01 '19 at 12:46
  • There is no concurrency. The blockchain serializes transactions and executes them in sequence. The state will evolve in an orderly fashion. – Rob Hitchens Apr 01 '19 at 13:51

1 Answers1

2

It is not nodes who call functions on smart contracts. It is private key owners and other smart contracts who do this.

Ethereum transaction is "executed" when it is included into block. All function invocations within one transactions are strictly ordered according to transaction order of execution. All transactions within block are strictly ordered and are executed in this order. All blocks are strictly ordered as well, so there is no concurrency in Ethereum world, thus no concurrency issues.

Mikhail Vladimirov
  • 7,313
  • 1
  • 23
  • 38