Skip to content

Commit

Permalink
Revert "[Process Exit Bounty] Add process exit bounty for IFE (#682)" (
Browse files Browse the repository at this point in the history
…#696)

This reverts commit 20c3502.
  • Loading branch information
souradeep-das authored Aug 24, 2020
1 parent 83d5c15 commit f7084a7
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions plasma_framework/contracts/mocks/utils/ExitBountyWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ contract ExitBountyWrapper {
return ExitBounty.processStandardExitBountySize(gasPriceStartExit);
}

function processInFlightExitBountySize(uint256 gasPricePiggyback) public view returns (uint256) {
return ExitBounty.processInFlightExitBountySize(gasPricePiggyback);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ library PaymentExitDataModel {
address token;
uint256 amount;
uint256 piggybackBondSize;
uint256 bountySize;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -59,8 +54,7 @@ library PaymentProcessInFlightExit {
Controller memory self,
PaymentExitDataModel.InFlightExitMap storage exitMap,
uint168 exitId,
address token,
address payable processor
address token
)
public
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -272,8 +266,7 @@ library PaymentProcessInFlightExit {
function returnInputPiggybackBonds(
Controller memory self,
PaymentExitDataModel.InFlightExit storage exit,
address token,
address payable processor
address token
)
private
{
Expand All @@ -282,32 +275,22 @@ 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);
}
}
}
}

function returnOutputPiggybackBonds(
Controller memory self,
PaymentExitDataModel.InFlightExit storage exit,
address token,
address payable processor
address token
)
private
{
Expand All @@ -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);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ contract PaymentInFlightExitRouter is
public
payable
nonReentrant(framework)
onlyWithValue(piggybackBondSize() + processInFlightExitBountySize(tx.gasprice))
onlyWithValue(piggybackBondSize())
{
piggybackInFlightExitController.piggybackInput(inFlightExitMap, args);
}
Expand All @@ -237,7 +237,7 @@ contract PaymentInFlightExitRouter is
public
payable
nonReentrant(framework)
onlyWithValue(piggybackBondSize() + processInFlightExitBountySize(tx.gasprice))
onlyWithValue(piggybackBondSize())
{
piggybackInFlightExitController.piggybackOutput(inFlightExitMap, args);
}
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}
}
10 changes: 1 addition & 9 deletions plasma_framework/contracts/src/exits/utils/ExitBounty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
7 changes: 3 additions & 4 deletions plasma_framework/python_tests/testlang/testlang.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit f7084a7

Please sign in to comment.