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

02-client-refactor: rename update to UpdateState for 07-tendermint #1117

Merged
merged 9 commits into from
Mar 24, 2022

Conversation

colin-axner
Copy link
Contributor

@colin-axner colin-axner commented Mar 14, 2022

Description

  • rename 07-tendermint update function to UpdateState
  • add pruneOldestConsensusState function
  • add check for duplicate update

ref: #879


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

rename 07-tendermint update function to UpdateState
add pruneOldestConsensusState function
add check for duplicate update
Comment on lines +276 to +278
if pruneError != nil {
panic(pruneError)
}
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 think we should just panic within the iterate function, but I can fix in a followup pr

testCases := []struct {
name string
malleate func()
expResult func()
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 find it useful to add a expected results callback for test cases which need to check unique state changes

Copy link
Member

Choose a reason for hiding this comment

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

Nice, I could see this being a useful approach for testing other state updates. ICS29 tests come to mind! :)

@colin-axner colin-axner marked this pull request as ready for review March 16, 2022 14:01
Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Nice work, looks clean! LGTM 🚀

// pruneOldestConsensusState will retrieve the earliest consensus state for this clientID and check if it is expired. If it is,
// that consensus state will be pruned from store along with all associated metadata. This will prevent the client store from
// becoming bloated with expired consensus states that can no longer be used for updates and packet verification.
func (cs ClientState) pruneOldestConsensusState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: add some logical spacing between code in this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good. Copied from existing code, but agree it could use spacing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated!

testCases := []struct {
name string
malleate func()
expResult func()
Copy link
Member

Choose a reason for hiding this comment

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

Nice, I could see this being a useful approach for testing other state updates. ICS29 tests come to mind! :)

@colin-axner colin-axner merged commit 5e3bac0 into 02-client-refactor Mar 24, 2022
@colin-axner colin-axner deleted the colin/879-tm-updatestate branch March 24, 2022 14:29
seunlanlege pushed a commit to ComposableFi/ibc-go that referenced this pull request Aug 9, 2022
…osmos#1117)

* rename update to UpdateState

rename 07-tendermint update function to UpdateState
add pruneOldestConsensusState function
add check for duplicate update

* fix: duplicate update check was performing incorrect logic

* update godoc

* add UpdateState tests

* update godoc

* chore: fix code spacing

Co-authored-by: Sean King <seantking@users.noreply.github.com>
CosmosCar pushed a commit to caelus-labs/ibc-go that referenced this pull request Nov 6, 2023
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.
-->

## Overview
I did a quick audit of the code for infinite for loops to catch any
remaining places where we might be hanging after a shutdown.

This PR adds some comments to explain some test helpers and adds two
select statements that watch for cancellation of subscriptions to help
with a cleaner shutdown.

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 
-->

closes cosmos#1069 

## Checklist

<!-- 
Please complete the checklist to ensure that the PR is ready to be
reviewed.

IMPORTANT:
PRs should be left in Draft until the below checklist is completed.
-->

- [ ] New and updated code has appropriate documentation
- [ ] New and updated code has new and/or updated testing
- [ ] Required CI checks are passing
- [ ] Visual proof for any user facing features like CLI or
documentation updates
- [ ] Linked issues closed with keywords
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.

3 participants