Skip to content

Commit

Permalink
PufferWithdrawalManager (2 step withdrawals) (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
bxmmm1 authored Sep 9, 2024
1 parent a8335ad commit 6327d6f
Show file tree
Hide file tree
Showing 33 changed files with 1,566 additions and 377 deletions.
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
skip = *.po,*.ts,*.json,*/node_modules/*
count = true
quiet-level = 3
ignore-words-list = amountIn
13 changes: 13 additions & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
.vscode
**/node_modules/
**/lib/
**/build/
**/cache/
**/out/
**/output/
**/cache/
.DS_Store
.aider*
**/.env
**/lcov.info
52 changes: 28 additions & 24 deletions .github/workflows/l2-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ on:
- "l2-contracts/**"

jobs:
# codespell:
# name: Check for spelling errors
# runs-on: ubuntu-latest

# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: Codespell
# uses: codespell-project/actions-codespell@v2.0
# with:
# check_hidden: true
# check_filenames: true
# ignore_words_list: amountIn
# skip: package-lock.json,*.pdf,./.git,yarn.lock
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Codespell
uses: codespell-project/actions-codespell@v2.0
with:
path: l2-contracts
check_hidden: true
check_filenames: true

unit-tests:
runs-on: ubuntu-latest
Expand All @@ -45,7 +44,7 @@ jobs:
run: echo running on branch ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}

- name: Install yarn
uses: borales/actions-yarn@v4
uses: borales/actions-yarn@v5
with:
cmd: install # will run `yarn install` command

Expand All @@ -54,9 +53,9 @@ jobs:
# with:
# version: nightly-de33b6af53005037b463318d2628b5cfcaf39916

- name: Run tests
working-directory: l2-contracts
run: export FOUNDRY_PROFILE=ci && forge test -vvv --match-path './test/unit/*'
# - name: Run tests
# working-directory: l2-contracts
# run: export FOUNDRY_PROFILE=ci && forge test -vvv --match-path './test/unit/*'

- name: forge fmt
working-directory: l2-contracts
Expand All @@ -68,7 +67,12 @@ jobs:
commit_message: "forge fmt"
file_pattern: '*.sol'

forge-coverage:
- name: List selectors
working-directory: l2-contracts
run: |
forge selectors list >> "$GITHUB_STEP_SUMMARY"
coverage:
runs-on: "ubuntu-latest"
steps:
- name: Cancel previous runs
Expand All @@ -85,7 +89,7 @@ jobs:
run: echo running on branch ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}

- name: Install yarn
uses: borales/actions-yarn@v4
uses: borales/actions-yarn@v5
with:
cmd: install # will run `yarn install` command

Expand All @@ -94,7 +98,7 @@ jobs:

- name: "Generate the coverage report"
working-directory: l2-contracts
run: 'forge coverage --no-match-coverage "(script|test|mock|node_modules|integrations|echidna)" --no-match-contract "PufferModuleManagerHoleskyTestnetFFI" --report lcov'
run: 'export FOUNDRY_PROFILE=ci && forge coverage --no-match-coverage "(script|test|mock|node_modules|integrations|echidna)" --no-match-contract "PufferModuleManagerHoleskyTestnetFFI" --report lcov -vvv'

- name: "Upload coverage report to Codecov"
uses: "codecov/codecov-action@v4"
Expand Down
58 changes: 31 additions & 27 deletions .github/workflows/mainnet-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ on:
- "mainnet-contracts/**"

jobs:
# codespell:
# name: Check for spelling errors
# runs-on: ubuntu-latest

# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: Codespell
# uses: codespell-project/actions-codespell@v2.0
# with:
# check_hidden: true
# check_filenames: true
# ignore_words_list: amountIn
# skip: package-lock.json,*.pdf,./.git,yarn.lock
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Codespell
uses: codespell-project/actions-codespell@v2.0
with:
path: mainnet-contracts
check_hidden: true
check_filenames: true

tests:
runs-on: ubuntu-latest
Expand All @@ -45,7 +44,7 @@ jobs:
run: echo running on branch ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}

- name: Install yarn
uses: borales/actions-yarn@v4
uses: borales/actions-yarn@v5
with:
cmd: install # will run `yarn install` command

Expand All @@ -54,12 +53,12 @@ jobs:
# with:
# version: nightly-de33b6af53005037b463318d2628b5cfcaf39916

- name: Run tests
working-directory: mainnet-contracts
run: forge test -vvv --ffi --no-match-test test_register_operator_eigen_da_holesky
env:
ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
HOLESKY_RPC_URL: ${{ secrets.HOLESKY_RPC_URL }}
# - name: Run tests
# working-directory: mainnet-contracts
# run: forge test -vvv --ffi --no-match-test test_register_operator_eigen_da_holesky
# env:
# ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
# HOLESKY_RPC_URL: ${{ secrets.HOLESKY_RPC_URL }}

- name: forge fmt
working-directory: mainnet-contracts
Expand All @@ -71,7 +70,12 @@ jobs:
commit_message: "forge fmt"
file_pattern: '*.sol'

forge-coverage:
- name: List selectors
working-directory: mainnet-contracts
run: |
forge selectors list >> "$GITHUB_STEP_SUMMARY"
coverage:
runs-on: "ubuntu-latest"
steps:
- name: Cancel previous runs
Expand All @@ -88,7 +92,7 @@ jobs:
run: echo running on branch ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}

- name: Install yarn
uses: borales/actions-yarn@v4
uses: borales/actions-yarn@v5
with:
cmd: install # will run `yarn install` command

Expand All @@ -97,7 +101,7 @@ jobs:

- name: "Generate the coverage report"
working-directory: mainnet-contracts
run: 'forge coverage --no-match-coverage "(script|test|mock|node_modules|integrations|echidna)" --no-match-contract "PufferModuleManagerHoleskyTestnetFFI" --report lcov'
run: 'forge coverage --no-match-coverage "(script|test|mock|node_modules|integrations|echidna)" --no-match-contract "PufferModuleManagerHoleskyTestnetFFI" --report lcov -vvv'
env:
ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
HOLESKY_RPC_URL: ${{ secrets.HOLESKY_RPC_URL }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ mainnet-contracts/out/*
mainnet-contracts/cache/*
l2-contracts/out/*
l2-contracts/cache/*
**/lcov.info

.DS_Store
.aider*
**/lcov.info
**/broadcast/
4 changes: 2 additions & 2 deletions l2-contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ optimizer = true
optimizer_runs = 200
evm_version = "cancun" # is live on mainnet
seed = "0x1337"
solc = "0.8.26"
solc = "0.8.27"
# via_ir = true

[fmt]
Expand All @@ -40,5 +40,5 @@ runs = 50
runs = 100

[profile.ci.fuzz]
runs = 50000
runs = 150
seed = ""
2 changes: 1 addition & 1 deletion l2-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@crytic/properties": "https://github.com/crytic/properties#f1ff61b",
"@prb/test": "0.6.4",
"erc4626-tests": "https://github.com/a16z/erc4626-tests#8b1d7c2",
"forge-std": "github:foundry-rs/forge-std#v1.8.2",
"forge-std": "github:foundry-rs/forge-std#v1.9.2",
"solarray": "github:evmcheb/solarray#a547630",
"solhint": "^5.0.1"
},
Expand Down
12 changes: 6 additions & 6 deletions l2-contracts/src/interface/IL2RewardManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import { L2RewardManagerStorage } from "../L2RewardManagerStorage.sol";
interface IL2RewardManager {
/**
* @notice Check if the reward has been claimed for a specific period and an account
* @param intervalId The claiming interal ID (see `getIntervalId`).
* @param intervalId The claiming internal ID (see `getIntervalId`).
* @param account The address of the account to check
* @return bool indicating whether the reward has been claimed
*/
function isClaimed(bytes32 intervalId, address account) external view returns (bool);

/**
* @notice Get the epoch record for a specific period
* @param intervalId The claiming interal ID (see `getIntervalId`).
* @param intervalId The claiming internal ID (see `getIntervalId`).
* @return EpochRecord The epoch record of exchange rate and reward root
*/
function getEpochRecord(bytes32 intervalId) external view returns (L2RewardManagerStorage.EpochRecord memory);
Expand All @@ -41,7 +41,7 @@ interface IL2RewardManager {

/**
* @notice A record of a single order for claim function call.
* @param intervalId The claiming interal ID (see `getIntervalId`).
* @param intervalId The claiming internal ID (see `getIntervalId`).
* @param amount The amount of reward to claim.
* @param isL1Contract The boolean indicating if the account is a smart contract on L1.
* @param account The address of the account claiming the reward.
Expand Down Expand Up @@ -73,7 +73,7 @@ interface IL2RewardManager {
* @param ethToPufETHRate The exchange rate from ETH to pufETH
* @param startEpoch The start epoch of the interval
* @param endEpoch The end epoch of the interval
* @param intervalId The claiming interal ID (see `getIntervalId`).
* @param intervalId The claiming internal ID (see `getIntervalId`).
* @param rewardsRoot The merkle root of the rewards
*/
event RewardRootAndRatePosted(
Expand All @@ -96,7 +96,7 @@ interface IL2RewardManager {
* @notice Event emitted when the claiming interval is reverted
* @param startEpoch The start epoch of the interval
* @param endEpoch The end epoch of the interval
* @param intervalId The claiming interal ID (see `getIntervalId`).
* @param intervalId The claiming internal ID (see `getIntervalId`).
* @param pufETHAmount The amount of xPufETH
* @param rewardsRoot The merkle root of the rewards
*/
Expand All @@ -108,7 +108,7 @@ interface IL2RewardManager {
* @notice Event emitted when rewards are claimed
* @param account The address of the account claiming the rewards
* @param recipient The address of the recipient of the rewards
* @param intervalId The claiming interal ID (see `getIntervalId`).
* @param intervalId The claiming internal ID (see `getIntervalId`).
* @param amount The amount claimed
*/
event Claimed(address indexed account, address indexed recipient, bytes32 indexed intervalId, uint256 amount);
Expand Down
4 changes: 2 additions & 2 deletions l2-contracts/test/unit/L2RewardManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ contract L2RewardManagerTest is Test {
// Unlock the interval
assertEq(l2RewardManager.isClaimingLocked(intervalId), false, "claiming should be unlocked");

// We cant revert, because the interval is unlocked
// We can't revert, because the interval is unlocked
vm.expectRevert(abi.encodeWithSelector(IL2RewardManager.UnableToFreezeInterval.selector));
l2RewardManager.freezeAndRevertInterval(address(mockBridge), startEpoch, endEpoch);
}
Expand Down Expand Up @@ -471,7 +471,7 @@ contract L2RewardManagerTest is Test {
address(l2RewardManager),
address(xPufETHProxy),
address(this),
0 ether, // invalid amount transfered
0 ether, // invalid amount transferred
uint256(0),
encodedCallData
);
Expand Down
2 changes: 1 addition & 1 deletion mainnet-contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ optimizer = true
optimizer_runs = 200
evm_version = "cancun" # is live on mainnet
seed = "0x1337"
solc = "0.8.26"
solc = "0.8.27"
# via_ir = true

[fmt]
Expand Down
21 changes: 1 addition & 20 deletions mainnet-contracts/output/puffer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{
"": "",
"PufferDepositor": "0xfb48F812cBFa8f3b107D86cb32F946bBbfa4a7c9",
"PufferDepositorImplementation": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
"PufferVault": "0x47F66E0CD2AF9a59954549b916895AF015869dE7",
"PufferVaultImplementation": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
"accessManager": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"dao": "0xeb1D5EE982DbEFf6E57e5Ca3CA45F35bBE229FFE",
"depositor": "0xfb48F812cBFa8f3b107D86cb32F946bBbfa4a7c9",
"enclaveVerifier": "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
"guardianModule": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1",
"moduleBeacon": "0x1613beB3B2C4f22Ee086B2b38C1476A3cE7f78E8",
"moduleManager": "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB",
"oracle": "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE",
"protocol": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E",
"stETH/stETH Mock": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"validatorTicket": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
"vault": "0x47F66E0CD2AF9a59954549b916895AF015869dE7",
"weth/weth Mock": "0x0165878A594ca255338adfa4d48449f69242Eb8F"
}
{}
2 changes: 1 addition & 1 deletion mainnet-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@crytic/properties": "https://github.com/crytic/properties#f1ff61b",
"@prb/test": "0.6.4",
"erc4626-tests": "https://github.com/a16z/erc4626-tests#8b1d7c2",
"forge-std": "github:foundry-rs/forge-std#v1.8.2",
"forge-std": "github:foundry-rs/forge-std#v1.9.2",
"solarray": "github:evmcheb/solarray#a547630",
"solhint": "^5.0.1"
},
Expand Down
Loading

0 comments on commit 6327d6f

Please sign in to comment.