-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delegated txs #89
Delegated txs #89
Conversation
contracts/generic/AugmintToken.sol
Outdated
/* Transfers based on an offline signed transfer instruction. */ | ||
function delegatedTransfer(address from, address to, uint amount, string narrative, | ||
uint minGasPrice, /* client provided gasPrice on which she expects tx to be exec. */ | ||
uint maxExecutorFee, /* client provided max fee for executing the tx */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specify units of measure (e.g. gas price is in ETH. is fee in ETH or tokens?)
contracts/generic/AugmintToken.sol
Outdated
) | ||
external returns(bool) { | ||
|
||
require(!noncesUsed[nonce], "nonce already used"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the nonce should be included in a hash along with all other parameters (or just use the signature) and we should store the used hashes (not the nonce). otherwise there's a security issue: I could censor transactions by front-running the nonce from the mem-pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, you could get away with much less bits for the nonce then. you just need to avoid collisions between transactions with the same from/to/amount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- nonce was already included in the hash
- pushed a change to store hashes used instead of nonce
- lower nonce bits: based on my tests passing+keccak256 of uint32 or bytes4 types actually consume slightly more gas than uint256 or bytes32. Maybe keccak256 is padding each param to same size?
contracts/generic/AugmintToken.sol
Outdated
external returns(bool) { | ||
|
||
require(!noncesUsed[nonce], "nonce already used"); | ||
require(tx.gasprice >= minGasPrice, "tx.gasprice must be >= minGasPrice"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we care about the gas price at this point? the transaction is already being processed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea is that client and "executor" agrees on an executorFee based on a minimum gasPrice. That's what the client signs. This way dishonest executors can't make "extra profit" on submitting tx on lower gas price than the "agreement".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the goal is to minimize the time it takes for my tx to hit the blockchain, not to maximize the profits of miners :) this is not an incentive (or disincentive) for executors.
the only way to ensure that my tx hits the chain in a timely manner is to have some competition between executors. if there's only a single executor for my tx, they may delay my tx for days even if i specified a high gas price. competition would keep them motivated to do their job well.
if an executor was able to have my transaction processed quickly at a lower gas price, they should keep the change. however, if they skimp on the gas too much, competition will beat them to the punch.
(i could also think of more incentives for timely processing, such as expiration dates or rewards diminishing over time.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as for now do you suggest to get rid of minGasprice ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
@@ -26,6 +26,7 @@ contract AugmintTokenInterface is Restricted, ERC20Interface { | |||
mapping(address => mapping (address => uint256)) public allowed; // allowances added with approve() | |||
|
|||
TransferFeeInterface public feeAccount; | |||
mapping(bytes32 => bool) public noncesUsed; // record nonces used by delegatedTransfer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see a prior comment (store tx hashes, not nonces)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, done
contracts/generic/AugmintToken.sol
Outdated
) | ||
external returns(bool) { | ||
|
||
require(!noncesUsed[nonce], "nonce already used"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, you could get away with much less bits for the nonce then. you just need to avoid collisions between transactions with the same from/to/amount.
contracts/generic/AugmintToken.sol
Outdated
external returns(bool) { | ||
|
||
require(!noncesUsed[nonce], "nonce already used"); | ||
require(tx.gasprice >= minGasPrice, "tx.gasprice must be >= minGasPrice"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the goal is to minimize the time it takes for my tx to hit the blockchain, not to maximize the profits of miners :) this is not an incentive (or disincentive) for executors.
the only way to ensure that my tx hits the chain in a timely manner is to have some competition between executors. if there's only a single executor for my tx, they may delay my tx for days even if i specified a high gas price. competition would keep them motivated to do their job well.
if an executor was able to have my transaction processed quickly at a lower gas price, they should keep the change. however, if they skimp on the gas too much, competition will beat them to the punch.
(i could also think of more incentives for timely processing, such as expiration dates or rewards diminishing over time.)
contracts/generic/AugmintToken.sol
Outdated
|
||
bytes32 txHash = keccak256(this, from, target, amount, data, minGasPrice, maxExecutorFeeInToken, nonce); | ||
|
||
require(!delegatedTxHashesUsed[txHash], "txHash already used"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest factoring common code between the two delegated... functions.
AugmintToken.delegatedTransfer()
anddelegatedTransferAndNotify()
see Transferring A-EUR without ETH #84