From feb5ea71a8e6ba45ee43e3cac9b4bd5405ebdb64 Mon Sep 17 00:00:00 2001 From: Gas <86567384+gas1cent@users.noreply.github.com> Date: Wed, 13 Nov 2024 19:04:48 +0400 Subject: [PATCH] feat: bonded dispute module release (#78) --- .../modules/dispute/BondedDisputeModule.sol | 17 ++--------------- solidity/test/integration/Arbitration.t.sol | 8 ++++---- .../modules/dispute/BondedDisputeModule.t.sol | 14 -------------- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/solidity/contracts/modules/dispute/BondedDisputeModule.sol b/solidity/contracts/modules/dispute/BondedDisputeModule.sol index 42f8fd97..91f83cc2 100644 --- a/solidity/contracts/modules/dispute/BondedDisputeModule.sol +++ b/solidity/contracts/modules/dispute/BondedDisputeModule.sol @@ -53,20 +53,13 @@ contract BondedDisputeModule is Module, IBondedDisputeModule { IOracle.DisputeStatus _status = ORACLE.disputeStatus(_disputeId); if (_status == IOracle.DisputeStatus.NoResolution) { - // No resolution, we release both bonds + // No resolution, we release the disputer's bond _params.accountingExtension.release({ _bonder: _dispute.disputer, _requestId: _dispute.requestId, _token: _params.bondToken, _amount: _params.bondSize }); - - _params.accountingExtension.release({ - _bonder: _dispute.proposer, - _requestId: _dispute.requestId, - _token: _params.bondToken, - _amount: _params.bondSize - }); } else if (_status == IOracle.DisputeStatus.Won) { // Disputer won, we pay the disputer and release their bond _params.accountingExtension.pay({ @@ -83,7 +76,7 @@ contract BondedDisputeModule is Module, IBondedDisputeModule { _amount: _params.bondSize }); } else if (_status == IOracle.DisputeStatus.Lost) { - // Disputer lost, we pay the proposer and release their bond + // Disputer lost, we pay the proposer _params.accountingExtension.pay({ _requestId: _dispute.requestId, _payer: _dispute.disputer, @@ -91,12 +84,6 @@ contract BondedDisputeModule is Module, IBondedDisputeModule { _token: _params.bondToken, _amount: _params.bondSize }); - _params.accountingExtension.release({ - _bonder: _dispute.proposer, - _requestId: _dispute.requestId, - _token: _params.bondToken, - _amount: _params.bondSize - }); } emit DisputeStatusChanged({_disputeId: _disputeId, _dispute: _dispute, _status: _status}); diff --git a/solidity/test/integration/Arbitration.t.sol b/solidity/test/integration/Arbitration.t.sol index fc48ba9e..1c95db09 100644 --- a/solidity/test/integration/Arbitration.t.sol +++ b/solidity/test/integration/Arbitration.t.sol @@ -106,9 +106,9 @@ contract Integration_Arbitration is IntegrationBase { // Check: is the dispute updated as lost? assertEq(uint256(_disputeStatus), uint256(IOracle.DisputeStatus.Lost)); - // Check: does the disputer receive the disputer's bond? + // Check: does the proposer receive the disputer's bond? uint256 _proposerBalance = _accountingExtension.balanceOf(proposer, usdc); - assertEq(_proposerBalance, _expectedBondSize * 2); + assertEq(_proposerBalance, _expectedBondSize); // Check: does the disputer get its bond slashed? uint256 _disputerBondedAmount = _accountingExtension.bondedAmountOf(disputer, usdc, _getId(mockRequest)); @@ -139,9 +139,9 @@ contract Integration_Arbitration is IntegrationBase { // Check: is the dispute updated as lost? assertEq(uint256(_disputeStatus), uint256(IOracle.DisputeStatus.Lost)); - // Check: does the disputer receive the disputer's bond? + // Check: does the proposer receive the disputer's bond? uint256 _proposerBalance = _accountingExtension.balanceOf(proposer, usdc); - assertEq(_proposerBalance, _expectedBondSize * 2); + assertEq(_proposerBalance, _expectedBondSize); // Check: does the disputer get its bond slashed? uint256 _disputerBondedAmount = _accountingExtension.bondedAmountOf(disputer, usdc, _getId(mockRequest)); diff --git a/solidity/test/unit/modules/dispute/BondedDisputeModule.t.sol b/solidity/test/unit/modules/dispute/BondedDisputeModule.t.sol index 4066ac4f..173fe4f7 100644 --- a/solidity/test/unit/modules/dispute/BondedDisputeModule.t.sol +++ b/solidity/test/unit/modules/dispute/BondedDisputeModule.t.sol @@ -113,13 +113,6 @@ contract BondedDisputeModule_Unit_OnDisputeStatusChange is BaseTest { abi.encode() ); - // Mock and expect the call to release, to the disputer - _mockAndExpect( - address(accountingExtension), - abi.encodeCall(accountingExtension.release, (mockResponse.proposer, _requestId, _token, _bondSize)), - abi.encode() - ); - vm.prank(address(oracle)); bondedDisputeModule.onDisputeStatusChange(_getId(mockDispute), mockRequest, mockResponse, mockDispute); } @@ -176,13 +169,6 @@ contract BondedDisputeModule_Unit_OnDisputeStatusChange is BaseTest { abi.encode(IOracle.DisputeStatus.NoResolution) ); - // Mock and expect the call to release, for the proposer - _mockAndExpect( - address(accountingExtension), - abi.encodeCall(accountingExtension.release, (mockResponse.proposer, _requestId, _token, _bondSize)), - abi.encode() - ); - // Mock and expect the call to release, for the disputer _mockAndExpect( address(accountingExtension),