Skip to content

Commit

Permalink
fix solo machine as per ics spec changes (#153)
Browse files Browse the repository at this point in the history
* fix solo machine as per ics spec changes

* add changelog
  • Loading branch information
colin-axner authored May 10, 2021
1 parent 67bcf56 commit 5991e86
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (modules/light-clients/06-solomachine) [\153](https://github.com/cosmos/ibc-go/pull/153) Fix solo machine proof height sequence mismatch bug.
* (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.

Expand Down
6 changes: 6 additions & 0 deletions modules/light-clients/06-solomachine/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ func (cs *ClientState) VerifyClientState(
proof []byte,
clientState exported.ClientState,
) error {
// NOTE: the proof height sequence is incremented by one due to the connection handshake verification ordering
height = clienttypes.NewHeight(height.GetRevisionNumber(), height.GetRevisionHeight()+1)

publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof)
if err != nil {
return err
Expand Down Expand Up @@ -159,6 +162,9 @@ func (cs *ClientState) VerifyClientConsensusState(
proof []byte,
consensusState exported.ConsensusState,
) error {
// NOTE: the proof height sequence is incremented by two due to the connection handshake verification ordering
height = clienttypes.NewHeight(height.GetRevisionNumber(), height.GetRevisionHeight()+2)

publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof)
if err != nil {
return err
Expand Down
10 changes: 8 additions & 2 deletions modules/light-clients/06-solomachine/types/client_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() {
expSeq = tc.clientState.Sequence + 1
}

// NOTE: to replicate the ordering of connection handshake, we must decrement proof height by 1
height := clienttypes.NewHeight(solomachine.GetHeight().GetRevisionNumber(), solomachine.GetHeight().GetRevisionHeight()-1)

err := tc.clientState.VerifyClientState(
suite.store, suite.chainA.Codec, solomachine.GetHeight(), tc.prefix, counterpartyClientIdentifier, tc.proof, clientState,
suite.store, suite.chainA.Codec, height, tc.prefix, counterpartyClientIdentifier, tc.proof, clientState,
)

if tc.expPass {
Expand Down Expand Up @@ -386,8 +389,11 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() {
expSeq = tc.clientState.Sequence + 1
}

// NOTE: to replicate the ordering of connection handshake, we must decrement proof height by 1
height := clienttypes.NewHeight(solomachine.GetHeight().GetRevisionNumber(), solomachine.GetHeight().GetRevisionHeight()-2)

err := tc.clientState.VerifyClientConsensusState(
suite.store, suite.chainA.Codec, solomachine.GetHeight(), counterpartyClientIdentifier, consensusHeight, tc.prefix, tc.proof, consensusState,
suite.store, suite.chainA.Codec, height, counterpartyClientIdentifier, consensusHeight, tc.prefix, tc.proof, consensusState,
)

if tc.expPass {
Expand Down

0 comments on commit 5991e86

Please sign in to comment.