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

Misbehavior monitoring and handling #691

Merged
merged 41 commits into from
Apr 9, 2021
Merged

Misbehavior monitoring and handling #691

merged 41 commits into from
Apr 9, 2021

Conversation

ancazamfir
Copy link
Collaborator

@ancazamfir ancazamfir commented Feb 19, 2021

Closes: #632

Description

  • Added header and deserialization in UpdateClient event and Tx result output for CLIs
  • Extract header from UpdateClient transactions
  • Get headers from query_tx()
  • Misbehaviour event deserialization
  • Added the hermes misbehaviour command for monitoring a given client on a chain
  • Fix tx raw create-client to not allow same source and dest chains
  • Removed src chain from tx raw update-client as it is redundant
  • Added target and trusted heights to tx raw update-client to allow testing with different updates.
  • Added option to query all consensus states and also display only the heights.
  • Added new command to query header used when a consensus state was created.
  • Submit evidence supported for headers at same height but different BlockId-s and also for BFT time violation.
  • Checks previous updates on hermes (re)start.
  • Added query_clients() to the runtime.

For contributor use:

  • Updated the Unreleased section of CHANGELOG.md with the issue.
  • If applicable: Unit tests written, added test to CI.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments.
  • Re-reviewed Files changed in the Github PR explorer.

@ancazamfir ancazamfir changed the title Anca/misbehavior misbehavior monitoring and handling Feb 19, 2021
@codecov-io
Copy link

codecov-io commented Feb 25, 2021

Codecov Report

Merging #691 (d7293dd) into master (b1b37f5) will increase coverage by 29.4%.
The diff coverage is n/a.

❗ Current head d7293dd differs from pull request most recent head 3942d74. Consider uploading reports for the commit 3942d74 to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##           master    #691      +/-   ##
=========================================
+ Coverage    13.6%   43.1%   +29.4%     
=========================================
  Files          69     171     +102     
  Lines        3752   11883    +8131     
  Branches     1374       0    -1374     
=========================================
+ Hits          513    5123    +4610     
- Misses       2618    6760    +4142     
+ Partials      621       0     -621     
Impacted Files Coverage Δ
...application/ics20_fungible_token_transfer/error.rs 0.0% <ø> (ø)
...ion/ics20_fungible_token_transfer/msgs/transfer.rs 22.2% <ø> (ø)
..._transfer/relay_application_logic/send_transfer.rs 85.7% <ø> (ø)
modules/src/events.rs 0.0% <ø> (ø)
modules/src/handler.rs 100.0% <ø> (ø)
modules/src/ics02_client/client_consensus.rs 41.3% <ø> (ø)
modules/src/ics02_client/client_def.rs 32.3% <ø> (ø)
modules/src/ics02_client/client_state.rs 65.1% <ø> (ø)
modules/src/ics02_client/client_type.rs 79.1% <ø> (+31.5%) ⬆️
modules/src/ics02_client/context.rs 90.4% <ø> (ø)
... and 276 more

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 1c72c28...3942d74. Read the comment docs.

@ancazamfir
Copy link
Collaborator Author

this seems a little odd to me. The header bytes should contain the type_url? This is the definition in the SDK. I don't know rust, but it looks like you are creating an Any by passing in the type url using a constant and then trying to decode the encoded any into the value of the Any?

This was with a version that you had where you were not using Any.

@romac romac changed the title misbehavior monitoring and handling Misbehavior monitoring and handling Mar 25, 2021
Copy link
Member

@adizere adizere left a comment

Choose a reason for hiding this comment

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

This is impressive, great work Anca!

I left several suggestions, but should be treated as lower priority. I didn't get the chance to look closely at the important part in ForeignClient::handle_misbehaviour.

modules/src/ics02_client/client_consensus.rs Show resolved Hide resolved
modules/src/ics02_client/client_misbehaviour.rs Outdated Show resolved Hide resolved
modules/src/ics02_client/events.rs Outdated Show resolved Hide resolved
modules/src/ics02_client/msgs/misbehavior.rs Outdated Show resolved Hide resolved
modules/src/ics07_tendermint/header.rs Outdated Show resolved Hide resolved
modules/src/ics07_tendermint/header.rs Outdated Show resolved Hide resolved
relayer-cli/src/commands/misbehaviour.rs Outdated Show resolved Hide resolved
relayer/src/lib.rs Outdated Show resolved Hide resolved
relayer/src/foreign_client.rs Outdated Show resolved Hide resolved
@ancazamfir ancazamfir mentioned this pull request Apr 9, 2021
5 tasks
Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

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

Great work @ancazamfir! Pushed a couple commits with some minor changes (none semantics) and otherwise left a bunch of comments and suggestions inline.

relayer/src/foreign_client.rs Show resolved Hide resolved
relayer/src/foreign_client.rs Show resolved Hide resolved
relayer/src/foreign_client.rs Outdated Show resolved Hide resolved
relayer/src/foreign_client.rs Outdated Show resolved Hide resolved
relayer/src/foreign_client.rs Outdated Show resolved Hide resolved
relayer/src/light_client/tendermint.rs Outdated Show resolved Hide resolved
relayer-cli/src/commands/misbehaviour.rs Show resolved Hide resolved
relayer-cli/src/commands/misbehaviour.rs Outdated Show resolved Hide resolved
relayer-cli/src/commands/query/client.rs Outdated Show resolved Hide resolved
relayer-cli/src/commands/tx/client.rs Show resolved Hide resolved
relayer/src/foreign_client.rs Outdated Show resolved Hide resolved
@ancazamfir
Copy link
Collaborator Author

Thanks @romac, @cezarad and @adizere for the great comments!! I think I addressed most of them but please double check.

@ancazamfir ancazamfir requested a review from romac April 9, 2021 17:38
@romac romac merged commit ff0e6e5 into master Apr 9, 2021
@romac romac deleted the anca/misbehavior branch April 9, 2021 21:10
@romac romac mentioned this pull request Apr 12, 2021
15 tasks
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Split client_def in state, consensus, header. Add sketch for Tx decoding.

* Added misbehaviour message, structures, relayer submission

* tentative try with interim update event from cosmos PR

* trying to decode the header from event

* decode the header in client update event

* Added restart support, move some of the misbehaviour detection in light client, reorg

* fix merge

* add support for potential on-chain state pruning, cleanup

* Update changelog

* sketch for time travelling lunatic attack check

* fmt

* Decode misbehaviour events, added comments

* Update to reflect bad updates in the middle

* cargo fmt

* Cleanup consensus query and allow query for all

* Allow target and trusted heights to be specified in client updates

* Allow update with any existing trusted height

* Disallow create client with same src and dst

* Fix tests

* Added mock misbehaviour

* Fix CI and reorg code

* Cleanup

* Updates after sitdown review

* Update comments

* Flip back the logic in compatible_headers()

* Rename client_misbehaviour to misbehaviour

* review comments

* fmt

* Return UpdateClient::consensus_height by copy instead of reference

* Small cleanup in LightClient::build_misbehaviour

* Small cleanup in chain::cosmos

* Set pagination limit to u64::MAX for all queries that support it to ensure we get all results at once

See informalsystems#811

* Addressed review comments

Co-authored-by: Romain Ruetschi <romain@informal.systems>
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.

Implement misbehavior monitoring and evidence relaying
6 participants