OpenST / mosaic-contracts

Mosaic-0: Gateways and anchors on top of Ethereum to scale DApps
https://discuss.openst.org/c/mosaic
MIT License
114 stars 31 forks source link

Staker proxy contract. #741

Closed deepesh-kn closed 5 years ago

deepesh-kn commented 5 years ago

This is closely dependent on #740

StakerProxy contract:

Please note: the contract is referred to StakerProxy, but this is not final name. Suggest a better name.

Gateways can do one stake - mint process at a time for a given staker address. So the composer contract cannot call gateway.stake() function, it will be not able to serve all stake requests from multiple stakers addresses. So a proxy contract is introduced as a proposal here.


This contract can have following variables.

address  public composer;
address  public owner;

Constructor

    constructor(
        address _composer, 
        address _owner
    ) 
        public;

Accept stake request

     function acceptStakeRequest(
        uint256 _amount,
        address _beneficiary,
        uint256 _gasPrice,
        uint256 _gasLimit,
        uint256 _nonce,
        bytes32 _hashLock,
        address _staker,
        address _gateway
    )
        onlyComposer
        external
        returns (bytes32 messageHash_);

More detail is on EPIC

abhayks1 commented 5 years ago

Was going through the epic 📔 . Have a question

@deepesh-kn @schemar what do you think 🤔 ?

deepesh-kn commented 5 years ago

Was going through the epic 📔 . Have a question

  • Should we also support transfer and approve methods in the proxy contract so that transferred money is not stuck? This could happen because of revertStake(if we are supporting) or an arbitrary transfer.

@deepesh-kn @schemar what do you think 🤔 ?

Nice point 👍 This is kept out of scope for now. We can think about this.

Revert will be very tricky. A facilitator will not get any benefit for revert stake, as the bounty will be burnt and also will not get any reward for facilitation so it may not do the facilitation. In this case staker needs to do facilitation itself. Staker may not have OST' on the auxiliary chain to perform it.

In case the tokens are stuck in the gateway then, any facilitator can progress with proof, the facilitator can get bounty and reward.

abhayks1 commented 5 years ago

In case the tokens are stuck in the gateway then, any facilitator can progress with proof, the facilitator can get bounty and reward.

I meant if tokens are stuck in staker proxy address. An arbitrary transfer(e.g. ALT coins transfer) can be made to staker proxy address. Should we give owner option to take out that money?

schemar commented 5 years ago

Right now I added a self-destruct method that returns all base coin and erc20 value to the owner before destructing.

deepesh-kn commented 5 years ago

Right now I added a self-destruct method that returns all base coin and erc20 value to the owner before destructing.

It should also update the composer contract to remove the proxy contract address for the staker address? We can discuss this in detail.

schemar commented 5 years ago

We had a short call and discussed that we want to: