duneanalytics / dune-client

A framework for interacting with Dune Analytics' officially supported API service
Apache License 2.0
85 stars 22 forks source link

Query Hash is not deterministic! #32

Open bh2smith opened 1 year ago

bh2smith commented 1 year ago

between different runs, the hash function uses different seeds. So just be aware that it is deterministic in a single run, but not between different executions.

https://github.com/cowprotocol/dune-client/blob/55d5f92f5436ad5b4fc18d7c050a01f463fce017/dune_client/query.py#L37-L42

TODO

  1. Document this and
  2. offer a deterministic hash function as well
eliseygusev commented 1 year ago

I think, this can get fixed by setting PYTHONHASHSEED to a particular value (can be moved to config or something) https://docs.python.org/3/using/cmdline.html#envvar-PYTHONHASHSEED

bh2smith commented 1 year ago

That's cool! Although I've also been reading that we should not rely on object hashes to be deterministic and that it's better to use a real hash function from hash lib. I've settled it in the meantime external to this package so this isn't urgent by any means, but feel free to go for it if you like!