Skip to main content

MagicBlockInstruction

Enum MagicBlockInstruction 

Source
pub enum MagicBlockInstruction {
Show 23 variants ModifyAccounts { accounts: HashMap<Pubkey, AccountModificationForInstruction>, message: Option<String>, }, ScheduleCommit, ScheduleCommitAndUndelegate, AcceptScheduleCommits, ScheduledCommitSent((u64, u64)), ScheduleBaseIntent(MagicBaseIntentArgs), ScheduleTask(ScheduleTaskArgs), CancelTask { task_id: i64, }, DisableExecutableCheck, EnableExecutableCheck, Noop(u64), ScheduleIntentBundle(MagicIntentBundleArgs), CreateEphemeralAccount { data_len: u32, }, ResizeEphemeralAccount { new_data_len: u32, }, CloseEphemeralAccount, ScheduleCommitFinalize { request_undelegation: bool, }, CloneAccount { pubkey: Pubkey, data: Vec<u8>, fields: AccountCloneFields, }, CloneAccountInit { pubkey: Pubkey, total_data_len: u32, initial_data: Vec<u8>, fields: AccountCloneFields, }, CloneAccountContinue { pubkey: Pubkey, offset: u32, data: Vec<u8>, is_last: bool, }, CleanupPartialClone { pubkey: Pubkey, }, FinalizeProgramFromBuffer { remote_slot: u64, }, FinalizeV1ProgramFromBuffer { remote_slot: u64, authority: Pubkey, }, SetProgramAuthority { authority: Pubkey, },
}

Variants§

§

ModifyAccounts

Modify one or more accounts

§Account references

  • 0. [WRITE, SIGNER] Validator Authority
  • 1..n. [WRITE] Accounts to modify
  • n+1 [SIGNER] (Implicit NativeLoader)
§

ScheduleCommit

Schedules the accounts provided at end of accounts Vec to be committed. It should be invoked from the program whose PDA accounts are to be committed.

This is the first part of scheduling a commit. A second transaction MagicBlockInstruction::AcceptScheduleCommits has to run in order to finish scheduling the commit.

§Account references

  • 0. [WRITE, SIGNER] Payer requesting the commit to be scheduled
  • 1. [WRITE] Magic Context Account containing to which we store the scheduled commits
  • 2..n [] Accounts to be committed
§

ScheduleCommitAndUndelegate

This is the exact same instruction as MagicBlockInstruction::ScheduleCommit except that the [ScheduledCommit] is flagged such that when accounts are committed, a request to undelegate them is included with the same transaction. Additionally the validator will refuse anymore transactions for the specific account since they are no longer considered delegated to it.

This is the first part of scheduling a commit. A second transaction MagicBlockInstruction::AcceptScheduleCommits has to run in order to finish scheduling the commit.

§Account references

  • 0. [WRITE, SIGNER] Payer requesting the commit to be scheduled
  • 1. [WRITE] Magic Context Account containing to which we store the scheduled commits
  • 2..n [] Accounts to be committed and undelegated
§

AcceptScheduleCommits

Moves the scheduled commit from the MagicContext to the global scheduled commits map. This is the second part of scheduling a commit.

It is run at the start of the slot to update the global scheduled commits map just in time for the validator to realize the commits right after.

§Account references

  • 0. [SIGNER] Validator Authority
  • 1. [WRITE] Magic Context Account containing the initially scheduled commits
§

ScheduledCommitSent((u64, u64))

Records the attempt to realize a scheduled commit on chain.

The signature of this transaction can be pre-calculated since we pass the ID of the scheduled commit and retrieve the signature from a globally stored hashmap.

We implement it this way so we can log the signature of this transaction as part of the MagicBlockInstruction::ScheduleCommit instruction. Args: (intent_id, bump) - bump is needed in order to guarantee unique transactions

§

ScheduleBaseIntent(MagicBaseIntentArgs)

Schedules execution of a single base intent.

A “base intent” is an atomic unit of work executed by the validator on the Base layer, such as:

  • executing standalone base actions (BaseActions)
  • committing a set of accounts (Commit)
  • committing and undelegating accounts, optionally with post-actions (CommitAndUndelegate)

This instruction is the legacy/single-intent variant of scheduling. For batching multiple independent intents into a single instruction, see MagicBlockInstruction::ScheduleIntentBundle.

§Account references

  • 0. [WRITE, SIGNER] Payer requesting the intent to be scheduled
  • 1. [WRITE] Magic Context account
  • 2..n [] Accounts referenced by the intent (including action accounts)

§Data

The embedded MagicBaseIntentArgs encodes account references by indices into the accounts array (compact representation).

§

ScheduleTask(ScheduleTaskArgs)

Schedule a new task for execution

§Account references

  • 0. [WRITE, SIGNER] Payer (payer)
  • 1. [WRITE] Task context account
  • 2..n [] Accounts included in the task
§

CancelTask

Cancel a task

§Account references

  • 0. [WRITE, SIGNER] Task authority
  • 1. [WRITE] Task context account

Fields

§task_id: i64
§

DisableExecutableCheck

Disables the executable check, needed to modify the data of a program in preparation to deploying it via LoaderV4 and to modify its authority.

§Account references

  • 0. [SIGNER] Validator authority
§

EnableExecutableCheck

Enables the executable check, and should run after a program is deployed with the LoaderV4 and we modified its authority

§Account references

  • 0. [SIGNER] Validator authority
§

Noop(u64)

Noop instruction

§

ScheduleIntentBundle(MagicIntentBundleArgs)

Schedules execution of a bundle of intents in a single instruction.

A “intent bundle” is an atomic unit of work executed by the validator on the Base layer, such as:

  • standalone base actions
  • an optional Commit
  • an optional CommitAndUndelegate

This is the recommended scheduling path when the caller wants to submit multiple independent intents while paying account overhead only once.

§Account references

  • 0. [WRITE, SIGNER] Payer requesting the bundle to be scheduled
  • 1. [WRITE] Magic Context account
  • 2..n [] All accounts referenced by any intent in the bundle

§Data

The embedded MagicIntentBundleArgs encodes account references by indices into the accounts array.

§

CreateEphemeralAccount

Creates a new ephemeral account with rent paid by a sponsor. The account is automatically owned by the calling program (CPI caller).

§Account references

  • 0. [WRITE] Sponsor account (pays rent, can be PDA or oncurve)
  • 1. [WRITE] Ephemeral account to create (must have 0 lamports)
  • 2. [WRITE] Vault account (receives rent payment)

Fields

§data_len: u32

Initial data length in bytes

§

ResizeEphemeralAccount

Resizes an existing ephemeral account, adjusting rent accordingly.

§Account references

  • 0. [WRITE] Sponsor account (pays/receives rent difference)
  • 1. [WRITE] Ephemeral account to resize
  • 2. [WRITE] Vault account (holds/receives lamports for rent transfer)

Fields

§new_data_len: u32

New data length in bytes

§

CloseEphemeralAccount

Closes an ephemeral account, refunding rent to the sponsor.

§Account references

  • 0. [WRITE] Sponsor account (receives rent refund)
  • 1. [WRITE] Ephemeral account to close
  • 2. [WRITE] Vault account (source of rent refund)
§

ScheduleCommitFinalize

Schedules the accounts provided at end of accounts Vec to be committed and finalized in a single DLP instruction. It should be invoked from the program whose PDA accounts are to be committed.

This is the first part of scheduling a commit. A second transaction MagicBlockInstruction::AcceptScheduleCommits has to run in order to finish scheduling the commit.

§Account references

  • 0. [WRITE, SIGNER] Payer requesting the commit to be scheduled
  • 1. [WRITE] Magic Context Account containing to which we store the scheduled commits
  • 2..n [] Accounts to be committed

Fields

§request_undelegation: bool
§

CloneAccount

Clone a single account that fits in one transaction (<63KB data).

§Account references

  • 0. [WRITE, SIGNER] Validator Authority
  • 1. [WRITE] Account to clone

Fields

§pubkey: Pubkey
§data: Vec<u8>
§

CloneAccountInit

Initialize a multi-transaction clone for a large account. Adds the pubkey to PENDING_CLONES. Must be followed by CloneAccountContinue with is_last=true to complete.

§Account references

  • 0. [WRITE, SIGNER] Validator Authority
  • 1. [WRITE] Account to clone

Fields

§pubkey: Pubkey
§total_data_len: u32
§initial_data: Vec<u8>
§

CloneAccountContinue

Continue a multi-transaction clone with the next data chunk. If is_last=true, removes the pubkey from PENDING_CLONES.

§Account references

  • 0. [WRITE, SIGNER] Validator Authority
  • 1. [WRITE] Account being cloned

Fields

§pubkey: Pubkey
§offset: u32
§data: Vec<u8>
§is_last: bool
§

CleanupPartialClone

Cleanup a partial clone on failure. Removes from PENDING_CLONES and deletes the account.

§Account references

  • 0. [WRITE, SIGNER] Validator Authority
  • 1. [WRITE] Account to cleanup

Fields

§pubkey: Pubkey
§

FinalizeProgramFromBuffer

Finalize program deployment from a buffer account. Does the following:

  1. Copies data from buffer account to program account
  2. Sets loader header with Retracted status and validator authority
  3. Closes buffer account

After this, LoaderV4::Deploy must be called, then SetProgramAuthority.

§Account references

  • 0. [SIGNER] Validator Authority
  • 1. [WRITE] Program account
  • 2. [WRITE] Buffer account (closed after)

Fields

§remote_slot: u64
§

FinalizeV1ProgramFromBuffer

Finalize V1 program deployment from a buffer account. V1 programs are converted to V3 (upgradeable loader) format. Does the following:

  1. Creates program_data account with V3 ProgramData header + ELF
  2. Creates program account with V3 Program header
  3. Closes buffer account

§Account references

  • 0. [SIGNER] Validator Authority
  • 1. [WRITE] Program account
  • 2. [WRITE] Program data account
  • 3. [WRITE] Buffer account (closed after)

Fields

§remote_slot: u64
§authority: Pubkey
§

SetProgramAuthority

Update the authority in a LoaderV4 program header. Used after Deploy to set the final chain authority.

§Account references

  • 0. [SIGNER] Validator Authority
  • 1. [WRITE] Program account

Fields

§authority: Pubkey

Implementations§

Trait Implementations§

Source§

impl Clone for MagicBlockInstruction

Source§

fn clone(&self) -> MagicBlockInstruction

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MagicBlockInstruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MagicBlockInstruction

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for MagicBlockInstruction

Source§

fn eq(&self, other: &MagicBlockInstruction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MagicBlockInstruction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for MagicBlockInstruction

Source§

impl StructuralPartialEq for MagicBlockInstruction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,