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

Update security docs #794

Merged
merged 29 commits into from
Nov 10, 2023

Conversation

ericnordelo
Copy link
Member

Fixes #565

PR Checklist

  • Tests
  • Tried the feature on a public network
  • Documentation

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.

Looking good, sir! I left some comments, questions, and suggestions

docs/modules/ROOT/pages/security.adoc Show resolved Hide resolved
docs/modules/ROOT/pages/security.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/security.adoc Outdated Show resolved Hide resolved
src/security.cairo Outdated Show resolved Hide resolved
src/tests/security/test_pausable.cairo Outdated Show resolved Hide resolved
Comment on lines 74 to 73
fn _pause(ref self: ComponentState<TContractState>) {
fn pause(ref self: ComponentState<TContractState>) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume this is for consistency, right? In the past, we followed the convention that underscored methods signified that it was potentially unsafe e.g. _mint. We should probably prioritize defining the new standard moving forward so that cases like this are clear. I don't love the idea of changing this without said standard

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair point. Agree is better wait for that discussion to happen.

docs/modules/ROOT/pages/api/security.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/security.adoc Outdated Show resolved Hide resolved
Comment on lines 4 to 6
trait ExternalTrait<TState> {
fn is_initialized(self: @TState) -> bool;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

No strong opinions on including this trait. I suppose there may be cases where this is useful

Copy link
Member Author

Choose a reason for hiding this comment

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

The name IPausable sounds a bit misleading IMO (for an interface with just the is_paused method), I think for this case is better to use a trait (like PublicKeyTrait in account), I selected the name ExternalTrait because no better name occurred to me for just is_paused. We should document this convention/pattern if we go along with it. What do you think @martriay ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The name IPausable sounds a bit misleading IMO (for an interface with just the is_paused method)

Good point. Here, it'd be IInitializable, but the point is the same. I can see it being misleading with just the getter

Copy link
Contributor

Choose a reason for hiding this comment

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

We should document this convention/pattern if we go along with it.

I just wrote this recently in our style guide, which is something I recall we discussed maybe during a call. Let me know if you think it doesn't apply here

The name IPausable sounds a bit misleading IMO (for an interface with just the is_paused method)

I kindof see what you mean, but on the other hand "pausable" doesn't really mean I can pause it, but rather that it can be paused, so the getter is not really confusing to me. btw Contracts for Solidity's version has public pause/unpause methods

ericnordelo and others added 3 commits October 20, 2023 11:00
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
…lo/cairo-contracts into feat/update-security-docs-#565
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.

I left one last suggestion. Assuming we all like ExternalTrait in these instances, LGTM!

docs/modules/ROOT/pages/security.adoc Outdated Show resolved Hide resolved
@ericnordelo ericnordelo mentioned this pull request Oct 21, 2023
3 tasks
ericnordelo and others added 3 commits October 23, 2023 12:25
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
…lo/cairo-contracts into feat/update-security-docs-#565
@andrew-fleming andrew-fleming mentioned this pull request Oct 25, 2023
3 tasks
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.

LGTM!

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.

Docs look really good! Left some comments.

src/tests/security/test_pausable.cairo Outdated Show resolved Hide resolved
@@ -1,4 +1,4 @@
use openzeppelin::security::initializable::InitializableComponent::InternalImpl;
use openzeppelin::security::InitializableComponent::{InitializableImpl, InternalImpl};
Copy link
Contributor

Choose a reason for hiding this comment

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

why was this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

To call is_initialized later

Copy link
Contributor

Choose a reason for hiding this comment

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

but why wasn't it failing?

src/tests/mocks/initializable_mock.cairo Show resolved Hide resolved
Comment on lines 4 to 6
trait ExternalTrait<TState> {
fn is_initialized(self: @TState) -> bool;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should document this convention/pattern if we go along with it.

I just wrote this recently in our style guide, which is something I recall we discussed maybe during a call. Let me know if you think it doesn't apply here

The name IPausable sounds a bit misleading IMO (for an interface with just the is_paused method)

I kindof see what you mean, but on the other hand "pausable" doesn't really mean I can pause it, but rather that it can be paused, so the getter is not really confusing to me. btw Contracts for Solidity's version has public pause/unpause methods

src/security/pausable.cairo Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/security.adoc Show resolved Hide resolved
docs/modules/ROOT/pages/api/security.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/security.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/security.adoc Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/api/security.adoc Outdated Show resolved Hide resolved
ericnordelo and others added 5 commits November 10, 2023 13:06
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: Martín Triay <martriay@gmail.com>
ericnordelo and others added 9 commits November 10, 2023 13:14
…lo/cairo-contracts into feat/update-security-docs-#565
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: Martín Triay <martriay@gmail.com>
Co-authored-by: Martín Triay <martriay@gmail.com>
…lo/cairo-contracts into feat/update-security-docs-#565
@ericnordelo ericnordelo requested a review from martriay November 10, 2023 12:21
@martriay martriay merged commit 68e9f37 into OpenZeppelin:main Nov 10, 2023
4 checks passed
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.

update security docs
3 participants