-
Notifications
You must be signed in to change notification settings - Fork 413
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
ERC20 Approval event conformance #76
Comments
@nventuro provided a link to the discussion where they came up to the decision to emit |
If you want to reconstruct the allowance fron LOGS (which is not really recommended, as LOGS shouldnt be relied upon for historical data) you can easily recalculate it from the Approval + Tranfer events. I dont think we should add additional logs here. For the record, |
@MrChico main OZ point was that it is not possible to recover state based on Approval+Transfer events since account can transferFrom to different destination than its own address. |
Using logs to recover state is not a good practice. I'm not sure that one would want to condone such behaviour |
@MrChico is there any particular reason why you wouldn't rely on logs?
Recovering state is not the only issue: when using |
That sounds like recovering state to me. Determining the allowance of a user is easy, you just fetch the corresponding |
The two basic use cases for events are: a) create a timeline for state, and b) react to something. |
@nventuro case |
For clarity, the thing that is a bad practice is using logs to recover ancient data like many dapps do. What logs are useful for is people who want to monitor/track changes live (which they then may store in an external database for historical lookup). In general, you log basically the same thing regardless of whether the user is just tracking head or trying to lookup ancient state. The thing that is a bad practice is relying on those logs being available forever. |
Thanks for everybody's comments. I dont have a strong feeling about this, and it seems like others do. So in the case of this contract one would add another event in the TransferFrom clause that actually diminishes the allowance? That would be L75 in dai.sol |
One last feeble attempt at ERC777: I think the right solution here is to have DAI be an ERC777 token instead of ERC20. ERC777 is backward compatible with ERC20, but it fixes a lot of mistakes that were made in ERC20, including this one. |
@MicahZoltu sorry, but I can't understand why anyone would prefer ERC777 instead of ERC20. For me, it seems like an overdeveloped solution with the not clear idea behind it. Additionally, |
@k06a ERC-777 operators are not the same as ERC20 approvals, they are intended for "this address is allowed to operate on my tokens on my behalf" rather than "I want to transfer some tokens as part of a larger transaction". For the latter, you would use Unlike ERC20, ERC777 went through a lot of rounds of feedback between a lot of people who have worked with ERC20 (and other) tokens in the past. Everything in it is incredibly deliberate (unlike ERC20) and serves a distinct purpose. If you think something in ERC777 doesn't make sense, I recommend reading through the discussion history for its development as I can almost guarantee that whatever concern you have was brought up and debated. |
Yeah. Not a fan of 777. Calls to unknown code goes strictly against the praxis of this codebase |
@MrChico This would be at the edge and for ecosystem interoperability. Already vat.dai doesn't follow any standard, the DAI token contract exists explicitly for ecosystem integration and standardization. Basically everything about the DAI token contract goes against the praxis of this codebase because it is an integration point and it has intentionally been designed to live external to the rest of Maker so that it can go against the norms found throughout the maker codebase without having to put the rest of the Maker codebase at risk. |
I found that OZ ERC20 implementation differs with your DAI implementation.
OZ ERC20 emits
Approval
event on every approval change:approve
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol#L217transfer
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol#L63transferFrom
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol#L100_burnFrom
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol#L228DAI implementation emits
Approval
event only insideapprove
method:approve
https://github.com/makerdao/dss/blob/master/src/dai.sol#L100transfer
https://github.com/makerdao/dss/blob/master/src/dai.sol#L76transferFrom
https://github.com/makerdao/dss/blob/master/src/dai.sol#L76burn
https://github.com/makerdao/dss/blob/master/src/dai.sol#L92ERC20 Token Standard tells:
For me it seems OZ implementation should be fixed to conform, or maybe they have some reasons to follow this behavior.
The text was updated successfully, but these errors were encountered: