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

IsFrozen() changed to Status() #140

Merged
merged 23 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8a5ab72
initial work, pause for feedback
colin-axner Apr 9, 2021
7afeca9
Merge branch 'main' of github.com:cosmos/ibc-go into colin/98-client-…
colin-axner Apr 22, 2021
0db05e6
IsFrozen() -> Status()
colin-axner Apr 26, 2021
47448e1
Merge branch 'main' of github.com:cosmos/ibc-go into colin/98-client-…
colin-axner Apr 26, 2021
7899060
fix bug
colin-axner Apr 26, 2021
400e719
fix tests
colin-axner Apr 26, 2021
e34a9af
remove typo
colin-axner Apr 26, 2021
9c4c899
add verify tests
colin-axner Apr 27, 2021
dc26cd3
error message and code cleanup
colin-axner Apr 27, 2021
94cafbe
self review fixes
colin-axner Apr 27, 2021
3ed46b2
Update modules/core/02-client/keeper/client.go
colin-axner Apr 27, 2021
2ae5339
Merge branch 'main' into colin/98-client-status
colin-axner Apr 27, 2021
ffd9e1b
add gRPC route to proto
colin-axner Apr 28, 2021
2f67828
add gRPC route and tests
colin-axner Apr 28, 2021
ea8644a
update changelog
colin-axner Apr 28, 2021
cb0eb3f
apply review suggestions
colin-axner Apr 28, 2021
0ac6588
Update modules/light-clients/06-solomachine/types/client_state_test.go
colin-axner Apr 28, 2021
8c4b1f1
code ordering
colin-axner Apr 28, 2021
d3e203c
Merge branch 'colin/98-client-status' of github.com:cosmos/ibc-go int…
colin-axner Apr 28, 2021
470dff8
Merge branch 'main' into colin/98-client-status
colin-axner Apr 29, 2021
90c9f29
add set consensus state helper function
colin-axner Apr 29, 2021
cca717d
use typed string for status
colin-axner May 3, 2021
2ad2e25
Merge branch 'main' into colin/98-client-status
colin-axner May 4, 2021
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 @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking

* (modules) [\#140](https://github.com/cosmos/ibc-go/pull/140) IsFrozen() client state interface changed to Status(). gRPC `ClientStatus` route added.
* (modules/core) [\#109](https://github.com/cosmos/ibc-go/pull/109) Remove connection and channel handshake CLI commands.
* (modules) [\#107](https://github.com/cosmos/ibc-go/pull/107) Modify OnRecvPacket callback to return an acknowledgement which indicates if it is successful or not. Callback state changes are discarded for unsuccessful acknowledgements only.
* (modules) [\#108](https://github.com/cosmos/ibc-go/pull/108) All message constructors take the signer as a string to prevent upstream bugs. The `String()` function for an SDK Acc Address relies on external context.
Expand Down
73 changes: 73 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,14 @@
<a href="#ibc.core.client.v1.QueryClientStatesResponse"><span class="badge">M</span>QueryClientStatesResponse</a>
</li>

<li>
<a href="#ibc.core.client.v1.QueryClientStatusRequest"><span class="badge">M</span>QueryClientStatusRequest</a>
</li>

<li>
<a href="#ibc.core.client.v1.QueryClientStatusResponse"><span class="badge">M</span>QueryClientStatusResponse</a>
</li>

<li>
<a href="#ibc.core.client.v1.QueryConsensusStateRequest"><span class="badge">M</span>QueryConsensusStateRequest</a>
</li>
Expand Down Expand Up @@ -4547,6 +4555,54 @@ MsgChannelCloseConfirm.</p></td>



<h3 id="ibc.core.client.v1.QueryClientStatusRequest">QueryClientStatusRequest</h3>
<p>QueryClientStatusRequest is the request type for the Query/ClientStatus RPC</p><p>method</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>client_id</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>client unique identifier </p></td>
</tr>

</tbody>
</table>





<h3 id="ibc.core.client.v1.QueryClientStatusResponse">QueryClientStatusResponse</h3>
<p>QueryClientStatusResponse is the response type for the Query/ClientStatus RPC</p><p>method. It returns the current status of the IBC client.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>status</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>

</tbody>
</table>





<h3 id="ibc.core.client.v1.QueryConsensusStateRequest">QueryConsensusStateRequest</h3>
<p>QueryConsensusStateRequest is the request type for the Query/ConsensusState</p><p>RPC method. Besides the consensus state, it includes a proof and the height</p><p>from which the proof was retrieved.</p>

Expand Down Expand Up @@ -4820,6 +4876,13 @@ client.</p></td>
<td><p>UpgradedConsensusState queries an Upgraded IBC consensus state.</p></td>
</tr>

<tr>
<td>ClientStatus</td>
<td><a href="#ibc.core.client.v1.QueryClientStatusRequest">QueryClientStatusRequest</a></td>
<td><a href="#ibc.core.client.v1.QueryClientStatusResponse">QueryClientStatusResponse</a></td>
<td><p>Status queries the status of an IBC client.</p></td>
</tr>

</tbody>
</table>

Expand Down Expand Up @@ -4908,6 +4971,16 @@ client.</p></td>
</tr>




<tr>
<td>ClientStatus</td>
<td>GET</td>
<td>/ibc/core/client/v1/client_status/{client_id}</td>
<td></td>
</tr>


</tbody>
</table>

Expand Down
26 changes: 15 additions & 11 deletions modules/core/02-client/keeper/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ func (k Keeper) UpdateClient(ctx sdk.Context, clientID string, header exported.H
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID)
}

// prevent update if the client is frozen before or at header height
if clientState.IsFrozen() && clientState.GetFrozenHeight().LTE(header.GetHeight()) {
return sdkerrors.Wrapf(types.ErrClientFrozen, "cannot update client with ID %s", clientID)
clientStore := k.ClientStore(ctx, clientID)

if status := clientState.Status(ctx, clientStore, k.cdc); status != exported.Active {
return sdkerrors.Wrapf(types.ErrClientNotActive, "cannot update client (%s) with status %s", clientID, status)
}

clientState, consensusState, err := clientState.CheckHeaderAndUpdateState(ctx, k.cdc, k.ClientStore(ctx, clientID), header)
clientState, consensusState, err := clientState.CheckHeaderAndUpdateState(ctx, k.cdc, clientStore, header)
if err != nil {
return sdkerrors.Wrapf(err, "cannot update client with ID %s", clientID)
}
Expand Down Expand Up @@ -130,12 +131,13 @@ func (k Keeper) UpgradeClient(ctx sdk.Context, clientID string, upgradedClient e
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot update client with ID %s", clientID)
}

// prevent upgrade if current client is frozen
if clientState.IsFrozen() {
return sdkerrors.Wrapf(types.ErrClientFrozen, "cannot update client with ID %s", clientID)
clientStore := k.ClientStore(ctx, clientID)

if status := clientState.Status(ctx, clientStore, k.cdc); status != exported.Active {
return sdkerrors.Wrapf(types.ErrClientNotActive, "cannot upgrade client (%s) with status %s", clientID, status)
}

updatedClientState, updatedConsState, err := clientState.VerifyUpgradeAndUpdateState(ctx, k.cdc, k.ClientStore(ctx, clientID),
updatedClientState, updatedConsState, err := clientState.VerifyUpgradeAndUpdateState(ctx, k.cdc, clientStore,
upgradedClient, upgradedConsState, proofUpgradeClient, proofUpgradeConsState)
if err != nil {
return sdkerrors.Wrapf(err, "cannot upgrade client with ID %s", clientID)
Expand Down Expand Up @@ -178,11 +180,13 @@ func (k Keeper) CheckMisbehaviourAndUpdateState(ctx sdk.Context, misbehaviour ex
return sdkerrors.Wrapf(types.ErrClientNotFound, "cannot check misbehaviour for client with ID %s", misbehaviour.GetClientID())
}

if clientState.IsFrozen() && clientState.GetFrozenHeight().LTE(misbehaviour.GetHeight()) {
return sdkerrors.Wrapf(types.ErrInvalidMisbehaviour, "client is already frozen at height ≤ misbehaviour height (%s ≤ %s)", clientState.GetFrozenHeight(), misbehaviour.GetHeight())
clientStore := k.ClientStore(ctx, misbehaviour.GetClientID())

if status := clientState.Status(ctx, clientStore, k.cdc); status != exported.Active {
return sdkerrors.Wrapf(types.ErrClientNotActive, "cannot process misbehaviour for client (%s) with status %s", misbehaviour.GetClientID(), status)
}

clientState, err := clientState.CheckMisbehaviourAndUpdateState(ctx, k.cdc, k.ClientStore(ctx, misbehaviour.GetClientID()), misbehaviour)
clientState, err := clientState.CheckMisbehaviourAndUpdateState(ctx, k.cdc, clientStore, misbehaviour)
if err != nil {
return err
}
Expand Down
Loading