Skip to content

IBC Packet Commitment Timeout Mismatch Across Variable Block-Time Chains #138

Description

@JamesEjembi

Problem Statement / Feature Objective

The IBC (Inter-Blockchain Communication) packet commitment timeout is calculated using the source chain's block time assumption. When sending packets to a chain with variable block times (e.g., 2-30s range), the timeout can expire prematurely on fast blocks or be excessively long on slow blocks, causing packet loss or settlement delays.

Technical Invariants & Bounds

  • Timeout calculation: source_height + (timeout_delta / source_block_time).
  • Block time variance tracking: rolling window of 100 blocks.
  • Timeout delta: configurable 10-300s.
  • Packet lifetime: max 1000 blocks on destination chain.
  • Mismatch penalty: >5% timeouts due to misestimation triggers recalibration.

Codebase Navigation Guide

  • src/cross-chain/ibc/packet-timeout.rs — timeout calculation.
  • src/cross-chain/ibc/block-time-estimator.rs — block time estimation.
  • src/cross-chain/ibc/packet-relayer.rs — packet relay logic.
  • src/cross-chain/consensus/header-sync.rs — header synchronization.

Implementation Blueprint

  1. In block-time-estimator.rs, maintain an exponential moving average (EMA) of block times with alpha = 0.3 over 100 blocks; also track the 95th percentile.
  2. In packet-timeout.rs, compute timeout as source_height + ceil(timeout_delta / p95_block_time_ms) instead of using a fixed value.
  3. Add a safety margin: multiply the estimated block count by 1.5 for the first 10 packets to a new chain until sufficient block time samples are collected.
  4. In packet-relayer.rs, emit a PacketTimeoutMisestimation event when a packet times out but the destination chain is still at or below the estimated timeout height.
  5. Unit test: simulate variable block times (2s average with spikes to 30s), verify packet timeout accuracy >95%.

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions