tradecraftio / tradecraft

Tradecraft integration/staging tree https://tradecraft.io/download
Other
13 stars 9 forks source link

Create integer math function for epoch value calculation (reverse demurrage) #17

Open maaku opened 5 years ago

maaku commented 5 years ago

When we went from software floating point to integer math for demurrage calculations, the code was written to only support calculation of future value corresponding to higher reference heights. Since reference heights are monotonically increasing, this is the only calculation which freicoin as-is requires. However tradecraft will permit epoch-based values within its confidential transactions implementation, and converting between the two will require moving values from a positive refheight to the zero-refheight epoch. Therefore an inverse-demurrage integer-math function needs to be implemented.

When the integer-math demurrage was implemented, it was specifically designed to round down so that no input would result in a greater value than the more precise floating-point calculation would have provided. This was to prevent a hard-fork due to its usage in transaction fee calculation. However this restriction does not exist for conversion into and out of the confidential transactions domain, so perhaps two new functions are required, with zero bias.

maaku commented 5 years ago

This is implemented in the work in progress rebase-0.10 branch. There are insufficient unit tests however, so I’m leaving this ticket open to track that.