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

fix: gov and group amino and snapshot hashes #49

Merged
merged 9 commits into from
Dec 16, 2022

Conversation

ryanchristo
Copy link
Member

@ryanchristo ryanchristo commented Dec 12, 2022

Description

This pull request adds the gov and group module amino codec fixes that were added in the following pull requests but were not included in cosmos sdk v0.46.7:

This pull request also includes RegisterLegacyAminoCodec in the mint module added in the following pull request:

Update

Another issue was discovered as tests were failing for me locally (using go 1.19) and intermittently on github (using go 1.18) and so I discovered cosmos#13373, which was resolved with two pull requests:

Also noticed the latest commit added to the release branch that fixes another failing test:

Update

To resolve the snapshot mismatch between this branch and main, one more pull request was added:


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)

@ryanchristo
Copy link
Member Author

Pending cosmos#14103 (and therefore cosmos#14214)

@clevinson
Copy link
Member

clevinson commented Dec 12, 2022

Can we cherry pick the PRs individually from upstream so they show up in the commit log?

@ryanchristo ryanchristo changed the base branch from release/v0.46.x to release/v0.46.7-regen December 14, 2022 04:55
amaury1093 and others added 4 commits December 13, 2022 21:42
* fix!(group): Register types with Amino

* Chagenlog
* fix!: Fix gov amino codec

* changelog
* fix!: Fix group amino codec

* changelog
@ryanchristo
Copy link
Member Author

ryanchristo commented Dec 14, 2022

The tests that are failing appear to be failing on release/v0.46.x. Should this be a concern?

@ryanchristo
Copy link
Member Author

We may want to clean this up and merge in separate pull requests but changes we need to make should all be included here to fix amino and to fix snapshots (and therefore require go 1.19 in regen ledger).

@ryanchristo ryanchristo changed the title fix: register gov and group amino codec fix: gov and group amino and bump go version Dec 15, 2022
@ryanchristo
Copy link
Member Author

One item I'm not totally sure on is the changes included from 2ee3503.

I excluded some changes and had to update some of the hashes separately, because some things do not exist in the release branch that were included in the original pull request.

@ryanchristo ryanchristo marked this pull request as ready for review December 15, 2022 01:08
Copy link
Member

@clevinson clevinson left a comment

Choose a reason for hiding this comment

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

Went through all the diff files (comparing against the source PRs in the description line-by-line), and I think is looking good to me!

A few comments, pointing out the hashes @ryanchristo alluded to in his last comment. Would appreciate an SDK perspective on this if @AmauryM you can have a look?

Otherwise, giving this an ACK. I'm in general support of us adding in the last commits so we ensure building with go 1.19 works as expected for regen ledger v5.0.

@@ -91,7 +91,7 @@ func TestManager_Take(t *testing.T) {
Height: 5,
Format: snapshotter.SnapshotFormat(),
Chunks: 1,
Hash: []uint8{0xcd, 0x17, 0x9e, 0x7f, 0x28, 0xb6, 0x82, 0x90, 0xc7, 0x25, 0xf3, 0x42, 0xac, 0x65, 0x73, 0x50, 0xaa, 0xa0, 0x10, 0x5c, 0x40, 0x8c, 0xd5, 0x1, 0xed, 0x82, 0xb5, 0xca, 0x8b, 0xe0, 0x83, 0xa2},
Hash: []uint8{0xcf, 0xd8, 0x16, 0xd2, 0xf8, 0x11, 0xe8, 0x90, 0x92, 0xf1, 0xfe, 0x3b, 0xea, 0xd2, 0x94, 0xfc, 0xfa, 0x4f, 0x9e, 0x2a, 0x91, 0xbe, 0xb0, 0x50, 0x83, 0xe9, 0x28, 0x62, 0x48, 0x6a, 0x4b, 0x4},
Copy link
Member

Choose a reason for hiding this comment

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

These hashes are different from the hashes in the tests on cosmos#13400 (see snapshots/manager_test.go).

@AmauryM any thoughts as to whether this might be a problem?

Choose a reason for hiding this comment

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

I think we should understand why there's a hash mismatch before merging this PR. Currently I'm not sure, and I also don't know if this will break state sync on regen-ledger or not.

Looking at git blames on the snapshot-related files, I noticed this addition wasn't included in this PR: https://github.com/cosmos/cosmos-sdk/blame/main/store/snapshots/store.go#L263. I also see we do a proto.Marshal() on the snaphot object. Maybe it's worth giving a try at backporting cosmos#13070 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved with 8985cf8

@@ -151,7 +151,7 @@ func TestMultistoreSnapshot_Checksum(t *testing.T) {
"05dfef0e32c34ef3900300f9de51f228d7fb204fa8f4e4d0d1529f083d122029",
"77d30aeeb427b0bdcedf3639adde1e822c15233d652782e171125280875aa492",
"c00c3801da889ea4370f0e647ffe1e291bd47f500e2a7269611eb4cc198b993f",
"6d565eb28776631f3e3e764decd53436c3be073a8a01fa5434afd539f9ae6eda",
"df5b8eeea83ca7f1e10824d0161bff46200ca12c02f50c1f42c8ed156368493e",
Copy link
Member

Choose a reason for hiding this comment

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

This hash update also seems to not be in a source PR (e.g. cosmos#13400)... Would be good to confirm that there's nothing to worry about here.

Choose a reason for hiding this comment

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

Store v2alpha1 is not used, so I'm not too worried about this. Though I suspect the reason of this hash mismatch is the same as the comment above.


// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/mint/Params", nil)
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 it's OK to keep this added, but I'm not sure if its actually necessary since we don't have MsgUpdateParams in v0.46.x. Either way, I don't think its harmful to add the registration here.

@ryanchristo ryanchristo changed the title fix: gov and group amino and bump go version fix: gov and group amino and snapshot hashes Dec 15, 2022
Comment on lines +40 to +41
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(groupcodec.Amino)

Choose a reason for hiding this comment

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

One thing we shouldn't forget to do in the PR that integrates this into regen-ledger, is to add these 2 lines to regen-ledger's modules too

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -151,7 +151,7 @@ func TestMultistoreSnapshot_Checksum(t *testing.T) {
"05dfef0e32c34ef3900300f9de51f228d7fb204fa8f4e4d0d1529f083d122029",
"77d30aeeb427b0bdcedf3639adde1e822c15233d652782e171125280875aa492",
"c00c3801da889ea4370f0e647ffe1e291bd47f500e2a7269611eb4cc198b993f",
"6d565eb28776631f3e3e764decd53436c3be073a8a01fa5434afd539f9ae6eda",
"df5b8eeea83ca7f1e10824d0161bff46200ca12c02f50c1f42c8ed156368493e",

Choose a reason for hiding this comment

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

Store v2alpha1 is not used, so I'm not too worried about this. Though I suspect the reason of this hash mismatch is the same as the comment above.

@@ -91,7 +91,7 @@ func TestManager_Take(t *testing.T) {
Height: 5,
Format: snapshotter.SnapshotFormat(),
Chunks: 1,
Hash: []uint8{0xcd, 0x17, 0x9e, 0x7f, 0x28, 0xb6, 0x82, 0x90, 0xc7, 0x25, 0xf3, 0x42, 0xac, 0x65, 0x73, 0x50, 0xaa, 0xa0, 0x10, 0x5c, 0x40, 0x8c, 0xd5, 0x1, 0xed, 0x82, 0xb5, 0xca, 0x8b, 0xe0, 0x83, 0xa2},
Hash: []uint8{0xcf, 0xd8, 0x16, 0xd2, 0xf8, 0x11, 0xe8, 0x90, 0x92, 0xf1, 0xfe, 0x3b, 0xea, 0xd2, 0x94, 0xfc, 0xfa, 0x4f, 0x9e, 0x2a, 0x91, 0xbe, 0xb0, 0x50, 0x83, 0xe9, 0x28, 0x62, 0x48, 0x6a, 0x4b, 0x4},

Choose a reason for hiding this comment

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

I think we should understand why there's a hash mismatch before merging this PR. Currently I'm not sure, and I also don't know if this will break state sync on regen-ledger or not.

Looking at git blames on the snapshot-related files, I noticed this addition wasn't included in this PR: https://github.com/cosmos/cosmos-sdk/blame/main/store/snapshots/store.go#L263. I also see we do a proto.Marshal() on the snaphot object. Maybe it's worth giving a try at backporting cosmos#13070 here?

* 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 <[email protected]>
@@ -91,7 +95,7 @@ func TestManager_Take(t *testing.T) {
Height: 5,
Format: snapshotter.SnapshotFormat(),
Chunks: 1,
Hash: []uint8{0xcf, 0xd8, 0x16, 0xd2, 0xf8, 0x11, 0xe8, 0x90, 0x92, 0xf1, 0xfe, 0x3b, 0xea, 0xd2, 0x94, 0xfc, 0xfa, 0x4f, 0x9e, 0x2a, 0x91, 0xbe, 0xb0, 0x50, 0x83, 0xe9, 0x28, 0x62, 0x48, 0x6a, 0x4b, 0x4},
Hash: []uint8{0xc5, 0xf7, 0xfe, 0xea, 0xd3, 0x4d, 0x3e, 0x87, 0xff, 0x41, 0xa2, 0x27, 0xfa, 0xcb, 0x38, 0x17, 0xa, 0x5, 0xeb, 0x27, 0x4e, 0x16, 0x5e, 0xf3, 0xb2, 0x8b, 0x47, 0xd1, 0xe6, 0x94, 0x7e, 0x8b},
Copy link
Member Author

@ryanchristo ryanchristo Dec 16, 2022

Choose a reason for hiding this comment

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

This was updated manually within the last commit to align with what was originally expected.

Copy link
Member Author

@ryanchristo ryanchristo Dec 16, 2022

Choose a reason for hiding this comment

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

i.e. what it was updated to in cosmos#13400

@ryanchristo
Copy link
Member Author

This did not fail for me locally but will try to rerun tests to see if intermittent:

https://github.com/regen-network/cosmos-sdk/actions/runs/3708969320/jobs/6287086423#step:6:183

@ryanchristo
Copy link
Member Author

This did not fail for me locally but will try to rerun tests to see if intermittent:

Seems to be intermittent and unrelated.

@clevinson
Copy link
Member

clevinson commented Dec 16, 2022

Just took a final pass over the latest commit comparing it to the source PR (cosmos#11825). I also verified that hashes now match what we expected from backporting cosmos#13400.

Looks like we didn't need to back port cosmos#13070 after all? Makes sense to me since the line in question that @AmauryM pointed out (defer chunkBody.Close()) only actually had an update of the //nolint comment, so there isn't any actual changes to store.go from this PR from what I can tell.

ACK from me 🎉

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

Successfully merging this pull request may close these issues.

6 participants