Skip to content

Commit

Permalink
optimize (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
webelf101 authored Nov 15, 2023
1 parent b8898c3 commit fd5659d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contracts/Compass.vy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@author Volume.Finance
"""

MAX_VALIDATORS: constant(uint256) = 175
MAX_VALIDATORS: constant(uint256) = 200
MAX_PAYLOAD: constant(uint256) = 10240
MAX_BATCH: constant(uint256) = 64

Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(_compass_id: bytes32, _event_id: uint256, valset: Valset):
cumulative_power += valset.powers[i]
if cumulative_power >= POWER_THRESHOLD:
break
i += 1
i = unsafe_add(i, 1)
assert cumulative_power >= POWER_THRESHOLD, "Insufficient Power"
new_checkpoint: bytes32 = keccak256(_abi_encode(valset.validators, valset.powers, valset.valset_id, compass_id, method_id=method_id("checkpoint(address[],uint256[],uint256,bytes32)")))
self.last_checkpoint = new_checkpoint
Expand All @@ -114,7 +114,7 @@ def check_validator_signatures(consensus: Consensus, hash: bytes32):
cumulative_power += consensus.valset.powers[i]
if cumulative_power >= POWER_THRESHOLD:
break
i += 1
i = unsafe_add(i, 1)
assert cumulative_power >= POWER_THRESHOLD, "Insufficient Power"

# Make a new checkpoint from the supplied validator set
Expand Down Expand Up @@ -147,7 +147,7 @@ def update_valset(consensus: Consensus, new_valset: Valset):
cumulative_power += new_valset.powers[i]
if cumulative_power >= POWER_THRESHOLD:
break
i += 1
i = unsafe_add(i, 1)
assert cumulative_power >= POWER_THRESHOLD, "Insufficient Power"
# check if the supplied current validator set matches the saved checkpoint
assert self.last_checkpoint == self.make_checkpoint(consensus.valset), "Incorrect Checkpoint"
Expand Down

0 comments on commit fd5659d

Please sign in to comment.