Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
Disallow calling processWithdrawCommitment twice
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception committed Jan 4, 2022
1 parent cb793dd commit c22ce25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/WithdrawManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ contract WithdrawManager {
uint256 batchID,
Types.MMCommitmentInclusionProof memory commitmentMP
) public {
require(
processed[commitmentMP.commitment.body.withdrawRoot] == "",
"WithdrawManager: commitment was already processed"
);
vault.requestApproval(batchID, commitmentMP);
(address addr, uint256 l2Unit) =
tokenRegistry.safeGetRecord(commitmentMP.commitment.body.tokenID);
Expand Down
6 changes: 6 additions & 0 deletions test/slow/rollup.massMigration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ describe("Mass Migrations", async function() {
"Transaction cost: Process Withdraw Commitment",
receiptProcess.gasUsed.toNumber()
);

await expectRevert(
withdrawManager.processWithdrawCommitment(batchId, batch.proof(0)),
"WithdrawManager: commitment was already processed"
);

const withdrawProof = migrationTree.getWithdrawProof(0);
const [, claimer] = await ethers.getSigners();
const claimerAddress = await claimer.getAddress();
Expand Down

0 comments on commit c22ce25

Please sign in to comment.