Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The simulation environment

An Environment bundles everything a simulation runs against (spec section 4):

Environment
  +-- network/protocol/token/ledger/randomness configuration
  +-- the deterministic state store
  +-- the seeded deterministic RNG
  +-- the current ledger context

Constructing an environment from a Configuration is a pure operation: the store starts empty, the RNG is seeded from the configuration, and the ledger starts at the configured sequence and timestamp. Two environments built from the same configuration are indistinguishable.

Configuration

Configuration is fully serializable and holds:

  • network — local (default) or testnet target;
  • protocol — step seconds the synthetic ledger advances by;
  • ledger — initial sequence and start timestamp;
  • token — default decimals, transferability policy;
  • account — default registration requirements;
  • randomness — the seed that drives every nonce.

The deterministic story starts here: the seed is the only source of randomness in the system. The environment’s RNG is SplitMix64 seeded from it, and everything random (blinding nonces) is drawn from that stream — never from system entropy.

The environment is a complete, resumable state

Because the environment serializes in full — configuration, store (accounts, commitments, statuses, nullifiers, logs), RNG stream position, and ledger — persisting an environment and reloading it resumes the exact same simulation. The CLI uses this to keep a stateful working directory: every command loads, runs one operation per ledger, and saves back.

Snapshots include the random stream

Environment::snapshot(name) records the RNG position next to the state payload; restore_snapshot(name) rewinds both. Restoring a mid-stream snapshot and rerunning the same operations therefore draws the same nonces and reproduces the identical commitments and final state (spec section 23). See docs/snapshots.md.

Modes

  • Local — the default environment: offline, fast, deterministic.
  • Testnet — described by TestnetConfiguration; execution behind the Soroban adapter boundary (see docs/testnet.md). Local simulation never depends on it.