From 835b91da3e5bc162ee6071a1d1a596294af24330 Mon Sep 17 00:00:00 2001 From: shaito Date: Wed, 11 Dec 2024 09:41:00 -0300 Subject: [PATCH] fix: remove ipfs hash --- package.json | 3 +- solidity/contracts/Oracle.sol | 10 ++----- solidity/contracts/utils/OracleTypehash.sol | 3 +- solidity/interfaces/IOracle.sol | 7 +---- .../test/integration/EscalateDispute.t.sol | 2 +- solidity/test/integration/Finalization.t.sol | 12 ++++---- solidity/test/integration/IntegrationBase.sol | 1 - .../test/integration/ResponseDispute.t.sol | 2 +- .../test/integration/ResponseProposal.t.sol | 6 ++-- solidity/test/unit/Oracle.t.sol | 28 +++++++------------ 10 files changed, 28 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index 07a15ed..970c528 100644 --- a/package.json +++ b/package.json @@ -48,5 +48,6 @@ "solhint-plugin-defi-wonderland": "1.1.2", "sort-package-json": "2.4.1", "standard-version": "9.5.0" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/solidity/contracts/Oracle.sol b/solidity/contracts/Oracle.sol index 9283cb9..5c5fb1f 100644 --- a/solidity/contracts/Oracle.sol +++ b/solidity/contracts/Oracle.sol @@ -98,23 +98,21 @@ contract Oracle is IOracle, OracleAccessController { /// @inheritdoc IOracle function createRequest( Request calldata _request, - bytes32 _ipfsHash, AccessControl calldata _accessControl ) external returns (bytes32 _requestId) { - _requestId = _createRequest(_request, _ipfsHash, _accessControl); + _requestId = _createRequest(_request, _accessControl); } /// @inheritdoc IOracle function createRequests( Request[] calldata _requestsData, - bytes32[] calldata _ipfsHashes, AccessControl[] calldata _accessControl ) external returns (bytes32[] memory _batchRequestsIds) { uint256 _requestsAmount = _requestsData.length; _batchRequestsIds = new bytes32[](_requestsAmount); for (uint256 _i; _i < _requestsAmount;) { - _batchRequestsIds[_i] = _createRequest(_requestsData[_i], _ipfsHashes[_i], _accessControl[_i]); + _batchRequestsIds[_i] = _createRequest(_requestsData[_i], _accessControl[_i]); unchecked { ++_i; } @@ -430,13 +428,11 @@ contract Oracle is IOracle, OracleAccessController { * @notice Stores a request in the contract and configures it in the modules * * @param _request The request to be created - * @param _ipfsHash The hashed IPFS CID of the metadata json * @param _accessControl The access control struct * @return _requestId The id of the created request */ function _createRequest( Request memory _request, - bytes32 _ipfsHash, AccessControl calldata _accessControl ) internal @@ -465,6 +461,6 @@ contract Oracle is IOracle, OracleAccessController { IRequestModule(_request.requestModule).createRequest(_requestId, _request.requestModuleData, _accessControl.user); - emit RequestCreated(_requestId, _request, _ipfsHash); + emit RequestCreated(_requestId, _request); } } diff --git a/solidity/contracts/utils/OracleTypehash.sol b/solidity/contracts/utils/OracleTypehash.sol index 77ae352..8d2e754 100644 --- a/solidity/contracts/utils/OracleTypehash.sol +++ b/solidity/contracts/utils/OracleTypehash.sol @@ -2,8 +2,7 @@ pragma solidity ^0.8.19; library OracleTypehash { - bytes32 public constant CREATE_TYPEHASH = - keccak256('createRequest(Request _request,bytes32 _ipfsHash,AccessControl _accessControl'); + bytes32 public constant CREATE_TYPEHASH = keccak256('createRequest(Request _request,AccessControl _accessControl'); bytes32 public constant PROPOSE_TYPEHASH = keccak256('proposeResponse(Request _request,Response _response,AccessControl _accessControl)'); diff --git a/solidity/interfaces/IOracle.sol b/solidity/interfaces/IOracle.sol index 6246de7..3525c66 100644 --- a/solidity/interfaces/IOracle.sol +++ b/solidity/interfaces/IOracle.sol @@ -16,9 +16,8 @@ interface IOracle is IOracleAccessController { * @notice Emitted when a request is created * @param _requestId The id of the created request * @param _request The request that has been created - * @param _ipfsHash The hashed IPFS CID of the metadata json */ - event RequestCreated(bytes32 indexed _requestId, Request _request, bytes32 _ipfsHash); + event RequestCreated(bytes32 indexed _requestId, Request _request); /** * @notice Emitted when a response is proposed @@ -366,13 +365,11 @@ interface IOracle is IOracleAccessController { * * @dev The modules must be real contracts following the IModule interface * @param _request The request data - * @param _ipfsHash The hashed IPFS CID of the metadata json * @param _accessControl The access control data * @return _requestId The id of the request, can be used to propose a response or query results */ function createRequest( Request memory _request, - bytes32 _ipfsHash, AccessControl calldata _accessControl ) external returns (bytes32 _requestId); @@ -381,12 +378,10 @@ interface IOracle is IOracleAccessController { * * @param _requestsData The array of calldata for each request * @return _batchRequestsIds The array of request IDs - * @param _ipfsHashes The array of hashed IPFS CIDs of the metadata files * @param _accessControl The array of access control datas */ function createRequests( Request[] calldata _requestsData, - bytes32[] calldata _ipfsHashes, AccessControl[] calldata _accessControl ) external returns (bytes32[] memory _batchRequestsIds); diff --git a/solidity/test/integration/EscalateDispute.t.sol b/solidity/test/integration/EscalateDispute.t.sol index 8c3b140..1e012c8 100644 --- a/solidity/test/integration/EscalateDispute.t.sol +++ b/solidity/test/integration/EscalateDispute.t.sol @@ -7,7 +7,7 @@ contract Integration_EscalateDispute is IntegrationBase { function test_escalateDispute() public { // Create the request mockAccessControl.user = requester; - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); // Submit a response mockAccessControl.user = proposer; diff --git a/solidity/test/integration/Finalization.t.sol b/solidity/test/integration/Finalization.t.sol index 42a89ee..2680f57 100644 --- a/solidity/test/integration/Finalization.t.sol +++ b/solidity/test/integration/Finalization.t.sol @@ -23,7 +23,7 @@ contract Integration_Finalization is IntegrationBase { ); mockAccessControl.user = requester; - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); _jumpToFinalization(); @@ -39,7 +39,7 @@ contract Integration_Finalization is IntegrationBase { abi.encode(IMockFinalityModule.RequestParameters({target: _callbackTarget, data: _calldata})); mockAccessControl.user = requester; - bytes32 _requestId = oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + bytes32 _requestId = oracle.createRequest(mockRequest, mockAccessControl); _jumpToFinalization(); @@ -60,7 +60,7 @@ contract Integration_Finalization is IntegrationBase { */ function test_finalizeWithoutResponse() public { mockAccessControl.user = requester; - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); vm.stopPrank(); mockResponse.requestId = bytes32(0); @@ -88,7 +88,7 @@ contract Integration_Finalization is IntegrationBase { mockDispute.responseId = _getId(mockResponse); mockAccessControl.user = requester; - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); mockAccessControl.user = proposer; oracle.proposeResponse(mockRequest, mockResponse, mockAccessControl); @@ -109,7 +109,7 @@ contract Integration_Finalization is IntegrationBase { abi.encode(IMockFinalityModule.RequestParameters({target: _callbackTarget, data: bytes('')})); mockAccessControl.user = requester; - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); } /** @@ -121,7 +121,7 @@ contract Integration_Finalization is IntegrationBase { mockAccessControl.user = requester; vm.expectCall(_callbackTarget, _calldata); - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); _jumpToFinalization(); diff --git a/solidity/test/integration/IntegrationBase.sol b/solidity/test/integration/IntegrationBase.sol index 701ded5..13f865d 100644 --- a/solidity/test/integration/IntegrationBase.sol +++ b/solidity/test/integration/IntegrationBase.sol @@ -65,7 +65,6 @@ contract IntegrationBase is TestConstants, Helpers { uint256 internal _expectedDeadline; uint256 internal _expectedCallbackValue = 42; uint256 internal _baseDisputeWindow = 12 hours; - bytes32 internal _ipfsHash = bytes32('QmR4uiJH654k3Ta2uLLQ8r'); function setUp() public virtual { vm.createSelectFork(vm.rpcUrl('optimism'), FORK_BLOCK); diff --git a/solidity/test/integration/ResponseDispute.t.sol b/solidity/test/integration/ResponseDispute.t.sol index 5e1b76b..cdd105c 100644 --- a/solidity/test/integration/ResponseDispute.t.sol +++ b/solidity/test/integration/ResponseDispute.t.sol @@ -17,7 +17,7 @@ contract Integration_ResponseDispute is IntegrationBase { mockRequest.nonce = uint96(oracle.totalRequestCount()); mockAccessControl.user = requester; - _requestId = oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + _requestId = oracle.createRequest(mockRequest, mockAccessControl); mockResponse.requestId = _requestId; diff --git a/solidity/test/integration/ResponseProposal.t.sol b/solidity/test/integration/ResponseProposal.t.sol index 77f37fb..21908b3 100644 --- a/solidity/test/integration/ResponseProposal.t.sol +++ b/solidity/test/integration/ResponseProposal.t.sol @@ -18,7 +18,7 @@ contract Integration_ResponseProposal is IntegrationBase { vm.expectRevert( abi.encodeWithSelector(IOracleAccessController.OracleAccessController_AccessModuleNotApproved.selector) ); - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); vm.stopPrank(); @@ -41,11 +41,11 @@ contract Integration_ResponseProposal is IntegrationBase { // Revert if access control is an EOA vm.expectRevert(); - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); // Create request mockRequest.accessModule = address(_accessModule); - _requestId = oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + _requestId = oracle.createRequest(mockRequest, mockAccessControl); } function test_proposeResponse_validResponse(bytes memory _response) public { diff --git a/solidity/test/unit/Oracle.t.sol b/solidity/test/unit/Oracle.t.sol index 6034398..4404281 100644 --- a/solidity/test/unit/Oracle.t.sol +++ b/solidity/test/unit/Oracle.t.sol @@ -94,11 +94,8 @@ contract BaseTest is Test, Helpers { IFinalityModule public finalityModule = IFinalityModule(_mockContract('finalityModule')); IAccessModule public accessModule = IAccessModule(_mockContract('accessModule')); - // Mock IPFS hash - bytes32 internal _ipfsHash = bytes32('QmR4uiJH654k3Ta2uLLQ8r'); - // Events - event RequestCreated(bytes32 indexed _requestId, IOracle.Request _request, bytes32 _ipfsHash); + event RequestCreated(bytes32 indexed _requestId, IOracle.Request _request); event ResponseProposed(bytes32 indexed _requestId, bytes32 indexed _responseId, IOracle.Response _response); event ResponseDisputed(bytes32 indexed _responseId, bytes32 indexed _disputeId, IOracle.Dispute _dispute); event OracleRequestFinalized(bytes32 indexed _requestId, bytes32 indexed _responseId); @@ -172,10 +169,10 @@ contract Oracle_Unit_CreateRequest is BaseTest { // Check: emits RequestCreated event? _expectEmit(address(oracle)); - emit RequestCreated(_getId(mockRequest), mockRequest, _ipfsHash); + emit RequestCreated(_getId(mockRequest), mockRequest); // Test: create the request - bytes32 _requestId = oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + bytes32 _requestId = oracle.createRequest(mockRequest, mockAccessControl); // Check: Adds the requester to the list of participants assertTrue(oracle.isParticipant(_requestId, requester)); @@ -211,7 +208,7 @@ contract Oracle_Unit_CreateRequest is BaseTest { vm.expectRevert(IOracleAccessController.OracleAccessController_AccessModuleNotApproved.selector); // Test: try to create the request - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); } /** @@ -228,7 +225,7 @@ contract Oracle_Unit_CreateRequest is BaseTest { // Test: try to create the request vm.prank(_caller); - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); } /** @@ -244,7 +241,7 @@ contract Oracle_Unit_CreateRequest is BaseTest { vm.expectRevert(IOracle.Oracle_InvalidRequestBody.selector); // Test: try to create the request - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); } /** @@ -260,7 +257,7 @@ contract Oracle_Unit_CreateRequest is BaseTest { vm.expectRevert(IOracle.Oracle_InvalidRequestBody.selector); // Test: try to create the request - oracle.createRequest(mockRequest, _ipfsHash, mockAccessControl); + oracle.createRequest(mockRequest, mockAccessControl); } } @@ -278,7 +275,6 @@ contract Oracle_Unit_CreateRequests is BaseTest { IOracle.Request[] memory _requests = new IOracle.Request[](_requestsAmount); bytes32[] memory _precalculatedIds = new bytes32[](_requestsAmount); bool _useResolutionAndFinality = _requestData.length % 2 == 0; - bytes32[] memory _ipfsHashes = new bytes32[](_requestsAmount); IAccessController.AccessControl[] memory _accessControls = new IAccessController.AccessControl[](_requestsAmount); vm.startPrank(requester); @@ -295,16 +291,15 @@ contract Oracle_Unit_CreateRequests is BaseTest { bytes32 _theoreticalRequestId = _getId(mockRequest); _requests[_i] = mockRequest; _precalculatedIds[_i] = _theoreticalRequestId; - _ipfsHashes[_i] = keccak256(abi.encode(_theoreticalRequestId, mockRequest.nonce)); _accessControls[_i].user = requester; // Check: emits RequestCreated event? _expectEmit(address(oracle)); - emit RequestCreated(_theoreticalRequestId, mockRequest, _ipfsHashes[_i]); + emit RequestCreated(_theoreticalRequestId, mockRequest); } - bytes32[] memory _requestsIds = oracle.createRequests(_requests, _ipfsHashes, _accessControls); + bytes32[] memory _requestsIds = oracle.createRequests(_requests, _accessControls); for (uint256 _i = 0; _i < _requestsIds.length; _i++) { assertEq(_requestsIds[_i], _precalculatedIds[_i]); @@ -345,7 +340,6 @@ contract Oracle_Unit_CreateRequests is BaseTest { uint256 _requestsAmount = 5; IOracle.Request[] memory _requests = new IOracle.Request[](_requestsAmount); bytes32[] memory _precalculatedIds = new bytes32[](_requestsAmount); - bytes32[] memory _ipfsHashes = new bytes32[](_requestsAmount); IAccessController.AccessControl[] memory _accessControls = new IAccessController.AccessControl[](_requestsAmount); mockRequest.requestModuleData = _requestData; @@ -355,19 +349,17 @@ contract Oracle_Unit_CreateRequests is BaseTest { mockRequest.nonce = uint96(0); bytes32 _theoreticalRequestId = _getId(mockRequest); - bytes32 _ipfsHash = keccak256(abi.encode(_theoreticalRequestId, uint96(0))); // Generate requests batch for (uint256 _i = 0; _i < _requestsAmount; _i++) { _requests[_i] = mockRequest; _precalculatedIds[_i] = _theoreticalRequestId; - _ipfsHashes[_i] = _ipfsHash; _accessControls[_i].user = requester; } vm.startPrank(requester); oracle.mock_setAccessModuleApproved(requester, address(accessModule), true); - oracle.createRequests(_requests, _ipfsHashes, _accessControls); + oracle.createRequests(_requests, _accessControls); uint256 _newNonce = oracle.totalRequestCount(); assertEq(_newNonce, _initialNonce + _requestsAmount);