omgnetwork / plasma-mvp

OmiseGO's research implementation of Minimal Viable Plasma
MIT License
561 stars 158 forks source link

Remove txBytes parameter from deposit function #80

Closed 4000D closed 6 years ago

4000D commented 6 years ago

With RLPEncode library, we can make plasma transaction in RootChain contract removing txBytes parameter at deposit().

cost type total gas used
transaction cost 51224 gas
execution cost 29952 gas
smartcontracts commented 6 years ago

We're currently thinking about creating a different type of deposit transaction to avoid having to do this encoding on chain and reduce the gas cost in general. The deposit root would be calculated somewhat like this:

    /**
     * @dev Calculates the block root for a deposit transaction
     * @param depositor Address of the depositor
     * @param amount Amount deposited
     * @return The root to be used for the deposit block
     */
    function calculateDepositRoot(address depositor, uint256 amount)
        private
        view
        returns (bytes32)
    {
        bytes32 root = keccak256(depositor, amount);
        for (uint256 i = 0; i < 16; i++) {
            root = keccak256(root, zeroHashes[i]);
        }

        return root;
    }

This means that an exitor just needs to send the amount when exiting from a deposit.

smartcontracts commented 6 years ago

Closing in favor of #72 which modified deposits so that deposit blocks are represented as keccak256(msg.sender, msg.value).