Skip to content

Commit

Permalink
Change DepositTreeSnapshot to Conform to EIP-4881
Browse files Browse the repository at this point in the history
  • Loading branch information
ethDreamer committed Mar 9, 2022
1 parent 9c71d87 commit 984ba58
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions beacon_node/eth1/src/deposit_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ pub mod tests {
let block7 = fake_eth1_block(tree.get_log(7).expect("should return log"));
tree.finalize(block7).expect("should finalize");
// Range starts <= finalized deposit
assert!(tree.get_deposits(7, 9, 2).is_err());
assert!(tree.get_deposits(6, 9, 2).is_err());
assert!(tree.get_deposits(7, 9, 11).is_err());
assert!(tree.get_deposits(6, 9, 11).is_err());
}

fn fake_eth1_block(deposit_log: &DepositLog) -> Eth1Block {
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/eth1/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl Service {
) -> Result<Self, Error> {
// first get eth1_block from endpoint
let endpoints = Arc::new(EndpointsCache::from_config(&config, log.clone()));
let block_hash_ref = &deposit_snapshot.eth1_block_hash;
let block_hash_ref = &deposit_snapshot.execution_block_hash;
let http_block = endpoints
.clone()
.first_success(|e| async move {
Expand Down
10 changes: 5 additions & 5 deletions consensus/state_processing/src/common/deposit_data_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ impl DepositDataTree {
/// Get snapshot of finalized deposit tree
pub fn get_snapshot(&self) -> DepositTreeSnapshot {
DepositTreeSnapshot {
branches: self.tree.get_finalized_snapshot(),
finalized: self.tree.get_finalized_snapshot(),
deposits: self.deposits_finalized as u64,
eth1_block_hash: self.finalized_eth1_block_hash.unwrap_or_else(Hash256::zero),
execution_block_hash: self.finalized_eth1_block_hash.unwrap_or_else(Hash256::zero),
}
}

Expand All @@ -82,14 +82,14 @@ impl DepositDataTree {
snapshot: &DepositTreeSnapshot,
depth: usize,
) -> Result<Self, MerkleTreeError> {
let finalized_eth1_block_hash = if snapshot.eth1_block_hash.is_zero() {
let finalized_eth1_block_hash = if snapshot.execution_block_hash.is_zero() {
None
} else {
Some(snapshot.eth1_block_hash)
Some(snapshot.execution_block_hash)
};
Ok(Self {
tree: MerkleTree::from_finalized_snapshot(
&snapshot.branches,
&snapshot.finalized,
snapshot.deposits as usize,
depth,
)?,
Expand Down
4 changes: 2 additions & 2 deletions consensus/types/src/deposit_tree_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use test_utils::TestRandom;

#[derive(Encode, Decode, Clone, Debug, PartialEq, TestRandom)]
pub struct DepositTreeSnapshot {
pub branches: Vec<Hash256>,
pub finalized: Vec<Hash256>,
pub deposits: u64,
pub eth1_block_hash: Hash256,
pub execution_block_hash: Hash256,
}

#[cfg(test)]
Expand Down

0 comments on commit 984ba58

Please sign in to comment.