From 9689fb5dedbd7aaac99e6232189c98765923dd6e Mon Sep 17 00:00:00 2001 From: adnpark Date: Tue, 12 Mar 2024 10:45:29 +0900 Subject: [PATCH] fix: set max address as first guardian when renew --- src/validator/WeightedECDSAValidator.sol | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/validator/WeightedECDSAValidator.sol b/src/validator/WeightedECDSAValidator.sol index e6924476..6f2170b5 100644 --- a/src/validator/WeightedECDSAValidator.sol +++ b/src/validator/WeightedECDSAValidator.sol @@ -63,11 +63,7 @@ contract WeightedECDSAValidator is EIP712, IKernelValidator { require(_guardians[i] != address(0), "Guardian cannot be 0"); require(_weights[i] != 0, "Weight cannot be 0"); require(guardian[_guardians[i]][_kernel].weight == 0, "Guardian already enabled"); - // when index is 0 meaning that adding the first guardian, since prevGuardian is type(uint160).max, we skip the check - if (i != 0) { - // check if guardians are sorted - require(uint160(_guardians[i]) < prevGuardian, "Guardians not sorted"); - } + require(uint160(_guardians[i]) < prevGuardian, "Guardians not sorted"); guardian[_guardians[i]][_kernel] = GuardianStorage({weight: _weights[i], nextGuardian: weightedStorage[_kernel].firstGuardian}); weightedStorage[_kernel].firstGuardian = _guardians[i]; @@ -116,7 +112,7 @@ contract WeightedECDSAValidator is EIP712, IKernelValidator { } delete weightedStorage[msg.sender]; require(_guardians.length == _weights.length, "Length mismatch"); - weightedStorage[msg.sender].firstGuardian = _guardians[0]; + weightedStorage[msg.sender].firstGuardian = address(uint160(type(uint160).max)); _addGuardians(_guardians, _weights, msg.sender); weightedStorage[msg.sender].delay = _delay; weightedStorage[msg.sender].threshold = _threshold;