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

Conversation

alysiahuggins
Copy link
Contributor

@alysiahuggins alysiahuggins commented Dec 6, 2024

Closes #2370 which is a sub issue of #2304

This PR:

  • validator is identified by their ethereum account (msg.sender), blsVK and schnorrVK
  • validator can update consensus key once they have access to their ethereum account

This PR does not:

  • consider epochs

Key places to review:

  • Updates to the AbstractStakeTable interface, StakeTable.sol and StakeTable.t.sol

How to test this PR:

forge test --match-contract StakeTable

@alysiahuggins alysiahuggins linked an issue Dec 6, 2024 that may be closed by this pull request
@alysiahuggins alysiahuggins changed the title 2370 staketable update validator identification keys WIP 2370 staketable update validator identification keys Dec 6, 2024
@alysiahuggins alysiahuggins changed the title WIP 2370 staketable update validator identification keys 2370 staketable update validator identification keys Dec 10, 2024
@alysiahuggins alysiahuggins marked this pull request as ready for review December 11, 2024 15:43
/// @dev This function can only be called by the validator itself when it's not in the exit
/// queue
/// @dev The validator will need to give up either its old BLS key and/or old Schnorr key
/// @dev The validator will need to provide a BLS signature over the new BLS key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. The message signed is the address of the validator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clarified the comment here 0cc8946

Copy link
Contributor

@philippecamacho philippecamacho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments. LGTM

@@ -24,20 +24,24 @@ abstract contract AbstractStakeTable {
uint256 public totalVotingStake;

/// @notice Signals a registration of a BLS public key.
/// @param blsVKhash hash of the BLS public key that is registered.
/// @param account the address of the validator
/// @param registerEpoch epoch when the registration becomes effective.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is HotShot epoch, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good q. The epoch side of things haven't been fully implemented yet (issue here). Ideally it's the hotshot epoch but yet to determine how the contract would be aware of hotshot's epochs


// Update the node's schnorr key once it's not the same as the old one and it's nonzero
if (
!EdOnBN254.isEqual(newSchnorrVK, node.schnorrVK)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the EdOnBn254 and BN254 types, can we use using ... for ... to make the code a bit more readable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e1b7e25 so i didn't add the isEqual function to the BN254 library since it was an external library but i did add it to the EdOnBn254 library so i added the using ... for ... syntax for that.

@philippecamacho shall I add isEqual and a zero point BN254 constant to the BN254 codebase? Also is it a good idea to add a zero point EdOnBN254 constant? Zero point checks have been added to the register and updateConsensusKeys functions.

@@ -299,28 +319,28 @@ contract StakeTable is AbstractStakeTable {
// Create an entry for the node.
node.account = msg.sender;
node.balance = fixedStakeAmount;
node.blsVK = blsVK;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly that we check that the keys are not zero when if consensus keys are updated but we don't check for that during registration? Is that intentional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't need to check the blsVk because we verify a signature but what about the schnorrVk?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you're right, there should be checks on the vk(s) here too!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added checks on zero point keys e1b7e25

&& EdOnBN254.isEqual(newSchnorrVK, node.schnorrVK)
)
|| (
_isEqualBlsKey(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we verify the BLS sig, is it necessary to check that the key is non-zero?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see it's allowed to be zero if only the schnorr key is updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now any zero keys cause a revert 638ed78

vm.stopPrank();
}

function test_UpdateConsensusKeysWithInvalidBlsKeyInfoButOnlySchnorrVKChanged_Succeeds()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this test function sort of prompted me to think that maybe we should rethink this particular part of the API a bit (previous comment).

@alysiahuggins alysiahuggins merged commit 97308ad into main Jan 15, 2025
22 checks passed
@alysiahuggins alysiahuggins deleted the 2370-staketable-update-validator-identification-keys branch January 15, 2025 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StakeTable: Update Validator identification keys
5 participants