mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 05:44:44 +00:00
Update types to new tree_hash crate
This commit is contained in:
@@ -7,9 +7,9 @@ use db::stores::{BeaconBlockStore, BeaconStateStore};
|
||||
use db::{DiskDB, MemoryDB};
|
||||
use fork_choice::BitwiseLMDGhost;
|
||||
use slot_clock::SystemTimeSlotClock;
|
||||
use ssz::TreeHash;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use tree_hash::TreeHash;
|
||||
use types::test_utils::TestingBeaconStateBuilder;
|
||||
use types::{BeaconBlock, ChainSpec, Hash256};
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn initialise_beacon_chain(
|
||||
let (genesis_state, _keypairs) = state_builder.build();
|
||||
|
||||
let mut genesis_block = BeaconBlock::empty(&spec);
|
||||
genesis_block.state_root = Hash256::from_slice(&genesis_state.hash_tree_root());
|
||||
genesis_block.state_root = Hash256::from_slice(&genesis_state.tree_hash_root());
|
||||
|
||||
// Slot clock
|
||||
let slot_clock = SystemTimeSlotClock::new(
|
||||
@@ -73,7 +73,7 @@ pub fn initialise_test_beacon_chain(
|
||||
let (genesis_state, _keypairs) = state_builder.build();
|
||||
|
||||
let mut genesis_block = BeaconBlock::empty(spec);
|
||||
genesis_block.state_root = Hash256::from_slice(&genesis_state.hash_tree_root());
|
||||
genesis_block.state_root = Hash256::from_slice(&genesis_state.tree_hash_root());
|
||||
|
||||
// Slot clock
|
||||
let slot_clock = SystemTimeSlotClock::new(
|
||||
|
||||
@@ -5,8 +5,8 @@ use db::{
|
||||
};
|
||||
use fork_choice::BitwiseLMDGhost;
|
||||
use slot_clock::TestingSlotClock;
|
||||
use ssz::TreeHash;
|
||||
use std::sync::Arc;
|
||||
use tree_hash::TreeHash;
|
||||
use types::test_utils::TestingBeaconStateBuilder;
|
||||
use types::*;
|
||||
|
||||
@@ -27,7 +27,7 @@ impl TestingBeaconChainBuilder {
|
||||
let (genesis_state, _keypairs) = self.state_builder.build();
|
||||
|
||||
let mut genesis_block = BeaconBlock::empty(&spec);
|
||||
genesis_block.state_root = Hash256::from_slice(&genesis_state.hash_tree_root());
|
||||
genesis_block.state_root = Hash256::from_slice(&genesis_state.tree_hash_root());
|
||||
|
||||
// Create the Beacon Chain
|
||||
BeaconChain::from_genesis(
|
||||
|
||||
@@ -9,8 +9,8 @@ use fork_choice::BitwiseLMDGhost;
|
||||
use log::debug;
|
||||
use rayon::prelude::*;
|
||||
use slot_clock::TestingSlotClock;
|
||||
use ssz::TreeHash;
|
||||
use std::sync::Arc;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{test_utils::TestingBeaconStateBuilder, *};
|
||||
|
||||
type TestingBeaconChain = BeaconChain<MemoryDB, TestingSlotClock, BitwiseLMDGhost<MemoryDB>>;
|
||||
@@ -54,7 +54,7 @@ impl BeaconChainHarness {
|
||||
let (mut genesis_state, keypairs) = state_builder.build();
|
||||
|
||||
let mut genesis_block = BeaconBlock::empty(&spec);
|
||||
genesis_block.state_root = Hash256::from_slice(&genesis_state.hash_tree_root());
|
||||
genesis_block.state_root = Hash256::from_slice(&genesis_state.tree_hash_root());
|
||||
|
||||
genesis_state
|
||||
.build_epoch_cache(RelativeEpoch::Previous, &spec)
|
||||
@@ -163,7 +163,7 @@ impl BeaconChainHarness {
|
||||
data: data.clone(),
|
||||
custody_bit: false,
|
||||
}
|
||||
.hash_tree_root();
|
||||
.tree_hash_root();
|
||||
let domain = self.spec.get_domain(
|
||||
state.slot.epoch(self.spec.slots_per_epoch),
|
||||
Domain::Attestation,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use crate::beacon_chain_harness::BeaconChainHarness;
|
||||
use beacon_chain::CheckPoint;
|
||||
use log::{info, warn};
|
||||
use ssz::SignedRoot;
|
||||
use tree_hash::SignedRoot;
|
||||
use types::*;
|
||||
|
||||
use types::test_utils::*;
|
||||
|
||||
@@ -2,9 +2,9 @@ use crate::beacon_chain::BeaconChain;
|
||||
use eth2_libp2p::rpc::methods::*;
|
||||
use eth2_libp2p::PeerId;
|
||||
use slog::{debug, error};
|
||||
use ssz::TreeHash;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
use tree_hash::TreeHash;
|
||||
use types::{BeaconBlock, BeaconBlockBody, BeaconBlockHeader, Hash256, Slot};
|
||||
|
||||
/// Provides a queue for fully and partially built `BeaconBlock`s.
|
||||
@@ -15,7 +15,7 @@ use types::{BeaconBlock, BeaconBlockBody, BeaconBlockHeader, Hash256, Slot};
|
||||
///
|
||||
/// - When we receive a `BeaconBlockBody`, the only way we can find it's matching
|
||||
/// `BeaconBlockHeader` is to find a header such that `header.beacon_block_body ==
|
||||
/// hash_tree_root(body)`. Therefore, if we used a `HashMap` we would need to use the root of
|
||||
/// tree_hash_root(body)`. Therefore, if we used a `HashMap` we would need to use the root of
|
||||
/// `BeaconBlockBody` as the key.
|
||||
/// - It is possible for multiple distinct blocks to have identical `BeaconBlockBodies`. Therefore
|
||||
/// we cannot use a `HashMap` keyed by the root of `BeaconBlockBody`.
|
||||
@@ -166,7 +166,7 @@ impl ImportQueue {
|
||||
let mut required_bodies: Vec<Hash256> = vec![];
|
||||
|
||||
for header in headers {
|
||||
let block_root = Hash256::from_slice(&header.hash_tree_root()[..]);
|
||||
let block_root = Hash256::from_slice(&header.tree_hash_root()[..]);
|
||||
|
||||
if self.chain_has_not_seen_block(&block_root) {
|
||||
self.insert_header(block_root, header, sender.clone());
|
||||
@@ -230,7 +230,7 @@ impl ImportQueue {
|
||||
///
|
||||
/// If the body already existed, the `inserted` time is set to `now`.
|
||||
fn insert_body(&mut self, body: BeaconBlockBody, sender: PeerId) {
|
||||
let body_root = Hash256::from_slice(&body.hash_tree_root()[..]);
|
||||
let body_root = Hash256::from_slice(&body.tree_hash_root()[..]);
|
||||
|
||||
self.partials.iter_mut().for_each(|mut p| {
|
||||
if let Some(header) = &mut p.header {
|
||||
@@ -250,7 +250,7 @@ impl ImportQueue {
|
||||
///
|
||||
/// If the partial already existed, the `inserted` time is set to `now`.
|
||||
fn insert_full_block(&mut self, block: BeaconBlock, sender: PeerId) {
|
||||
let block_root = Hash256::from_slice(&block.hash_tree_root()[..]);
|
||||
let block_root = Hash256::from_slice(&block.tree_hash_root()[..]);
|
||||
|
||||
let partial = PartialBeaconBlock {
|
||||
slot: block.slot,
|
||||
|
||||
@@ -5,10 +5,10 @@ use eth2_libp2p::rpc::methods::*;
|
||||
use eth2_libp2p::rpc::{RPCRequest, RPCResponse, RequestId};
|
||||
use eth2_libp2p::PeerId;
|
||||
use slog::{debug, error, info, o, warn};
|
||||
use ssz::TreeHash;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{Attestation, BeaconBlock, Epoch, Hash256, Slot};
|
||||
|
||||
/// The number of slots that we can import blocks ahead of us, before going into full Sync mode.
|
||||
@@ -565,7 +565,7 @@ impl SimpleSync {
|
||||
return false;
|
||||
}
|
||||
|
||||
let block_root = Hash256::from_slice(&block.hash_tree_root());
|
||||
let block_root = Hash256::from_slice(&block.tree_hash_root());
|
||||
|
||||
// Ignore any block that the chain already knows about.
|
||||
if self.chain_has_seen_block(&block_root) {
|
||||
|
||||
Reference in New Issue
Block a user