Sigil documentation
ReferenceRust referencesigil-consensus

sigil-consensus · semantic

Source declarations, signatures and documentation for semantic.

Source: sigil/node/sigil-consensus/src/semantic.rs. SHA-256: b0ecc4ada3f75fdc6082d3ddfb716d9cc8e60714dfe828e85401d096da006b85.

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.

semantic::SemanticValidationError

Error type for semantic validation failures.

#[derive(Debug, Clone, thiserror::Error)]
pub enum SemanticValidationError {
    /// The transaction type does not match what this module handles.
    #[error("wrong transaction category: expected {expected:?}, got {actual:?}")]
    WrongCategory {
        expected: TransactionCategory,
        actual: TransactionCategory,
    },

    /// A domain-specific validation rule was violated.
    #[error("validation failed: {0}")]
    ValidationFailed(String),

    /// The validator module encountered an internal error.
    #[error("internal error: {0}")]
    InternalError(String),
}

Source line: 15.

semantic::SemanticValidator

A semantic validation module that checks domain-specific rules on transactions.

Each module handles a specific transaction category and applies rules that go beyond structural validation (e.g., lineage checks for identity transactions, bond verification for MARS transactions).

pub trait SemanticValidator: Send + Sync {
    /// Returns the human-readable name of this validator module.
    fn name(&self) -> &str;

    /// Returns the transaction category this module handles.
    fn category(&self) -> TransactionCategory;

    /// Validate a signed transaction against domain-specific rules.
    ///
    /// Returns `Ok(())` if the transaction passes validation, or a
    /// `SemanticValidationError` describing why it was rejected.
    fn validate(&self, tx: &SignedTransaction) -> Result<(), SemanticValidationError>;
}

Source line: 37.

semantic::SemanticValidatorRegistry

Registry that routes transactions to the appropriate semantic validator modules.

pub struct SemanticValidatorRegistry {

}

Source line: 52.

semantic::SemanticValidatorRegistry::new

Create a new empty registry.

pub fn new() -> Self;

Source line: 58.

semantic::SemanticValidatorRegistry::with_defaults

Create a registry pre-populated with validators that enforce at least state-independent production checks. Unsupported categories fail closed.

pub fn with_defaults() -> Self;

Source line: 66.

semantic::SemanticValidatorRegistry::with_economics_state

Create a default registry with economics checks backed by live state.

Consensus/node production paths should prefer this constructor whenever an execution-state snapshot is available; the plain default registry keeps economics fail-closed because balance and nonce checks require state access.

pub fn with_economics_state(state: Arc<dyn EconomicsState>) -> Self;

Source line: 88.

semantic::SemanticValidatorRegistry::register

Register a new semantic validator module.

pub fn register(&mut self, validator: Box<dyn SemanticValidator>);

Source line: 105.

semantic::SemanticValidatorRegistry::validate

Validate a transaction by routing it to all matching validator modules.

A module matches if its category equals the transaction's category. All matching modules must pass for the transaction to be considered valid.

pub fn validate(&self, tx: &SignedTransaction) -> Result<(), ConsensusError>;

Source line: 118.

semantic::SemanticValidatorRegistry::has_validator_for_category

Returns true if this registry has at least one validator for category.

pub fn has_validator_for_category(&self, category: TransactionCategory) -> bool;

Source line: 145.

semantic::SemanticValidatorRegistry::len

Returns the number of registered validator modules.

pub fn len(&self) -> usize;

Source line: 150.

semantic::SemanticValidatorRegistry::is_empty

Returns true if no validator modules are registered.

pub fn is_empty(&self) -> bool;

Source line: 155.

semantic::SemanticValidatorRegistry::module_names

Returns the names of all registered modules.

pub fn module_names(&self) -> Vec<&str>;

Source line: 160.

semantic::OasVerifyModule

Validates OAS identity transactions (lineage checks, DID format, etc.).

pub struct OasVerifyModule;

Source line: 194.

semantic::AttestationVerifyModule

Validates attestation and verifiable credential transactions.

pub struct AttestationVerifyModule;

Source line: 281.

semantic::GovernanceVerifyModule

Validates governance proposals and votes.

pub struct GovernanceVerifyModule;

Source line: 310.

semantic::EconomicsState

Trait for balance/nonce state lookups needed by economics validation.

pub trait EconomicsState: Send + Sync {
    fn get_balance(&self, did: &str) -> Result<u64, String>;
    fn get_nonce(&self, did: &str) -> Result<u64, String>;
}

Source line: 366.

semantic::EconomicsVerifyModule

Validates staking, unstaking, delegation, and reward transactions.

pub struct EconomicsVerifyModule {

}

Source line: 372.

semantic::EconomicsVerifyModule::new

Create with no state. State-independent checks still run, but state-dependent economics admission fails closed.

pub fn new() -> Self;

Source line: 385.

semantic::EconomicsVerifyModule::with_state

Create with a state backend for real validation.

pub fn with_state(state: Arc<dyn EconomicsState>) -> Self;

Source line: 390.

semantic::MarsVerifyModule

Validates MARS registry anchoring transactions.

pub struct MarsVerifyModule;

Source line: 531.

semantic::GalVerifyModule

Validates typed Global Anchor Layer transactions.

#[cfg(feature = "tower")]
pub struct GalVerifyModule;

Source line: 590.

semantic::ComputeVerifyModule

Validates compute marketplace transactions (feature-gated).

State-independent rules only — provider existence, escrow balance, and double-settle prevention live in the executor.

#[cfg(feature = "compute")]
pub struct ComputeVerifyModule;

Source line: 817.

semantic::VigilsVerifyModule

Validates Vigils transactions for state-independent consensus invariants.

State-dependent checks (subscription existence, replay protection, gas tank solvency, source activation, callback scheduling, and cryptographic proof verification) live in the executor because they require the block-height and execution-state snapshot.

pub struct VigilsVerifyModule;

Source line: 1247.

semantic::ContractsVerifyModule

Validates DeployContract, CallContract, UpgradeContract, and SetContractPolicy for state-independent properties only. State-dependent checks (controller authorization, code-blob presence, zone status, mandate / budget) live in the executor.

#[cfg(feature = "contracts")]
pub struct ContractsVerifyModule;

Source line: 1426.

semantic::ContractsVerifyModule::MAX_CALL_ARGS_BYTES

Maximum size of a single CallContract args JSON value, in bytes. Hard limit — large inputs go through cross-zone messaging.

#[cfg(feature = "contracts")]
pub const MAX_CALL_ARGS_BYTES: usize;

Source line: 1432.

semantic::ContractsVerifyModule::MAX_FUNCTION_NAME_LEN

Maximum length of a contract function name.

#[cfg(feature = "contracts")]
pub const MAX_FUNCTION_NAME_LEN: usize;

Source line: 1434.

semantic::ContractsVerifyModule::MAX_GAS_BUDGET

Hard upper bound on per-call gas budget (also bounded by tx gas_limit upstream).

#[cfg(feature = "contracts")]
pub const MAX_GAS_BUDGET: u64;

Source line: 1437.

On this page