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

39 lines
1.7 KiB
Markdown
Raw Normal View History

2019-04-12 12:30:19 +00:00
# Test format: shuffling
2019-05-06 15:30:32 +00:00
The runner of the Shuffling test type has only one handler: `core`.
2019-04-12 12:30:19 +00:00
2019-05-06 15:30:32 +00:00
However, this does not mean that testing is limited.
2019-04-12 12:30:19 +00:00
Clients may take different approaches to shuffling, for optimizing,
and supporting advanced lookup behavior back in older history.
For implementers, possible test runners implementing testing can include:
2019-07-30 13:06:15 +00:00
1) Just test permute-index, run it for each index `i` in `range(count)`, and check against expected `mapping[i]` (default spec implementation).
2019-05-06 15:30:32 +00:00
2) Test un-permute-index (the reverse lookup; implemented by running the shuffling rounds in reverse, from `round_count-1` to `0`).
3) Test the optimized complete shuffle, where all indices are shuffled at once; test output in one go.
4) Test complete shuffle in reverse (reverse rounds, same as #2).
2019-04-12 12:30:19 +00:00
## Test case format
2019-07-30 13:06:15 +00:00
### `mapping.yaml`
2019-04-12 12:30:19 +00:00
```yaml
seed: bytes32
count: int
2019-07-30 13:06:15 +00:00
mapping: List[int]
2019-04-12 12:30:19 +00:00
```
- The `bytes32` is encoded as a string, hexadecimal encoding, prefixed with `0x`.
2019-04-12 12:30:19 +00:00
- Integers are validator indices. These are `uint64`, but realistically they are not as big.
The `count` specifies the validator registry size. One should compute the shuffling for indices `0, 1, 2, 3, ..., count (exclusive)`.
2019-07-30 13:06:15 +00:00
The `seed` is the raw shuffling seed, passed to permute-index (or optimized shuffling approach).
2019-04-12 12:30:19 +00:00
2019-07-30 13:06:15 +00:00
The `mapping` is a look up array, constructed as `[spec.compute_shuffled_index(i, count, seed) for i in range(count)]`
I.e. `mapping[i]` is the shuffled location of `i`.
2019-07-30 13:06:15 +00:00
## Condition
2019-04-12 12:30:19 +00:00
2019-07-30 13:06:15 +00:00
The resulting list should match the expected output after shuffling the implied input, using the given `seed`.
The output is checked using the `mapping`, based on the shuffling test type (e.g. can be backwards shuffling).