Skip to content

Commit f245118

Browse files
authored
Merge branch 'main' into colin/148-remove-misbehaviour-getheight
2 parents 112c376 + 5991e86 commit f245118

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
3838

3939
### Bug Fixes
4040

41+
* (modules/light-clients/06-solomachine) [\153](https://github.com/cosmos/ibc-go/pull/153) Fix solo machine proof height sequence mismatch bug.
4142
* (modules/light-clients/06-solomachine) [\#122](https://github.com/cosmos/ibc-go/pull/122) Fix solo machine merkle prefix casting bug.
4243
* (modules/light-clients/06-solomachine) [\#120](https://github.com/cosmos/ibc-go/pull/120) Fix solo machine handshake verification bug.
4344

modules/light-clients/06-solomachine/types/client_state.go

+6
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ func (cs *ClientState) VerifyClientState(
121121
proof []byte,
122122
clientState exported.ClientState,
123123
) error {
124+
// NOTE: the proof height sequence is incremented by one due to the connection handshake verification ordering
125+
height = clienttypes.NewHeight(height.GetRevisionNumber(), height.GetRevisionHeight()+1)
126+
124127
publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof)
125128
if err != nil {
126129
return err
@@ -159,6 +162,9 @@ func (cs *ClientState) VerifyClientConsensusState(
159162
proof []byte,
160163
consensusState exported.ConsensusState,
161164
) error {
165+
// NOTE: the proof height sequence is incremented by two due to the connection handshake verification ordering
166+
height = clienttypes.NewHeight(height.GetRevisionNumber(), height.GetRevisionHeight()+2)
167+
162168
publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, prefix, proof)
163169
if err != nil {
164170
return err

modules/light-clients/06-solomachine/types/client_state_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,11 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() {
256256
expSeq = tc.clientState.Sequence + 1
257257
}
258258

259+
// NOTE: to replicate the ordering of connection handshake, we must decrement proof height by 1
260+
height := clienttypes.NewHeight(solomachine.GetHeight().GetRevisionNumber(), solomachine.GetHeight().GetRevisionHeight()-1)
261+
259262
err := tc.clientState.VerifyClientState(
260-
suite.store, suite.chainA.Codec, solomachine.GetHeight(), tc.prefix, counterpartyClientIdentifier, tc.proof, clientState,
263+
suite.store, suite.chainA.Codec, height, tc.prefix, counterpartyClientIdentifier, tc.proof, clientState,
261264
)
262265

263266
if tc.expPass {
@@ -386,8 +389,11 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() {
386389
expSeq = tc.clientState.Sequence + 1
387390
}
388391

392+
// NOTE: to replicate the ordering of connection handshake, we must decrement proof height by 1
393+
height := clienttypes.NewHeight(solomachine.GetHeight().GetRevisionNumber(), solomachine.GetHeight().GetRevisionHeight()-2)
394+
389395
err := tc.clientState.VerifyClientConsensusState(
390-
suite.store, suite.chainA.Codec, solomachine.GetHeight(), counterpartyClientIdentifier, consensusHeight, tc.prefix, tc.proof, consensusState,
396+
suite.store, suite.chainA.Codec, height, counterpartyClientIdentifier, consensusHeight, tc.prefix, tc.proof, consensusState,
391397
)
392398

393399
if tc.expPass {

0 commit comments

Comments
 (0)