ethereum-consensus
ethereum-consensus copied to clipboard
Add functionality for generating valid / random states
User Story:
As a dev, I'd like to be able to test the various functions throughout this library; however, creating dummy/test BeaconState
and Context
objects is not straightforward. Ideally, I'd like to be able to run tests and create these objects with something like ::random()
to then write various tests on the dummy data -- e.g., helping me verify how the state transition functions are manipulating the data.
Requirements:
Add functionality, such as implementing ::random()
, for generating valid / random states on BeaconState
and Context
(and related subtypes)
using something in the realm of property-based testing would be great here -- ideally we want to be able to generate random values for all of our types and be able to apply constraints on the values so that we can get actual consistent instances.
for example, i know if we had such a thing we could apply it to generating more interesting spec tests for https://github.com/ethereum/consensus-specs
Before I attempt to take this on & start researching, are there any resources / guidelines off the top of your head that would help here? Just figuring out where to start -- e.g., looking at ssz_rs
, would it follow a similar design by adding default
impls to everything in BeaconState
and Context
?
Alternatively, I can attempt other open issues if those have higher priority or might make sense to do first (https://github.com/ralexstokes/ethereum_consensus/issues/5 or https://github.com/ralexstokes/ethereum_consensus/issues/54)?.
i'd say implementing tests are higher priority, and then continuing on the altair and bellatrix forks, and also implementing an optimized phase0 spec
for future reference, i'd say we consider starting w/ random impls like in this example: https://rust-lang-nursery.github.io/rust-cookbook/algorithms/randomness.html#generate-random-values-of-a-custom-type using the rng
crate