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

Unable to decode blocks (Phoenix) received via RPC using ModuleBasics.RegisterInterfaces #248

Open
wolthrax opened this issue Feb 23, 2023 · 3 comments

Comments

@wolthrax
Copy link
Contributor

wolthrax commented Feb 23, 2023

When decoding the transactions, we get an error messagewhen decoding the block, we get an error message:
invalid character '\x12' looking for beginning of value

Working branch: terra-phoenix
File: tx_decoding.go

Function:
image

I am trying to decode a "MsgRecvPacket" message in a transaction within a block, but I am unable to do so using the ModuleBasics.RegisterInterfaces method. When I attempt to decode the message using this method, I receive an error message indicating that the decoding was unsuccessful.

Steps to reproduce:

  1. Connect to a node via RPC.
  2. Retrieve a 903443 block containing a transaction with a "MsgRecvPacket" message using the RPC.
  3. Attempt to decode the "MsgRecvPacket" message using ModuleBasics.RegisterInterfaces.

Expected result: The "MsgRecvPacket" message should be successfully decoded using the ModuleBasics.RegisterInterfaces method.

Actual result: An error message is displayed, indicating that the decoding was unsuccessful.

Block: 903443
Transaction hash: 70321A8E0FF8B6790ABC5DDE1B8623B9F99B3D58737F993BEDF68135BF0E63BF
Message: MsgRecvPacket

I am using dependencies:
github.com/terra-money/core/v2 v2.2.1
github.com/terra-money/cosmos-sdk v0.45.12-terra.1
github.com/terra-money/tendermint v0.34.21-terra.1
github.com/cosmos/ibc-go/v3 v3.4.0

I have tried decoding other types of messages in transactions (& other blocks) using the ModuleBasics.RegisterInterfaces method, and they have been successful.

Update:

I have identified that the specific issue is with the unmarshalling of the "Data" field of the "MsgRecvPacket" message to a "FungibleTokenPacketData" struct. The error message indicates that the unmarshalling was unsuccessful.

Error location: https://github.com/mapofzones/cosmos-watcher/blob/terra-phoenix/pkg/cosmos_sdk/block/parsing/msg_parsing.go#L195-L199

		data := transfer.FungibleTokenPacketData{}
		err := json.Unmarshal(msg.Packet.Data, &data)
		if err != nil {
			return nil, err
		}

After reviewing the error message and examining the code, it seems likely that the problem lies with the protobuf codec for FungibleTokenPacketData in the ibc-go library. This will need to be fixed in order to successfully unmarshal the data.

@Raumo0 Raumo0 changed the title Can't decode a blocks (Phoenix) Unable to decode blocks (Phoenix) received via RPC using ModuleBasics.RegisterInterfaces Feb 28, 2023
@javiersuweijie
Copy link

javiersuweijie commented Mar 10, 2023

903443 block should still be using an older version of the binary. Possible to try https://github.com/terra-money/core/releases/tag/v2.1.3 and https://github.com/terra-money/cosmos-sdk/releases/tag/v0.45.9-terra.2. There could be a change in the msg binary for this newest version of the terrad binary

@javiersuweijie
Copy link

Hey @wolthrax

I think here is the problem. Looking at the transaction you provided, the data field after decode. Shows this:
image

This isn't a FungibleTokenPacketData and is a custom IBC message. In the code you linked, https://github.com/mapofzones/cosmos-watcher/blob/terra-phoenix/pkg/cosmos_sdk/block/parsing/msg_parsing.go#L195-L199

The switch case assumes that all channeltypes.MsgRecvPacket messages are fungible token messages which isn't true. There could be custom messages sent in Data field. I think the code there needs to handle custom messages. Since we are only interested in FungibleTokenPacketData messages, we could ignore messages when decoding fails. WDYT?

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

No branches or pull requests

2 participants