From 1d1a4163d3e92d1d82e0f7aa0082d7baf620857f Mon Sep 17 00:00:00 2001 From: Rubilmax Date: Mon, 18 Dec 2023 18:41:22 +0100 Subject: [PATCH 1/4] fix(authorization): revert already set error --- src/Morpho.sol | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Morpho.sol b/src/Morpho.sol index 72ae6b74c..01b430bc4 100644 --- a/src/Morpho.sol +++ b/src/Morpho.sol @@ -444,10 +444,6 @@ contract Morpho is IMorphoStaticTyping { /// @inheritdoc IMorphoBase function setAuthorizationWithSig(Authorization memory authorization, Signature calldata signature) external { - require( - authorization.isAuthorized != isAuthorized[authorization.authorizer][authorization.authorized], - ErrorsLib.ALREADY_SET - ); require(block.timestamp <= authorization.deadline, ErrorsLib.SIGNATURE_EXPIRED); require(authorization.nonce == nonce[authorization.authorizer]++, ErrorsLib.INVALID_NONCE); From 65cf2c0e1dc001c02d1bfbf489ec43cf208ed34f Mon Sep 17 00:00:00 2001 From: MathisGD Date: Wed, 20 Dec 2023 10:29:08 +0100 Subject: [PATCH 2/4] test: remove useless test --- .../forge/integration/AuthorizationIntegrationTest.sol | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/forge/integration/AuthorizationIntegrationTest.sol b/test/forge/integration/AuthorizationIntegrationTest.sol index e7933d19f..8115c7a32 100644 --- a/test/forge/integration/AuthorizationIntegrationTest.sol +++ b/test/forge/integration/AuthorizationIntegrationTest.sol @@ -16,16 +16,6 @@ contract AuthorizationIntegrationTest is BaseTest { assertFalse(morpho.isAuthorized(address(this), addressFuzz)); } - function testAlreadySet(address addressFuzz) public { - vm.expectRevert(bytes(ErrorsLib.ALREADY_SET)); - morpho.setAuthorization(addressFuzz, false); - - morpho.setAuthorization(addressFuzz, true); - - vm.expectRevert(bytes(ErrorsLib.ALREADY_SET)); - morpho.setAuthorization(addressFuzz, true); - } - function testAlreadySetWithSig(Authorization memory authorization, Signature memory sig) public { authorization.isAuthorized = false; authorization.authorizer = address(this); From 3d55307d51897fa2690b4c427bad5b96b65f7b3a Mon Sep 17 00:00:00 2001 From: MathisGD Date: Wed, 20 Dec 2023 10:37:43 +0100 Subject: [PATCH 3/4] test: remove useless test --- .../integration/AuthorizationIntegrationTest.sol | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/test/forge/integration/AuthorizationIntegrationTest.sol b/test/forge/integration/AuthorizationIntegrationTest.sol index 8115c7a32..dd9e2440d 100644 --- a/test/forge/integration/AuthorizationIntegrationTest.sol +++ b/test/forge/integration/AuthorizationIntegrationTest.sol @@ -16,20 +16,14 @@ contract AuthorizationIntegrationTest is BaseTest { assertFalse(morpho.isAuthorized(address(this), addressFuzz)); } - function testAlreadySetWithSig(Authorization memory authorization, Signature memory sig) public { - authorization.isAuthorized = false; - authorization.authorizer = address(this); - authorization.deadline = block.timestamp; - authorization.nonce = 0; - + function testAlreadySet(address addressFuzz) public { vm.expectRevert(bytes(ErrorsLib.ALREADY_SET)); - morpho.setAuthorizationWithSig(authorization, sig); + morpho.setAuthorization(addressFuzz, false); - morpho.setAuthorization(authorization.authorized, true); + morpho.setAuthorization(addressFuzz, true); - authorization.isAuthorized = true; vm.expectRevert(bytes(ErrorsLib.ALREADY_SET)); - morpho.setAuthorizationWithSig(authorization, sig); + morpho.setAuthorization(addressFuzz, true); } function testSetAuthorizationWithSignatureDeadlineOutdated( From b2279f2cbd55baa5a19892541e44b466b2801127 Mon Sep 17 00:00:00 2001 From: Rubilmax Date: Wed, 20 Dec 2023 11:45:11 +0100 Subject: [PATCH 4/4] docs(authorization): comment already set --- src/Morpho.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Morpho.sol b/src/Morpho.sol index 01b430bc4..4ef3996a9 100644 --- a/src/Morpho.sol +++ b/src/Morpho.sol @@ -444,6 +444,7 @@ contract Morpho is IMorphoStaticTyping { /// @inheritdoc IMorphoBase function setAuthorizationWithSig(Authorization memory authorization, Signature calldata signature) external { + /// Do not check whether authorization is already set because the nonce increment is a desired side effect. require(block.timestamp <= authorization.deadline, ErrorsLib.SIGNATURE_EXPIRED); require(authorization.nonce == nonce[authorization.authorizer]++, ErrorsLib.INVALID_NONCE);