Open getzdan opened 8 years ago
good catch!
I believe maintaining an RNG state is similar to maintaining any kind of state. I think a global counter would be better here than random numbers to give ids to the signals.
yeah, a counter would do the trick (non-repeating nonces). the only considerations I could come up with about it are:
but these are mainly non-issues.
Signals between the browser and Julia in Escher use nonce values which are randomly generated (i.e.
239286640159958284960877608660596719563
) usingstring(rand(UInt128))
. Therand
function uses the global scope Julia RNG state which means if a different part of the system plays withsrand(...)
it could generate repeating nonce-s which would mess things up.This is not a theoretical issue, as it was discovered in a real program which failed mysteriously. A small example could be:
In the example,
button 1
fails to operate after a couple of clicks onbutton 2
because a nonce generated for the third button interferes with it.Not sure what is the right way to approach this. An internal RNG state for Escher seems needed. But to initialize it, I can see 3 alternatives, which could co-exist and be specified using parameters:
Additionally, it might be possible to allow playing with RNG state using sanctioned methods instead of Julia allowed internal tinkering.