Skip to content

Commit 0e1820b

Browse files
committed
Revert SM contract format
1 parent ffb0bae commit 0e1820b

1 file changed

Lines changed: 82 additions & 25 deletions

File tree

contracts/src/core/AlignedLayerServiceManager.sol

Lines changed: 82 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ contract AlignedLayerServiceManager is
2929
IStakeRegistry __stakeRegistry
3030
)
3131
BLSSignatureChecker(__registryCoordinator)
32-
ServiceManagerBase(__avsDirectory, __rewardsCoordinator, __registryCoordinator, __stakeRegistry)
32+
ServiceManagerBase(
33+
__avsDirectory,
34+
__rewardsCoordinator,
35+
__registryCoordinator,
36+
__stakeRegistry
37+
)
3338
{
3439
if (address(__avsDirectory) == address(0)) {
3540
revert InvalidAddress("avsDirectory");
@@ -68,27 +73,39 @@ contract AlignedLayerServiceManager is
6873
// This function is to be run only on upgrade
6974
// If a new contract is deployed, this function should be removed
7075
// Because this new value is also added in the initializer
71-
function initializeAggregator(address _alignedAggregator) public reinitializer(2) {
76+
function initializeAggregator(
77+
address _alignedAggregator
78+
) public reinitializer(2) {
7279
setAggregator(_alignedAggregator);
7380
}
7481

75-
function createNewTask(bytes32 batchMerkleRoot, string calldata batchDataPointer, uint256 respondToTaskFeeLimit)
76-
external
77-
payable
78-
{
79-
bytes32 batchIdentifier = keccak256(abi.encodePacked(batchMerkleRoot, msg.sender));
82+
function createNewTask(
83+
bytes32 batchMerkleRoot,
84+
string calldata batchDataPointer,
85+
uint256 respondToTaskFeeLimit
86+
) external payable {
87+
bytes32 batchIdentifier = keccak256(
88+
abi.encodePacked(batchMerkleRoot, msg.sender)
89+
);
8090

8191
if (batchesState[batchIdentifier].taskCreatedBlock != 0) {
8292
revert BatchAlreadySubmitted(batchIdentifier);
8393
}
8494

8595
if (msg.value > 0) {
8696
batchersBalances[msg.sender] += msg.value;
87-
emit BatcherBalanceUpdated(msg.sender, batchersBalances[msg.sender]);
97+
emit BatcherBalanceUpdated(
98+
msg.sender,
99+
batchersBalances[msg.sender]
100+
);
88101
}
89102

90103
if (batchersBalances[msg.sender] < respondToTaskFeeLimit) {
91-
revert InsufficientFunds(msg.sender, respondToTaskFeeLimit, batchersBalances[msg.sender]);
104+
revert InsufficientFunds(
105+
msg.sender,
106+
respondToTaskFeeLimit,
107+
batchersBalances[msg.sender]
108+
);
92109
}
93110

94111
BatchState memory batchState;
@@ -100,7 +117,13 @@ contract AlignedLayerServiceManager is
100117
batchesState[batchIdentifier] = batchState;
101118

102119
// For aggregator and operators in v0.7.0
103-
emit NewBatchV3(batchMerkleRoot, msg.sender, uint32(block.number), batchDataPointer, respondToTaskFeeLimit);
120+
emit NewBatchV3(
121+
batchMerkleRoot,
122+
msg.sender,
123+
uint32(block.number),
124+
batchDataPointer,
125+
respondToTaskFeeLimit
126+
);
104127
}
105128

106129
function respondToTaskV2(
@@ -111,7 +134,9 @@ contract AlignedLayerServiceManager is
111134
) external onlyAggregator {
112135
uint256 initialGasLeft = gasleft();
113136

114-
bytes32 batchIdentifierHash = keccak256(abi.encodePacked(batchMerkleRoot, senderAddress));
137+
bytes32 batchIdentifierHash = keccak256(
138+
abi.encodePacked(batchMerkleRoot, senderAddress)
139+
);
115140

116141
BatchState storage currentBatch = batchesState[batchIdentifierHash];
117142

@@ -129,23 +154,33 @@ contract AlignedLayerServiceManager is
129154

130155
// Check that batcher has enough funds to fund response
131156
if (batchersBalances[senderAddress] < currentBatch.respondToTaskFeeLimit) {
132-
revert InsufficientFunds(senderAddress, currentBatch.respondToTaskFeeLimit, batchersBalances[senderAddress]);
157+
revert InsufficientFunds(
158+
senderAddress,
159+
currentBatch.respondToTaskFeeLimit,
160+
batchersBalances[senderAddress]
161+
);
133162
}
134163

135164
/* CHECKING SIGNATURES & WHETHER THRESHOLD IS MET OR NOT */
136165

137166
// check that aggregated BLS signature is valid
138-
(QuorumStakeTotals memory quorumStakeTotals,) =
139-
checkSignatures(batchIdentifierHash, currentBatch.taskCreatedBlock, nonSignerStakesAndSignature);
167+
(QuorumStakeTotals memory quorumStakeTotals, ) = checkSignatures(
168+
batchIdentifierHash,
169+
currentBatch.taskCreatedBlock,
170+
nonSignerStakesAndSignature
171+
);
140172

141173
// check that signatories own at least a threshold percentage of each quourm
142174
if (
143-
quorumStakeTotals.signedStakeForQuorum[0] * THRESHOLD_DENOMINATOR
144-
< quorumStakeTotals.totalStakeForQuorum[0] * QUORUM_THRESHOLD_PERCENTAGE
175+
quorumStakeTotals.signedStakeForQuorum[0] * THRESHOLD_DENOMINATOR <
176+
quorumStakeTotals.totalStakeForQuorum[0] *
177+
QUORUM_THRESHOLD_PERCENTAGE
145178
) {
146179
revert InvalidQuorumThreshold(
147-
quorumStakeTotals.signedStakeForQuorum[0] * THRESHOLD_DENOMINATOR,
148-
quorumStakeTotals.totalStakeForQuorum[0] * QUORUM_THRESHOLD_PERCENTAGE
180+
quorumStakeTotals.signedStakeForQuorum[0] *
181+
THRESHOLD_DENOMINATOR,
182+
quorumStakeTotals.totalStakeForQuorum[0] *
183+
QUORUM_THRESHOLD_PERCENTAGE
149184
);
150185
}
151186

@@ -155,7 +190,10 @@ contract AlignedLayerServiceManager is
155190
uint256 txCost = (initialGasLeft - gasleft() + 70_000) * tx.gasprice;
156191

157192
if (txCost > currentBatch.respondToTaskFeeLimit) {
158-
revert ExceededMaxRespondFee(currentBatch.respondToTaskFeeLimit, txCost);
193+
revert ExceededMaxRespondFee(
194+
currentBatch.respondToTaskFeeLimit,
195+
txCost
196+
);
159197
}
160198

161199
// Subtract the txCost from the batcher's balance
@@ -182,7 +220,9 @@ contract AlignedLayerServiceManager is
182220
if (senderAddress == address(0)) {
183221
batchIdentifier = batchMerkleRoot;
184222
} else {
185-
batchIdentifier = keccak256(abi.encodePacked(batchMerkleRoot, senderAddress));
223+
batchIdentifier = keccak256(
224+
abi.encodePacked(batchMerkleRoot, senderAddress)
225+
);
186226
}
187227

188228
if (batchesState[batchIdentifier].taskCreatedBlock == 0) {
@@ -193,12 +233,22 @@ contract AlignedLayerServiceManager is
193233
return false;
194234
}
195235

196-
bytes memory leaf =
197-
abi.encodePacked(proofCommitment, pubInputCommitment, provingSystemAuxDataCommitment, proofGeneratorAddr);
236+
bytes memory leaf = abi.encodePacked(
237+
proofCommitment,
238+
pubInputCommitment,
239+
provingSystemAuxDataCommitment,
240+
proofGeneratorAddr
241+
);
198242

199243
bytes32 hashedLeaf = keccak256(leaf);
200244

201-
return Merkle.verifyInclusionKeccak(merkleProof, batchMerkleRoot, hashedLeaf, verificationDataBatchIndex);
245+
return
246+
Merkle.verifyInclusionKeccak(
247+
merkleProof,
248+
batchMerkleRoot,
249+
hashedLeaf,
250+
verificationDataBatchIndex
251+
);
202252
}
203253

204254
// Old function signature for backwards compatibility
@@ -230,7 +280,11 @@ contract AlignedLayerServiceManager is
230280

231281
function withdraw(uint256 amount) external {
232282
if (batchersBalances[msg.sender] < amount) {
233-
revert InsufficientFunds(msg.sender, amount, batchersBalances[msg.sender]);
283+
revert InsufficientFunds(
284+
msg.sender,
285+
amount,
286+
batchersBalances[msg.sender]
287+
);
234288
}
235289

236290
batchersBalances[msg.sender] -= amount;
@@ -259,7 +313,10 @@ contract AlignedLayerServiceManager is
259313
_depositToBatcher(msg.sender, msg.value);
260314
}
261315

262-
function checkPublicInput(bytes calldata publicInput, bytes32 hash) public pure returns (bool) {
316+
function checkPublicInput(
317+
bytes calldata publicInput,
318+
bytes32 hash
319+
) public pure returns (bool) {
263320
return keccak256(publicInput) == hash;
264321
}
265322

0 commit comments

Comments
 (0)