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

feat: Make extension snapshotter interface safer to use #11825

Merged
merged 12 commits into from
Aug 18, 2022

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Apr 29, 2022

Closes: #11824
Solution:

  • Use new methods SnapshotExtension/RestoreExtension to handle payload stream specifically.
  • Improve unit tests.

Description

more details in the closed issue.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Closes: cosmos#11824
Solution:
- Use new methods `SnapshotExtension`/`RestoreExtension` to handle payload stream specifically.
- Improve unit tests.
@github-actions github-actions bot added the T: ADR An issue or PR relating to an architectural decision record label Apr 29, 2022
CHANGELOG.md Outdated Show resolved Hide resolved
return nil
}

func (s *extSnapshotter) RestoreExtension(height uint64, format uint32, payloadReader snapshottypes.ExtensionPayloadReader) error {
Copy link
Collaborator Author

@yihuang yihuang Apr 29, 2022

Choose a reason for hiding this comment

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

An typical extension implementation.

@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jun 17, 2022
@tac0turtle
Copy link
Member

@JeancarloBarrios any chance you can review this, seems like this was assigned with no follow wup

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

@alexanderbez could you pop in for a review

@codecov
Copy link

codecov bot commented Aug 15, 2022

Codecov Report

Merging #11825 (bba13cf) into main (0ed7360) will increase coverage by 0.07%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11825      +/-   ##
==========================================
+ Coverage   55.50%   55.57%   +0.07%     
==========================================
  Files         646      646              
  Lines       54870    54891      +21     
==========================================
+ Hits        30453    30508      +55     
+ Misses      21962    21919      -43     
- Partials     2455     2464       +9     
Impacted Files Coverage Δ
snapshots/manager.go 56.91% <57.14%> (+9.32%) ⬆️
crypto/keys/internal/ecdsa/privkey.go 81.13% <0.00%> (-1.89%) ⬇️
x/group/keeper/keeper.go 55.90% <0.00%> (-0.40%) ⬇️
x/distribution/simulation/operations.go 90.42% <0.00%> (+9.57%) ⬆️

snapshots/types/util.go Outdated Show resolved Hide resolved
m.items = [][]byte{}
for {
item := &snapshottypes.SnapshotItem{}
err := protoReader.ReadMsg(item)
item.Reset()
Copy link
Member

Choose a reason for hiding this comment

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

is there a test case to test this in handled correctly? I recently ran into an issue where we used .Reset like this and the api is different than what we expected

Copy link
Collaborator Author

@yihuang yihuang Aug 16, 2022

Choose a reason for hiding this comment

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

func (m *SnapshotItem) Reset()         { *m = SnapshotItem{} }

looks straightforward enough to me, what issue did you have? Do you have a concern that after ReadMsg, some fields still keep the values from the last one?

snapshots/types/util.go Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@alexanderbez alexanderbez changed the title Make extension snapshotter interface safer to use feat: Make extension snapshotter interface safer to use Aug 17, 2022
@alexanderbez
Copy link
Contributor

@yihuang could you quickly take a look at the linting failures pls?

types/events.go:6: File is not `gofumpt`-ed (gofumpt)
	"golang.org/x/exp/maps"
	"golang.org/x/exp/slices"
types/events.go:10: File is not `gofumpt`-ed (gofumpt)
	"strings"

@yihuang
Copy link
Collaborator Author

yihuang commented Aug 18, 2022

@yihuang could you quickly take a look at the linting failures pls?

types/events.go:6: File is not `gofumpt`-ed (gofumpt)
	"golang.org/x/exp/maps"
	"golang.org/x/exp/slices"
types/events.go:10: File is not `gofumpt`-ed (gofumpt)
	"strings"

It's strange this PR doesn't touch this file. I update the main branch again and it disppears.

@tac0turtle tac0turtle merged commit e397434 into cosmos:main Aug 18, 2022
@yihuang yihuang deleted the safer-snapshotter-api branch August 18, 2022 07:35
ryanchristo pushed a commit to regen-network/cosmos-sdk that referenced this pull request Dec 16, 2022
* Make extension snapshotter interface safer to use

Closes: cosmos#11824
Solution:
- Use new methods `SnapshotExtension`/`RestoreExtension` to handle payload stream specifically.
- Improve unit tests.

* update changelog

* Update snapshots/types/util.go

* changelog

* go linter

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
mhofman pushed a commit to agoric-labs/cosmos-sdk that referenced this pull request Feb 24, 2023
* Make extension snapshotter interface safer to use

Closes: cosmos#11824
Solution:
- Use new methods `SnapshotExtension`/`RestoreExtension` to handle payload stream specifically.
- Improve unit tests.

* update changelog

* Update snapshots/types/util.go

* changelog

* go linter

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

(cherry picked from commit e397434)
mhofman pushed a commit to agoric-labs/cosmos-sdk that referenced this pull request Mar 8, 2023
* Make extension snapshotter interface safer to use

Closes: cosmos#11824
Solution:
- Use new methods `SnapshotExtension`/`RestoreExtension` to handle payload stream specifically.
- Improve unit tests.

* update changelog

* Update snapshots/types/util.go

* changelog

* go linter

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

(cherry picked from commit e397434)
mhofman pushed a commit to agoric-labs/cosmos-sdk that referenced this pull request Mar 14, 2023
* Make extension snapshotter interface safer to use

Closes: cosmos#11824
Solution:
- Use new methods `SnapshotExtension`/`RestoreExtension` to handle payload stream specifically.
- Improve unit tests.

* update changelog

* Update snapshots/types/util.go

* changelog

* go linter

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

(cherry picked from commit e397434)
mhofman pushed a commit to agoric-labs/cosmos-sdk that referenced this pull request Mar 23, 2023
* Make extension snapshotter interface safer to use

Closes: cosmos#11824
Solution:
- Use new methods `SnapshotExtension`/`RestoreExtension` to handle payload stream specifically.
- Improve unit tests.

* update changelog

* Update snapshots/types/util.go

* changelog

* go linter

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

(cherry picked from commit e397434)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: ADR An issue or PR relating to an architectural decision record Type: ADR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make extension snapshotter interface safer to use
5 participants