From faa539ee92555e7f9d3dcb0b4eba612f7e48326e Mon Sep 17 00:00:00 2001 From: Duncan Townsend Date: Wed, 5 Feb 2025 21:31:48 -0500 Subject: [PATCH] Always clean dirty bits --- src/SettlerIntent.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SettlerIntent.sol b/src/SettlerIntent.sol index 8bee6331..16a596e1 100644 --- a/src/SettlerIntent.sol +++ b/src/SettlerIntent.sol @@ -130,10 +130,10 @@ abstract contract SettlerIntent is Permit2PaymentIntent, SettlerMetaTxn { mstore(0x00, solver) mstore(0x20, _SOLVER_LIST_BASE_SLOT) let solverSlot := keccak256(0x00, 0x40) - let solverSlotValue := sload(solverSlot) + let solverSlotValue := and(0xffffffffffffffffffffffffffffffffffffffff, sload(solverSlot)) - // If the slot is zero, `addNotRemove` must be true (we are adding a new - // solver). Likewise if the slot is nonzero, `addNotRemove` must be false (we are + // If the slot contains zero, `addNotRemove` must be true (we are adding a new + // solver). Likewise if the slot contains nonzero, `addNotRemove` must be false (we are // removing one). fail := or(fail, xor(iszero(solverSlotValue), addNotRemove)) @@ -151,7 +151,7 @@ abstract contract SettlerIntent is Permit2PaymentIntent, SettlerMetaTxn { // new solver, then `prev` must be the last element of the list (it points at // `_SENTINEL_SOLVER`). If we are removing an existing solver, then `prev` must point at // `solver. - fail := or(fail, xor(sload(prevSlot), expectedPrevSlotValue)) + fail := or(fail, xor(and(0xffffffffffffffffffffffffffffffffffffffff, sload(prevSlot)), expectedPrevSlotValue)) // Update the linked list. This either points `$[prev]` at `$[solver]` and zeroes // `$[solver]` or it points `$[prev]` at `solver` and points `$[solver]` at