Struct round_based::dev::Simulation[][src]

pub struct Simulation<P> {
    pub parties: Vec<P>,
    // some fields omitted
}
This is supported on crate feature dev only.
Expand description

Emulates running protocol between local parties

Takes parties (every party is instance of StateMachine) and executes protocol between them. It logs whole process (changing state of party, receiving messages, etc.) in stdout.

Compared to AsyncSimulation, it’s lightweight (doesn’t require async runtime), and, more importantly, executes everything in straight order (sequently, without any parallelism). It makes this sumaltion more useful for writing benchmarks that detect performance regression.

Limitations

  • No proper error handling. It should attach a context to returning error (like current round, what we was doing when error occurred, etc.). The only way to determine error context is to look at stdout and find out what happened from logs.
  • Logs everything to stdout. No choice.

Example

let results = Simulation::new()
    .add_party(Party::new(1, 3))    
    .add_party(Party::new(2, 3))    
    .add_party(Party::new(3, 3))
    .run()?;   
assert!(results.into_iter().all(|r| is_valid(&r)));

Fields

parties: Vec<P>

Parties running a protocol

Field is exposed mainly to allow examining parties state after simulation is completed.

Implementations

Creates new simulation

Adds protocol participant

Enables benchmarks so they can be retrieved after simulation is completed

Returns benchmark results if they were enabled

Benchmarks show how much time (in average) proceed method takes for proceeding particular rounds. Benchmarks might help to find out which rounds are cheap to proceed, and which of them are expensive to compute.

Runs a simulation

Returns

Returns either Vec of protocol outputs (one output for each one party) or first occurred critical error.

Panics

  • Number of parties is less than 2

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.