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

Shivani/detect faulty vals #163

merged 6 commits into from
Mar 6, 2020

Conversation

Shivani912
Copy link
Contributor

@Shivani912 Shivani912 commented Feb 27, 2020

closes #140

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGES.md

@codecov-io
Copy link

codecov-io commented Feb 27, 2020

Codecov Report

Merging #163 into master will increase coverage by 0.09%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #163      +/-   ##
==========================================
+ Coverage   39.68%   39.78%   +0.09%     
==========================================
  Files          91       91              
  Lines        3276     3283       +7     
  Branches      490      491       +1     
==========================================
+ Hits         1300     1306       +6     
- Misses       1690     1691       +1     
  Partials      286      286
Impacted Files Coverage Δ
tendermint/src/lite/error.rs 52.83% <0%> (-1.02%) ⬇️
tendermint/src/lite_impl/signed_header.rs 79.41% <87.5%> (+1.99%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6df2a92...b28b3da. Read the comment docs.

Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

We need to clarify if it makes sense to have a new error kind in the light module to signal that we detected a vote from a validator not in the val set (should be aligned with the spec).

A small test that tests (and thereby documents) the new (and correct) behaviour would also be great.

@brapse brapse self-requested a review March 5, 2020 14:16
tendermint/src/lite/error.rs Outdated Show resolved Hide resolved

/// This is returned when a faulty i.e misbehaving full node is found
#[error("Faulty full node: {reason}")]
FaultyFullNode { reason: String },
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.

@liamsi
Copy link
Member

liamsi commented Mar 5, 2020

@Shivani912 can you briefly summarize the changes to the JSON file? And if it was regenerated reference the used commit in your fork (if it was a different one)?
On github it doesn't show bc: 13,718 additions, 13,693 deletions not shown because the diff is too large.

@@ -119,6 +119,8 @@ impl MockRequester {
}
}

// Link to the commit that generated below JSON test files:
// https://github.com/Shivani912/tendermint/commit/f7d16ab59b55a4f1a5cdbfa6b0c24467aa88fdb2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liamsi Here is the link to the commit that generated the new val_set_tests.json

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this test that fails with FaultyFullNode error:
https://github.com/interchainio/tendermint-rs/blob/b28b3da6049cb4b0868e3c234f447c22daa2d289/tendermint/tests/support/lite/single_step_sequential/val_set_tests.json#L13078

Here, the input contains a validator set of 3 vals (v1, v2, v3) for header at height 2 with precommits from 3 vals (v1, v2, v4). This makes it pass all other validation tests but fails because there is a vote from val v4 which is not in the val set and thus there is a chance that the full node who sent this data is misbehaving.

@liamsi

Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

Awesome work! Thanks @Shivani912 👍

Although a bit redundant, I think it would be good to add a (rust only) unit test for the (implementation specific) validate method. This and adding the error to the spec can happen in separate PRs.

@liamsi liamsi merged commit efadd8b into master Mar 6, 2020
@liamsi liamsi deleted the shivani/detect-faulty-vals branch March 6, 2020 20:18
@Shivani912
Copy link
Contributor Author

Awesome work! Thanks @Shivani912 👍

Although a bit redundant, I think it would be good to add a (rust only) unit test for the (implementation specific) validate method. This and adding the error to the spec can happen in separate PRs.

Thanks @liamsi ! I actually pinged @milosevic about this and we're not currently sure on what level of specification this should appear. We probably need some discussions over this. Do we have a spec where these error types are defined?

For rust only test, we need a way to generate votes in the code. I was looking into it, but couldn't find how to produce signatures for votes.

@liamsi
Copy link
Member

liamsi commented Mar 6, 2020

and we're not currently sure on what level of specification this should appear. We probably need some discussions over this.

IMHO wherever we specify detecting (and handling) cases of faulty nodes, we need to mention these errors (prob here).

Do we have a spec where these error types are defined?

Not yet AFAIK. The other error kinds also live in the spec though: (e.g see fatalError helper function in https://github.com/tendermint/spec/blob/master/spec/consensus/light-client/verification.md).

@liamsi
Copy link
Member

liamsi commented Mar 6, 2020

For rust only test, we need a way to generate votes in the code. I was looking into it, but couldn't find how to produce signatures for votes.

I see. It might not be too difficult to generate a signature for votes (with the same libs / deps we are using for verification) but it looks definitely like more work than I though. Thanks for looking into this 👍

"validator({}) voted for header {}, but current header is {}",
precommit.validator_address,
header_hash,
self.header_hash()
);
}
}

// 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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Light client voting_power_in can't detect invalid signers
4 participants