From 4de223ed0c1416f22456b8d0bda698f538e6fc00 Mon Sep 17 00:00:00 2001 From: zorzal Date: Wed, 6 Nov 2024 07:54:01 -0500 Subject: [PATCH 01/11] refactor: create ModuleAccessControl, use AccessModule --- .../accessControl/AccessControllerModule.sol | 19 +++++--- .../accessControl/ModuleAccessController.sol | 44 +++++++++++++++++++ .../modules/dispute/BondEscalationModule.sol | 16 +++---- .../modules/dispute/CircuitResolverModule.sol | 5 ++- .../dispute/RootVerificationModule.sol | 5 ++- .../BondEscalationResolutionModule.sol | 14 +++--- .../resolution/ERC20ResolutionModule.sol | 12 +++-- .../PrivateERC20ResolutionModule.sol | 14 +++--- solidity/test/integration/IntegrationBase.sol | 5 ++- .../dispute/BondEscalationModule.t.sol | 19 ++++---- solidity/test/utils/Helpers.sol | 2 +- 11 files changed, 99 insertions(+), 56 deletions(-) create mode 100644 solidity/contracts/modules/accessControl/ModuleAccessController.sol diff --git a/solidity/contracts/modules/accessControl/AccessControllerModule.sol b/solidity/contracts/modules/accessControl/AccessControllerModule.sol index ad2a7fd..af8ad7d 100644 --- a/solidity/contracts/modules/accessControl/AccessControllerModule.sol +++ b/solidity/contracts/modules/accessControl/AccessControllerModule.sol @@ -1,11 +1,16 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {AccessController} from '@defi-wonderland/prophet-core/solidity/contracts/AccessController.sol'; +// import {AccessController} from '@defi-wonderland/prophet-core/solidity/contracts/AccessController.sol'; import {Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import { + IAccessController, + IAccessModule +} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/accessControl/IAccessModule.sol'; +// import {ModuleAccessController} from './ModuleAccessController.sol'; -abstract contract AccessControllerModule is AccessController, Module { +abstract contract AccessControllerModule is Module { constructor(IOracle _oracle) Module(_oracle) {} /** @@ -14,8 +19,12 @@ abstract contract AccessControllerModule is AccessController, Module { * @param _data Arbitrary data * @return _accessControl The self access control for this contract. */ - function _defaultAccessControl(bytes memory _data) internal view returns (AccessControl memory _accessControl) { - _accessControl = AccessControl({user: address(this), data: _data}); + function _defaultAccessControl(bytes memory _data) + internal + view + returns (IAccessController.AccessControl memory _accessControl) + { + _accessControl = IAccessController.AccessControl({user: address(this), data: _data}); } /** @@ -25,7 +34,7 @@ abstract contract AccessControllerModule is AccessController, Module { * @dev should only be used by modules as the self-access-control object * @return _accessControl The self access control for this contract. */ - function _defaultAccessControl() internal view returns (AccessControl memory _accessControl) { + function _defaultAccessControl() internal view returns (IAccessController.AccessControl memory _accessControl) { _accessControl = _defaultAccessControl(bytes('')); } } diff --git a/solidity/contracts/modules/accessControl/ModuleAccessController.sol b/solidity/contracts/modules/accessControl/ModuleAccessController.sol new file mode 100644 index 0000000..3772b0c --- /dev/null +++ b/solidity/contracts/modules/accessControl/ModuleAccessController.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {CommonAccessController} from '@defi-wonderland/prophet-core/solidity/contracts/CommonAccessController.sol'; + +import {Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; +import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IAccessModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/accessControl/IAccessModule.sol'; + +abstract contract ModuleAccessController is CommonAccessController, Module { + constructor(IOracle _oracle) Module(_oracle) {} + + /** + * @notice Returns an access control object using the contract address as user and the given data + * @dev should only be used by modules as the self-access-control object + * @param _data Arbitrary data + * @return _accessControl The self access control for this contract. + */ + function _defaultAccessControl(bytes memory _data) internal view returns (AccessControl memory _accessControl) { + _accessControl = AccessControl({user: address(this), data: _data}); + } + + /** + * @notice Returns an access control object using the contract address as user, and empty data + * + * @dev should only be used by modules as the self-access-control object + * @return _accessControl The self access control for this contract. + */ + function _defaultAccessControl() internal view returns (AccessControl memory _accessControl) { + _accessControl = _defaultAccessControl(bytes('')); + } + + modifier hasAccess( + address _accessModule, + bytes32 _typehash, + bytes memory _params, + AccessControl memory _accessControl + ) { + bool _isApproved = ORACLE.isAccessModuleApproved(_accessControl.user, _accessModule); + if (!_isApproved) revert AccessController_NoAccess(); + __hasAccess(_accessModule, _typehash, _params, _accessControl); + _; + } +} diff --git a/solidity/contracts/modules/dispute/BondEscalationModule.sol b/solidity/contracts/modules/dispute/BondEscalationModule.sol index 090a07d..f65a518 100644 --- a/solidity/contracts/modules/dispute/BondEscalationModule.sol +++ b/solidity/contracts/modules/dispute/BondEscalationModule.sol @@ -8,9 +8,10 @@ import {FixedPointMathLib} from 'solmate/src/utils/FixedPointMathLib.sol'; import {IBondEscalationModule} from '../../../interfaces/modules/dispute/IBondEscalationModule.sol'; import {_PLEDGE_AGAINST_DISPUTE_TYPEHASH, _PLEDGE_FOR_DISPUTE_TYPEHASH} from '../../utils/Typehash.sol'; -import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; -contract BondEscalationModule is AccessControllerModule, IBondEscalationModule { +import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; + +contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { /// @inheritdoc IBondEscalationModule mapping(bytes32 _requestId => mapping(address _pledger => uint256 pledges)) public pledgesForDispute; @@ -22,7 +23,7 @@ contract BondEscalationModule is AccessControllerModule, IBondEscalationModule { */ mapping(bytes32 _requestId => BondEscalation) internal _escalations; - constructor(IOracle _oracle) AccessControllerModule(_oracle) {} + constructor(IOracle _oracle) ModuleAccessController(_oracle) {} /// @inheritdoc IModule function moduleName() external pure returns (string memory _moduleName) { @@ -217,7 +218,7 @@ contract BondEscalationModule is AccessControllerModule, IBondEscalationModule { AccessControl calldata _accessControl ) external - hasAccess(_request.accessControlModule, _PLEDGE_FOR_DISPUTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) + hasAccess(_request.accessModule, _PLEDGE_FOR_DISPUTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) { bytes32 _disputeId = _getId(_dispute); RequestParameters memory _params = _pledgeChecks(_request, _dispute, true); @@ -244,12 +245,7 @@ contract BondEscalationModule is AccessControllerModule, IBondEscalationModule { AccessControl calldata _accessControl ) external - hasAccess( - _request.accessControlModule, - _PLEDGE_AGAINST_DISPUTE_TYPEHASH, - abi.encode(_request, _dispute), - _accessControl - ) + hasAccess(_request.accessModule, _PLEDGE_AGAINST_DISPUTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) { bytes32 _disputeId = _getId(_dispute); RequestParameters memory _params = _pledgeChecks(_request, _dispute, false); diff --git a/solidity/contracts/modules/dispute/CircuitResolverModule.sol b/solidity/contracts/modules/dispute/CircuitResolverModule.sol index 80b6894..f615efc 100644 --- a/solidity/contracts/modules/dispute/CircuitResolverModule.sol +++ b/solidity/contracts/modules/dispute/CircuitResolverModule.sol @@ -8,12 +8,13 @@ import {IProphetVerifier} from '../../../interfaces/IProphetVerifier.sol'; import {ICircuitResolverModule} from '../../../interfaces/modules/dispute/ICircuitResolverModule.sol'; import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; +import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; -contract CircuitResolverModule is AccessControllerModule, ICircuitResolverModule { +contract CircuitResolverModule is ModuleAccessController, ICircuitResolverModule { /// @notice Keeps track of the correct responses to requests mapping(bytes32 _requestId => bytes _correctResponse) internal _correctResponses; - constructor(IOracle _oracle) AccessControllerModule(_oracle) {} + constructor(IOracle _oracle) ModuleAccessController(_oracle) {} /// @inheritdoc IModule function moduleName() external pure returns (string memory _moduleName) { diff --git a/solidity/contracts/modules/dispute/RootVerificationModule.sol b/solidity/contracts/modules/dispute/RootVerificationModule.sol index e79874d..92e329a 100644 --- a/solidity/contracts/modules/dispute/RootVerificationModule.sol +++ b/solidity/contracts/modules/dispute/RootVerificationModule.sol @@ -7,8 +7,9 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IRootVerificationModule} from '../../../interfaces/modules/dispute/IRootVerificationModule.sol'; import {MerkleLib} from '../../libraries/MerkleLib.sol'; import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; +import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; -contract RootVerificationModule is AccessControllerModule, IRootVerificationModule { +contract RootVerificationModule is ModuleAccessController, IRootVerificationModule { using MerkleLib for MerkleLib.Tree; /** @@ -16,7 +17,7 @@ contract RootVerificationModule is AccessControllerModule, IRootVerificationModu */ mapping(bytes32 _requestId => bytes32 _correctRoot) internal _correctRoots; - constructor(IOracle _oracle) AccessControllerModule(_oracle) {} + constructor(IOracle _oracle) ModuleAccessController(_oracle) {} /// @inheritdoc IModule function moduleName() external pure returns (string memory _moduleName) { diff --git a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol index 661a0c6..4b025e2 100644 --- a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol +++ b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol @@ -17,6 +17,7 @@ import {IResolutionModule} from import {IBondEscalationResolutionModule} from '../../../interfaces/modules/resolution/IBondEscalationResolutionModule.sol'; import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; +import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; import { _CLAIM_PLEDGE_TYPEHASH, @@ -24,7 +25,7 @@ import { _PLEDGE_FOR_DISPUTE_TYPEHASH } from '../../utils/Typehash.sol'; -contract BondEscalationResolutionModule is AccessControllerModule, IBondEscalationResolutionModule { +contract BondEscalationResolutionModule is ModuleAccessController, IBondEscalationResolutionModule { using SafeERC20 for IERC20; /// @inheritdoc IBondEscalationResolutionModule @@ -42,7 +43,7 @@ contract BondEscalationResolutionModule is AccessControllerModule, IBondEscalati /// @inheritdoc IBondEscalationResolutionModule mapping(bytes32 _disputeId => mapping(address _pledger => uint256 pledges)) public pledgesAgainstDispute; - constructor(IOracle _oracle) AccessControllerModule(_oracle) {} + constructor(IOracle _oracle) ModuleAccessController(_oracle) {} /// @inheritdoc IModule function moduleName() external pure returns (string memory _moduleName) { @@ -74,7 +75,7 @@ contract BondEscalationResolutionModule is AccessControllerModule, IBondEscalati ) external hasAccess( - _request.accessControlModule, + _request.accessModule, _PLEDGE_FOR_DISPUTE_TYPEHASH, abi.encode(_request, _dispute, _pledgeAmount), _accessControl @@ -98,7 +99,7 @@ contract BondEscalationResolutionModule is AccessControllerModule, IBondEscalati ) external hasAccess( - _request.accessControlModule, + _request.accessModule, _PLEDGE_AGAINST_DISPUTE_TYPEHASH, abi.encode(_request, _dispute, _pledgeAmount), _accessControl @@ -162,10 +163,7 @@ contract BondEscalationResolutionModule is AccessControllerModule, IBondEscalati IOracle.Request calldata _request, IOracle.Dispute calldata _dispute, AccessControl calldata _accessControl - ) - external - hasAccess(_request.accessControlModule, _CLAIM_PLEDGE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) - { + ) external hasAccess(_request.accessModule, _CLAIM_PLEDGE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) { bytes32 _disputeId = _validateDispute(_request, _dispute); Escalation storage _escalation = escalations[_disputeId]; diff --git a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol index ebbb46a..6fec60e 100644 --- a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol @@ -13,8 +13,9 @@ import {IERC20ResolutionModule} from '../../../interfaces/modules/resolution/IER import {_CAST_VOTE_TYPEHASH, _CLAIM_VOTE_TYPEHASH} from '../../utils/Typehash.sol'; import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; +import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; -contract ERC20ResolutionModule is AccessControllerModule, IERC20ResolutionModule { +contract ERC20ResolutionModule is ModuleAccessController, IERC20ResolutionModule { using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; @@ -29,7 +30,7 @@ contract ERC20ResolutionModule is AccessControllerModule, IERC20ResolutionModule */ mapping(bytes32 _disputeId => EnumerableSet.AddressSet _votersSet) internal _voters; - constructor(IOracle _oracle) AccessControllerModule(_oracle) {} + constructor(IOracle _oracle) ModuleAccessController(_oracle) {} /// @inheritdoc IModule function moduleName() external pure returns (string memory _moduleName) { @@ -61,7 +62,7 @@ contract ERC20ResolutionModule is AccessControllerModule, IERC20ResolutionModule ) external hasAccess( - _request.accessControlModule, + _request.accessModule, _CAST_VOTE_TYPEHASH, abi.encode(_request, _dispute, _numberOfVotes, _numberOfVotes), _accessControl @@ -138,10 +139,7 @@ contract ERC20ResolutionModule is AccessControllerModule, IERC20ResolutionModule IOracle.Request calldata _request, IOracle.Dispute calldata _dispute, AccessControl calldata _accessControl - ) - external - hasAccess(_request.accessControlModule, _CLAIM_VOTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) - { + ) external hasAccess(_request.accessModule, _CLAIM_VOTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) { bytes32 _disputeId = _validateDispute(_request, _dispute); Escalation memory _escalation = escalations[_disputeId]; diff --git a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol index 7dd0a17..2ad114a 100644 --- a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol @@ -12,8 +12,9 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IPrivateERC20ResolutionModule} from '../../../interfaces/modules/resolution/IPrivateERC20ResolutionModule.sol'; import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; +import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; -contract PrivateERC20ResolutionModule is AccessControllerModule, IPrivateERC20ResolutionModule { +contract PrivateERC20ResolutionModule is ModuleAccessController, IPrivateERC20ResolutionModule { using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; @@ -28,7 +29,7 @@ contract PrivateERC20ResolutionModule is AccessControllerModule, IPrivateERC20Re */ mapping(bytes32 _disputeId => EnumerableSet.AddressSet _votersSet) internal _voters; - constructor(IOracle _oracle) AccessControllerModule(_oracle) {} + constructor(IOracle _oracle) ModuleAccessController(_oracle) {} /// @inheritdoc IModule function moduleName() external pure returns (string memory _moduleName) { @@ -59,12 +60,7 @@ contract PrivateERC20ResolutionModule is AccessControllerModule, IPrivateERC20Re AccessControl calldata _accessControl ) external - hasAccess( - _request.accessControlModule, - _COMMIT_VOTE_TYPEHASH, - abi.encode(_request, _dispute, _commitment), - _accessControl - ) + hasAccess(_request.accessModule, _COMMIT_VOTE_TYPEHASH, abi.encode(_request, _dispute, _commitment), _accessControl) { bytes32 _disputeId = _validateDispute(_request, _dispute); if (ORACLE.disputeStatus(_disputeId) != IOracle.DisputeStatus.Escalated) { @@ -94,7 +90,7 @@ contract PrivateERC20ResolutionModule is AccessControllerModule, IPrivateERC20Re ) external hasAccess( - _request.accessControlModule, + _request.accessModule, _REVEAL_VOTE_TYPEHASH, abi.encode(_request, _dispute, _numberOfVotes, _salt), _accessControl diff --git a/solidity/test/integration/IntegrationBase.sol b/solidity/test/integration/IntegrationBase.sol index cb86d3d..21e0edb 100644 --- a/solidity/test/integration/IntegrationBase.sol +++ b/solidity/test/integration/IntegrationBase.sol @@ -6,8 +6,9 @@ pragma solidity ^0.8.19; import {console} from 'forge-std/console.sol'; import { - AccessController, IAccessController -} from '@defi-wonderland/prophet-core/solidity/contracts/AccessController.sol'; + CommonAccessController, + IAccessController +} from '@defi-wonderland/prophet-core/solidity/contracts/CommonAccessController.sol'; import {IOracle, Oracle} from '@defi-wonderland/prophet-core/solidity/contracts/Oracle.sol'; import {IDisputeModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/dispute/IDisputeModule.sol'; import {IFinalityModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/finality/IFinalityModule.sol'; diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 8927bfa..35ff50e 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -9,8 +9,7 @@ import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfac import {IModule} from '@defi-wonderland/prophet-core/solidity/interfaces/IModule.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; -import {IAccessControlModule} from - '@defi-wonderland/prophet-core/solidity/interfaces/modules/accessControl/IAccessControlModule.sol'; +import {IAccessModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/accessControl/IAccessModule.sol'; import {ValidatorLib} from '@defi-wonderland/prophet-core/solidity/libraries/ValidatorLib.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; @@ -1501,10 +1500,10 @@ contract BondEscalationModule_Unit_SettleBondEscalation is BaseTest { } contract BondEscalationModule_Unit_AccessControl is BaseTest { - address internal _accessControlModule = makeAddr('accessControlModule'); + address internal _accessModule = makeAddr('accessModule'); function setUp() public override { - mockRequest.accessControlModule = _accessControlModule; + mockRequest.accessModule = _accessModule; super.setUp(); } @@ -1537,12 +1536,12 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { // Mock and expect call to access control module vm.mockCall( - _accessControlModule, + _accessModule, abi.encodeCall( - IAccessControlModule.hasAccess, + IAccessModule.hasAccess, ( abi.encode( - IAccessControlModule.AccessControlParameters({ + IAccessModule.AccessControlParameters({ sender: _caller, typehash: _PLEDGE_FOR_DISPUTE_TYPEHASH, params: abi.encode(mockRequest, _dispute), @@ -1603,12 +1602,12 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { // Mock and expect call to access control module vm.mockCall( - _accessControlModule, + _accessModule, abi.encodeCall( - IAccessControlModule.hasAccess, + IAccessModule.hasAccess, ( abi.encode( - IAccessControlModule.AccessControlParameters({ + IAccessModule.AccessControlParameters({ sender: _caller, typehash: _PLEDGE_AGAINST_DISPUTE_TYPEHASH, params: abi.encode(mockRequest, _dispute), diff --git a/solidity/test/utils/Helpers.sol b/solidity/test/utils/Helpers.sol index b92a301..cd3d2ad 100644 --- a/solidity/test/utils/Helpers.sol +++ b/solidity/test/utils/Helpers.sol @@ -13,7 +13,7 @@ contract Helpers is DSTestPlus, TestConstants { // Mock objects IOracle.Request public mockRequest = IOracle.Request({ - accessControlModule: address(0), + accessModule: address(0), requestModule: address(0), responseModule: address(0), disputeModule: address(0), From 0e6fb1b9b08da4c2e9d0d7cbd9dcfa1e496a2d0d Mon Sep 17 00:00:00 2001 From: zorzal Date: Wed, 6 Nov 2024 12:01:56 -0500 Subject: [PATCH 02/11] refactor: remove AccessControllerModule - update imports --- .../accessControl/AccessControllerModule.sol | 40 ------------------- .../modules/dispute/CircuitResolverModule.sol | 1 - .../dispute/RootVerificationModule.sol | 1 - .../modules/resolution/ArbitratorModule.sol | 7 ++-- .../BondEscalationResolutionModule.sol | 1 - .../resolution/ERC20ResolutionModule.sol | 1 - .../PrivateERC20ResolutionModule.sol | 1 - .../modules/response/BondedResponseModule.sol | 5 +-- 8 files changed, 5 insertions(+), 52 deletions(-) delete mode 100644 solidity/contracts/modules/accessControl/AccessControllerModule.sol diff --git a/solidity/contracts/modules/accessControl/AccessControllerModule.sol b/solidity/contracts/modules/accessControl/AccessControllerModule.sol deleted file mode 100644 index af8ad7d..0000000 --- a/solidity/contracts/modules/accessControl/AccessControllerModule.sol +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -// import {AccessController} from '@defi-wonderland/prophet-core/solidity/contracts/AccessController.sol'; -import {Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; -import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; -import { - IAccessController, - IAccessModule -} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/accessControl/IAccessModule.sol'; -// import {ModuleAccessController} from './ModuleAccessController.sol'; - -abstract contract AccessControllerModule is Module { - constructor(IOracle _oracle) Module(_oracle) {} - - /** - * @notice Returns an access control object using the contract address as user and the given data - * @dev should only be used by modules as the self-access-control object - * @param _data Arbitrary data - * @return _accessControl The self access control for this contract. - */ - function _defaultAccessControl(bytes memory _data) - internal - view - returns (IAccessController.AccessControl memory _accessControl) - { - _accessControl = IAccessController.AccessControl({user: address(this), data: _data}); - } - - /** - * // todo: update name to _selfAccessControl - * @notice Returns an access control object using the contract address as user, and empty data - * - * @dev should only be used by modules as the self-access-control object - * @return _accessControl The self access control for this contract. - */ - function _defaultAccessControl() internal view returns (IAccessController.AccessControl memory _accessControl) { - _accessControl = _defaultAccessControl(bytes('')); - } -} diff --git a/solidity/contracts/modules/dispute/CircuitResolverModule.sol b/solidity/contracts/modules/dispute/CircuitResolverModule.sol index f615efc..0345f93 100644 --- a/solidity/contracts/modules/dispute/CircuitResolverModule.sol +++ b/solidity/contracts/modules/dispute/CircuitResolverModule.sol @@ -7,7 +7,6 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IProphetVerifier} from '../../../interfaces/IProphetVerifier.sol'; import {ICircuitResolverModule} from '../../../interfaces/modules/dispute/ICircuitResolverModule.sol'; -import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; contract CircuitResolverModule is ModuleAccessController, ICircuitResolverModule { diff --git a/solidity/contracts/modules/dispute/RootVerificationModule.sol b/solidity/contracts/modules/dispute/RootVerificationModule.sol index 92e329a..f2d0614 100644 --- a/solidity/contracts/modules/dispute/RootVerificationModule.sol +++ b/solidity/contracts/modules/dispute/RootVerificationModule.sol @@ -6,7 +6,6 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IRootVerificationModule} from '../../../interfaces/modules/dispute/IRootVerificationModule.sol'; import {MerkleLib} from '../../libraries/MerkleLib.sol'; -import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; contract RootVerificationModule is ModuleAccessController, IRootVerificationModule { diff --git a/solidity/contracts/modules/resolution/ArbitratorModule.sol b/solidity/contracts/modules/resolution/ArbitratorModule.sol index 9ace482..71169a5 100644 --- a/solidity/contracts/modules/resolution/ArbitratorModule.sol +++ b/solidity/contracts/modules/resolution/ArbitratorModule.sol @@ -6,16 +6,15 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IArbitrator} from '../../../interfaces/IArbitrator.sol'; import {IArbitratorModule} from '../../../interfaces/modules/resolution/IArbitratorModule.sol'; +import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; -import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; - -contract ArbitratorModule is AccessControllerModule, IArbitratorModule { +contract ArbitratorModule is ModuleAccessController, IArbitratorModule { /** * @notice The status of all disputes */ mapping(bytes32 _disputeId => ArbitrationStatus _status) internal _disputeData; - constructor(IOracle _oracle) AccessControllerModule(_oracle) {} + constructor(IOracle _oracle) ModuleAccessController(_oracle) {} /// @inheritdoc IModule function moduleName() external pure returns (string memory _moduleName) { diff --git a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol index 4b025e2..e9af226 100644 --- a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol +++ b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol @@ -16,7 +16,6 @@ import {IResolutionModule} from import {IBondEscalationResolutionModule} from '../../../interfaces/modules/resolution/IBondEscalationResolutionModule.sol'; -import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; import { diff --git a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol index 6fec60e..5297505 100644 --- a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol @@ -12,7 +12,6 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IERC20ResolutionModule} from '../../../interfaces/modules/resolution/IERC20ResolutionModule.sol'; import {_CAST_VOTE_TYPEHASH, _CLAIM_VOTE_TYPEHASH} from '../../utils/Typehash.sol'; -import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; contract ERC20ResolutionModule is ModuleAccessController, IERC20ResolutionModule { diff --git a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol index 2ad114a..4e1c6db 100644 --- a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol @@ -11,7 +11,6 @@ import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; import {IPrivateERC20ResolutionModule} from '../../../interfaces/modules/resolution/IPrivateERC20ResolutionModule.sol'; -import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; contract PrivateERC20ResolutionModule is ModuleAccessController, IPrivateERC20ResolutionModule { diff --git a/solidity/contracts/modules/response/BondedResponseModule.sol b/solidity/contracts/modules/response/BondedResponseModule.sol index c552c1a..cb52b7c 100644 --- a/solidity/contracts/modules/response/BondedResponseModule.sol +++ b/solidity/contracts/modules/response/BondedResponseModule.sol @@ -5,10 +5,9 @@ import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; import {IBondedResponseModule} from '../../../interfaces/modules/response/IBondedResponseModule.sol'; -import {AccessControllerModule} from '../accessControl/AccessControllerModule.sol'; -contract BondedResponseModule is AccessControllerModule, IBondedResponseModule { - constructor(IOracle _oracle) AccessControllerModule(_oracle) {} +contract BondedResponseModule is Module, IBondedResponseModule { + constructor(IOracle _oracle) Module(_oracle) {} /// @inheritdoc IModule function moduleName() public pure returns (string memory _moduleName) { From c6912b062c397afc796538067d364a6fc6317e08 Mon Sep 17 00:00:00 2001 From: zorzal Date: Wed, 6 Nov 2024 12:38:33 -0500 Subject: [PATCH 03/11] feat: skip access control validation when address module is not set --- .../modules/accessControl/ModuleAccessController.sol | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/solidity/contracts/modules/accessControl/ModuleAccessController.sol b/solidity/contracts/modules/accessControl/ModuleAccessController.sol index 3772b0c..0708a14 100644 --- a/solidity/contracts/modules/accessControl/ModuleAccessController.sol +++ b/solidity/contracts/modules/accessControl/ModuleAccessController.sol @@ -36,9 +36,13 @@ abstract contract ModuleAccessController is CommonAccessController, Module { bytes memory _params, AccessControl memory _accessControl ) { - bool _isApproved = ORACLE.isAccessModuleApproved(_accessControl.user, _accessModule); - if (!_isApproved) revert AccessController_NoAccess(); - __hasAccess(_accessModule, _typehash, _params, _accessControl); + if (_accessModule != address(0)) { + bool _isApproved = ORACLE.isAccessModuleApproved(_accessControl.user, _accessModule); + + if (!_isApproved) revert AccessController_NoAccess(); + + _hasAccess(_accessModule, _typehash, _params, _accessControl); + } _; } } From 1955be4db794c1a7ad2de617db08d267d5a389c3 Mon Sep 17 00:00:00 2001 From: zorzal Date: Wed, 6 Nov 2024 12:44:10 -0500 Subject: [PATCH 04/11] test: add necessary mocked call in access control unit testing --- .../modules/dispute/BondEscalationModule.t.sol | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 35ff50e..8f4a0ca 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -8,7 +8,7 @@ import {Helpers} from '../../../utils/Helpers.sol'; import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; import {IModule} from '@defi-wonderland/prophet-core/solidity/interfaces/IModule.sol'; -import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; +import {IOracle, IOracleAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; import {IAccessModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/accessControl/IAccessModule.sol'; import {ValidatorLib} from '@defi-wonderland/prophet-core/solidity/libraries/ValidatorLib.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; @@ -1532,6 +1532,13 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { uint256 _numAgainstPledgers = _numForPledgers + 1; _setBondEscalation(_requestId, _numForPledgers, _numAgainstPledgers); + // expect a call checking whether the access module has been approved by the user + _mockAndExpect( + address(oracle), + abi.encodeCall(IOracleAccessController.isAccessModuleApproved, (_user, _accessModule)), + abi.encode(true) + ); + IAccessController.AccessControl memory _accessControl = IAccessController.AccessControl({user: _user, data: _data}); // Mock and expect call to access control module @@ -1590,6 +1597,13 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { _setBondEscalation(_requestId, _numForPledgers, _numAgainstPledgers); + // todo: extract to helper when we add tests for the other access controlled functions + _mockAndExpect( + address(oracle), + abi.encodeCall(IOracleAccessController.isAccessModuleApproved, (_user, _accessModule)), + abi.encode(true) + ); + _mockAndExpect( address(_params.accountingExtension), abi.encodeCall( From 2d63d581ebc143e581ac3aaad622b2dcf46c339a Mon Sep 17 00:00:00 2001 From: zorzal Date: Wed, 6 Nov 2024 14:39:50 -0500 Subject: [PATCH 05/11] chore: update prophet-core version --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3b374ee..43bd7e5 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "package.json": "sort-package-json" }, "dependencies": { - "@defi-wonderland/prophet-core": "0.0.0-3afab791", + "@defi-wonderland/prophet-core": "0.0.0-17b27bfb", "@openzeppelin/contracts": "4.9.5", "solmate": "https://github.com/transmissions11/solmate.git#bfc9c25865a274a7827fea5abf6e4fb64fc64e6c" }, diff --git a/yarn.lock b/yarn.lock index e9f077b..d93b761 100644 --- a/yarn.lock +++ b/yarn.lock @@ -193,10 +193,10 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@defi-wonderland/prophet-core@0.0.0-3afab791": - version "0.0.0-3afab791" - resolved "https://registry.yarnpkg.com/@defi-wonderland/prophet-core/-/prophet-core-0.0.0-3afab791.tgz#e9e40fabf2ae50b1edbfca806d4159b29b64daec" - integrity sha512-0zvdUCehT2yMDzRPG60XUlMIwSESxeVqaWwVswnDlr3G4ISYhFl1kZvg4fShJTbB9pu9G9tfj19/zFXt0BFaHw== +"@defi-wonderland/prophet-core@0.0.0-17b27bfb": + version "0.0.0-17b27bfb" + resolved "https://registry.yarnpkg.com/@defi-wonderland/prophet-core/-/prophet-core-0.0.0-17b27bfb.tgz#118bb97067eb84bf4059e2b5c35ce7d10689694f" + integrity sha512-auL03R3YeBQDdyAq4GH+I653oBMWOIMH1+sYdxl6HYqWZSb/8+973hZ4tj3M5EfQZeWcFywdjkceKdVjeAcD3g== "@defi-wonderland/solidity-utils@0.0.0-3e9c8e8b": version "0.0.0-3e9c8e8b" From bde5b21b2b18e444f0d38e48b77a5d56461da2bb Mon Sep 17 00:00:00 2001 From: Ashitaka Date: Thu, 7 Nov 2024 15:58:20 -0300 Subject: [PATCH 06/11] fix: package version --- package.json | 2 +- .../modules/accessControl/ModuleAccessController.sol | 1 - .../unit/modules/dispute/BondEscalationModule.t.sol | 10 +++++----- yarn.lock | 8 ++++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 43bd7e5..0a893bb 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "package.json": "sort-package-json" }, "dependencies": { - "@defi-wonderland/prophet-core": "0.0.0-17b27bfb", + "@defi-wonderland/prophet-core": "0.0.0-823459fc", "@openzeppelin/contracts": "4.9.5", "solmate": "https://github.com/transmissions11/solmate.git#bfc9c25865a274a7827fea5abf6e4fb64fc64e6c" }, diff --git a/solidity/contracts/modules/accessControl/ModuleAccessController.sol b/solidity/contracts/modules/accessControl/ModuleAccessController.sol index 0708a14..a672868 100644 --- a/solidity/contracts/modules/accessControl/ModuleAccessController.sol +++ b/solidity/contracts/modules/accessControl/ModuleAccessController.sol @@ -5,7 +5,6 @@ import {CommonAccessController} from '@defi-wonderland/prophet-core/solidity/con import {Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; -import {IAccessModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/accessControl/IAccessModule.sol'; abstract contract ModuleAccessController is CommonAccessController, Module { constructor(IOracle _oracle) Module(_oracle) {} diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 8f4a0ca..623a20d 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -9,7 +9,7 @@ import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfac import {IModule} from '@defi-wonderland/prophet-core/solidity/interfaces/IModule.sol'; import {IOracle, IOracleAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; -import {IAccessModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/accessControl/IAccessModule.sol'; +import {IAccessModule} from '@defi-wonderland/prophet-core/solidity/interfaces/modules/access/IAccessModule.sol'; import {ValidatorLib} from '@defi-wonderland/prophet-core/solidity/libraries/ValidatorLib.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; @@ -1550,9 +1550,9 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { abi.encode( IAccessModule.AccessControlParameters({ sender: _caller, + accessControl: _accessControl, typehash: _PLEDGE_FOR_DISPUTE_TYPEHASH, - params: abi.encode(mockRequest, _dispute), - accessControl: _accessControl + typehashParams: abi.encode(mockRequest, _dispute) }) ) ) @@ -1623,9 +1623,9 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { abi.encode( IAccessModule.AccessControlParameters({ sender: _caller, + accessControl: _accessControl, typehash: _PLEDGE_AGAINST_DISPUTE_TYPEHASH, - params: abi.encode(mockRequest, _dispute), - accessControl: _accessControl + typehashParams: abi.encode(mockRequest, _dispute) }) ) ) diff --git a/yarn.lock b/yarn.lock index d93b761..ac0d62e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -193,10 +193,10 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@defi-wonderland/prophet-core@0.0.0-17b27bfb": - version "0.0.0-17b27bfb" - resolved "https://registry.yarnpkg.com/@defi-wonderland/prophet-core/-/prophet-core-0.0.0-17b27bfb.tgz#118bb97067eb84bf4059e2b5c35ce7d10689694f" - integrity sha512-auL03R3YeBQDdyAq4GH+I653oBMWOIMH1+sYdxl6HYqWZSb/8+973hZ4tj3M5EfQZeWcFywdjkceKdVjeAcD3g== +"@defi-wonderland/prophet-core@0.0.0-823459fc": + version "0.0.0-823459fc" + resolved "https://registry.yarnpkg.com/@defi-wonderland/prophet-core/-/prophet-core-0.0.0-823459fc.tgz#a48f7b35899968468f37f5c9eb2c67a1c8a823ff" + integrity sha512-lqTFlKFUwt4yjBGnSUJf9PwNQE6MP4KJHUSCov2+yxJCkKHKzFlYQ7M25dAdebiwa6Hfd+XHQfLx1bzff6mM6Q== "@defi-wonderland/solidity-utils@0.0.0-3e9c8e8b": version "0.0.0-3e9c8e8b" From 13b03b89e94a8fc5ae3deb064d3fd25163e60dcb Mon Sep 17 00:00:00 2001 From: zorzal Date: Thu, 7 Nov 2024 08:27:40 -0500 Subject: [PATCH 07/11] refactor: rename modules/accessControl to modules/access --- .../{accessControl => access}/ModuleAccessController.sol | 0 solidity/contracts/modules/dispute/BondEscalationModule.sol | 2 +- solidity/contracts/modules/dispute/CircuitResolverModule.sol | 2 +- .../contracts/modules/dispute/RootVerificationModule.sol | 2 +- solidity/contracts/modules/resolution/ArbitratorModule.sol | 2 +- .../modules/resolution/BondEscalationResolutionModule.sol | 2 +- .../contracts/modules/resolution/ERC20ResolutionModule.sol | 2 +- .../modules/resolution/PrivateERC20ResolutionModule.sol | 2 +- .../test/unit/modules/dispute/BondEscalationModule.t.sol | 5 +++++ 9 files changed, 12 insertions(+), 7 deletions(-) rename solidity/contracts/modules/{accessControl => access}/ModuleAccessController.sol (100%) diff --git a/solidity/contracts/modules/accessControl/ModuleAccessController.sol b/solidity/contracts/modules/access/ModuleAccessController.sol similarity index 100% rename from solidity/contracts/modules/accessControl/ModuleAccessController.sol rename to solidity/contracts/modules/access/ModuleAccessController.sol diff --git a/solidity/contracts/modules/dispute/BondEscalationModule.sol b/solidity/contracts/modules/dispute/BondEscalationModule.sol index f65a518..1280734 100644 --- a/solidity/contracts/modules/dispute/BondEscalationModule.sol +++ b/solidity/contracts/modules/dispute/BondEscalationModule.sol @@ -9,7 +9,7 @@ import {IBondEscalationModule} from '../../../interfaces/modules/dispute/IBondEs import {_PLEDGE_AGAINST_DISPUTE_TYPEHASH, _PLEDGE_FOR_DISPUTE_TYPEHASH} from '../../utils/Typehash.sol'; -import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; +import {ModuleAccessController} from '../access/ModuleAccessController.sol'; contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { /// @inheritdoc IBondEscalationModule diff --git a/solidity/contracts/modules/dispute/CircuitResolverModule.sol b/solidity/contracts/modules/dispute/CircuitResolverModule.sol index 0345f93..c7d06d7 100644 --- a/solidity/contracts/modules/dispute/CircuitResolverModule.sol +++ b/solidity/contracts/modules/dispute/CircuitResolverModule.sol @@ -7,7 +7,7 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IProphetVerifier} from '../../../interfaces/IProphetVerifier.sol'; import {ICircuitResolverModule} from '../../../interfaces/modules/dispute/ICircuitResolverModule.sol'; -import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; +import {ModuleAccessController} from '../access/ModuleAccessController.sol'; contract CircuitResolverModule is ModuleAccessController, ICircuitResolverModule { /// @notice Keeps track of the correct responses to requests diff --git a/solidity/contracts/modules/dispute/RootVerificationModule.sol b/solidity/contracts/modules/dispute/RootVerificationModule.sol index f2d0614..24e164a 100644 --- a/solidity/contracts/modules/dispute/RootVerificationModule.sol +++ b/solidity/contracts/modules/dispute/RootVerificationModule.sol @@ -6,7 +6,7 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IRootVerificationModule} from '../../../interfaces/modules/dispute/IRootVerificationModule.sol'; import {MerkleLib} from '../../libraries/MerkleLib.sol'; -import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; +import {ModuleAccessController} from '../access/ModuleAccessController.sol'; contract RootVerificationModule is ModuleAccessController, IRootVerificationModule { using MerkleLib for MerkleLib.Tree; diff --git a/solidity/contracts/modules/resolution/ArbitratorModule.sol b/solidity/contracts/modules/resolution/ArbitratorModule.sol index 71169a5..f970df6 100644 --- a/solidity/contracts/modules/resolution/ArbitratorModule.sol +++ b/solidity/contracts/modules/resolution/ArbitratorModule.sol @@ -6,7 +6,7 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IArbitrator} from '../../../interfaces/IArbitrator.sol'; import {IArbitratorModule} from '../../../interfaces/modules/resolution/IArbitratorModule.sol'; -import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; +import {ModuleAccessController} from '../access/ModuleAccessController.sol'; contract ArbitratorModule is ModuleAccessController, IArbitratorModule { /** diff --git a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol index e9af226..f450488 100644 --- a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol +++ b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol @@ -16,7 +16,7 @@ import {IResolutionModule} from import {IBondEscalationResolutionModule} from '../../../interfaces/modules/resolution/IBondEscalationResolutionModule.sol'; -import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; +import {ModuleAccessController} from '../access/ModuleAccessController.sol'; import { _CLAIM_PLEDGE_TYPEHASH, diff --git a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol index 5297505..e14ba00 100644 --- a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol @@ -12,7 +12,7 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IERC20ResolutionModule} from '../../../interfaces/modules/resolution/IERC20ResolutionModule.sol'; import {_CAST_VOTE_TYPEHASH, _CLAIM_VOTE_TYPEHASH} from '../../utils/Typehash.sol'; -import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; +import {ModuleAccessController} from '../access/ModuleAccessController.sol'; contract ERC20ResolutionModule is ModuleAccessController, IERC20ResolutionModule { using SafeERC20 for IERC20; diff --git a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol index 4e1c6db..09dd4d8 100644 --- a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol @@ -11,7 +11,7 @@ import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; import {IPrivateERC20ResolutionModule} from '../../../interfaces/modules/resolution/IPrivateERC20ResolutionModule.sol'; -import {ModuleAccessController} from '../accessControl/ModuleAccessController.sol'; +import {ModuleAccessController} from '../access/ModuleAccessController.sol'; contract PrivateERC20ResolutionModule is ModuleAccessController, IPrivateERC20ResolutionModule { using SafeERC20 for IERC20; diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 623a20d..3906818 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -1552,7 +1552,12 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { sender: _caller, accessControl: _accessControl, typehash: _PLEDGE_FOR_DISPUTE_TYPEHASH, +<<<<<<< HEAD typehashParams: abi.encode(mockRequest, _dispute) +======= + typehashParams: abi.encode(mockRequest, _dispute), + accessControl: _accessControl +>>>>>>> 1045a6d (refactor: rename modules/accessControl to modules/access) }) ) ) From 0610e87ddab210e8caccb81b00b89d387d516fde Mon Sep 17 00:00:00 2001 From: zorzal Date: Fri, 8 Nov 2024 05:02:14 -0500 Subject: [PATCH 08/11] feat: add IModuleAccessController interface --- .../access/IModuleAccessController.sol | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 solidity/interfaces/modules/access/IModuleAccessController.sol diff --git a/solidity/interfaces/modules/access/IModuleAccessController.sol b/solidity/interfaces/modules/access/IModuleAccessController.sol new file mode 100644 index 0000000..1713b7d --- /dev/null +++ b/solidity/interfaces/modules/access/IModuleAccessController.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {IAccessController} from '@defi-wonderland/prophet-core/solidity/interfaces/IAccessController.sol'; + +/** + * @title Module Access Controller Interface + * @notice Interface for the module access controller + */ +interface IModuleAccessController is IAccessController { + /*/////////////////////////////////////////////////////////////// + EVENTS + //////////////////////////////////////////////////////////////*/ + + /*/////////////////////////////////////////////////////////////// + STRUCTS + //////////////////////////////////////////////////////////////*/ + + /*/////////////////////////////////////////////////////////////// + ERRORS + //////////////////////////////////////////////////////////////*/ + + /** + * @notice Thrown when user has not approved the access module + */ + error ModuleAccessController_AccessModuleNotApproved(); + + /*/////////////////////////////////////////////////////////////// + VARIABLES + //////////////////////////////////////////////////////////////*/ + + /*/////////////////////////////////////////////////////////////// + LOGIC + //////////////////////////////////////////////////////////////*/ +} From fc27d214f63fcc7bbe61368e728acec7652415b4 Mon Sep 17 00:00:00 2001 From: zorzal Date: Fri, 8 Nov 2024 05:02:58 -0500 Subject: [PATCH 09/11] feat: update hasAccess modifier --- .../modules/access/ModuleAccessController.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/solidity/contracts/modules/access/ModuleAccessController.sol b/solidity/contracts/modules/access/ModuleAccessController.sol index a672868..e2cd9c2 100644 --- a/solidity/contracts/modules/access/ModuleAccessController.sol +++ b/solidity/contracts/modules/access/ModuleAccessController.sol @@ -3,10 +3,11 @@ pragma solidity ^0.8.19; import {CommonAccessController} from '@defi-wonderland/prophet-core/solidity/contracts/CommonAccessController.sol'; +import {IModuleAccessController} from '../../../interfaces/modules/access/IModuleAccessController.sol'; import {Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; -abstract contract ModuleAccessController is CommonAccessController, Module { +abstract contract ModuleAccessController is IModuleAccessController, CommonAccessController, Module { constructor(IOracle _oracle) Module(_oracle) {} /** @@ -35,13 +36,12 @@ abstract contract ModuleAccessController is CommonAccessController, Module { bytes memory _params, AccessControl memory _accessControl ) { - if (_accessModule != address(0)) { - bool _isApproved = ORACLE.isAccessModuleApproved(_accessControl.user, _accessModule); - - if (!_isApproved) revert AccessController_NoAccess(); - - _hasAccess(_accessModule, _typehash, _params, _accessControl); + // Revert if sender is acting for a user without module approval + if (msg.sender != _accessControl.user && !ORACLE.isAccessModuleApproved(_accessControl.user, _accessModule)) { + revert ModuleAccessController_AccessModuleNotApproved(); } + // todo: probably a change name is required here, something like `_ensureAccess`? + _hasAccess(_accessModule, _typehash, _params, _accessControl); _; } } From 2b5a9885ae6cedda05810f288e5b1be01df42830 Mon Sep 17 00:00:00 2001 From: zorzal Date: Fri, 8 Nov 2024 05:15:10 -0500 Subject: [PATCH 10/11] test: add unit test for when user did not approve the access module --- .../dispute/BondEscalationModule.t.sol | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 3906818..1f747e9 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -23,6 +23,7 @@ import { } from '../../../../contracts/utils/Typehash.sol'; import {IAccountingExtension} from '../../../../interfaces/extensions/IAccountingExtension.sol'; import {IBondEscalationAccounting} from '../../../../interfaces/extensions/IBondEscalationAccounting.sol'; +import {IModuleAccessController} from '../../../../interfaces/modules/access/IModuleAccessController.sol'; /** * @dev Harness to set an entry in the requestData mapping, without triggering setup request hooks @@ -1507,7 +1508,7 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { super.setUp(); } - function test_pledgeForDispute_accessControl( + function test_pledgeForDispute_accessControl_granted( address _caller, address _user, bytes memory _data, @@ -1552,12 +1553,7 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { sender: _caller, accessControl: _accessControl, typehash: _PLEDGE_FOR_DISPUTE_TYPEHASH, -<<<<<<< HEAD typehashParams: abi.encode(mockRequest, _dispute) -======= - typehashParams: abi.encode(mockRequest, _dispute), - accessControl: _accessControl ->>>>>>> 1045a6d (refactor: rename modules/accessControl to modules/access) }) ) ) @@ -1577,7 +1573,29 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { bondEscalationModule.pledgeForDispute(mockRequest, _dispute, _accessControl); } - function test_pledgeAgainstDispute_accessControl( + function test_pledgeForDispute_accessControl_notGranted( + address _caller, + address _user, + bytes memory _data, + IBondEscalationModule.RequestParameters memory _params + ) public assumeFuzzable(address(_params.accountingExtension)) { + vm.assume(_caller != _user); + + // mock and expect a call checking whether the access module has been approved by the user + _mockAndExpect( + address(oracle), + abi.encodeCall(IOracleAccessController.isAccessModuleApproved, (_user, _accessModule)), + abi.encode(false) + ); + + IAccessController.AccessControl memory _accessControl = IAccessController.AccessControl({user: _user, data: _data}); + + vm.expectRevert(IModuleAccessController.ModuleAccessController_AccessModuleNotApproved.selector); + vm.prank(_caller); + bondEscalationModule.pledgeForDispute(mockRequest, mockDispute, _accessControl); + } + + function test_pledgeAgainstDispute_accessControl_granted( address _caller, address _user, bytes memory _data, From 860783508a4d61bab40e15fd6a8907a17a17adf0 Mon Sep 17 00:00:00 2001 From: zorzal Date: Fri, 8 Nov 2024 09:22:35 -0500 Subject: [PATCH 11/11] feat: use library instead of free variables --- .../modules/dispute/BondEscalationModule.sol | 18 ++++++++++--- .../BondEscalationResolutionModule.sol | 20 ++++++++------ .../resolution/ERC20ResolutionModule.sol | 9 ++++--- .../PrivateERC20ResolutionModule.sol | 11 +++++--- solidity/contracts/utils/ModuleTypehash.sol | 26 +++++++++++++++++++ solidity/contracts/utils/Typehash.sol | 22 ---------------- .../dispute/BondEscalationModule.t.sol | 8 +++--- 7 files changed, 69 insertions(+), 45 deletions(-) create mode 100644 solidity/contracts/utils/ModuleTypehash.sol delete mode 100644 solidity/contracts/utils/Typehash.sol diff --git a/solidity/contracts/modules/dispute/BondEscalationModule.sol b/solidity/contracts/modules/dispute/BondEscalationModule.sol index 1280734..08906b5 100644 --- a/solidity/contracts/modules/dispute/BondEscalationModule.sol +++ b/solidity/contracts/modules/dispute/BondEscalationModule.sol @@ -7,10 +7,10 @@ import {FixedPointMathLib} from 'solmate/src/utils/FixedPointMathLib.sol'; import {IBondEscalationModule} from '../../../interfaces/modules/dispute/IBondEscalationModule.sol'; -import {_PLEDGE_AGAINST_DISPUTE_TYPEHASH, _PLEDGE_FOR_DISPUTE_TYPEHASH} from '../../utils/Typehash.sol'; - import {ModuleAccessController} from '../access/ModuleAccessController.sol'; +import {ModuleTypehash} from '../../utils/ModuleTypehash.sol'; + contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { /// @inheritdoc IBondEscalationModule mapping(bytes32 _requestId => mapping(address _pledger => uint256 pledges)) public pledgesForDispute; @@ -218,7 +218,12 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { AccessControl calldata _accessControl ) external - hasAccess(_request.accessModule, _PLEDGE_FOR_DISPUTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) + hasAccess( + _request.accessModule, + ModuleTypehash._PLEDGE_FOR_DISPUTE_TYPEHASH, + abi.encode(_request, _dispute), + _accessControl + ) { bytes32 _disputeId = _getId(_dispute); RequestParameters memory _params = _pledgeChecks(_request, _dispute, true); @@ -245,7 +250,12 @@ contract BondEscalationModule is ModuleAccessController, IBondEscalationModule { AccessControl calldata _accessControl ) external - hasAccess(_request.accessModule, _PLEDGE_AGAINST_DISPUTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) + hasAccess( + _request.accessModule, + ModuleTypehash._PLEDGE_AGAINST_DISPUTE_TYPEHASH, + abi.encode(_request, _dispute), + _accessControl + ) { bytes32 _disputeId = _getId(_dispute); RequestParameters memory _params = _pledgeChecks(_request, _dispute, false); diff --git a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol index f450488..63002a9 100644 --- a/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol +++ b/solidity/contracts/modules/resolution/BondEscalationResolutionModule.sol @@ -18,11 +18,7 @@ import {IBondEscalationResolutionModule} from '../../../interfaces/modules/resolution/IBondEscalationResolutionModule.sol'; import {ModuleAccessController} from '../access/ModuleAccessController.sol'; -import { - _CLAIM_PLEDGE_TYPEHASH, - _PLEDGE_AGAINST_DISPUTE_TYPEHASH, - _PLEDGE_FOR_DISPUTE_TYPEHASH -} from '../../utils/Typehash.sol'; +import {ModuleTypehash} from '../../utils/ModuleTypehash.sol'; contract BondEscalationResolutionModule is ModuleAccessController, IBondEscalationResolutionModule { using SafeERC20 for IERC20; @@ -75,7 +71,7 @@ contract BondEscalationResolutionModule is ModuleAccessController, IBondEscalati external hasAccess( _request.accessModule, - _PLEDGE_FOR_DISPUTE_TYPEHASH, + ModuleTypehash._PLEDGE_FOR_DISPUTE_TYPEHASH, abi.encode(_request, _dispute, _pledgeAmount), _accessControl ) @@ -99,7 +95,7 @@ contract BondEscalationResolutionModule is ModuleAccessController, IBondEscalati external hasAccess( _request.accessModule, - _PLEDGE_AGAINST_DISPUTE_TYPEHASH, + ModuleTypehash._PLEDGE_AGAINST_DISPUTE_TYPEHASH, abi.encode(_request, _dispute, _pledgeAmount), _accessControl ) @@ -162,7 +158,15 @@ contract BondEscalationResolutionModule is ModuleAccessController, IBondEscalati IOracle.Request calldata _request, IOracle.Dispute calldata _dispute, AccessControl calldata _accessControl - ) external hasAccess(_request.accessModule, _CLAIM_PLEDGE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) { + ) + external + hasAccess( + _request.accessModule, + ModuleTypehash._CLAIM_PLEDGE_TYPEHASH, + abi.encode(_request, _dispute), + _accessControl + ) + { bytes32 _disputeId = _validateDispute(_request, _dispute); Escalation storage _escalation = escalations[_disputeId]; diff --git a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol index e14ba00..9e187af 100644 --- a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol @@ -11,7 +11,7 @@ import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle import {IERC20ResolutionModule} from '../../../interfaces/modules/resolution/IERC20ResolutionModule.sol'; -import {_CAST_VOTE_TYPEHASH, _CLAIM_VOTE_TYPEHASH} from '../../utils/Typehash.sol'; +import {ModuleTypehash} from '../../utils/ModuleTypehash.sol'; import {ModuleAccessController} from '../access/ModuleAccessController.sol'; contract ERC20ResolutionModule is ModuleAccessController, IERC20ResolutionModule { @@ -62,7 +62,7 @@ contract ERC20ResolutionModule is ModuleAccessController, IERC20ResolutionModule external hasAccess( _request.accessModule, - _CAST_VOTE_TYPEHASH, + ModuleTypehash._CAST_VOTE_TYPEHASH, abi.encode(_request, _dispute, _numberOfVotes, _numberOfVotes), _accessControl ) @@ -138,7 +138,10 @@ contract ERC20ResolutionModule is ModuleAccessController, IERC20ResolutionModule IOracle.Request calldata _request, IOracle.Dispute calldata _dispute, AccessControl calldata _accessControl - ) external hasAccess(_request.accessModule, _CLAIM_VOTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) { + ) + external + hasAccess(_request.accessModule, ModuleTypehash._CLAIM_VOTE_TYPEHASH, abi.encode(_request, _dispute), _accessControl) + { bytes32 _disputeId = _validateDispute(_request, _dispute); Escalation memory _escalation = escalations[_disputeId]; diff --git a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol index 09dd4d8..d71705e 100644 --- a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol @@ -6,7 +6,7 @@ import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; -import {_COMMIT_VOTE_TYPEHASH, _REVEAL_VOTE_TYPEHASH} from '../../utils/Typehash.sol'; +import {ModuleTypehash} from '../../utils/ModuleTypehash.sol'; import {IModule, Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol'; import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol'; @@ -59,7 +59,12 @@ contract PrivateERC20ResolutionModule is ModuleAccessController, IPrivateERC20Re AccessControl calldata _accessControl ) external - hasAccess(_request.accessModule, _COMMIT_VOTE_TYPEHASH, abi.encode(_request, _dispute, _commitment), _accessControl) + hasAccess( + _request.accessModule, + ModuleTypehash._COMMIT_VOTE_TYPEHASH, + abi.encode(_request, _dispute, _commitment), + _accessControl + ) { bytes32 _disputeId = _validateDispute(_request, _dispute); if (ORACLE.disputeStatus(_disputeId) != IOracle.DisputeStatus.Escalated) { @@ -90,7 +95,7 @@ contract PrivateERC20ResolutionModule is ModuleAccessController, IPrivateERC20Re external hasAccess( _request.accessModule, - _REVEAL_VOTE_TYPEHASH, + ModuleTypehash._REVEAL_VOTE_TYPEHASH, abi.encode(_request, _dispute, _numberOfVotes, _salt), _accessControl ) diff --git a/solidity/contracts/utils/ModuleTypehash.sol b/solidity/contracts/utils/ModuleTypehash.sol new file mode 100644 index 0000000..37f44ec --- /dev/null +++ b/solidity/contracts/utils/ModuleTypehash.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +library ModuleTypehash { + bytes32 internal constant _PLEDGE_FOR_DISPUTE_TYPEHASH = + keccak256('pledgeForDispute(Request _request, Dispute _dispute,IAccessController.AccessControl _accessControl)'); + + bytes32 internal constant _PLEDGE_AGAINST_DISPUTE_TYPEHASH = + keccak256('pledgeAgainstDispute(Request _request,Dispute _dispute,IAccessController.AccessControl _accessControl)'); + + bytes32 internal constant _CLAIM_PLEDGE_TYPEHASH = + keccak256('claimPledge(Request _request,Dispute _dispute,AccessControl _accessControl)'); + + bytes32 internal constant _CLAIM_VOTE_TYPEHASH = + keccak256('claimVote(Request _request,Dispute _dispute,AccessControl _accessControl)'); + + bytes32 internal constant _CAST_VOTE_TYPEHASH = + keccak256('castVote(Request _request,Dispute _dispute,uint256 _numberOfVotes,AccessControl _accessControl)'); + + bytes32 internal constant _COMMIT_VOTE_TYPEHASH = + keccak256('commitVote(Request _request,Dispute _dispute,bytes32 _commitment,AccessControl _accessControl)'); + + bytes32 internal constant _REVEAL_VOTE_TYPEHASH = keccak256( + 'revealVote(Request _request,Dispute _dispute,uint256 _numberOfVotes,bytes32 _salt,AccessControl _accessControl)' + ); +} diff --git a/solidity/contracts/utils/Typehash.sol b/solidity/contracts/utils/Typehash.sol deleted file mode 100644 index a64ddea..0000000 --- a/solidity/contracts/utils/Typehash.sol +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -bytes32 constant _PLEDGE_FOR_DISPUTE_TYPEHASH = - keccak256('pledgeForDispute(Request _request, Dispute _dispute,IAccessController.AccessControl _accessControl)'); - -bytes32 constant _PLEDGE_AGAINST_DISPUTE_TYPEHASH = - keccak256('pledgeAgainstDispute(Request _request,Dispute _dispute,IAccessController.AccessControl _accessControl)'); - -bytes32 constant _CLAIM_PLEDGE_TYPEHASH = - keccak256('claimPledge(Request _request,Dispute _dispute,AccessControl _accessControl)'); - -bytes32 constant _CLAIM_VOTE_TYPEHASH = - keccak256('claimVote(Request _request,Dispute _dispute,AccessControl _accessControl)'); - -bytes32 constant _CAST_VOTE_TYPEHASH = - keccak256('castVote(Request _request,Dispute _dispute,uint256 _numberOfVotes,AccessControl _accessControl)'); -bytes32 constant _COMMIT_VOTE_TYPEHASH = - keccak256('commitVote(Request _request,Dispute _dispute,bytes32 _commitment,AccessControl _accessControl)'); -bytes32 constant _REVEAL_VOTE_TYPEHASH = keccak256( - 'revealVote(Request _request,Dispute _dispute,uint256 _numberOfVotes,bytes32 _salt,AccessControl _accessControl)' -); diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 1f747e9..1adf211 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -18,9 +18,7 @@ import { BondEscalationModule, IBondEscalationModule } from '../../../../contracts/modules/dispute/BondEscalationModule.sol'; -import { - _PLEDGE_AGAINST_DISPUTE_TYPEHASH, _PLEDGE_FOR_DISPUTE_TYPEHASH -} from '../../../../contracts/utils/Typehash.sol'; +import {ModuleTypehash} from '../../../../contracts/utils/ModuleTypehash.sol'; import {IAccountingExtension} from '../../../../interfaces/extensions/IAccountingExtension.sol'; import {IBondEscalationAccounting} from '../../../../interfaces/extensions/IBondEscalationAccounting.sol'; import {IModuleAccessController} from '../../../../interfaces/modules/access/IModuleAccessController.sol'; @@ -1552,7 +1550,7 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { IAccessModule.AccessControlParameters({ sender: _caller, accessControl: _accessControl, - typehash: _PLEDGE_FOR_DISPUTE_TYPEHASH, + typehash: ModuleTypehash._PLEDGE_FOR_DISPUTE_TYPEHASH, typehashParams: abi.encode(mockRequest, _dispute) }) ) @@ -1647,7 +1645,7 @@ contract BondEscalationModule_Unit_AccessControl is BaseTest { IAccessModule.AccessControlParameters({ sender: _caller, accessControl: _accessControl, - typehash: _PLEDGE_AGAINST_DISPUTE_TYPEHASH, + typehash: ModuleTypehash._PLEDGE_AGAINST_DISPUTE_TYPEHASH, typehashParams: abi.encode(mockRequest, _dispute) }) )