Skip to content

Commit 9b2adcb

Browse files
committed
Fix comments & clarity
1 parent a50ca2a commit 9b2adcb

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

chains/evm/.gas-snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AdvancedPoolHooksExtractor_extract:test_extract_PostflightCheck() (gas: 63184)
2-
AdvancedPoolHooksExtractor_extract:test_extract_PreflightCheck() (gas: 49468)
2+
AdvancedPoolHooksExtractor_extract:test_extract_PreflightCheck() (gas: 49534)
33
AdvancedPoolHooks_applyAllowListUpdates:test_applyAllowListUpdates() (gas: 184272)
44
AdvancedPoolHooks_applyAllowListUpdates:test_applyAllowListUpdates_SkipsZero() (gas: 24071)
55
AdvancedPoolHooks_applyAuthorizedCallerUpdates:test_applyAuthorizedCallerUpdates_AddAndRemove() (gas: 65310)

chains/evm/contracts/libraries/FinalityCodec.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ pragma solidity ^0.8.4;
1616
/// flags (6 bits) depth (10 bits)
1717
/// max = 1023 (0x3FF)
1818
///
19-
/// S (bit 10) = WAIT_FOR_SAFE_FLAG — wait for the `safe` tag instead of a block count.
19+
/// S (bit 10) = WAIT_FOR_SAFE_FLAG — wait for the `safe` tag.
2020
/// R (bits 11-15) = Reserved for future flags (currently unassigned; accepted on the wire).
2121
/// Reserved bits may be assigned in the future, read the docs for the latest bit definitions.
2222
///
2323
/// Special values:
2424
/// 0x0000 WAIT_FOR_FINALITY_FLAG — wait for full finality (safest, default).
2525
/// 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).
26+
/// 0x0001..0x03FF — wait for N blocks.
2727
library FinalityCodec {
2828
error InvalidBlockDepth(uint16 requestedDepth, uint16 maxDepth);
2929
error InvalidRequestedFinality(bytes2 requestedFinality, bytes2 allowedFinality);
@@ -47,7 +47,7 @@ library FinalityCodec {
4747
bytes2 public constant WAIT_FOR_SAFE_FLAG = bytes2(uint16(1 << BLOCK_DEPTH_BITS));
4848

4949
/// @notice Helper to encode block depth into the finality params. Will revert if the block depth is greater than the
50-
/// maximum block depth.
50+
/// maximum block depth. Returns WAIT_FOR_FINALITY_FLAG if the block depth is zero.
5151
/// @param blockDepth The block depth to encode into the finality params.
5252
/// @return The encoded finality params with the block depth.
5353
function _encodeBlockDepth(
@@ -110,11 +110,11 @@ library FinalityCodec {
110110
bytes2 allowedFinality
111111
) internal pure {
112112
// Finality is always allowed.
113-
if (requestedFinality == bytes2(0)) {
113+
if (requestedFinality == WAIT_FOR_FINALITY_FLAG) {
114114
return;
115115
}
116116
// If any of the flags match, the request is allowed only when it has no depth field (flag-only request).
117-
if (requestedFinality >> BLOCK_DEPTH_BITS & allowedFinality >> BLOCK_DEPTH_BITS != 0) {
117+
if ((requestedFinality >> BLOCK_DEPTH_BITS) & (allowedFinality >> BLOCK_DEPTH_BITS) != 0) {
118118
if (uint16(requestedFinality & BLOCK_DEPTH_MASK) != 0) {
119119
revert InvalidRequestedFinality(requestedFinality, allowedFinality);
120120
}

0 commit comments

Comments
 (0)