Skip to content

Commit

Permalink
Add sanity checks for protocol params
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Feb 14, 2024
1 parent 336d398 commit d0e38ca
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tips/TIP-0049/tip-0049.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ other nodes and to process blocks properly.
</tr>
</table>

When referring to Protocol Parameters contained in subschemas in other TIPs, one may use namespacing with a `::`
separator for disambiguation. For instance, `Work Score Parameters::Block` refers to the `Block` parameter inside the
`Work Score Parameters`.

## Protocol Parameters Hash

The Protocol Parameters Hash is used in signaling protocol parameters upgrades and is a field in the Validation Block.
Expand All @@ -483,6 +487,42 @@ The Protocol Parameters Hash is computed as follows:
- Let `Protocol Parameters Bytes` be the serialized protocol parameters.
- Let the protocol parameters hash be the BLAKE2b-256 hash over `Protocol Parameters Bytes`.

## Sanity Checks

The Protocol Parameters do not have strict syntactic validation, but _sanity checks_ instead. These codify the
assumptions about how certain parameters are intended to work together.

Because these checks do not have to be run upon serialization or deserialization and the checks are only _recommended_
to be implemented, the wording is _should_ rather than _must_, in line with the language proposed by
[RFC 2119](https://www.rfc-editor.org/rfc/rfc2119).

- `Mana Parameters` checks:
- The `Maximum Mana Supply` should not be greater or equal to <code>2<sup>Bits Count</sup></code>, where the former is
defined as:
- Let `Beta` be <code>-Log<sub>n</sub>(Annual Decay Factor Percentage)</code>.
- Let `Epoch Duration In Years` be <code>Slot Duration in Seconds * 2<sup>Slots Per Epoch Exponent</sup> / (365 *
24 * 60 * 60)</code>.
- Let `Maximum Mana Supply` be <code>21 * Token Supply * Generation Rate * 2<sup>Slots Per Epoch Exponent -
Generation Rate Exponent</sup> / (Beta * Epoch Duration In Years)</code>.
- `Decay Factor Epochs Sum * uint32(Generation Rate)` should not overflow a `uint32`.
- Time checks:
- `Liveness Threshold Lower Bound In Seconds` should be less than or equal to
`Liveness Threshold Upper Bound In Seconds`.
- `Liveness Threshold Upper Bound In Seconds` should be strictly less than
`Min Committable Age * Slot Duration In Seconds`.
- `Min Committable Age` should be strictly less than `Max Committable Age`.
- `Max Committable Age` should be strictly less than `Epoch Nearing Threshold`.
- `Epoch Duration In Slots` should be strictly greater than `Epoch Nearing Threshold`, where:
- `Epoch Duration In Slots` is <code>2<sup>Slots Per Epoch Exponent</sup></code>.
- `Congestion Control Parameters` checks:
- `Increase Threshold` should be less than or equal to `Scheduler Rate * Slot Duration In Seconds`.
- `Decrease Threshold` should be less than or equal to `Scheduler Rate * Slot Duration In Seconds`.
- `Decrease Threshold` should be less than or equal to `Increase Threshold`.
- `Rewards Parameters` checks:
- `Token Supply Bits Count + Pool Coefficient Exponent` should be less than or equal to `64`, where:
- `Token Supply Bits Count` is <code>uint8(Log<sub>2</sub>(Token Supply)) + 1</code>.
- `Validation Blocks Per Slot` should be less than or equal to `32`.

# Test Vectors

## Protocol Parameters Hash
Expand Down

0 comments on commit d0e38ca

Please sign in to comment.