Sigil documentation
ReferenceRust referencesigil-node

sigil-node · contract_durable

Source declarations, signatures and documentation for contract_durable.

Source: sigil/node/sigil-node/src/contract_durable.rs. SHA-256: 133cd84c3ea670420745f6e552a846511146176455fda3264abda3e80f5c0999.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

Module condition:

#[cfg(feature = "contracts")]

contract_durable::DurableContractStore

Durable Agent Contract Zone store backed by AkashaKV.

Stores contract records, per-contract keyed state, code blobs, organization zones, contract events, and cross-zone messages. All multi-write operations should go through [ContractWriteBatch] + [DurableContractStore::commit_batch] for crash safety.

#[cfg(feature = "contracts")]
pub struct DurableContractStore {

}

Source line: 213.

contract_durable::DurableContractStore::open

Open (or create) the store at path. The directory becomes the AkashaKV data root for the contract subsystem.

#[cfg(feature = "contracts")]
pub fn open(path: &Path) -> Result<Self, NodeError>;

Source line: 221.

contract_durable::DurableContractStore::get_contract

Fetch a contract record by DID. Returns None if not deployed.

#[cfg(feature = "contracts")]
pub fn get_contract(&self, contract_did: &str) -> Result<Option<ContractRecord>, NodeError>;

Source line: 298.

contract_durable::DurableContractStore::put_contract

Insert or replace a contract record.

#[cfg(feature = "contracts")]
pub fn put_contract(&self, record: &ContractRecord) -> Result<(), NodeError>;

Source line: 307.

contract_durable::DurableContractStore::delete_contract

Delete a contract record. Used during failed deploy rollback.

#[cfg(feature = "contracts")]
pub fn delete_contract(&self, contract_did: &str) -> Result<(), NodeError>;

Source line: 314.

contract_durable::DurableContractStore::list_contracts

List all deployed contract records in deterministic DID order.

#[cfg(feature = "contracts")]
pub fn list_contracts(&self) -> Result<Vec<ContractRecord>, NodeError>;

Source line: 320.

contract_durable::DurableContractStore::list_zone_contracts

List all contracts deployed in zone_id.

#[cfg(feature = "contracts")]
pub fn list_zone_contracts(&self, zone_id: &str) -> Result<Vec<ContractRecord>, NodeError>;

Source line: 331.

contract_durable::DurableContractStore::get_zone

Fetch an OrganizationZone by id. Returns None if not found.

#[cfg(feature = "contracts")]
pub fn get_zone(&self, zone_id: &str) -> Result<Option<OrganizationZone>, NodeError>;

Source line: 346.

contract_durable::DurableContractStore::put_zone

Insert or replace an OrganizationZone.

#[cfg(feature = "contracts")]
pub fn put_zone(&self, zone: &OrganizationZone) -> Result<(), NodeError>;

Source line: 355.

contract_durable::DurableContractStore::list_zones

List all known Organization Zones in deterministic zone_id order.

#[cfg(feature = "contracts")]
pub fn list_zones(&self) -> Result<Vec<OrganizationZone>, NodeError>;

Source line: 362.

contract_durable::DurableContractStore::get_contract_state

Read a single key from a contract's keyed state.

#[cfg(feature = "contracts")]
pub fn get_contract_state(
        &self,
        contract_did: &str,
        slot: &[u8],
    ) -> Result<Option<Vec<u8>>, NodeError>;

Source line: 374.

contract_durable::DurableContractStore::put_contract_state

Write a single key into a contract's keyed state.

#[cfg(feature = "contracts")]
pub fn put_contract_state(
        &self,
        contract_did: &str,
        slot: &[u8],
        value: &[u8],
    ) -> Result<(), NodeError>;

Source line: 383.

contract_durable::DurableContractStore::delete_contract_state

Delete a single key from a contract's keyed state.

#[cfg(feature = "contracts")]
pub fn delete_contract_state(&self, contract_did: &str, slot: &[u8]) -> Result<(), NodeError>;

Source line: 393.

contract_durable::DurableContractStore::list_contract_state_entries

List every keyed state cell as (contract_did, slot, value).

#[cfg(feature = "contracts")]
pub fn list_contract_state_entries(
        &self,
    ) -> Result<Vec<(String, Vec<u8>, Vec<u8>)>, NodeError>;

Source line: 398.

contract_durable::DurableContractStore::contract_state_root

Compute a BLAKE3-based state root over all keyed state for contract_did. Iterates all (slot, value) pairs in lexicographic key order and feeds them into a flat byte buffer, then hashes it with BLAKE3 via SigilHash::digest. Returns SigilHash::ZERO if the contract has no keyed state.

#[cfg(feature = "contracts")]
pub fn contract_state_root(&self, contract_did: &str) -> Result<SigilHash, NodeError>;

Source line: 432.

contract_durable::DurableContractStore::get_code_blob

Get WASM bytecode by content-addressed hash.

#[cfg(feature = "contracts")]
pub fn get_code_blob(&self, code_hash: &SigilHash) -> Result<Option<Vec<u8>>, NodeError>;

Source line: 461.

contract_durable::DurableContractStore::get_code_metadata

Get license/source/audit metadata for a registered code hash.

#[cfg(feature = "contracts")]
pub fn get_code_metadata(
        &self,
        code_hash: &SigilHash,
    ) -> Result<Option<ContractLicenseMetadata>, NodeError>;

Source line: 467.

contract_durable::DurableContractStore::put_code_blob

Store a WASM bytecode blob. Verifies hash == BLAKE3(bytes).

#[cfg(feature = "contracts")]
pub fn put_code_blob(&self, code_hash: &SigilHash, bytes: &[u8]) -> Result<(), NodeError>;

Source line: 476.

contract_durable::DurableContractStore::list_code_blobs

#[cfg(feature = "contracts")]
pub fn list_code_blobs(&self) -> Result<Vec<(SigilHash, Vec<u8>)>, NodeError>;

Source line: 487.

contract_durable::DurableContractStore::put_code_metadata

Store license/source/audit metadata for a registered code hash.

#[cfg(feature = "contracts")]
pub fn put_code_metadata(
        &self,
        code_hash: &SigilHash,
        metadata: &ContractLicenseMetadata,
    ) -> Result<(), NodeError>;

Source line: 506.

contract_durable::DurableContractStore::list_code_metadata

#[cfg(feature = "contracts")]
pub fn list_code_metadata(
        &self,
    ) -> Result<Vec<(SigilHash, ContractLicenseMetadata)>, NodeError>;

Source line: 515.

contract_durable::DurableContractStore::append_contract_event

Append a contract event. Returns the assigned monotonic global seq.

#[cfg(feature = "contracts")]
pub fn append_contract_event(&self, event: ContractEvent) -> Result<u64, NodeError>;

Source line: 538.

contract_durable::DurableContractStore::list_contract_events

List contract events matching query.

#[cfg(feature = "contracts")]
pub fn list_contract_events(
        &self,
        query: &ContractEventQuery,
    ) -> Result<Vec<ContractEvent>, NodeError>;

Source line: 563.

contract_durable::DurableContractStore::enqueue_zone_message

Enqueue a cross-zone message.

#[cfg(feature = "contracts")]
pub fn enqueue_zone_message(&self, msg: &CrossZoneMessage) -> Result<(), NodeError>;

Source line: 592.

contract_durable::DurableContractStore::list_pending_zone_messages

List pending messages for target_zone.

AkashaKV's scan returns the oldest visible version of each key due to ascending SkipMap ordering. To avoid stale reads, we use the pending index only for its keys (to discover which message IDs to look up), then fetch the authoritative current record from the main PREFIX_MSG store. Any message whose current status is not Pending is excluded.

#[cfg(feature = "contracts")]
pub fn list_pending_zone_messages(
        &self,
        target_zone: &str,
    ) -> Result<Vec<CrossZoneMessage>, NodeError>;

Source line: 611.

contract_durable::DurableContractStore::list_zone_messages

#[cfg(feature = "contracts")]
pub fn list_zone_messages(&self) -> Result<Vec<CrossZoneMessage>, NodeError>;

Source line: 638.

contract_durable::DurableContractStore::mark_zone_message_delivered

Update a message's status (e.g. Delivered / Failed).

Updates the authoritative main record under PREFIX_MSG. list_pending_zone_messages reads from the main record for each message ID it discovers via the pending index, so it will see the updated status.

#[cfg(feature = "contracts")]
pub fn mark_zone_message_delivered(
        &self,
        msg_id: &str,
        status: MessageStatus,
    ) -> Result<(), NodeError>;

Source line: 653.

contract_durable::DurableContractStore::flush

Force a flush of AkashaKV memtables to SSTables. Useful in tests.

#[cfg(feature = "contracts")]
pub fn flush(&self) -> Result<(), NodeError>;

Source line: 671.

contract_durable::DurableContractStore::close

Graceful shutdown — flushes memtables and stops background tasks.

#[cfg(feature = "contracts")]
pub fn close(&self) -> Result<(), NodeError>;

Source line: 678.

contract_durable::DurableContractStore::commit_batch

Apply all operations in batch atomically via a single AkashaKV MVCC transaction.

Atomicity guarantee: if any individual operation fails the transaction is dropped (auto-aborted via Drop) before commit, leaving zero partial state visible. Either every operation in the batch lands or none do.

#[cfg(feature = "contracts")]
pub fn commit_batch(&self, batch: &ContractWriteBatch) -> Result<(), NodeError>;

Source line: 692.

contract_durable::DurableContractStore::namespace_prefix

Test helper: return the namespace prefix used by every contract key.

#[cfg(feature = "contracts")]
pub fn namespace_prefix() -> &'static [u8];

Source line: 789.

contract_durable::ArcContractStore

Convenience type alias for a shared durable store.

#[cfg(feature = "contracts")]
pub type ArcContractStore = Arc<DurableContractStore>;

Source line: 795.

contract_durable::ContractBatchOp

An individual operation inside a [ContractWriteBatch].

#[cfg(feature = "contracts")]
#[derive(Clone)]
pub enum ContractBatchOp {
    /// Insert or replace a contract record.
    PutContract(Box<ContractRecord>),
    /// Remove a contract record (rollback of failed deploys).
    DeleteContract(String),
    /// Insert or replace an OrganizationZone.
    PutZone(Box<OrganizationZone>),
    /// Write a (contract_did, slot, value) keyed state entry.
    PutContractState(String, Vec<u8>, Vec<u8>),
    /// Delete a (contract_did, slot) keyed state entry.
    DeleteContractState(String, Vec<u8>),
    /// Content-addressed WASM bytecode blob (hash, bytes).
    PutCodeBlob(SigilHash, Vec<u8>),
    /// License/source/audit metadata associated with a code hash.
    PutCodeMetadata(SigilHash, Box<ContractLicenseMetadata>),
    /// Append a contract event (seq will be assigned at commit time).
    AppendContractEvent(Box<ContractEvent>),
    /// Enqueue a cross-zone message.
    EnqueueZoneMessage(Box<CrossZoneMessage>),
}

Source line: 803.

contract_durable::ContractWriteBatch

Write batch accumulating all mutations for a single contract executor handler.

Build the batch during the handler, then call [crate::executor::ExecutionState::commit_contract_tx] at the end to apply all mutations atomically. A crash before commit_contract_tx leaves zero partial state on disk.

#[cfg(feature = "contracts")]
#[derive(Default)]
pub struct ContractWriteBatch {

}

Source line: 831.

contract_durable::ContractWriteBatch::new

Create an empty write batch.

#[cfg(feature = "contracts")]
pub fn new() -> Self;

Source line: 837.

contract_durable::ContractWriteBatch::put_contract

Insert or replace a contract record.

#[cfg(feature = "contracts")]
pub fn put_contract(&mut self, record: ContractRecord);

Source line: 842.

contract_durable::ContractWriteBatch::delete_contract

Delete a contract record (rollback / replacement).

#[cfg(feature = "contracts")]
pub fn delete_contract(&mut self, did: impl Into<String>);

Source line: 848.

contract_durable::ContractWriteBatch::put_zone

Insert or replace an OrganizationZone.

#[cfg(feature = "contracts")]
pub fn put_zone(&mut self, zone: OrganizationZone);

Source line: 853.

contract_durable::ContractWriteBatch::put_contract_state

Write a keyed state entry for contract_did.

#[cfg(feature = "contracts")]
pub fn put_contract_state(
        &mut self,
        contract_did: impl Into<String>,
        slot: Vec<u8>,
        value: Vec<u8>,
    );

Source line: 858.

contract_durable::ContractWriteBatch::delete_contract_state

Delete a keyed state entry for contract_did.

#[cfg(feature = "contracts")]
pub fn delete_contract_state(&mut self, contract_did: impl Into<String>, slot: Vec<u8>);

Source line: 872.

contract_durable::ContractWriteBatch::put_code_blob

Add a content-addressed WASM code blob.

#[cfg(feature = "contracts")]
pub fn put_code_blob(&mut self, hash: SigilHash, bytes: Vec<u8>);

Source line: 880.

contract_durable::ContractWriteBatch::put_code_metadata

Add metadata associated with a content-addressed code blob.

#[cfg(feature = "contracts")]
pub fn put_code_metadata(&mut self, hash: SigilHash, metadata: ContractLicenseMetadata);

Source line: 885.

contract_durable::ContractWriteBatch::append_contract_event

Append a contract event (seq assigned at commit time).

#[cfg(feature = "contracts")]
pub fn append_contract_event(&mut self, event: ContractEvent);

Source line: 891.

contract_durable::ContractWriteBatch::enqueue_zone_message

Enqueue a cross-zone message.

#[cfg(feature = "contracts")]
pub fn enqueue_zone_message(&mut self, msg: CrossZoneMessage);

Source line: 897.

contract_durable::ContractWriteBatch::len

Number of operations queued.

#[cfg(feature = "contracts")]
pub fn len(&self) -> usize;

Source line: 903.

contract_durable::ContractWriteBatch::is_empty

Returns true if no operations have been queued.

#[cfg(feature = "contracts")]
pub fn is_empty(&self) -> bool;

Source line: 908.

contract_durable::ContractWriteBatch::into_ops

Consume the batch and return the inner op list.

Used by MemoryExecutionState::commit_contract_tx to iterate ops on the in-memory slow-path without an extra clone.

#[cfg(feature = "contracts")]
pub fn into_ops(self) -> Vec<ContractBatchOp>;

Source line: 916.

On this page

contract_durable::DurableContractStorecontract_durable::DurableContractStore::opencontract_durable::DurableContractStore::get_contractcontract_durable::DurableContractStore::put_contractcontract_durable::DurableContractStore::delete_contractcontract_durable::DurableContractStore::list_contractscontract_durable::DurableContractStore::list_zone_contractscontract_durable::DurableContractStore::get_zonecontract_durable::DurableContractStore::put_zonecontract_durable::DurableContractStore::list_zonescontract_durable::DurableContractStore::get_contract_statecontract_durable::DurableContractStore::put_contract_statecontract_durable::DurableContractStore::delete_contract_statecontract_durable::DurableContractStore::list_contract_state_entriescontract_durable::DurableContractStore::contract_state_rootcontract_durable::DurableContractStore::get_code_blobcontract_durable::DurableContractStore::get_code_metadatacontract_durable::DurableContractStore::put_code_blobcontract_durable::DurableContractStore::list_code_blobscontract_durable::DurableContractStore::put_code_metadatacontract_durable::DurableContractStore::list_code_metadatacontract_durable::DurableContractStore::append_contract_eventcontract_durable::DurableContractStore::list_contract_eventscontract_durable::DurableContractStore::enqueue_zone_messagecontract_durable::DurableContractStore::list_pending_zone_messagescontract_durable::DurableContractStore::list_zone_messagescontract_durable::DurableContractStore::mark_zone_message_deliveredcontract_durable::DurableContractStore::flushcontract_durable::DurableContractStore::closecontract_durable::DurableContractStore::commit_batchcontract_durable::DurableContractStore::namespace_prefixcontract_durable::ArcContractStorecontract_durable::ContractBatchOpcontract_durable::ContractWriteBatchcontract_durable::ContractWriteBatch::newcontract_durable::ContractWriteBatch::put_contractcontract_durable::ContractWriteBatch::delete_contractcontract_durable::ContractWriteBatch::put_zonecontract_durable::ContractWriteBatch::put_contract_statecontract_durable::ContractWriteBatch::delete_contract_statecontract_durable::ContractWriteBatch::put_code_blobcontract_durable::ContractWriteBatch::put_code_metadatacontract_durable::ContractWriteBatch::append_contract_eventcontract_durable::ContractWriteBatch::enqueue_zone_messagecontract_durable::ContractWriteBatch::lencontract_durable::ContractWriteBatch::is_emptycontract_durable::ContractWriteBatch::into_ops