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

Migration path for math.IntProto to math.Int (breaking) #7699

Open
damiannolan opened this issue Dec 17, 2024 · 3 comments · May be fixed by #7919 or #7767
Open

Migration path for math.IntProto to math.Int (breaking) #7699

damiannolan opened this issue Dec 17, 2024 · 3 comments · May be fixed by #7919 or #7767
Labels
icebox Issues that we will not address for the time being

Comments

@damiannolan
Copy link
Contributor

Handle migration of math.IntProto (proto encoding) to math.Int (binary encoding).

See thread in PR #7261.

Confirmed with @julienrbrt that this is breaking.

func TestMathIntIntProtoEqual(t *testing.T) {
	mathInt := math.NewInt(100)
	interfaceRegistry := testutil.CodecOptions{}.NewInterfaceRegistry()
	codec := codec.NewProtoCodec(interfaceRegistry)

	ip := types.IntProto{Int: mathInt}
	ipBz := codec.MustMarshal(&ip)

	bz, err := mathInt.Marshal()
	require.NoError(t, err)
	require.Equal(t, ipBz, bz)

	amount := math.Int{}
	err = amount.Unmarshal(ipBz)
	require.NoError(t, err)
	require.Equal(t, mathInt, amount)
}

The above fails.

The IntProto type will be readded to sdk and the recommendation is to do a migration. Either with upgrade handler or lazy migration by updating this k/v entry to use collections.

Originally posted by @damiannolan in #7261 (comment)

@damiannolan damiannolan self-assigned this Dec 17, 2024
@damiannolan damiannolan added this to the v10.0.0 milestone Dec 17, 2024
@julienrbrt
Copy link
Member

You should be able to use the AltValueCodec from collections: https://github.com/cosmos/cosmos-sdk/blob/collections/v1.0.0-rc.1/collections/codec/alternative_value.go#L20

@damiannolan
Copy link
Contributor Author

Thanks, will try to take a look at it in the coming days

@tac0turtle
Copy link
Member

the code that changed this can be reverted, we brought it back. it should save a migration and extra work. happy to knock it out if needed

@tac0turtle tac0turtle linked a pull request Feb 6, 2025 that will close this issue
10 tasks
@gjermundgaraba gjermundgaraba removed their assignment Feb 6, 2025
@gjermundgaraba gjermundgaraba added the icebox Issues that we will not address for the time being label Feb 6, 2025
@gjermundgaraba gjermundgaraba removed this from the v10.0.0 milestone Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
icebox Issues that we will not address for the time being
Projects
None yet
4 participants