@@ -51,12 +51,12 @@ contract AlignedLayerServiceManager is
5151 bytes32 batchMerkleRoot ,
5252 string calldata batchDataPointer
5353 ) external payable {
54- bytes32 batchIdentifierHash = keccak256 (
54+ bytes32 batchIdentifier = keccak256 (
5555 abi.encodePacked (batchMerkleRoot, msg .sender )
5656 );
5757
58- if (batchesState[batchIdentifierHash ].taskCreatedBlock != 0 ) {
59- revert BatchAlreadySubmitted (batchIdentifierHash );
58+ if (batchesState[batchIdentifier ].taskCreatedBlock != 0 ) {
59+ revert BatchAlreadySubmitted (batchIdentifier );
6060 }
6161
6262 if (msg .value > 0 ) {
@@ -76,17 +76,17 @@ contract AlignedLayerServiceManager is
7676 batchState.taskCreatedBlock = uint32 (block .number );
7777 batchState.responded = false ;
7878
79- batchesState[batchIdentifierHash ] = batchState;
79+ batchesState[batchIdentifier ] = batchState;
8080
81- emit NewBatch (
81+ emit NewBatchV2 (
8282 batchMerkleRoot,
8383 msg .sender ,
8484 uint32 (block .number ),
8585 batchDataPointer
8686 );
8787 }
8888
89- function respondToTask (
89+ function respondToTaskV2 (
9090 // (batchMerkleRoot,senderAddress) is signed as a way to verify the batch was right
9191 bytes32 batchMerkleRoot ,
9292 address senderAddress ,
@@ -174,15 +174,20 @@ contract AlignedLayerServiceManager is
174174 uint256 verificationDataBatchIndex ,
175175 address senderAddress
176176 ) external view returns (bool ) {
177- bytes32 batchIdentifierHash = keccak256 (
178- abi.encodePacked (batchMerkleRoot, senderAddress)
179- );
177+ bytes32 batchIdentifier;
178+ if (senderAddress == address (0 )) {
179+ batchIdentifier = batchMerkleRoot;
180+ } else {
181+ batchIdentifier = keccak256 (
182+ abi.encodePacked (batchMerkleRoot, senderAddress)
183+ );
184+ }
180185
181- if (batchesState[batchIdentifierHash ].taskCreatedBlock == 0 ) {
186+ if (batchesState[batchIdentifier ].taskCreatedBlock == 0 ) {
182187 return false ;
183188 }
184189
185- if (! batchesState[batchIdentifierHash ].responded) {
190+ if (! batchesState[batchIdentifier ].responded) {
186191 return false ;
187192 }
188193
@@ -198,12 +203,34 @@ contract AlignedLayerServiceManager is
198203 return
199204 Merkle.verifyInclusionKeccak (
200205 merkleProof,
201- batchIdentifierHash ,
206+ batchMerkleRoot ,
202207 hashedLeaf,
203208 verificationDataBatchIndex
204209 );
205210 }
206211
212+ // Old function signature for backwards compatibility
213+ function verifyBatchInclusion (
214+ bytes32 proofCommitment ,
215+ bytes32 pubInputCommitment ,
216+ bytes32 provingSystemAuxDataCommitment ,
217+ bytes20 proofGeneratorAddr ,
218+ bytes32 batchMerkleRoot ,
219+ bytes memory merkleProof ,
220+ uint256 verificationDataBatchIndex
221+ ) external view returns (bool ) {
222+ return this .verifyBatchInclusion (
223+ proofCommitment,
224+ pubInputCommitment,
225+ provingSystemAuxDataCommitment,
226+ proofGeneratorAddr,
227+ batchMerkleRoot,
228+ merkleProof,
229+ verificationDataBatchIndex,
230+ address (0 )
231+ );
232+ }
233+
207234 function withdraw (uint256 amount ) external {
208235 if (batchersBalances[msg .sender ] < amount) {
209236 revert InsufficientFunds (
0 commit comments