Please stop me if I am wrong.
When we call any "state-changing" function of smart contract, this function will be run by all the miners of the mainnet. As a caller, I need to pay this using the ether and whenever I use the metamask, it estimates how much it will cost.
Here is what I am not sure
How to even estimate the number of miners? we don't know how many miners are there or how many of them will run my function? If I paid X amount and there are more miners than I paid, it won't be runnable by other miners.
How is this handled? Am I missing something?