linera-io/linera-protocol · info

serialize heights

Error message

serialize heights

What it means

The From<Vec<Option<BlockHeight>>> for api::EventBlockHeightsResponse conversion (linera-rpc/src/grpc/conversions.rs:1130) bincode-serializes the heights into the protobuf response and expects success. BlockHeight wraps a u64, so serialization cannot fail; the expect asserts infallibility. Note the reverse direction (TryFrom on the response) is fallible and uses proper error handling for malicious bytes.

Source

Thrown at linera-rpc/src/grpc/conversions.rs:1133

    fn from(event_ids: Vec<EventId>) -> Self {
        Self {
            event_ids: bincode::serialize(&event_ids).expect("serialize event_ids"),
        }
    }
}

impl TryFrom<api::EventBlockHeightsRequest> for Vec<EventId> {
    type Error = GrpcProtoConversionError;

    fn try_from(request: api::EventBlockHeightsRequest) -> Result<Self, Self::Error> {
        Ok(bincode::deserialize(&request.event_ids)?)
    }
}

impl From<Vec<Option<BlockHeight>>> for api::EventBlockHeightsResponse {
    fn from(heights: Vec<Option<BlockHeight>>) -> Self {
        Self {
            heights: bincode::serialize(&heights).expect("serialize heights"),
        }
    }
}

impl TryFrom<api::EventBlockHeightsResponse> for Vec<Option<BlockHeight>> {
    type Error = GrpcProtoConversionError;

    fn try_from(response: api::EventBlockHeightsResponse) -> Result<Self, Self::Error> {
        Ok(bincode::deserialize(&response.heights)?)
    }
}

#[cfg(test)]
/// Tests for the gRPC protobuf conversions.
pub mod tests {
    // Test helpers in this module don't need individual documentation.
    #![allow(missing_docs)]

View on GitHub (pinned to 6c226ddcb3)

Solutions

  1. If hit in a fork, switch to TryFrom or fix the custom Serialize impl.
  2. In upstream builds, report as an internal bug with a backtrace.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Not realistically reachable: serializing Vec<Option<BlockHeight>> with bincode cannot error. A hit implies a modified fork with fallible Serialize impls or memory corruption.

Common situations: None under normal operation.

Related errors


AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22). Data as JSON: /api/errors/1cf48be06ce4d94e. Report an issue: GitHub.