diff --git a/src/rollup/RollupUserLogic.sol b/src/rollup/RollupUserLogic.sol index bd16ad5e..0617f363 100644 --- a/src/rollup/RollupUserLogic.sol +++ b/src/rollup/RollupUserLogic.sol @@ -234,7 +234,7 @@ abstract contract AbsRollupUserLogic is * and move it to the desired node. * @param stakerAddress Address of the staker whose stake is refunded */ - function returnOldDeposit(address stakerAddress) external override onlyValidator whenNotPaused { + function returnOldDeposit(address stakerAddress) external override onlyValidator { require(latestStakedNode(stakerAddress) <= latestConfirmed(), "TOO_RECENT"); requireUnchallengedStaker(stakerAddress); withdrawStaker(stakerAddress); @@ -258,7 +258,7 @@ abstract contract AbsRollupUserLogic is * @notice Reduce the amount staked for the sender (difference between initial amount staked and target is creditted back to the sender). * @param target Target amount of stake for the staker. If this is below the current minimum, it will be set to minimum instead */ - function reduceDeposit(uint256 target) external onlyValidator whenNotPaused { + function reduceDeposit(uint256 target) external onlyValidator { requireUnchallengedStaker(msg.sender); uint256 currentRequired = currentRequiredStake(); if (target < currentRequired) { @@ -659,7 +659,7 @@ contract RollupUserLogic is AbsRollupUserLogic, IRollupUser { /** * @notice Withdraw uncommitted funds owned by sender from the rollup chain */ - function withdrawStakerFunds() external override onlyValidator whenNotPaused returns (uint256) { + function withdrawStakerFunds() external override onlyValidator returns (uint256) { uint256 amount = withdrawFunds(msg.sender); // This is safe because it occurs after all checks and effects // solhint-disable-next-line avoid-low-level-calls @@ -731,7 +731,7 @@ contract ERC20RollupUserLogic is AbsRollupUserLogic, IRollupUserERC20 { /** * @notice Withdraw uncommitted funds owned by sender from the rollup chain */ - function withdrawStakerFunds() external override onlyValidator whenNotPaused returns (uint256) { + function withdrawStakerFunds() external override onlyValidator returns (uint256) { uint256 amount = withdrawFunds(msg.sender); // This is safe because it occurs after all checks and effects require(IERC20Upgradeable(stakeToken).transfer(msg.sender, amount), "TRANSFER_FAILED"); diff --git a/test/contract/arbRollup.spec.ts b/test/contract/arbRollup.spec.ts index ad71ad1e..459952a4 100644 --- a/test/contract/arbRollup.spec.ts +++ b/test/contract/arbRollup.spec.ts @@ -681,67 +681,85 @@ describe('ArbRollup', () => { await rollup.confirmNextNode(challengerNode) }) - it('should add and remove stakes correctly', async function () { - /* - RollupUser functions that alter stake and their respective Core logic + it('allow force refund staker with pending node', async function () { + await (await rollupAdmin.pause()).wait(); + await (await rollupAdmin.forceRefundStaker([await validators[1].getAddress()])).wait() + await (await rollup.rollup.connect(validators[1]).withdrawStakerFunds()).wait() + await (await rollupAdmin.resume()).wait(); - user: newStake - core: createNewStake + const postWithdrawablefunds = await rollup.rollup.withdrawableFunds( + await validators[1].getAddress() + ) + expect(postWithdrawablefunds, "withdrawable funds").to.equal(0) + const stake = await rollup.rollup.amountStaked( + await validators[1].getAddress() + ) + expect(stake, "amount staked").to.equal(0) + }) - user: addToDeposit - core: increaseStakeBy + // it('should add and remove stakes correctly', async function () { + // /* + // RollupUser functions that alter stake and their respective Core logic - user: reduceDeposit - core: reduceStakeTo + // user: newStake + // core: createNewStake - user: returnOldDeposit - core: withdrawStaker + // user: addToDeposit + // core: increaseStakeBy - user: withdrawStakerFunds - core: withdrawFunds - */ + // user: reduceDeposit + // core: reduceStakeTo - const initialStake = await rollup.rollup.amountStaked( - await validators[1].getAddress() - ) + // user: returnOldDeposit + // core: withdrawStaker - await rollup.connect(validators[1]).reduceDeposit(initialStake) + // user: withdrawStakerFunds + // core: withdrawFunds + // */ - await expect( - rollup.connect(validators[1]).reduceDeposit(initialStake.add(1)) - ).to.be.revertedWith('TOO_LITTLE_STAKE') + // const initialStake = await rollup.rollup.amountStaked( + // await validators[1].getAddress() + // ) - await rollup - .connect(validators[1]) - .addToDeposit(await validators[1].getAddress(), { value: 5 }) + // await rollup.connect(validators[1]).reduceDeposit(initialStake) - await rollup.connect(validators[1]).reduceDeposit(5) + // await expect( + // rollup.connect(validators[1]).reduceDeposit(initialStake.add(1)) + // ).to.be.revertedWith('TOO_LITTLE_STAKE') - const prevBalance = await validators[1].getBalance() - const prevWithdrawablefunds = await rollup.rollup.withdrawableFunds( - await validators[1].getAddress() - ) + // await rollup + // .connect(validators[1]) + // .addToDeposit(await validators[1].getAddress(), { value: 5 }) - const tx = await rollup.rollup.connect(validators[1]).withdrawStakerFunds() - const receipt = await tx.wait() - const gasPaid = receipt.gasUsed.mul(receipt.effectiveGasPrice) + // await rollupAdmin.pause() + // await rollup.connect(validators[1]).reduceDeposit(5) - const postBalance = await validators[1].getBalance() - const postWithdrawablefunds = await rollup.rollup.withdrawableFunds( - await validators[1].getAddress() - ) + // const prevBalance = await validators[1].getBalance() + // const prevWithdrawablefunds = await rollup.rollup.withdrawableFunds( + // await validators[1].getAddress() + // ) - expect(postWithdrawablefunds).to.equal(0) - expect(postBalance.add(gasPaid)).to.equal( - prevBalance.add(prevWithdrawablefunds) - ) + // const tx = await rollup.rollup.connect(validators[1]).withdrawStakerFunds() + // const receipt = await tx.wait() + // const gasPaid = receipt.gasUsed.mul(receipt.effectiveGasPrice) - // this gets deposit and removes staker - await rollup.rollup - .connect(validators[1]) - .returnOldDeposit(await validators[1].getAddress()) - // all stake is now removed - }) + // const postBalance = await validators[1].getBalance() + // const postWithdrawablefunds = await rollup.rollup.withdrawableFunds( + // await validators[1].getAddress() + // ) + + // expect(postWithdrawablefunds).to.equal(0) + // expect(postBalance.add(gasPaid)).to.equal( + // prevBalance.add(prevWithdrawablefunds) + // ) + + // // this gets deposit and removes staker + // await rollup.rollup + // .connect(validators[1]) + // .returnOldDeposit(await validators[1].getAddress()) + // // all stake is now removed + // await rollupAdmin.resume() + // }) it('should allow removing zombies', async function () { const zombieCount = (