Skip to content

Commit 27b1bb5

Browse files
committed
Fix incorrect bitwise comparison
_getMessageAttestationsStorage()[digest].attestedTransceivers & uint64(1 << index) == 1; The call at the beginning is getting a bitmap of attested transceivers. So, 7 (b111) would be 3 accepted transceivers. Next, we are computing the index to compare on the bitmap with transceiver index. So, if we want check the second index then 1 << 1 would work to produce 2 or the middle bit out of the 3 in the example. Finally, we're comparing this with 1, which is where the bug is at. This is ONLY true if we're checking the first index. For instance, if we're checking the second index (value of 1) then we'd do 7 & (1 << 1) == 1 or 7 & 2 == 1 which is 2 == 1 . So, the comparison will fail on all indexes that aren't the first one (value of 0). So, the fix is to check if the value is greater than 0. This means that if the singular bit is set, then it's already been attested to
1 parent 42a08e0 commit 27b1bb5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

evm/src/NttManager/NttManagerState.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ abstract contract NttManagerState is
169169
/// @inheritdoc INttManagerState
170170
function transceiverAttestedToMessage(bytes32 digest, uint8 index) public view returns (bool) {
171171
return
172-
_getMessageAttestationsStorage()[digest].attestedTransceivers & uint64(1 << index) == 1;
172+
_getMessageAttestationsStorage()[digest].attestedTransceivers & uint64(1 << index) > 0;
173173
}
174174

175175
/// @inheritdoc INttManagerState

0 commit comments

Comments
 (0)