Skip to content

Possible gas inefficiency in the updateReward modifier usage pattern  #79

@NicolaBernini

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions