Skip to main content

DeterministicVM

Trait DeterministicVM 

Source
pub trait DeterministicVM {
    // Required methods
    fn execute(
        &self,
        bytecode: &[u8],
        inputs: VMInputs,
        signatures: &[Vec<u8>],
    ) -> Result<VMOutputs, VMError>;
    fn validate_outputs(
        &self,
        inputs: &VMInputs,
        outputs: &VMOutputs,
    ) -> Result<(), VMError>;
}
Expand description

The DeterministicVM trait defines the interface for CSV contract execution.

Any VM implementing this trait must guarantee:

  • The same bytecode + inputs always produce the same outputs
  • No access to external state (time, network, random, etc.)
  • Bounded execution (no infinite loops)

Required Methods§

Source

fn execute( &self, bytecode: &[u8], inputs: VMInputs, signatures: &[Vec<u8>], ) -> Result<VMOutputs, VMError>

Execute a transition’s bytecode with the given inputs.

§Arguments
  • bytecode - The validation script (e.g., AluVM bytecode)
  • inputs - The input state being consumed
  • signatures - Authorizing signatures
§Returns

The output state produced by execution.

Source

fn validate_outputs( &self, inputs: &VMInputs, outputs: &VMOutputs, ) -> Result<(), VMError>

Validate that outputs are consistent with the schema.

This is called after execution to ensure the VM hasn’t produced invalid state (e.g., negative supply, undefined type IDs).

Implementors§