From 59c43cd0479037ffa5225c9bd776dda617d7ec48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 23 Sep 2020 16:06:20 +0200 Subject: [PATCH] fix proposal update handling (#7372) Fix proposal update handling to update the consensus state with the new diversifier and timestamp. Add checks in the proposal update test to ensure the values provided in the header match. Did manual testing to ensure the test additions fails before updating the code to the correct behaviour. Co-authored-by: Christopher Goes --- .../solomachine/types/proposal_handle.go | 4 +++- .../solomachine/types/proposal_handle_test.go | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/x/ibc/light-clients/solomachine/types/proposal_handle.go b/x/ibc/light-clients/solomachine/types/proposal_handle.go index 1d58f55639..ecd078954e 100644 --- a/x/ibc/light-clients/solomachine/types/proposal_handle.go +++ b/x/ibc/light-clients/solomachine/types/proposal_handle.go @@ -42,7 +42,9 @@ func (cs ClientState) CheckProposedHeaderAndUpdateState( clientState := &cs consensusState := &ConsensusState{ - PublicKey: smHeader.NewPublicKey, + PublicKey: smHeader.NewPublicKey, + Diversifier: smHeader.NewDiversifier, + Timestamp: smHeader.Timestamp, } clientState.Sequence = smHeader.Sequence diff --git a/x/ibc/light-clients/solomachine/types/proposal_handle_test.go b/x/ibc/light-clients/solomachine/types/proposal_handle_test.go index b5c58ef3d1..b7d02be058 100644 --- a/x/ibc/light-clients/solomachine/types/proposal_handle_test.go +++ b/x/ibc/light-clients/solomachine/types/proposal_handle_test.go @@ -58,9 +58,17 @@ func (suite *SoloMachineTestSuite) TestCheckProposedHeaderAndUpdateState() { if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(header.(*types.Header).GetPubKey(), consState.(*types.ConsensusState).GetPubKey()) + + smConsState, ok := consState.(*types.ConsensusState) + suite.Require().True(ok) + smHeader, ok := header.(*types.Header) + suite.Require().True(ok) + suite.Require().Equal(cs.(*types.ClientState).ConsensusState, consState) - suite.Require().Equal(header.GetHeight().GetEpochHeight(), cs.(*types.ClientState).Sequence) + suite.Require().Equal(smHeader.GetPubKey(), smConsState.GetPubKey()) + suite.Require().Equal(smHeader.NewDiversifier, smConsState.Diversifier) + suite.Require().Equal(smHeader.Timestamp, smConsState.Timestamp) + suite.Require().Equal(smHeader.GetHeight().GetEpochHeight(), cs.(*types.ClientState).Sequence) } else { suite.Require().Error(err) suite.Require().Nil(cs)