state_processing: verify_deposit v0.6.0
This commit is contained in:
parent
4f138fa3fe
commit
2751be9a05
@ -88,9 +88,9 @@ pub fn get_existing_validator_index(
|
|||||||
|
|
||||||
/// Verify that a deposit is included in the state's eth1 deposit root.
|
/// Verify that a deposit is included in the state's eth1 deposit root.
|
||||||
///
|
///
|
||||||
/// Spec v0.5.1
|
/// Spec v0.6.0
|
||||||
fn verify_deposit_merkle_proof(state: &BeaconState, deposit: &Deposit, spec: &ChainSpec) -> bool {
|
fn verify_deposit_merkle_proof(state: &BeaconState, deposit: &Deposit, spec: &ChainSpec) -> bool {
|
||||||
let leaf = hash(&get_serialized_deposit_data(deposit));
|
let leaf = deposit.data.tree_hash_root();
|
||||||
verify_merkle_proof(
|
verify_merkle_proof(
|
||||||
Hash256::from_slice(&leaf),
|
Hash256::from_slice(&leaf),
|
||||||
&deposit.proof,
|
&deposit.proof,
|
||||||
@ -99,27 +99,3 @@ fn verify_deposit_merkle_proof(state: &BeaconState, deposit: &Deposit, spec: &Ch
|
|||||||
state.latest_eth1_data.deposit_root,
|
state.latest_eth1_data.deposit_root,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper struct for easily getting the serialized data generated by the deposit contract.
|
|
||||||
///
|
|
||||||
/// Spec v0.5.1
|
|
||||||
#[derive(Encode)]
|
|
||||||
struct SerializedDepositData {
|
|
||||||
amount: u64,
|
|
||||||
timestamp: u64,
|
|
||||||
input: DepositInput,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the serialized data generated by the deposit contract that is used to generate the
|
|
||||||
/// merkle proof.
|
|
||||||
///
|
|
||||||
/// Spec v0.5.1
|
|
||||||
fn get_serialized_deposit_data(deposit: &Deposit) -> Vec<u8> {
|
|
||||||
let serialized_deposit_data = SerializedDepositData {
|
|
||||||
amount: deposit.deposit_data.amount,
|
|
||||||
timestamp: deposit.deposit_data.timestamp,
|
|
||||||
input: deposit.deposit_data.deposit_input.clone(),
|
|
||||||
};
|
|
||||||
|
|
||||||
ssz_encode(&serialized_deposit_data)
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user