Repository navigation
Description
ReplayEngine.resetState (emulator/replay.go:656-664) resets the StateManager and nothing else. Plugins hold their own mutable counters, and PluginRegistry (emulator/types.go:334-365) is a sync.RWMutex plus a map[string]Plugin with no reset hook — so a second replay in one process starts from the first replay's counter values and produces different identifiers for the same recorded events.
The counters that survive a reset
S3Plugin.versionSeq—emulator/s3_plugin.go:927and:1200(version IDs)SESV2Plugin.msgSeq—emulator/sesv2_plugin.go:20(MessageId)
Both are atomic.Int64 fields on the plugin struct. resetState cannot reach them, and nothing else tries.
Why it matters beyond tidiness
resetState exists so a replay begins from the recorded run's starting point. It does that for state and not for the plugins, so:
- replay stream X, then replay stream X again in the same process → the second run mints different version IDs and
MessageIds than the first, from identical input; - and the CLI now runs a real registry (substrate replay wires an empty registry, a nil state manager, and never loads the events #855), so this is reachable from
substrate replayrather than only from a test that constructs an engine.
A replay whose output depends on how many replays preceded it is the one property the event log exists to rule out.
This is a hard sub-task of #856
#856 proposes making the ~66 minters deterministic. Whichever option it takes, the two atomic counters come under it, and a counter is only reproducible if something resets it between runs. So a lifecycle hook is a prerequisite of #856's full seam, not an optional extra — and it is separable from the question of how the other minters derive their values, which is why it is filed on its own.
Acceptance criteria
-
PluginRegistrygains a way to signal "reset to a run's starting point" to every registered plugin — an optional interface a plugin may implement (so the 40-odd plugins that hold no state need no change) rather than a method onPlugin, unless there is a reason to force all of them. -
resetStatecalls it, and its doc comment stops implying theStateManageris the whole of a plugin's mutable state. -
S3PluginandSESV2Pluginimplement it, resettingversionSeqandmsgSeq. - A test that replays one recorded stream twice in one process and asserts the two runs produce identical minted values. This is the assertion that fails today; assert on the values, not just that both runs succeeded.
- An audit recorded on the issue of any other plugin-held mutable field, so the hook's implementers are a known set rather than the two found here.
grepforatomic.and for non-config struct fields on plugin types.
Found while scoping #856 for the v0.116.0 cut; the CLI wiring in #855 made it reachable from the command line.
Activity
fix(plugins): every default registration carries the simulated clock (#…
fix(reset): release what a plugin started, not only what it minted (#902