Skip to content

Commit

Permalink
remove lookup table
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviasaa committed Mar 18, 2024
1 parent 237e175 commit 9a64af2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tips/TIP-0039/tip-0039.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,17 @@ point arithmetics (which do not expose the nodes to these rounding divergencies)
require exact consensus over values. In particular, all the Mana and rewards calculations have to be done with fixed
point arithmetics.

In the [lookup table](#lookup-table) section of this TIP, a lookup table is introduced that will be used in the rest of
this TIP, as a tool to perform calculations that would otherwise be done with floating point operations.
### Lookup Table

The derivation of the `Mana Parameters::Decay Factors` protocol parameter, also referred to as the _lookup table_ is
described in the present section. This parameter must be calculated exactly once for a network's protocol parameters
to avoid differences in floating point operations on different machines. This Table is provided in the snapshot files;
thus, its definition is explained here just for the sake of clarification. The values on the table **must not** be calculated locally in the node or any application to avoid inconsistencies in the calculations.

The lookup table is an integer approximation of <code>2<sup>Decay Factors Exponent</sup>Decay per
Epoch<sup>n</sup></code>, for different values of `n` ranging from 1 to `Decay Factors Length`.
To obtain the decayed value of a certain amont of Mana `M` after `n` epochs has been passed, one should multiply
`M` by the entry of `Mana Parameters::Decay Factors` relative to `n` and then execute a right shift of `Decay Factors Exponent` bits.

### Decay Function

Expand Down Expand Up @@ -435,15 +444,6 @@ A transaction is only valid if either of the following conditions holds:
It is highly recommended to use overflow checks for arithmetic operations when calculating Mana balances to avoid over-
and underflows.

## Lookup Table

The derivation of the `Mana Parameters::Decay Factors` protocol parameter, also referred to as the _lookup table_ is
described in the following section. This parameter must be calculated exactly once for a network's protocol parameters
to avoid differences in floating point operations on different machines.

This lookup table is an integer approximation of <code>2<sup>Decay Factors Exponent</sup>Decay per
Epoch<sup>n</sup></code>, for different values of `n` ranging from 1 to `Decay Factors Length`.

# Test Vectors

The protocol parameters used in the following test vectors are the same as in
Expand Down

0 comments on commit 9a64af2

Please sign in to comment.