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

Implement ValidationContext and ExecutionContext for clients (ICS-2) #241

Merged
merged 15 commits into from
Nov 18, 2022

Conversation

plafer
Copy link
Contributor

@plafer plafer commented Nov 14, 2022

Closes: #240


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@plafer plafer changed the title Implement ValidationContext and ExecutionContext Implement ValidationContext and ExecutionContext for clients (ICS-2) Nov 16, 2022
@plafer plafer requested a review from hu55a1n1 November 16, 2022 21:59
@plafer plafer marked this pull request as ready for review November 16, 2022 21:59
Copy link
Member

@hu55a1n1 hu55a1n1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the general structure and approach of the changes in this PR. Will approve once the logic mismatch in the VPs and validate() is addressed/clarified. We can improve on the other suggestions iteratively in future PRs.

client_state,
consensus_state,
} = client_state
.check_header_and_update_state(ctx, client_id.clone(), header.clone())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't be running the complete header verification here and should only decode the header to obtain new client and consensus states. https://github.com/anoma/namada/blob/main/shared/src/ledger/ibc/handler.rs#L1187

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Should we do the check_header_and_update_state() split from #173 first then? Or perhaps merge this but open an issue, which we address before the next release?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay with both, but I would prefer the second option (i.e. merge this and open an issue).

let _ = client_state
.check_header_and_update_state(ctx, client_id.clone(), header)
.map_err(|e| Error::header_verification_failure(e.to_string()))?;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, the validate() function is Anoma's VP equivalent right? If so, the logic is incomplete, for e.g. w're missing verifying the previously emitted event (emitted during execution). https://github.com/anoma/namada/blob/main/shared/src/ledger/ibc/vp/client.rs#L311

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see Anoma's VP as a superset of validate(). For example, "verifying that the event was previously emitted" is specific to Anoma's architecture, and doesn't belong in ibc-rs. So Anoma's VP would first call validate() (IBC-specific checks), and then do their own custom checks (suck as making sure the event was properly emitted).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying this. 👍

})?;
let consensus_state = client_state.initialise(consensus_state)?;

ctx.store_client_type(ClientTypePath(client_id.clone()), client_type.clone())?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we could extract blocks like these (e.g. write_create_client(), emit_create_client_event(), etc.) and reused them in the future to avoid code duplication.

@plafer plafer merged commit 56fa56a into main Nov 18, 2022
@plafer plafer deleted the plafer/240-validation-execution-contexts branch November 18, 2022 18:12
Farhad-Shabani pushed a commit that referenced this pull request Sep 9, 2024
…-2) (#241)

* ValidationContext scaffolding

* validate for create_client()

* update_client validate()

* update client

* add `ExecutionContext`

* use pub(crate)

* execute scaffolding

* upgrade_client validate

* execute() for create_client

* execute update_client

* upgrade_client execute

* changelog

* fmt

* changelog fix
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.

ADR 5: Implement ValidationContext and ExecutionContext for clients (ICS-2)
2 participants