From 26e19db15b1d96d599882b2ba634ccef07488b85 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Tue, 26 Sep 2023 12:45:45 +0200 Subject: [PATCH] fix(api)!: remove `Pretty` and `String` custom implementations of `MerklePath` (#4459) ## Description Second part of #4128. First part was #4429. closes: #4128 ### Commit Message / Changelog Entry ```bash fix(api)!: remove `Pretty` and `String` custom implementations of `MerklePath` ``` see the [guidelines](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#commit-messages) for commit messages. (view raw markdown for examples) --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#pull-request-targeting)). - [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules/11-structure.md) and [Go style guide](../docs/dev/go-style-guide.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/main/testing/README.md#ibc-testing-package). - [ ] Updated relevant documentation (`docs/`) or specification (`x//spec/`). - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Provide a [commit message](https://github.com/cosmos/ibc-go/blob/main/docs/dev/pull-requests.md#commit-messages) to be used for the changelog entry in the PR description for review. - [x] Re-reviewed `Files changed` in the Github PR explorer. - [ ] Review `Codecov Report` in the comment section below once CI passes. --- .../core/23-commitment/types/commitment.pb.go | 47 +++++++++-------- modules/core/23-commitment/types/merkle.go | 38 -------------- .../core/23-commitment/types/merkle_test.go | 21 +------- modules/core/exported/commitment.go | 1 - .../06-solomachine/client_state_test.go | 16 +++--- proto/ibc/core/commitment/v1/commitment.proto | 2 - testing/solomachine.go | 52 +++++++------------ 7 files changed, 50 insertions(+), 127 deletions(-) diff --git a/modules/core/23-commitment/types/commitment.pb.go b/modules/core/23-commitment/types/commitment.pb.go index 29f883de776..bf95874a8ac 100644 --- a/modules/core/23-commitment/types/commitment.pb.go +++ b/modules/core/23-commitment/types/commitment.pb.go @@ -117,8 +117,9 @@ type MerklePath struct { KeyPath []string `protobuf:"bytes,1,rep,name=key_path,json=keyPath,proto3" json:"key_path,omitempty"` } -func (m *MerklePath) Reset() { *m = MerklePath{} } -func (*MerklePath) ProtoMessage() {} +func (m *MerklePath) Reset() { *m = MerklePath{} } +func (m *MerklePath) String() string { return proto.CompactTextString(m) } +func (*MerklePath) ProtoMessage() {} func (*MerklePath) Descriptor() ([]byte, []int) { return fileDescriptor_7921d88972a41469, []int{2} } @@ -217,27 +218,27 @@ func init() { } var fileDescriptor_7921d88972a41469 = []byte{ - // 315 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0x31, 0x4f, 0xc3, 0x30, - 0x10, 0x85, 0x13, 0x51, 0x15, 0xea, 0x76, 0xb2, 0x10, 0x82, 0x0a, 0x4c, 0xd5, 0x01, 0xba, 0xc4, - 0x56, 0xdb, 0xa5, 0xaa, 0x98, 0x60, 0x60, 0x42, 0xaa, 0x32, 0x30, 0xb0, 0xa0, 0xc4, 0xb8, 0x89, - 0xd5, 0x86, 0x8b, 0x62, 0x37, 0xa2, 0xff, 0x80, 0x91, 0x91, 0x91, 0x9f, 0xc3, 0xd8, 0x91, 0x11, - 0xb5, 0x7f, 0x04, 0xd9, 0x6e, 0x50, 0xb6, 0x3b, 0xbd, 0xcf, 0x4f, 0x7e, 0xef, 0xd0, 0xb5, 0x8c, - 0x39, 0xe3, 0x50, 0x08, 0xc6, 0x21, 0xcb, 0xa4, 0xce, 0xc4, 0xab, 0x66, 0xe5, 0xb0, 0xb6, 0xd1, - 0xbc, 0x00, 0x0d, 0xf8, 0x44, 0xc6, 0x9c, 0x1a, 0x90, 0xd6, 0xa4, 0x72, 0xd8, 0x3d, 0x4e, 0x20, - 0x01, 0x8b, 0x30, 0x33, 0x39, 0xba, 0x7b, 0xce, 0x41, 0x65, 0xa0, 0x98, 0xe4, 0x6a, 0x34, 0x36, - 0x7e, 0x79, 0x01, 0x30, 0x57, 0x4e, 0xed, 0x5f, 0x21, 0xf4, 0x20, 0x8a, 0xc5, 0x52, 0x84, 0x00, - 0x1a, 0x63, 0xd4, 0x48, 0x23, 0x95, 0x9e, 0xfa, 0x3d, 0x7f, 0xd0, 0x09, 0xed, 0x3c, 0x6d, 0xbc, - 0x7f, 0x5d, 0x7a, 0xfd, 0x00, 0x75, 0x1c, 0x37, 0x2b, 0xc4, 0x5c, 0xbe, 0xe1, 0x0b, 0x84, 0x16, - 0x62, 0xfd, 0x9c, 0xdb, 0x6d, 0xcf, 0xb7, 0x16, 0x62, 0xed, 0xe4, 0x7e, 0x50, 0xd9, 0xce, 0x22, - 0x9d, 0xe2, 0x33, 0x74, 0x64, 0xe1, 0x48, 0x1b, 0xeb, 0x83, 0x41, 0x2b, 0x3c, 0x34, 0x68, 0xa4, - 0xd3, 0x69, 0xe3, 0xd3, 0xb8, 0xdf, 0xa3, 0x76, 0xe5, 0x0e, 0x30, 0xc7, 0x13, 0xd4, 0x74, 0x9f, - 0xb4, 0x74, 0x7b, 0xd4, 0xa3, 0x2e, 0x03, 0xb5, 0x19, 0x68, 0x39, 0xa4, 0x77, 0xff, 0xc1, 0xed, - 0x8b, 0x70, 0xcf, 0xdf, 0x3e, 0x7e, 0x6f, 0x89, 0xbf, 0xd9, 0x12, 0xff, 0x77, 0x4b, 0xfc, 0x8f, - 0x1d, 0xf1, 0x36, 0x3b, 0xe2, 0xfd, 0xec, 0x88, 0xf7, 0x74, 0x93, 0x48, 0x9d, 0xae, 0x62, 0x53, - 0x19, 0xab, 0x1a, 0x89, 0x79, 0x90, 0x00, 0x2b, 0x27, 0x2c, 0x83, 0x97, 0xd5, 0x52, 0x28, 0xd7, - 0xfe, 0x68, 0x1c, 0xd4, 0x0e, 0xa0, 0xd7, 0xb9, 0x50, 0x71, 0xd3, 0xb6, 0x35, 0xfe, 0x0b, 0x00, - 0x00, 0xff, 0xff, 0xcb, 0xa1, 0x7a, 0x2b, 0xa4, 0x01, 0x00, 0x00, + // 312 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xb1, 0x4e, 0xeb, 0x30, + 0x14, 0x86, 0x13, 0xdd, 0xaa, 0x97, 0xba, 0x9d, 0x2c, 0x84, 0xa0, 0x02, 0x53, 0x65, 0xa0, 0x5d, + 0x6a, 0xab, 0xed, 0x52, 0x21, 0x26, 0x18, 0x98, 0x90, 0xaa, 0x0c, 0x0c, 0x2c, 0x28, 0x31, 0x6e, + 0x62, 0xb5, 0xe1, 0x44, 0xb1, 0x1b, 0xd1, 0x37, 0x60, 0xe4, 0x11, 0x78, 0x1c, 0xc6, 0x8e, 0x8c, + 0xa8, 0x79, 0x11, 0x64, 0xbb, 0x41, 0xd9, 0xce, 0xd1, 0xf9, 0xfc, 0xeb, 0xf7, 0x87, 0x86, 0x32, + 0xe6, 0x8c, 0x43, 0x21, 0x18, 0x87, 0x2c, 0x93, 0x3a, 0x13, 0xaf, 0x9a, 0x95, 0x93, 0xc6, 0x46, + 0xf3, 0x02, 0x34, 0xe0, 0x13, 0x19, 0x73, 0x6a, 0x40, 0xda, 0x38, 0x95, 0x93, 0xfe, 0x71, 0x02, + 0x09, 0x58, 0x84, 0x99, 0xc9, 0xd1, 0xfd, 0x73, 0x0e, 0x2a, 0x03, 0xc5, 0x24, 0x57, 0xd3, 0x99, + 0xc9, 0xcb, 0x0b, 0x80, 0xa5, 0x72, 0xd7, 0xe0, 0x0a, 0xa1, 0x07, 0x51, 0xac, 0xd6, 0x22, 0x04, + 0xd0, 0x18, 0xa3, 0x56, 0x1a, 0xa9, 0xf4, 0xd4, 0x1f, 0xf8, 0xa3, 0x5e, 0x68, 0xe7, 0xeb, 0xd6, + 0xfb, 0xe7, 0xa5, 0x17, 0x8c, 0x51, 0xcf, 0x71, 0x8b, 0x42, 0x2c, 0xe5, 0x1b, 0xbe, 0x40, 0x68, + 0x25, 0xb6, 0xcf, 0xb9, 0xdd, 0x0e, 0x7c, 0x67, 0x25, 0xb6, 0xee, 0x1c, 0x0c, 0xeb, 0xd8, 0x45, + 0xa4, 0x53, 0x7c, 0x86, 0x8e, 0x2c, 0x1c, 0x69, 0x13, 0xfd, 0x6f, 0xd4, 0x09, 0xff, 0x1b, 0x34, + 0xd2, 0x69, 0x70, 0x8f, 0xba, 0x75, 0x2e, 0xc0, 0x12, 0xcf, 0x51, 0xdb, 0xd5, 0xb3, 0x5c, 0x77, + 0x3a, 0xa0, 0xae, 0x3d, 0xb5, 0xed, 0x69, 0x39, 0xa1, 0x77, 0x7f, 0x5f, 0xb6, 0x2f, 0xc2, 0x03, + 0x7f, 0xfb, 0xf8, 0xb5, 0x27, 0xfe, 0x6e, 0x4f, 0xfc, 0x9f, 0x3d, 0xf1, 0x3f, 0x2a, 0xe2, 0xed, + 0x2a, 0xe2, 0x7d, 0x57, 0xc4, 0x7b, 0xba, 0x49, 0xa4, 0x4e, 0x37, 0xb1, 0x91, 0xc5, 0x6a, 0x17, + 0x31, 0x1f, 0x27, 0xc0, 0xca, 0x39, 0xcb, 0xe0, 0x65, 0xb3, 0x16, 0xca, 0x79, 0x9f, 0xce, 0xc6, + 0x0d, 0xf5, 0x7a, 0x9b, 0x0b, 0x15, 0xb7, 0xad, 0xa7, 0xd9, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x55, 0x02, 0x17, 0xe1, 0x9e, 0x01, 0x00, 0x00, } func (m *MerkleRoot) Marshal() (dAtA []byte, err error) { diff --git a/modules/core/23-commitment/types/merkle.go b/modules/core/23-commitment/types/merkle.go index 9c00e176f73..751ae81677a 100644 --- a/modules/core/23-commitment/types/merkle.go +++ b/modules/core/23-commitment/types/merkle.go @@ -3,7 +3,6 @@ package types import ( "bytes" "fmt" - "net/url" "github.com/cosmos/gogoproto/proto" ics23 "github.com/cosmos/ics23/go" @@ -77,44 +76,7 @@ func NewMerklePath(keyPath ...string) MerklePath { } } -// String implements fmt.Stringer. -// This represents the path in the same way the tendermint KeyPath will -// represent a key path. The backslashes partition the key path into -// the respective stores they belong to. -// -// Deprecated: This function makes assumptions about the way a merkle path -// in a multistore should be represented as a string that are not standardized. -// The decision on how to represent the merkle path as a string will be deferred -// to upstream users of the type. -// This function will be removed in a next release. -func (mp MerklePath) String() string { - pathStr := "" - for _, k := range mp.KeyPath { - pathStr += "/" + url.PathEscape(k) - } - return pathStr -} - -// Pretty returns the unescaped path of the URL string. -// This function will unescape any backslash within a particular store key. -// This makes the keypath more human-readable while removing information -// about the exact partitions in the key path. -// -// Deprecated: This function makes assumptions about the way a merkle path -// in a multistore should be represented as a string that are not standardized. -// The decision on how to represent the merkle path as a string will be deferred -// to upstream users of the type. -// This function will be removed in a next release. -func (mp MerklePath) Pretty() string { - path, err := url.PathUnescape(mp.String()) - if err != nil { - panic(err) - } - return path -} - // GetKey will return a byte representation of the key -// after URL escaping the key element func (mp MerklePath) GetKey(i uint64) ([]byte, error) { if i >= uint64(len(mp.KeyPath)) { return nil, fmt.Errorf("index out of range. %d (index) >= %d (len)", i, len(mp.KeyPath)) diff --git a/modules/core/23-commitment/types/merkle_test.go b/modules/core/23-commitment/types/merkle_test.go index 9b15c3218b8..74ea939abb9 100644 --- a/modules/core/23-commitment/types/merkle_test.go +++ b/modules/core/23-commitment/types/merkle_test.go @@ -150,24 +150,5 @@ func TestApplyPrefix(t *testing.T) { prefixedPath, err := types.ApplyPrefix(prefix, path) require.NoError(t, err, "valid prefix returns error") - - require.Equal(t, "/storePrefixKey/"+pathStr, prefixedPath.Pretty(), "Prefixed path incorrect") - require.Equal(t, "/storePrefixKey/pathone%2Fpathtwo%2Fpaththree%2Fkey", prefixedPath.String(), "Prefixed escaped path incorrect") -} - -func TestString(t *testing.T) { - path := types.NewMerklePath("rootKey", "storeKey", "path/to/leaf") - - require.Equal(t, "/rootKey/storeKey/path%2Fto%2Fleaf", path.String(), "path String returns unxpected value") - require.Equal(t, "/rootKey/storeKey/path/to/leaf", path.Pretty(), "path's pretty string representation is incorrect") - - onePath := types.NewMerklePath("path/to/leaf") - - require.Equal(t, "/path%2Fto%2Fleaf", onePath.String(), "one element path does not have correct string representation") - require.Equal(t, "/path/to/leaf", onePath.Pretty(), "one element path has incorrect pretty string representation") - - zeroPath := types.NewMerklePath() - - require.Equal(t, "", zeroPath.String(), "zero element path does not have correct string representation") - require.Equal(t, "", zeroPath.Pretty(), "zero element path does not have correct pretty string representation") + require.Len(t, prefixedPath.GetKeyPath(), 2, "unexpected key path length") } diff --git a/modules/core/exported/commitment.go b/modules/core/exported/commitment.go index 9a8b47f0151..7886b4d323a 100644 --- a/modules/core/exported/commitment.go +++ b/modules/core/exported/commitment.go @@ -28,7 +28,6 @@ type Prefix interface { // Path implements spec:CommitmentPath. // A path is the additional information provided to the verification function. type Path interface { - String() string // deprecated Empty() bool } diff --git a/modules/light-clients/06-solomachine/client_state_test.go b/modules/light-clients/06-solomachine/client_state_test.go index 396075614c4..34f3b66323d 100644 --- a/modules/light-clients/06-solomachine/client_state_test.go +++ b/modules/light-clients/06-solomachine/client_state_test.go @@ -179,7 +179,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() { clientStateBz, err := suite.chainA.Codec.Marshal(clientState) suite.Require().NoError(err) - path = suite.solomachine.GetClientStatePath(counterpartyClientIdentifier) + path = sm.GetClientStatePath(counterpartyClientIdentifier) merklePath, ok := path.(commitmenttypes.MerklePath) suite.Require().True(ok) key, err := merklePath.GetKey(1) // in a multistore context: index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store @@ -474,7 +474,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() { { "malformed proof fails to unmarshal", func() { - path = suite.solomachine.GetClientStatePath(counterpartyClientIdentifier) + path = sm.GetClientStatePath(counterpartyClientIdentifier) proof = []byte("invalid proof") }, false, @@ -609,14 +609,12 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() { func (suite *SoloMachineTestSuite) TestSignBytesMarshalling() { sm := suite.solomachine - merklePath := commitmenttypes.NewMerklePath("ibc", "solomachine") - key, err := merklePath.GetKey(1) // in a multistore context: index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - suite.Require().NoError(err) + path := []byte("solomachine") signBytesNilData := solomachine.SignBytes{ Sequence: sm.GetHeight().GetRevisionHeight(), Timestamp: sm.Time, Diversifier: sm.Diversifier, - Path: key, + Path: path, Data: nil, } @@ -624,7 +622,7 @@ func (suite *SoloMachineTestSuite) TestSignBytesMarshalling() { Sequence: sm.GetHeight().GetRevisionHeight(), Timestamp: sm.Time, Diversifier: sm.Diversifier, - Path: key, + Path: path, Data: []byte{}, } @@ -662,7 +660,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() { { "success: packet receipt absence verification", func() { - path = suite.solomachine.GetPacketReceiptPath(ibctesting.MockPort, ibctesting.FirstChannelID, 1) + path = sm.GetPacketReceiptPath(ibctesting.MockPort, ibctesting.FirstChannelID, 1) merklePath, ok := path.(commitmenttypes.MerklePath) suite.Require().True(ok) key, err := merklePath.GetKey(1) // in a multistore context: index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store @@ -700,7 +698,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() { { "malformed proof fails to unmarshal", func() { - path = suite.solomachine.GetClientStatePath(counterpartyClientIdentifier) + path = sm.GetClientStatePath(counterpartyClientIdentifier) proof = []byte("invalid proof") }, false, diff --git a/proto/ibc/core/commitment/v1/commitment.proto b/proto/ibc/core/commitment/v1/commitment.proto index bbad400bf73..b4753be2d92 100644 --- a/proto/ibc/core/commitment/v1/commitment.proto +++ b/proto/ibc/core/commitment/v1/commitment.proto @@ -26,8 +26,6 @@ message MerklePrefix { // arbitrary structured object (defined by a commitment type). // MerklePath is represented from root-to-leaf message MerklePath { - option (gogoproto.goproto_stringer) = false; - repeated string key_path = 1; } diff --git a/testing/solomachine.go b/testing/solomachine.go index e55ac8ff158..2293f285bec 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -202,7 +202,7 @@ func (solo *Solomachine) CreateHeader(newDiversifier string) *solomachine.Header // CreateMisbehaviour constructs testing misbehaviour for the solo machine client // by signing over two different data bytes at the same sequence. func (solo *Solomachine) CreateMisbehaviour() *solomachine.Misbehaviour { - merklePath := solo.GetClientStatePath("counterparty") + merklePath := commitmenttypes.NewMerklePath(host.FullClientStatePath("counterparty")) path, err := solo.cdc.Marshal(&merklePath) require.NoError(solo.t, err) @@ -231,7 +231,7 @@ func (solo *Solomachine) CreateMisbehaviour() *solomachine.Misbehaviour { // misbehaviour signaturess can have different timestamps solo.Time++ - merklePath = solo.GetConsensusStatePath("counterparty", clienttypes.NewHeight(0, 1)) + merklePath = commitmenttypes.NewMerklePath(host.FullConsensusStatePath("counterparty", clienttypes.NewHeight(0, 1))) path, err = solo.cdc.Marshal(&merklePath) require.NoError(solo.t, err) @@ -516,14 +516,12 @@ func (solo *Solomachine) GenerateClientStateProof(clientState exported.ClientSta data, err := clienttypes.MarshalClientState(solo.cdc, clientState) require.NoError(solo.t, err) - merklePath := solo.GetClientStatePath(clientIDSolomachine) - key, err := merklePath.GetKey(1) // index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - require.NoError(solo.t, err) + path := host.FullClientStateKey(clientIDSolomachine) signBytes := &solomachine.SignBytes{ Sequence: solo.Sequence, Timestamp: solo.Time, Diversifier: solo.Diversifier, - Path: key, + Path: path, Data: data, } @@ -536,14 +534,12 @@ func (solo *Solomachine) GenerateConsensusStateProof(consensusState exported.Con data, err := clienttypes.MarshalConsensusState(solo.cdc, consensusState) require.NoError(solo.t, err) - merklePath := solo.GetConsensusStatePath(clientIDSolomachine, consensusHeight) - key, err := merklePath.GetKey(1) // index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - require.NoError(solo.t, err) + path := host.FullConsensusStateKey(clientIDSolomachine, consensusHeight) signBytes := &solomachine.SignBytes{ Sequence: solo.Sequence, Timestamp: solo.Time, Diversifier: solo.Diversifier, - Path: key, + Path: path, Data: data, } @@ -559,14 +555,12 @@ func (solo *Solomachine) GenerateConnOpenTryProof(counterpartyClientID, counterp data, err := solo.cdc.Marshal(&connection) require.NoError(solo.t, err) - merklePath := solo.GetConnectionStatePath(connectionIDSolomachine) - key, err := merklePath.GetKey(1) // index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - require.NoError(solo.t, err) + path := host.ConnectionKey(connectionIDSolomachine) signBytes := &solomachine.SignBytes{ Sequence: solo.Sequence, Timestamp: solo.Time, Diversifier: solo.Diversifier, - Path: key, + Path: path, Data: data, } @@ -582,14 +576,12 @@ func (solo *Solomachine) GenerateChanOpenTryProof(portID, version, counterpartyC data, err := solo.cdc.Marshal(&channel) require.NoError(solo.t, err) - merklePath := solo.GetChannelStatePath(portID, channelIDSolomachine) - key, err := merklePath.GetKey(1) // index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - require.NoError(solo.t, err) + path := host.ChannelKey(portID, channelIDSolomachine) signBytes := &solomachine.SignBytes{ Sequence: solo.Sequence, Timestamp: solo.Time, Diversifier: solo.Diversifier, - Path: key, + Path: path, Data: data, } @@ -605,14 +597,12 @@ func (solo *Solomachine) GenerateChanClosedProof(portID, version, counterpartyCh data, err := solo.cdc.Marshal(&channel) require.NoError(solo.t, err) - merklePath := solo.GetChannelStatePath(portID, channelIDSolomachine) - key, err := merklePath.GetKey(1) // index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - require.NoError(solo.t, err) + path := host.ChannelKey(portID, channelIDSolomachine) signBytes := &solomachine.SignBytes{ Sequence: solo.Sequence, Timestamp: solo.Time, Diversifier: solo.Diversifier, - Path: key, + Path: path, Data: data, } @@ -623,14 +613,12 @@ func (solo *Solomachine) GenerateChanClosedProof(portID, version, counterpartyCh func (solo *Solomachine) GenerateCommitmentProof(packet channeltypes.Packet) []byte { commitment := channeltypes.CommitPacket(solo.cdc, packet) - merklePath := solo.GetPacketCommitmentPath(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - key, err := merklePath.GetKey(1) // index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - require.NoError(solo.t, err) + path := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) signBytes := &solomachine.SignBytes{ Sequence: solo.Sequence, Timestamp: solo.Time, Diversifier: solo.Diversifier, - Path: key, + Path: path, Data: commitment, } @@ -641,14 +629,12 @@ func (solo *Solomachine) GenerateCommitmentProof(packet channeltypes.Packet) []b func (solo *Solomachine) GenerateAcknowledgementProof(packet channeltypes.Packet) []byte { transferAck := channeltypes.NewResultAcknowledgement([]byte{byte(1)}).Acknowledgement() - merklePath := solo.GetPacketAcknowledgementPath(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - key, err := merklePath.GetKey(1) // index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - require.NoError(solo.t, err) + path := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) signBytes := &solomachine.SignBytes{ Sequence: solo.Sequence, Timestamp: solo.Time, Diversifier: solo.Diversifier, - Path: key, + Path: path, Data: channeltypes.CommitAcknowledgement(transferAck), } @@ -657,14 +643,12 @@ func (solo *Solomachine) GenerateAcknowledgementProof(packet channeltypes.Packet // GenerateReceiptAbsenceProof generates a receipt absence proof for the provided packet. func (solo *Solomachine) GenerateReceiptAbsenceProof(packet channeltypes.Packet) []byte { - merklePath := solo.GetPacketReceiptPath(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - key, err := merklePath.GetKey(1) // index 0 is the key for the IBC store in the multistore, index 1 is the key in the IBC store - require.NoError(solo.t, err) + path := host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) signBytes := &solomachine.SignBytes{ Sequence: solo.Sequence, Timestamp: solo.Time, Diversifier: solo.Diversifier, - Path: key, + Path: path, Data: nil, } return solo.GenerateProof(signBytes)