Sigil documentation
ReferenceRust referencesigil-execution

sigil-execution · context

Source declarations, signatures and documentation for context.

Source: sigil/node/sigil-execution/src/context.rs. SHA-256: 0f1843b8437d04ea561f7a3b2729d3a49a8c5ce3a8dd20d135fc74aee8f278b7.

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.

context::StateChange

A single state mutation recorded during execution.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct StateChange {
/// Key that was modified.

pub key: Vec<u8>,
/// Previous value (None if the key did not exist).

pub old_value: Option<Vec<u8>>,
/// New value (None if the key was deleted).

pub new_value: Option<Vec<u8>>
}

Source line: 18.

context::LogEntry

A log entry emitted during execution.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct LogEntry {
/// Severity level.

pub level: LogLevel,
/// Log message.

pub message: String,
/// Block timestamp at which the log was emitted.

pub timestamp: u64
}

Source line: 29.

context::ExecutionContext

Context for a single WASM execution, tracking all side effects and gas usage.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ExecutionContext {
/// Zone in which the execution is running.

pub zone_id: String,
/// OAS DID of the transaction sender.

pub caller_did: String,
/// Current block height.

pub block_height: u64,
/// Current block timestamp (Unix seconds).

pub block_timestamp: u64,
/// Hash of the transaction being executed.

pub tx_hash: SigilHash,
/// Gas meter for this execution.

pub fuel_meter: FuelMeter,
/// State mutations accumulated during execution.

pub state_changes: Vec<StateChange>,
/// Cross-zone messages emitted during execution.

pub messages_sent: Vec<CrossZoneMessage>,
/// Log entries emitted during execution.

pub logs: Vec<LogEntry>
}

Source line: 40.

context::ExecutionContext::new

Create a new execution context.

pub fn new(
        zone_id: impl Into<String>,
        caller_did: impl Into<String>,
        block_height: u64,
        block_timestamp: u64,
        tx_hash: SigilHash,
        gas_limit: u64,
    ) -> Self;

Source line: 67.

context::ExecutionContext::with_gas_costs

Create a new execution context with custom gas costs.

pub fn with_gas_costs(mut self, costs: GasCosts) -> Self;

Source line: 91.

context::ExecutionContext::record_state_change

Record a state change (key-value mutation).

pub fn record_state_change(
        &mut self,
        key: Vec<u8>,
        old_value: Option<Vec<u8>>,
        new_value: Option<Vec<u8>>,
    );

Source line: 97.

context::ExecutionContext::send_message

Send a cross-zone message, charging gas for the operation.

Returns Err(ExecutionError::OutOfGas) if gas is insufficient.

pub fn send_message(
        &mut self,
        target_zone: impl Into<String>,
        payload: Vec<u8>,
        gas_forwarded: u64,
    ) -> Result<(), ExecutionError>;

Source line: 113.

context::ExecutionContext::log

Emit a log entry, charging gas per byte of the message.

Returns Err(ExecutionError::OutOfGas) if gas is insufficient.

pub fn log(
        &mut self,
        level: LogLevel,
        message: impl Into<String>,
    ) -> Result<(), ExecutionError>;

Source line: 146.

context::ExecutionContext::finalize

Finalize the execution context into an [ExecutionResult].

If error is Some, the result is marked as failed.

pub fn finalize(self, return_value: Option<Vec<u8>>, error: Option<String>) -> ExecutionResult;

Source line: 170.

context::ExecutionContext::gas_remaining

Returns the remaining gas budget.

pub fn gas_remaining(&self) -> u64;

Source line: 186.

context::ExecutionContext::gas_used

Returns the gas consumed so far.

pub fn gas_used(&self) -> u64;

Source line: 191.

On this page