Skip to content

Commit f384868

Browse files
djb15Rahul Maganti
and
Rahul Maganti
authored
Fix: Don't allow a threshold of 0 (#123)
* Pausable: implement Pausable abstract contract * WormholeEndpointStandalone: add pausing functionality * Pausable: use custom errors instead of require * feat: add pausing to WormholeEndpoint, WormholeEndpointAndManager, and WormholeEndpointStandalone * Pausable: remove superfluous comments * Pausable: rmv leading underscore on [`isPaused`] * WormholeEndpointStandalone: rmv outdated doctag * Pausable: move to libraries * Endpoint: abstract Pausing functionality out to all endpoints * EndpointStandalone: expose pausing through the Endpoint Standalone API * Pausable: add configurable pauser role * Feat: allow owner or pauser role to pause * Pausable: fix typo in comment * fix: modify structure to inherit PausableOwnable to linearize access controls * fix: make renounce and transfer public * fix: override transferOwnership in ManagerStandalone loop through all the endpoints and update the owner of all the endpoints to be the owner of the manager * fix: define new transferOwnership method instead of initializing * fix: rmv pass through upgrade from Manager * fix: use interface for manager instead of manager directly * Fix: Don't allow a threshold of 0 --------- Co-authored-by: Rahul Maganti <rahulmaganti@rahuls-mbp.mynetworksettings.com>
1 parent 7bf64ad commit f384868

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ManagerStandalone.sol

+8-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ contract ManagerStandalone is IManagerStandalone, Manager, Implementation {
7878
/// =============== GETTERS/SETTERS ========================================
7979

8080
function setThreshold(uint8 threshold) external onlyOwner {
81+
if (threshold == 0) {
82+
revert ZeroThreshold();
83+
}
84+
8185
_Threshold storage _threshold = _getThresholdStorage();
8286
uint8 oldThreshold = _threshold.num;
8387

@@ -110,9 +114,11 @@ contract ManagerStandalone is IManagerStandalone, Manager, Implementation {
110114
// Instead, we leave it up to the owner to manually update the threshold
111115
// after some period of time, ideally once all chains have the new Endpoint
112116
// and transfers that were sent via the old configuration are all complete.
117+
// However if the threshold is 0 (the initial case) we do increment to 1.
113118
if (_threshold.num == 0) {
114119
_threshold.num = 1;
115120
}
121+
116122
address[] storage _enabledEndpoints = _getEnabledEndpointsStorage();
117123

118124
emit EndpointAdded(endpoint, _enabledEndpoints.length, _threshold.num);
@@ -221,13 +227,14 @@ contract ManagerStandalone is IManagerStandalone, Manager, Implementation {
221227
function _checkThresholdInvariants() internal view {
222228
_Threshold storage _threshold = _getThresholdStorage();
223229
address[] storage _enabledEndpoints = _getEnabledEndpointsStorage();
230+
address[] storage _registeredEndpoints = _getRegisteredEndpointsStorage();
224231

225232
// invariant: threshold <= enabledEndpoints.length
226233
if (_threshold.num > _enabledEndpoints.length) {
227234
revert ThresholdTooHigh(_threshold.num, _enabledEndpoints.length);
228235
}
229236

230-
if (_enabledEndpoints.length > 0) {
237+
if (_registeredEndpoints.length > 0) {
231238
if (_threshold.num == 0) {
232239
revert ZeroThreshold();
233240
}

0 commit comments

Comments
 (0)