@@ -111,6 +111,79 @@ contract AlignedLayerServiceManager is
111111 );
112112 }
113113
114+ // previous version of this function, for smooth upgradeability
115+ function respondToTask_old (
116+ // Root is signed as a way to verify the batch was right
117+ bytes32 batchMerkleRoot ,
118+ NonSignerStakesAndSignature memory nonSignerStakesAndSignature
119+ ) external {
120+ // batcherAddress [address(0x7969c5eD335650692Bc04293B07F5BF2e7A673C0)] > 0, // Devnet
121+ // batcherAddress [address(0x7577Ec4ccC1E6C529162ec8019A49C13F6DAd98b)] > 0, // Stage
122+ // batcherAddress [address(0x815aeCA64a974297942D2Bbf034ABEe22a38A003)] > 0, // Prod
123+ address batcherAddress = address (0x7969c5eD335650692Bc04293B07F5BF2e7A673C0 );
124+ uint256 initialGasLeft = gasleft ();
125+
126+ /* CHECKING SIGNATURES & WHETHER THRESHOLD IS MET OR NOT */
127+
128+ // Note: This is a hacky solidity way to see that the element exists
129+ // Value 0 would mean that the task is in block 0 so this can't happen.
130+ require (
131+ batchesState[batchMerkleRoot].taskCreatedBlock != 0 ,
132+ "Batch doesn't exists "
133+ );
134+
135+ // Check task hasn't been responsed yet
136+ require (
137+ batchesState[batchMerkleRoot].responded == false ,
138+ "Batch already responded "
139+ );
140+
141+ require (
142+ batchersBalances[batcherAddress] > 0 ,
143+ "Batcher has no balance "
144+ );
145+
146+ batchesState[batchMerkleRoot].responded = true ;
147+
148+ /* CHECKING SIGNATURES & WHETHER THRESHOLD IS MET OR NOT */
149+ // check that aggregated BLS signature is valid
150+ (
151+ QuorumStakeTotals memory quorumStakeTotals ,
152+ bytes32 _hashOfNonSigners
153+ ) = checkSignatures (
154+ batchMerkleRoot,
155+ batchesState[batchMerkleRoot].taskCreatedBlock,
156+ nonSignerStakesAndSignature
157+ );
158+
159+ // check that signatories own at least a threshold percentage of each quourm
160+ require (
161+ quorumStakeTotals.signedStakeForQuorum[0 ] * THRESHOLD_DENOMINATOR >=
162+ quorumStakeTotals.totalStakeForQuorum[0 ] *
163+ QUORUM_THRESHOLD_PERCENTAGE,
164+ "Signatories do not own at least threshold percentage of a quorum "
165+ );
166+
167+ emit BatchVerified (batchMerkleRoot, batcherAddress);
168+
169+ // Calculate estimation of gas used, check that batcher has sufficient funds
170+ // and send transaction cost to aggregator.
171+ uint256 finalGasLeft = gasleft ();
172+ // 70k was measured by trial and error until the aggregator got paid a bit over what it needed
173+ uint256 txCost = (initialGasLeft - finalGasLeft + 70000 ) * tx .gasprice ;
174+
175+ require (
176+ batchersBalances[batcherAddress] >=
177+ txCost,
178+ "Batcher has not sufficient funds for paying this transaction "
179+ );
180+
181+ batchersBalances[
182+ batcherAddress
183+ ] -= txCost;
184+ payable (msg .sender ).transfer (txCost);
185+ }
186+
114187 function respondToTask (
115188 // (batchMerkleRoot,senderAddress) is signed as a way to verify the batch was right
116189 bytes32 batchMerkleRoot ,
0 commit comments