-
Notifications
You must be signed in to change notification settings - Fork 207
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
[VAULTS] PredepositGuarantee #932
Open
failingtwice
wants to merge
66
commits into
feat/vaults
Choose a base branch
from
predeposit-guardian
base: feat/vaults
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,614
−186
Open
Changes from 46 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
c19a543
feat: verify deposit guardian upon deposit
failingtwice b710b58
feat: add comment
failingtwice 86f80bf
fix: use bytes for sig and XOR for aggregate root
failingtwice a0de885
fix: remove unused imports
failingtwice 295ba6e
fix: elaborate comment
failingtwice 938a519
feat: predeposit guardian concept WIP, full of bugs and errors
failingtwice 34d203d
refactor: cleanup logic
failingtwice 21f475e
feat: remove unnecessary mapping
failingtwice 331a6e6
feat: remove node operator check
failingtwice 2c84783
fix: rename
failingtwice ccde1b2
fix: comment on naming
failingtwice d0954f7
fix: comment on naming
failingtwice c5312c0
feat: add accounting&delegation to predeposit guardian
Jeday 9d2b349
feat: proof validation
Jeday e4d3ebc
fix: clean up errors
Jeday 74917ee
fix: mitigate mal staking vault
Jeday a17c375
fix: prove using validator container
Jeday 8674bba
fix: withdraw
Jeday 87c7e01
fix: use uint256 for collateral
Jeday ad9e476
fix: merge prove flows
Jeday 5212738
fix: move predeposit to vaults
Jeday 0d5f663
test: pdg cl verifier test
Jeday ae6d487
fix: use correct merkle implementation
Jeday 2fc25b6
feat: add predeposit guarantee to vault factory
Jeday 563d852
docs: update libs with refs
Jeday d2f5f24
fix: remove GIndex usage
Jeday 4ef7550
fix: rework no voucher
Jeday 6d6242b
fix: rewrite hashTreeRoot for calldata
Jeday ecc06c6
test: local testing merkle tree
Jeday ef47aed
feat: enhance PredepositGuarantee with events and improved error hand…
DiRaiks 3bb45e8
feat: rework for wc proof
Jeday 500e8be
feat: clean up SSZ lib
Jeday 56b7752
docs: clProofVerifier
Jeday 364e1e7
test: update to childBlockTimestamp
Jeday 04a70a9
Merge branch 'predeposit-guardian' of github.com:lidofinance/core int…
DiRaiks 3576bb9
refactor: simplify node operator bond top-up logic
DiRaiks 16014b0
test: export PG test helpers
Jeday 7b61c6a
Merge pull request #936 from lidofinance/predeposit-guardian-fixes
Jeday 6e3b647
feat: integrate predeposit guarantee into locator
Jeday 8c45174
fix: add whenResumed
Jeday 60b3157
fix: move up from internal function
Jeday 3223ab5
test: pdg happy path
Jeday 917c685
fix: enforce balance multiple of ether
Jeday 966ab9c
Merge branch 'feat/vaults' of github.com:lidofinance/core into predep…
Jeday e79014d
feat: add PDG integration to dashboard
Jeday d077613
feat: allow GIndex change via slot proof
Jeday 0bbf207
fix: rename deposit guardian to depositor in StakingVault
DiRaiks d42777e
fix: update references from depositGuardian to depositor across contr…
DiRaiks 118163c
Merge branch 'feat/vaults' of github.com:lidofinance/core into predep…
DiRaiks c1f271d
test: update createVault calls to include deposit contract address
DiRaiks 6f37fc5
test: update asset recovery role test to use specific role
DiRaiks 65bbd88
test: integrate predeposit guarantee into vault tests
DiRaiks ba74cb4
test: add predepositGuarantee to LidoLocator and test configurations
DiRaiks da9d8aa
fix: update VaultHub deployment to use LidoLocator address
DiRaiks 01450ad
refactor: simplify LidoLocator deployment in non-Aragon contracts script
DiRaiks 7a8ef28
feat: update VaultHub constructor to accept StETH address directly
DiRaiks e423920
feat: add PredepositGuarantee deployment to non-Aragon contracts script
DiRaiks 8d15647
refactor: update VaultHub constructor to use LidoLocator for StETH ad…
DiRaiks 0479f8a
refactor: deploy PredepositGuarantee behind ossifiable proxy
DiRaiks ae75131
feat: add unregistered validator flow
Jeday 715a0fd
feat: remove locator call from vaulthub constructor
Jeday 1418175
chore: revert accounting formating
Jeday 322e3a9
chore: add line
Jeday 8749e6a
fix: naming&comments
Jeday 93bffbc
fix: remove depositor setter
Jeday b098888
chore: remove guardian naming
Jeday File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks like it should be collected under a library There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// SPDX-FileCopyrightText: 2024 Lido <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
/* | ||
GIndex library from CSM | ||
original: https://github.com/lidofinance/community-staking-module/blob/7071c2096983a7780a5f147963aaa5405c0badb1/src/lib/GIndex.sol | ||
*/ | ||
|
||
pragma solidity 0.8.25; | ||
|
||
type GIndex is bytes32; | ||
|
||
using {isRoot, isParentOf, index, width, shr, shl, concat, unwrap, pow} for GIndex global; | ||
|
||
error IndexOutOfRange(); | ||
|
||
/// @param gI Is a generalized index of a node in a tree. | ||
/// @param p Is a power of a tree level the node belongs to. | ||
/// @return GIndex | ||
function pack(uint256 gI, uint8 p) pure returns (GIndex) { | ||
if (gI > type(uint248).max) { | ||
revert IndexOutOfRange(); | ||
} | ||
|
||
// NOTE: We can consider adding additional metadata like a fork version. | ||
return GIndex.wrap(bytes32((gI << 8) | p)); | ||
} | ||
|
||
function unwrap(GIndex self) pure returns (bytes32) { | ||
return GIndex.unwrap(self); | ||
} | ||
|
||
function isRoot(GIndex self) pure returns (bool) { | ||
return index(self) == 1; | ||
} | ||
|
||
function index(GIndex self) pure returns (uint256) { | ||
return uint256(unwrap(self)) >> 8; | ||
} | ||
|
||
function width(GIndex self) pure returns (uint256) { | ||
return 1 << pow(self); | ||
} | ||
|
||
function pow(GIndex self) pure returns (uint8) { | ||
return uint8(uint256(unwrap(self))); | ||
} | ||
|
||
/// @return Generalized index of the nth neighbor of the node to the right. | ||
function shr(GIndex self, uint256 n) pure returns (GIndex) { | ||
uint256 i = index(self); | ||
uint256 w = width(self); | ||
|
||
if ((i % w) + n >= w) { | ||
revert IndexOutOfRange(); | ||
} | ||
|
||
return pack(i + n, pow(self)); | ||
} | ||
|
||
/// @return Generalized index of the nth neighbor of the node to the left. | ||
function shl(GIndex self, uint256 n) pure returns (GIndex) { | ||
uint256 i = index(self); | ||
uint256 w = width(self); | ||
|
||
if (i % w < n) { | ||
revert IndexOutOfRange(); | ||
} | ||
|
||
return pack(i - n, pow(self)); | ||
} | ||
|
||
// See https://github.com/protolambda/remerkleable/blob/91ed092d08ef0ba5ab076f0a34b0b371623db728/remerkleable/tree.py#L46 | ||
function concat(GIndex lhs, GIndex rhs) pure returns (GIndex) { | ||
uint256 lhsMSbIndex = fls(index(lhs)); | ||
uint256 rhsMSbIndex = fls(index(rhs)); | ||
|
||
if (lhsMSbIndex + 1 + rhsMSbIndex > 248) { | ||
revert IndexOutOfRange(); | ||
} | ||
|
||
return pack((index(lhs) << rhsMSbIndex) | (index(rhs) ^ (1 << rhsMSbIndex)), pow(rhs)); | ||
} | ||
|
||
function isParentOf(GIndex self, GIndex child) pure returns (bool) { | ||
uint256 parentIndex = index(self); | ||
uint256 childIndex = index(child); | ||
|
||
if (parentIndex >= childIndex) { | ||
return false; | ||
} | ||
|
||
while (childIndex > 0) { | ||
if (childIndex == parentIndex) { | ||
return true; | ||
} | ||
|
||
childIndex = childIndex >> 1; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/// @dev From Solady LibBit, see https://github.com/Vectorized/solady/blob/main/src/utils/LibBit.sol. | ||
/// @dev Find last set. | ||
/// Returns the index of the most significant bit of `x`, | ||
/// counting from the least significant bit position. | ||
/// If `x` is zero, returns 256. | ||
function fls(uint256 x) pure returns (uint256 r) { | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
// prettier-ignore | ||
r := or(shl(8, iszero(x)), shl(7, lt(0xffffffffffffffffffffffffffffffff, x))) | ||
r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x)))) | ||
r := or(r, shl(5, lt(0xffffffff, shr(r, x)))) | ||
r := or(r, shl(4, lt(0xffff, shr(r, x)))) | ||
r := or(r, shl(3, lt(0xff, shr(r, x)))) | ||
// prettier-ignore | ||
r := or(r, byte(and(0x1f, shr(shr(r, x), 0x8421084210842108cc6318c6db6d54be)), | ||
0x0706060506020504060203020504030106050205030304010505030400000000)) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we roll it back?