Skip to content

Commit 1845259

Browse files
committed
fix: remove the deprecated pow from RewardsManager (OZ N-03)
1 parent dbdda2f commit 1845259

File tree

4 files changed

+0
-151
lines changed

4 files changed

+0
-151
lines changed

.solhintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ node_modules
44
./contracts/discovery/erc1056
55
./contracts/rewards/RewardsManager.sol
66
./contracts/staking/libs/LibFixedMath.sol
7-
./contracts/tests/RewardsManagerMock.sol
87
./contracts/tests/ens
98
./contracts/tests/testnet/GSRManager.sol

contracts/rewards/RewardsManager.sol

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -424,67 +424,4 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa
424424

425425
return rewards;
426426
}
427-
428-
/**
429-
* @dev Raises x to the power of n with scaling factor of base.
430-
* Based on: https://github.com/makerdao/dss/blob/master/src/pot.sol#L81
431-
* @param x Base of the exponentiation
432-
* @param n Exponent
433-
* @param base Scaling factor
434-
* @return z Exponential of n with base x
435-
*/
436-
function _pow(
437-
uint256 x,
438-
uint256 n,
439-
uint256 base
440-
) private pure returns (uint256 z) {
441-
assembly {
442-
switch x
443-
case 0 {
444-
switch n
445-
case 0 {
446-
z := base
447-
}
448-
default {
449-
z := 0
450-
}
451-
}
452-
default {
453-
switch mod(n, 2)
454-
case 0 {
455-
z := base
456-
}
457-
default {
458-
z := x
459-
}
460-
let half := div(base, 2) // for rounding.
461-
for {
462-
n := div(n, 2)
463-
} n {
464-
n := div(n, 2)
465-
} {
466-
let xx := mul(x, x)
467-
if iszero(eq(div(xx, x), x)) {
468-
revert(0, 0)
469-
}
470-
let xxRound := add(xx, half)
471-
if lt(xxRound, xx) {
472-
revert(0, 0)
473-
}
474-
x := div(xxRound, base)
475-
if mod(n, 2) {
476-
let zx := mul(z, x)
477-
if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) {
478-
revert(0, 0)
479-
}
480-
let zxRound := add(zx, half)
481-
if lt(zxRound, zx) {
482-
revert(0, 0)
483-
}
484-
z := div(zxRound, base)
485-
}
486-
}
487-
}
488-
}
489-
}
490427
}

contracts/tests/RewardsManagerMock.sol

Lines changed: 0 additions & 68 deletions
This file was deleted.

test/rewards/rewards.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { Curation } from '../../build/types/Curation'
99
import { EpochManager } from '../../build/types/EpochManager'
1010
import { GraphToken } from '../../build/types/GraphToken'
1111
import { RewardsManager } from '../../build/types/RewardsManager'
12-
import { RewardsManagerMock } from '../../build/types/RewardsManagerMock'
1312
import { Staking } from '../../build/types/Staking'
1413

1514
import {
@@ -48,7 +47,6 @@ describe('Rewards', () => {
4847
let epochManager: EpochManager
4948
let staking: Staking
5049
let rewardsManager: RewardsManager
51-
let rewardsManagerMock: RewardsManagerMock
5250

5351
// Derive some channel keys for each indexer used to sign attestations
5452
const channelKey1 = deriveChannelKey()
@@ -140,11 +138,6 @@ describe('Rewards', () => {
140138
governor.signer,
141139
))
142140

143-
rewardsManagerMock = (await deployContract(
144-
'RewardsManagerMock',
145-
governor.signer,
146-
)) as unknown as RewardsManagerMock
147-
148141
// 200 GRT per block
149142
await rewardsManager.connect(governor.signer).setIssuancePerBlock(ISSUANCE_PER_BLOCK)
150143

@@ -831,18 +824,6 @@ describe('Rewards', () => {
831824
})
832825
})
833826

834-
describe('pow', function () {
835-
it('exponentiation works under normal boundaries (annual rate from 1% to 700%, 90 days period)', async function () {
836-
const baseRatio = toGRT('0.000000004641377923') // 1% annual rate
837-
const timePeriods = (60 * 60 * 24 * 10) / 15 // 90 days in blocks
838-
for (let i = 0; i < 50; i = i + 4) {
839-
const r = baseRatio.mul(i * 4).add(toGRT('1'))
840-
const h = await rewardsManagerMock.pow(r, timePeriods, toGRT('1'))
841-
console.log('\tr:', formatGRT(r), '=> c:', formatGRT(h))
842-
}
843-
})
844-
})
845-
846827
describe('edge scenarios', function () {
847828
it('close allocation on a subgraph that no longer have signal', async function () {
848829
// Update total signalled

0 commit comments

Comments
 (0)