lang: Update idl.rs docs (#117)

This commit is contained in:
Armani Ferrante 2021-03-23 10:08:22 -07:00 committed by GitHub
parent f84d072bca
commit 25706d17c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 12 deletions

View File

@ -1,17 +1,21 @@
//! idl.rs defines the instructions and account state used to store a //! idl.rs defines the instructions and account state used to store a program's
//! program's IDL. //! IDL on-chain at a canonical account address, which can be derived as a
//! function of nothing other than the program's ID.
//! //!
//! Note that the transaction to store the IDL can be larger than the max //! It can be upgraded in a way similar to a BPF upgradeable program. That is,
//! transaction size. As a reuslt, the transaction must be broken up into //! one may invoke the `IdlInstruction::CreateBuffer` instruction to create
//! several pieces and stored into the IDL account with multiple transactions //! a buffer, `IdlInstruction::Write` to write a new IDL into it, and then
//! via the `Write` instruction to continuously append to the account's IDL data //! `IdlInstruction::SetBuffer` to copy the IDL into the program's canonical
//! buffer. //! IDL account. In order to perform this upgrade, the buffer's `authority`
//! must match the canonical IDL account's authority.
//! //!
//! To upgrade the IDL, first invoke the `Clear` instruction to reset the data. //! Because the IDL can be larger than the max transaction size, the transaction
//! And invoke `Write` once more. To eliminate the ability to change the IDL, //! must be broken up into several pieces and stored into the IDL account with
//! set the authority to a key for which you can't sign, e.g., the zero address //! multiple transactions via the `Write` instruction to continuously append to
//! or the system program ID, or compile the program with the "no-idl" feature //! the account's IDL data buffer.
//! and upgrade the program with the upgradeable BPF loader. //!
//! Note that IDL account instructions are automatically inserted into all
//! Anchor programs. To remove them, one can use the `no-idl` feature.
use crate::prelude::*; use crate::prelude::*;
use solana_program::pubkey::Pubkey; use solana_program::pubkey::Pubkey;