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

2370 staketable update validator identification keys #2373

Merged
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
978cd8f
add stake table tests
alysiahuggins Dec 5, 2024
2bc6d75
remove stake types
alysiahuggins Dec 5, 2024
c8812ef
verify token allowance, balance and reprioritize verification order o…
alysiahuggins Dec 5, 2024
e33bf9b
set the fixed stake amount, added related tests, updated data types
alysiahuggins Dec 5, 2024
7bd7f4b
add more verification checks to the withdraw function
alysiahuggins Dec 5, 2024
2b2411c
updated errror types
alysiahuggins Dec 6, 2024
d7a352d
Merge branch 'main' into 2304-stake-table-registration
alysiahuggins Dec 6, 2024
584e320
added TODO statements in comments to be explicit about outdated funct…
alysiahuggins Dec 6, 2024
59c2109
a validator/node is identified by the msg.sender, blskey and schnorrk…
alysiahuggins Dec 6, 2024
23b0fb0
Merge branch 'main' into 2304-stake-table-registration
alysiahuggins Dec 6, 2024
ec4b02b
Merge branch '2304-stake-table-registration' into 2370-staketable-upd…
alysiahuggins Dec 6, 2024
9777b99
merged from the fixed stake branch and modified test to include the i…
alysiahuggins Dec 6, 2024
b9c7022
not required to get the blsSig for a withdrawal since we have the eth…
alysiahuggins Dec 6, 2024
9303444
add the ability to update consensus keys
alysiahuggins Dec 6, 2024
3a264c1
add the ability to update consensus keys
alysiahuggins Dec 6, 2024
955a69d
merge with main
alysiahuggins Dec 6, 2024
1f171dd
remove vscode settings
alysiahuggins Dec 6, 2024
f237074
add test or happy path of updating consensus keys
alysiahuggins Dec 9, 2024
8800893
added unhappy path tests on based on no key changes and changed the b…
alysiahuggins Dec 9, 2024
cee5a6f
added comment to newly added function on StakeTable and added tests t…
alysiahuggins Dec 9, 2024
f8c0210
change the lookup node and lookup stake functions to use their ethere…
alysiahuggins Dec 9, 2024
5124d9d
updated updateConsensusKeys function, enhance test coverage
alysiahuggins Dec 9, 2024
6a34dae
added todo
alysiahuggins Dec 10, 2024
548b28c
Merge branch 'main' into 2370-staketable-update-validator-identificat…
alysiahuggins Dec 10, 2024
5df564c
updated test to use the new seed so that a new schnorr key could be g…
alysiahuggins Dec 11, 2024
83f1a70
Update contracts/src/StakeTable.sol
alysiahuggins Jan 6, 2025
9d1b2b1
Merge branch 'main' into 2370-staketable-update-validator-identificat…
alysiahuggins Jan 7, 2025
e1b7e25
check for invalid bls and schnorr keys on register
alysiahuggins Jan 7, 2025
178e680
Merge branch 'main' into 2370-staketable-update-validator-identificat…
alysiahuggins Jan 7, 2025
48db5c4
update test comments so that they are clearer
alysiahuggins Jan 7, 2025
5f3a988
updateConsensusKeys reverts when the keys the same as the old ones, n…
alysiahuggins Jan 8, 2025
638ed78
updating consensus keys revert if any VK is a zero point VK
alysiahuggins Jan 9, 2025
0cc8946
clarifies that the bls sig proves
alysiahuggins Jan 9, 2025
2821408
Merge branch 'main' into 2370-staketable-update-validator-identificat…
alysiahuggins Jan 10, 2025
63fa46d
Merge branch 'main' into 2370-staketable-update-validator-identificat…
alysiahuggins Jan 15, 2025
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
Prev Previous commit
Next Next commit
merge with main
alysiahuggins committed Dec 6, 2024
commit 955a69dd7f645fc9f01ae324b0bbf9e2b3bb6b4f
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"wake.compiler.solc.remappings": [
"@openzeppelin/contracts-upgradeable/=contracts/lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=contracts/lib/openzeppelin-contracts/contracts/",
"bn254/=contracts/lib/bn254/src/",
"ds-test/=contracts/lib/solmate/lib/ds-test/src/",
"erc4626-tests/=contracts/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"forge-std/=contracts/lib/forge-std/src/",
"foundry-devops/=contracts/lib/foundry-devops/",
"openzeppelin-contracts-upgradeable/=contracts/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=contracts/lib/openzeppelin-contracts/",
"openzeppelin-foundry-upgrades/=contracts/lib/openzeppelin-foundry-upgrades/src/",
"solidity-bytes-utils/=contracts/lib/solidity-bytes-utils/contracts/",
"solidity-stringutils/=contracts/lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/",
"solmate/=contracts/lib/solmate/src/"
]
}
19 changes: 11 additions & 8 deletions contracts/src/StakeTable.sol
Original file line number Diff line number Diff line change
@@ -113,10 +113,9 @@ contract StakeTable is AbstractStakeTable {
return 0;
}

/// @notice Look up the balance of `blsVK`
/// @notice Look up the balance of `blsVK`g
/// @param blsVK BLS public key controlled by the user.
/// @return Current balance owned by the user.
/// TODO modify this according to the current spec
function lookupStake(BN254.G2Point memory blsVK) external view override returns (uint256) {
Node memory node = this.lookupNode(blsVK);
return node.balance;
@@ -133,6 +132,7 @@ contract StakeTable is AbstractStakeTable {

/// @notice Get the next available epoch and queue size in that epoch
/// TODO modify this according to the current spec
/// TODO modify this according to the current spec
function nextRegistrationEpoch() external view override returns (uint64, uint64) {
uint64 epoch;
uint64 queueSize;
@@ -155,19 +155,22 @@ contract StakeTable is AbstractStakeTable {
// @param queueSize current size of the registration queue (after insertion of new element in
// the queue)
/// TODO modify this according to the current spec
/// TODO modify this according to the current spec
function appendRegistrationQueue(uint64 epoch, uint64 queueSize) private {
firstAvailableRegistrationEpoch = epoch;
_numPendingRegistrations = queueSize + 1;
}

/// @notice Get the number of pending registration requests in the waiting queue
/// TODO modify this according to the current spec
/// TODO modify this according to the current spec
function numPendingRegistrations() external view override returns (uint64) {
return _numPendingRegistrations;
}

/// @notice Get the next available epoch for exit and queue size in that epoch
/// TODO modify this according to the current spec
/// TODO modify this according to the current spec
function nextExitEpoch() external view override returns (uint64, uint64) {
uint64 epoch;
uint64 queueSize;
@@ -189,13 +192,15 @@ contract StakeTable is AbstractStakeTable {
// @param epoch next available exit epoch
// @param queueSize current size of the exit queue (after insertion of new element in the queue)
/// TODO modify this according to the current spec
/// TODO modify this according to the current spec
function appendExitQueue(uint64 epoch, uint64 queueSize) private {
firstAvailableExitEpoch = epoch;
_numPendingExits = queueSize + 1;
}

/// @notice Get the number of pending exit requests in the waiting queue
/// TODO modify this according to the current spec
/// TODO modify this according to the current spec
function numPendingExits() external view override returns (uint64) {
return _numPendingExits;
}
@@ -215,6 +220,7 @@ contract StakeTable is AbstractStakeTable {
/// @param node node which is assigned an exit escrow period.
/// @return Number of epochs post exit after which funds can be withdrawn.
/// TODO modify this according to the current spec
/// TODO modify this according to the current spec
function exitEscrowPeriod(Node memory node) public pure returns (uint64) {
if (node.balance > 100) {
return 10;
@@ -303,7 +309,6 @@ contract StakeTable is AbstractStakeTable {
node.account = msg.sender;
node.balance = fixedStakeAmount;
node.schnorrVK = schnorrVK;
node.blsVK = blsVK;
node.registerEpoch = registerEpoch;

nodes[key] = node;
@@ -355,6 +360,7 @@ contract StakeTable is AbstractStakeTable {
/// @notice Request to exit from the stake table, not immediately withdrawable!
///
/// @dev TODO modify this according to the current spec
/// @dev TODO modify this according to the current spec
/// @param blsVK The BLS verification key to exit
function requestExit(BN254.G2Point memory blsVK) external override {
bytes32 key = _hashBlsKey(blsVK);
@@ -389,12 +395,7 @@ contract StakeTable is AbstractStakeTable {
/// withdraw past their `exitEpoch`.
///
/// @param blsVK The BLS verification key to withdraw
/// @param blsSig The BLS signature that authenticates the ethereum account this function is
/// called from the caller
/// @return The total amount withdrawn, equal to `Node.balance` associated with `blsVK`
/// TODO: This function should be tested
/// TODO modify this according to the current spec

function withdrawFunds(BN254.G2Point memory blsVK) external override returns (uint256) {
bytes32 key = _hashBlsKey(blsVK);
Node memory node = nodes[key];
@@ -415,6 +416,8 @@ contract StakeTable is AbstractStakeTable {
revert PrematureWithdrawal();
}

// Delete the node from the stake table.

// Delete the node from the stake table.
delete nodes[key];

6 changes: 2 additions & 4 deletions contracts/src/interfaces/AbstractStakeTable.sol
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@ abstract contract AbstractStakeTable {

/// @notice Look up the balance of `blsVK`
function lookupStake(BN254.G2Point memory blsVK) external view virtual returns (uint256);

/// @notice Look up the full `Node` state associated with `blsVK`
function lookupNode(BN254.G2Point memory blsVK) external view virtual returns (Node memory);

@@ -96,8 +97,7 @@ abstract contract AbstractStakeTable {
/// @param blsVK The BLS verification key
/// @param schnorrVK The Schnorr verification key (as the auxiliary info)
/// @param amount The amount to register
/// @param blsSig The BLS signature that authenticates the ethereum account this function is
/// called from
/// @param blsSig The BLS signature that the caller owns the `blsVK`
/// @param validUntilEpoch The maximum epoch the sender is willing to wait to be included
/// (cannot be smaller than the current epoch)
/// @dev No validity check on `schnorrVK`, as it's assumed to be sender's responsibility,
@@ -132,8 +132,6 @@ abstract contract AbstractStakeTable {
/// withdraw past their `exitEpoch`.
///
/// @param blsVK The BLS verification key to withdraw
/// @param blsSig The BLS signature that authenticates the ethereum account this function is
/// called from the caller
/// @return The total amount withdrawn, equal to `Node.balance` associated with `blsVK`
function withdrawFunds(BN254.G2Point memory blsVK) external virtual returns (uint256);

You are viewing a condensed version of this merge commit. You can view the full changes here.