Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Naohiro Yoshida <[email protected]>
  • Loading branch information
Naohiro Yoshida committed Sep 29, 2023
1 parent 79987a1 commit 364f98d
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions light-client/src/header/eth_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,13 @@ impl ETHHeaders {
}

// Ensure valid seals
let checkpoint = checkpoint(previous_validators);
if self.target.number % BLOCKS_PER_EPOCH >= checkpoint {
for h in self.all.iter() {
let epoch = self.target.number / BLOCKS_PER_EPOCH;
let checkpoint = epoch * BLOCKS_PER_EPOCH + checkpoint(previous_validators);
for h in self.all.iter() {
if h.number >= checkpoint {
h.verify_seal(current_validators, chain_id)?;
}
} else {
for h in self.all.iter() {
if h.number % BLOCKS_PER_EPOCH >= checkpoint {
h.verify_seal(current_validators, chain_id)?;
} else {
h.verify_seal(previous_validators, chain_id)?;
}
} else {
h.verify_seal(previous_validators, chain_id)?;
}
}

Expand All @@ -51,19 +46,12 @@ impl ETHHeaders {

// Ensure BLS signature is collect
// At the just checkpoint BLS signature uses previous validator set.
if self.target.number % BLOCKS_PER_EPOCH > checkpoint {
for h in headers_for_finalize {
let vote = h.get_vote_attestation()?;
for h in headers_for_finalize {
let vote = h.get_vote_attestation()?;
if h.number > checkpoint {
vote.verify(h.number, current_validators)?;
}
} else {
for h in headers_for_finalize {
let vote = h.get_vote_attestation()?;
if h.number % BLOCKS_PER_EPOCH > checkpoint {
vote.verify(h.number, current_validators)?;
} else {
vote.verify(h.number, previous_validators)?;
}
} else {
vote.verify(h.number, previous_validators)?;
}
}
Ok(())
Expand Down

0 comments on commit 364f98d

Please sign in to comment.