mirror of
https://github.com/getwax/zk-account-abstraction.git
synced 2026-01-09 20:47:58 -05:00
AA-138 N-07 rename vars and internal methods (#221)
* N-07 rename vars and internal methods
This commit is contained in:
@@ -17,7 +17,7 @@ abstract contract BaseAccount is IAccount {
|
||||
using UserOperationLib for UserOperation;
|
||||
|
||||
//return value in case of signature failure, with no time-range.
|
||||
// equivalent to packSigTimeRange(true,0,0);
|
||||
// equivalent to _packSigTimeRange(true,0,0);
|
||||
uint256 constant internal SIG_VALIDATION_FAILED = 1;
|
||||
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ abstract contract BaseAccount is IAccount {
|
||||
* @param validUntil last timestamp this UserOperation is valid (or zero for infinite)
|
||||
* @param validAfter first timestamp this UserOperation is valid
|
||||
*/
|
||||
function packSigTimeRange(bool sigFailed, uint64 validUntil, uint64 validAfter) internal pure returns (uint256) {
|
||||
function _packSigTimeRange(bool sigFailed, uint64 validUntil, uint64 validAfter) internal pure returns (uint256) {
|
||||
return uint256(sigFailed ? 1 : 0) | (uint256(validUntil) << 8) | (uint256(validAfter) << 64+8);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ abstract contract BasePaymaster is IPaymaster, Ownable {
|
||||
* @param validUntil last timestamp this UserOperation is valid (or zero for infinite)
|
||||
* @param validAfter first timestamp this UserOperation is valid
|
||||
*/
|
||||
function packSigTimeRange(bool sigFailed, uint64 validUntil, uint64 validAfter) internal pure returns (uint256) {
|
||||
function _packSigTimeRange(bool sigFailed, uint64 validUntil, uint64 validAfter) internal pure returns (uint256) {
|
||||
return uint256(sigFailed ? 1 : 0) | (uint256(validUntil) << 8) | (uint256(validAfter) << 64 + 8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ contract EntryPoint is IEntryPoint, StakeManager {
|
||||
/**
|
||||
* Execute a batch of UserOperation.
|
||||
* no signature aggregator is used.
|
||||
* if any account requires an aggregator (that is, it returned an "actualAggregator" when
|
||||
* if any account requires an aggregator (that is, it returned an aggregator when
|
||||
* performing simulateValidation), then handleAggregatedOps() must be used instead.
|
||||
* @param ops the operations to execute
|
||||
* @param beneficiary the address to receive the fees
|
||||
@@ -286,13 +286,13 @@ contract EntryPoint is IEntryPoint, StakeManager {
|
||||
UserOpInfo memory outOpInfo;
|
||||
|
||||
(uint256 sigTimeRange, uint256 paymasterTimeRange, address aggregator) = _validatePrepayment(0, userOp, outOpInfo, SIMULATE_FIND_AGGREGATOR);
|
||||
StakeInfo memory paymasterInfo = getStakeInfo(outOpInfo.mUserOp.paymaster);
|
||||
StakeInfo memory senderInfo = getStakeInfo(outOpInfo.mUserOp.sender);
|
||||
StakeInfo memory paymasterInfo = _getStakeInfo(outOpInfo.mUserOp.paymaster);
|
||||
StakeInfo memory senderInfo = _getStakeInfo(outOpInfo.mUserOp.sender);
|
||||
StakeInfo memory factoryInfo;
|
||||
{
|
||||
bytes calldata initCode = userOp.initCode;
|
||||
address factory = initCode.length >= 20 ? address(bytes20(initCode[0 : 20])) : address(0);
|
||||
factoryInfo = getStakeInfo(factory);
|
||||
factoryInfo = _getStakeInfo(factory);
|
||||
}
|
||||
|
||||
(bool sigFailed, uint64 validAfter, uint64 validUntil) = _intersectTimeRange(sigTimeRange, paymasterTimeRange);
|
||||
@@ -300,7 +300,7 @@ contract EntryPoint is IEntryPoint, StakeManager {
|
||||
sigFailed, validAfter, validUntil, getMemoryBytesFromOffset(outOpInfo.contextOffset));
|
||||
|
||||
if (aggregator != address(0)) {
|
||||
AggregatorStakeInfo memory aggregatorInfo = AggregatorStakeInfo(aggregator, getStakeInfo(aggregator));
|
||||
AggregatorStakeInfo memory aggregatorInfo = AggregatorStakeInfo(aggregator, _getStakeInfo(aggregator));
|
||||
revert ValidationResultWithAggregation(returnInfo, senderInfo, factoryInfo, paymasterInfo, aggregatorInfo);
|
||||
}
|
||||
revert ValidationResult(returnInfo, senderInfo, factoryInfo, paymasterInfo);
|
||||
@@ -601,7 +601,7 @@ contract EntryPoint is IEntryPoint, StakeManager {
|
||||
revert FailedOp(opIndex, paymaster, "A51 prefund below actualGasCost");
|
||||
}
|
||||
uint256 refund = opInfo.prefund - actualGasCost;
|
||||
internalIncrementDeposit(refundAddress, refund);
|
||||
_incrementDeposit(refundAddress, refund);
|
||||
bool success = mode == IPaymaster.PostOpMode.opSucceeded;
|
||||
emit UserOperationEvent(opInfo.userOpHash, mUserOp.sender, mUserOp.paymaster, mUserOp.nonce, success, actualGasCost, actualGas);
|
||||
} // unchecked
|
||||
|
||||
@@ -13,12 +13,12 @@ contract SenderCreator {
|
||||
* @return sender the returned address of the created account, or zero address on failure.
|
||||
*/
|
||||
function createSender(bytes calldata initCode) external returns (address sender) {
|
||||
address initAddress = address(bytes20(initCode[0 : 20]));
|
||||
address factory = address(bytes20(initCode[0 : 20]));
|
||||
bytes memory initCallData = initCode[20 :];
|
||||
bool success;
|
||||
/* solhint-disable no-inline-assembly */
|
||||
assembly {
|
||||
success := call(gas(), initAddress, 0, add(initCallData, 0x20), mload(initCallData), 0, 32)
|
||||
success := call(gas(), factory, 0, add(initCallData, 0x20), mload(initCallData), 0, 32)
|
||||
sender := mload(0)
|
||||
}
|
||||
if (!success) {
|
||||
|
||||
@@ -21,7 +21,7 @@ abstract contract StakeManager is IStakeManager {
|
||||
}
|
||||
|
||||
// internal method to return just the stake info
|
||||
function getStakeInfo(address addr) internal view returns (StakeInfo memory info) {
|
||||
function _getStakeInfo(address addr) internal view returns (StakeInfo memory info) {
|
||||
DepositInfo storage depositInfo = deposits[addr];
|
||||
info.stake = depositInfo.stake;
|
||||
info.unstakeDelaySec = depositInfo.unstakeDelaySec;
|
||||
@@ -36,7 +36,7 @@ abstract contract StakeManager is IStakeManager {
|
||||
depositTo(msg.sender);
|
||||
}
|
||||
|
||||
function internalIncrementDeposit(address account, uint256 amount) internal {
|
||||
function _incrementDeposit(address account, uint256 amount) internal {
|
||||
DepositInfo storage info = deposits[account];
|
||||
uint256 newAmount = info.deposit + amount;
|
||||
require(newAmount <= type(uint112).max, "deposit overflow");
|
||||
@@ -47,7 +47,7 @@ abstract contract StakeManager is IStakeManager {
|
||||
* add to the deposit of the given account
|
||||
*/
|
||||
function depositTo(address account) public payable {
|
||||
internalIncrementDeposit(account, msg.value);
|
||||
_incrementDeposit(account, msg.value);
|
||||
DepositInfo storage info = deposits[account];
|
||||
emit Deposited(account, info.deposit);
|
||||
}
|
||||
@@ -55,12 +55,12 @@ abstract contract StakeManager is IStakeManager {
|
||||
/**
|
||||
* add to the account's stake - amount and delay
|
||||
* any pending unstake is first cancelled.
|
||||
* @param _unstakeDelaySec the new lock duration before the deposit can be withdrawn.
|
||||
* @param unstakeDelaySec the new lock duration before the deposit can be withdrawn.
|
||||
*/
|
||||
function addStake(uint32 _unstakeDelaySec) public payable {
|
||||
function addStake(uint32 unstakeDelaySec) public payable {
|
||||
DepositInfo storage info = deposits[msg.sender];
|
||||
require(_unstakeDelaySec > 0, "must specify unstake delay");
|
||||
require(_unstakeDelaySec >= info.unstakeDelaySec, "cannot decrease unstake time");
|
||||
require(unstakeDelaySec > 0, "must specify unstake delay");
|
||||
require(unstakeDelaySec >= info.unstakeDelaySec, "cannot decrease unstake time");
|
||||
uint256 stake = info.stake + msg.value;
|
||||
require(stake > 0, "no stake specified");
|
||||
require(stake <= type(uint112).max, "stake overflow");
|
||||
@@ -68,10 +68,10 @@ abstract contract StakeManager is IStakeManager {
|
||||
info.deposit,
|
||||
true,
|
||||
uint112(stake),
|
||||
_unstakeDelaySec,
|
||||
unstakeDelaySec,
|
||||
0
|
||||
);
|
||||
emit StakeLocked(msg.sender, stake, _unstakeDelaySec);
|
||||
emit StakeLocked(msg.sender, stake, unstakeDelaySec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,7 @@ interface IAggregator {
|
||||
* This method is called off-chain to calculate the signature to pass with handleOps()
|
||||
* bundler MAY use optimized custom code perform this aggregation
|
||||
* @param userOps array of UserOperations to collect the signatures from.
|
||||
* @return aggregatesSignature the aggregated signature
|
||||
* @return aggregatedSignature the aggregated signature
|
||||
*/
|
||||
function aggregateSignatures(UserOperation[] calldata userOps) external view returns (bytes memory aggregatesSignature);
|
||||
function aggregateSignatures(UserOperation[] calldata userOps) external view returns (bytes memory aggregatedSignature);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ interface IEntryPoint is IStakeManager {
|
||||
/**
|
||||
* return value of simulateHandleOp
|
||||
*/
|
||||
error ExecutionResult(uint256 preOpGas, uint256 paid, uint64 validAfter, uint64 validBefore, bool targetSuccess, bytes targetResult);
|
||||
error ExecutionResult(uint256 preOpGas, uint256 paid, uint64 validAfter, uint64 validUntil, bool targetSuccess, bytes targetResult);
|
||||
|
||||
//UserOps handled, per aggregator
|
||||
struct UserOpsPerAggregator {
|
||||
@@ -113,7 +113,7 @@ interface IEntryPoint is IStakeManager {
|
||||
/**
|
||||
* Execute a batch of UserOperation.
|
||||
* no signature aggregator is used.
|
||||
* if any account requires an aggregator (that is, it returned an "actualAggregator" when
|
||||
* if any account requires an aggregator (that is, it returned an aggregator when
|
||||
* performing simulateValidation), then handleAggregatedOps() must be used instead.
|
||||
* @param ops the operations to execute
|
||||
* @param beneficiary the address to receive the fees
|
||||
@@ -167,7 +167,7 @@ interface IEntryPoint is IStakeManager {
|
||||
* the aggregator returned by the account, and its current stake.
|
||||
*/
|
||||
struct AggregatorStakeInfo {
|
||||
address actualAggregator;
|
||||
address aggregator;
|
||||
StakeInfo stakeInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,8 @@ contract BLSSignatureAggregator is IAggregator {
|
||||
* the account checks the signature over this value using its public-key
|
||||
*/
|
||||
function userOpToMessage(UserOperation memory userOp) public view returns (uint256[2] memory) {
|
||||
bytes32 hashPublicKey = _getPublicKeyHash(getUserOpPublicKey(userOp));
|
||||
return _userOpToMessage(userOp, hashPublicKey);
|
||||
bytes32 publicKeyHash = _getPublicKeyHash(getUserOpPublicKey(userOp));
|
||||
return _userOpToMessage(userOp, publicKeyHash);
|
||||
}
|
||||
|
||||
function _userOpToMessage(UserOperation memory userOp, bytes32 publicKeyHash) internal view returns (uint256[2] memory) {
|
||||
@@ -106,12 +106,12 @@ contract BLSSignatureAggregator is IAggregator {
|
||||
|
||||
// helper for test
|
||||
function getUserOpHash(UserOperation memory userOp) public view returns (bytes32) {
|
||||
bytes32 hashPublicKey = _getPublicKeyHash(getUserOpPublicKey(userOp));
|
||||
return _getUserOpHash(userOp, hashPublicKey);
|
||||
bytes32 publicKeyHash = _getPublicKeyHash(getUserOpPublicKey(userOp));
|
||||
return _getUserOpHash(userOp, publicKeyHash);
|
||||
}
|
||||
|
||||
function _getUserOpHash(UserOperation memory userOp, bytes32 hashPublicKey) internal view returns (bytes32) {
|
||||
return keccak256(abi.encode(internalUserOpHash(userOp), hashPublicKey, address(this), block.chainid));
|
||||
function _getUserOpHash(UserOperation memory userOp, bytes32 publicKeyHash) internal view returns (bytes32) {
|
||||
return keccak256(abi.encode(internalUserOpHash(userOp), publicKeyHash, address(this), block.chainid));
|
||||
}
|
||||
|
||||
function _getPublicKeyHash(uint256[4] memory publicKey) internal pure returns(bytes32) {
|
||||
@@ -141,9 +141,9 @@ contract BLSSignatureAggregator is IAggregator {
|
||||
* This method is called off-chain to calculate the signature to pass with handleOps()
|
||||
* bundler MAY use optimized custom code perform this aggregation
|
||||
* @param userOps array of UserOperations to collect the signatures from.
|
||||
* @return aggregatesSignature the aggregated signature
|
||||
* @return aggregatedSignature the aggregated signature
|
||||
*/
|
||||
function aggregateSignatures(UserOperation[] calldata userOps) external pure returns (bytes memory aggregatesSignature) {
|
||||
function aggregateSignatures(UserOperation[] calldata userOps) external pure returns (bytes memory aggregatedSignature) {
|
||||
BLSHelper.XY[] memory points = new BLSHelper.XY[](userOps.length);
|
||||
for (uint i = 0; i < points.length; i++) {
|
||||
(uint256 x, uint256 y) = abi.decode(userOps[i].signature, (uint256, uint256));
|
||||
|
||||
@@ -26,7 +26,7 @@ contract EIP4337Manager is GnosisSafe, IAccount {
|
||||
address public immutable entryPoint;
|
||||
|
||||
// return value in case of signature failure, with no time-range.
|
||||
// equivalent to packSigTimeRange(true,0,0);
|
||||
// equivalent to _packSigTimeRange(true,0,0);
|
||||
uint256 constant internal SIG_VALIDATION_FAILED = 1;
|
||||
|
||||
constructor(address anEntryPoint) {
|
||||
@@ -39,8 +39,8 @@ contract EIP4337Manager is GnosisSafe, IAccount {
|
||||
*/
|
||||
function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, address /*aggregator*/, uint256 missingAccountFunds)
|
||||
external override returns (uint256 sigTimeRange) {
|
||||
address _msgSender = address(bytes20(msg.data[msg.data.length - 20 :]));
|
||||
require(_msgSender == entryPoint, "account: not from entrypoint");
|
||||
address msgSender = address(bytes20(msg.data[msg.data.length - 20 :]));
|
||||
require(msgSender == entryPoint, "account: not from entrypoint");
|
||||
|
||||
GnosisSafe pThis = GnosisSafe(payable(address(this)));
|
||||
bytes32 hash = userOpHash.toEthSignedMessageHash();
|
||||
@@ -56,7 +56,7 @@ contract EIP4337Manager is GnosisSafe, IAccount {
|
||||
|
||||
if (missingAccountFunds > 0) {
|
||||
//Note: MAY pay more than the minimum, to deposit for future transactions
|
||||
(bool success,) = payable(_msgSender).call{value : missingAccountFunds}("");
|
||||
(bool success,) = payable(msgSender).call{value : missingAccountFunds}("");
|
||||
(success);
|
||||
//ignore failure (its EntryPoint's job to verify, not account.)
|
||||
}
|
||||
@@ -75,8 +75,8 @@ contract EIP4337Manager is GnosisSafe, IAccount {
|
||||
bytes memory data,
|
||||
Enum.Operation operation
|
||||
) external {
|
||||
address _msgSender = address(bytes20(msg.data[msg.data.length - 20 :]));
|
||||
require(_msgSender == entryPoint, "account: not from entrypoint");
|
||||
address msgSender = address(bytes20(msg.data[msg.data.length - 20 :]));
|
||||
require(msgSender == entryPoint, "account: not from entrypoint");
|
||||
|
||||
(bool success, bytes memory returnData) = execTransactionFromModuleReturnData(to, value, data, operation);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ contract TestExpirePaymaster is BasePaymaster {
|
||||
returns (bytes memory context, uint256 sigTimeRange) {
|
||||
(userOp, userOpHash, maxCost);
|
||||
(uint64 validAfter, uint64 validUntil) = abi.decode(userOp.paymasterAndData[20 :], (uint64, uint64));
|
||||
sigTimeRange = packSigTimeRange(false, validUntil, validAfter);
|
||||
sigTimeRange = _packSigTimeRange(false, validUntil, validAfter);
|
||||
context = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,6 @@ contract TestExpiryAccount is SimpleAccount {
|
||||
|
||||
//we have "until" value for all valid owners. so zero means "invalid signature"
|
||||
bool sigFailed = _until == 0;
|
||||
return packSigTimeRange(sigFailed, _until, _after);
|
||||
return _packSigTimeRange(sigFailed, _until, _after);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ contract TestSignatureAggregator is IAggregator {
|
||||
/**
|
||||
* dummy test aggregator: sum all nonce values of UserOps.
|
||||
*/
|
||||
function aggregateSignatures(UserOperation[] calldata userOps) external pure returns (bytes memory aggregatesSignature) {
|
||||
function aggregateSignatures(UserOperation[] calldata userOps) external pure returns (bytes memory aggregatedSignature) {
|
||||
uint sum = 0;
|
||||
for (uint i = 0; i < userOps.length; i++) {
|
||||
sum += userOps[i].nonce;
|
||||
|
||||
@@ -10,26 +10,26 @@
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple │ 1 │ 78111 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple - diff from previous │ 2 │ │ 43573 │ 12528 ║
|
||||
║ simple - diff from previous │ 2 │ │ 43585 │ 12540 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple │ 10 │ 470509 │ │ ║
|
||||
║ simple │ 10 │ 470497 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple - diff from previous │ 11 │ │ 43732 │ 12687 ║
|
||||
║ simple - diff from previous │ 11 │ │ 43780 │ 12735 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple paymaster │ 1 │ 84411 │ │ ║
|
||||
║ simple paymaster │ 1 │ 84387 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple paymaster with diff │ 2 │ │ 42550 │ 11505 ║
|
||||
║ simple paymaster with diff │ 2 │ │ 42598 │ 11553 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple paymaster │ 10 │ 467966 │ │ ║
|
||||
║ simple paymaster │ 10 │ 467930 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ simple paymaster with diff │ 11 │ │ 42758 │ 11713 ║
|
||||
║ simple paymaster with diff │ 11 │ │ 42770 │ 11725 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ big tx 5k │ 1 │ 179846 │ │ ║
|
||||
║ big tx 5k │ 1 │ 179834 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ big tx - diff from previous │ 2 │ │ 144910 │ 17615 ║
|
||||
║ big tx - diff from previous │ 2 │ │ 144934 │ 17639 ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ big tx 5k │ 10 │ 1489653 │ │ ║
|
||||
║ big tx 5k │ 10 │ 1489677 │ │ ║
|
||||
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
|
||||
║ big tx - diff from previous │ 11 │ │ 146379 │ 19084 ║
|
||||
║ big tx - diff from previous │ 11 │ │ 146391 │ 19096 ║
|
||||
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝
|
||||
|
||||
|
||||
@@ -1033,7 +1033,7 @@ describe('EntryPoint', function () {
|
||||
it('simulateValidation should return aggregator and its stake', async () => {
|
||||
await aggregator.addStake(entryPoint.address, 3, { value: TWO_ETH })
|
||||
const { aggregatorInfo } = await entryPoint.callStatic.simulateValidation(userOp).catch(simulationResultWithAggregationCatch)
|
||||
expect(aggregatorInfo.actualAggregator).to.equal(aggregator.address)
|
||||
expect(aggregatorInfo.aggregator).to.equal(aggregator.address)
|
||||
expect(aggregatorInfo.stakeInfo.stake).to.equal(TWO_ETH)
|
||||
expect(aggregatorInfo.stakeInfo.unstakeDelaySec).to.equal(3)
|
||||
})
|
||||
|
||||
@@ -192,7 +192,7 @@ describe('bls account', function () {
|
||||
userOp.signature = hexConcat(sigParts)
|
||||
|
||||
const { aggregatorInfo } = await entrypoint.callStatic.simulateValidation(userOp).catch(simulationResultWithAggregationCatch)
|
||||
expect(aggregatorInfo.actualAggregator).to.eq(blsAgg.address)
|
||||
expect(aggregatorInfo.aggregator).to.eq(blsAgg.address)
|
||||
expect(aggregatorInfo.stakeInfo.stake).to.eq(ONE_ETH)
|
||||
expect(aggregatorInfo.stakeInfo.unstakeDelaySec).to.eq(2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user