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

02-client refactor #1871

Merged
merged 76 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
a4b5b8f
chore: Remove GetClientID() From Misbehaviour Interface (#897)
notbdu Mar 9, 2022
841d21d
chore: add 668 functions to localhost client (#908)
notbdu Mar 9, 2022
18abb79
chore: rename 06-solomachine type Misbehaviour to DuplicateSignatures…
damiannolan Mar 10, 2022
a333a73
chore: reverting renaming of Misbehaviour (#1099)
damiannolan Mar 11, 2022
daa01db
remove GetClientID from 07-tendermint misbehaviour (#1097)
colin-axner Mar 11, 2022
2de5f1d
chore: remove GetClientID from 06-solomachine type Misbehaviour (#1100)
damiannolan Mar 11, 2022
12f4ed2
client-02 update to latest from main (#1106)
seantking Mar 11, 2022
ebf40bb
02-client: merge misbehavior & header interfaces (#1107)
seantking Mar 15, 2022
b0fa240
chore: 06-solomachine rename checkHeader to VerifyClientMessage (#1109)
damiannolan Mar 16, 2022
5e9785e
refactor: modify VerifyUpgradeAndUpdateState to set upgraded client a…
colin-axner Mar 16, 2022
4c8b7c5
chore: 06-solomachine rename update to UpdateState (#1110)
damiannolan Mar 16, 2022
bdbaa91
chore: 06-solomachine adding CheckForMisbehaviour and UpdateStateOnMi…
damiannolan Mar 16, 2022
f4480fb
chore: 02-client-refactor: merge main into feature branch (#1149)
seantking Mar 21, 2022
5e3bac0
02-client-refactor: rename update to UpdateState for 07-tendermint (#…
colin-axner Mar 24, 2022
efbc5a1
chore: adding UpdateStateOnMisbehaviour to 07-tendermint (#1168)
damiannolan Mar 24, 2022
b0dd49d
chore: add solomachine client storage (#1144)
damiannolan Mar 28, 2022
17209f7
refactor: adding CheckForMisbehaviour to 07-tendermint client (#1163)
damiannolan Mar 28, 2022
fadd9d0
02-client refactor: Adding VerifyClientMessage helper fn (#1119)
seantking Mar 28, 2022
c2602a5
refactor: removing GetRoot from ConsensusState interface (#1186)
seantking Mar 30, 2022
40183b4
Adding VerifyClientMessage to ClientState interface (#1196)
seantking Mar 30, 2022
a4b3d09
chore: CheckSubstituteAndUpdateState stores client state in lightclie…
damiannolan Mar 30, 2022
2e2bfab
chore: 07-tendermint set client/consensus states in UpdateState (#1199)
damiannolan Mar 30, 2022
18f1382
chore: update 07-tendermint GetConsensusState to return bool over err…
damiannolan Mar 30, 2022
3c7358b
feat: adding UpdateStateOnMisbehaviour to ClientState interface (#1198)
seantking Mar 31, 2022
5cf6528
refactor: remove localhost client implementation (#1187)
seantking Mar 31, 2022
eb48e54
chore: adding UpdateState to ClientState interface (#1206)
damiannolan Mar 31, 2022
d2be6d5
feat: adding CheckForMisbehaviour to ClientState interface (#1197)
seantking Mar 31, 2022
e2f37b8
Replace CheckHeaderAndUpdateState with new ClientState functions (#1208)
colin-axner Apr 1, 2022
8a9978c
refactor: removing CheckHeaderAndUpdateState from ClientState (#1210)
seantking Apr 4, 2022
c43af66
refactor: routing MsgSubmitMisbehaviour to UpdateClient keeper fn (#1…
seantking Apr 4, 2022
e249518
refactor: removing CheckMisbehaviourAndUpdateState from ClientState i…
seantking Apr 4, 2022
e91ee68
fix: rm AllowUpdateAfter... check (#1118)
charleenfei Apr 25, 2022
e1ec9f4
chore: update 02-client-refactor branch with latest main (#1286)
damiannolan Apr 26, 2022
cf893c2
chore: remove GetHeight from ClientMessage interface (#1285)
damiannolan Apr 27, 2022
55b115a
update godoc for VerifyClientMessage (#1281)
colin-axner Apr 27, 2022
48882a9
Add VerifyMembership to 07-tendermint (#1297)
colin-axner Apr 28, 2022
8f46821
chore: MsgUpdateClient rename header to client_message (#1316)
damiannolan May 9, 2022
e1f2103
Add migration docs for 02-client refactor (#1287)
catShaark May 10, 2022
31b6ead
Add revision number tests for 07-tendermint (#1302)
colin-axner May 10, 2022
d120044
ADR 005: update client consensus height events (#1315)
damiannolan May 10, 2022
e2bdd1f
feat: VerifyNonMembership 07-tendermint implementation (#1611)
seantking Jun 30, 2022
aab9ca2
chore: making changes based on nits from 02-client refactor audit (#1…
chatton Jun 30, 2022
4def196
chore: add generic proof verification methods to ClientState interfac…
damiannolan Jul 4, 2022
32c4827
chore: add GetTimestampAtHeight to client state #888 (#1659)
charleenfei Jul 6, 2022
1617de7
chore: modify connection keeper GetTimestampAtHeight to use the clien…
charleenfei Jul 7, 2022
3987a5b
refactor: replace usage of verification funcs in 03-connection (#1647)
damiannolan Jul 7, 2022
81a7cae
Check that client state is zeroed out for ibc client upgrade proposal…
chatton Jul 11, 2022
60e5305
Zero out client state before upgrading client proof (#1674)
chatton Jul 11, 2022
549c181
chore: restructuring 07-tendermint lightclient directory layout (#1677)
damiannolan Jul 12, 2022
04df7cd
chore: adding upgrade handler for 09-localhost removal (#1671)
damiannolan Jul 15, 2022
d8ac28a
Emit event upon setting upgrade consensus state (#1741)
chatton Jul 27, 2022
d3d91ed
chore: removing GetHeight legacy method from 06-solomachine (#1810)
damiannolan Jul 29, 2022
b0a58a8
refactor: solomachine generic verification methods and signbytes simp…
damiannolan Aug 2, 2022
7237c43
bump version from 3 to 5
colin-axner Aug 2, 2022
6cdcc63
merge main
colin-axner Aug 2, 2022
0d8f408
fix merge conflicts
colin-axner Aug 2, 2022
a7d23fd
fix build
colin-axner Aug 3, 2022
f861e0e
go imports
colin-axner Aug 3, 2022
607458a
make format
colin-axner Aug 3, 2022
e9a7fac
fix linter
colin-axner Aug 3, 2022
18eee1a
apply review suggestions
colin-axner Aug 3, 2022
197c2bd
Merge branch 'main' into updated-02-client-refactor
colin-axner Aug 3, 2022
2da9e65
fix: import changes for 02-client-refactor (#1875)
colin-axner Aug 4, 2022
68e8e79
apply suggested changes (#1877)
colin-axner Aug 4, 2022
3d33e8b
documentation fixes (#1876)
colin-axner Aug 4, 2022
163b706
fix: complete changes for CheckSubstituteAndUpdateState (#1878)
colin-axner Aug 4, 2022
3cb1ba8
Merge branch 'main' of github.com:cosmos/ibc-go into updated-02-clien…
colin-axner Aug 4, 2022
81f2d09
02-client refactor: fix changelog (#1873)
seantking Aug 4, 2022
311a563
fix: revert unnecessary change in 02-client-refactor branch (#1883)
colin-axner Aug 5, 2022
173c1fb
updating solomachine to use setClientState helper in update funcs (#1…
damiannolan Aug 8, 2022
f8debd7
Merge branch 'main' of github.com:cosmos/ibc-go into updated-02-clien…
colin-axner Aug 8, 2022
a7407cc
Update CHANGELOG.md
colin-axner Aug 8, 2022
fc4bfaf
Update docs/migrations/v5-to-v6.md
colin-axner Aug 8, 2022
9a4ed68
chore: remove error return in IterateConsensusStateAscending (#1896)
damiannolan Aug 8, 2022
87bae33
removing solomachine consensus state nil check and test cases (#1895)
damiannolan Aug 8, 2022
88936be
Merge branch 'main' into updated-02-client-refactor
colin-axner Aug 8, 2022
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
Prev Previous commit
Next Next commit
fix: rm AllowUpdateAfter... check (#1118)
* update code & test

* update proto and adr026

* update CHANGELOG

* update cli docs

* update broken milestone link
  • Loading branch information
charleenfei committed Apr 25, 2022
commit e91ee68dd01742097230929fc7a12791a0ae868d
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### State Machine Breaking

### Improvements
* (modules/light-clients/07-tendermint) [\#1118](https://github.com/cosmos/ibc-go/pull/1118) Deprecating `AllowUpdateAfterExpiry and AllowUpdateAfterMisbehaviour`. See ADR-026 for context.
* (modules/core/02-client) [\#1188](https://github.com/cosmos/ibc-go/pull/1188/files) Routing `MsgSubmitMisbehaviour` to `UpdateClient` keeper function. Deprecating `SubmitMisbehaviour` endpoint.
* (modules/core/02-client) [\#1208](https://github.com/cosmos/ibc-go/pull/1208) Replace `CheckHeaderAndUpdateState` usage in 02-client with calls to `VerifyClientMessage`, `CheckForMisbehaviour`, `UpdateStateOnMisbehaviour` and `UpdateState`.
* (modules/light-clients/09-localhost) [\#1187](https://github.com/cosmos/ibc-go/pull/1187/) Removing localhost light client implementation as it is not functional.
Expand Down
13 changes: 6 additions & 7 deletions docs/architecture/adr-026-ibc-client-recovery-mechanisms.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- 2020/08/06: Revisions per review & to reference version
- 2021/01/15: Revision to support substitute clients for unfreezing
- 2021/05/20: Revision to simplify consensus state copying, remove initial height
- 2022/04/08: Revision to deprecate AllowUpdateAfterExpiry and AllowUpdateAfterMisbehaviour

## Status

Expand Down Expand Up @@ -35,21 +36,20 @@ Two-thirds of the validator set (the quorum for governance, module participation
We elect not to deal with chains which have actually halted, which is necessarily Byzantine behaviour and in which case token recovery is not likely possible anyways (in-flight packets cannot be timed-out, but the relative impact of that is minor).

1. Require Tendermint light clients (ICS 07) to be created with the following additional flags
1. `allow_governance_override_after_expiry` (boolean, default false)
1. `allow_update_after_expiry` (boolean, default true). Note that this flag has been deprecated, it remains to signal intent but checks against this value will not be enforced.
1. Require Tendermint light clients (ICS 07) to expose the following additional internal query functions
1. `Expired() boolean`, which returns whether or not the client has passed the trusting period since the last update (in which case no headers can be validated)
1. Require Tendermint light clients (ICS 07) & solo machine clients (ICS 06) to be created with the following additional flags
1. `allow_governance_override_after_misbehaviour` (boolean, default false)
1. `allow_update_after_misbehaviour` (boolean, default true). Note that this flag has been deprecated, it remains to signal intent but checks against this value will not be enforced.
1. Require Tendermint light clients (ICS 07) to expose the following additional state mutation functions
1. `Unfreeze()`, which unfreezes a light client after misbehaviour and clears any frozen height previously set
1. Add a new governance proposal type, `ClientUpdateProposal`, in the `x/ibc` module
1. Extend the base `Proposal` with two client identifiers (`string`).
1. The first client identifier is the proposed client to be updated. This client must be either frozen or expired.
1. The second client is a substitute client. It carries all the state for the client which may be updated. It must have identitical client and chain parameters to the client which may be updated (except for latest height, frozen height, and chain-id). It should be continually updated during the voting period.
1. If this governance proposal passes, the client on trial will be updated to the latest state of the substitute, if and only if:
1. `allow_governance_override_after_expiry` is true and the client has expired (`Expired()` returns true)
1. `allow_governance_override_after_misbehaviour` is true and the client has been frozen (`Frozen()` returns true)
1. In this case, additionally, the client is unfrozen by calling `Unfreeze()`
1. If this governance proposal passes, the client on trial will be updated to the latest state of the substitute.

Previously, AllowUpdateAfterExpiry and AllowUpdateAfterMisbehaviour were used to signal the recovery options for an expired or frozen client, and governance proposals were not allowed to overwrite the client if these parameters were set to false. However, this has now been deprecated because a code migration can overwrite the client and consensus states regardless of the value of these parameters. If governance would vote to overwrite a client or consensus state, it is likely that governance would also willing to perform a code migration to do the same.


Note that clients frozen due to misbehaviour must wait for the evidence to expire to avoid becoming refrozen.
Expand All @@ -62,7 +62,6 @@ This ADR does not address planned upgrades, which are handled separately as per

- Establishes a mechanism for client recovery in the case of expiry
- Establishes a mechanism for client recovery in the case of misbehaviour
- Clients can elect to disallow this recovery mechanism if they do not wish to allow for it
- Constructing an ClientUpdate Proposal is as difficult as creating a new client

### Negative
Expand Down
3 changes: 1 addition & 2 deletions docs/ibc/proposals.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ See also the relevant documentation: [ADR-026, IBC client recovery mechanisms](.

### Preconditions
- The chain is updated with ibc-go >= v1.1.0.
- Recovery parameters are set to `true` for the Tendermint light client (this determines if a governance proposal can be used). If the recovery parameters are set to `false`, recovery will require custom migration code.
- The client identifier of an active client for the same counterparty chain.
- The governance deposit.

Expand All @@ -67,7 +66,7 @@ Check if the client is attached to the expected `chain-id`. For example, for an
}
```

The client is attached to the expected Akash `chain-id` and the recovery parameters (`allow_update_after_expiry` and `allow_update_after_misbehaviour`) are set to `true`.
The client is attached to the expected Akash `chain-id`. Note that although the parameters (`allow_update_after_expiry` and `allow_update_after_misbehaviour`) exist to signal intent, these parameters have been deprecated and will not enforce any checks on the revival of client. See ADR-026 for more context on this deprecation.

### Step 2

Expand Down
4 changes: 2 additions & 2 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3911,8 +3911,8 @@ and a possible frozen height.
| `latest_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Latest height the client was updated to |
| `proof_specs` | [ics23.ProofSpec](#ics23.ProofSpec) | repeated | Proof specifications used in verifying counterparty state |
| `upgrade_path` | [string](#string) | repeated | Path at which next upgraded client will be committed. Each element corresponds to the key for a single CommitmentProof in the chained proof. NOTE: ClientState must stored under `{upgradePath}/{upgradeHeight}/clientState` ConsensusState must be stored under `{upgradepath}/{upgradeHeight}/consensusState` For SDK chains using the default upgrade module, upgrade_path should be []string{"upgrade", "upgradedIBCState"}` |
| `allow_update_after_expiry` | [bool](#bool) | | This flag, when set to true, will allow governance to recover a client which has expired |
| `allow_update_after_misbehaviour` | [bool](#bool) | | This flag, when set to true, will allow governance to unfreeze a client whose chain has experienced a misbehaviour event |
| `allow_update_after_expiry` | [bool](#bool) | | **Deprecated.** allow_update_after_expiry is deprecated |
| `allow_update_after_misbehaviour` | [bool](#bool) | | **Deprecated.** allow_update_after_misbehaviour is deprecated |



Expand Down
2 changes: 1 addition & 1 deletion docs/roadmap/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ During this quarter we will also probably release versions that bump the Cosmos

### H2 January

- [`v2.0.a`](https://github.com/cosmos/ibc-go/milestone/14)
- [`v2.0.a`](https://github.com/cosmos/ibc-go/milestone/11)
- [`v3.0.0-beta1`](https://github.com/cosmos/ibc-go/milestone/12): Beta 1 release of `v3.0.0` including Interchain Accounts, an update of Golang from `v1.15` to `v1.17`, and some core improvements. This is a Go-API breaking release because of [#472](https://github.com/cosmos/ibc-go/issues/472) and [#675](https://github.com/cosmos/ibc-go/pull/675).

### H1 February
Expand Down
27 changes: 6 additions & 21 deletions modules/light-clients/07-tendermint/types/proposal_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ import (
)

// CheckSubstituteAndUpdateState will try to update the client with the state of the
// substitute if and only if the proposal passes and one of the following conditions are
// satisfied:
// 1) AllowUpdateAfterMisbehaviour and Status() == Frozen
// 2) AllowUpdateAfterExpiry=true and Status() == Expired
// substitute.
//
// AllowUpdateAfterMisbehaviour and AllowUpdateAfterExpiry have been deprecated.
// Please see ADR 026 for more information.
//
// The following must always be true:
// - The substitute client is the same type as the subject client
// - The subject and substitute client states match in all parameters (expect frozen height, latest height, and chain-id)
//
// In case 1) before updating the client, the client will be unfrozen by resetting
// the FrozenHeight to the zero Height. If a client is frozen and AllowUpdateAfterMisbehaviour
// is set to true, the client will be unexpired even if AllowUpdateAfterExpiry is set to false.
// the FrozenHeight to the zero Height.
func (cs ClientState) CheckSubstituteAndUpdateState(
ctx sdk.Context, cdc codec.BinaryCodec, subjectClientStore,
substituteClientStore sdk.KVStore, substituteClient exported.ClientState,
Expand All @@ -39,23 +38,9 @@ func (cs ClientState) CheckSubstituteAndUpdateState(
return nil, sdkerrors.Wrap(clienttypes.ErrInvalidSubstitute, "subject client state does not match substitute client state")
}

switch cs.Status(ctx, subjectClientStore, cdc) {

case exported.Frozen:
if !cs.AllowUpdateAfterMisbehaviour {
return nil, sdkerrors.Wrap(clienttypes.ErrUpdateClientFailed, "client is not allowed to be unfrozen")
}

if cs.Status(ctx, subjectClientStore, cdc) == exported.Frozen {
// unfreeze the client
cs.FrozenHeight = clienttypes.ZeroHeight()

case exported.Expired:
if !cs.AllowUpdateAfterExpiry {
return nil, sdkerrors.Wrap(clienttypes.ErrUpdateClientFailed, "client is not allowed to be unexpired")
}

default:
return nil, sdkerrors.Wrap(clienttypes.ErrUpdateClientFailed, "client cannot be updated with proposal")
}

// copy consensus states and processed time from substitute to subject
Expand Down
102 changes: 7 additions & 95 deletions modules/light-clients/07-tendermint/types/proposal_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,133 +82,45 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() {
expPass bool
}{
{
name: "not allowed to be updated, not frozen or expired",
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: false,
FreezeClient: false,
ExpireClient: false,
expPass: false,
},
{
name: "not allowed to be updated, client is frozen",
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: false,
FreezeClient: true,
ExpireClient: false,
expPass: false,
},
{
name: "not allowed to be updated, client is expired",
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: false,
FreezeClient: false,
ExpireClient: true,
expPass: false,
},
{
name: "not allowed to be updated, client is frozen and expired",
name: "PASS: update checks are deprecated, client is frozen and expired",
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: false,
FreezeClient: true,
ExpireClient: true,
expPass: false,
},
{
name: "allowed to be updated only after misbehaviour, not frozen or expired",
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: true,
FreezeClient: false,
ExpireClient: false,
expPass: false,
},
{
name: "allowed to be updated only after misbehaviour, client is expired",
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: true,
FreezeClient: false,
ExpireClient: true,
expPass: false,
},
{
name: "allowed to be updated only after expiry, not frozen or expired",
AllowUpdateAfterExpiry: true,
AllowUpdateAfterMisbehaviour: false,
FreezeClient: false,
ExpireClient: false,
expPass: false,
},
{
name: "allowed to be updated only after expiry, client is frozen",
AllowUpdateAfterExpiry: true,
AllowUpdateAfterMisbehaviour: false,
FreezeClient: true,
ExpireClient: false,
expPass: false,
},
{
name: "PASS: allowed to be updated only after misbehaviour, client is frozen",
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: true,
FreezeClient: true,
ExpireClient: false,
expPass: true,
},
{
name: "PASS: allowed to be updated only after misbehaviour, client is frozen and expired",
name: "PASS: update checks are deprecated, not frozen or expired",
AllowUpdateAfterExpiry: false,
AllowUpdateAfterMisbehaviour: true,
FreezeClient: true,
ExpireClient: true,
expPass: true,
},
{
name: "PASS: allowed to be updated only after expiry, client is expired",
AllowUpdateAfterExpiry: true,
AllowUpdateAfterMisbehaviour: false,
FreezeClient: false,
ExpireClient: true,
ExpireClient: false,
expPass: true,
},
{
name: "allowed to be updated only after expiry, client is frozen and expired",
name: "PASS: update checks are deprecated, not frozen or expired",
AllowUpdateAfterExpiry: true,
AllowUpdateAfterMisbehaviour: false,
FreezeClient: true,
ExpireClient: true,
expPass: false,
},
{
name: "allowed to be updated after expiry and misbehaviour, not frozen or expired",
AllowUpdateAfterExpiry: true,
AllowUpdateAfterMisbehaviour: true,
FreezeClient: false,
ExpireClient: false,
expPass: false,
expPass: true,
},
{
name: "PASS: allowed to be updated after expiry and misbehaviour, client is frozen",
name: "PASS: update checks are deprecated, client is frozen",
AllowUpdateAfterExpiry: true,
AllowUpdateAfterMisbehaviour: true,
FreezeClient: true,
ExpireClient: false,
expPass: true,
},
{
name: "PASS: allowed to be updated after expiry and misbehaviour, client is expired",
name: "PASS: update checks are deprecated, client is expired",
AllowUpdateAfterExpiry: true,
AllowUpdateAfterMisbehaviour: true,
FreezeClient: false,
ExpireClient: true,
expPass: true,
},
{
name: "PASS: allowed to be updated after expiry and misbehaviour, client is frozen and expired",
AllowUpdateAfterExpiry: true,
AllowUpdateAfterMisbehaviour: true,
FreezeClient: true,
ExpireClient: true,
expPass: true,
},
}

for _, tc := range testCases {
Expand Down
Loading