notes
notes copied to clipboard
Transaction Execution Guarantees for Ethereum
http://ethos.dev/ pointed me to https://www.anydot.dev/ which seems to be what is described below, though not a market of guarantors, but a single company.
(WIP)
It could be useful to be able to buy the right to execute a transaction at a specific block.
Ethereum provides no mechanism to automatically schedule state transitions or the execution of transactions at a future date. Miners can arbitrarily decide which transactions are included when they mine a new block. It is therefore impossible to guarantee the transaction of funds or execution of smart contracts at a specific block.
Third party systems like provable.xyz allow contracts to schedule a call to themselves in the future, but whether this call will be executed still relies fundamentally on the miners.
It is possible to incentivize miners to include a transaction via system-internal (higher gas prices, executing a transaction that changes state in a way that benefits the miner) or -external means (e.g. bribing in cash, social considerations or physical coercion).
Gas price (in ETH) and ETH price (in fiat currency) are volatile due to varying transaction volume and market demand.
It would be possible to build a system that creates the right incentives for miners to cooperate with this protocol. The following will focus on a system-internal implementation of this protocol:
Proof that miner will be paid when transaction is executed. Proof that miner will not be paid/will receive a penalty if transaction is not executed.
The right (option) to have a set of miners execute a transaction
-
at a specific block id vs block range
-
with specific content (determined at the time of agreement) vs arbitrary content (to be determined in the future)
specific tx wouldn't be very useful due to fixed data and because the nonce is unknown in advance, unless the address is used exactly futurenonce-currentnonce times in between that. Incentive problems there, too
- with a probably preset, fixed gas limit
iff one of the miners in the set actually mines the block.
In Ethereum, the blocks' beneficiary can be queried with the COINBASE opcode.
Not all miners may participate, but those who do could (but cannot be forced to!) supervise/account for each other. Slashing mechanisms may reduce counterparty risk.
It is not possible for a single transaction to call several pieces of code, when the transaction halts, execution stops. So the called smart contract function would have to end the call with a cleanup routine that unlocks miner funds/attests to execution
-> Forwarder?
-
transaction receipt logs/solidity events?
-
transaction may fail
With a secondary tx: tx trie branch up to block hash (op BLOCKHASH can retrieve the 256 most recent block hashes)
third party oracle (e.g. Provable)
Since the mining process is random, contracting a specific miner for a specific block id may not work.
It would be great if most guarantees could be moved offchain.
A contract which allows miners to opt in:
(restrict to recent miners using BLOCKHASH?)
Kinda weird because if setup transactions are onchain, it's a system betting on itself, probably has dark edge cases.
A conglomerate with significant mining power may delay punitive actions for a long time (it seems to be possible to create counter-incentives for miners who mine transactions that cause this, though).
TODO: challenge protocol vs automatic slashing if not redeemed
pragma solidity >=0.5.0 <0.7.0;
/// @title Transaction Execution Guarantees
contract TEG {
mapping(address => uint) public balances;
function blockIncludesTx(uint blockid, bytes32[] memory txrootproof) {
blockhash = getBlockHash(blockid);
verifyTxRootProof(blockhash, txrootproof)
return true;
}
//TODO []txs?
function redeemOrPunish(guarantorsignature, address guarantoraddress, address useraddress, uint guarantorvalue, uint punishmentvalue, uint blockid, bytes32[] memory txrootproof) public {
require (
verifySignature(guarantorsignature, guarantoraddress, useraddress, blockid, guarantorvalue, punishmentvalue),
"Guarantor signature invalid"
);
// check if this specific guarantor included tx? or also allow arbitrary third party?
if (blockIncludesTx(blockid, txrootproof)) {
guarantoraddress.transfer()
} else {
//burn guarantor funds
uint guarantorbalance = balances[guarantoraddress];
//TODO check guarantorbalance > guarantorvaluee
deduct(guarantoraddress, guarantorvalue)
address(0).transfer(guarantorvalue)
}
}
}