Hi @alexvandesande,
Permissions
Ah, good idea on onlyOwner
, &c! I hadn’t considered these, but they’re exceedingly common. Will add!
There actually is a Not allowed Yet
An earlier draft even was called that verbatim, but we reprhrased it as 0x13 Awaiting Permission
.
Sub-codes
We’ve explored this, and are not a fan. There’s an infinite level of granularity, and the combinatoral complexity makes translation nearly impossible. It’s a less-is-more case: by limiting ourselves (if 256 is “limited” ), we can do more with each code. Situations that are deeply context-specific can come along something like one of the following:
returns (byte status, string message)
// ex. (hex"A0", "System went boom")
returns(byte status, uint8 customSubcode)
// ex. (hex"10", 1)
returns (byte status, uint8 requiredAuthLevel, address[] requestAuthFrom)
// ex. (hex"10", 4, [0x123f6..., 0x3c6ae...])
Integer Overflow
First let me say that the fact that overflows are part of the EVM spec drives me crazy. I could rant all day about this, so I’ll leave it at that
I suppose that it could be covered under 0x25 Out of Range
, but perhaps there is a case for low-level codes to cover arithmetic errors to cover the same cases as SafeMath
. I’m of two minds on this one:
1. Status Codes are for Communication
Integer overflow is a bug and should never be allowed to occur in a contract. Codes are meant for communicating between contracts, or for user feedback, not debugging. It also may be a bit granular/lacks semantics. As an end user, I don’t care that 0x66 Integer Overflow
, I care that 0xA6 Namespace Full
.
2. Overflows are Common
Because of the way the EVM is designed, over- and underflows are sadly an easy mistake to make. Maybe communicating that there was an arithmetic error would have some internal utility? Translations here are better than not having them, for instance.
I’ll be honest: working through the idea has pushed me back into the “status codes are for communication” camp. 0x66 Integer Overflow
(or similar) isn’t terribly helpful, and can probably be handled with a simple revert. A more semantically rich message would be more helpful to a user. Again, not to say that I’m totally opposed to the idea, but I’m just not convinced yet.
I’d love to hear any further thoughts that you have!