You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
substrate replay builds a zero-value ReplayConfig and there is no config section to populate it #880
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.
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.
Activity
scttfrdmn commentedon Sep 15, 2026
Premise review (before implementing)
Every claim in the body checks out against
main(5a16569):newReplayCmd's wiring did buildsubstrate.ReplayConfig{}—cmd/substrate/main.go, innewReplayEngineWiringas extracted by substrate replay wires an empty registry, a nil state manager, and never loads the events #855.Confighad noReplayfield and there was noReplayCfgtype; nothing insubstrate.yamlreached the replay engine.ReplayConfigfields are genuinely read byReplayEngine, so none of them is a knob the engine ignores. That was worth checking before exposing them:RandomSeedreachesRandFloat64/RandInt64on 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:
Validate" —ReplayCfghas no enumerated field. The only bounded one isspeed_multiplier, whichValidatenow 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.validate_state: true"reportsStateValid/StateErrorsmeaningfully" is not satisfiable as written, becauseReplayResults.StateErrorswas documented to carry "descriptions of any state hash mismatches" and was never appended to — a mismatch flippedStateValidto 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 reportedvalidfor a stream carrying no recorded state hashes at all, which is the same class of wrong answer this issue is about: withevent_store.include_state_hashesoff 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 tosubstrate.ReplayConfig{}so that stays true.feat(config): a replay: section, and state: decides the state manager