Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix solo machine as per ics spec changes #153

Merged
merged 4 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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