Skip to content

Commit

Permalink
fix solo machine merkle prefix casting bug (#122)
Browse files Browse the repository at this point in the history
* fix merkle prefix casting bug, credit: @devashishdxt

* update changelog

* update docs
  • Loading branch information
colin-axner authored Apr 14, 2021
1 parent 7e673b9 commit 5d3a800
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions modules/light-clients/06-solomachine/spec/01_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion modules/light-clients/06-solomachine/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const (
)

var (
prefix = commitmenttypes.NewMerklePrefix([]byte("ibc"))
prefix = &commitmenttypes.MerklePrefix{
KeyPrefix: []byte("ibc"),
}
consensusHeight = clienttypes.ZeroHeight()
)

Expand Down Expand Up @@ -387,7 +389,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)
Expand Down
4 changes: 2 additions & 2 deletions modules/light-clients/06-solomachine/types/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 5d3a800

Please sign in to comment.