Skip to content

Commit

Permalink
refactor(contracts): add check of validator set uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Sep 28, 2024
1 parent 9262ad4 commit cd9134c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contracts/StreamManager.vy
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ def set_validators(validators: DynArray[Validator, MAX_VALIDATORS]):
if Ability.MODFIY_VALIDATORS not in self.capabilities[msg.sender]:
assert msg.sender == self.controller # dev: insufficient capability

# TODO: Ensure uniqueness using Set
# TODO: Replace this logic with Set when available in Vyper
last_validator_uint: uint256 = convert(empty(address), uint256)
for validator: Validator in validators:
# NOTE: Sort in ascending order to ensure uniqueness of set
assert convert(validator.address, uint256) > last_validator_uint # dev: duplicate validator detected
last_validator_uint = convert(validator.address, uint256)

self.validators = validators


Expand Down

0 comments on commit cd9134c

Please sign in to comment.