Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shivani/detect faulty vals #163

Merged
merged 6 commits into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tendermint/src/lite/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ pub enum Kind {
/// the implementation, if any.
#[error("Implementation specific error")]
ImplementationSpecific,

/// This is returned when a faulty i.e misbehaving full node is found
#[error("Faulty full node: {reason}")]
FaultyFullNode { reason: String },
Shivani912 marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

@liamsi liamsi Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed with @Shivani912 this error needs to be mentioned in the spec too.

}

impl Kind {
Expand Down
16 changes: 12 additions & 4 deletions tendermint/src/lite_impl/signed_header.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! [`lite::SignedHeader`] implementation for [`block::signed_header::SignedHeader`].

use crate::lite::error::{Error, Kind};
use crate::lite::ValidatorSet;
use crate::validator::Set;
use crate::{block, hash, lite, vote};
use anomaly::fail;
Expand Down Expand Up @@ -60,10 +61,10 @@ impl lite::Commit for block::signed_header::SignedHeader {
);
}

// make sure each vote is for the correct header
for precommit_opt in self.commit.precommits.iter() {
match precommit_opt {
Some(precommit) => {
// make sure each vote is for the correct header
if let Some(header_hash) = precommit.header_hash() {
if header_hash != self.header_hash() {
fail!(
Expand All @@ -75,14 +76,21 @@ impl lite::Commit for block::signed_header::SignedHeader {
);
}
}

// returns FaultyFullNode error if it detects a signer isn't present in the validator set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually an ImplementationSpecific error, since it depends on Commits containing the validator set addresses. So we don't need a new error type in the light client.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense @ebuchman. Will address that :)

if vals.validator(precommit.validator_address) == None {
let reason = format!(
"Found a faulty signer ({}) not present in the validator set ({})",
precommit.validator_address,
vals.hash()
);
return Err(Kind::FaultyFullNode { reason }.into());
Shivani912 marked this conversation as resolved.
Show resolved Hide resolved
}
Shivani912 marked this conversation as resolved.
Show resolved Hide resolved
}
None => (),
}
}

// TODO: check here if all the votes are from correct validators
// TODO: return error kind "InvalidValidator" if we find a vote from a validator not in the val set

Ok(())
}
}
Expand Down
Loading