forked from ethereum/consensus-specs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ethereum#1130 from ethereum/v06x
Release V06x into master
- Loading branch information
Showing
81 changed files
with
2,901 additions
and
2,207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Epoch processing tests | ||
|
||
The different epoch sub-transitions are tested individually with test handlers. | ||
The format is similar to block-processing state-transition tests. | ||
There is no "change" factor however, the transitions are pure functions with just the pre-state as input. | ||
Hence, the format is shared between each test-handler. (See test condition documentation on how to run the tests.) | ||
|
||
## Test case format | ||
|
||
```yaml | ||
description: string -- description of test case, purely for debugging purposes | ||
bls_setting: int -- see general test-format spec. | ||
pre: BeaconState -- state before running the sub-transition | ||
post: BeaconState -- state after applying the epoch sub-transition. | ||
``` | ||
## Condition | ||
A handler of the `epoch_processing` test-runner should process these cases, | ||
calling the corresponding processing implementation. | ||
|
||
Sub-transitions: | ||
|
||
| *`sub-transition-name`* | *`processing call`* | | ||
|-------------------------|-----------------------------------| | ||
| `crosslinks` | `process_crosslinks(state)` | | ||
| `registry_updates` | `process_registry_updates(state)` | | ||
|
||
The resulting state should match the expected `post` state. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Sanity tests | ||
|
||
The aim of the sanity tests is to set a base-line on what really needs to pass, i.e. the essentials. | ||
|
||
There are two handlers, documented individually: | ||
- [`slots`](./slots.md): transitions of one or more slots (and epoch transitions within) | ||
- [`blocks`](./blocks.md): transitions triggered by one or more blocks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Sanity blocks testing | ||
|
||
Sanity tests to cover a series of one or more blocks being processed, aiming to cover common changes. | ||
|
||
## Test case format | ||
|
||
```yaml | ||
description: string -- description of test case, purely for debugging purposes | ||
bls_setting: int -- see general test-format spec. | ||
pre: BeaconState -- state before running through the transitions triggered by the blocks. | ||
blocks: [BeaconBlock] -- blocks to process, in given order, following the main transition function (i.e. process slot and epoch transitions in between blocks as normal) | ||
post: BeaconState -- state after applying all the transitions triggered by the blocks. | ||
``` | ||
## Condition | ||
The resulting state should match the expected `post` state, or if the `post` state is left blank, | ||
the handler should reject the series of blocks as invalid. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Sanity slots testing | ||
|
||
Sanity tests to cover a series of one or more empty-slot transitions being processed, aiming to cover common changes. | ||
|
||
## Test case format | ||
|
||
```yaml | ||
description: string -- description of test case, purely for debugging purposes | ||
bls_setting: int -- see general test-format spec. | ||
pre: BeaconState -- state before running through the transitions. | ||
slots: N -- amount of slots to process, N being a positive numer. | ||
post: BeaconState -- state after applying all the transitions. | ||
``` | ||
The transition with pure time, no blocks, is known as `state_transition_to(state, slot)` in the spec. | ||
This runs state-caching (pure slot transition) and epoch processing (every E slots). | ||
|
||
To process the data, call `state_transition_to(pre, pre.slot + N)`. And see if `pre` mutated into the equivalent of `post`. | ||
|
||
|
||
## Condition | ||
|
||
The resulting state should match the expected `post` state. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
py-ecc==1.6.0 | ||
eth-utils==1.4.1 | ||
py-ecc==1.7.0 | ||
eth-utils==1.6.0 | ||
../../test_libs/gen_helpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Epoch processing | ||
|
||
Epoch processing covers the sub-transitions during an epoch change. | ||
|
||
An epoch-processing test-runner can consume these sub-transition test-suites, | ||
and handle different kinds of epoch sub-transitions by processing the cases using the specified test handler. | ||
|
||
Information on the format of the tests can be found in the [epoch-processing test formats documentation](../../specs/test_formats/epoch_processing/README.md). | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import Callable, Iterable | ||
|
||
from eth2spec.phase0 import spec | ||
from eth2spec.test.epoch_processing import ( | ||
test_process_crosslinks, | ||
test_process_registry_updates | ||
) | ||
from gen_base import gen_runner, gen_suite, gen_typing | ||
from gen_from_tests.gen import generate_from_tests | ||
from preset_loader import loader | ||
|
||
|
||
def create_suite(transition_name: str, config_name: str, get_cases: Callable[[], Iterable[gen_typing.TestCase]]) \ | ||
-> Callable[[str], gen_typing.TestSuiteOutput]: | ||
def suite_definition(configs_path: str) -> gen_typing.TestSuiteOutput: | ||
presets = loader.load_presets(configs_path, config_name) | ||
spec.apply_constants_preset(presets) | ||
|
||
return ("%s_%s" % (transition_name, config_name), transition_name, gen_suite.render_suite( | ||
title="%s epoch processing" % transition_name, | ||
summary="Test suite for %s type epoch processing" % transition_name, | ||
forks_timeline="testing", | ||
forks=["phase0"], | ||
config=config_name, | ||
runner="epoch_processing", | ||
handler=transition_name, | ||
test_cases=get_cases())) | ||
|
||
return suite_definition | ||
|
||
|
||
if __name__ == "__main__": | ||
gen_runner.run_generator("epoch_processing", [ | ||
create_suite('crosslinks', 'minimal', lambda: generate_from_tests(test_process_crosslinks)), | ||
create_suite('crosslinks', 'mainnet', lambda: generate_from_tests(test_process_crosslinks)), | ||
create_suite('registry_updates', 'minimal', lambda: generate_from_tests(test_process_registry_updates)), | ||
create_suite('registry_updates', 'mainnet', lambda: generate_from_tests(test_process_registry_updates)), | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
eth-utils==1.6.0 | ||
../../test_libs/gen_helpers | ||
../../test_libs/config_helpers | ||
../../test_libs/pyspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.