Skip to content

Commit

Permalink
chore: remove AllowUpdateAfterProposal (#1940)
Browse files Browse the repository at this point in the history
  • Loading branch information
charleenfei authored Aug 9, 2022
1 parent f891c29 commit cb46e7d
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 74 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (07-tendermint) [\#1097](https://github.com/cosmos/ibc-go/pull/1097) Remove `GetClientID` function from 07-tendermint `Misbehaviour` type.
* (07-tendermint) [\#1097](https://github.com/cosmos/ibc-go/pull/1097) Deprecate `ClientId` field in 07-tendermint `Misbehaviour` type.
* (modules/core/exported) [\#1107](https://github.com/cosmos/ibc-go/pull/1107) Merging the `Header` and `Misbehaviour` interfaces into a single `ClientMessage` type.
* (06-solomachine)[\#1906](https://github.com/cosmos/ibc-go/pull/1906/files) Removed `AllowUpdateAfterProposal` boolean as it has been deprecated (see 01_concepts of the solo machine spec for more details).
* (07-tendermint) [\#1896](https://github.com/cosmos/ibc-go/pull/1896) Remove error return from `IterateConsensusStateAscending` in `07-tendermint`.

### State Machine Breaking
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (suite *KeeperTestSuite) TestCreateClient() {
expPass bool
}{
{"success", ibctm.NewClientState(testChainID, ibctm.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, testClientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath), true},
{"client type not supported", solomachinetypes.NewClientState(0, &solomachinetypes.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time}, false), false},
{"client type not supported", solomachinetypes.NewClientState(0, &solomachinetypes.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time}), false},
}

for i, tc := range cases {
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() {
},
{
"invalid client type",
solomachinetypes.NewClientState(0, &solomachinetypes.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time}, false),
solomachinetypes.NewClientState(0, &solomachinetypes.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time}),
false,
},
{
Expand Down
1 change: 0 additions & 1 deletion modules/core/02-client/legacy/v100/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func (suite *LegacyTestSuite) TestMigrateGenesisSolomachine() {
Diversifier: clientState.ConsensusState.Diversifier,
Timestamp: clientState.ConsensusState.Timestamp,
},
AllowUpdateAfterProposal: clientState.AllowUpdateAfterProposal,
}

// set client state
Expand Down
7 changes: 3 additions & 4 deletions modules/core/02-client/legacy/v100/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ func migrateSolomachine(clientState *ClientState) *smtypes.ClientState {
}

return &smtypes.ClientState{
Sequence: clientState.Sequence,
IsFrozen: isFrozen,
ConsensusState: consensusState,
AllowUpdateAfterProposal: clientState.AllowUpdateAfterProposal,
Sequence: clientState.Sequence,
IsFrozen: isFrozen,
ConsensusState: consensusState,
}
}

Expand Down
1 change: 0 additions & 1 deletion modules/core/02-client/legacy/v100/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (suite *LegacyTestSuite) TestMigrateStoreSolomachine() {
Diversifier: clientState.ConsensusState.Diversifier,
Timestamp: clientState.ConsensusState.Timestamp,
},
AllowUpdateAfterProposal: clientState.AllowUpdateAfterProposal,
}

// set client state
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() {
types.NewIdentifiedClientState(
soloMachineClientID, ibctm.NewClientState(suite.chainA.ChainID, ibctm.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath),
),
types.NewIdentifiedClientState(tmClientID0, solomachinetypes.NewClientState(0, &solomachinetypes.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time}, false)),
types.NewIdentifiedClientState(tmClientID0, solomachinetypes.NewClientState(0, &solomachinetypes.ConsensusState{suite.solomachine.ConsensusState().PublicKey, suite.solomachine.Diversifier, suite.solomachine.Time})),
},
nil,
nil,
Expand Down
1 change: 0 additions & 1 deletion modules/core/02-client/types/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func (suite *TypesTestSuite) TestUpgradeProposalValidateBasic() {
"fails validate abstract - empty title", func() {
proposal, err = types.NewUpgradeProposal("", ibctesting.Description, plan, cs.ZeroCustomFields())
suite.Require().NoError(err)

}, false,
},
{
Expand Down
1 change: 0 additions & 1 deletion modules/core/legacy/v100/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func (suite *LegacyTestSuite) TestMigrateGenesisSolomachine() {
Diversifier: clientState.ConsensusState.Diversifier,
Timestamp: clientState.ConsensusState.Timestamp,
},
AllowUpdateAfterProposal: clientState.AllowUpdateAfterProposal,
}

// set client state
Expand Down
15 changes: 7 additions & 8 deletions modules/light-clients/06-solomachine/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
var _ exported.ClientState = (*ClientState)(nil)

// NewClientState creates a new ClientState instance.
func NewClientState(latestSequence uint64, consensusState *ConsensusState, allowUpdateAfterProposal bool) *ClientState {
func NewClientState(latestSequence uint64, consensusState *ConsensusState) *ClientState {
return &ClientState{
Sequence: latestSequence,
IsFrozen: false,
ConsensusState: consensusState,
AllowUpdateAfterProposal: allowUpdateAfterProposal,
Sequence: latestSequence,
IsFrozen: false,
ConsensusState: consensusState,
// AllowUpdateAfterProposal has been DEPRECATED. See 01_concepts in the solo machine spec repo for more details.
}
}

Expand Down Expand Up @@ -75,11 +75,10 @@ func (cs ClientState) Validate() error {
return cs.ConsensusState.ValidateBasic()
}

// ZeroCustomFields returns solomachine client state with client-specific fields FrozenSequence,
// and AllowUpdateAfterProposal zeroed out
// ZeroCustomFields returns solomachine client state with client-specific field FrozenSequence zeroed out
func (cs ClientState) ZeroCustomFields() exported.ClientState {
return NewClientState(
cs.Sequence, cs.ConsensusState, false,
cs.Sequence, cs.ConsensusState,
)
}

Expand Down
18 changes: 8 additions & 10 deletions modules/light-clients/06-solomachine/client_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() {
},
{
"sequence is zero",
solomachine.NewClientState(0, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, sm.Diversifier, sm.Time}, false),
solomachine.NewClientState(0, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, sm.Diversifier, sm.Time}),
false,
},
{
"timestamp is zero",
solomachine.NewClientState(1, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, sm.Diversifier, 0}, false),
solomachine.NewClientState(1, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, sm.Diversifier, 0}),
false,
},
{
"diversifier is blank",
solomachine.NewClientState(1, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, " ", 1}, false),
solomachine.NewClientState(1, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, " ", 1}),
false,
},
{
"pubkey is empty",
solomachine.NewClientState(1, &solomachine.ConsensusState{nil, sm.Diversifier, sm.Time}, false),
solomachine.NewClientState(1, &solomachine.ConsensusState{nil, sm.Diversifier, sm.Time}),
false,
},
}
Expand All @@ -76,7 +76,6 @@ func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() {
tc := tc

suite.Run(tc.name, func() {

err := tc.clientState.Validate()

if tc.expPass {
Expand Down Expand Up @@ -193,7 +192,6 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() {

proof, err = suite.chainA.Codec.Marshal(signatureDoc)
suite.Require().NoError(err)

},
true,
},
Expand Down Expand Up @@ -455,7 +453,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() {
PublicKey: sm.ConsensusState().PublicKey,
}

clientState = solomachine.NewClientState(sm.Sequence-1, consensusState, false)
clientState = solomachine.NewClientState(sm.Sequence-1, consensusState)
},
false,
},
Expand Down Expand Up @@ -492,7 +490,7 @@ func (suite *SoloMachineTestSuite) TestVerifyMembership() {
PublicKey: sm.ConsensusState().PublicKey,
}

clientState = solomachine.NewClientState(sm.Sequence, consensusState, false)
clientState = solomachine.NewClientState(sm.Sequence, consensusState)
},
false,
},
Expand Down Expand Up @@ -666,7 +664,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() {
PublicKey: sm.ConsensusState().PublicKey,
}

clientState = solomachine.NewClientState(sm.Sequence-1, consensusState, false)
clientState = solomachine.NewClientState(sm.Sequence-1, consensusState)
},
false,
},
Expand Down Expand Up @@ -703,7 +701,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNonMembership() {
PublicKey: sm.ConsensusState().PublicKey,
}

clientState = solomachine.NewClientState(sm.Sequence, consensusState, false)
clientState = solomachine.NewClientState(sm.Sequence, consensusState)
},
false,
},
Expand Down
1 change: 0 additions & 1 deletion modules/light-clients/06-solomachine/misbehaviour_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() {
tc := tc

suite.Run(tc.name, func() {

misbehaviour := sm.CreateMisbehaviour()
tc.malleateMisbehaviour(misbehaviour)

Expand Down
4 changes: 0 additions & 4 deletions modules/light-clients/06-solomachine/proposal_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ func (cs ClientState) CheckSubstituteAndUpdateState(
ctx sdk.Context, cdc codec.BinaryCodec, subjectClientStore,
_ sdk.KVStore, substituteClient exported.ClientState,
) error {
if !cs.AllowUpdateAfterProposal {
return sdkerrors.Wrapf(clienttypes.ErrUpdateClientFailed, "solo machine client is not allowed to updated with a proposal")
}

substituteClientState, ok := substituteClient.(*ClientState)
if !ok {
return sdkerrors.Wrapf(clienttypes.ErrInvalidClientType, "substitute client state type %T, expected %T", substituteClient, &ClientState{})
Expand Down
6 changes: 0 additions & 6 deletions modules/light-clients/06-solomachine/proposal_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ func (suite *SoloMachineTestSuite) TestCheckSubstituteAndUpdateState() {
subjectClientState.AllowUpdateAfterProposal = true
}, true,
},
{
"subject not allowed to be updated", func() {
subjectClientState.AllowUpdateAfterProposal = false
}, false,
},
{
"substitute is not the solo machine", func() {
substituteClientState = &ibctm.ClientState{}
Expand Down Expand Up @@ -63,7 +58,6 @@ func (suite *SoloMachineTestSuite) TestCheckSubstituteAndUpdateState() {
suite.SetupTest()

subjectClientState = sm.ClientState()
subjectClientState.AllowUpdateAfterProposal = true
substitute := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "substitute", "testing", 5)
substituteClientState = substitute.ClientState()

Expand Down
3 changes: 2 additions & 1 deletion modules/light-clients/06-solomachine/spec/01_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ If the update is successful:
An update by a governance proposal will only succeed if:

- the substitute provided is parseable to solo machine client state
- the `AllowUpdateAfterProposal` client parameter is set to `true`
- the new consensus state public key does not equal the current consensus state public key

If the update is successful:
Expand All @@ -142,6 +141,8 @@ If the update is successful:
- the subject consensus state is updated to the substitute consensus state
- the client is unfrozen (if it was previously frozen)

NOTE: Previously, `AllowUpdateAfterProposal` was used to signal the update/recovery options for the solo machine client. However, this has now been deprecated because a code migration can overwrite the client and consensus states regardless of the value of this parameter. If governance would vote to overwrite a client or consensus state, it is likely that governance would also be willing to perform a code migration to do the same.

## Misbehaviour

Misbehaviour handling will only succeed if:
Expand Down
9 changes: 1 addition & 8 deletions modules/light-clients/06-solomachine/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() {
{
"signature uses wrong sequence",
func() {

sm.Sequence++
clientMsg = sm.CreateHeader(sm.Diversifier)
},
Expand Down Expand Up @@ -125,7 +124,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() {

clientState = cs
clientMsg = h

},
false,
},
Expand Down Expand Up @@ -341,7 +339,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() {
{
"signatures sign over different sequence",
func() {

// store in temp before assigning to interface type
m := sm.CreateMisbehaviour()

Expand Down Expand Up @@ -470,16 +467,13 @@ func (suite *SoloMachineTestSuite) TestUpdateState() {
clientState.UpdateState(suite.chainA.GetContext(), suite.chainA.Codec, suite.store, clientMsg)
})
}

})
}
}
}

func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() {
var (
clientMsg exported.ClientMessage
)
var clientMsg exported.ClientMessage

// test singlesig and multisig public keys
for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} {
Expand Down Expand Up @@ -519,7 +513,6 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() {
} else {
suite.Require().False(foundMisbehaviour)
}

})
}
}
Expand Down
5 changes: 1 addition & 4 deletions modules/light-clients/07-tendermint/client_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const (
fiftyOneCharChainID = "123456789012345678901234567890123456789012345678901"
)

var (
invalidProof = []byte("invalid proof")
)
var invalidProof = []byte("invalid proof")

func (suite *TendermintTestSuite) TestStatus() {
var (
Expand Down Expand Up @@ -162,7 +160,6 @@ func (suite *TendermintTestSuite) TestValidate() {
}

func (suite *TendermintTestSuite) TestInitialize() {

testCases := []struct {
name string
consensusState exported.ConsensusState
Expand Down
30 changes: 20 additions & 10 deletions modules/light-clients/07-tendermint/consensus_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,44 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() {
consensusState *ibctm.ConsensusState
expectPass bool
}{
{"success",
{
"success",
&ibctm.ConsensusState{
Timestamp: suite.now,
Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")),
NextValidatorsHash: suite.valsHash,
},
true},
{"success with sentinel",
true,
},
{
"success with sentinel",
&ibctm.ConsensusState{
Timestamp: suite.now,
Root: commitmenttypes.NewMerkleRoot([]byte(ibctm.SentinelRoot)),
NextValidatorsHash: suite.valsHash,
},
true},
{"root is nil",
true,
},
{
"root is nil",
&ibctm.ConsensusState{
Timestamp: suite.now,
Root: commitmenttypes.MerkleRoot{},
NextValidatorsHash: suite.valsHash,
},
false},
{"root is empty",
false,
},
{
"root is empty",
&ibctm.ConsensusState{
Timestamp: suite.now,
Root: commitmenttypes.MerkleRoot{},
NextValidatorsHash: suite.valsHash,
},
false},
{"nextvalshash is invalid",
false,
},
{
"nextvalshash is invalid",
&ibctm.ConsensusState{
Timestamp: suite.now,
Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")),
Expand All @@ -51,7 +60,8 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() {
false,
},

{"timestamp is zero",
{
"timestamp is zero",
&ibctm.ConsensusState{
Timestamp: time.Time{},
Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")),
Expand Down
Loading

0 comments on commit cb46e7d

Please sign in to comment.