Skip to content

Commit b2982a9

Browse files
fix: change less than = 0 in contracts to == 0to reduce gas costs when the number is unsigned (yetanotherco#892)
1 parent 80cbc1a commit b2982a9

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/src/core/AlignedLayerServiceManager.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ contract AlignedLayerServiceManager is
6767
);
6868
}
6969

70-
if (batchersBalances[msg.sender] <= 0) {
70+
if (batchersBalances[msg.sender] == 0) {
7171
revert BatcherBalanceIsEmpty(msg.sender);
7272
}
7373

@@ -111,7 +111,7 @@ contract AlignedLayerServiceManager is
111111
revert BatchAlreadyResponded(batchIdentifierHash);
112112
}
113113

114-
if (batchersBalances[senderAddress] <= 0) {
114+
if (batchersBalances[senderAddress] == 0) {
115115
revert BatcherHasNoBalance(senderAddress);
116116
}
117117

@@ -228,7 +228,7 @@ contract AlignedLayerServiceManager is
228228
}
229229

230230
function _depositToBatcher(address account, uint256 amount) internal {
231-
if (amount <= 0) {
231+
if (amount == 0) {
232232
revert InvalidDepositAmount(amount);
233233
}
234234
batchersBalances[account] += amount;

contracts/src/core/BatcherPaymentService.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ contract BatcherPaymentService is
117117
uint256 feeForAggregator = gasForAggregator * tx.gasprice;
118118
uint256 feePerProof = gasPerProof * tx.gasprice;
119119

120-
if (leavesQty <= 0) {
120+
if (leavesQty == 0) {
121121
revert NoLeavesSubmitted();
122122
}
123123

124-
if (signaturesQty <= 0) {
124+
if (signaturesQty == 0) {
125125
revert NoProofSubmitterSignatures();
126126
}
127127

@@ -133,11 +133,11 @@ contract BatcherPaymentService is
133133
revert LeavesNotPowerOfTwo(leavesQty);
134134
}
135135

136-
if (feeForAggregator <= 0) {
136+
if (feeForAggregator == 0) {
137137
revert NoGasForAggregator();
138138
}
139139

140-
if (feePerProof <= 0) {
140+
if (feePerProof == 0) {
141141
revert NoGasPerProof();
142142
}
143143

@@ -170,7 +170,7 @@ contract BatcherPaymentService is
170170
}
171171

172172
function unlock() external whenNotPaused {
173-
if (userData[msg.sender].balance <= 0) {
173+
if (userData[msg.sender].balance == 0) {
174174
revert UserHasNoFundsToUnlock(msg.sender);
175175
}
176176

@@ -179,7 +179,7 @@ contract BatcherPaymentService is
179179
}
180180

181181
function lock() external whenNotPaused {
182-
if (userData[msg.sender].balance <= 0) {
182+
if (userData[msg.sender].balance == 0) {
183183
revert UserHasNoFundsToLock(msg.sender);
184184
}
185185
userData[msg.sender].unlockBlock = 0;

0 commit comments

Comments
 (0)