Skip to content

Commit

Permalink
remove pause role
Browse files Browse the repository at this point in the history
  • Loading branch information
n00b21337 committed Jul 23, 2024
1 parent 849937d commit b2f0da5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 19 deletions.
9 changes: 2 additions & 7 deletions src/Redistribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ contract Redistribution is AccessControl, Pausable {
// Maximum value of the keccack256 hash.
bytes32 private constant MAX_H = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff;

// Role allowed to pause.
bytes32 private immutable PAUSER_ROLE;

// ----------------------------- Events ------------------------------

/**
Expand Down Expand Up @@ -263,9 +260,7 @@ contract Redistribution is AccessControl, Pausable {
Stakes = IStakeRegistry(staking);
PostageContract = IPostageStamp(postageContract);
OracleContract = IPriceOracle(oracleContract);
PAUSER_ROLE = keccak256("PAUSER_ROLE");
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(PAUSER_ROLE, msg.sender);
}

////////////////////////////////////////
Expand Down Expand Up @@ -659,7 +654,7 @@ contract Redistribution is AccessControl, Pausable {
the pauser role and the admin role after pausing, can only be called by the `PAUSER`
*/
function pause() public {
if (!hasRole(PAUSER_ROLE, msg.sender)) {
if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) {
revert OnlyPauser();
}

Expand All @@ -670,7 +665,7 @@ contract Redistribution is AccessControl, Pausable {
* @dev Unpause the contract, can only be called by the pauser when paused
*/
function unPause() public {
if (!hasRole(PAUSER_ROLE, msg.sender)) {
if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) {
revert OnlyPauser();
}
_unpause();
Expand Down
7 changes: 2 additions & 5 deletions src/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ contract StakeRegistry is AccessControl, Pausable {
// Associate every stake id with node address data.
mapping(address => Stake) public stakes;

// Role allowed to pause
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
// Role allowed to freeze and slash entries
bytes32 public constant REDISTRIBUTOR_ROLE = keccak256("REDISTRIBUTOR_ROLE");

Expand Down Expand Up @@ -105,7 +103,6 @@ contract StakeRegistry is AccessControl, Pausable {
bzzToken = _bzzToken;
OracleContract = IPriceOracle(_oracleContract);
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(PAUSER_ROLE, msg.sender);
}

////////////////////////////////////////
Expand Down Expand Up @@ -223,15 +220,15 @@ contract StakeRegistry is AccessControl, Pausable {
the pauser role and the admin role after pausing, can only be called by the `PAUSER`
*/
function pause() public {
if (!hasRole(PAUSER_ROLE, msg.sender)) revert OnlyPauser();
if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert OnlyPauser();
_pause();
}

/**
* @dev Unpause the contract, can only be called by the pauser when paused
*/
function unPause() public {
if (!hasRole(PAUSER_ROLE, msg.sender)) revert OnlyPauser();
if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert OnlyPauser();
_unpause();
}

Expand Down
2 changes: 1 addition & 1 deletion test/PostageStamp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('PostageStamp', function () {

it('should assign the pauser role', async function () {
const postageStamp = await ethers.getContract('PostageStamp');
const pauserRole = await postageStamp.PAUSER_ROLE();
const pauserRole = await postageStamp.DEFAULT_ADMIN_ROLE();
expect(await postageStamp.hasRole(pauserRole, deployer)).to.be.true;
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/Redistribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('Redistribution', function () {
redistribution = await ethers.getContract('Redistribution');
token = await ethers.getContract('TestToken', deployer);

const pauserRole = await read('StakeRegistry', 'PAUSER_ROLE');
const pauserRole = await read('StakeRegistry', 'DEFAULT_ADMIN_ROLE');
await execute('StakeRegistry', { from: deployer }, 'grantRole', pauserRole, pauser);

//initialise, set minimum price, todo: move to deployment
Expand Down
8 changes: 4 additions & 4 deletions test/Staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Staking', function () {
await deployments.fixture();
stakeRegistry = await ethers.getContract('StakeRegistry');

const pauserRole = await read('StakeRegistry', 'PAUSER_ROLE');
const pauserRole = await read('StakeRegistry', 'DEFAULT_ADMIN_ROLE');
await execute('StakeRegistry', { from: deployer }, 'grantRole', pauserRole, pauser);
});

Expand All @@ -90,7 +90,7 @@ describe('Staking', function () {
});

it('should set the pauser role', async function () {
const pauserRole = await stakeRegistry.PAUSER_ROLE();
const pauserRole = await stakeRegistry.DEFAULT_ADMIN_ROLE();
expect(await stakeRegistry.hasRole(pauserRole, pauser)).to.be.true;
});

Expand Down Expand Up @@ -288,7 +288,7 @@ describe('Staking', function () {
await sr_staker_0.manageStake(nonce_0, stakeAmount_0);

const stakeRegistryDeployer = await ethers.getContract('StakeRegistry', deployer);
const pauserRole = await stakeRegistryDeployer.PAUSER_ROLE();
const pauserRole = await stakeRegistryDeployer.DEFAULT_ADMIN_ROLE();
await stakeRegistryDeployer.grantRole(pauserRole, pauser);
});

Expand Down Expand Up @@ -358,7 +358,7 @@ describe('Staking', function () {
updatedBlockNumber = await getBlockNumber();

const stakeRegistryDeployer = await ethers.getContract('StakeRegistry', deployer);
const pauserRole = await stakeRegistryDeployer.PAUSER_ROLE();
const pauserRole = await stakeRegistryDeployer.DEFAULT_ADMIN_ROLE();
await stakeRegistryDeployer.grantRole(pauserRole, pauser);
});

Expand Down
2 changes: 1 addition & 1 deletion test/Stats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('Stats', async function () {
const priceOracleRole = await read('PostageStamp', 'PRICE_ORACLE_ROLE');
await execute('PostageStamp', { from: deployer }, 'grantRole', priceOracleRole, oracle);

const pauserRole = await read('StakeRegistry', 'PAUSER_ROLE');
const pauserRole = await read('StakeRegistry', 'DEFAULT_ADMIN_ROLE');
await execute('StakeRegistry', { from: deployer }, 'grantRole', pauserRole, pauser);

const priceOracle = await ethers.getContract('PriceOracle', deployer);
Expand Down

0 comments on commit b2f0da5

Please sign in to comment.