From c5bd66d37ca83d20d7e573360742b65a1676599e Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Fri, 2 Dec 2022 13:30:20 +0100 Subject: [PATCH 01/17] New EIP: Nonce management for signature-based operations powered on EIP-712 --- EIPS/eip-X.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 EIPS/eip-X.md diff --git a/EIPS/eip-X.md b/EIPS/eip-X.md new file mode 100644 index 00000000000000..bee8987884da7e --- /dev/null +++ b/EIPS/eip-X.md @@ -0,0 +1,55 @@ +--- +eip: TBD +title: Nonce management for signature-based operations powered on EIP-712 +description: Extends EIP-712 and unifies EIP-2612 with many others +author: Anton Bukov (@k06a), Mikhail Melnik (@zumzoom) +discussions-to: TBD +status: Draft +type: Standards Track +category: ERC +created: 2022-12-02 +requires: 712 +--- + +## Abstract + +This EIP defines interface allowing multiple other EIPs. This interface is designed to be used in the context of [EIP-712](./eip-712.md) and allows to define abstract operations that can be executed in behalf of signer. + +## Motivation + +Multiple EIPs define operations that can be executed in behalf of signer and sometime introduce method naming collision and other. For example, [EIP-2612](./eip-2612.md) defines both `permit` and `nonces` methods, but gives no clue that `nonces` is related to permit operation. In case of multiple same-level EIPs implemented within one smart contract (for example: permit, delegate, vote) it's obvious that they should use different nonces. + +## Specification + +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. + +- Smart contract implementing EIP-712 MUST also implement the folllowing interface: + ```solidity + interface EIP_TBD { + /// @dev Returns next nonce for the signer in the context of the operation typehash + /// @param signer The signer address + /// @param typehash The operation typehash + function nonces(address signer, bytes32 typehash) external view returns (uint256); + + /// @dev Increments nonce for the signer in the context of the operation typehash + /// @param signer The signer address + /// @param typehash The operation typehash + function useNonce(address owner, bytes32 typehash) external returns (uint256); + } + ``` + +## Rationale + +TBD + +## Backwards Compatibility + +Fully backward compatibile with EIP-712. + +## Security Considerations + +TBD + +## Copyright + +Copyright and related rights waived via [CC0](../LICENSE.md). From aa01545232c2a42360a732e4e21b258838bac435 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Fri, 2 Dec 2022 13:49:15 +0100 Subject: [PATCH 02/17] Rename methods to avoid collision with EIP-2612 (aka Permit) --- EIPS/eip-X.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-X.md b/EIPS/eip-X.md index bee8987884da7e..ba38cf429bbc52 100644 --- a/EIPS/eip-X.md +++ b/EIPS/eip-X.md @@ -29,12 +29,12 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S /// @dev Returns next nonce for the signer in the context of the operation typehash /// @param signer The signer address /// @param typehash The operation typehash - function nonces(address signer, bytes32 typehash) external view returns (uint256); + function operationNonces(address signer, bytes32 typehash) external view returns (uint256); /// @dev Increments nonce for the signer in the context of the operation typehash /// @param signer The signer address /// @param typehash The operation typehash - function useNonce(address owner, bytes32 typehash) external returns (uint256); + function useOperationNonce(address owner, bytes32 typehash) external returns (uint256); } ``` From b7512967e92502d43ed45a7286ec8bbfa7334ecb Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Fri, 2 Dec 2022 13:51:57 +0100 Subject: [PATCH 03/17] Fix typo --- EIPS/eip-X.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-X.md b/EIPS/eip-X.md index ba38cf429bbc52..b065fbacdebc93 100644 --- a/EIPS/eip-X.md +++ b/EIPS/eip-X.md @@ -1,6 +1,6 @@ --- eip: TBD -title: Nonce management for signature-based operations powered on EIP-712 +title: Nonce management for signature-based operations powered by EIP-712 description: Extends EIP-712 and unifies EIP-2612 with many others author: Anton Bukov (@k06a), Mikhail Melnik (@zumzoom) discussions-to: TBD From 7a211fd5b8d1bf2ee015236a2f2ef8269c597d98 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Fri, 2 Dec 2022 14:00:38 +0100 Subject: [PATCH 04/17] Fix bug --- EIPS/eip-X.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/EIPS/eip-X.md b/EIPS/eip-X.md index b065fbacdebc93..30e0705a0b83c4 100644 --- a/EIPS/eip-X.md +++ b/EIPS/eip-X.md @@ -31,10 +31,9 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S /// @param typehash The operation typehash function operationNonces(address signer, bytes32 typehash) external view returns (uint256); - /// @dev Increments nonce for the signer in the context of the operation typehash - /// @param signer The signer address + /// @dev Increments nonce for the caller in the context of the operation typehash /// @param typehash The operation typehash - function useOperationNonce(address owner, bytes32 typehash) external returns (uint256); + function useOperationNonce(bytes32 typehash) external returns (uint256); } ``` From 8a970f1b5eec71ab0dc68e6714619f8f13c94ea8 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Fri, 2 Dec 2022 17:51:05 +0100 Subject: [PATCH 05/17] Changes and fixes --- EIPS/eip-X.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/EIPS/eip-X.md b/EIPS/eip-X.md index 30e0705a0b83c4..8daa363824bfd4 100644 --- a/EIPS/eip-X.md +++ b/EIPS/eip-X.md @@ -23,17 +23,32 @@ Multiple EIPs define operations that can be executed in behalf of signer and som The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. -- Smart contract implementing EIP-712 MUST also implement the folllowing interface: +- Smart contract implementing EIP-712 MUST also implement the following interface: ```solidity - interface EIP_TBD { + interface ISequentialOperations { /// @dev Returns next nonce for the signer in the context of the operation typehash - /// @param signer The signer address /// @param typehash The operation typehash - function operationNonces(address signer, bytes32 typehash) external view returns (uint256); + /// @param signer The signer address + function operationNonces(bytes32 typehash, address signer) external view returns (uint256); /// @dev Increments nonce for the caller in the context of the operation typehash /// @param typehash The operation typehash - function useOperationNonce(bytes32 typehash) external returns (uint256); + /// @return success True if nonce has not been invalidated previously + function useOperationNonce(bytes32 typehash, uint256 nonce) external; + } + + interface IParallelOperations { + /// @dev Returns true if the operation id was not invalidated previously + /// @param typehash The operation typehash + /// @param signer The signer address + /// @param operationId The operation id + function isOperationIdAvailable(bytes32 typehash, address signer, uint256 operationId) external view returns (bool); + + /// @dev Invalidates operation id for the caller in the context of the operation typehash + /// @param typehash The operation typehash + /// @param operationId The operation id + /// @return success True if nonce has not been invalidated previously + function useOperationId(bytes32 typehash, uint256 operationId) external; } ``` From 1aeb60b2aa0d378d881c42db89adb57943fd34ed Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Fri, 2 Dec 2022 17:52:13 +0100 Subject: [PATCH 06/17] Change title --- EIPS/eip-X.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-X.md b/EIPS/eip-X.md index 8daa363824bfd4..a4aedee742ed9b 100644 --- a/EIPS/eip-X.md +++ b/EIPS/eip-X.md @@ -1,6 +1,6 @@ --- eip: TBD -title: Nonce management for signature-based operations powered by EIP-712 +title: Invalidation abstraction for signature-based operations powered by EIP-712 description: Extends EIP-712 and unifies EIP-2612 with many others author: Anton Bukov (@k06a), Mikhail Melnik (@zumzoom) discussions-to: TBD From c54471cc993e47c83f9f9af71f621dd4ffc13981 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Tue, 6 Dec 2022 00:45:10 +0100 Subject: [PATCH 07/17] Introduce threads of ids per signer per beneficiary --- EIPS/eip-X.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/EIPS/eip-X.md b/EIPS/eip-X.md index a4aedee742ed9b..cee4f612da3823 100644 --- a/EIPS/eip-X.md +++ b/EIPS/eip-X.md @@ -13,11 +13,15 @@ requires: 712 ## Abstract -This EIP defines interface allowing multiple other EIPs. This interface is designed to be used in the context of [EIP-712](./eip-712.md) and allows to define abstract operations that can be executed in behalf of signer. +This EIP extends [EIP-712](./eip-712.md) and defines two ways to validate and invalidate signature-based operations. Such operations as [EIP-20](./eip-20.md) permit operation defined in [EIP-2612](./eip-2612.md). This EIP provides two ways to track such operations and invalidate them: +- main sequnce of incremental nonces per signer +- sequence of incremental ids per signer per beneficiary ## Motivation -Multiple EIPs define operations that can be executed in behalf of signer and sometime introduce method naming collision and other. For example, [EIP-2612](./eip-2612.md) defines both `permit` and `nonces` methods, but gives no clue that `nonces` is related to permit operation. In case of multiple same-level EIPs implemented within one smart contract (for example: permit, delegate, vote) it's obvious that they should use different nonces. +Same abstraction could be utilized by mutilple signature-based operations, moreover existing EIPs like [EIP-2612](./eip-2612.md) could be considered as fully compatible with the EIP. + +Multiple EIPs define operations that can be executed in behalf of signer and sometime introduce method naming collisions and other. For example, [EIP-2612](./eip-2612.md) defines both `permit` and `nonces` methods, but gives no clue that `nonces` is related to permit operation. In case of multiple same-level EIPs implemented within one smart contract (for example: permit, delegate, vote) it's obvious that they should use different nonces. ## Specification @@ -25,33 +29,33 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S - Smart contract implementing EIP-712 MUST also implement the following interface: ```solidity - interface ISequentialOperations { - /// @dev Returns next nonce for the signer in the context of the operation typehash + interface ISignatureOperations { + /// @dev Returns next nonce for the signer in the context of the operation typehash and operation beneficiary /// @param typehash The operation typehash /// @param signer The signer address function operationNonces(bytes32 typehash, address signer) external view returns (uint256); - /// @dev Increments nonce for the caller in the context of the operation typehash + /// @dev Returns next id for the signer in the context of the operation typehash and operation beneficiary /// @param typehash The operation typehash - /// @return success True if nonce has not been invalidated previously - function useOperationNonce(bytes32 typehash, uint256 nonce) external; - } + /// @param signer The signer address + /// @param beneficiary The address of the spender, delegate, or other beneficiary of the transaction + function operationIds(bytes32 typehash, address signer, address beneficiary) external view returns (uint256); - interface IParallelOperations { - /// @dev Returns true if the operation id was not invalidated previously + /// @dev Increments nonce for the caller in the context of the operation typehash and operation beneficiary /// @param typehash The operation typehash - /// @param signer The signer address - /// @param operationId The operation id - function isOperationIdAvailable(bytes32 typehash, address signer, uint256 operationId) external view returns (bool); + /// @param nonce The operation nonce + function useOperationNonce(bytes32 typehash, uint256 nonce) external; - /// @dev Invalidates operation id for the caller in the context of the operation typehash + /// @dev Increments id for the caller in the context of the operation typehash and operation beneficiary /// @param typehash The operation typehash - /// @param operationId The operation id - /// @return success True if nonce has not been invalidated previously - function useOperationId(bytes32 typehash, uint256 operationId) external; + /// @param beneficiary The address of the spender, delegate, or other beneficiary of the transaction + /// @param id The operation nonce + function useOperationIds(bytes32 typehash, address beneficiary, uint256 id) external; } ``` +- Operation EIPs SHOULD use at leat one of the nonces or ids sequences per signer defined by this EIP or both. + ## Rationale TBD From dda6b4c13eb63e0d57a2ae32fbe20ee13d5dea0c Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Wed, 14 Dec 2022 17:31:22 +0100 Subject: [PATCH 08/17] Update EIPS/eip-X.md Co-authored-by: Pandapip1 <45835846+Pandapip1@users.noreply.github.com> --- EIPS/eip-X.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-X.md b/EIPS/eip-X.md index cee4f612da3823..dc699a7275f48e 100644 --- a/EIPS/eip-X.md +++ b/EIPS/eip-X.md @@ -1,5 +1,5 @@ --- -eip: TBD +eip: 6077 title: Invalidation abstraction for signature-based operations powered by EIP-712 description: Extends EIP-712 and unifies EIP-2612 with many others author: Anton Bukov (@k06a), Mikhail Melnik (@zumzoom) From ea37dcd8fd11c77bb6099ccf867cca5ad339160e Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Wed, 14 Dec 2022 17:34:51 +0100 Subject: [PATCH 09/17] Rename file --- EIPS/{eip-X.md => eip-6077.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename EIPS/{eip-X.md => eip-6077.md} (100%) diff --git a/EIPS/eip-X.md b/EIPS/eip-6077.md similarity index 100% rename from EIPS/eip-X.md rename to EIPS/eip-6077.md From 4005a727c3d6235893fa0e5c907be0a8ecfa0ecc Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Thu, 15 Dec 2022 12:33:14 +0100 Subject: [PATCH 10/17] Update EIPS/eip-6077.md Co-authored-by: Pandapip1 <45835846+Pandapip1@users.noreply.github.com> --- EIPS/eip-6077.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6077.md b/EIPS/eip-6077.md index dc699a7275f48e..4bee6f60a2ede4 100644 --- a/EIPS/eip-6077.md +++ b/EIPS/eip-6077.md @@ -1,6 +1,6 @@ --- eip: 6077 -title: Invalidation abstraction for signature-based operations powered by EIP-712 +title: Invalidation Abstraction for Signature-Based Operations description: Extends EIP-712 and unifies EIP-2612 with many others author: Anton Bukov (@k06a), Mikhail Melnik (@zumzoom) discussions-to: TBD From a1ac4523d6b29a4610ea79823893e8e3ee49d208 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Thu, 15 Dec 2022 12:33:20 +0100 Subject: [PATCH 11/17] Update EIPS/eip-6077.md Co-authored-by: Pandapip1 <45835846+Pandapip1@users.noreply.github.com> --- EIPS/eip-6077.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6077.md b/EIPS/eip-6077.md index 4bee6f60a2ede4..9d1412217c8abe 100644 --- a/EIPS/eip-6077.md +++ b/EIPS/eip-6077.md @@ -8,7 +8,7 @@ status: Draft type: Standards Track category: ERC created: 2022-12-02 -requires: 712 +requires: 712, 2612 --- ## Abstract From 5c17d7c046ab5b15b7b20d4e734e8c77bd7a8f2a Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Thu, 15 Dec 2022 12:33:50 +0100 Subject: [PATCH 12/17] Update EIPS/eip-6077.md Co-authored-by: Pandapip1 <45835846+Pandapip1@users.noreply.github.com> --- EIPS/eip-6077.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EIPS/eip-6077.md b/EIPS/eip-6077.md index 9d1412217c8abe..2c331b78d9c98e 100644 --- a/EIPS/eip-6077.md +++ b/EIPS/eip-6077.md @@ -13,7 +13,8 @@ requires: 712, 2612 ## Abstract -This EIP extends [EIP-712](./eip-712.md) and defines two ways to validate and invalidate signature-based operations. Such operations as [EIP-20](./eip-20.md) permit operation defined in [EIP-2612](./eip-2612.md). This EIP provides two ways to track such operations and invalidate them: +This EIP extends [EIP-712](./eip-712.md) and defines two methods to validate and invalidate signature-based operations, such as [EIP-2612](./eip-20.md)'s permit operation. This EIP provides two ways to track such operations and invalidate them: + - main sequnce of incremental nonces per signer - sequence of incremental ids per signer per beneficiary From 651431e9e04b699349f332df23ed65894f3b6c78 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Thu, 15 Dec 2022 12:36:18 +0100 Subject: [PATCH 13/17] Add discussion link --- EIPS/eip-6077.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6077.md b/EIPS/eip-6077.md index 2c331b78d9c98e..8e89968dfb94d3 100644 --- a/EIPS/eip-6077.md +++ b/EIPS/eip-6077.md @@ -3,7 +3,7 @@ eip: 6077 title: Invalidation Abstraction for Signature-Based Operations description: Extends EIP-712 and unifies EIP-2612 with many others author: Anton Bukov (@k06a), Mikhail Melnik (@zumzoom) -discussions-to: TBD +discussions-to: https://ethereum-magicians.org/t/eip-6077-invalidation-abstraction-for-signature-based-operations/12162 status: Draft type: Standards Track category: ERC From 02e4ad6049bf9a1a1553fd9c88313887ce468f4c Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Thu, 15 Dec 2022 12:37:05 +0100 Subject: [PATCH 14/17] Update EIPS/eip-6077.md Co-authored-by: Pandapip1 <45835846+Pandapip1@users.noreply.github.com> --- EIPS/eip-6077.md | 1 + 1 file changed, 1 insertion(+) diff --git a/EIPS/eip-6077.md b/EIPS/eip-6077.md index 8e89968dfb94d3..b116308816226e 100644 --- a/EIPS/eip-6077.md +++ b/EIPS/eip-6077.md @@ -29,6 +29,7 @@ Multiple EIPs define operations that can be executed in behalf of signer and som The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. - Smart contract implementing EIP-712 MUST also implement the following interface: + ```solidity interface ISignatureOperations { /// @dev Returns next nonce for the signer in the context of the operation typehash and operation beneficiary From 8429d316b3776e2d175db7aaa5578f78edae24fe Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Mon, 16 Jan 2023 01:59:17 +0100 Subject: [PATCH 15/17] Update EIPS/eip-6077.md Co-authored-by: Sam Wilson <57262657+SamWilsn@users.noreply.github.com> --- EIPS/eip-6077.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6077.md b/EIPS/eip-6077.md index b116308816226e..a1a88d006c84ef 100644 --- a/EIPS/eip-6077.md +++ b/EIPS/eip-6077.md @@ -1,6 +1,6 @@ --- eip: 6077 -title: Invalidation Abstraction for Signature-Based Operations +title: Invalidation for Signature-Based Operations description: Extends EIP-712 and unifies EIP-2612 with many others author: Anton Bukov (@k06a), Mikhail Melnik (@zumzoom) discussions-to: https://ethereum-magicians.org/t/eip-6077-invalidation-abstraction-for-signature-based-operations/12162 From d3cf7a4fa3ee084e0b5910cbbae0d02c481e6206 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Wed, 25 Jan 2023 21:17:47 +0100 Subject: [PATCH 16/17] Update EIPS/eip-6077.md Co-authored-by: Pandapip1 <45835846+Pandapip1@users.noreply.github.com> --- EIPS/eip-6077.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6077.md b/EIPS/eip-6077.md index a1a88d006c84ef..b2d57c4631101b 100644 --- a/EIPS/eip-6077.md +++ b/EIPS/eip-6077.md @@ -8,7 +8,7 @@ status: Draft type: Standards Track category: ERC created: 2022-12-02 -requires: 712, 2612 +requires: 712 --- ## Abstract From 911c35b42f2d93c766f931768f1f811d8a2d08d4 Mon Sep 17 00:00:00 2001 From: Anton Bukov Date: Wed, 25 Jan 2023 21:19:28 +0100 Subject: [PATCH 17/17] Update EIPS/eip-6077.md Co-authored-by: Pandapip1 <45835846+Pandapip1@users.noreply.github.com> --- EIPS/eip-6077.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-6077.md b/EIPS/eip-6077.md index b2d57c4631101b..7692ae3df45e5c 100644 --- a/EIPS/eip-6077.md +++ b/EIPS/eip-6077.md @@ -64,7 +64,7 @@ TBD ## Backwards Compatibility -Fully backward compatibile with EIP-712. +This EIP is backward compatible with EIP-712. ## Security Considerations