diff --git a/CHANGELOG.md b/CHANGELOG.md index c670b35a8c9..370a4731e70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (light-clients/solomachine) [#1839](https://github.com/cosmos/ibc-go/issues/1839) Fixed usage of the new diversifier in validation of changing diversifiers for the solo machine. The current diversifier must sign over the new diversifier. * (modules/core/04-channel) [\#1130](https://github.com/cosmos/ibc-go/pull/1130) Call `packet.GetSequence()` rather than passing func in `WriteAcknowledgement` log output * (apps/29-fee) [\#1278](https://github.com/cosmos/ibc-go/pull/1278) The URI path for the query to get all incentivized packets for a specifc channel did not follow the same format as the rest of queries. * (07-tendermint) [\#1674](https://github.com/cosmos/ibc-go/pull/1674) Submitted ClientState is zeroed out before checking the proof in order to prevent the proposal from containing information governance is not actually voting on. diff --git a/modules/core/02-client/types/codec_test.go b/modules/core/02-client/types/codec_test.go index 2db68dbb244..5dd9b99620c 100644 --- a/modules/core/02-client/types/codec_test.go +++ b/modules/core/02-client/types/codec_test.go @@ -118,7 +118,7 @@ func (suite *TypesTestSuite) TestPackClientMessage() { }{ { "solo machine header", - ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2).CreateHeader(), + ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2).CreateHeader("solomachine"), true, }, { diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index c51ebfce957..03148e73686 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -204,7 +204,7 @@ func (suite *TypesTestSuite) TestMarshalMsgUpdateClient() { { "solo machine client", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chainA.SenderAccount.GetAddress().String()) + msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(soloMachine.Diversifier), suite.chainA.SenderAccount.GetAddress().String()) suite.Require().NoError(err) }, }, @@ -293,7 +293,8 @@ func (suite *TypesTestSuite) TestMsgUpdateClient_ValidateBasic() { "valid - solomachine header", func() { soloMachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "solomachine", "", 2) - msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(), suite.chainA.SenderAccount.GetAddress().String()) + msg, err = types.NewMsgUpdateClient(soloMachine.ClientID, soloMachine.CreateHeader(soloMachine.Diversifier), suite.chainA.SenderAccount.GetAddress().String()) + suite.Require().NoError(err) }, true, diff --git a/modules/light-clients/06-solomachine/header_test.go b/modules/light-clients/06-solomachine/header_test.go index 5b02b41c555..a2b96ea7d62 100644 --- a/modules/light-clients/06-solomachine/header_test.go +++ b/modules/light-clients/06-solomachine/header_test.go @@ -10,7 +10,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { // test singlesig and multisig public keys for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - header := sm.CreateHeader() + header := sm.CreateHeader(sm.Diversifier) cases := []struct { name string diff --git a/modules/light-clients/06-solomachine/update_test.go b/modules/light-clients/06-solomachine/update_test.go index 8832b8c8ace..e205886bc25 100644 --- a/modules/light-clients/06-solomachine/update_test.go +++ b/modules/light-clients/06-solomachine/update_test.go @@ -29,7 +29,14 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { { "successful header", func() { - clientMsg = sm.CreateHeader() + clientMsg = sm.CreateHeader(sm.Diversifier) + }, + true, + }, + { + "successful header with new diversifier", + func() { + clientMsg = sm.CreateHeader(sm.Diversifier + "0") }, true, }, @@ -51,7 +58,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { "wrong sequence in header", func() { // store in temp before assigning to interface type - h := sm.CreateHeader() + h := sm.CreateHeader(sm.Diversifier) h.Sequence++ clientMsg = h }, @@ -60,7 +67,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { { "invalid header Signature", func() { - h := sm.CreateHeader() + h := sm.CreateHeader(sm.Diversifier) h.Signature = suite.GetInvalidProof() clientMsg = h }, false, @@ -68,7 +75,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { { "invalid timestamp in header", func() { - h := sm.CreateHeader() + h := sm.CreateHeader(sm.Diversifier) h.Timestamp-- clientMsg = h }, false, @@ -78,7 +85,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { func() { sm.Sequence++ - clientMsg = sm.CreateHeader() + clientMsg = sm.CreateHeader(sm.Diversifier) }, false, }, @@ -87,7 +94,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { func() { // store in temp before assinging to interface type cs := sm.ClientState() - h := sm.CreateHeader() + h := sm.CreateHeader(sm.Diversifier) publicKey, err := codectypes.NewAnyWithValue(sm.PublicKey) suite.NoError(err) @@ -128,7 +135,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { // store in temp before assinging to interface type cs := sm.ClientState() oldPubKey := sm.PublicKey - h := sm.CreateHeader() + h := sm.CreateHeader(sm.Diversifier) // generate invalid signature data := append(sdk.Uint64ToBigEndian(cs.Sequence), oldPubKey.Bytes()...) @@ -144,7 +151,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { "consensus state public key is nil - header", func() { clientState.ConsensusState.PublicKey = nil - clientMsg = sm.CreateHeader() + clientMsg = sm.CreateHeader(sm.Diversifier) }, false, }, @@ -309,7 +316,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { badMisbehaviour := sm.CreateMisbehaviour() // update public key to a new one - sm.CreateHeader() + sm.CreateHeader(sm.Diversifier) m := sm.CreateMisbehaviour() // set SignatureOne to use the wrong signature @@ -323,7 +330,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { badMisbehaviour := sm.CreateMisbehaviour() // update public key to a new one - sm.CreateHeader() + sm.CreateHeader(sm.Diversifier) m := sm.CreateMisbehaviour() // set SignatureTwo to use the wrong signature @@ -421,7 +428,7 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { "successful update", func() { clientState = sm.ClientState() - clientMsg = sm.CreateHeader() + clientMsg = sm.CreateHeader(sm.Diversifier) }, true, }, @@ -491,7 +498,7 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() { { "normal header returns false", func() { - clientMsg = sm.CreateHeader() + clientMsg = sm.CreateHeader(sm.Diversifier) }, false, }, diff --git a/testing/solomachine.go b/testing/solomachine.go index bb0d43c97b7..f0cd445d1db 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -107,7 +107,8 @@ func (solo *Solomachine) GetHeight() exported.Height { // CreateHeader generates a new private/public key pair and creates the // necessary signature to construct a valid solo machine header. -func (solo *Solomachine) CreateHeader() *solomachinetypes.Header { +// A new diversifier will be used as well +func (solo *Solomachine) CreateHeader(newDiversifier string) *solomachinetypes.Header { // generate new private keys and signature for header newPrivKeys, newPubKeys, newPubKey := GenerateKeys(solo.t, uint64(len(solo.PrivateKeys))) @@ -116,7 +117,7 @@ func (solo *Solomachine) CreateHeader() *solomachinetypes.Header { data := &solomachinetypes.HeaderData{ NewPubKey: publicKey, - NewDiversifier: solo.Diversifier, + NewDiversifier: newDiversifier, } dataBz, err := solo.cdc.Marshal(data) @@ -140,7 +141,7 @@ func (solo *Solomachine) CreateHeader() *solomachinetypes.Header { Timestamp: solo.Time, Signature: sig, NewPublicKey: publicKey, - NewDiversifier: solo.Diversifier, + NewDiversifier: newDiversifier, } // assumes successful header update @@ -148,6 +149,7 @@ func (solo *Solomachine) CreateHeader() *solomachinetypes.Header { solo.PrivateKeys = newPrivKeys solo.PublicKeys = newPubKeys solo.PublicKey = newPubKey + solo.Diversifier = newDiversifier return header }