-
Notifications
You must be signed in to change notification settings - Fork 12
Proposed beacon state test format #21
Comments
What's a bit unclear to me is if this type of test is for block processing or for state transitions in general. I think it would be useful to have tests specific for slot and epoch processing that don't contain any blocks, and to have tests for block processing without slot or epoch processing. In addition, full tests make sense as well, to check if slots/blocks/epochs are processed in the right order, but we probably need much fewer of those as most complexity lies in block processing. But for full tests we should specify first and last processed slot and epoch as well. This could be implicitly defined (e.g. we just say the test runner has to process all empty slots between the initial state slot and the block slots, and do potential epoch transitions up until the one directly following the last block). One concern I have is that some of the tests could get unnecessarily verbose. Defaults for block and state fields as you mentioned would help a lot already. In addition to that, Justin proposed reduced constant sets for testing which could shorten the config section. Maybe we can replace
Just a minor side note, but I think we should have at least a few full tests with valid signatures that are checked. Otherwise we might get false positives (or false negatives? I can never tell), i.e. tests pass even though the clients signature verification is broken. |
I think we should distinguish unit tests for logical components and integration tests for the whole machinery as debugging the whole machinery is quite complex and it helps a lot to target small pieces at a time. Also one thing I'm afraid of is the timing with state tests:
|
A state transition is I have a series of state tests using the above format ready to release with the next version of the spec (v0.5.0). The tests are quite verbose but adding defaults for constants or constants sets aren't going to save us much space. It's the pre_state (specifically the cache arrays) that really get us.
The tests I currently have do so in specifying just a subset of the Do you have something more granular in mind @mratsim ?
agreed I'll share the tests I've generated from the executable python spec soon |
It's pretty minor, but I'd like it if all the "config" values were in lower case. All of these variables are lower-case in my structs and as far as my YAML parser is concerned, I suspect this will be the case for other clients too, considering that it'll need to be a variable if it's set from YAML and variables are generally lower-case. No big deal though, I can devise a work-around. Thanks for you efforts on it :) |
ah, interesting. standard in python is that constants are capitalized so my config expects caps :) The vectors I'm releasing right now are capitalized. I'm down to switch to whichever is preferred by most languages. |
I'm just calling Case-insensitive blockchains are the future, IMO. |
For the Go executable spec it is a little bit more complicated to make this config design work: The goals of the Go version are:
Now I've implemented a spec-test runner, but the current implementation, using And I imagine that many others would prefer to just make it part of the build, instead of dealing with all the extra complexity (ensure lengths everywhere, initialize things, unclear types) Given that the "config" section is only really used to make tests more efficient, can't we just agree on a few build presets? E.g.:
And a few more. And then simply reference these in all the test suite cases, instead of duplicating the config contents: - config: minimal
initial_state:
...
expected_state:
slot: 51 And then we can have the best of both worlds (compile time guarantees and testing) :) Edit: alternatively, we could also list these configs by their name in a special |
This has been raised several times in Lighthouse: do we make the constants constant or keep them as variables? Currently we keep all the spec "constants" as variables in a We prefer variables for two main reasons:
We've come to the decision that constants don't give us significantly more safety (we can quite reasonably make assumptions that Personally, I'd vote to keep all constants variable (lol) because defining scenarios is (a) more work and (b) less flexible. @protolambda I understand that you're in a different situation though, you need to prioritize readability above (almost) all else -- I wouldn't complain if defining scenarios was implemented, just sharing my POV :) |
The two options are not exclusive. The config scenarios idea boils down to the following:
|
Also, I would like the state test format to support the definition of a test-case for a sub-state-transition. Each of these transitions already supports a generalized in/output, the same as the big block/epoch transition itself:
Or alternatively, we create a separate format or two for this, since state sub-transitions don't have block inputs, and block transitions only have 1 block. |
Test suite name
beacon_state
Test case format
Format field notes
config
[key/value]verify_signatures
(optional) [bool]initial_state
[key/value]BeaconState
blocks
[list]expected_state
[key/value]BeaconState
containing the expected values of the resulting stateexpected_state_root
(optional) [32-byte hex string]hash_tree_root(state)
after processing to the latest block inblocks
Example
Notes
expected_state_root
as optional andexpected_state
allowed to specify just a subset of fields, we use this format for very narrowly targeted sets of tests (like the above update slot test, or maybe a deposit processing test) as well as for full blown state tests that test very complex transitions.parent_root
will not be assessed for validity. Could just leave it out and handle locally in each client as makes sense.verify_signatures == False
.Validator
epoch fields should all just default toFAR_FUTURE_EPOCH
unless explicitly specified otherwise. Block body arrays might just default to empty unless specified. etc.is_invalid: True
field.The text was updated successfully, but these errors were encountered: