File tree Expand file tree Collapse file tree
chains/evm/contracts/libraries Expand file tree Collapse file tree Original file line number Diff line number Diff 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).
727library 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.
You can’t perform that action at this time.
0 commit comments