I'm building an ETH wallet as an exercise to learn more about the Etheruem blockchain. I was wondering what mechanism is used to decide which transaction is executed first.
Suppose the following:
- 2 transactions are sent to the same smart contract at the same time
- Transaction are sent from 2 different accounts
- Transactions have same gas amount
- Both transactions are sent to the Infura node
What decides which one of these two transactions get broadcasted from the mempool of the node first? Further, is the transaction that was broadcasted first going to be included in the next block earlier and considered final always?