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

fix: change less than = 0 in contracts to == 0to reduce gas costs when the number is unsigned #892

Merged
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

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions contracts/src/core/AlignedLayerServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ contract AlignedLayerServiceManager is
);
}

if (batchersBalances[msg.sender] <= 0) {
if (batchersBalances[msg.sender] == 0) {
revert BatcherBalanceIsEmpty(msg.sender);
}

Expand Down Expand Up @@ -111,7 +111,7 @@ contract AlignedLayerServiceManager is
revert BatchAlreadyResponded(batchIdentifierHash);
}

if (batchersBalances[senderAddress] <= 0) {
if (batchersBalances[senderAddress] == 0) {
revert BatcherHasNoBalance(senderAddress);
}

Expand Down Expand Up @@ -228,7 +228,7 @@ contract AlignedLayerServiceManager is
}

function _depositToBatcher(address account, uint256 amount) internal {
if (amount <= 0) {
if (amount == 0) {
revert InvalidDepositAmount(amount);
}
batchersBalances[account] += amount;
Expand Down
12 changes: 6 additions & 6 deletions contracts/src/core/BatcherPaymentService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ contract BatcherPaymentService is
uint256 feeForAggregator = gasForAggregator * tx.gasprice;
uint256 feePerProof = gasPerProof * tx.gasprice;

if (leavesQty <= 0) {
if (leavesQty == 0) {
revert NoLeavesSubmitted();
}

if (signaturesQty <= 0) {
if (signaturesQty == 0) {
revert NoProofSubmitterSignatures();
}

Expand All @@ -133,11 +133,11 @@ contract BatcherPaymentService is
revert LeavesNotPowerOfTwo(leavesQty);
}

if (feeForAggregator <= 0) {
if (feeForAggregator == 0) {
revert NoGasForAggregator();
}

if (feePerProof <= 0) {
if (feePerProof == 0) {
revert NoGasPerProof();
}

Expand Down Expand Up @@ -170,7 +170,7 @@ contract BatcherPaymentService is
}

function unlock() external whenNotPaused {
if (userData[msg.sender].balance <= 0) {
if (userData[msg.sender].balance == 0) {
revert UserHasNoFundsToUnlock(msg.sender);
}

Expand All @@ -179,7 +179,7 @@ contract BatcherPaymentService is
}

function lock() external whenNotPaused {
if (userData[msg.sender].balance <= 0) {
if (userData[msg.sender].balance == 0) {
revert UserHasNoFundsToLock(msg.sender);
}
userData[msg.sender].unlockBlock = 0;
Expand Down
Loading