Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C4 539 - Unsigned Integer Comparison #177

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contracts/core/EntryPoint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ contract EntryPoint is IEntryPoint, StakeManager {
}

IPaymaster.PostOpMode mode = IPaymaster.PostOpMode.opSucceeded;
if (callData.length > 0) {
if (callData.length != 0) {
bool success = Exec.call(mUserOp.sender, 0, callData, callGasLimit);
if (!success) {
bytes memory result = Exec.getReturnData(REVERT_REASON_MAX_LEN);
if (result.length > 0) {
if (result.length != 0) {
emit UserOperationRevertReason(opInfo.userOpHash, mUserOp.sender, mUserOp.nonce, result);
}
mode = IPaymaster.PostOpMode.opReverted;
Expand Down Expand Up @@ -259,7 +259,7 @@ contract EntryPoint is IEntryPoint, StakeManager {
mUserOp.maxFeePerGas = userOp.maxFeePerGas;
mUserOp.maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;
bytes calldata paymasterAndData = userOp.paymasterAndData;
if (paymasterAndData.length > 0) {
if (paymasterAndData.length != 0) {
require(paymasterAndData.length >= 20, "AA93 invalid paymasterAndData");
mUserOp.paymaster = address(bytes20(paymasterAndData[: 20]));
} else {
Expand Down Expand Up @@ -540,7 +540,7 @@ contract EntryPoint is IEntryPoint, StakeManager {
refundAddress = mUserOp.sender;
} else {
refundAddress = paymaster;
if (context.length > 0) {
if (context.length != 0) {
actualGasCost = actualGas * gasPrice;
if (mode != IPaymaster.PostOpMode.postOpReverted) {
IPaymaster(paymaster).postOp{gas : mUserOp.verificationGasLimit}(mode, context, actualGasCost);
Expand Down
8 changes: 4 additions & 4 deletions contracts/core/StakeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ abstract contract StakeManager is IStakeManager {
*/
function addStake(uint32 _unstakeDelaySec) public payable {
DepositInfo storage info = deposits[msg.sender];
require(_unstakeDelaySec > 0, "must specify unstake delay");
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 != 0, "no stake specified");
require(stake < type(uint112).max, "stake overflow");
deposits[msg.sender] = DepositInfo(
info.deposit,
Expand Down Expand Up @@ -96,8 +96,8 @@ abstract contract StakeManager is IStakeManager {
function withdrawStake(address payable withdrawAddress) external {
DepositInfo storage info = deposits[msg.sender];
uint256 stake = info.stake;
require(stake > 0, "No stake to withdraw");
require(info.withdrawTime > 0, "must call unlockStake() first");
require(stake != 0, "No stake to withdraw");
require(info.withdrawTime != 0, "must call unlockStake() first");
require(info.withdrawTime <= block.timestamp, "Stake withdrawal is not due");
info.unstakeDelaySec = 0;
info.withdrawTime = 0;
Expand Down
18 changes: 9 additions & 9 deletions reports/gas-checker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple │ 1 │ 78122 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple - diff from previous │ 2 │ │ 4359612551
║ simple - diff from previous │ 2 │ │ 4358412539
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple │ 10 │ 470595 │ │ ║
║ simple │ 10 │ 470643 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple - diff from previous │ 11 │ │ 4374312698
║ simple - diff from previous │ 11 │ │ 4371912674
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster │ 1 │ 78122 │ │ ║
║ simple paymaster │ 1 │ 78110 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster with diff │ 2 │ │ 4359612551
║ simple paymaster with diff │ 2 │ │ 4360812563
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster │ 10 │ 470619 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ simple paymaster with diff │ 11 │ │ 4371912674
║ simple paymaster with diff │ 11 │ │ 4374312698
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx 5k │ 1 │ 179857 │ │ ║
║ big tx 5k │ 1 │ 179845 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx - diff from previous │ 2 │ │ 14493317638
║ big tx - diff from previous │ 2 │ │ 14494517650
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx 5k │ 10 │ 1489775 │ │ ║
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
║ big tx - diff from previous │ 11 │ │ 14642619131
║ big tx - diff from previous │ 11 │ │ 14641419119
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝