Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better document reentrancy_guard() #3893

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sway-lib-std/src/reentrancy.sw
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use ::assert::assert;
use ::call_frames::*;
use ::registers::frame_ptr;

/// Reverts if the reentrancy pattern is detected in the contract in which this is called.
/// Not needed if the Checks-Effects-Interactions (CEI) pattern is followed (as prompted by the compiler).
/// Caution: While this can protect against both single-function reentrancy and cross-function reentrancy attacks, it WILL NOT PREVENT a cross-contract reentrancy attack.
pub fn reentrancy_guard() {
assert(!is_reentrant());
}
Expand Down