currentPriorityRequestId variable in collectOnchainOps (Franklin.sol)
@@ -375,7 +375,7 @@ contract Franklin is UpgradeableMaster, Storage, Config, Events {
internal returns (bytes32 withdrawalsDataHash) {
require(_publicData.length % 8 == 0, "fcs11"); // pubdata length must be a multiple of 8 because each chunk is 8 bytes
- uint64 currentCommittedPriorityRequests = 0;
+ uint64 currentPriorityRequestId = firstPriorityRequestId + totalCommittedPriorityRequests;
uint256 pubDataPtr = 0;
uint256 pubDataStartPtr = 0;
@@ -427,8 +427,8 @@ contract Franklin is UpgradeableMaster, Storage, Config, Events {
Operations.OpType.Deposit,
pubData
);
- commitNextPriorityOperation(onchainOp, currentCommittedPriorityRequests);
- currentCommittedPriorityRequests++;
+ commitNextPriorityOperation(onchainOp, currentPriorityRequestId);
+ currentPriorityRequestId++;
pubDataPtr += DEPOSIT_BYTES;
} else if (opType == uint8(Operations.OpType.PartialExit)) {
@@ -451,8 +451,8 @@ contract Franklin is UpgradeableMaster, Storage, Config, Events {
Operations.OpType.FullExit,
pubData
);
- commitNextPriorityOperation(onchainOp, currentCommittedPriorityRequests);
- currentCommittedPriorityRequests++;
+ commitNextPriorityOperation(onchainOp, currentPriorityRequestId);
+ currentPriorityRequestId++;
pubDataPtr += FULL_EXIT_BYTES;
} else if (opType == uint8(Operations.OpType.ChangePubKey)) {
@@ -482,7 +482,8 @@ contract Franklin is UpgradeableMaster, Storage, Config, Events {
require(ethWitnessOffset == _ethWitness.length, "fcs14"); // _ethWitness was not used completely
require(processedOperationsRequiringEthWitness == _ethWitnessSizes.length, "fcs15"); // _ethWitnessSizes was not used completely
- totalCommittedPriorityRequests += currentCommittedPriorityRequests;
+ require(currentPriorityRequestId <= firstPriorityRequestId + totalOpenPriorityRequests, "fcs16"); // fcs16 - excess priority requests in pubdata
+ totalCommittedPriorityRequests = currentPriorityRequestId - firstPriorityRequestId;
}
/// @notice Verifies ethereum signature for given message and recovers address of the signer
@@ -567,12 +568,7 @@ contract Franklin is UpgradeableMaster, Storage, Config, Events {
}
}
- /// @param _currentCommittedPriorityRequests number of currently committed priority operation, which are not yet calculated in totalCommittedPriorityRequests variable
- /// @dev _currentCommittedPriorityRequests is needed to reduce gas outlay: we can update totalCommittedPriorityRequests variable only once during committing priority requests
- function commitNextPriorityOperation(OnchainOperation memory _onchainOp, uint64 _currentCommittedPriorityRequests) internal {
- require(totalOpenPriorityRequests > totalCommittedPriorityRequests, "vnp11"); // no more priority requests in queue
-
- uint64 _priorityRequestId = firstPriorityRequestId + totalCommittedPriorityRequests + _currentCommittedPriorityRequests;
+ function commitNextPriorityOperation(OnchainOperation memory _onchainOp, uint64 _priorityRequestId) internal {
Operations.OpType priorReqType = priorityRequests[_priorityRequestId].opType;
bytes memory priorReqPubdata = priorityRequests[_priorityRequestId].pubData;
