Question about determinism
I looked into LUAU but couldn't find any information pertaining to this. Does mlua provide a way to interpret a script OP_CODE by OP_CODE?
Example: lets say I wanted to deterministically run lua scripts where I can guarantee the output on any machine, and I assign each opcode a "cost" and have a "max cost" for the script - which all machines respect. How would I go about this with mlua?
I know theres ways to terminate a lua script after x time with LUAU, but even then I cant guarantee determinism because different machines might deviate from how much is actually ran during this window of time.
Thanks in advance!
Luau has debug api (lua_singlestep) that allow to stop execution after each instruction.
mlua does not support yet this api through safe interface, as it's designed for debugging only and the costs would be huge.
Most practical option with low overhead would be using interrupts and stop execution (or yield) if time limit is exceeded. This is supported by mlua. I'm sure that interrupts are run at specific deterministic points that are machine independent.