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

MockClient verifyMembership error #165

Closed
yoshidan opened this issue Mar 22, 2023 · 2 comments
Closed

MockClient verifyMembership error #165

yoshidan opened this issue Mar 22, 2023 · 2 comments

Comments

@yoshidan
Copy link
Contributor

yoshidan commented Mar 22, 2023

The proof commitment for MsgRecvPacket uses sha256 + sha256 .

commitment := chantypes.CommitPacket(c.Codec(), packet)

https://github.com/cosmos/ibc-go/blob/12c00ec85c1238a0b9075a14593485c60f0da729/modules/core/04-channel/types/packet.go#L19

On the other hand, IBCPacket uses sha256 + sha256 and MockClient verifyMembership further performs sha256, which always seems to cause an error. In fact, it failed in my environment.

sha256(
abi.encodePacked(
msg_.packet.timeout_timestamp,
msg_.packet.timeout_height.revision_number,
msg_.packet.timeout_height.revision_height,
sha256(msg_.packet.data)
)
)

return sha256(value) == proof.toBytes32(0);

It looks like we should'n use sha256 for verifyMembership in MockClient, but it is still an error because sha256 is used in yui-relayer for connection and channel.
https://github.com/hyperledger-labs/yui-relayer/blob/d4cc52059626e9dd86433dbd78de0c40fba87f5b/provers/mock/prover.go#L159

As a tentative response, I was able to prevent the error by modifying MockClient's verifyMembership as follows.

//before 
return sha256(value) == proof.toBytes32(0);

//after
bytes32 v = value.toBytes32(0); // for packet
bytes32 s = sha256(value); // for connection and channel
bytes32 p = proof.toBytes32(0);
return s == p; || v == p;
@yoshidan yoshidan changed the title MockClient verifyMembership causes error MockClient verifyMembership error Mar 22, 2023
@yoshidan yoshidan reopened this Mar 23, 2023
@bluele
Copy link
Member

bluele commented Mar 24, 2023

I think the problem is that the mock-client does not support the generic verification function.
https://github.com/datachainlab/ibc-mock-client/blob/main/modules/light-clients/xx-mock/types/client_state.go#L225

The property of being able to verify commtiment in the same method, independent of the commitment path, would be important to support some applications (e.g. https://github.com/cosmos/ibc/tree/main/spec/app/ics-031-crosschain-queries)

@bluele
Copy link
Member

bluele commented May 10, 2023

I close this issue since already opened the issue in ibc-mock-client: datachainlab/ibc-mock-client#7

@bluele bluele closed this as completed May 10, 2023
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