Make lcli
testnet genesis use EL withdrawal creds (#1)
In order for validators to withdraw staked funds, they need withdrawal credentials containing an execution layer address (and `0x01` prefix). https://lighthouse-book.sigmaprime.io/voluntary-exit.html#1-how-to-know-if-i-have-the-withdrawal-credentials-type-0x01 The current tooling creates validators with credentials derived from a BLS signature using the initial keypair (with `0x00` prefix). To allow withdrawals, these then have to be updated on the running chain in a separate signed message. By creating validators with EL address credentials at genesis, we avoid this extra step. Reviewed-on: #1
This commit is contained in:
parent
f6a60be80e
commit
5801d5dea5
@ -258,16 +258,19 @@ fn initialize_state_with_validators<T: EthSpec>(
|
|||||||
state.fill_randao_mixes_with(eth1_block_hash);
|
state.fill_randao_mixes_with(eth1_block_hash);
|
||||||
|
|
||||||
for keypair in keypairs.iter() {
|
for keypair in keypairs.iter() {
|
||||||
let withdrawal_credentials = |pubkey: &PublicKey| {
|
let eth1_withdrawal_credentials = |pubkey: &PublicKey| -> Hash256 {
|
||||||
let mut credentials = hash(&pubkey.as_ssz_bytes());
|
let fake_execution_address = &hash(&pubkey.as_ssz_bytes())[0..20];
|
||||||
credentials[0] = spec.bls_withdrawal_prefix_byte;
|
let mut credentials = [0u8; 32];
|
||||||
|
credentials[0] = spec.eth1_address_withdrawal_prefix_byte;
|
||||||
|
credentials[12..].copy_from_slice(fake_execution_address);
|
||||||
Hash256::from_slice(&credentials)
|
Hash256::from_slice(&credentials)
|
||||||
};
|
};
|
||||||
|
|
||||||
let amount = spec.max_effective_balance;
|
let amount = spec.max_effective_balance;
|
||||||
// Create a new validator.
|
// Create a new validator.
|
||||||
let validator = Validator {
|
let validator = Validator {
|
||||||
pubkey: keypair.0.pk.clone().into(),
|
pubkey: keypair.0.pk.clone().into(),
|
||||||
withdrawal_credentials: withdrawal_credentials(&keypair.1.pk),
|
withdrawal_credentials: eth1_withdrawal_credentials(&keypair.1.pk),
|
||||||
activation_eligibility_epoch: spec.far_future_epoch,
|
activation_eligibility_epoch: spec.far_future_epoch,
|
||||||
activation_epoch: spec.far_future_epoch,
|
activation_epoch: spec.far_future_epoch,
|
||||||
exit_epoch: spec.far_future_epoch,
|
exit_epoch: spec.far_future_epoch,
|
||||||
|
Loading…
Reference in New Issue
Block a user