From b4f2a46b35e662b1965bc2e144b2610e2456c30c Mon Sep 17 00:00:00 2001 From: Jay Paik Date: Wed, 13 Mar 2024 02:30:55 -0400 Subject: [PATCH] fix: optimize LightAccountFactory's _getCombinedSalt --- src/LightAccountFactory.sol | 8 ++++++-- test/LightAccount.t.sol | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/LightAccountFactory.sol b/src/LightAccountFactory.sol index 74b6a28..e91dca9 100644 --- a/src/LightAccountFactory.sol +++ b/src/LightAccountFactory.sol @@ -45,7 +45,11 @@ contract LightAccountFactory { ); } - function _getCombinedSalt(address owner, uint256 salt) internal pure returns (bytes32) { - return keccak256(abi.encode(owner, salt)); + function _getCombinedSalt(address owner, uint256 salt) internal pure returns (bytes32 combinedSalt) { + assembly ("memory-safe") { + mstore(0x00, owner) + mstore(0x20, salt) + combinedSalt := keccak256(0x00, 0x40) + } } } diff --git a/test/LightAccount.t.sol b/test/LightAccount.t.sol index 0c9dee3..d4c835f 100644 --- a/test/LightAccount.t.sol +++ b/test/LightAccount.t.sol @@ -288,7 +288,7 @@ contract LightAccountTest is Test { bytes32(uint256(uint160(0x0000000071727De22E5E9d8BAf0edAc6f37da032))) ) ), - 0x61ded19e9e86ff20a3a8822529fb98ef584c1e9f6e1457dcfdcd1f5e146d7d97 + 0xa677af8a16ab66d988856a88ea647c45da368a588b036126ce3e21645f7891ca ); }