Skip to content

Feat: Update AccountsClose to be safe to call manually - #2209

Merged
Henry-E merged 12 commits into
otter-sec:masterfrom
stegaBOB:stegaBOB/fix/close-safety
Oct 21, 2022
Merged

Feat: Update AccountsClose to be safe to call manually#2209
Henry-E merged 12 commits into
otter-sec:masterfrom
stegaBOB:stegaBOB/fix/close-safety

Conversation

@stegaBOB

@stegaBOB stegaBOB commented Oct 6, 2022

Copy link
Copy Markdown
Contributor

Updates the AccountsClose trait to ensure its safe to call manually.

Also removed the warnings and added more tests to make sure its safe. Also added AccountsClose to the prelude.

@vercel

vercel Bot commented Oct 6, 2022

Copy link
Copy Markdown

@stegaBOB is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@armaniferrante
armaniferrante requested a review from Henry-E October 6, 2022 20:50
@Henry-E

Henry-E commented Oct 6, 2022

Copy link
Copy Markdown

@armaniferrante The core part of this change is switching
if &T::owner() == program_id {
to
if self.info.owner == program_id {
If that's a safe change to make then we should totally do this. But I don't feel qualified yet to comment on using the owner trait vs. the self.info.owner value.

@stegaBOB

stegaBOB commented Oct 6, 2022

Copy link
Copy Markdown
Contributor Author

This may actually cause issues if assign is called manually. I'm not sure if the serialization would normally fail in that case. I'm going to do an additional test here first and I'll report back.

@stegaBOB

stegaBOB commented Oct 7, 2022

Copy link
Copy Markdown
Contributor Author

@Henry-E @armaniferrante I updated the AccountsExit logic and it should prevent any false positives from being triggered on accounts with reassigned owners.

@stegaBOB

stegaBOB commented Oct 7, 2022

Copy link
Copy Markdown
Contributor Author

This PR should be ready to merge in. The failed workflow runs fails were GitHub network errors.

Comment thread lang/src/accounts/account_loader.rs Outdated
Comment thread lang/src/accounts/account.rs
@Henry-E
Henry-E merged commit fa12498 into otter-sec:master Oct 21, 2022
Henry-E pushed a commit to Henry-E/anchor that referenced this pull request Dec 6, 2022
* fix other lints to make the test pass

(cherry picked from commit d6e43c1)

* update close to make it safe to call manually

* fix test script

* re-add safety warnings for deprecated account types

* update close checking logic

* readd logic for deprecated methods

* add additional checks to account_loader in exit
akash-osec pushed a commit to akash-osec/anchor that referenced this pull request Mar 25, 2026
* fix other lints to make the test pass

(cherry picked from commit d6e43c1)

* update close to make it safe to call manually

* fix test script

* re-add safety warnings for deprecated account types

* update close checking logic

* readd logic for deprecated methods

* add additional checks to account_loader in exit
@stegaBOB
stegaBOB deleted the stegaBOB/fix/close-safety branch May 8, 2026 18:50
@jamie-osec jamie-osec added this to the Pre-1.0 milestone Jun 24, 2026
akash-osec pushed a commit to akash-osec/anchor that referenced this pull request Jul 25, 2026
* fix other lints to make the test pass

(cherry picked from commit d6e43c1)

* update close to make it safe to call manually

* fix test script

* re-add safety warnings for deprecated account types

* update close checking logic

* readd logic for deprecated methods

* add additional checks to account_loader in exit
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.

4 participants