From 1541577e8fa0e62c8532d4ca67b9ccf6e6d552ac Mon Sep 17 00:00:00 2001 From: Gas One Cent <86567384+gas1cent@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:10:37 +0400 Subject: [PATCH 1/3] feat: update core package --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 647e268c..9baed5e7 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "package.json": "sort-package-json" }, "dependencies": { - "@defi-wonderland/prophet-core-contracts": "0.0.0-5fbc6720", + "@defi-wonderland/prophet-core-contracts": "0.0.0-c8bd8736", "@defi-wonderland/solidity-utils": "0.0.0-3e9c8e8b", "@openzeppelin/contracts": "^4.9.3", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", diff --git a/yarn.lock b/yarn.lock index 08861dda..6e6107d5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -192,10 +192,10 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@defi-wonderland/prophet-core-contracts@0.0.0-5fbc6720": - version "0.0.0-5fbc6720" - resolved "https://registry.yarnpkg.com/@defi-wonderland/prophet-core-contracts/-/prophet-core-contracts-0.0.0-5fbc6720.tgz#5fef99e5a9064289566c8b7eec3e754c20c67166" - integrity sha512-tXiSGhSFW/QJhW4eLKJ7MCUXEG+NvJvOPteFHlri+GEiXfQRQztpWBQYSngI68C+rourOTVCbXSm0bDJK2UfMw== +"@defi-wonderland/prophet-core-contracts@0.0.0-c8bd8736": + version "0.0.0-c8bd8736" + resolved "https://registry.yarnpkg.com/@defi-wonderland/prophet-core-contracts/-/prophet-core-contracts-0.0.0-c8bd8736.tgz#3f27e8296831b384c9bb516bcef3d7bceb5383bd" + integrity sha512-Zh+kWY6GZsEf6+Fs399XOxlWojWN1yFyznjnXh2Ydfxa72AqzyviaEPgse5zc9diizGJnBsyo9FRF/BY+EbuTg== dependencies: "@defi-wonderland/solidity-utils" "0.0.0-3e9c8e8b" "@openzeppelin/contracts" "^4.9.3" From 1d77f5ac9a1af617089a42ce84aac6bfea77bfc4 Mon Sep 17 00:00:00 2001 From: Gas One Cent <86567384+gas1cent@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:22:00 +0400 Subject: [PATCH 2/3] feat: remove or comment out unused variables --- .../modules/dispute/BondEscalationModule.sol | 2 +- .../modules/dispute/BondedDisputeModule.sol | 6 +++--- .../modules/resolution/ArbitratorModule.sol | 2 +- .../modules/resolution/ERC20ResolutionModule.sol | 6 +++--- .../resolution/PrivateERC20ResolutionModule.sol | 6 +++--- .../modules/dispute/BondEscalationModule.t.sol | 16 ++-------------- .../resolution/ERC20ResolutionModule.t.sol | 3 +-- .../PrivateERC20ResolutionModule.t.sol | 1 - 8 files changed, 14 insertions(+), 28 deletions(-) diff --git a/solidity/contracts/modules/dispute/BondEscalationModule.sol b/solidity/contracts/modules/dispute/BondEscalationModule.sol index 4a5dd673..da0fd0da 100644 --- a/solidity/contracts/modules/dispute/BondEscalationModule.sol +++ b/solidity/contracts/modules/dispute/BondEscalationModule.sol @@ -30,7 +30,7 @@ contract BondEscalationModule is Module, IBondEscalationModule { /// @inheritdoc IBondEscalationModule function disputeResponse( IOracle.Request calldata _request, - IOracle.Response calldata _response, + IOracle.Response calldata, /* _response */ IOracle.Dispute calldata _dispute ) external onlyOracle { RequestParameters memory _params = decodeRequestData(_request.disputeModuleData); diff --git a/solidity/contracts/modules/dispute/BondedDisputeModule.sol b/solidity/contracts/modules/dispute/BondedDisputeModule.sol index 1da2a6bd..a6fbfd98 100644 --- a/solidity/contracts/modules/dispute/BondedDisputeModule.sol +++ b/solidity/contracts/modules/dispute/BondedDisputeModule.sol @@ -16,14 +16,14 @@ contract BondedDisputeModule is Module, IBondedDisputeModule { } /// @inheritdoc IBondedDisputeModule - function decodeRequestData(bytes calldata _data) public view returns (RequestParameters memory _params) { + function decodeRequestData(bytes calldata _data) public pure returns (RequestParameters memory _params) { _params = abi.decode(_data, (RequestParameters)); } /// @inheritdoc IBondedDisputeModule function disputeResponse( IOracle.Request calldata _request, - IOracle.Response calldata _response, + IOracle.Response calldata, /* _response */ IOracle.Dispute calldata _dispute ) external onlyOracle { RequestParameters memory _params = decodeRequestData(_request.disputeModuleData); @@ -48,7 +48,7 @@ contract BondedDisputeModule is Module, IBondedDisputeModule { function onDisputeStatusChange( bytes32 _disputeId, IOracle.Request calldata _request, - IOracle.Response calldata _response, + IOracle.Response calldata, /* _response */ IOracle.Dispute calldata _dispute ) external onlyOracle { RequestParameters memory _params = decodeRequestData(_request.disputeModuleData); diff --git a/solidity/contracts/modules/resolution/ArbitratorModule.sol b/solidity/contracts/modules/resolution/ArbitratorModule.sol index 0f4df46a..7e916dbd 100644 --- a/solidity/contracts/modules/resolution/ArbitratorModule.sol +++ b/solidity/contracts/modules/resolution/ArbitratorModule.sol @@ -35,7 +35,7 @@ contract ArbitratorModule is Module, IArbitratorModule { function startResolution( bytes32 _disputeId, IOracle.Request calldata _request, - IOracle.Response calldata _response, + IOracle.Response calldata, /* _response */ IOracle.Dispute calldata _dispute ) external onlyOracle { RequestParameters memory _params = decodeRequestData(_request.resolutionModuleData); diff --git a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol index c7a40ff6..05bad682 100644 --- a/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/ERC20ResolutionModule.sol @@ -42,9 +42,9 @@ contract ERC20ResolutionModule is Module, IERC20ResolutionModule { /// @inheritdoc IERC20ResolutionModule function startResolution( bytes32 _disputeId, - IOracle.Request calldata _request, - IOracle.Response calldata _response, - IOracle.Dispute calldata _dispute + IOracle.Request calldata, /* _request */ + IOracle.Response calldata, /* _response */ + IOracle.Dispute calldata /* _dispute */ ) external onlyOracle { escalations[_disputeId].startTime = block.timestamp; emit VotingPhaseStarted(block.timestamp, _disputeId); diff --git a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol index 5cebd018..450e837c 100644 --- a/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol +++ b/solidity/contracts/modules/resolution/PrivateERC20ResolutionModule.sol @@ -42,9 +42,9 @@ contract PrivateERC20ResolutionModule is Module, IPrivateERC20ResolutionModule { /// @inheritdoc IPrivateERC20ResolutionModule function startResolution( bytes32 _disputeId, - IOracle.Request calldata _request, - IOracle.Response calldata _response, - IOracle.Dispute calldata _dispute + IOracle.Request calldata, /* _request */ + IOracle.Response calldata, /* _response */ + IOracle.Dispute calldata /* _dispute */ ) external onlyOracle { escalations[_disputeId].startTime = block.timestamp; emit CommittingPhaseStarted(block.timestamp, _disputeId); diff --git a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol index 6357f549..21d7a8bd 100644 --- a/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondEscalationModule.t.sol @@ -123,10 +123,7 @@ contract BaseTest is Test, Helpers { bondEscalationModule = new ForTest_BondEscalationModule(oracle); } - function _getRandomDispute( - bytes32 _requestId, - IOracle.DisputeStatus _status - ) internal view returns (IOracle.Dispute memory _dispute) { + function _getRandomDispute(bytes32 _requestId) internal view returns (IOracle.Dispute memory _dispute) { _dispute = IOracle.Dispute({disputer: disputer, responseId: bytes32('response'), proposer: proposer, requestId: _requestId}); } @@ -387,12 +384,7 @@ contract BondEscalationModule_Unit_DisputeResponse is BaseTest { /** * @notice Tests that disputeResponse reverts the caller is not the oracle address. */ - function test_revertIfCallerIsNotOracle( - bytes32 _requestId, - bytes32 _responseId, - address _caller, - IOracle.Request calldata _request - ) public { + function test_revertIfCallerIsNotOracle(address _caller, IOracle.Request calldata _request) public { vm.assume(_caller != address(oracle)); // Check: does it revert if not called by the Oracle? @@ -573,7 +565,6 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { */ function test_revertIfCallerIsNotOracle( bytes32 _disputeId, - bytes32 _requestId, address _caller, uint8 _status, IOracle.Request calldata _request @@ -581,9 +572,6 @@ contract BondEscalationModule_Unit_OnDisputeStatusChange is BaseTest { vm.assume(_caller != address(oracle)); vm.assume(_status < 4); - IOracle.DisputeStatus _disputeStatus = IOracle.DisputeStatus(_status); - IOracle.Dispute memory _dispute = _getRandomDispute(_requestId, _disputeStatus); - // Check: does it revert if not called by the Oracle? vm.expectRevert(IModule.Module_OnlyOracle.selector); vm.prank(_caller); diff --git a/solidity/test/unit/modules/resolution/ERC20ResolutionModule.t.sol b/solidity/test/unit/modules/resolution/ERC20ResolutionModule.t.sol index b18e4fcd..86c1fa9e 100644 --- a/solidity/test/unit/modules/resolution/ERC20ResolutionModule.t.sol +++ b/solidity/test/unit/modules/resolution/ERC20ResolutionModule.t.sol @@ -359,7 +359,7 @@ contract ERC20ResolutionModule_Unit_ClaimVote is BaseTest { /** * @notice Reverts if the vote is still ongoing */ - function test_revertIfVoteIsOnGoing(address _voter, uint256 _amount) public { + function test_revertIfVoteIsOnGoing(address _voter) public { mockRequest.resolutionModuleData = abi.encode( IERC20ResolutionModule.RequestParameters({ accountingExtension: accountingExtension, @@ -370,7 +370,6 @@ contract ERC20ResolutionModule_Unit_ClaimVote is BaseTest { ); mockDispute.requestId = _getId(mockRequest); - bytes32 _disputeId = _getId(mockDispute); module.forTest_setStartTime(_getId(mockDispute), block.timestamp); // Expect an error to be thrown diff --git a/solidity/test/unit/modules/resolution/PrivateERC20ResolutionModule.t.sol b/solidity/test/unit/modules/resolution/PrivateERC20ResolutionModule.t.sol index 003c82bc..edb927bb 100644 --- a/solidity/test/unit/modules/resolution/PrivateERC20ResolutionModule.t.sol +++ b/solidity/test/unit/modules/resolution/PrivateERC20ResolutionModule.t.sol @@ -78,7 +78,6 @@ contract BaseTest is Test, Helpers { uint256 _amountOfVotes ) internal returns (uint256 _totalVotesCast) { bytes32 _disputeId = _getId(_dispute); - bytes32 _requestId = _getId(_request); for (uint256 _i = 1; _i <= _amountOfVoters;) { vm.warp(120_000); From 5cfb222b5f280f162eb402d88ebb4459110a172a Mon Sep 17 00:00:00 2001 From: Gas One Cent <86567384+gas1cent@users.noreply.github.com> Date: Tue, 28 Nov 2023 15:22:10 +0400 Subject: [PATCH 3/3] feat: resolve a todo --- .../test/unit/modules/dispute/CircuitResolverModule.t.sol | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/solidity/test/unit/modules/dispute/CircuitResolverModule.t.sol b/solidity/test/unit/modules/dispute/CircuitResolverModule.t.sol index f3871e98..a7b77377 100644 --- a/solidity/test/unit/modules/dispute/CircuitResolverModule.t.sol +++ b/solidity/test/unit/modules/dispute/CircuitResolverModule.t.sol @@ -288,10 +288,9 @@ contract CircuitResolverModule_Unit_OnDisputeStatusChange is BaseTest { bytes32 _disputeId = _getId(mockDispute); IOracle.DisputeStatus _status = IOracle.DisputeStatus.Lost; - // TODO: fix this test // Check: is the event emitted? - // vm.expectEmit(true, true, true, true, address(circuitResolverModule)); - // emit DisputeStatusChanged(_disputeId, mockDispute, _status); + vm.expectEmit(true, true, true, true, address(circuitResolverModule)); + emit DisputeStatusChanged(_disputeId, mockDispute, _status); vm.prank(address(oracle)); circuitResolverModule.onDisputeStatusChange(_disputeId, mockRequest, mockResponse, mockDispute);