-
Notifications
You must be signed in to change notification settings - Fork 0
Implement veNFT interface #23
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
base: master
Are you sure you want to change the base?
Conversation
|
PASS [ 43.765s] (3/3) lit_node::test toxiproxy::perf_tests::load_with_no_latency |
|
Just tried running the forge invariant tests locally and no issues there. Might need to run few more times 🤔 |
a7ce0ec to
7befe08
Compare
69aad84 to
852a7f5
Compare
a4fae38 to
f7c391c
Compare
e8f9f44 to
dcd1142
Compare
We need to reeserve the balanceOf(address) for StakingNFTFacet.
c4c6deb to
3a9d9ec
Compare
glitch003
left a comment
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.
overall, looks good. how does an existing delegated staker get an NFT? like what's the migration path?
| @@ -0,0 +1,159 @@ | |||
| // SPDX-License-Identifier: MIT | |||
| // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) | |||
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.
we should import this from openzeppelin instead of pasting it here, right?
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.
On line 8 (few lines below) I explain why I am doing this approach instead. Open to better ideas tho!
| mappedStakeRecord.operatorStakerAddress | ||
| ) == 0 | ||
| ) { | ||
| revert NoEmptyStakeRecordSlots(); |
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.
under what conditions can this happen? the user has too many stake records? what's the limit?
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.
Each staker vault holds only 30 stake records. Keep in mind a staker vault is specific to a validator, so a delegating staker can have more than 30 stake records if delegating against more than one validator.
|
|
||
| // Add NFT | ||
| LibStakingNFT._addTokenTo(to, tokenId); | ||
| // Set the block of ownership transfer (for Flash NFT protection) |
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.
what's flash nft protection?
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.
Copied over from aerodrome contracts. It's basically to prevent buyers from doing additional actions in the same transaction / block as when they got transferred the NFT. For example, in aerodrome they prevent poking, delegating and voting in the same TX / block as when the transferred happened.
| address owner = ownerOf(tokenId); | ||
| bool spenderIsOwner = owner == spender; | ||
| bool spenderIsApproved = spender == s().tokenToApprovals[tokenId]; | ||
| bool spenderIsApprovedForAll = (s().ownerToOperators[owner])[spender]; |
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.
i don't understand spenderIsApprovedForAll, can you explain how that works? is it an admin function?
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.
An owner can approve another address for permission over all of that owner's tokens.
|
also question - i didn't see the NFT name or metadata uri stuff in the erc721 interface. did i miss it? i wish we could inherit from openzeppelin erc721 but it doesn't use diamond storage. |
We would need to script / use admin powers to manipulate existing state to account for the existing stakes. |
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.
Pull request overview
This PR implements a veNFT (voting-escrow NFT) interface for the staking system. The changes introduce ERC721 functionality to represent staking positions as transferable NFTs, allowing users to trade or transfer their staked positions while maintaining proper accounting.
Key changes:
- Introduces veNFT interface with ERC721 standard functions (approve, transfer, balanceOf, etc.)
- Renames the staking balance query function from
balanceOftoselfStakeBalanceOfto avoid collision with ERC721'sbalanceOf - Adds NFT-specific tracking with tokenId fields in StakeRecord structs
- Updates event handling in the listener to match new contract events
Reviewed changes
Copilot reviewed 29 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rust/lit-node/lit-node/src/peers/peer_state/listener.rs | Changes event filter from RequestToJoinFilter to RequestToJoin1Filter (appears to contain naming issue) |
| rust/lit-core/lit-blockchain/src/contracts/pkp_helper.rs | Updates contract bytecode for PKPHelper contract |
| rust/lit-core/lit-blockchain/abis/Staking.json | Extensive ABI updates: adds veNFT/ERC721 functions, renames balanceOf to selfStakeBalanceOf, adds tokenId fields to StakeRecord structs |
| blockchain/contracts/test/lit-node/Staking.js | Updates test calls from balanceOf to selfStakeBalanceOf |
| blockchain/contracts/test/lit-node/PubkeyRouter.js | Adds StakingNFTFacet to the deployment configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Closes NODE-4819.