Expand description
A deterministic runtime that randomly selects tasks to run based on a seed
§Panics
Unless configured otherwise, any task panic will lead to a runtime panic.
§External Processes
When testing an application that interacts with some external process, it can appear to the runtime that progress has stalled because no pending tasks can make progress and/or that futures resolve at variable latency (which in turn triggers non-deterministic execution).
To support such applications, the runtime can be built with the external feature to both
sleep for each Config::cycle (opting to wait if all futures are pending) and to constrain
the resolution latency of any future (with pace()).
Applications that do not interact with external processes (or are able to mock them) should never need to enable this feature. It is commonly used when testing consensus with external execution environments that use their own runtime (but are deterministic over some set of inputs).
§Example
use commonware_runtime::{Spawner, Runner, deterministic, Metrics};
let executor = deterministic::Runner::default();
executor.start(|context| async move {
println!("Parent started");
let result = context.with_label("child").spawn(|_| async move {
println!("Child started");
"hello"
});
println!("Child result: {:?}", result.await);
println!("Parent exited");
println!("Auditor state: {}", context.auditor().state());
});Structs§
- Auditor
- Track the state of the runtime for determinism auditing.
- Checkpoint
- An artifact that can be used to recover the state of the runtime.
- Config
- Configuration for the
deterministicruntime. - Context
- Implementation of crate::Spawner, crate::Clock,
crate::Network, and crate::Storage for the
deterministicruntime. - Executor
- Deterministic runtime that randomly selects tasks to run based on a seed.
- Runner
- Implementation of crate::Runner for the
deterministicruntime.