Is it possible for a contract to pay for its own execution?
I'm contemplating the possibilities of an online space-explore-mine-trade-shoot-up-type game (think a distributed turn-based EVE Online) on the Ethereum network. One enormous possibility would be for "player"-controlled ships to be controlled by contracts instead. For these contracts to act is perfectly possible, but how about reacting?
Suppose you wanted a contract to automatically order a counterattack against anyone entering its territory. It can't check by itself, because contracts cannot call themselves. The naive solution is for the game contract to call the player contract under certain conditions, but the obvious abuse case is for the contract to deliberately waste gas so that whoever called the game contract in the first place (most likely the opponent) will have to pay an extraneous amount of real money to begin the attack.
Yes, the game contract could call player contracts with gas limits, but the next abuse case is to create insane numbers of player contracts (or in my contemplated case, insane numbers of ships), so that anyone who would make a move would have to sub-call player contract after player contract and still waste extraneous amounts of real money. And a player obviously cannot be allowed to pick which other player contracts to pay for.
And, mind you, this is not limited to games. Imagine a distributed exchange with contract-based bots (ignore for the moment that their strategy would be public.) An attacker could essentially DDoS the exchange's bot system with useless bots.
The options I have thought of are two:
1) The player who wants a reactive bot will have to write a client-side one, and either host it himself or let a centralized server host it. This is essentially reinventing the wheel, poorly.
2) Have the reacting contracts reimburse the acting player for the gas (via the game contract, to prevent oh-I'll-you-later shenanigans.) This feels a little strange, and the acting player would still have to pay the full cost up front. Still, I can't see why it wouldn't work.
Am I correct in believing that there is no "turn-own-ETH-into-gas" opcode for the sake of miners knowing what they are getting into? If so, these might be the only two options.