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

Remove a check for a valid nonce and mutex from StakerProxy.stake() #763

Closed pgev closed 5 years ago

pgev commented 5 years ago

In the context of OSTComposer functionality, we've already checked the validity of a provided nonce within OSTComposer::requestStake() function (to make sure that OSTComposer::acceptStakeRequest() would not fail because of an invalid nonce).

In the context of StakerProxy::stake() function this check is not needed as a call to gateway stack function would assure this.

We can safely remove a mutex from OSTComposer::acceptStakeRequest and execute the following statements after the first require statement in the function:

delete stakeRequestHashes[stakeRequest.staker][address(stakeRequest.gateway)];
delete stakeRequests[_stakeRequestHash];

We can safely remove mutex from OSTComposer::revokeStakeRequest and OSTComposer::rejectStakeRequest as the following statements in function OSTComposer::removeStakeRequest (called within above-mentioned functions) protects against reentrancy:

        delete stakeRequestHashes[staker][address(stakeRequest.gateway)];
        delete stakeRequests[_stakeRequestHash];
abhayks1 commented 5 years ago

Started working on it 🚗