Skip to main content

create

Function create 

Source
pub fn create<R: DiffSource>(state: &R) -> BeaconStateDelta
Expand description

Creates a BeaconStateDelta describing the transition between two beacon states.

DiffSource supplies both the base and target components. Each component is passed to the specialized encoder best suited to its update semantics.

The resulting delta contains enough information to reconstruct the target state when applied to the corresponding base state with apply.

§Fork handling

The fork returned by DiffSource::fork is stored in the delta. Fork-specific components are populated according to that fork.

The function performs debug-only invariant checks to ensure that fork-specific fields are present exactly when expected.

§Complexity

O(n) in the amount of state data examined by the individual diff algorithms. No single representation is imposed on all state components; the actual amount of work depends on the component sizes and their specialized encoding strategies.

§Examples

A consensus client typically implements DiffSource for a wrapper around its state representation and then calls:

let delta = eth_state_diff::create(&source);

The resulting BeaconStateDelta can then be serialized or archived for later application.