Skip to content

read only version of nonReentrant modifier #4422

@thedavidmeister

Description

@thedavidmeister

🧐 Motivation

Help slither understand read only reentrancy guards by implementing a modifier like nonReentrant that does NOT modify the state, and just checks _reentrancyGuardEntered.

Slither has a special case in it for analysing nonReentrant but gives false positives on cross function reentrancies where view functions read state that is modified after a reentrant call.

E.g. crytic/slither#735 (comment)

If there was a modifier that was compatible with view functions then slither could understand this too.

📝 Details

Add a nonReentrantView modifier that is a thin wrapper around _reentrancyGuardEntered()

e.g.

modifier nonReentrantView() {
  if(_reentrancyGuardEntered()) {
    revert ReentrancyGuardReentrantCall();
  }
  _;
}

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