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

Add ability to generate exit message #4

Merged

Conversation

valefar-on-discord
Copy link
Collaborator

Port from ethereum#355

Adds two commands:
exit-transaction-keystore and exit-transaction-mnemonic

exit-transaction-keystore

Allows the user to specify a single keystore file to generate an exit message if the provided password is correct.
The success of this command will result in a single signed_exit_transaction-***.json file in exit_transactions

exit-transaction-mnemonic

Allows the user to specify a mnemonic to generate 1-n exit messages depending on how many validator indices are provided. The success of this command will result in n signed_exit_transaction-***.json files in exit_transactions for each validator index provided.

Testing

Build as instructed

Create a new mnemonic and keystore(s) on mainnet with
./deposit.sh new-mnemonic

For each keystore, create an entry in this base offline-preparation.json file:

{
  "version":"3",
  "validators":[
    {
      "index": "<ANY_INDEX_IE_123456>",
      "pubkey": "0x<PUBKEY>",
      "state": "active_ongoing",
      "withdrawal_credentials": "<CREDENTIALS>"
    }
  ],
  "genesis_validators_root":"0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95",
  "epoch":"274294",
  "genesis_fork_version":"0x00000000",
  "exit_fork_version":"0x03000000",
  "current_fork_version":"0x04000000",
  "bls_to_execution_change_domain_type":"0x0a000000",
  "voluntary_exit_domain_type":"0x04000000"
}

With the saved offline-preparation.json above in the same location as ethdo, create an exit message with ethdo using the following command:
./ethdo validator exit --offline --mnemonic="<GENERATED_MNEMONIC>" --validator=<VALIDATOR_INDEX_IN_PREF_FILE>

Create an exit message with the CLI using both
./deposit.sh exit-transaction-mnemonic --epoch=274294
for each keystore
./deposit.sh exit-transaction-keystore --epoch=274294

All outputs should match

@remyroy remyroy self-requested a review April 18, 2024 17:55
Copy link
Member

@remyroy remyroy left a comment

Choose a reason for hiding this comment

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

Everything is generally good. I still have some real world tests I would like to complete on Holesky. Let me know what you think of these comments.

staking_deposit/cli/existing_mnemonic.py Show resolved Hide resolved
staking_deposit/cli/exit_transaction_keystore.py Outdated Show resolved Hide resolved
staking_deposit/cli/exit_transaction_keystore.py Outdated Show resolved Hide resolved
staking_deposit/cli/exit_transaction_mnemonic.py Outdated Show resolved Hide resolved
tests/test_cli/test_exit_transaction_keystore.py Outdated Show resolved Hide resolved
@valefar-on-discord
Copy link
Collaborator Author

Ran through all the items and added quite a few changes:

  • Added logic to verify the integrity of the exit signature for both keystore and mnemonic flow
  • Added familiar progress bar with exit mnemonic flow
  • Updated some wording for error messages
  • Added NON_PRATER_CHAIN_KEYS to reduce chain param logic duplication
  • Added utf-8 encoding when reading json file
  • Removing int cast in validate_validator_indices so the value will be validated in validate_int_range instead where it will throw the proper error

If I missed anything, let me know and thanks for such a thorough review

@remyroy
Copy link
Member

remyroy commented Apr 23, 2024

What's the issue with having prater as an alias to goerli and the need for the NON_PRATER_CHAIN_KEYS value? Is this related to goerli being deprecated? Can you elaborate? If someone can select goerli, they should also be able to select prater as an alias if my understanding is correct. For instance:

./deposit.sh exit-transaction-keystore --chain prater --keystore /home/remyroy/Desktop/keystore-m_12381_3600_0_0_0-1713107844.json --keystore_password hidden --validator_index 1688054

should result in the same as

./deposit.sh exit-transaction-keystore --chain goerli --keystore /home/remyroy/Desktop/keystore-m_12381_3600_0_0_0-1713107844.json --keystore_password hidden --validator_index 1688054

but right now only the second one works.

@valefar-on-discord
Copy link
Collaborator Author

What's the issue with having prater as an alias to goerli and the need for the NON_PRATER_CHAIN_KEYS value? Is this related to goerli being depracated? Can you elaborate? If someone can select goerli, they should also be able to select prater as an alias if my understanding is correct.

When selecting a chain, the previous verification logic for the parameter was
list(key for key in ALL_CHAINS.keys() if key != PRATER)
for every instance of where chain was used. This would mean that choosing prater shouldn't work.

The problem here is the verification logic for the captive callback was different:
list(ALL_CHAINS.keys())

The resulting UX is the prater chain would not be an option for the initial chain prompt but if you trigger the captive callback logic, it would show as an option because it wasn't being filtered.

I'm not sure why they went this route to begin with but at this point we are probably safe to add an issue to completely remove goerli, prater, and zhejiang as they are all deprecated and then this bit of logic and be replaced with
list(ALL_CHAINS.keys())
making it clear.

@remyroy
Copy link
Member

remyroy commented Apr 23, 2024

I think removing all dead or deprecated chains is the way forward. I don't think there is a lot of value in keeping them around. I've moved that concern into #20 .

Copy link
Member

@remyroy remyroy left a comment

Choose a reason for hiding this comment

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

I think there are 1 minor thing remaining before I can approve this:

  • Replacing the pre-baked hex data in tests/test_utils/test_validation.py

I'm still waiting on my validators to be activated on Holeksy to test these changes on a real network. According to beaconcha.in, I still have around 6 days to wait.

tests/test_utils/test_validation.py Show resolved Hide resolved
@remyroy
Copy link
Member

remyroy commented Apr 24, 2024

We should add the exit_transactions directory, the default directory for exit transaction, in the .gitignore file similar to how we have validator_keys and bls_to_execution_changes to avoid potentially polluting the repo.

@valefar-on-discord
Copy link
Collaborator Author

We should add the exit_transactions directory, the default directory for exit transaction, in the .gitignore file similar to how we have validator_keys and bls_to_execution_changes to avoid potentially polluting the repo.

I thought I did that. Did I mess something up there?

@remyroy
Copy link
Member

remyroy commented Apr 24, 2024

We should add the exit_transactions directory, the default directory for exit transaction, in the .gitignore file similar to how we have validator_keys and bls_to_execution_changes to avoid potentially polluting the repo.

I thought I did that. Did I mess something up there?

Sorry, I missed it with being on the wrong branch. Everything is good here.

Copy link
Member

@remyroy remyroy left a comment

Choose a reason for hiding this comment

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

Everything is good in the review. What's left are some real world tests that I should be able to perform in the next few days.

@remyroy
Copy link
Member

remyroy commented Apr 29, 2024

My validators were just activated on Holesky and I tried to submit the exit messages but I have to wait another 2 days until I can start the exit process.

@remyroy
Copy link
Member

remyroy commented May 1, 2024

I've successfully exited 2 validators, one with a keystore and one with a mnemonic.

  1. https://holesky.beaconcha.in/validator/1688054
  2. https://holesky.beaconcha.in/validator/1688057

@remyroy
Copy link
Member

remyroy commented May 1, 2024

I tried to resolve the pending merge conflict but I think I broke the tests. It feels like they are stuck waiting for some input on stdin.

@valefar-on-discord
Copy link
Collaborator Author

There was a problem with the git merge that combined two changes in the existing mnemonic test where it provided the argument for the execution address and input.
So the test stalled expecting verification of the execution address argument which it never got.

@remyroy remyroy merged commit 36a86b9 into eth-educators:main May 1, 2024
15 checks passed
@valefar-on-discord valefar-on-discord deleted the exit-message-generation branch May 6, 2024 22:24
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.

2 participants