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

CLI migrate command follow-up: decode & re-encode #7464

Merged
merged 23 commits into from
Oct 9, 2020
Merged

Conversation

amaury1093
Copy link
Contributor

Description

Follow-up of #6839. In that PR, I only migrated the modules with breaking changes.

In this PR, all modules are migrated. For those without any breaking change, "migrating" just means decoding using amino, and re-encoding using JSONMarshaler.


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

@amaury1093 amaury1093 added C:CLI C:genesis relating to chain genesis C:x/genutil genutil module issues labels Oct 6, 2020
@codecov
Copy link

codecov bot commented Oct 6, 2020

Codecov Report

Merging #7464 into master will increase coverage by 0.01%.
The diff coverage is 64.44%.

@@            Coverage Diff             @@
##           master    #7464      +/-   ##
==========================================
+ Coverage   56.02%   56.03%   +0.01%     
==========================================
  Files         591      592       +1     
  Lines       37177    37253      +76     
==========================================
+ Hits        20827    20875      +48     
- Misses      14232    14261      +29     
+ Partials     2118     2117       -1     

@@ -0,0 +1,116 @@
package v040
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'll pay a beer to anyone who tells me if there's a way to make this boilerplate code shorter (esp the 5 for loops and some inner loops...)

Copy link
Member

Choose a reason for hiding this comment

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

You may be able to just amino JSON encode and decode from one version to the next. If there were no other changes, the amino JSON should be the same.

@@ -56,8 +56,16 @@ type (

Validators []Validator

Params struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing a 0.36->0.38 migration here

@amaury1093
Copy link
Contributor Author

I would need some help here, maybe @alexanderbez or @alessio ? We ran a small devnet inside Regen: using gaia, with 4 validators, around 100k blocks.

Here's the exported genesis after 100k blocks:
https://gist.github.com/amaurymartiny/10521ee802ab72ac7c5c384cc6c9e615

After running the CLI migrate command from this branch, here's the 0.40 genesis state:
https://gist.github.com/amaurymartiny/8dfb3ca35afa77f002193ca00b63429f

Repro

You can download the 0.40 genesis json, and run:

simd init --chain-id devnet-40 <your_name>
rm ~/.simapp/config/genesis.json
cp v040_genesis.json ~/.simapp/config/genesis.json
simd start

Expected

no error

Actual

$ ./build/simd start
I[2020-10-07|17:43:52.905] starting ABCI with Tendermint                module=main 
panic: invariant broken: staking: bonded and not bonded module account coins invariant
	Pool's bonded tokens: 101970100000stake
	sum of bonded tokens: 0
not bonded token invariance:
	Pool's not bonded tokens: 990000000stake
	sum of not bonded tokens: 102960100000
module accounts total (bonded + not bonded):
	Module Accounts' tokens: 102960100000stake
	sum tokens:              102960100000


	CRITICAL please submit the following transaction:
		 tx crisis invariant-broken staking module-accounts

@alexanderbez
Copy link
Contributor

what version of Gaia did you export from? Did you go from 0.37 -> 0.39 -> 0.40? Also, did you export for zero-height?

@amaury1093
Copy link
Contributor Author

$ gaiacli version
2.0.13

Did you go from 0.37 -> 0.39 -> 0.40?

No, we didn't have a gaia updated to latest 0.40 yet. So we actually went from gaia (0.37) -> simapp (0.40), the error is coming from simapp.

Also, did you export for zero-height?

yes

@alexanderbez
Copy link
Contributor

So we actually went from gaia (0.37) -> simapp (0.40)

How did you do this? Maybe there is a user error somewhere?

@amaury1093
Copy link
Contributor Author

How did you do this? Maybe there is a user error somewhere?

  • run gaia (0.37), export state with --for-zero-height. See the 1st gist for output.
  • checkout this branch of the SDK, run simd migrate 0.38, simd migrate 0.39, simd migrate 0.40 one after the other. The output is in the 2nd gist.
  • Assuming the final migrated genesis.json is called v040_genesis.json, run the repro I pasted above:
simd init --chain-id devnet-40 <your_name>
rm ~/.simapp/config/genesis.json
cp v040_genesis.json ~/.simapp/config/genesis.json
simd start

lmk if it's a user error (might be possible since we're running simapp on a gaia-exported genesis), not 100% sure, might also be an error in the CLI migrate command somewhere in the middle.

@alexanderbez
Copy link
Contributor

Hmmm I think it'd be best to run the entire thing either against Gaia or Simapp and not switch tbh. That being said, it might be an error in migration. The bonded and non-bonded pools are wayyy off.

@amaury1093 amaury1093 marked this pull request as ready for review October 8, 2020 18:29
@amaury1093
Copy link
Contributor Author

amaury1093 commented Oct 8, 2020

Putting R4R, it'll be good to get a 1st round of review. We'll be testing internally at regen a bit more to find out why it panics (which might or might not be related to the migrate command).

@zmanian
Copy link
Member

zmanian commented Oct 8, 2020

Just an FYI, we will be attempt non-zero height snapshot off the hub for a Stargate testnet next week. Would love to know more about the panic

types/staking.go Outdated Show resolved Hide resolved
@amaury1093
Copy link
Contributor Author

The panic is fixed in 5d608ac, this PR is R4R now.

Copy link
Contributor

@blushi blushi left a comment

Choose a reason for hiding this comment

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

Pre-approving, this needs clarification #7464 (comment)

types/staking.go Outdated Show resolved Hide resolved
x/genutil/legacy/v040/migrate.go Outdated Show resolved Hide resolved
@clevinson
Copy link
Contributor

Approving, but i'd like to see the int32 > enum piece still happen within v0.40.0 if possible. Should be a pretty small lift?

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

ACK 🎉

@@ -0,0 +1,116 @@
package v040
Copy link
Member

Choose a reason for hiding this comment

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

You may be able to just amino JSON encode and decode from one version to the next. If there were no other changes, the amino JSON should be the same.

@clevinson clevinson added the A:automerge Automatically merge PR once all prerequisites pass. label Oct 9, 2020
@amaury1093
Copy link
Contributor Author

@clevinson sounds good! I started #7499, can finish it Monday, and we can release an RC after.

@mergify mergify bot merged commit c14a3a7 into master Oct 9, 2020
@mergify mergify bot deleted the am-migrate-followup branch October 9, 2020 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:CLI C:genesis relating to chain genesis C:x/genutil genutil module issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants