Skip to content

Commit

Permalink
reduce bytecode size by removing unused addGuardian logic and
Browse files Browse the repository at this point in the history
drop optimisation runs for modules to 300
  • Loading branch information
elenadimitrova committed Apr 1, 2021
1 parent ce08fd4 commit 8628fec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
20 changes: 8 additions & 12 deletions contracts/modules/SecurityManager.sol
Expand Up @@ -241,18 +241,14 @@ abstract contract SecurityManager is BaseModule {
// Note that this test is not meant to be strict and can be bypassed by custom malicious contracts.
(bool success,) = _guardian.call{gas: 25000}(abi.encodeWithSignature("owner()"));
require(success, "SM: must be EOA/Argent wallet");
if (guardianStorage.guardianCount(_wallet) == 0) {
guardianStorage.addGuardian(_wallet, _guardian);
emit GuardianAdded(_wallet, _guardian);
} else {
bytes32 id = keccak256(abi.encodePacked(_wallet, _guardian, "addition"));
GuardianManagerConfig storage config = guardianConfigs[_wallet];
require(
config.pending[id] == 0 || block.timestamp > config.pending[id] + securityWindow,
"SM: duplicate pending addition");
config.pending[id] = block.timestamp + securityPeriod;
emit GuardianAdditionRequested(_wallet, _guardian, block.timestamp + securityPeriod);
}

bytes32 id = keccak256(abi.encodePacked(_wallet, _guardian, "addition"));
GuardianManagerConfig storage config = guardianConfigs[_wallet];
require(
config.pending[id] == 0 || block.timestamp > config.pending[id] + securityWindow,
"SM: duplicate pending addition");
config.pending[id] = block.timestamp + securityPeriod;
emit GuardianAdditionRequested(_wallet, _guardian, block.timestamp + securityPeriod);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/modules/common/Utils.sol
Expand Up @@ -65,7 +65,7 @@ library Utils {
* @param _to The target contract.
* @param _data The data payload.
*/
function recoverSpender(address _to, bytes memory _data) public pure returns (address spender) {
function recoverSpender(address _to, bytes memory _data) internal pure returns (address spender) {
if(_data.length >= 68) {
bytes4 methodId;
// solhint-disable-next-line no-inline-assembly
Expand Down Expand Up @@ -131,7 +131,7 @@ library Utils {
* @param _guardian the address to test
* @return true and the list of guardians minus the found guardian upon success, false and the original list of guardians if not found.
*/
function isGuardianOrGuardianSigner(address[] memory _guardians, address _guardian) public view returns (bool, address[] memory) {
function isGuardianOrGuardianSigner(address[] memory _guardians, address _guardian) internal view returns (bool, address[] memory) {
if (_guardians.length == 0 || _guardian == address(0)) {
return (false, _guardians);
}
Expand Down
2 changes: 1 addition & 1 deletion truffle-config-modules.js
Expand Up @@ -11,7 +11,7 @@ module.exports = {
settings: {
optimizer: {
enabled: true,
runs: 400,
runs: 300,
},
},
},
Expand Down

0 comments on commit 8628fec

Please sign in to comment.