From b443c8a9d18f5e6e13321a6467e187440abb43d6 Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:38:32 +0000 Subject: [PATCH] create sender before finding paymaster gasLimit --- src/v07/EntryPoint.sol | 2 +- src/v07/EntryPointSimulations.sol | 23 +++++------------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/v07/EntryPoint.sol b/src/v07/EntryPoint.sol index b415a2e..99d35e8 100644 --- a/src/v07/EntryPoint.sol +++ b/src/v07/EntryPoint.sol @@ -28,7 +28,7 @@ contract EntryPoint is IEntryPoint, StakeManager, NonceManager, ReentrancyGuard using UserOperationLib for PackedUserOperation; - SenderCreator private immutable _senderCreator = new SenderCreator(); + SenderCreator internal immutable _senderCreator = new SenderCreator(); function senderCreator() internal view virtual returns (SenderCreator) { return _senderCreator; diff --git a/src/v07/EntryPointSimulations.sol b/src/v07/EntryPointSimulations.sol index f631cd2..42bc2c8 100644 --- a/src/v07/EntryPointSimulations.sol +++ b/src/v07/EntryPointSimulations.sol @@ -23,24 +23,11 @@ struct SimulationArgs { contract EntryPointSimulations is EntryPoint, IEntryPointSimulations { EntryPointSimulations immutable thisContract = this; AggregatorStakeInfo private NOT_AGGREGATED = AggregatorStakeInfo(address(0), StakeInfo(0, 0)); - SenderCreator private _senderCreator; // Thrown when the binary search fails due hitting the simulation gasLimit. error SimulationOutOfGas(uint256 optimalGas, uint256 minGas, uint256 maxGas); error innerCallResult(uint256 remainingGas); - function initSenderCreator() internal virtual { - //this is the address of the first contract created with CREATE by this address. - address createdObj = address(uint160(uint256(keccak256(abi.encodePacked(hex"d694", address(this), hex"01"))))); - _senderCreator = SenderCreator(createdObj); - } - - function senderCreator() internal view virtual override returns (SenderCreator) { - // return the same senderCreator as real EntryPoint. - // this call is slightly (100) more expensive than EntryPoint's access to immutable member - return _senderCreator; - } - /** * simulation contract should not be deployed, and specifically, accounts should not trust * it as entrypoint, since the simulation functions don't check the signatures @@ -231,9 +218,12 @@ contract EntryPointSimulations is EntryPoint, IEntryPointSimulations { uint256 toleranceDelta, uint256 gasAllowance ) public returns (TargetCallResult memory) { + UserOpInfo memory setupOpInfo; + _copyUserOpToMemory(targetUserOp.op, setupOpInfo.mUserOp); + _validateAccountPrepayment(0, targetUserOp.op, setupOpInfo, 0, gasleft()); + UserOpInfo memory opInfo; bytes memory payload = abi.encodeWithSelector(this._paymasterValidation.selector, 0, targetUserOp.op, opInfo); - return binarySearchGasLimit( queuedUserOps, targetUserOp, entryPoint, initialMinGas, toleranceDelta, gasAllowance, payload ); @@ -404,10 +394,7 @@ contract EntryPointSimulations is EntryPoint, IEntryPointSimulations { return results[ops.length - 1]; } - function _simulationOnlyValidations(PackedUserOperation calldata userOp) internal { - //initialize senderCreator(). we can't rely on constructor - initSenderCreator(); - + function _simulationOnlyValidations(PackedUserOperation calldata userOp) internal view { string memory revertReason = _validateSenderAndPaymaster(userOp.initCode, userOp.sender, userOp.paymasterAndData); // solhint-disable-next-line no-empty-blocks