Skip to content

Commit

Permalink
Fixed Boundary Condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ethDreamer committed Mar 25, 2022
1 parent d78b87e commit 38e8f98
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions beacon_node/eth1/src/deposit_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,7 @@ impl DepositCache {
requested: end,
known_deposits: self.logs.len(),
})
} else if self
.finalized_deposit_count
.map(|count| start - count + 1)
.unwrap_or(1)
== 0
{
} else if self.finalized_deposit_count.unwrap_or(0) > start {
// Can't ask for deposits before or on the finalized deposit
Err(Error::DepositRangeInvalid {
range_start: start,
Expand Down Expand Up @@ -638,8 +633,10 @@ 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, 11).is_err());
assert!(tree.get_deposits(6, 9, 11).is_err());
assert!(tree.get_deposits(7, 9, 11).is_err());
// Range start > finalized deposit should be OK
assert!(tree.get_deposits(8, 9, 11).is_ok());
}

fn fake_eth1_block(deposit_log: &DepositLog) -> Eth1Block {
Expand Down

0 comments on commit 38e8f98

Please sign in to comment.