Expand description
Delta encoding for Ethereum slashing vectors.
Ethereum consensus stores slashing totals in a fixed-capacity circular buffer indexed by epoch.
Unlike root and RANDAO buffers, where every slot or epoch transition may require recording a new value, slashing totals are comparatively sparse. This module therefore records only ring-buffer entries whose values differ between the base and target states at the ring positions touched by the epoch transition.
The delta stores (ring_index, value) pairs. Applying the delta writes only
those recorded values into the destination buffer; all other entries remain
untouched.
§Epoch Mapping
Ring-buffer indices are derived from the epoch number:
ring_index = epoch % buffer_capacitydiff_slashings examines the ring positions corresponding to the epoch
boundaries crossed between base_slot and target_slot. The base epoch
itself is not examined. For a transition from base_epoch to
target_epoch, the epochs mapped to ring positions are:
base_epoch + 1, ..., target_epochIf both slots belong to the same epoch, no ring positions are examined and the resulting delta is empty.
If the transition spans more than one complete ring cycle, the same ring-buffer index may be examined more than once. Each occurrence compares the current values at that index in the base and target buffers. Applying the resulting updates in order still reconstructs the target buffer.
§Correctness
The base and target buffers must have the same capacity and represent the same logical slashing ring. The delta stores ring indices rather than epoch numbers, so the buffer capacity is part of the implicit representation.
Applying a delta to a buffer with a different capacity, layout, or unrelated state can write values to incorrect positions.
The delta only records positions whose base and target values differ among the ring positions examined by the transition. Positions omitted from the delta are expected to already contain their target values.
§Complexity
If E is the number of epoch boundaries crossed by the transition:
diff_slashingsruns in O(E) time and O(U) additional space, whereUis the number of recorded updates.apply_slashingsruns in O(U) time and O(1) additional space.
Functions§
- apply_
slashings - Applies a sparse slashing delta to a circular slashing buffer in place.
- diff_
slashings - Computes a sparse delta between two slashing ring buffers.