omgnetwork / research

43 stars 2 forks source link

Fees withdrawal from plasma contract research #113

Closed Pongch closed 4 years ago

Pongch commented 4 years ago

Research for the operator to discover the possibility of withdrawing collected fees from the root-chain contract and any potential issues that may arise.

boolafish commented 4 years ago

Did a POC with the following fee tx format on the contract side. In this format, fee transaction would point to the previous fee transaction. First fee tx would be with empty input.

The main thing to verify is can we have multiple output data structure for fee tx? If we are not aiming to exit by the fee tx type directly, which means we don't need a exit game implementation, potentially the old statement of "it is hard to have multiple data structure for outputs because of solidity limit" would not block us.

Branch: https://github.com/omisego/plasma-contracts/tree/poc_fee_chain_tx_multi_output_structure Example commit: https://github.com/omisego/plasma-contracts/commit/7e6bf7a5886a5b1131d5346a71e923a64fab4b38

Fee Transaction

{
    txType: uint256,
    inputs: [], // list of bytes32
    outputs: [], // list of 2 potential structs (2 output types)
}

Inputs

bytes32: outputId of the previous fee transaction

Outputs

  1. FeeOutput: the output that holds the Fee value
    {
    outputType: uint256,
    amount: uint256,
    outputGuard: bytes20,
    token: address,
    }
  2. FeeNonceOutput: the output that holds a nonce
    {
    outputType: uint256,
    nonce: uint256,
    }

PS. I don't think we need to chain txs together though, and we don't really gain anything with that. The nonce itself would be good enough. However, chch/watcher should probably check the nonce is unique or not.