From be19d93f99316ff27f780415138bc19a34550cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 14 Apr 2021 18:11:25 +0200 Subject: [PATCH 1/3] fix merkle prefix casting bug, credit: @devashishdxt --- modules/light-clients/06-solomachine/types/client_state.go | 2 +- .../light-clients/06-solomachine/types/client_state_test.go | 6 ++++-- modules/light-clients/06-solomachine/types/codec_test.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/light-clients/06-solomachine/types/client_state.go b/modules/light-clients/06-solomachine/types/client_state.go index d008ac81be9..ad547b51d1d 100644 --- a/modules/light-clients/06-solomachine/types/client_state.go +++ b/modules/light-clients/06-solomachine/types/client_state.go @@ -435,7 +435,7 @@ func produceVerificationArgs( return nil, nil, 0, 0, sdkerrors.Wrap(commitmenttypes.ErrInvalidPrefix, "prefix cannot be empty") } - _, ok := prefix.(commitmenttypes.MerklePrefix) + _, ok := prefix.(*commitmenttypes.MerklePrefix) if !ok { return nil, nil, 0, 0, sdkerrors.Wrapf(commitmenttypes.ErrInvalidPrefix, "invalid prefix type %T, expected MerklePrefix", prefix) } diff --git a/modules/light-clients/06-solomachine/types/client_state_test.go b/modules/light-clients/06-solomachine/types/client_state_test.go index 6666f2d493a..37d803eef01 100644 --- a/modules/light-clients/06-solomachine/types/client_state_test.go +++ b/modules/light-clients/06-solomachine/types/client_state_test.go @@ -19,7 +19,9 @@ const ( ) var ( - prefix = commitmenttypes.NewMerklePrefix([]byte("ibc")) + prefix = &commitmenttypes.MerklePrefix{ + KeyPrefix: []byte("ibc"), + } consensusHeight = clienttypes.ZeroHeight() ) @@ -385,7 +387,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { } func (suite *SoloMachineTestSuite) TestVerifyConnectionState() { - counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, prefix) + counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, *prefix) conn := connectiontypes.NewConnectionEnd(connectiontypes.OPEN, "clientA", counterparty, connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions()), 0) path := suite.solomachine.GetConnectionStatePath(testConnectionID) diff --git a/modules/light-clients/06-solomachine/types/codec_test.go b/modules/light-clients/06-solomachine/types/codec_test.go index d4589be6a43..e635cb8c65f 100644 --- a/modules/light-clients/06-solomachine/types/codec_test.go +++ b/modules/light-clients/06-solomachine/types/codec_test.go @@ -67,7 +67,7 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { }, { "connection", types.CONNECTION, func() { - counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, prefix) + counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, *prefix) conn := connectiontypes.NewConnectionEnd(connectiontypes.OPEN, "clientA", counterparty, connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions()), 0) path := solomachine.GetConnectionStatePath("connectionID") @@ -98,7 +98,7 @@ func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { }, { "bad channel (uses connection data)", types.CHANNEL, func() { - counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, prefix) + counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, *prefix) conn := connectiontypes.NewConnectionEnd(connectiontypes.OPEN, "clientA", counterparty, connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions()), 0) path := solomachine.GetConnectionStatePath("connectionID") From 0673e148bb0b3c2894645922db1258623f509ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 14 Apr 2021 18:14:47 +0200 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e92fea92aa..1df5346f190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,8 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (modules/light-clients/06-solomachine) [\#122](https://github.com/cosmos/ibc-go/pull/122) Fix solo machine merkle prefix casting bug. * (modules/light-clients/06-solomachine) [\#120](https://github.com/cosmos/ibc-go/pull/120) Fix solo machine handshake verification bug. + ### API Breaking * (modules/core) [\#109](https://github.com/cosmos/ibc-go/pull/109) Remove connection and channel handshake CLI commands. From 447d6881aa4cb4100f2fd85b28b53c2e361dbdcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 14 Apr 2021 18:20:34 +0200 Subject: [PATCH 3/3] update docs --- modules/light-clients/06-solomachine/spec/01_concepts.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/light-clients/06-solomachine/spec/01_concepts.md b/modules/light-clients/06-solomachine/spec/01_concepts.md index de486b71b1a..a121803f43c 100644 --- a/modules/light-clients/06-solomachine/spec/01_concepts.md +++ b/modules/light-clients/06-solomachine/spec/01_concepts.md @@ -108,6 +108,9 @@ timestampedSignatureData := &types.TimestampedSignatureData{ proof, err := cdc.MarshalBinaryBare(timestampedSignatureData) ``` +NOTE: At the end of this process, the sequence associated with the key needs to be updated. +The sequence must be incremented each time proof is generated. + ## Updates By Header An update by a header will only succeed if: