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 added support for multiple consensus states inside a header #115

Merged

Conversation

nadeemb53
Copy link
Contributor

A beefy or grandpa header submitted on-chain can potentially contain headers with multiple consensus states. This PR refactors the client interface to support beefy and grandpa light clients.

@nadeemb53 nadeemb53 force-pushed the nadeem/o2-client-refactor branch from 5b24f86 to 84cc4dc Compare November 4, 2022 07:34
@nadeemb53 nadeemb53 marked this pull request as ready for review November 4, 2022 09:10
@nadeemb53 nadeemb53 requested a review from a team as a code owner November 4, 2022 09:10
@nadeemb53 nadeemb53 changed the title WIP: 02-client-refactor added support for multiple consensus states inside a header 02-client-refactor added support for multiple consensus states inside a header Nov 4, 2022
@bluele
Copy link
Member

bluele commented Nov 8, 2022

Thanks for your PR!

My understanding is that in ICS-02 and ibc-go, each client implementation currently has the responsibility for client state updates. (ref. cosmos/ibc-go#1871) I would like to apply the same design to ibc-solidity as much as possible. Would this design change help with beefy and grandpa client implementations? Also, if you have already considered it, please tell us why it was difficult.

(however, there may be some things I missed about Gas cost or EVM constraints)
cc: @siburu @3100

@siburu
Copy link
Contributor

siburu commented Nov 8, 2022

@bluele

each client implementation currently has the responsibility for client state updates

Do you mean that IClient::updateClient itself should call host.setClientState?

@bluele
Copy link
Member

bluele commented Nov 8, 2022

Yes. FYI, example in Go: https://github.com/cosmos/ibc-go/blob/c86d27fc280cfb342a9e4689b381e5823441b694/modules/light-clients/07-tendermint/update.go#L132

@siburu
Copy link
Contributor

siburu commented Nov 8, 2022

Aside from that, I think you should move the definition of the handwritten ConsensusUpdate.Result to a different location.
The contracts/core/types directory contains only .sol files auto-generated from .proto files.

@bluele Where is an appropriate place to move it to?

@nadeemb53 nadeemb53 requested a review from Wizdave97 November 8, 2022 11:38
@nadeemb53
Copy link
Contributor Author

Hey @bluele, thanks for your comment. I have implemented it according to your suggestion.

@siburu thanks for your comment, I have removed consensusUpdate.Result as it was not needed anymore.

@bluele
Copy link
Member

bluele commented Nov 9, 2022

hey @nadeemb53, I realized there is one problem with moving the state updates to each client implementation.

The set* functions of the host cannot be called from Light Client contracts due to onlyIBCModule modifier. To prevent this, we need to use delegatecall for the Light Client contract call.

This have already been fixed in PR #116 . Therefore, please rebase the branch with the latest main. Also, could you minimize the changes in the commits? (e.g. the changes regarding code format are not needed in this PR)

@nadeemb53 nadeemb53 force-pushed the nadeem/o2-client-refactor branch from ce04237 to f5125a7 Compare November 9, 2022 12:34
@nadeemb53
Copy link
Contributor Author

@bluele thanks for your changes. I've rebased and followed it to further fix my PR.

tests/foundry/src/IBC.t.sol Outdated Show resolved Hide resolved
contracts/core/MockClient.sol Outdated Show resolved Hide resolved
contracts/core/IBFT2Client.sol Outdated Show resolved Hide resolved
contracts/core/MockClient.sol Outdated Show resolved Hide resolved
contracts/core/IBFT2Client.sol Outdated Show resolved Hide resolved
contracts/core/IBFT2Client.sol Outdated Show resolved Hide resolved
contracts/core/IClient.sol Outdated Show resolved Hide resolved
@bluele
Copy link
Member

bluele commented Nov 10, 2022

Hi @nadeemb53, I've left some comments. Also, run CI and it looks like integration-test is failed.

@nadeemb53 nadeemb53 force-pushed the nadeem/o2-client-refactor branch from 91a9844 to e62cbce Compare November 14, 2022 09:31
@nadeemb53
Copy link
Contributor Author

Hi @bluele , could you please run the CI?

@bluele
Copy link
Member

bluele commented Nov 14, 2022

@nadeemb53 done. Please squash your commits into one commit.

Signed-off-by: nadeemb53 <[email protected]>
@nadeemb53 nadeemb53 force-pushed the nadeem/o2-client-refactor branch from e62cbce to d683489 Compare November 14, 2022 11:39
@nadeemb53
Copy link
Contributor Author

done @bluele

@bluele bluele merged commit 686dd31 into hyperledger-labs:main Nov 15, 2022
@bluele
Copy link
Member

bluele commented Nov 15, 2022

@nadeemb53 Great work! I've merged this.

bluele added a commit that referenced this pull request Nov 16, 2022
Signed-off-by: Jun Kimura <[email protected]>
bluele added a commit that referenced this pull request Nov 16, 2022
Update tests and follow-up #115

Signed-off-by: Jun Kimura <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants