eth2.0-specs/tests/formats/rewards/README.md

64 lines
2.2 KiB
Markdown
Raw Normal View History

2020-05-04 19:20:32 +00:00
# Rewards tests
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.
(See test condition documentation on how to run the tests.)
`Deltas` is defined as:
```python
class Deltas(Container):
2020-05-19 12:31:28 +00:00
rewards: List[Gwei, VALIDATOR_REGISTRY_LIMIT]
penalties: List[Gwei, 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-10-08 19:02:18 +00:00
### `pre.ssz_snappy`
2020-05-04 19:20:32 +00:00
2020-10-08 19:02:18 +00:00
A SSZ-snappy encoded `BeaconState`, the state before running the rewards sub-function.
2020-05-04 19:20:32 +00:00
2020-10-08 19:02:18 +00:00
### `source_deltas.ssz_snappy`
2020-05-04 19:20:32 +00:00
2020-10-08 19:02:18 +00:00
A SSZ-snappy 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-10-08 19:02:18 +00:00
### `target_deltas.ssz_snappy`
2020-05-04 19:20:32 +00:00
2020-10-08 19:02:18 +00:00
A SSZ-snappy encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_target_deltas` function
2020-10-08 19:02:18 +00:00
### `head_deltas.ssz_snappy`
2020-10-08 19:02:18 +00:00
A SSZ-snappy encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_head_deltas` function
2020-10-08 19:02:18 +00:00
### `inclusion_delay_deltas.ssz_snappy`
2020-10-08 19:02:18 +00:00
A SSZ-snappy encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_inclusion_delay_deltas` function
2020-10-08 19:02:18 +00:00
### `inactivity_penalty_deltas.ssz_snappy`
2020-10-08 19:02:18 +00:00
A SSZ-snappy 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
## Condition
A handler of the `rewards` test-runner should process these cases,
calling the corresponding rewards deltas function for each set of deltas.
2020-05-04 19:20:32 +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
deltas function. Specifically the following must hold true for each set of deltas:
2020-05-04 19:20:32 +00:00
```python
deltas.rewards == deltas_function(state)[0]
deltas.penalties == deltas_function(state)[1]
2020-05-04 19:20:32 +00:00
```