2

I apologize in advance if my question is dumb.

I want to make a smart contract which will handle money from the outside. However, I haven't been able to find any information about multithreading on the Ethereum network.

Does it work as a multithreaded environment, or are all transactions in a block executed in a linear fashion? I'm asking since I don't know is there need for the introduction of custom-made atomic variables.

Mikko Ohtamaa
  • 22,269
  • 6
  • 62
  • 127
lizardev
  • 73
  • 4

2 Answers2

2

You are not concerned if EVM implementation itself is multithreaded or not (there are several implementations, you do not care.)

Does it work as a multithreaded environment, or are all transactions in a block executed in a linear fashion

Yes. All transactions are atomic by the definition. The whole block gets executed, or none of a block gets executed. You do not need to worry about atomicity as a developer. However, you still need to worry about re-entrancy.

If a transaction cannot get into a block, miners will try to fit into another block.

More information about the transaction lifecycle here.

Mikko Ohtamaa
  • 22,269
  • 6
  • 62
  • 127
  • 1
    Yes I have read up a lot about re-entrancy, but this specific question came to my mind because I didn't know whether I should worry about data consistency, locks, mutexes etc. – lizardev Jul 04 '21 at 23:44
0

If you're looking for multithreading, look at Solana. EVM is single-threaded. https://fullstacks.org/materials/ethereumbook/14_evm.html