From 940afd112685cfd20aad52f13274b1ce47bff409 Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Tue, 30 Jan 2024 18:08:41 +0100 Subject: [PATCH] Added missing parameter to the getter for LinearSum, fixed calculation of the idealNeighborhoodMaxDistance --- abi/LinearSum.json | 9 +++++++-- contracts/v2/scoring/LinearSum.sol | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/abi/LinearSum.json b/abi/LinearSum.json index bcbb7b7b..8f1b0842 100644 --- a/abi/LinearSum.json +++ b/abi/LinearSum.json @@ -159,9 +159,14 @@ "name": "getParameters", "outputs": [ { - "internalType": "uint192", + "internalType": "uint96", "name": "", - "type": "uint192" + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "", + "type": "uint96" }, { "internalType": "uint32", diff --git a/contracts/v2/scoring/LinearSum.sol b/contracts/v2/scoring/LinearSum.sol index 374c1fc6..d1c3240a 100644 --- a/contracts/v2/scoring/LinearSum.sol +++ b/contracts/v2/scoring/LinearSum.sol @@ -94,7 +94,7 @@ contract LinearSum is IProximityScoreFunctionsPair, Indexable, Named, HubDepende function normalizeDistance(uint256 distance, uint256 maxDistance, uint72 nodesCount) public view returns (uint64) { if (distance == 0) return 0; - uint256 idealMaxDistance = (HASH_RING_SIZE / nodesCount) * (parametersStorage.r2() / 2); + uint256 idealMaxDistance = (HASH_RING_SIZE / nodesCount) * ((parametersStorage.r2() + 1) / 2); uint256 divisor = (maxDistance <= idealMaxDistance) ? maxDistance : idealMaxDistance; uint256 maxMultiplier = type(uint256).max / distance; @@ -122,8 +122,8 @@ contract LinearSum is IProximityScoreFunctionsPair, Indexable, Named, HubDepende return uint64((uint256(stakeScaleFactor) * (stake - minStake)) / (maxStake - minStake)); } - function getParameters() external view returns (uint192, uint32, uint32) { - return (distanceScaleFactor, w1, w2); + function getParameters() external view returns (uint96, uint96, uint32, uint32) { + return (distanceScaleFactor, stakeScaleFactor, w1, w2); } function setDistanceScaleFactor(uint96 distanceScaleFactor_) external onlyHubOwner {