Skip to content

Commit b36763a

Browse files
committed
fix: paying bug in Aligned contract
1 parent 8b37fb8 commit b36763a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

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: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,19 @@ contract AlignedLayerServiceManager is
214214
// 70k was measured by trial and error until the aggregator got paid a bit over what it needed
215215
uint256 txCost = (initialGasLeft - gasleft() + 70_000) * tx.gasprice;
216216

217-
if (txCost > currentBatch.respondToTaskFeeLimit) {
218-
// Subtract the txCost from the batcher's balance
219-
batchersBalances[senderAddress] -= currentBatch.respondToTaskFeeLimit;
220-
} else {
221-
batchersBalances[senderAddress] -= txCost;
222-
}
217+
// limit amount to spend is respondToTaskFeeLimit
218+
// transferAmount = if txCost > currentBatch.respondToTaskFeeLimit -> currentBatch.respondToTaskFeeLimit; else -> txCost
219+
uint256 transferAmount = txCost > currentBatch.respondToTaskFeeLimit ?
220+
currentBatch.respondToTaskFeeLimit : txCost;
221+
222+
batchersBalances[senderAddress] -= transferAmount;
223223

224224
emit BatcherBalanceUpdated(
225225
senderAddress,
226226
batchersBalances[senderAddress]
227227
);
228-
payable(alignedAggregator).transfer(txCost);
228+
229+
payable(alignedAggregator).transfer(transferAmount);
229230
}
230231

231232
function isVerifierDisabled(

0 commit comments

Comments
 (0)