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

Cleanup mock context for ICS2 #305

Merged
merged 12 commits into from
Oct 15, 2020
Merged

Cleanup mock context for ICS2 #305

merged 12 commits into from
Oct 15, 2020

Conversation

adizere
Copy link
Member

@adizere adizere commented Oct 12, 2020

Closes: #296


For contributor use:

  • Unit tests written
  • Added test to CI if applicable
  • Updated CHANGELOG_PENDING.md
  • 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

@adizere adizere self-assigned this Oct 12, 2020
@adizere adizere changed the title ICS2 create_client handler adapted to global mock context Cleanup mock context for ICS2 Oct 13, 2020
@adizere adizere marked this pull request as ready for review October 13, 2020 18:50
@adizere adizere marked this pull request as draft October 13, 2020 19:04
@adizere adizere marked this pull request as ready for review October 13, 2020 19:04
romac
romac previously approved these changes Oct 14, 2020
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.

👍

Copy link
Collaborator

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

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

Looks great, left a few comments.

modules/src/mock_context.rs Show resolved Hide resolved
modules/src/mock_context.rs Outdated Show resolved Hide resolved
modules/src/ics02_client/handler.rs Outdated Show resolved Hide resolved
modules/src/ics02_client/handler/update_client.rs Outdated Show resolved Hide resolved
@romac romac dismissed their stale review October 14, 2020 12:33

Other changes are required

@codecov-io
Copy link

codecov-io commented Oct 14, 2020

Codecov Report

Merging #305 into master will increase coverage by 24.1%.
The diff coverage is 61.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #305      +/-   ##
=========================================
+ Coverage    13.6%   37.7%   +24.1%     
=========================================
  Files          69     124      +55     
  Lines        3752    8013    +4261     
  Branches     1374    2778    +1404     
=========================================
+ Hits          513    3027    +2514     
- Misses       2618    4751    +2133     
+ Partials      621     235     -386     
Impacted Files Coverage Δ
modules/src/events.rs 0.0% <0.0%> (ø)
modules/src/ics02_client/events.rs 0.0% <ø> (ø)
modules/src/ics02_client/raw.rs 0.0% <0.0%> (ø)
modules/src/ics03_connection/context.rs 0.0% <0.0%> (ø)
modules/src/ics03_connection/error.rs 16.6% <0.0%> (-16.7%) ⬇️
modules/src/ics04_channel/error.rs 75.0% <ø> (+50.0%) ⬆️
modules/src/ics04_channel/packet.rs 0.0% <0.0%> (ø)
modules/src/ics07_tendermint/client_def.rs 0.0% <0.0%> (ø)
modules/src/ics07_tendermint/error.rs 75.0% <ø> (+75.0%) ⬆️
modules/src/ics18_relayer/error.rs 0.0% <0.0%> (ø)
... and 226 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 c8a7c65...53dec60. Read the comment docs.

Copy link
Collaborator

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

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

Looks good, a couple comments on dropping the ics2_...

modules/src/ics02_client/handler.rs Outdated Show resolved Hide resolved
modules/src/ics02_client/handler.rs Outdated Show resolved Hide resolved
modules/src/ics02_client/handler.rs Outdated Show resolved Hide resolved
Co-authored-by: Anca Zamfir <ancazamfir@users.noreply.github.com>
Copy link
Collaborator

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

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

Great!!!

Comment on lines +79 to +84
pub fn with_client_parametrized(
self,
client_id: &ClientId,
client_state_height: Height,
client_type: Option<ClientType>,
consensus_state_height: Option<Height>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still not sure about this, seems that the client_state_height is a bit redundant, not clear what it means if the two heights are different. Maybe just pass an AnyHeader. But let's leave this for the next step where we support tendermint client and consensus states in the mock context and things will become more clear.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will merge this after #309. Thanks Anca!

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.

LGTM

@adizere adizere merged commit ec494b1 into master Oct 15, 2020
@adizere adizere deleted the adi/296_ics2_cleanup branch October 15, 2020 14:52
Comment on lines +110 to +116
let ctx = MockContext::default().with_client_parametrized(
&client_id,
height,
Some(ClientType::Mock),
Some(height.increment()),
);
let height = Height::new(0, 30);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that this is does not result in the same context as before (where two consensus states existed). Another problem is that the context now has a client state with latest height smaller than the highest height of the consensus states, only one here but still an invariant that we don't currently have/check is broken. Maybe add this in a different PR. Until then just remove the increment() to pass the same height for client and consensus states.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +30 to +32
// All the connections in the store.
connections: HashMap<ConnectionId, ConnectionEnd>,

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we move these back down again? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Cleaner context mocks for ICS2
4 participants