beacon-chain-java icon indicating copy to clipboard operation
beacon-chain-java copied to clipboard

Refactor StateTransition construction

Open ericsson49 opened this issue 6 years ago • 0 comments

There are two main StateTransition functions: preBlock (empty slot) and perBlock. However, their construction somewhat clumsy and non-uniform accross code base. E.g.

    initialTransition = new InitialStateTransition(chainStartEvent, spec);
    perSlotTransition = new PerSlotTransition(spec);
    perBlockTransition = new PerBlockTransition(spec);
    perEpochTransition = new PerEpochTransition(spec);
    extendedSlotTransition =
        new ExtendedSlotTransition(perEpochTransition, perSlotTransition, spec);
    emptySlotTransition = new EmptySlotTransition(extendedSlotTransition);

In order to improve readability and reduce code duplication, refactor StateTransition construction.

There can be (at least) two steps: 1 there exists already StateTransitions class with appropriate helper functions (preBlockTransition and blockTransition). The only problem is that some benchmarking code overloads some methods to gather statistics. 2 Incapsulate state transition logic in a Stepper class, having two methods: processSlots and processBlock (or something like this).

ericsson49 avatar Sep 18 '19 10:09 ericsson49