From f7084a72f24baa2a7951fc6587e607e676543f1b Mon Sep 17 00:00:00 2001 From: Souradeep Das Date: Mon, 24 Aug 2020 14:10:25 +0530 Subject: [PATCH] Revert "[Process Exit Bounty] Add process exit bounty for IFE (#682)" (#696) This reverts commit 20c3502c0c1e3583d2f35deb21a076bee6bb867d. --- .../routers/PaymentInFlightExitRouterMock.sol | 4 +- .../mocks/utils/ExitBountyWrapper.sol | 4 - .../exits/payment/PaymentExitDataModel.sol | 1 - .../src/exits/payment/PaymentExitGame.sol | 2 +- .../PaymentChallengeIFEInputSpent.sol | 3 +- .../PaymentChallengeIFEOutputSpent.sol | 3 +- .../PaymentPiggybackInFlightExit.sol | 10 +- .../PaymentProcessInFlightExit.sol | 44 ++---- .../controllers/PaymentStartStandardExit.sol | 5 +- .../routers/PaymentInFlightExitRouter.sol | 15 +- .../contracts/src/exits/utils/ExitBounty.sol | 10 +- .../python_tests/testlang/testlang.py | 7 +- .../root_chain/test_process_exits.py | 45 +++--- .../tests/tests_utils/plasma_framework.py | 4 - .../PaymentInFlightExit.e2e.test.js | 97 +++---------- .../PaymentInFlightExitModelUtils.test.js | 1 - .../PaymentChallengeIFEInputSpent.test.js | 31 ++-- .../PaymentChallengeIFENotCanonical.test.js | 4 - .../PaymentChallengeIFEOutputSpent.test.js | 16 +-- .../PaymentDeleteInFlightExit.test.js | 3 - ...aymentPiggybackInFlightExitOnInput.test.js | 91 ++---------- ...ymentPiggybackInFlightExitOnOutput.test.js | 83 ++--------- .../PaymentProcessInFlightExit.test.js | 134 +----------------- .../PaymentProcessStandardExit.test.js | 2 +- .../test/src/exits/utils/BountySize.test.js | 27 +--- 25 files changed, 101 insertions(+), 545 deletions(-) diff --git a/plasma_framework/contracts/mocks/exits/payment/routers/PaymentInFlightExitRouterMock.sol b/plasma_framework/contracts/mocks/exits/payment/routers/PaymentInFlightExitRouterMock.sol index d8590bd7b..6c09dc1c4 100644 --- a/plasma_framework/contracts/mocks/exits/payment/routers/PaymentInFlightExitRouterMock.sol +++ b/plasma_framework/contracts/mocks/exits/payment/routers/PaymentInFlightExitRouterMock.sol @@ -30,8 +30,8 @@ contract PaymentInFlightExitRouterMock is FailFastReentrancyGuard, PaymentInFlig } /** override and calls processInFlightExit for test */ - function processExit(uint168 exitId, uint256, address ercContract, address payable processor) external { - PaymentInFlightExitRouter.processInFlightExit(exitId, ercContract, processor); + function processExit(uint168 exitId, uint256, address ercContract, address payable) external { + PaymentInFlightExitRouter.processInFlightExit(exitId, ercContract); } function setInFlightExit(uint168 exitId, PaymentExitDataModel.InFlightExit memory exit) public { diff --git a/plasma_framework/contracts/mocks/utils/ExitBountyWrapper.sol b/plasma_framework/contracts/mocks/utils/ExitBountyWrapper.sol index f2f73b8d3..a348d9f48 100644 --- a/plasma_framework/contracts/mocks/utils/ExitBountyWrapper.sol +++ b/plasma_framework/contracts/mocks/utils/ExitBountyWrapper.sol @@ -8,8 +8,4 @@ contract ExitBountyWrapper { return ExitBounty.processStandardExitBountySize(gasPriceStartExit); } - function processInFlightExitBountySize(uint256 gasPricePiggyback) public view returns (uint256) { - return ExitBounty.processInFlightExitBountySize(gasPricePiggyback); - } - } diff --git a/plasma_framework/contracts/src/exits/payment/PaymentExitDataModel.sol b/plasma_framework/contracts/src/exits/payment/PaymentExitDataModel.sol index a2a67c4a8..5c32e8edd 100644 --- a/plasma_framework/contracts/src/exits/payment/PaymentExitDataModel.sol +++ b/plasma_framework/contracts/src/exits/payment/PaymentExitDataModel.sol @@ -43,7 +43,6 @@ library PaymentExitDataModel { address token; uint256 amount; uint256 piggybackBondSize; - uint256 bountySize; } /** diff --git a/plasma_framework/contracts/src/exits/payment/PaymentExitGame.sol b/plasma_framework/contracts/src/exits/payment/PaymentExitGame.sol index 08c86a8c8..23b5a2caa 100644 --- a/plasma_framework/contracts/src/exits/payment/PaymentExitGame.sol +++ b/plasma_framework/contracts/src/exits/payment/PaymentExitGame.sol @@ -47,7 +47,7 @@ contract PaymentExitGame is IExitProcessor, OnlyFromAddress, PaymentStandardExit if (ExitId.isStandardExit(exitId)) { PaymentStandardExitRouter.processStandardExit(exitId, token, processor); } else { - PaymentInFlightExitRouter.processInFlightExit(exitId, token, processor); + PaymentInFlightExitRouter.processInFlightExit(exitId, token); } } diff --git a/plasma_framework/contracts/src/exits/payment/controllers/PaymentChallengeIFEInputSpent.sol b/plasma_framework/contracts/src/exits/payment/controllers/PaymentChallengeIFEInputSpent.sol index bfa7b15b3..b160c5520 100644 --- a/plasma_framework/contracts/src/exits/payment/controllers/PaymentChallengeIFEInputSpent.sol +++ b/plasma_framework/contracts/src/exits/payment/controllers/PaymentChallengeIFEInputSpent.sol @@ -102,8 +102,7 @@ library PaymentChallengeIFEInputSpent { ife.clearInputPiggybacked(args.inFlightTxInputIndex); uint256 piggybackBondSize = ife.inputs[args.inFlightTxInputIndex].piggybackBondSize; - uint256 bountySize = ife.inputs[args.inFlightTxInputIndex].bountySize; - SafeEthTransfer.transferRevertOnError(msg.sender, piggybackBondSize + bountySize, self.safeGasStipend); + SafeEthTransfer.transferRevertOnError(msg.sender, piggybackBondSize, self.safeGasStipend); emit InFlightExitInputBlocked(msg.sender, keccak256(args.inFlightTx), args.inFlightTxInputIndex); } diff --git a/plasma_framework/contracts/src/exits/payment/controllers/PaymentChallengeIFEOutputSpent.sol b/plasma_framework/contracts/src/exits/payment/controllers/PaymentChallengeIFEOutputSpent.sol index 7fe59ca2c..98783a1ad 100644 --- a/plasma_framework/contracts/src/exits/payment/controllers/PaymentChallengeIFEOutputSpent.sol +++ b/plasma_framework/contracts/src/exits/payment/controllers/PaymentChallengeIFEOutputSpent.sol @@ -65,8 +65,7 @@ library PaymentChallengeIFEOutputSpent { ife.clearOutputPiggybacked(outputIndex); uint256 piggybackBondSize = ife.outputs[outputIndex].piggybackBondSize; - uint256 bountySize = ife.outputs[outputIndex].bountySize; - SafeEthTransfer.transferRevertOnError(msg.sender, piggybackBondSize + bountySize, controller.safeGasStipend); + SafeEthTransfer.transferRevertOnError(msg.sender, piggybackBondSize, controller.safeGasStipend); emit InFlightExitOutputBlocked(msg.sender, keccak256(args.inFlightTx), outputIndex); } diff --git a/plasma_framework/contracts/src/exits/payment/controllers/PaymentPiggybackInFlightExit.sol b/plasma_framework/contracts/src/exits/payment/controllers/PaymentPiggybackInFlightExit.sol index ed361c341..76c475e5c 100644 --- a/plasma_framework/contracts/src/exits/payment/controllers/PaymentPiggybackInFlightExit.sol +++ b/plasma_framework/contracts/src/exits/payment/controllers/PaymentPiggybackInFlightExit.sol @@ -6,19 +6,15 @@ import "../PaymentInFlightExitModelUtils.sol"; import "../routers/PaymentInFlightExitRouterArgs.sol"; import "../../utils/ExitableTimestamp.sol"; import "../../utils/ExitId.sol"; -import "../../utils/ExitBounty.sol"; import "../../../framework/PlasmaFramework.sol"; import "../../../framework/interfaces/IExitProcessor.sol"; import "../../../transactions/PaymentTransactionModel.sol"; import "../../../utils/PosLib.sol"; -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; - library PaymentPiggybackInFlightExit { using PosLib for PosLib.Position; using ExitableTimestamp for ExitableTimestamp.Calculator; using PaymentInFlightExitModelUtils for PaymentExitDataModel.InFlightExit; - using SafeMath for uint256; struct Controller { PlasmaFramework framework; @@ -91,8 +87,7 @@ library PaymentPiggybackInFlightExit { PaymentExitDataModel.WithdrawData storage withdrawData = exit.inputs[args.inputIndex]; require(withdrawData.exitTarget == msg.sender, "Can be called only by the exit target"); - withdrawData.bountySize = ExitBounty.processInFlightExitBountySize(tx.gasprice); - withdrawData.piggybackBondSize = msg.value.sub(withdrawData.bountySize); + withdrawData.piggybackBondSize = msg.value; if (isFirstPiggybackOfTheToken(exit, withdrawData.token)) { enqueue(self, withdrawData.token, PosLib.decode(exit.position), exitId); @@ -129,8 +124,7 @@ library PaymentPiggybackInFlightExit { PaymentExitDataModel.WithdrawData storage withdrawData = exit.outputs[args.outputIndex]; require(withdrawData.exitTarget == msg.sender, "Can be called only by the exit target"); - withdrawData.bountySize = ExitBounty.processInFlightExitBountySize(tx.gasprice); - withdrawData.piggybackBondSize = msg.value.sub(withdrawData.bountySize); + withdrawData.piggybackBondSize = msg.value; if (isFirstPiggybackOfTheToken(exit, withdrawData.token)) { enqueue(self, withdrawData.token, PosLib.decode(exit.position), exitId); diff --git a/plasma_framework/contracts/src/exits/payment/controllers/PaymentProcessInFlightExit.sol b/plasma_framework/contracts/src/exits/payment/controllers/PaymentProcessInFlightExit.sol index b01d7f873..2e5c1f8b5 100644 --- a/plasma_framework/contracts/src/exits/payment/controllers/PaymentProcessInFlightExit.sol +++ b/plasma_framework/contracts/src/exits/payment/controllers/PaymentProcessInFlightExit.sol @@ -39,11 +39,6 @@ library PaymentProcessInFlightExit { uint256 amount ); - event InFlightBountyReturnFailed( - address indexed receiver, - uint256 amount - ); - /** * @notice Main logic function to process in-flight exit * @dev emits InFlightExitOmitted event if the exit is omitted @@ -59,8 +54,7 @@ library PaymentProcessInFlightExit { Controller memory self, PaymentExitDataModel.InFlightExitMap storage exitMap, uint168 exitId, - address token, - address payable processor + address token ) public { @@ -114,8 +108,8 @@ library PaymentProcessInFlightExit { flagOutputsWhenCanonical(self.framework, exit, token, exitId); } - returnInputPiggybackBonds(self, exit, token, processor); - returnOutputPiggybackBonds(self, exit, token, processor); + returnInputPiggybackBonds(self, exit, token); + returnOutputPiggybackBonds(self, exit, token); clearPiggybackInputFlag(exit, token); clearPiggybackOutputFlag(exit, token); @@ -272,8 +266,7 @@ library PaymentProcessInFlightExit { function returnInputPiggybackBonds( Controller memory self, PaymentExitDataModel.InFlightExit storage exit, - address token, - address payable processor + address token ) private { @@ -282,23 +275,14 @@ library PaymentProcessInFlightExit { // If the input has been challenged, isInputPiggybacked() will return false if (token == withdrawal.token && exit.isInputPiggybacked(i)) { - bool successBondReturn = SafeEthTransfer.transferReturnResult( + bool success = SafeEthTransfer.transferReturnResult( withdrawal.exitTarget, withdrawal.piggybackBondSize, self.safeGasStipend ); // we do not want to block a queue if bond return is unsuccessful - if (!successBondReturn) { + if (!success) { emit InFlightBondReturnFailed(withdrawal.exitTarget, withdrawal.piggybackBondSize); } - - bool successBountyReturn = SafeEthTransfer.transferReturnResult( - processor, withdrawal.bountySize, self.safeGasStipend - ); - - // we do not want to block a queue if bounty return is unsuccessful - if (!successBountyReturn) { - emit InFlightBountyReturnFailed(processor, withdrawal.bountySize); - } } } } @@ -306,8 +290,7 @@ library PaymentProcessInFlightExit { function returnOutputPiggybackBonds( Controller memory self, PaymentExitDataModel.InFlightExit storage exit, - address token, - address payable processor + address token ) private { @@ -316,23 +299,14 @@ library PaymentProcessInFlightExit { // If the output has been challenged, isOutputPiggybacked() will return false if (token == withdrawal.token && exit.isOutputPiggybacked(i)) { - bool successBondReturn = SafeEthTransfer.transferReturnResult( + bool success = SafeEthTransfer.transferReturnResult( withdrawal.exitTarget, withdrawal.piggybackBondSize, self.safeGasStipend ); // we do not want to block a queue if bond return is unsuccessful - if (!successBondReturn) { + if (!success) { emit InFlightBondReturnFailed(withdrawal.exitTarget, withdrawal.piggybackBondSize); } - - bool successBountyReturn = SafeEthTransfer.transferReturnResult( - processor, withdrawal.bountySize, self.safeGasStipend - ); - - // we do not want to block a queue if bounty return is unsuccessful - if (!successBountyReturn) { - emit InFlightBountyReturnFailed(processor, withdrawal.bountySize); - } } } } diff --git a/plasma_framework/contracts/src/exits/payment/controllers/PaymentStartStandardExit.sol b/plasma_framework/contracts/src/exits/payment/controllers/PaymentStartStandardExit.sol index 5e5263ea3..0fd61c414 100644 --- a/plasma_framework/contracts/src/exits/payment/controllers/PaymentStartStandardExit.sol +++ b/plasma_framework/contracts/src/exits/payment/controllers/PaymentStartStandardExit.sol @@ -12,13 +12,10 @@ import "../../../transactions/PaymentTransactionModel.sol"; import "../../../utils/PosLib.sol"; import "../../../framework/PlasmaFramework.sol"; -import "openzeppelin-solidity/contracts/math/SafeMath.sol"; - library PaymentStartStandardExit { using ExitableTimestamp for ExitableTimestamp.Calculator; using PosLib for PosLib.Position; using PaymentTransactionModel for PaymentTransactionModel.Transaction; - using SafeMath for uint256; struct Controller { IExitProcessor exitProcessor; @@ -173,7 +170,7 @@ library PaymentStartStandardExit { outputId: data.outputId, exitTarget: msg.sender, amount: data.output.amount, - bondSize: msg.value.sub(ExitBounty.processStandardExitBountySize(tx.gasprice)), + bondSize: msg.value - ExitBounty.processStandardExitBountySize(tx.gasprice), bountySize: ExitBounty.processStandardExitBountySize(tx.gasprice) }); } diff --git a/plasma_framework/contracts/src/exits/payment/routers/PaymentInFlightExitRouter.sol b/plasma_framework/contracts/src/exits/payment/routers/PaymentInFlightExitRouter.sol index 40395a410..17617ec88 100644 --- a/plasma_framework/contracts/src/exits/payment/routers/PaymentInFlightExitRouter.sol +++ b/plasma_framework/contracts/src/exits/payment/routers/PaymentInFlightExitRouter.sol @@ -222,7 +222,7 @@ contract PaymentInFlightExitRouter is public payable nonReentrant(framework) - onlyWithValue(piggybackBondSize() + processInFlightExitBountySize(tx.gasprice)) + onlyWithValue(piggybackBondSize()) { piggybackInFlightExitController.piggybackInput(inFlightExitMap, args); } @@ -237,7 +237,7 @@ contract PaymentInFlightExitRouter is public payable nonReentrant(framework) - onlyWithValue(piggybackBondSize() + processInFlightExitBountySize(tx.gasprice)) + onlyWithValue(piggybackBondSize()) { piggybackInFlightExitController.piggybackOutput(inFlightExitMap, args); } @@ -309,8 +309,8 @@ contract PaymentInFlightExitRouter is * @param exitId The in-flight exit ID * @param token The token (in erc20 address or address(0) for ETH) of the exiting output */ - function processInFlightExit(uint168 exitId, address token, address payable processor) internal { - processInflightExitController.run(inFlightExitMap, exitId, token, processor); + function processInFlightExit(uint168 exitId, address token) internal { + processInflightExitController.run(inFlightExitMap, exitId, token); } /** @@ -344,11 +344,4 @@ contract PaymentInFlightExitRouter is piggybackBond.updateBondSize(newBondSize); emit PiggybackBondUpdated(newBondSize); } - - /** - * @notice Retrieves the process IFE bounty size - */ - function processInFlightExitBountySize(uint256 gasPricePiggyback) public view returns (uint256) { - return ExitBounty.processInFlightExitBountySize(gasPricePiggyback); - } } diff --git a/plasma_framework/contracts/src/exits/utils/ExitBounty.sol b/plasma_framework/contracts/src/exits/utils/ExitBounty.sol index 0643cf444..ca3c4f91f 100644 --- a/plasma_framework/contracts/src/exits/utils/ExitBounty.sol +++ b/plasma_framework/contracts/src/exits/utils/ExitBounty.sol @@ -7,16 +7,8 @@ library ExitBounty { * @dev See https://github.com/omgnetwork/plasma-contracts/issues/658 for discussion about size * 107000 is the approx gas usage for calling processExit() */ - function processStandardExitBountySize(uint256 gasPriceStartExit) internal pure returns (uint256) { + function processStandardExitBountySize(uint256 gasPriceStartExit) internal view returns (uint256) { return 107000 * gasPriceStartExit; } - /** - * @notice Returns the Process Exit Bounty size for in-flight exits - * @dev See https://github.com/omgnetwork/plasma-contracts/issues/658 for discussion about size - */ - function processInFlightExitBountySize(uint256 gasPricePiggyback) internal pure returns (uint256) { - return 500000 * gasPricePiggyback; - } - } diff --git a/plasma_framework/python_tests/testlang/testlang.py b/plasma_framework/python_tests/testlang/testlang.py index 0c16e7304..46bd9686a 100644 --- a/plasma_framework/python_tests/testlang/testlang.py +++ b/plasma_framework/python_tests/testlang/testlang.py @@ -63,13 +63,12 @@ def __init__(self, root, timestamp): class InFlightExit: class WithdrawData: - def __init__(self, output_id, exit_target, token, amount, piggyback_bond_size, bounty_size): + def __init__(self, output_id, exit_target, token, amount, piggyback_bond_size): self.output_id = output_id self.exit_target = exit_target self.token = token self.amount = amount self.piggyback_bond_size = piggyback_bond_size - self.bounty_size = bounty_size def __init__(self, root_chain, in_flight_tx, is_canonical, @@ -401,8 +400,8 @@ def get_merkle_proof(self, tx_id): def piggyback_in_flight_exit_input(self, tx_id, input_index, account, bond=None, spend_tx=None): if spend_tx is None: spend_tx = self.child_chain.get_transaction(tx_id) - bond = bond if bond is not None else self.root_chain.piggybackBond() + self.root_chain.processInFlightExitBounty() - self.root_chain.piggybackInFlightExit(spend_tx.encoded, input_index, **{'value': bond, 'from': account.address, 'gasPrice': 100}) + bond = bond if bond is not None else self.root_chain.piggybackBond() + self.root_chain.piggybackInFlightExit(spend_tx.encoded, input_index, **{'value': bond, 'from': account.address}) def piggyback_in_flight_exit_output(self, tx_id, output_index, account, bond=None, spend_tx=None): assert output_index in range(4) diff --git a/plasma_framework/python_tests/tests/contracts/root_chain/test_process_exits.py b/plasma_framework/python_tests/tests/contracts/root_chain/test_process_exits.py index a293710e6..5f5431434 100644 --- a/plasma_framework/python_tests/tests/contracts/root_chain/test_process_exits.py +++ b/plasma_framework/python_tests/tests/contracts/root_chain/test_process_exits.py @@ -86,7 +86,7 @@ def test_process_exits_in_flight_exit_should_succeed(testlang): assert input_info.exit_target == NULL_ADDRESS_HEX assert input_info.amount == 0 - expected_balance = pre_balance + amount + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() + testlang.root_chain.processInFlightExitBounty() + expected_balance = pre_balance + amount + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() assert testlang.get_balance(owner) == expected_balance @@ -369,7 +369,7 @@ def test_finalize_exits_for_in_flight_exit_should_transfer_funds(testlang, plasm testlang.process_exits(NULL_ADDRESS, 0, 10) assert testlang.get_balance(owner) == \ - pre_balance + first_utxo + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() + testlang.root_chain.processInFlightExitBounty() + pre_balance + first_utxo + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() def test_finalize_in_flight_exit_finalizes_only_piggybacked_outputs(testlang, plasma_framework): @@ -394,7 +394,7 @@ def test_finalize_in_flight_exit_finalizes_only_piggybacked_outputs(testlang, pl testlang.process_exits(NULL_ADDRESS, 0, 10) assert testlang.get_balance(owner) == \ - pre_balance + first_utxo + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() + testlang.root_chain.processInFlightExitBounty() + pre_balance + first_utxo + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() in_flight_exit = testlang.get_in_flight_exit(spend_id) @@ -430,7 +430,7 @@ def test_finalize_exits_priority_for_in_flight_exits_corresponds_to_the_age_of_y balance = testlang.get_balance(owner) testlang.process_exits(NULL_ADDRESS, testlang.get_in_flight_exit_id(spend_1_id), 1) assert testlang.get_balance( - owner) == balance + 70 + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() + testlang.root_chain.processInFlightExitBounty() + owner) == balance + 70 + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() balance = testlang.get_balance(owner) testlang.process_exits(NULL_ADDRESS, testlang.get_standard_exit_id(spend_2_id), 1) @@ -663,7 +663,7 @@ def test_when_processing_an_ife_it_is_cleaned_up_when_all_piggybacked_outputs_fi assert in_flight_exit.exit_map == 0 # assert bond was sent to the owner - assert testlang.get_balance(testlang.accounts[0]) == pre_balance + testlang.root_chain.inFlightExitBond() + (2 * testlang.root_chain.processInFlightExitBounty()) + assert testlang.get_balance(testlang.accounts[0]) == pre_balance + testlang.root_chain.inFlightExitBond() def test_in_flight_exit_is_cleaned_up_even_though_none_of_outputs_exited(testlang): @@ -687,7 +687,7 @@ def test_in_flight_exit_is_cleaned_up_even_though_none_of_outputs_exited(testlan assert in_flight_exit.exit_map == 0 # assert IFE and piggyback bonds were sent to the owners - assert testlang.get_balance(owner) == pre_balance + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() + testlang.root_chain.processInFlightExitBounty() + assert testlang.get_balance(owner) == pre_balance + testlang.root_chain.inFlightExitBond() + testlang.root_chain.piggybackBond() def test_processing_ife_and_se_exit_from_same_output_does_not_fail(testlang): @@ -820,7 +820,7 @@ def start_ife_piggyback_and_process(spend_id, owner, testlang): testlang.process_exits(NULL_ADDRESS, 0, 10) -def test_should_not_allow_to_withdraw_outputs_from_two_ifes_marked_as_canonical_but_sharing_an_input(testlang, w3, plasma_framework, token): +def test_should_not_allow_to_withdraw_outputs_from_two_ifes_marked_as_canonical_but_sharing_an_input(testlang, plasma_framework, token): alice, amount_token = testlang.accounts[0], 200 caroline, amount_eth = testlang.accounts[1], 100 @@ -841,9 +841,7 @@ def test_should_not_allow_to_withdraw_outputs_from_two_ifes_marked_as_canonical_ caroline_eth_balance_before = testlang.get_balance(caroline) testlang.piggyback_in_flight_exit_output(swap_tx_id, 1, caroline) - gasCostToken = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_output(None, 0, caroline, spend_tx=steal_tx) - gasCostEth = w3.eth.last_gas_used * 100 testlang.forward_timestamp(2 * MIN_EXIT_PERIOD + 1) testlang.process_exits(token.address, 0, 1) @@ -855,7 +853,7 @@ def test_should_not_allow_to_withdraw_outputs_from_two_ifes_marked_as_canonical_ # but she can not exit with Eth caroline_eth_balance = testlang.get_balance(caroline) - assert caroline_eth_balance == caroline_eth_balance_before - gasCostToken - gasCostEth - (2 * testlang.root_chain.processInFlightExitBounty()) + assert caroline_eth_balance == caroline_eth_balance_before # flaky: https://github.com/omgnetwork/plasma-contracts/issues/606 # def test_should_not_allow_to_withdraw_inputs_and_outputs_when_ifes_processing_interchanges(testlang, plasma_framework, token): @@ -934,19 +932,14 @@ def test_not_challenged_standard_exit_blocks_ife_output_exit(testlang, w3, plasm caroline_eth_balance_before = testlang.get_balance(caroline) testlang.start_standard_exit(deposit_id_eth_small, caroline) - gasCostStartExit = w3.eth.last_gas_used * 100 + gasCost = w3.eth.last_gas_used * 100 testlang.start_in_flight_exit(swap_tx_id) testlang.piggyback_in_flight_exit_output(swap_tx_id, 0, alice) - gasCostAliceOutput = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_output(swap_tx_id, 1, caroline) - gasCostCarolineOutputOne = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_input(swap_tx_id, 0, alice) - gasCostAliceInput = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_input(swap_tx_id, 1, caroline) - gasCostCarolineInputOne = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_input(swap_tx_id, 2, caroline) - gasCostCarolineInputTwo = w3.eth.last_gas_used * 100 testlang.forward_timestamp(2 * MIN_EXIT_PERIOD + 1) # caroline's exits finalize @@ -960,14 +953,14 @@ def test_not_challenged_standard_exit_blocks_ife_output_exit(testlang, w3, plasm assert caroline_token_balance == caroline_token_balance_before # but gets her Eth back caroline_eth_balance = testlang.get_balance(caroline) - assert caroline_eth_balance == caroline_eth_balance_before + amount_eth_big + amount_eth_small - gasCostStartExit - testlang.root_chain.processStandardExitBounty() - gasCostCarolineInputOne - gasCostCarolineInputTwo - gasCostCarolineOutputOne - (3 * testlang.root_chain.processInFlightExitBounty()) + assert caroline_eth_balance == caroline_eth_balance_before + amount_eth_big + amount_eth_small - gasCost - testlang.root_chain.processStandardExitBounty() # alice gets tokens alice_token_balance = token.balanceOf(alice.address) assert alice_token_balance == alice_token_balance_before + amount_token # but does not get Eth output alice_eth_balance = testlang.get_balance(alice) - assert alice_eth_balance == alice_eth_balance_before - gasCostAliceInput - gasCostAliceOutput - (2 * testlang.root_chain.processInFlightExitBounty()) + assert alice_eth_balance == alice_eth_balance_before def test_challenged_standard_exit_does_not_block_ife_output_exit(testlang, w3, plasma_framework, token): @@ -989,20 +982,15 @@ def test_challenged_standard_exit_does_not_block_ife_output_exit(testlang, w3, p caroline_eth_balance_before = testlang.get_balance(caroline) testlang.start_standard_exit(deposit_id_eth_small, caroline) - gasCostStartExit = w3.eth.last_gas_used * 100 + gasCost = w3.eth.last_gas_used * 100 testlang.challenge_standard_exit(deposit_id_eth_small, swap_tx_id) testlang.start_in_flight_exit(swap_tx_id) testlang.piggyback_in_flight_exit_output(swap_tx_id, 0, alice) - gasCostAliceOutput = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_output(swap_tx_id, 1, caroline) - gasCostCarolineOutputOne = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_input(swap_tx_id, 0, alice) - gasCostAliceInput = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_input(swap_tx_id, 1, caroline) - gasCostCarolineInputOne = w3.eth.last_gas_used * 100 testlang.piggyback_in_flight_exit_input(swap_tx_id, 2, caroline) - gasCostCarolineInputTwo = w3.eth.last_gas_used * 100 testlang.forward_timestamp(2 * MIN_EXIT_PERIOD + 1) # caroline's exits finalize @@ -1016,17 +1004,17 @@ def test_challenged_standard_exit_does_not_block_ife_output_exit(testlang, w3, p assert caroline_token_balance == caroline_token_balance_before + amount_token # and does not get the Eth back caroline_eth_balance = testlang.get_balance(caroline) - assert caroline_eth_balance == caroline_eth_balance_before - testlang.root_chain.standardExitBond() - gasCostStartExit - testlang.root_chain.processStandardExitBounty() - gasCostCarolineInputOne - gasCostCarolineInputTwo - gasCostCarolineOutputOne - (3 * testlang.root_chain.processInFlightExitBounty()) + assert caroline_eth_balance == caroline_eth_balance_before - testlang.root_chain.standardExitBond() - gasCost - testlang.root_chain.processStandardExitBounty() # alice exits with her Eth output alice_eth_balance = testlang.get_balance(alice) - assert alice_eth_balance == alice_eth_balance_before + amount_eth_small + amount_eth_big - gasCostAliceInput - gasCostAliceOutput - (2 * testlang.root_chain.processInFlightExitBounty()) + assert alice_eth_balance == alice_eth_balance_before + amount_eth_small + amount_eth_big # and does not get the tokens back alice_token_balance = token.balanceOf(alice.address) assert alice_token_balance == alice_token_balance_before -def test_after_canonical_ife_is_finalized_inputs_are_not_exited_when_ife_is_restarted_and_non_canonical(testlang, w3, plasma_framework, token): +def test_after_canonical_ife_is_finalized_inputs_are_not_exited_when_ife_is_restarted_and_non_canonical(testlang, plasma_framework, token): """ 1. Alice and Bob send a canonical transaction transfering their funds to Alice. 2. Alice starts an in-flight exit and exits her output. @@ -1047,13 +1035,12 @@ def test_after_canonical_ife_is_finalized_inputs_are_not_exited_when_ife_is_rest # transaction is not included in child chain and canonical in-flight exit is started and processed testlang.start_in_flight_exit(spend_id) testlang.piggyback_in_flight_exit_output(spend_id, 0, alice) - gasCost = w3.eth.last_gas_used * 100 testlang.forward_timestamp(2 * MIN_EXIT_PERIOD + 1) testlang.process_exits(NULL_ADDRESS, 0, 1) # alice exits with her Eth output alice_eth_balance = testlang.get_balance(alice) - assert alice_eth_balance == alice_eth_balance_before + alice_output_amount - gasCost + assert alice_eth_balance == alice_eth_balance_before + alice_output_amount # bob spends his inputs in a competing transaction competing_spend_id = testlang.spend_utxo( diff --git a/plasma_framework/python_tests/tests/tests_utils/plasma_framework.py b/plasma_framework/python_tests/tests/tests_utils/plasma_framework.py index 0e21d6e94..e7177d417 100644 --- a/plasma_framework/python_tests/tests/tests_utils/plasma_framework.py +++ b/plasma_framework/python_tests/tests/tests_utils/plasma_framework.py @@ -347,10 +347,6 @@ def processStandardExitBounty(self): dummy_gasprice = 100 return self.payment_exit_game.processStandardExitBountySize(dummy_gasprice) - def processInFlightExitBounty(self): - dummy_gasprice = 100 - return self.payment_exit_game.processInFlightExitBountySize(dummy_gasprice) - def inFlightExitBond(self): return self.payment_exit_game.startIFEBondSize() diff --git a/plasma_framework/test/endToEndTests/PaymentInFlightExit.e2e.test.js b/plasma_framework/test/endToEndTests/PaymentInFlightExit.e2e.test.js index 6ed68f354..60337f952 100644 --- a/plasma_framework/test/endToEndTests/PaymentInFlightExit.e2e.test.js +++ b/plasma_framework/test/endToEndTests/PaymentInFlightExit.e2e.test.js @@ -11,14 +11,14 @@ const { expect } = require('chai'); const { EMPTY_BYTES, SAFE_GAS_STIPEND } = require('../helpers/constants.js'); const { MerkleTree } = require('../helpers/merkle.js'); const { PaymentTransactionOutput, PaymentTransaction } = require('../helpers/transaction.js'); -const { computeNormalOutputId, spentOnGas } = require('../helpers/utils.js'); +const { computeNormalOutputId } = require('../helpers/utils.js'); const { sign } = require('../helpers/sign.js'); const { hashTx } = require('../helpers/paymentEip712.js'); const { buildUtxoPos } = require('../helpers/positions.js'); const Testlang = require('../helpers/testlang.js'); const config = require('../../config.js'); -contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _maintainer, authority, carol, richFather, otherAddress]) => { +contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _maintainer, authority, carol, richFather]) => { const ETH = constants.ZERO_ADDRESS; const DEPOSIT_VALUE = 1000000; const TX_TYPE_PAYMENT = config.registerKeys.txTypes.payment; @@ -35,12 +35,12 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma alice = await web3.eth.personal.importRawKey(alicePrivateKey, password); alice = web3.utils.toChecksumAddress(alice); web3.eth.personal.unlockAccount(alice, password, 3600); - web3.eth.sendTransaction({ to: alice, from: richFather, value: web3.utils.toWei('2', 'ether') }); + web3.eth.sendTransaction({ to: alice, from: richFather, value: web3.utils.toWei('1', 'ether') }); bob = await web3.eth.personal.importRawKey(bobPrivateKey, password); bob = web3.utils.toChecksumAddress(bob); web3.eth.personal.unlockAccount(bob, password, 3600); - web3.eth.sendTransaction({ to: bob, from: richFather, value: web3.utils.toWei('2', 'ether') }); + web3.eth.sendTransaction({ to: bob, from: richFather, value: web3.utils.toWei('1', 'ether') }); }; before(setupAccount); @@ -56,13 +56,6 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma this.startIFEBondSize = await this.exitGame.startIFEBondSize(); this.piggybackBondSize = await this.exitGame.piggybackBondSize(); - this.dummyGasPrice = 10000; - this.dummyNewGasPrice = 20000; - - this.processExitBountySize = await this.exitGame.processInFlightExitBountySize(this.dummyGasPrice); - this.processExitBountySizeOther = await this.exitGame.processInFlightExitBountySize(this.dummyNewGasPrice); - this.piggybackExitTxValue = this.piggybackBondSize.add(this.processExitBountySize); - this.framework.addExitQueue(config.registerKeys.vaultId.eth, ETH); }; @@ -141,7 +134,7 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma this.piggybackTx = await this.exitGame.piggybackInFlightExitOnOutput( args, - { from: bob, value: this.piggybackExitTxValue, gasPrice: this.dummyGasPrice }, + { from: bob, value: this.piggybackBondSize }, ); }); @@ -166,10 +159,8 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma await time.increase(time.duration.weeks(2).add(time.duration.seconds(1))); this.exitsToProcess = 1; - this.preBalanceCarol = new BN(await web3.eth.getBalance(carol)); this.processTx = await this.framework.processExits( config.registerKeys.vaultId.eth, ETH, 0, this.exitsToProcess, - { from: carol }, ); }); @@ -182,15 +173,6 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma expect(postBalanceBob).to.be.bignumber.equal(expectedBalance); }); - it('should transfer the exit bounty to processor (Carol)', async () => { - const postBalanceCarol = new BN(await web3.eth.getBalance(carol)); - const expectedBalance = this.preBalanceCarol - .add(new BN(this.processExitBountySize)) - .sub(await spentOnGas(this.processTx.receipt)); - - expect(postBalanceCarol).to.be.bignumber.equal(expectedBalance); - }); - it('should publish an event', async () => { await expectEvent.inLogs( this.processTx.logs, @@ -285,7 +267,7 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma await this.exitGame.piggybackInFlightExitOnOutput( args, - { from: bob, value: this.piggybackExitTxValue, gasPrice: this.dummyGasPrice }, + { from: bob, value: this.piggybackBondSize }, ); }); @@ -323,19 +305,13 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma }; await this.exitGame.piggybackInFlightExitOnInput( - args1, { - from: alice, - value: this.piggybackBondSize.add(this.processExitBountySizeOther), - gasPrice: this.dummyNewGasPrice, - }, + args1, + { from: alice, value: this.piggybackBondSize }, ); await this.exitGame.piggybackInFlightExitOnInput( - args2, { - from: alice, - value: this.piggybackBondSize.add(this.processExitBountySizeOther), - gasPrice: this.dummyNewGasPrice, - }, + args2, + { from: alice, value: this.piggybackBondSize }, ); }); @@ -371,12 +347,8 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma await time.increase(slightlyMoreThanTwoWeeks); const exitsToProcess = 1; - this.preBalanceOtherAddress = new BN( - await web3.eth.getBalance(otherAddress), - ); - this.processTx = await this.framework.processExits( + await this.framework.processExits( config.registerKeys.vaultId.eth, ETH, 0, exitsToProcess, - { from: otherAddress }, ); }); @@ -393,22 +365,8 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma const postBalanceBob = new BN(await web3.eth.getBalance(bob)); const expectedBalance = preBalanceBob .add(new BN(this.piggybackBondSize)); - expect(expectedBalance).to.be.bignumber.equal(postBalanceBob); }); - - it('should award bounty for both piggybacks to the processor', async () => { - const postBalanceOtherAddress = new BN( - await web3.eth.getBalance(otherAddress), - ); - const expectedBalance = this.preBalanceOtherAddress - .add(new BN(this.processExitBountySize)) - .add(new BN(this.processExitBountySizeOther)) - .sub(await spentOnGas(this.processTx.receipt)); - - expect(expectedBalance) - .to.be.bignumber.equal(postBalanceOtherAddress); - }); }); }); }); @@ -560,11 +518,8 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma inputIndex: 0, }; await this.exitGame.piggybackInFlightExitOnInput( - piggybackInputArgs, { - from: alice, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + piggybackInputArgs, + { from: alice, value: this.piggybackBondSize }, ); const piggybackOutputArgs = { @@ -572,11 +527,8 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma outputIndex: 0, }; await this.exitGame.piggybackInFlightExitOnOutput( - piggybackOutputArgs, { - from: bob, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + piggybackOutputArgs, + { from: bob, value: this.piggybackBondSize }, ); }); @@ -596,12 +548,8 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma await time.increase(slightlyMoreThanTwoWeeks); const exitsToProcess = 2; - this.preBalanceOtherAddress = new BN( - await web3.eth.getBalance(otherAddress), - ); - this.processTx = await this.framework.processExits( + await this.framework.processExits( config.registerKeys.vaultId.eth, ETH, 0, exitsToProcess, - { from: otherAddress }, ); }); @@ -630,19 +578,6 @@ contract('PaymentExitGame - In-flight Exit - End to End Tests', ([_deployer, _ma expect(expectedBalance).to.be.bignumber.equal(postBalanceAlice); }); - - it('should award exit bounty to Processor', async () => { - const postBalanceOtherAddress = new BN( - await web3.eth.getBalance(otherAddress), - ); - const expectedBalance = this.preBalanceOtherAddress - .add(new BN(this.processExitBountySize)) - .add(new BN(this.processExitBountySize)) - .sub(await spentOnGas(this.processTx.receipt)); - - expect(expectedBalance) - .to.be.bignumber.equal(postBalanceOtherAddress); - }); }); }); }); diff --git a/plasma_framework/test/src/exits/payment/PaymentInFlightExitModelUtils.test.js b/plasma_framework/test/src/exits/payment/PaymentInFlightExitModelUtils.test.js index 554052ade..107f20b14 100644 --- a/plasma_framework/test/src/exits/payment/PaymentInFlightExitModelUtils.test.js +++ b/plasma_framework/test/src/exits/payment/PaymentInFlightExitModelUtils.test.js @@ -21,7 +21,6 @@ contract('PaymentInFlightExitModelUtils', () => { token: constants.ZERO_ADDRESS, amount: 0, piggybackBondSize: 0, - bountySize: 0, }; describe('isInputEmpty', () => { diff --git a/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFEInputSpent.test.js b/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFEInputSpent.test.js index a3e7853e9..e526c5f8f 100644 --- a/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFEInputSpent.test.js +++ b/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFEInputSpent.test.js @@ -31,7 +31,6 @@ const { spentOnGas, computeNormalOutputId, getOutputId } = require('../../../../ contract('PaymentChallengeIFEInputSpent', ([_, alice, inputOwner, outputOwner, challenger, otherAddress]) => { const DUMMY_IFE_BOND_SIZE = 31415926535; const PIGGYBACK_BOND = 31415926535; - const PROCESS_EXIT_BOUNTY = 500000000000; const MIN_EXIT_PERIOD = 60 * 60 * 24 * 7; // 1 week const DUMMY_INITIAL_IMMUNE_VAULTS_NUM = 0; const INITIAL_IMMUNE_EXIT_GAME_NUM = 1; @@ -118,7 +117,6 @@ contract('PaymentChallengeIFEInputSpent', ([_, alice, inputOwner, outputOwner, c token: constants.ZERO_ADDRESS, amount: 0, piggybackBondSize: 0, - bountySize: 0, }; const inFlightExitData = { @@ -135,7 +133,6 @@ contract('PaymentChallengeIFEInputSpent', ([_, alice, inputOwner, outputOwner, c token: ETH, amount: 999, piggybackBondSize: PIGGYBACK_BOND, - bountySize: PROCESS_EXIT_BOUNTY, }, { outputId: getOutputId(inputTx.txBytes, inputTx.utxoPos), outputGuard: web3.utils.sha3('dummy output guard'), @@ -143,7 +140,6 @@ contract('PaymentChallengeIFEInputSpent', ([_, alice, inputOwner, outputOwner, c token: ETH, amount: INPUT_TX_AMOUNT, piggybackBondSize: PIGGYBACK_BOND, - bountySize: PROCESS_EXIT_BOUNTY, }, emptyWithdrawData, emptyWithdrawData], outputs: [{ outputId: web3.utils.sha3('dummy output id'), @@ -152,7 +148,6 @@ contract('PaymentChallengeIFEInputSpent', ([_, alice, inputOwner, outputOwner, c token: ETH, amount: outputAmount, piggybackBondSize: PIGGYBACK_BOND, - bountySize: PROCESS_EXIT_BOUNTY, }, emptyWithdrawData, emptyWithdrawData, emptyWithdrawData], }; @@ -205,19 +200,16 @@ contract('PaymentChallengeIFEInputSpent', ([_, alice, inputOwner, outputOwner, c this.piggybackBondSize = await this.exitGame.piggybackBondSize(); - this.dummyGasPrice = 1000000; - this.processExitBountySize = await this.exitGame.processInFlightExitBountySize(this.dummyGasPrice); - // Set up the piggyback data this.testData = await buildPiggybackInputData(this.inputTx); await this.exitGame.setInFlightExit(this.testData.exitId, this.testData.inFlightExitData); // Piggyback the second input - await this.exitGame.setInFlightExitInputPiggybacked(this.testData.exitId, 1, { - from: inputOwner, - value: this.piggybackBondSize.add(this.processExitBountySize), - gasPrice: this.dummyGasPrice, - }); + await this.exitGame.setInFlightExitInputPiggybacked( + this.testData.exitId, + 1, + { from: inputOwner, value: this.piggybackBondSize.toString() }, + ); // Create a transaction that spends the same input const challengingTx = createInputTransaction( @@ -277,11 +269,10 @@ contract('PaymentChallengeIFEInputSpent', ([_, alice, inputOwner, outputOwner, c expect(new BN(exits[0].exitMap)).to.be.bignumber.equal(new BN(0)); }); - it('should pay the piggyback bond plus exit bounty to the challenger', async () => { + it('should pay the piggyback bond to the challenger', async () => { const actualPostBalance = new BN(await web3.eth.getBalance(challenger)); const expectedPostBalance = this.challengerPreBalance .add(new BN(PIGGYBACK_BOND)) - .add(new BN(PROCESS_EXIT_BOUNTY)) .sub(await spentOnGas(this.challengeTx.receipt)); expect(actualPostBalance).to.be.bignumber.equal(expectedPostBalance); @@ -291,11 +282,11 @@ contract('PaymentChallengeIFEInputSpent', ([_, alice, inputOwner, outputOwner, c describe('check exitMap before and after challenge', () => { beforeEach(async () => { // Piggyback input0 as well. - await this.exitGame.setInFlightExitInputPiggybacked(this.testData.exitId, 0, { - from: inputOwner, - value: this.piggybackBondSize.add(this.processExitBountySize), - gasPrice: this.dummyGasPrice, - }); + await this.exitGame.setInFlightExitInputPiggybacked( + this.testData.exitId, + 0, + { from: inputOwner, value: this.piggybackBondSize.toString() }, + ); }); it('should remove the input from piggybacked', async () => { diff --git a/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFENotCanonical.test.js b/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFENotCanonical.test.js index 01fc2f908..592547d93 100644 --- a/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFENotCanonical.test.js +++ b/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFENotCanonical.test.js @@ -33,7 +33,6 @@ const { createInclusionProof } = require('../../../../helpers/ife.js'); contract('PaymentChallengeIFENotCanonical', ([_, ifeOwner, inputOwner, outputOwner, competitorOwner, challenger]) => { const DUMMY_IFE_BOND_SIZE = 31415926535; // wei const PIGGYBACK_BOND = 31415926535; // wei - const PROCESS_EXIT_BOUNTY = 500000000000; const CHILD_BLOCK_INTERVAL = 1000; const MIN_EXIT_PERIOD = 60 * 60 * 24 * 7; // 1 week in second const DUMMY_INITIAL_IMMUNE_VAULTS_NUM = 0; @@ -138,7 +137,6 @@ contract('PaymentChallengeIFENotCanonical', ([_, ifeOwner, inputOwner, outputOwn token: constants.ZERO_ADDRESS, amount: 0, piggybackBondSize: 0, - bountySize: 0, }; const output = new PaymentTransactionOutput(outputType, TEST_IFE_OUTPUT_AMOUNT, outputOwner, ETH); @@ -171,7 +169,6 @@ contract('PaymentChallengeIFENotCanonical', ([_, ifeOwner, inputOwner, outputOwn token: ETH, amount: TEST_IFE_INPUT_AMOUNT, piggybackBondSize: PIGGYBACK_BOND, - bountySize: PROCESS_EXIT_BOUNTY, }, emptyWithdrawData, emptyWithdrawData, emptyWithdrawData], outputs: [{ outputId: DUMMY_OUTPUT_ID_FOR_OUTPUT, @@ -179,7 +176,6 @@ contract('PaymentChallengeIFENotCanonical', ([_, ifeOwner, inputOwner, outputOwn token: ETH, amount: TEST_IFE_OUTPUT_AMOUNT, piggybackBondSize: PIGGYBACK_BOND, - bountySize: PROCESS_EXIT_BOUNTY, }, emptyWithdrawData, emptyWithdrawData, emptyWithdrawData], bondSize: DUMMY_IFE_BOND_SIZE, }; diff --git a/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFEOutputSpent.test.js b/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFEOutputSpent.test.js index 33876f4c0..8df95874a 100644 --- a/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFEOutputSpent.test.js +++ b/plasma_framework/test/src/exits/payment/controllers/PaymentChallengeIFEOutputSpent.test.js @@ -31,7 +31,6 @@ const { contract('PaymentChallengeIFEOutputSpent', ([_, alice, bob, otherAddress]) => { const DUMMY_IFE_BOND_SIZE = 31415926535; // wei const PIGGYBACK_BOND = 31415926535; - const PROCESS_EXIT_BOUNTY = 500000000000; const MIN_EXIT_PERIOD = 60 * 60 * 24 * 7; // 1 week const DUMMY_INITIAL_IMMUNE_VAULTS_NUM = 0; const INITIAL_IMMUNE_EXIT_GAME_NUM = 1; @@ -48,7 +47,6 @@ contract('PaymentChallengeIFEOutputSpent', ([_, alice, bob, otherAddress]) => { token: constants.ZERO_ADDRESS, amount: 0, piggybackBondSize: 0, - bountySize: 0, }; const BLOCK_NUM = 1000; const MAX_NUM_OF_INPUTS = 4; @@ -111,7 +109,6 @@ contract('PaymentChallengeIFEOutputSpent', ([_, alice, bob, otherAddress]) => { token: ETH, amount: AMOUNT, piggybackBondSize: PIGGYBACK_BOND, - bountySize: PROCESS_EXIT_BOUNTY, }, DUMMY_WITHDRAW_DATA, DUMMY_WITHDRAW_DATA, DUMMY_WITHDRAW_DATA], outputs: [{ outputId: filler, @@ -120,7 +117,6 @@ contract('PaymentChallengeIFEOutputSpent', ([_, alice, bob, otherAddress]) => { token: ETH, amount: AMOUNT, piggybackBondSize: PIGGYBACK_BOND, - bountySize: PROCESS_EXIT_BOUNTY, }, { outputId: filler, outputGuard: filler, @@ -128,7 +124,6 @@ contract('PaymentChallengeIFEOutputSpent', ([_, alice, bob, otherAddress]) => { token: ETH, amount: AMOUNT, piggybackBondSize: PIGGYBACK_BOND, - bountySize: PIGGYBACK_BOND, }, DUMMY_WITHDRAW_DATA, DUMMY_WITHDRAW_DATA], }; @@ -179,13 +174,7 @@ contract('PaymentChallengeIFEOutputSpent', ([_, alice, bob, otherAddress]) => { await this.framework.registerExitGame(OTHER_TX_TYPE, dummyExitGame.address, PROTOCOL.MORE_VP); this.piggybackBondSize = await this.exitGame.piggybackBondSize(); - this.dummyGasPrice = 1000000; - this.processExitBountySize = await this.exitGame.processInFlightExitBountySize(this.dummyGasPrice); - - this.exitGame.depositFundForTest({ - from: alice, - value: this.piggybackBondSize.add(this.processExitBountySize), - }); + this.exitGame.depositFundForTest({ from: alice, value: this.piggybackBondSize.toString() }); const args = await buildValidChallengeOutputArgs(); @@ -218,7 +207,7 @@ contract('PaymentChallengeIFEOutputSpent', ([_, alice, bob, otherAddress]) => { ); }); - it('should pay out bond plus bounty to the challenger when challenged successfully', async () => { + it('should pay out bond to the challenger when challenged successfully', async () => { const challengerPreBalance = new BN(await web3.eth.getBalance(bob)); const { receipt } = await this.exitGame.challengeInFlightExitOutputSpent( @@ -226,7 +215,6 @@ contract('PaymentChallengeIFEOutputSpent', ([_, alice, bob, otherAddress]) => { ); const expectedPostBalance = challengerPreBalance .add(new BN(PIGGYBACK_BOND)) - .add(new BN(PROCESS_EXIT_BOUNTY)) .sub(await spentOnGas(receipt)); const challengerPostBalance = new BN(await web3.eth.getBalance(bob)); diff --git a/plasma_framework/test/src/exits/payment/controllers/PaymentDeleteInFlightExit.test.js b/plasma_framework/test/src/exits/payment/controllers/PaymentDeleteInFlightExit.test.js index b42907bd2..353abf37d 100644 --- a/plasma_framework/test/src/exits/payment/controllers/PaymentDeleteInFlightExit.test.js +++ b/plasma_framework/test/src/exits/payment/controllers/PaymentDeleteInFlightExit.test.js @@ -109,7 +109,6 @@ contract('PaymentDeleteInFlightExit', ([_, bondOwner, inputOwner, outputOwner]) token: constants.ZERO_ADDRESS, amount: 0, piggybackBondSize: 0, - bountySize: 0, }; const inFlightExitData = { @@ -124,7 +123,6 @@ contract('PaymentDeleteInFlightExit', ([_, bondOwner, inputOwner, outputOwner]) token: ETH, amount: 999, piggybackBondSize: 0, - bountySize: 0, }, emptyWithdrawData, emptyWithdrawData, emptyWithdrawData], outputs: [{ outputId: web3.utils.sha3('dummy output id'), @@ -132,7 +130,6 @@ contract('PaymentDeleteInFlightExit', ([_, bondOwner, inputOwner, outputOwner]) token: ETH, amount: outputAmount, piggybackBondSize: 0, - bountySize: 0, }, emptyWithdrawData, emptyWithdrawData, emptyWithdrawData], bondSize: this.startIFEBondSize.toString(), }; diff --git a/plasma_framework/test/src/exits/payment/controllers/PaymentPiggybackInFlightExitOnInput.test.js b/plasma_framework/test/src/exits/payment/controllers/PaymentPiggybackInFlightExitOnInput.test.js index 779b8e672..2671bbc83 100644 --- a/plasma_framework/test/src/exits/payment/controllers/PaymentPiggybackInFlightExitOnInput.test.js +++ b/plasma_framework/test/src/exits/payment/controllers/PaymentPiggybackInFlightExitOnInput.test.js @@ -91,11 +91,6 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput this.startIFEBondSize = await this.exitGame.startIFEBondSize(); this.piggybackBondSize = await this.exitGame.piggybackBondSize(); - - this.dummyGasPrice = 1000000; - - this.processExitBountySize = await this.exitGame.processInFlightExitBountySize(this.dummyGasPrice); - this.piggybackExitTxValue = this.piggybackBondSize.add(this.processExitBountySize); }); describe('piggybackOnInput', () => { @@ -118,7 +113,6 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput token: constants.ZERO_ADDRESS, amount: 0, piggybackBondSize: 0, - bountySize: 0, }; const inFlightExitData = { @@ -133,14 +127,12 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput token: firstInputToken, amount: 999, piggybackBondSize: 0, - bountySize: 0, }, { outputId: web3.utils.sha3('dummy output id'), exitTarget: inputOwner, token: ETH, amount: 998, piggybackBondSize: 0, - bountySize: 0, }, emptyWithdrawData, emptyWithdrawData], outputs: [{ outputId: web3.utils.sha3('dummy output id'), @@ -148,7 +140,6 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput token: ETH, amount: outputAmount, piggybackBondSize: 0, - bountySize: 0, }, emptyWithdrawData, emptyWithdrawData, emptyWithdrawData], bondSize: this.startIFEBondSize.toString(), }; @@ -173,22 +164,10 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput }; }; - it('should fail when not sent with the bond value', async () => { + it('should fail when not send with the bond value', async () => { const { argsInputOne } = await buildPiggybackInputData(); await expectRevert( - this.exitGame.piggybackInFlightExitOnInput( - argsInputOne, { value: this.processExitBountySize, gasPrice: this.dummyGasPrice }, - ), - 'Input value must match msg.value', - ); - }); - - it('should fail when not sent with the correct bounty', async () => { - const { argsInputOne } = await buildPiggybackInputData(); - await expectRevert( - this.exitGame.piggybackInFlightExitOnInput( - argsInputOne, { value: this.piggybackBondSize, gasPrice: this.dummyGasPrice }, - ), + this.exitGame.piggybackInFlightExitOnInput(argsInputOne), 'Input value must match msg.value', ); }); @@ -201,11 +180,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput data.argsInputOne.inFlightTx = nonExistingTx; await expectRevert( this.exitGame.piggybackInFlightExitOnInput( - data.argsInputOne, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.argsInputOne, { from: inputOwner, value: this.piggybackBondSize.toString() }, ), 'No in-flight exit to piggyback on', ); @@ -219,11 +194,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput await expectRevert( this.exitGame.piggybackInFlightExitOnInput( - data.argsInputOne, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.argsInputOne, { from: inputOwner, value: this.piggybackBondSize.toString() }, ), 'Piggyback is possible only in the first phase of the exit period', ); @@ -237,11 +208,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput data.argsInputOne.inputIndex = inputIndexExceedSize; await expectRevert( this.exitGame.piggybackInFlightExitOnInput( - data.argsInputOne, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.argsInputOne, { from: inputOwner, value: this.piggybackBondSize.toString() }, ), 'Invalid input index', ); @@ -255,11 +222,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput data.argsInputOne.inputIndex = indexOfEmptyInput; await expectRevert( this.exitGame.piggybackInFlightExitOnInput( - data.argsInputOne, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.argsInputOne, { from: inputOwner, value: this.piggybackBondSize.toString() }, ), 'Indexed input is empty', ); @@ -273,11 +236,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput await expectRevert( this.exitGame.piggybackInFlightExitOnInput( - data.argsInputOne, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.argsInputOne, { from: inputOwner, value: this.piggybackBondSize.toString() }, ), 'Indexed input already piggybacked', ); @@ -288,11 +247,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput await this.exitGame.setInFlightExit(data.exitId, data.inFlightExitData); await expectRevert( this.exitGame.piggybackInFlightExitOnInput( - data.argsInputOne, { - from: nonInputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.argsInputOne, { from: nonInputOwner, value: this.piggybackBondSize.toString() }, ), 'Can be called only by the exit target', ); @@ -303,11 +258,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput await this.exitGame.setInFlightExit(data.exitId, data.inFlightExitData); await expectRevert( this.exitGame.piggybackInFlightExitOnInput( - data.argsInputOne, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.argsInputOne, { from: inputOwner, value: this.piggybackBondSize.toString() }, ), 'There is no block for the exit position to enqueue', ); @@ -326,11 +277,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput await this.framework.addExitQueue(VAULT_ID.ETH, ETH); this.piggybackTx = await this.exitGame.piggybackInFlightExitOnInput( - this.testData.argsInputOne, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + this.testData.argsInputOne, { from: inputOwner, value: this.piggybackBondSize.toString() }, ); }); @@ -357,11 +304,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput it('should not enqueue when it is not first piggyback of the exit on the same token', async () => { const enqueuedCountBeforePiggyback = (await this.framework.enqueuedCount()).toNumber(); await this.exitGame.piggybackInFlightExitOnInput( - this.testData.argsInputTwo, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + this.testData.argsInputTwo, { from: inputOwner, value: this.piggybackBondSize.toString() }, ); expect((await this.framework.enqueuedCount()).toNumber()).to.equal(enqueuedCountBeforePiggyback); }); @@ -379,12 +322,6 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput expect(new BN(exits[0].inputs[0].piggybackBondSize)).to.be.bignumber.equal(this.piggybackBondSize); }); - it('should set the proper bounty size', async () => { - const exits = await this.exitGame.inFlightExits([this.testData.exitId]); - - expect(new BN(exits[0].inputs[0].bountySize)).to.be.bignumber.equal(this.processExitBountySize); - }); - it('should emit InFlightExitInputPiggybacked event', async () => { await expectEvent.inLogs( this.piggybackTx.logs, @@ -411,11 +348,7 @@ contract('PaymentPiggybackInFlightExitOnInput', ([_, alice, inputOwner, nonInput await this.framework.addExitQueue(VAULT_ID.ERC20, ERC20_TOKEN); this.piggybackTx = await this.exitGame.piggybackInFlightExitOnInput( - this.testData.argsInputOne, { - from: inputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + this.testData.argsInputOne, { from: inputOwner, value: this.piggybackBondSize.toString() }, ); }); diff --git a/plasma_framework/test/src/exits/payment/controllers/PaymentPiggybackInFlightExitOnOutput.test.js b/plasma_framework/test/src/exits/payment/controllers/PaymentPiggybackInFlightExitOnOutput.test.js index 7d54c4736..8521ae06d 100644 --- a/plasma_framework/test/src/exits/payment/controllers/PaymentPiggybackInFlightExitOnOutput.test.js +++ b/plasma_framework/test/src/exits/payment/controllers/PaymentPiggybackInFlightExitOnOutput.test.js @@ -92,11 +92,6 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO this.startIFEBondSize = await this.exitGame.startIFEBondSize(); this.piggybackBondSize = await this.exitGame.piggybackBondSize(); - - this.dummyGasPrice = 1000000; - - this.processExitBountySize = await this.exitGame.processInFlightExitBountySize(this.dummyGasPrice); - this.piggybackExitTxValue = this.piggybackBondSize.add(this.processExitBountySize); }); describe('piggybackOnOutput', () => { @@ -119,7 +114,6 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO token: constants.ZERO_ADDRESS, amount: 0, piggybackBondSize: 0, - bountySize: 0, }; const inFlightExitData = { @@ -134,7 +128,6 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO token: ETH, amount: 999, piggybackBondSize: 0, - bountySize: 0, }, emptyWithdrawData, emptyWithdrawData, emptyWithdrawData], outputs: [{ outputId: web3.utils.sha3('dummy output id'), @@ -142,14 +135,12 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO token: ETH, amount: outputAmount1, piggybackBondSize: 0, - bountySize: 0, }, { outputId: web3.utils.sha3('dummy output id'), exitTarget: outputOwner, token: ETH, amount: outputAmount2, piggybackBondSize: 0, - bountySize: 0, }, emptyWithdrawData, emptyWithdrawData], bondSize: this.startIFEBondSize.toString(), }; @@ -183,19 +174,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO it('should fail when not send with the bond value', async () => { const data = await buildPiggybackOutputData(); await expectRevert( - this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { value: this.processExitBountySize, gasPrice: this.dummyGasPrice }, - ), - 'Input value must match msg.value', - ); - }); - - it('should fail when not sent with the correct bounty', async () => { - const data = await buildPiggybackOutputData(); - await expectRevert( - this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { value: this.piggybackBondSize, gasPrice: this.dummyGasPrice }, - ), + this.exitGame.piggybackInFlightExitOnOutput(data.outputOneCase.args), 'Input value must match msg.value', ); }); @@ -204,11 +183,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO const data = await buildPiggybackOutputData(); await expectRevert( this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { - from: outputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.outputOneCase.args, { from: outputOwner, value: this.piggybackBondSize.toString() }, ), 'No in-flight exit to piggyback on', ); @@ -222,11 +197,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO await expectRevert( this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { - from: outputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.outputOneCase.args, { from: outputOwner, value: this.piggybackBondSize.toString() }, ), 'Piggyback is possible only in the first phase of the exit period', ); @@ -240,11 +211,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO data.outputOneCase.args.outputIndex = MAX_OUTPUT_SIZE + 1; await expectRevert( this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { - from: outputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.outputOneCase.args, { from: outputOwner, value: this.piggybackBondSize.toString() }, ), 'Invalid output index', ); @@ -259,11 +226,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO data.outputOneCase.args.outputIndex = indexOfEmptyOutput; await expectRevert( this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { - from: outputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.outputOneCase.args, { from: outputOwner, value: this.piggybackBondSize.toString() }, ), 'Indexed output is empty', ); @@ -280,11 +243,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO await expectRevert( this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { - from: outputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.outputOneCase.args, { from: outputOwner, value: this.piggybackBondSize.toString() }, ), 'Indexed output already piggybacked', ); @@ -297,11 +256,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO await expectRevert( this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { - from: outputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.outputOneCase.args, { from: outputOwner, value: this.piggybackBondSize.toString() }, ), 'There is no block for the exit position to enqueue', ); @@ -312,11 +267,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO await this.exitGame.setInFlightExit(data.exitId, data.inFlightExitData); await expectRevert( this.exitGame.piggybackInFlightExitOnOutput( - data.outputOneCase.args, { - from: nonOutputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + data.outputOneCase.args, { from: nonOutputOwner, value: this.piggybackBondSize.toString() }, ), 'Can be called only by the exit target', ); @@ -334,11 +285,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO ); this.piggybackTx = await this.exitGame.piggybackInFlightExitOnOutput( - this.testData.outputOneCase.args, { - from: outputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + this.testData.outputOneCase.args, { from: outputOwner, value: this.piggybackBondSize.toString() }, ); }); @@ -365,11 +312,7 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO it('should NOT enqueue with correct data when it is not the first piggyback of the exit on the token', async () => { const originalEnqueuedCount = await this.framework.enqueuedCount(); await this.exitGame.piggybackInFlightExitOnOutput( - this.testData.outputTwoCase.args, { - from: outputOwner, - value: this.piggybackExitTxValue, - gasPrice: this.dummyGasPrice, - }, + this.testData.outputTwoCase.args, { from: outputOwner, value: this.piggybackBondSize.toString() }, ); expect(await this.framework.enqueuedCount()).to.be.bignumber.equal(originalEnqueuedCount); @@ -389,12 +332,6 @@ contract('PaymentPiggybackInFlightExitOnOutput', ([_, alice, inputOwner, outputO expect(new BN(exits[0].outputs[0].piggybackBondSize)).to.be.bignumber.equal(this.piggybackBondSize); }); - it('should set the proper bounty size', async () => { - const exits = await this.exitGame.inFlightExits([this.testData.exitId]); - - expect(new BN(exits[0].outputs[0].bountySize)).to.be.bignumber.equal(this.processExitBountySize); - }); - it('should set the correct exit target to withdraw data on the output of exit data', async () => { const exitData = await this.exitGame.getInFlightExitOutput( this.testData.exitId, this.testData.outputOneCase.args.outputIndex, diff --git a/plasma_framework/test/src/exits/payment/controllers/PaymentProcessInFlightExit.test.js b/plasma_framework/test/src/exits/payment/controllers/PaymentProcessInFlightExit.test.js index fe99ccc8f..0a648e096 100644 --- a/plasma_framework/test/src/exits/payment/controllers/PaymentProcessInFlightExit.test.js +++ b/plasma_framework/test/src/exits/payment/controllers/PaymentProcessInFlightExit.test.js @@ -86,7 +86,6 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne token: constants.ZERO_ADDRESS, amount: 0, piggybackBondSize: 0, - bountySize: 0, }; const inFlightExitData = { @@ -102,21 +101,18 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne token: ETH, amount: TEST_INPUT_AMOUNT, piggybackBondSize: this.piggybackBondSize.toString(), - bountySize: this.processExitBountySize.toString(), }, { outputId: TEST_OUTPUT_ID_FOR_INPUT_2, exitTarget: inputOwner2, token: ETH, amount: TEST_INPUT_AMOUNT, piggybackBondSize: this.piggybackBondSize.toString(), - bountySize: this.processExitBountySize.toString(), }, { outputId: TEST_OUTPUT_ID_FOR_INPUT_3, exitTarget: inputOwner3, token: erc20, amount: TEST_INPUT_AMOUNT, piggybackBondSize: this.piggybackBondSize.toString(), - bountySize: this.processExitBountySize.toString(), }, emptyWithdrawData], outputs: [{ outputId: TEST_OUTPUT_ID_FOR_OUTPUT_1, @@ -124,21 +120,18 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne token: ETH, amount: TEST_OUTPUT_AMOUNT, piggybackBondSize: this.piggybackBondSize.toString(), - bountySize: this.processExitBountySize.toString(), }, { outputId: TEST_OUTPUT_ID_FOR_OUTPUT_2, exitTarget: outputOwner2, token: ETH, amount: TEST_OUTPUT_AMOUNT, piggybackBondSize: this.piggybackBondSize.toString(), - bountySize: this.processExitBountySize.toString(), }, { outputId: TEST_OUTPUT_ID_FOR_OUTPUT_3, exitTarget: outputOwner3, token: erc20, amount: TEST_OUTPUT_AMOUNT, piggybackBondSize: this.piggybackBondSize.toString(), - bountySize: this.processExitBountySize.toString(), }, emptyWithdrawData], }; @@ -175,9 +168,6 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne this.startIFEBondSize = await this.exitGame.startIFEBondSize(); this.piggybackBondSize = await this.exitGame.piggybackBondSize(); - this.dummyGasPrice = 1000000; - this.processExitBountySize = await this.exitGame.processInFlightExitBountySize(this.dummyGasPrice); - const maxNeededBond = this.startIFEBondSize.add(this.piggybackBondSize).muln(4); await this.exitGame.depositFundForTest({ value: maxNeededBond.toString() }); }); @@ -247,10 +237,8 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne it('should not return piggyback bond', async () => { const postAttackBalance = new BN(await web3.eth.getBalance(this.exitGame.address)); - // only start ife bond and exit bounty was returned - const expectedBalance = this.preAttackBalance - .sub(new BN(this.startIFEBondSize)) - .sub(new BN(this.processExitBountySize)); + // only start ife bond was returned + const expectedBalance = this.preAttackBalance.sub(new BN(this.startIFEBondSize)); expect(postAttackBalance).to.be.bignumber.equal(expectedBalance); }); @@ -274,10 +262,8 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne it('should not return piggyback bond', async () => { const postAttackBalance = new BN(await web3.eth.getBalance(this.exitGame.address)); - // only start ife bond and exit bounty was returned - const expectedBalance = this.preAttackBalance - .sub(new BN(this.startIFEBondSize)) - .sub(new BN(this.processExitBountySize)); + // only start ife bond was returned + const expectedBalance = this.preAttackBalance.sub(new BN(this.startIFEBondSize)); expect(postAttackBalance).to.be.bignumber.equal(expectedBalance); }); @@ -296,86 +282,6 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne }); }); - describe('When bounty award call failed', () => { - beforeEach(async () => { - this.attacker = await Attacker.new(); - - this.preAttackBalance = new BN(await web3.eth.getBalance(this.exitGame.address)); - }); - describe('on awarding exit bounty', () => { - beforeEach(async () => { - this.exit = await buildInFlightExitData(); - }); - - const setExitAndStartProcessing = async (exitMap, isCanonical) => { - this.exit.exitMap = exitMap; - this.exit.isCanonical = isCanonical; - await this.exitGame.setInFlightExit(DUMMY_EXIT_ID, this.exit); - const { receipt } = await this.exitGame.processExit( - DUMMY_EXIT_ID, - VAULT_ID.ETH, - ETH, - this.attacker.address, - ); - return receipt; - }; - - describe('when transaction is non-canonical', () => { - beforeEach(async () => { - this.receipt = await setExitAndStartProcessing(2 ** 0, false); - }); - - it('should not return exit bounty', async () => { - const postAttackBalance = new BN(await web3.eth.getBalance(this.exitGame.address)); - // only start ife bond and piggyback bond was returned - const expectedBalance = this.preAttackBalance - .sub(new BN(this.startIFEBondSize)) - .sub(new BN(this.piggybackBondSize)); - expect(postAttackBalance).to.be.bignumber.equal(expectedBalance); - }); - - it('should publish an event that bounty award failed', async () => { - await expectEvent.inTransaction( - this.receipt.transactionHash, - PaymentProcessInFlightExit, - 'InFlightBountyReturnFailed', - { - receiver: this.attacker.address, - amount: new BN(this.processExitBountySize), - }, - ); - }); - }); - - describe('when transaction is canonical', () => { - beforeEach(async () => { - this.receipt = await setExitAndStartProcessing(2 ** MAX_INPUT_NUM, true); - }); - - it('should not return exit bounty', async () => { - const postAttackBalance = new BN(await web3.eth.getBalance(this.exitGame.address)); - // only start ife bond and piggyback bond was returned - const expectedBalance = this.preAttackBalance - .sub(new BN(this.startIFEBondSize)) - .sub(new BN(this.piggybackBondSize)); - expect(postAttackBalance).to.be.bignumber.equal(expectedBalance); - }); - - it('should publish an event that bounty award failed', async () => { - await expectEvent.inTransaction( - this.receipt.transactionHash, - PaymentProcessInFlightExit, - 'InFlightBountyReturnFailed', - { - receiver: this.attacker.address, - amount: new BN(this.processExitBountySize), - }, - ); - }); - }); - }); - }); - describe('When any in-flight exit is processed successfully', () => { beforeEach(async () => { this.ifeBondOwnerPreBalance = new BN(await web3.eth.getBalance(ifeBondOwner)); @@ -390,19 +296,9 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne await this.exitGame.setInFlightExitOutputPiggybacked(DUMMY_EXIT_ID, 0); await this.exitGame.setInFlightExitOutputPiggybacked(DUMMY_EXIT_ID, 2); - this.preBalanceOtherAddress = new BN(await web3.eth.getBalance(otherAddress)); await this.exitGame.processExit(DUMMY_EXIT_ID, VAULT_ID.ETH, ETH, otherAddress); }); - it('should transfer exit bounty to the processor of all piggybacked inputs/outputs that are cleaned up', async () => { - const postBalanceOtherAddress = new BN(await web3.eth.getBalance(otherAddress)); - const expectedBalance = this.preBalanceOtherAddress - .add(this.processExitBountySize) - .add(this.processExitBountySize); - - expect(postBalanceOtherAddress).to.be.bignumber.equal(expectedBalance); - }); - it('should transfer exit bond to the IFE bond owner if all piggybacked inputs/outputs are cleaned up', async () => { await this.exitGame.processExit(DUMMY_EXIT_ID, VAULT_ID.ERC20, erc20, otherAddress); @@ -588,17 +484,6 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne expect(postBalance).to.be.bignumber.equal(expectedBalance); }); - it('should return bounty to processor for both input and output', async () => { - const preBalanceOtherAddress = new BN(await web3.eth.getBalance(otherAddress)); - await this.exitGame.processExit(DUMMY_EXIT_ID, VAULT_ID.ERC20, erc20, otherAddress); - const postBalanceOtherAddress = new BN(await web3.eth.getBalance(otherAddress)); - const expectedBalance = preBalanceOtherAddress - .add(this.processExitBountySize) - .add(this.processExitBountySize); - - expect(postBalanceOtherAddress).to.be.bignumber.equal(expectedBalance); - }); - it('should only flag piggybacked inputs with the same token as spent', async () => { await this.exitGame.processExit(DUMMY_EXIT_ID, VAULT_ID.ETH, ETH, otherAddress); // piggybacked input @@ -731,17 +616,6 @@ contract('PaymentProcessInFlightExit', ([_, ifeBondOwner, inputOwner1, inputOwne expect(postBalance).to.be.bignumber.equal(expectedBalance); }); - it('should return bounty to processor for both input and output', async () => { - const preBalanceOtherAddress = new BN(await web3.eth.getBalance(otherAddress)); - await this.exitGame.processExit(DUMMY_EXIT_ID, VAULT_ID.ERC20, erc20, otherAddress); - const postBalanceOtherAddress = new BN(await web3.eth.getBalance(otherAddress)); - const expectedBalance = preBalanceOtherAddress - .add(this.processExitBountySize) - .add(this.processExitBountySize); - - expect(postBalanceOtherAddress).to.be.bignumber.equal(expectedBalance); - }); - it('should flag ALL inputs as spent', async () => { await this.exitGame.processExit(DUMMY_EXIT_ID, VAULT_ID.ETH, ETH, otherAddress); // same token, both piggybacked and non-piggybacked cases diff --git a/plasma_framework/test/src/exits/payment/controllers/PaymentProcessStandardExit.test.js b/plasma_framework/test/src/exits/payment/controllers/PaymentProcessStandardExit.test.js index 1b87c514b..9626b049e 100644 --- a/plasma_framework/test/src/exits/payment/controllers/PaymentProcessStandardExit.test.js +++ b/plasma_framework/test/src/exits/payment/controllers/PaymentProcessStandardExit.test.js @@ -131,7 +131,7 @@ contract('PaymentProcessStandardExit', ([_, alice, bob, otherAddress]) => { }); }); - describe('when paying out bounty fails', () => { + describe('when paying out bond fails', () => { beforeEach(async () => { const exitId = 1; this.attacker = await Attacker.new(); diff --git a/plasma_framework/test/src/exits/utils/BountySize.test.js b/plasma_framework/test/src/exits/utils/BountySize.test.js index 34046055c..166e5b163 100644 --- a/plasma_framework/test/src/exits/utils/BountySize.test.js +++ b/plasma_framework/test/src/exits/utils/BountySize.test.js @@ -4,7 +4,6 @@ const { expect } = require('chai'); contract('ExitBounty', () => { const GAS_USED_PROCESS_EXIT = 107000; // approx gas usage of processExit - const GAS_SPLIT_PER_PIGGYBACK = 500000; // approx gas usage split per piggyback before('setup', async () => { this.contract = await ExitBounty.new(); @@ -12,33 +11,15 @@ contract('ExitBounty', () => { describe('calculate process standard exit bounty', () => { it('should return the correct bounty for a gas price of 10 gwei', async () => { - const gasPrice = new BN('10000000000'); - const expectedSize = gasPrice.mul(new BN(GAS_USED_PROCESS_EXIT)); + const gasPrice = 10000000000; expect(await this.contract.processStandardExitBountySize(gasPrice)) - .to.be.bignumber.equal(expectedSize); + .to.be.bignumber.equal(new BN(GAS_USED_PROCESS_EXIT * gasPrice)); }); it('should return the correct bounty for a gas price of 80 gwei', async () => { - const gasPrice = new BN('80000000000'); - const expectedSize = gasPrice.mul(new BN(GAS_USED_PROCESS_EXIT)); + const gasPrice = 80000000000; expect(await this.contract.processStandardExitBountySize(gasPrice)) - .to.be.bignumber.equal(expectedSize); - }); - }); - - describe('calculate process in-flight exit bounty', () => { - it('should return the correct bounty for a gas price of 10 gwei', async () => { - const gasPrice = new BN('10000000000'); - const expectedSize = gasPrice.mul(new BN(GAS_SPLIT_PER_PIGGYBACK)); - expect(await this.contract.processInFlightExitBountySize(gasPrice)) - .to.be.bignumber.equal(expectedSize); - }); - - it('should return the correct bounty for a gas price of 80 gwei', async () => { - const gasPrice = new BN('80000000000'); - const expectedSize = gasPrice.mul(new BN(GAS_SPLIT_PER_PIGGYBACK)); - expect(await this.contract.processInFlightExitBountySize(gasPrice)) - .to.be.bignumber.equal(expectedSize); + .to.be.bignumber.equal(new BN(GAS_USED_PROCESS_EXIT * gasPrice)); }); }); });