Skip to content

beacon: raise the custody group count for attached validators (fulu validator custody) #848

Open

Description

@MegaRedHand

Problem

ethlambda beacon does not implement fulu validator custody. It custodies and advertises whatever --custody-group-count says (default CUSTODY_REQUIREMENT = 4), regardless of how many validators are attached to it.

Fulu validator.md ("Validator custody") says a node with validators attached custodies get_validators_custody_requirement(state, validator_indices) groups. That is the attached validators' total effective balance divided by BALANCE_PER_ADDITIONAL_CUSTODY_GROUP (32 ETH), with a floor of VALIDATOR_CUSTODY_REQUIREMENT (8) and a cap of NUMBER_OF_CUSTODY_GROUPS (128). A node with 4096 ETH or more attached must therefore be a supernode.

Observed in a kurtosis test enclave: with 128 validators attached, ethlambda logged custody_group_count=4, while Lighthouse in the same network reported 128. A network laid out on the assumption that every validating node stores at least 8 groups is short on column custody wherever ethlambda runs the validators.

What the code does today (at 0ea6e21)

  • validator_custody_requirement and balance_per_additional_custody_group are parsed into Config and then dropped. first_config_difference destructures both as _, and nothing else reads them.
    // PeerDAS custody: describes what this node samples/custodies, an
    // operator/wire choice, not a state-transition rule.
    balance_per_additional_custody_group: _,
    custody_requirement: _,
    number_of_custody_groups: _,
    samples_per_slot: _,
    validator_custody_requirement: _,
  • The custody set is computed once at startup, in wire_params, from the CLI value, and kept for the life of the process.
    let sampling = ethlambda_state_transition::beacon::das::sampling_size(custody_group_count);
    let custody_columns =
    ethlambda_state_transition::beacon::das::custody_columns(node_id, sampling)
    .expect("the sampling size is within NUMBER_OF_CUSTODY_GROUPS");
    info!(
    custody_group_count,
    sampling,
    columns = ?custody_columns,
    "Custodying data columns"
    );
  • The node does not record which validators are attached. beacon_committee_subscriptions parses validator_index but never reads it, and prepare_beacon_proposer keeps the indices only as keys of the fee-recipient map.
    /// One entry of `beacon_committee_subscriptions`. Parsed so a malformed body
    /// is refused, though `validator_index` is never read.
    #[derive(Debug, Deserialize)]
    struct CommitteeSubscription {
    #[allow(dead_code)]
    #[serde(with = "ethlambda_types::beacon::serde_helpers::quoted_or_bare")]
    validator_index: ValidatorIndex,
    #[serde(with = "ethlambda_types::beacon::serde_helpers::quoted_or_bare")]
    committee_index: CommitteeIndex,
    #[serde(with = "ethlambda_types::beacon::serde_helpers::quoted_or_bare")]
    committees_at_slot: u64,
    #[serde(with = "ethlambda_types::beacon::serde_helpers::quoted_or_bare")]
    slot: Slot,
    is_aggregator: bool,
    }

    /// `POST /eth/v1/validator/prepare_beacon_proposer`: record where each
    /// validator's block rewards should be paid.
    async fn post_prepare_beacon_proposer(
    Extension(fee_recipients): Extension<FeeRecipients>,
    Json(preparations): Json<Vec<ProposerPreparation>>,
    ) -> Response {
    let mut map = fee_recipients.lock().expect("fee recipient lock poisoned");
    for preparation in preparations {
    map.insert(preparation.validator_index, preparation.fee_recipient);
    }
    axum::http::StatusCode::OK.into_response()
  • MetaData v3 always answers custody_group_count = CUSTODY_REQUIREMENT, even when --custody-group-count is set higher. The ENR's cgc does carry the flag's value, so the two disagree on any node started with a non-default count.
    /// `custody_group_count` is `CUSTODY_REQUIREMENT`, the floor a peer may demand,
    /// not this node's actual custody: `sampling_size` raises what it stores and
    /// serves (`BeaconWire::custody_columns`) to cover at least `SAMPLES_PER_SLOT`
    /// groups, so `cgc` can only understate this node's real coverage, never
    /// overstate it.
    pub fn build_metadata(wire: &BeaconWire, protocol: &str) -> Option<BeaconMetaData> {
    let seq_number = wire.metadata_seq_number;
    let attnets = attnets(wire);
    let syncnets = syncnets(wire);
    match protocol {
    protocols::METADATA_V1 => Some(BeaconMetaData::V1(MetaDataV1 {
    seq_number,
    attnets,
    })),
    protocols::METADATA_V2 => Some(BeaconMetaData::V2(MetaDataV2 {
    seq_number,
    attnets,
    syncnets,
    })),
    protocols::METADATA_V3 => Some(BeaconMetaData::V3(MetaDataV3 {
    seq_number,
    attnets,
    syncnets,
    custody_group_count: constants::CUSTODY_REQUIREMENT,
    })),
  • GET /eth/v1/node/identity reports seq_number, attnets and syncnets under metadata, but not custody_group_count. AdvertisedMetaData has no field for it.
    let identity = identity.unwrap_or_default();
    let metadata = match identity.metadata {
    Some(metadata) => {
    let metadata = metadata.get();
    serde_json::json!({
    "seq_number": metadata.seq_number.to_string(),
    "attnets": format!("0x{}", hex::encode(&metadata.attnets)),
    "syncnets": format!("0x{}", hex::encode(&metadata.syncnets)),
    })
    }
    None => serde_json::json!({
    "seq_number": "0",
    "attnets": "0x0000000000000000",
    "syncnets": "0x00",

What the spec asks for (fulu validator.md)

  • Advertise the higher count in MetaData custody_group_count and in the ENR's cgc.
  • Adjust it dynamically, without operator input, as the attached validators' effective balances change.
  • On an increase, advertise the new count immediately. Backfill MAY follow. earliest_available_slot in Status v2 should reflect what the node can actually serve, and may move lower as backfill progresses.
  • On a decrease, keep custodying and advertising the previous (highest) count, and persist it across restarts.

Rough scope

  1. Track attached validator indices from validator client calls (beacon_committee_subscriptions, prepare_beacon_proposer), with an expiry so that a detached validator client stops counting.
  2. Once per epoch, compute get_validators_custody_requirement and take the larger of the flag, that requirement, and the persisted highest count. Store the highest count in the data directory.
  3. Make the custody set changeable at runtime. Today it is fixed in BeaconWire and in the chain actor at spawn, and these paths read it: data-column subnet subscriptions, the availability check, req/resp serving, and the engine's custody columns.
  4. When the count changes, bump the MetaData seq_number and the ENR. The ENR has the same known gap as the fork digest: ethrex's DiscoveryServer cannot replace the record it serves at runtime, so cgc would stay at its startup value until a restart.
  5. Make MetaData v3 report the real count, and add custody_group_count to /eth/v1/node/identity.
  6. After an increase, keep earliest_available_slot honest until backfill completes.

Steps 5 and 1 are small and independent, so they could land first.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions