Reputation: 339
If I have a function that counts up by 1 every time someone calls it, what happens if 10 people all call the function at the same time, during the same block? Without knowing for sure, I see two possibilities.
A particular sender is chosen to successfully call the function, and then the counter is only increased by 1 1a) If this is the case, what happens to the other 9 senders? Do they get pushed to the next block, hoping to succeed again? This process would repeat until their request expires (TTL) I suppose.
All 10 are able to successfully call the function, and the counter is increased by 10 in the next block. 2a) If this is the case, how is it possible that there are no overlaps on the counting if the counter is not yet submitted to the blockchain? Who gets to increase it from 1->2, 2->3, 3->4 and so on?
Is there something else that happens?
Upvotes: 1
Views: 78
Reputation: 43521
The second option is correct. All transactions within a block are run in series.
Specifics depend on each network and miner (PoW) / validator (PoS), but generally in most cases, transactions within a block are ordered by gasPrice
from the highest to the lowest, as that's usually the most profitable option for the block producer (who decides on the transactions order before executing them and publishing the block).
Upvotes: 2