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 · 2 comments · May be fixed by #7767
Open

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

damiannolan opened this issue Dec 17, 2024 · 2 comments · May be fixed by #7767
Assignees
Milestone

Comments

@damiannolan
Copy link
Member

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
Member Author

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

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

Successfully merging a pull request may close this issue.

2 participants