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
- 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.
- In
packet-timeout.rs, compute timeout as source_height + ceil(timeout_delta / p95_block_time_ms) instead of using a fixed value.
- 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.
- 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.
- Unit test: simulate variable block times (2s average with spikes to 30s), verify packet timeout accuracy >95%.
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
source_height + (timeout_delta / source_block_time).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
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.packet-timeout.rs, compute timeout assource_height + ceil(timeout_delta / p95_block_time_ms)instead of using a fixed value.packet-relayer.rs, emit aPacketTimeoutMisestimationevent when a packet times out but the destination chain is still at or below the estimated timeout height.