Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TonioMacaronio committed Jan 21, 2020
1 parent a2634d9 commit c67ad94
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions contracts/contracts/Franklin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ contract Franklin {
/// @notice Accrues users balances from deposit priority requests in Exodus mode
/// @dev WARNING: Only for Exodus mode
/// @dev Canceling may take several separate transactions to be completed
/// @dev popOutstandingDeposits returns only limited number of deposits so as not to go beyond the block gas limit
function cancelOutstandingDepositsForExodusMode() external {
/// @param _number Supposed number of requests to look at
function cancelOutstandingDepositsForExodusMode(uint64 _number) external {
require(
exodusMode,
"frс11"
); // frс11 - exodus mode is not activated
bytes memory depositsPubData = priorityQueue.popOutstandingDeposits();
bytes memory depositsPubData = priorityQueue.deletePriorityRequestsAndPopOutstandingDeposits(_number);
uint64 i = 0;
while (i < depositsPubData.length) {
bytes memory deposit = Bytes.slice(depositsPubData, i, ETH_ADDR_BYTES+TOKEN_BYTES+AMOUNT_BYTES);
Expand Down
20 changes: 10 additions & 10 deletions contracts/contracts/PriorityQueue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,27 @@ contract PriorityQueue {
}

/// @notice Concates open (outstanding) deposit requests public data up to defined deposits number
/// @dev Deletes processed requests. Number of request is determined in MAX_OUTSTANDING_DEPOSITS_TO_CANCEL_IN_ONE_CALL
/// @dev Deletes processed requests.
/// @param _number Supposed number of open requests to look at and delete
/// @return concated deposits public data for limited number of deposits so as not to go beyond the block gas limit in the caller function
function popOutstandingDeposits() external returns (bytes memory depositsPubData) {
function deletePriorityRequestsAndPopOutstandingDeposits(uint64 _number) external returns (bytes memory depositsPubData) {
requireFranklin();
require(
totalOpenPriorityRequests > 0,
"pgs11"
); // pgs11 - no one priority request left
uint64 k = 0; // Number of outstanding deposits
uint64 i = firstPriorityRequestId;
while(k < MAX_OUTSTANDING_DEPOSITS_TO_CANCEL_IN_ONE_CALL && i < firstPriorityRequestId + totalOpenPriorityRequests) {
uint64 number = firstPriorityRequestId + _number;
if (totalOpenPriorityRequests < _number) {
number = firstPriorityRequestId + totalOpenPriorityRequests;
}
for (uint64 i = firstPriorityRequestId; i < number; i++) {
if (priorityRequests[i].opType == DEPOSIT_OP) {
depositsPubData = Bytes.concat(depositsPubData, priorityRequests[i].pubData);
k++;
}
delete priorityRequests[i];
i++;
}
uint64 numberDeleted = i - firstPriorityRequestId;
firstPriorityRequestId = i;
totalOpenPriorityRequests -= numberDeleted;
firstPriorityRequestId = number;
totalOpenPriorityRequests -= number;
}

/// @notice Compares Rollup operation with corresponding priority requests' operation
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/fails_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,14 @@ describe("PLANNED FAILS", function() {
expect(balanceToWithdraw).equal(parseEther("0"));

// Cancel first 2 deposits
const cancelTx1 = await franklinDeployedContract.cancelOutstandingDepositsForExodusMode();
const cancelTx1 = await franklinDeployedContract.cancelOutstandingDepositsForExodusMode(2);
await cancelTx1.wait();

balanceToWithdraw = await franklinDeployedContract.balancesToWithdraw(wallet.address, 0);
expect(balanceToWithdraw).equal(parseEther("19.993556"));

// Cancel last deposit
const cancelTx2 = await franklinDeployedContract.cancelOutstandingDepositsForExodusMode();
// Cancel last deposit - try 3 but there is only 1 left
const cancelTx2 = await franklinDeployedContract.cancelOutstandingDepositsForExodusMode(3);
await cancelTx2.wait();

balanceToWithdraw = await franklinDeployedContract.balancesToWithdraw(wallet.address, 0);
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/integration_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe("INTEGRATION", function() {

// Full exit eth
const fullExitAmount = parseEther("0.096778"); // amount after: tx value - some counted fee - exit amount
const fullExitMinusGas = parseEther("0.096047308");
const fullExitMinusGas = parseEther("0.096047605");
const accId = 0;
const pubkey = "0x0000000000000000000000000000000000000000000000000000000000000000";
const signature = Buffer.from("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "hex");
Expand Down

0 comments on commit c67ad94

Please sign in to comment.