Skip to content

Commit

Permalink
Remove temporary sender variable (gas savings) (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog authored Nov 1, 2023
1 parent 6dbc718 commit 5123656
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/Paymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ contract Paymaster is BasePaymaster {
function getHash(UserOperation calldata userOp, uint48 validUntil, uint48 validAfter)
public view returns (bytes32) {
// can't use userOp.hash(), since it contains also the paymasterAndData itself.
address sender = userOp.getSender();
return keccak256(
abi.encode(
sender,
userOp.getSender(),
userOp.nonce,
keccak256(userOp.initCode),
keccak256(userOp.callData),
Expand Down
6 changes: 3 additions & 3 deletions test/Paymaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ contract PaymasterTest is Test {
UserOperation memory userOp = createUserOp();
signUserOp(userOp);

vm.expectRevert(createEncodedValidationResult(false, 57198));
vm.expectRevert(createEncodedValidationResult(false, 57193));
entrypoint.simulateValidation(userOp);
}

Expand All @@ -71,7 +71,7 @@ contract PaymasterTest is Test {
userOp.paymasterAndData = abi.encodePacked(address(paymaster), abi.encode(MOCK_VALID_UNTIL, MOCK_VALID_AFTER), r, s, v);
signUserOp(userOp);

vm.expectRevert(createEncodedValidationResult(false, 55198));
vm.expectRevert(createEncodedValidationResult(false, 55193));
entrypoint.simulateValidation(userOp);
}

Expand All @@ -81,7 +81,7 @@ contract PaymasterTest is Test {
userOp.paymasterAndData = abi.encodePacked(address(paymaster), abi.encode(MOCK_VALID_UNTIL, MOCK_VALID_AFTER), r, s, v);
signUserOp(userOp);

vm.expectRevert(createEncodedValidationResult(true, 57204));
vm.expectRevert(createEncodedValidationResult(true, 57199));
entrypoint.simulateValidation(userOp);
}

Expand Down

0 comments on commit 5123656

Please sign in to comment.