Skip to main content

diff_sync_committee

Function diff_sync_committee 

Source
pub fn diff_sync_committee(
    base_ssz: &[u8],
    target_ssz: &[u8],
) -> SyncCommitteeDiff
Expand description

Computes a delta between two serialized Ethereum sync committees.

The serialized committee bytes are compared as opaque byte sequences.

If base_ssz and target_ssz are identical, this function returns SyncCommitteeDiff::Unchanged and stores no committee bytes.

If they differ, this function returns SyncCommitteeDiff::FullReplacement containing a copy of target_ssz. The target committee is therefore stored in its entirety rather than attempting to encode individual member changes.

§Arguments

  • base_ssz - Serialized SSZ bytes of the committee in the base state.
  • target_ssz - Serialized SSZ bytes of the committee in the target state.

Both arguments must represent the same consensus-state field and use the same serialization format.

§Returns

A SyncCommitteeDiff representing the transition from base_ssz to target_ssz.

§Complexity

O(n) time, where n is the length of the serialized committee.

If the committees differ, O(n) additional space is required for the copied replacement payload.

§Example

use eth_state_diff::sync_committee::diff_sync_committee;
use eth_state_diff::types::SyncCommitteeDiff;

let base = b"committee-a";
let target = b"committee-b";

let delta = diff_sync_committee(base, target);

assert_eq!(
    delta,
    SyncCommitteeDiff::FullReplacement(target.to_vec())
);