Skip to content

cli: idl close to directly an idl address#2760

Merged
acheroncrypto merged 7 commits into
otter-sec:masterfrom
ochaloup:anchor-cli-close-buffer
Jan 16, 2024
Merged

cli: idl close to directly an idl address#2760
acheroncrypto merged 7 commits into
otter-sec:masterfrom
ochaloup:anchor-cli-close-buffer

Conversation

@ochaloup

@ochaloup ochaloup commented Jan 3, 2024

Copy link
Copy Markdown
Contributor

On upgrading the IDL account

anchor --provider.cluster devnet idl \
  --provider.wallet <fee-payer> upgrade <program-id> -f ./target/idl/program.json

It creates the IDL buffer and then it writes the buffer to the program IDL account.
The IDL buffer is still opened. It's not possible to use anchor idl close with specific IDL address (e.g., address of the buffer) to close it and get back the rent for the account.
Adding the optional argument of providing the IDL address directly makes possible to close the buffer account as well.

@vercel

vercel Bot commented Jan 3, 2024

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added cli idl related to the IDL, either program or client side labels Jan 4, 2024

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder why upgrade command doesn't close the buffer account by default, perhaps to version the IDLs? If you don't have any objections, I think we should close the buffer account similar to how program upgrades work and historical data should be left to RPC providers.

Comment thread cli/src/lib.rs Outdated
@ochaloup ochaloup force-pushed the anchor-cli-close-buffer branch from d938e35 to eb71503 Compare January 8, 2024 15:00
@ochaloup

ochaloup commented Jan 8, 2024

Copy link
Copy Markdown
Contributor Author

I wonder why upgrade command doesn't close the buffer account by default, perhaps to version the IDLs? ...

To me the suggestion makes perfect sense. I would expect it should work this way to follow how the solana program cli does.
Do you thing adding the idl_close call at id_upgrade makes this working as you proposed?
https://github.com/coral-xyz/anchor/pull/2760/files#diff-c1f8f7498da827a634bddc8a7559198bc99b296e9d9e8b91a70b503662995b8cR2264

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you thing adding the idl_close call at id_upgrade makes this working as you proposed?

Yes, it works great but the upgrade output is a bit confusing:

Idl buffer created: CK5yrU9hjfgPRjEN5PKTLK7UD6niW1C7RvBXstrwjJfm
Idl account closed: CK5yrU9hjfgPRjEN5PKTLK7UD6niW1C7RvBXstrwjJfm

Maybe we should log the upgrade was successful and the IDL account key?

Also, could you note both of these changes in the CHANGELOG? I think closing the buffer account is a breaking change since it's possible some people are using the buffer account.

@ochaloup ochaloup force-pushed the anchor-cli-close-buffer branch from eb71503 to 8e3cc5d Compare January 11, 2024 15:38
@ochaloup ochaloup force-pushed the anchor-cli-close-buffer branch from 8e3cc5d to c5b0efb Compare January 11, 2024 15:39
@ochaloup

Copy link
Copy Markdown
Contributor Author

@acheroncrypto Sure. So it's a new update here in PR. Let's see.

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Somehow the previous change that removed short was overridden but I restored it. Thanks!

@acheroncrypto acheroncrypto merged commit bcd7e17 into otter-sec:master Jan 16, 2024
@ochaloup

Copy link
Copy Markdown
Contributor Author

Somehow the previous change that removed short was overridden but I restored it. Thanks!

Ah, that was probably my wrong, sorry.

Thanks for looking into this, for fixing and merging 😉

Otter-0x4ka5h pushed a commit to Otter-0x4ka5h/anchor that referenced this pull request Mar 25, 2026
…fter `idl upgrade` (otter-sec#2760)

Co-authored-by: acheron <acheroncrypto@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli idl related to the IDL, either program or client side

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants