vegaprotocol / specs

Specs, designs and requirements 🦔
MIT License
7 stars 2 forks source link

Do simple-POS-rewards without any floating point operations #627

Closed davidsiska-vega closed 2 years ago

davidsiska-vega commented 3 years ago

At the moment

https://github.com/vegaprotocol/specs-internal/blob/master/protocol/0058-simple-POS-rewards.md

contains sqrt function which makes no sense for integers, the decimal type we're using doesn't implement it (and mathematically speaking it still won't make sense for a decimal type).

so if we were to implement it we might run into floating point non-determinism. One solution may be to send all the results of the calculation as transactions through consensus but that seems complicated and I probably don't see all the problems this could lead to.

A simpler solution is to replace sqrt with an approximation that can be done entirely with multiplications and additions (think Taylor series expansions). That way we can avoid floating point operations and we can work entirely with a integer / decimal data types.

edd commented 3 years ago

@davidsiska-vega now that we have https://github.com/vegaprotocol/research-internal/blob/master/validator_rewards/val2.go do we want to update the spec to match, or do we want to just close this issue knowing that core will use that as the basis, or what?

davidsiska-vega commented 2 years ago

This is no longer relevant, no square roots there.