Skip to main content

Crate magicblock_account

Crate magicblock_account 

Source
Expand description

§solana-account

This fork defines the engine’s account representation. Account is the fully-owned compatibility form. AccountSharedData uses either a heap-owned Arc<Vec<u8>> or a borrowed view into aligned external storage and records field-level dirty markers.

Equality compares core state and data bytes, ignoring storage form and dirty markers.

The testkit feature exposes borrowed-buffer fixtures and testkit::delegated_account(lamports, data, owner), which returns a customizable builder for an explicitly user-mutable test account.

AccountMode::mutable() permits user mutation only in delegated and ephemeral modes. AccountSharedData::mutable() is a transaction-final acceptance check: it also permits transient and closed accounts whose mode changed in the current transaction. This allows lifecycle writeback, never another program write. AccountMode::authoritative() separately identifies delegated, ephemeral, and transient state that the engine owns and higher layers retain in persistent storage.

AccountSharedData::set_lifecycle() and AccountMode::allows_transition() share one mode-and-slot rule:

FromSame or newer slotStrictly newer slot
PlaceholderReadOnly, System, Delegated, Ephemeral, ClosedPlaceholder
ReadOnlyDelegated, Ephemeral, ClosedReadOnly, Placeholder
SystemSystem
DelegatedTransient
EphemeralClosed
TransientReadOnly, PlaceholderDelegated
Closed

Unlisted pairs and slot regressions are rejected. Authoritative accounts cannot be rematerialized in the same mode, even at a newer slot; ordinary transaction mutations are unaffected. Errors leave account state and dirty markers unchanged and identify the invalid mode or slot pair through AccountPatchError.

Full-account patch sequences cover non-flag fields, establish the exact data length, and then write data in bounded chunks. MagicRoot finalization installs the caller-supplied complete flag value without changing lamports. StateFlags currently contains only EXECUTABLE; replacement freshness is enforced by the caller rather than an account flag.

§Borrowed layout

PartPositionContents
headerstartsequence and image size
pubkeyafter headershared account pubkey
image Aafter pubkeycore state and data
image Bafter image Acore state and data

Borrowed buffers must be 8-byte aligned, match this layout, remain live, and have unique mutable access for the duration of the borrow. The source may be an mmap, arena, or test buffer.

The sequence counter selects the active image. Mutation translates active state into the shadow image; commit advances the sequence to publish it. Writes that exceed borrowed capacity promote the account to owned storage.

Structs§

Account
An on-chain account with owned data and an explicit rent epoch.
AccountBuilder
Builder for an owned account representation.
AccountSeqLock
Read wrapper that retries borrowed account reads when a concurrent publish changes the backing image.
AccountSharedData
Shared account data that borrows directly from an aligned external buffer until a write requires promotion to owned heap storage.
BorrowedAccount
Borrowed zero-copy account view into an aligned external buffer.
DirtyMarkers
Bits that record which fields changed through AccountSharedData.
OwnedAccount
Heap-backed account, used after promotion from borrowed or direct construction.
StateFlags
Account state modifier flags.
StorageUnit
Minimum addressable storage unit for borrowed account images.

Enums§

AccountFieldPatch
A bounded account-image patch.
AccountMode
Mutually exclusive modes an account can occupy in the ephemeral rollup (ER).
AccountPatchError
Failure to apply an account lifecycle or ordering patch.
CoWAccount
Backing storage for AccountSharedData.

Constants§

ALIGNMENT
Borrowed buffers must be aligned to this many bytes.
PROGRAM_OWNERS
Owners that imply the account contains a loaded program.
STORAGE_UNIT
Bytes in one storage unit.

Traits§

ReadableAccount
Read-only access to account state.
WritableAccount
Writable access to account state.

Functions§

accounts_equal
Returns true when the readable account fields match.
create_is_signer_account_infos
Builds AccountInfo values for accounts and signer bits.