From 8f9851889767d5db68a4e901f8092fd8b8400b42 Mon Sep 17 00:00:00 2001 From: Marko Date: Tue, 28 May 2024 18:09:06 +0200 Subject: [PATCH 1/2] remove pauser role in contracts --- src/Redistribution.sol | 9 ++------- src/Staking.sol | 7 ++----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Redistribution.sol b/src/Redistribution.sol index fb9f88e7..59091a08 100644 --- a/src/Redistribution.sol +++ b/src/Redistribution.sol @@ -160,9 +160,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 ------------------------------ /** @@ -267,9 +264,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); } //////////////////////////////////////// @@ -656,7 +651,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(); } @@ -667,7 +662,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(); diff --git a/src/Staking.sol b/src/Staking.sol index 1d209dc4..1962bc1f 100644 --- a/src/Staking.sol +++ b/src/Staking.sol @@ -29,8 +29,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"); @@ -80,7 +78,6 @@ contract StakeRegistry is AccessControl, Pausable { NetworkId = _NetworkId; bzzToken = _bzzToken; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); - _setupRole(PAUSER_ROLE, msg.sender); } //////////////////////////////////////// @@ -188,7 +185,7 @@ 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(); } @@ -196,7 +193,7 @@ contract StakeRegistry 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)) revert OnlyPauser(); + if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) revert OnlyPauser(); _unpause(); } From 763e72ead35fc1658e9aa254da793390319817b5 Mon Sep 17 00:00:00 2001 From: Marko Date: Tue, 28 May 2024 18:14:53 +0200 Subject: [PATCH 2/2] change pauser roles to admin --- test/PostageStamp.test.ts | 2 +- test/Redistribution.test.ts | 2 +- test/Staking.test.ts | 8 ++++---- test/Stats.test.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/PostageStamp.test.ts b/test/PostageStamp.test.ts index 5faa4a78..36b9026b 100644 --- a/test/PostageStamp.test.ts +++ b/test/PostageStamp.test.ts @@ -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; }); }); diff --git a/test/Redistribution.test.ts b/test/Redistribution.test.ts index 1a1fd2ac..b3340886 100644 --- a/test/Redistribution.test.ts +++ b/test/Redistribution.test.ts @@ -266,7 +266,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 diff --git a/test/Staking.test.ts b/test/Staking.test.ts index 9a9cd3e6..1b38edba 100644 --- a/test/Staking.test.ts +++ b/test/Staking.test.ts @@ -79,7 +79,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); }); @@ -88,7 +88,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; }); @@ -285,7 +285,7 @@ describe('Staking', function () { await sr_staker_0.depositStake(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); }); @@ -353,7 +353,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); }); diff --git a/test/Stats.test.ts b/test/Stats.test.ts index 538204a5..e657e21b 100644 --- a/test/Stats.test.ts +++ b/test/Stats.test.ts @@ -139,7 +139,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);