Skip to content

Commit

Permalink
Refactor parlia-elc (#38)
Browse files Browse the repository at this point in the history
Refactor

Signed-off-by: Naohiro Yoshida <[email protected]>
  • Loading branch information
yoshidan authored Dec 17, 2023
1 parent c78c881 commit b5bdac9
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 252 deletions.
5 changes: 1 addition & 4 deletions light-client/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,8 @@ impl ClientState {
));
}

// Ensure validator set is
header.verify_validator_set(cs)?;

// Ensure header is valid
header.verify(&self.chain_id)
header.verify(&self.chain_id, cs)
}
}

Expand Down
16 changes: 12 additions & 4 deletions light-client/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ pub enum Error {
InvalidProofFormatError(Vec<u8>),
MissingValidatorInEpochBlock(BlockNumber),
MissingNextValidatorSet(BlockNumber),
MissingCurrentValidatorSet(BlockNumber),
UnexpectedPreviousValidatorsHash(Height, Height, Hash, Hash),
UnexpectedCurrentValidatorsHash(Height, Height, Hash, Hash),
InvalidVerifyingHeaderLength(BlockNumber, usize),
ValidatorNotTrusted(Hash),
InsufficientTrustedValidatorsInUntrustedValidators(Hash, usize, usize),
MissingValidatorToVerifySeal(BlockNumber),
MissingValidatorToVerifyVote(BlockNumber),
UnexpectedNextCheckpointHeader(BlockNumber, BlockNumber),
Expand Down Expand Up @@ -282,11 +283,18 @@ impl core::fmt::Display for Error {
Error::UnexpectedVoteRelation(e1, e2, e3) => {
write!(f, "UnexpectedVoteRelation : {} {} {:?}", e1, e2, e3)
}
Error::ValidatorNotTrusted(e1) => {
write!(f, "ValidatorNotTrusted : {:?}", e1)
Error::InsufficientTrustedValidatorsInUntrustedValidators(e1, e2, e3) => {
write!(
f,
"InsufficientTrustedValidatorsInUntrustedValidators : {:?} {} {}",
e1, e2, e3
)
}
Error::MissingNextValidatorSet(e1) => {
write!(f, "MissingNextValidatorSet : {:?}", e1)
write!(f, "MissingNextValidatorSet : {}", e1)
}
Error::MissingCurrentValidatorSet(e1) => {
write!(f, "MissingCurrentValidatorSet : {}", e1)
}
Error::MissingValidatorToVerifySeal(e1) => {
write!(f, "MissingValidatorToVerifySeal : {:?}", e1)
Expand Down
Loading

0 comments on commit b5bdac9

Please sign in to comment.