Skip to content

Commit 1bc6d91

Browse files
committed
moved actual nonce to least significant bits
1 parent d34ef61 commit 1bc6d91

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/allocators/ERC7683Allocator.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,11 @@ contract ERC7683Allocator is SimpleAllocator, IERC7683Allocator {
276276
}
277277

278278
function _checkNonce(address sponsor_, uint256 nonce_) internal pure {
279-
// Enforce a nonce where the most significant 96 bits are the nonce and the least significant 160 bits are the sponsor
279+
// Enforce a nonce where the least significant 96 bits are the nonce and the most significant 160 bits are the sponsors address
280280
// This ensures that the nonce is unique for a given sponsor
281281
address expectedSponsor;
282282
assembly ("memory-safe") {
283-
expectedSponsor := shr(96, shl(96, nonce_))
283+
expectedSponsor := shr(96, nonce_)
284284
}
285285
if (expectedSponsor != sponsor_) {
286286
revert InvalidNonce(nonce_);

test/ERC7683Allocator.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ abstract contract MocksSetup is Test {
6969
});
7070
usdcId = IdLib.toId(lock);
7171
(attacker, attackerPK) = makeAddrAndKey('attacker');
72-
defaultNonce = uint256(bytes32(abi.encodePacked(uint96(1), user)));
72+
defaultNonce = uint256(bytes32(abi.encodePacked(user, uint96(1))));
7373

7474
ORDERDATA_GASLESS_TYPEHASH = erc7683Allocator.ORDERDATA_GASLESS_TYPEHASH();
7575
ORDERDATA_TYPEHASH = erc7683Allocator.ORDERDATA_TYPEHASH();
@@ -940,7 +940,7 @@ contract ERC7683Allocator_checkNonce is OnChainCrossChainOrderData {
940940
address sponsor = user;
941941
uint256 nonce;
942942
assembly ("memory-safe") {
943-
nonce := or(shl(160, nonce_), shr(96, shl(96, sponsor)))
943+
nonce := or(shl(96, sponsor), shr(160, shl(160, nonce_)))
944944
}
945945
assertEq(erc7683Allocator.checkNonce(sponsor, nonce), true);
946946
}

0 commit comments

Comments
 (0)