From 08c2988174e1f2f118ae156a883b84ac2444f343 Mon Sep 17 00:00:00 2001 From: webelf101 Date: Thu, 16 Nov 2023 02:31:27 +0800 Subject: [PATCH] optimize --- contracts/Compass.vy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/Compass.vy b/contracts/Compass.vy index d4cf8c4..9c9d0ec 100644 --- a/contracts/Compass.vy +++ b/contracts/Compass.vy @@ -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 @@ -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 @@ -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 @@ -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"