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

Implement a reentrancy guard #236

Merged
merged 33 commits into from
Apr 1, 2022

Conversation

JulissaDantes
Copy link
Contributor

Fixes #228

Implements a reentrancy guard contract with 2 steps, start and end, that should be above and below the function body

Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good! Left some comments. Also, I think we should also test that the protected function can be called under normal conditions.

openzeppelin/security/reentrancy_guard.cairo Outdated Show resolved Hide resolved
openzeppelin/security/reentrancy_guard.cairo Outdated Show resolved Hide resolved
tests/mocks/reentrancy_attacker_mock.cairo Outdated Show resolved Hide resolved
tests/security/test_reentrancy.py Outdated Show resolved Hide resolved
tests/mocks/reentrancy_mock.cairo Outdated Show resolved Hide resolved
docs/Security.md Outdated Show resolved Hide resolved
tests/mocks/reentrancy_mock.cairo Outdated Show resolved Hide resolved
tests/mocks/reentrancy_attacker_mock.cairo Outdated Show resolved Hide resolved
Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! I left some questions and comments. Also, I think we should add a test case testing that a protected function still executes properly.

docs/Security.md Show resolved Hide resolved
docs/Security.md Outdated Show resolved Hide resolved
openzeppelin/security/reentrancy_guard.cairo Outdated Show resolved Hide resolved
tests/mocks/reentrancy_attacker_mock.cairo Outdated Show resolved Hide resolved
tests/mocks/reentrancy_mock.cairo Outdated Show resolved Hide resolved
tests/mocks/reentrancy_mock.cairo Outdated Show resolved Hide resolved
tests/mocks/reentrancy_mock.cairo Outdated Show resolved Hide resolved
tests/security/test_reentrancy.py Outdated Show resolved Hide resolved
tests/mocks/reentrancy_mock.cairo Outdated Show resolved Hide resolved
openzeppelin/security/reentrancy_guard.cairo Outdated Show resolved Hide resolved
@JulissaDantes JulissaDantes changed the title Reentrancy guard Implement a reentrancy guard Mar 28, 2022
Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvements! We're almost there.

docs/Security.md Outdated Show resolved Hide resolved
docs/Security.md Show resolved Hide resolved
openzeppelin/security/reentrancy_guard.cairo Outdated Show resolved Hide resolved
tests/mocks/reentrancy_mock.cairo Outdated Show resolved Hide resolved
tests/security/test_reentrancy.py Outdated Show resolved Hide resolved
tests/mocks/reentrancy_mock.cairo Outdated Show resolved Hide resolved
Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvements! Please ignore the storage var suggested change.

openzeppelin/security/reentrancy_guard.cairo Outdated Show resolved Hide resolved
@andrew-fleming andrew-fleming dismissed their stale review March 30, 2022 11:10

Requested change is not necessary

JulissaDantes and others added 12 commits March 31, 2022 09:08
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
Co-authored-by: Martín Triay <martriay@gmail.com>
Co-authored-by: Martín Triay <martriay@gmail.com>
Co-authored-by: Martín Triay <martriay@gmail.com>
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
Copy link
Contributor

@martriay martriay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Copy link
Collaborator

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ReentrancyGuard
4 participants