Skip to content

substrate replay builds a zero-value ReplayConfig and there is no config section to populate it #880

Closed

Description

@scttfrdmn

substrate replay builds its engine with a zero-value ReplayConfig, and there is no way for a user to change that: Config has no Replay field and there is no ReplayCfg type, so nothing in substrate.yaml reaches the replay engine.

Split out of #855, whose AC 4 asked for ReplayConfig to be "populated from config rather than being the zero value, at least for ValidateState and StopOnError". That is a new config section, not wiring — it pulls in DefaultConfig, Validate, docs/, and the substrate.yaml example — so #855 ships the wiring and the Load, and this issue adds the section. The correction is recorded at #855's premise-review comment.

What exists today

ReplayConfig (emulator/replay.go) carries the fields that decide what a replay actually checks — ValidateState and StopOnError among them. newReplayCmd passes substrate.ReplayConfig{}, so every field takes its zero value. Notably ValidateState: false means the state hash comparison — the thing that turns "re-executed 100 events" into "re-executed 100 events and reached the same state" — is off by default and cannot be switched on from the CLI at all.

The pattern to follow is any of the existing sections: EventStoreCfg with its ToEventStoreConfig() converter, CostsCfg with ToCostConfig(). Each is a mapstructure-tagged struct on Config, defaulted in DefaultConfig, checked in Validate, and documented.

Acceptance criteria

  • A ReplayCfg type with mapstructure tags, a Replay ReplayCfg field on Config, and a ToReplayConfig() converter, following EventStoreCfg/CostsCfg.
  • Defaults set in DefaultConfig, with the choice of default for ValidateState stated in a comment — leaving it off is defensible, but it must be a decision rather than a zero value.
  • Any enumerated or bounded field checked in Validate, with the same error style as the existing sections (state.backend %q is not valid; choose …).
  • newReplayCmd passes cfg.Replay.ToReplayConfig().
  • The section documented and added to the substrate.yaml example, so --config is discoverable for replay rather than honoured only for the event store and the log format.
  • A test that a config file setting validate_state: true produces a replay that reports StateValid/StateErrors meaningfully, and one that the defaults round-trip.

Activity

  1. added
    type: bug
    on Sep 15, 2026
  2. added this to the v0.117.0 milestone on Sep 15, 2026
  3. scttfrdmn commented on Sep 15, 2026

    @scttfrdmn
    OwnerAuthor

    Premise review (before implementing)

    Every claim in the body checks out against main (5a16569):

    • newReplayCmd's wiring did build substrate.ReplayConfig{} — cmd/substrate/main.go, in newReplayEngineWiring as extracted by substrate replay wires an empty registry, a nil state manager, and never loads the events #855.
    • Config had no Replay field and there was no ReplayCfg type; nothing in substrate.yaml reached the replay engine.
    • All five ReplayConfig fields are genuinely read by ReplayEngine, so none of them is a knob the engine ignores. That was worth checking before exposing them: RandomSeed reaches RandFloat64/RandInt64 on the engine's source, and those two methods have no non-test callers today, so the seed is honoured but currently observable only through them. The section documents that rather than implying plugin-level determinism it does not yet deliver.

    Two notes on how the ACs were met, both narrower or wider than the wording:

    • "Any enumerated or bounded field checked in Validate" — ReplayCfg has no enumerated field. The only bounded one is speed_multiplier, which Validate now refuses below zero (replay.speed_multiplier %g is out of range; must be >= 0, and 0 replays instantly). The four booleans and the seed are unbounded, so nothing else is checked; validating them would have been theatre.
    • AC 6 turned up a second defect. Asserting that a configured validate_state: true "reports StateValid/StateErrors meaningfully" is not satisfiable as written, because ReplayResults.StateErrors was documented to carry "descriptions of any state hash mismatches" and was never appended to — a mismatch flipped StateValid to false and left the slice empty, so the CLI could report a failure it could not describe. Both comparison sites now append a description. Beyond that, the summary reported valid for a stream carrying no recorded state hashes at all, which is the same class of wrong answer this issue is about: with event_store.include_state_hashes off there is nothing to compare, and the summary now says so instead of passing.

    Defaults are all the previous zero values, deliberately: this section makes the existing behaviour configurable rather than changing it, and cfg.Replay.ToReplayConfig() on a default config is asserted equal to substrate.ReplayConfig{} so that stays true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions