Skip to content

Commit

Permalink
Added missing parameter to the getter for LinearSum, fixed calculatio…
Browse files Browse the repository at this point in the history
…n of the idealNeighborhoodMaxDistance
  • Loading branch information
br-41n committed Jan 30, 2024
1 parent 316b67a commit 940afd1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions abi/LinearSum.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,14 @@
"name": "getParameters",
"outputs": [
{
"internalType": "uint192",
"internalType": "uint96",
"name": "",
"type": "uint192"
"type": "uint96"
},
{
"internalType": "uint96",
"name": "",
"type": "uint96"
},
{
"internalType": "uint32",
Expand Down
6 changes: 3 additions & 3 deletions contracts/v2/scoring/LinearSum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 940afd1

Please sign in to comment.