all the miners run the smart contract code. The algorithm has random run time if run properly but you could cheat by "randomly guessing" the correct answer, which isn't a guess at all just preknowledge of when the code quits running.
Ethereum and other smart contract blockchains have to settle money to prevent people from exploiting.
Its starting to sound like you are downplaying the flaws in "smart contract" cryptocurrencies. You don't seriously believe that anyone can run any code and nobody can design malicious code... do you?? It's a trust based inner currency of switzerland.
Trust me, I more than understand someone could design malicious code. But I personally just lack the context. I don't quite understand the idea Ethereum network functionality myself. If I say something that seems to make little sense it's likely just because my knowledge of the network is limited, and by limited I mean nonexistent. Just trying to figure out how you would actually integrate it within the network is all
You said 'all the miners run the smart contract code'. Do you mean that they use the code themselves in some way to leverage it against the algorithm they're attempting to solve for the block? Or do you mean that when they run and attempt to solve an algorithm they'll attempt to solve the code within the smart contract? If you mean the latter of the two, then how do the miners access the smart contract code?
I was always under the impression that the process was something like:
1. network generates algorithm in need of solving --> 2. miner receives algorithm and begins to work --> 3. work is comprised of throwing as many computations as possible against the algorithm in hopes of solving it --> 4. miner solves the algorithm, relays it to network --> 5. miner is granted block reward, etc.
and
MY interpretation of what you're saying is that the process could be exploited like:
1. network generates algorithm in need of solving --> 2. you know the answer to the algorithm --> 4. miner solves the algorithm, relays it to network --> 5. miner is granted block reward, etc.
which would effectively cut out the third step in the process, reducing the time required to solve a block, thus granting you the ability to receive the block reward all on your own.
What confuses me, though, is where the smart contract comes in to play. I don't quite see how it could affect the miner unless the algorithm that generates the block and the required problem needing to be solved to produce the block somehow produces the same algorithm as the exploit requires. You said I may be 'downplaying the flaws in smart contract cryptocurrencies' but I assure you I'm not, I just don't understand/have knowledge of any of these flaws
In short, It seems to me that you're saying 1 + 1 = 2 and mining/smart contracts (being 1 and 1) are easily connected resulting in the output of 2 (representing the exploit); but my understanding was that it was set up more along the lines of 0 + 2 = 2 or 2 + 0 = 2 and neither the miner nor the smart contract have any communication with one another related to the solution of a block. I can't wrap my head around how a smart contract affects the solution of a block to exploit the reward. Would be great to have you clarify my misunderstandings!