Skip to content

Commit be8c0e8

Browse files
committed
add clear bit layout
1 parent d5dabce commit be8c0e8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

chains/evm/contracts/libraries/FinalityCodec.sol

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ pragma solidity ^0.8.4;
44
/// @notice This library provides encoding and validation for finality parameters used in cross-chain transfers.
55
/// @dev this codec supports all the bit flags, even though some might not be assigned any meaning yet. This is
66
/// intentional to allow for future flexibility.
7+
///
8+
/// @dev Bit layout of the `bytes2` finality value (16 bits, MSB on the left):
9+
///
10+
/// Bit: 15 14 13 12 11 10 | 9 8 7 6 5 4 3 2 1 0
11+
/// +----+----+----+----+----+---+----+----+----+----+----+----+----+----+----+----+
12+
/// | R | R | R | R | R | S | block depth (10 bits) |
13+
/// +----+----+----+----+----+---+----+----+----+----+----+----+----+----+----+----+
14+
/// \____________________ ____/ \________________________ _____________________/
15+
/// \/ \/
16+
/// flags (6 bits) depth (10 bits)
17+
/// max = 1023 (0x3FF)
18+
///
19+
/// S (bit 10) = WAIT_FOR_SAFE_FLAG — wait for the `safe` tag instead of a block count.
20+
/// R (bits 11-15) = Reserved for future flags (currently unassigned; accepted on the wire).
21+
/// Reserved bits may be assigned in the future, read the docs for the latest bit definitions.
22+
///
23+
/// Special values:
24+
/// 0x0000 WAIT_FOR_FINALITY_FLAG — wait for full finality (safest, default).
25+
/// 0x0400 WAIT_FOR_SAFE_FLAG — wait for the `safe` head (bit 10 set, no depth).
26+
/// 0x0001..0x03FF — wait for N confirmation blocks (depth only, no flags).
727
library FinalityCodec {
828
error InvalidBlockDepth(uint16 requestedDepth, uint16 maxDepth);
929
/// @notice Requested finality must be exactly one mode: any of the flag bits or a block depth with no upper flag bits.

0 commit comments

Comments
 (0)