Skip to content

Commit d7930da

Browse files
committed
MultiSignerERC7913: prevent setting the threshold to zero (#5772)
Signed-off-by: Hadrien Croubois <[email protected]>
1 parent a60baa2 commit d7930da

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

contracts/utils/cryptography/signers/MultiSignerERC7913.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ abstract contract MultiSignerERC7913 is AbstractSigner {
6767
/// @dev The `signer` is less than 20 bytes long.
6868
error MultiSignerERC7913InvalidSigner(bytes signer);
6969

70+
/// @dev The `threshold` is zero.
71+
error MultiSignerERC7913ZeroThreshold();
72+
7073
/// @dev The `threshold` is unreachable given the number of `signers`.
7174
error MultiSignerERC7913UnreachableThreshold(uint64 signers, uint64 threshold);
7275

@@ -147,6 +150,7 @@ abstract contract MultiSignerERC7913 is AbstractSigner {
147150
* * See {_validateReachableThreshold} for the threshold validation.
148151
*/
149152
function _setThreshold(uint64 newThreshold) internal virtual {
153+
require(newThreshold > 0, MultiSignerERC7913ZeroThreshold());
150154
_threshold = newThreshold;
151155
_validateReachableThreshold();
152156
emit ERC7913ThresholdSet(newThreshold);

test/account/AccountMultiSigner.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,14 @@ describe('AccountMultiSigner', function () {
176176
await expect(this.mock.$_setThreshold(2)).to.emit(this.mock, 'ERC7913ThresholdSet');
177177

178178
// Unreachable threshold reverts
179-
await expect(this.mock.$_setThreshold(3)).to.revertedWithCustomError(
179+
await expect(this.mock.$_setThreshold(3))
180+
.to.revertedWithCustomError(this.mock, 'MultiSignerERC7913UnreachableThreshold')
181+
.withArgs(2, 3);
182+
183+
// Zero threshold reverts
184+
await expect(this.mock.$_setThreshold(0)).to.revertedWithCustomError(
180185
this.mock,
181-
'MultiSignerERC7913UnreachableThreshold',
186+
'MultiSignerERC7913ZeroThreshold',
182187
);
183188
});
184189

0 commit comments

Comments
 (0)