Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed whenNotPaused from deposit withdrawal #48

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/rollup/RollupUserLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down
110 changes: 64 additions & 46 deletions test/contract/arbRollup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { ethers, run, network } from 'hardhat'
import { Signer } from '@ethersproject/abstract-signer'
import { BigNumberish, BigNumber } from '@ethersproject/bignumber'
import { BytesLike, hexConcat, zeroPad } from '@ethersproject/bytes'

Check warning on line 21 in test/contract/arbRollup.spec.ts

View workflow job for this annotation

GitHub Actions / Contract tests

'hexConcat' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 21 in test/contract/arbRollup.spec.ts

View workflow job for this annotation

GitHub Actions / Contract tests

'zeroPad' is defined but never used. Allowed unused vars must match /^_/u
import { ContractTransaction } from '@ethersproject/contracts'
import { assert, expect } from 'chai'
import {
Expand Down Expand Up @@ -681,67 +681,85 @@
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();

Check failure on line 685 in test/contract/arbRollup.spec.ts

View workflow job for this annotation

GitHub Actions / Contract tests

Delete `;`
await (await rollupAdmin.forceRefundStaker([await validators[1].getAddress()])).wait()

Check failure on line 686 in test/contract/arbRollup.spec.ts

View workflow job for this annotation

GitHub Actions / Contract tests

Replace `await·rollupAdmin.forceRefundStaker([await·validators[1].getAddress()])` with `⏎······await·rollupAdmin.forceRefundStaker([await·validators[1].getAddress()])⏎····`
await (await rollup.rollup.connect(validators[1]).withdrawStakerFunds()).wait()

Check failure on line 687 in test/contract/arbRollup.spec.ts

View workflow job for this annotation

GitHub Actions / Contract tests

Replace `await·rollup.rollup.connect(validators[1]).withdrawStakerFunds()` with `⏎······await·rollup.rollup.connect(validators[1]).withdrawStakerFunds()⏎····`
await (await rollupAdmin.resume()).wait();

Check failure on line 688 in test/contract/arbRollup.spec.ts

View workflow job for this annotation

GitHub Actions / Contract tests

Delete `;`

user: newStake
core: createNewStake
const postWithdrawablefunds = await rollup.rollup.withdrawableFunds(
await validators[1].getAddress()
)
expect(postWithdrawablefunds, "withdrawable funds").to.equal(0)

Check failure on line 693 in test/contract/arbRollup.spec.ts

View workflow job for this annotation

GitHub Actions / Contract tests

Replace `"withdrawable·funds"` with `'withdrawable·funds'`
const stake = await rollup.rollup.amountStaked(
await validators[1].getAddress()
)
expect(stake, "amount staked").to.equal(0)

Check failure on line 697 in test/contract/arbRollup.spec.ts

View workflow job for this annotation

GitHub Actions / Contract tests

Replace `"amount·staked"` with `'amount·staked'`
})

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 = (
Expand Down
Loading