CEP-2612: Permit Extension#99
Conversation
davidatwhiletrue
left a comment
There was a problem hiding this comment.
@zie1ony , please check my comments.
| that produces the same allowance state change as `approve` while being callable | ||
| by a third party. | ||
|
|
||
| ## Prior art |
There was a problem hiding this comment.
Almost every CEP has a Motivation section. We may have one here too.
There was a problem hiding this comment.
We are porting a standard here, not inventing anything new.
|
|
||
| The CEP-2612 extension is defined by: | ||
| - one new entrypoint (`permit`), | ||
| - the EIP-712 typed data definition for the `Permit` struct, |
There was a problem hiding this comment.
'...and the domain separator'
|
|
||
| Below definitions use Rust syntax, but they are not Rust specific. | ||
|
|
||
| ### Entrypoint interface |
| /// disables the expiry check. | ||
| /// - `public_key` is the signer's Casper public key. | ||
| /// - `signature` is `public_key`'s signature over the EIP-712 digest | ||
| /// of the `Permit` typed data (see below). |
There was a problem hiding this comment.
I'd remove (see below) becuase this is a code block.
| /// - the allowance of `spender` over `owner` is set to `value` (i.e. | ||
| /// the same effect as `owner` calling `approve(spender, value)`), | ||
| /// - the `owner`'s permit nonce is incremented by one, | ||
| /// - a CEP-18 `SetAllowance { owner, spender, allowance: value }` |
There was a problem hiding this comment.
just SetAllowance { owner, spender, allowance }
There was a problem hiding this comment.
This is ok, because value is the parameter in permit function. This link makes sense.
|
|
||
| 1. `signature` is a valid signature of `public_key` over the EIP-712 | ||
| digest of the `Permit` typed data (described below), AND | ||
| 2. `owner == Address::from(public_key)` — i.e. `owner` is the account |
There was a problem hiding this comment.
Is Address::from() correct here?
There was a problem hiding this comment.
Yes. It only represents the logic.
There was a problem hiding this comment.
I'm not convinced. Address is an Odra type. It doesn't exist in casper_types. The reader doesn't need to know that an Address is an account hash. It'd be more explicit.
| The encoded message data hashed alongside the typehash is the | ||
| concatenation, in order, of: | ||
|
|
||
| - `owner` encoded as an EIP-712 `address` (32 bytes, big-endian, left-padded), |
There was a problem hiding this comment.
In Casper, owner and spender are a hash of an Account Hash or a (package) Hash (the hash of 0x00 or 0x01 prefix || 32 bytes). I would mention it here. and remove big-endian, left-padded
There was a problem hiding this comment.
done, I mentioned how address is serialized.
| - `nonce` encoded as an EIP-712 `uint256` (32 bytes, big-endian) — equal | ||
| to the current on-chain `permit_nonces[owner]` value at the time the | ||
| signature was produced, | ||
| - `deadline` encoded as an EIP-712 `uint64` (32 bytes, big-endian, |
There was a problem hiding this comment.
“EIP-712 uint64" does not exist. u64 or uint256. let’s use the same here as in CEP-3009 for validAfter and validBefore
| The final digest is computed using the standard EIP-712 rule | ||
| (`keccak256("\x19\x01" || domainSeparator || keccak256(typeHash || encodedData))`). | ||
|
|
||
| The EIP-712 `domainSeparator` uses: |
There was a problem hiding this comment.
Not aligned with casper-eip-712 domain type:
EIP712Domain(string name,string version,string chain_name,bytes32 contract_package_hash).
Worth to add the type string to this section too.
Also, recommend to use CAIP-2 for chain_name as here.
There was a problem hiding this comment.
I updated the document, but not sure if this is what you wanted. Please check
There was a problem hiding this comment.
I don't see the domain type in the document. Because it differs from the EIP-2612 domain type, I think we need to include it.
EIP712Domain(string name,string version,string chain_name,bytes32 contract_package_hash)
Also, check this comment: https://github.com/casper-network/ceps/pull/99/changes#r3272351456
| - The chain name is stored under the key `chain_name` with the type | ||
| `String`. | ||
|
|
||
| #### Permit nonces |
There was a problem hiding this comment.
Should we discuss non-sequential nonces? I realize this will diverge from the ERC-2612 specification. But it’s a limitation and something Permit2 solved if I'm not mistaken.
Moving to random nonce probably means having a cancel_permit-like entry point, and a different structure to store used values.
There was a problem hiding this comment.
I don't think we need to. We do 2612 to be compatible with possible 2612 users, but I'd use 3009 over 2612 in any case.
davidatwhiletrue
left a comment
There was a problem hiding this comment.
@zie1ony , see my comments.
| The final digest is computed using the standard EIP-712 rule | ||
| (`keccak256("\x19\x01" || domainSeparator || keccak256(typeHash || encodedData))`). | ||
|
|
||
| The `domainSeparator` is defined as: |
There was a problem hiding this comment.
This is not the domain separator for casper.
See here:
https://github.com/casper-ecosystem/casper-eip-712#casper-native-domain-example
EIP712Domain(string name,string version,string chain_name,bytes32 contract_package_hash)
| The final digest is computed using the standard EIP-712 rule | ||
| (`keccak256("\x19\x01" || domainSeparator || keccak256(typeHash || encodedData))`). | ||
|
|
||
| The EIP-712 `domainSeparator` uses: |
There was a problem hiding this comment.
I don't see the domain type in the document. Because it differs from the EIP-2612 domain type, I think we need to include it.
EIP712Domain(string name,string version,string chain_name,bytes32 contract_package_hash)
Also, check this comment: https://github.com/casper-network/ceps/pull/99/changes#r3272351456
|
|
||
| `Address` encoding is defined as 33 bytes, where the first byte is a type tag: | ||
| - `0x00` for `AccountHash`, | ||
| - `0x01` for `PackageHash`. |
There was a problem hiding this comment.
Hash instead of PackageHash?
o "0x01 for a package Hash"
Rendered