Search code examples
rustnearprotocol

Which Rust data structures are non deterministic


When writing smart contracts it's important to make sure that all data structures used are deterministic.

Specifically, if HashMap or HashSet are used - is there a possible non determinism coming from Rust standard library?


Solution

  • Since Wasm runtime doesn't have access to non-deterministic inputs, the entire execution is deterministic. HashSet and HashMap use seed from the available source, in case of Wasm compilation there are no available source, the execution will always be the same. It should be easy to confirm.