2020-05-04 19:20:32 +00:00
|
|
|
# Rewards tests
|
|
|
|
|
2020-05-18 22:00:59 +00:00
|
|
|
All rewards deltas sub-functions are tested for each test case.
|
2020-05-04 19:20:32 +00:00
|
|
|
There is no "change" factor, the rewards/penalties outputs are pure functions with just the pre-state as input.
|
2020-05-18 22:00:59 +00:00
|
|
|
(See test condition documentation on how to run the tests.)
|
|
|
|
|
|
|
|
`Deltas` is defined as:
|
|
|
|
```python
|
|
|
|
class Deltas(Container):
|
|
|
|
rewards: List[uint64, VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
penalties: List[uint64, VALIDATOR_REGISTRY_LIMIT]
|
|
|
|
```
|
2020-05-04 19:20:32 +00:00
|
|
|
|
|
|
|
## Test case format
|
|
|
|
|
|
|
|
### `meta.yaml`
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
description: string -- Optional description of test case, purely for debugging purposes.
|
|
|
|
Tests should use the directory name of the test case as identifier, not the description.
|
|
|
|
```
|
|
|
|
|
2020-05-05 21:37:14 +00:00
|
|
|
_Note_: No signature verification happens within rewards sub-functions. These
|
|
|
|
tests can safely be run with or without BLS enabled.
|
|
|
|
|
2020-05-04 19:20:32 +00:00
|
|
|
### `pre.yaml`
|
|
|
|
|
|
|
|
A YAML-encoded `BeaconState`, the state before running the rewards sub-function.
|
|
|
|
|
|
|
|
Also available as `pre.ssz`.
|
|
|
|
|
2020-05-18 22:00:59 +00:00
|
|
|
### `source_deltas.yaml`
|
2020-05-04 19:20:32 +00:00
|
|
|
|
2020-05-18 22:00:59 +00:00
|
|
|
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_source_deltas` function
|
2020-05-04 19:20:32 +00:00
|
|
|
|
2020-05-18 22:00:59 +00:00
|
|
|
Also available as `source_deltas.ssz`.
|
|
|
|
|
|
|
|
### `target_deltas.yaml`
|
|
|
|
|
|
|
|
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_target_deltas` function
|
|
|
|
|
|
|
|
Also available as `target_deltas.ssz`.
|
|
|
|
|
|
|
|
### `head_deltas.yaml`
|
|
|
|
|
|
|
|
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_head_deltas` function
|
|
|
|
|
|
|
|
Also available as `head_deltas.ssz`.
|
|
|
|
|
|
|
|
### `inclusion_delay_deltas.yaml`
|
|
|
|
|
|
|
|
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_inclusion_delay_deltas` function
|
|
|
|
|
|
|
|
Also available as `inclusion_delay_deltas.ssz`.
|
|
|
|
|
|
|
|
### `inactivity_penalty_deltas.yaml`
|
|
|
|
|
|
|
|
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_inactivity_penalty_deltas` function
|
2020-05-04 19:20:32 +00:00
|
|
|
|
2020-05-18 22:00:59 +00:00
|
|
|
Also available as `inactivity_penalty_deltas.ssz`.
|
2020-05-04 19:20:32 +00:00
|
|
|
|
|
|
|
## Condition
|
|
|
|
|
|
|
|
A handler of the `rewards` test-runner should process these cases,
|
2020-05-18 22:00:59 +00:00
|
|
|
calling the corresponding rewards deltas function for each set of deltas.
|
2020-05-04 19:20:32 +00:00
|
|
|
|
2020-05-18 22:00:59 +00:00
|
|
|
The provided pre-state is ready to be input into each rewards deltas function.
|
2020-05-04 19:20:32 +00:00
|
|
|
|
2020-05-05 21:37:14 +00:00
|
|
|
The provided `deltas` should match the return values of the
|
2020-05-18 22:00:59 +00:00
|
|
|
deltas function. Specifically the following must hold true for each set of deltas:
|
2020-05-04 19:20:32 +00:00
|
|
|
|
|
|
|
```python
|
2020-05-18 22:00:59 +00:00
|
|
|
deltas.rewards == deltas_function(state)[0]
|
|
|
|
deltas.penalties == deltas_function(state)[1]
|
2020-05-04 19:20:32 +00:00
|
|
|
```
|