Skip to content

Possible gas inefficiency in the updateReward modifier usage pattern  #79

Description

@NicolaBernini

In Rewards.sol I have noticed some functions like stake() and withdraw() use the updateReward() modifier

            function stake(uint256 amount) public override updateReward(msg.sender) {
                require(amount > 0, "Cannot stake 0");
                super.stake(amount);
                emit Staked(msg.sender, amount);
            }

If I am not mistaken it means the modifier code, which does some math and storage, is executed before the require() statement in the called function and hence I guess it could be more gas efficient if the require() is executed first

What do you think?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions