Skip to main content

Module slashings

Module slashings 

Source
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.

The delta stores (ring_index, value) pairs. Applying the delta writes only those changed entries into the destination buffer; all other entries remain untouched.

§Epoch Mapping

Ring-buffer indices are derived from the epoch number:

ring_index = epoch % buffer_capacity

diff_slashings examines the epochs crossed between base_slot and target_slot. The base epoch itself is not examined. For a transition from base_epoch to target_epoch, the inspected epochs are:

base_epoch + 1, ..., target_epoch

This means that when both slots belong to the same epoch, no entries are examined and the resulting delta is empty.

§Correctness

The base and target buffers must have the same capacity and represent the same slashing ring. The delta stores ring indices rather than epochs, 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.

§Complexity

If E is the number of epoch boundaries crossed by the transition:

  • diff_slashings runs in O(E) time and O(U) additional space, where U is the number of changed ring entries.
  • apply_slashings runs 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.