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

[IBC] Implement ICS-23 CommitmentProof verification for the SMT #845

Merged
merged 12 commits into from
Jun 29, 2023

Conversation

h5law
Copy link
Contributor

@h5law h5law commented Jun 19, 2023

Description

Summary generated by Reviewpad on 29 Jun 23 20:46 UTC

This pull request includes various changes across multiple files.

In the README.md file, a new section titled "ICS-23 Vector Commitments" was added under the "Components" section, along with a link to the ICS-23 specification. Additionally, the link to the ICS-24 specification was updated to point to the ics24.md file.

In the go.sum file, new dependencies were added for the libraries github.com/cosmos/gogoproto and github.com/h5law/ics23/go, with specific version tags. The existing dependency on github.com/pokt-network/smt was also updated to a newer version.

The ics23.md file provides implementation details of ICS-23 Vector Commitments, including the benefits of using the cosmos/ics23 library and the changes made for Pocket's implementation. It also explains the proof verification process for membership and non-membership proofs, accompanied by flowchart diagrams. The implementation logic can be found in the file proofs_ics23.go.

A new file proofs_ics23_test.go was added to the ibc/store package, containing test functions for generating and verifying commitment proofs using the ICS23 library. The tests cover membership and non-membership proofs for a sparse Merkle tree.

The go.mod file shows various changes, including the addition of replace directives for modules github.com/cosmos/ics23/go and github.com/regen-network/gocuke, updates to module versions, and the addition of a new module github.com/cosmos/gogoproto.

The file proofs_ics23.go is a new addition to the ibc/store package, containing functions and constants for verifying membership and non-membership in a Sparse Merkle Tree.

Lastly, in the file where the NextCode constant is defined, it was updated to a new value and a new constant and error function were added.

Please review these changes in the pull request.

Issue

Fixes #841

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation
  • Other

List of changes

  • Add proof generation and verification in accordance with cosmos/ics23
  • Add SMT proof -> ics23 proof conversion

Testing

  • make develop_test; if any code changes were made
  • make test_e2e on k8s LocalNet; if any code changes were made
  • e2e-devnet-test passes tests on DevNet; if any code was changed
  • Docker Compose LocalNet; if any major functionality was changed or introduced
  • k8s LocalNet; if any infrastructure or configuration changes were made

Required Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added, or updated, godoc format comments on touched members (see: tip.golang.org/doc/comment)
  • I have tested my changes using the available tooling
  • I have updated the corresponding CHANGELOG

If Applicable Checklist

  • I have updated the corresponding README(s); local and/or global
  • I have added tests that prove my fix is effective or that my feature works
  • I have added, or updated, mermaid.js diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@h5law h5law added e2e-devnet-test Runs E2E tests on devnet ibc IBC specific changes labels Jun 19, 2023
@h5law h5law added this to the M7: Pocket NoS (North Star) milestone Jun 19, 2023
@h5law h5law self-assigned this Jun 19, 2023
@reviewpad reviewpad bot added large Pull request is large waiting-for-review labels Jun 19, 2023
@h5law h5law force-pushed the ibc/ics23_integration branch 2 times, most recently from 36a8056 to 8cd1fab Compare June 26, 2023 09:04
ibc/docs/README.md Outdated Show resolved Hide resolved
shared/core/types/error.go Outdated Show resolved Hide resolved
ibc/docs/ics23.md Show resolved Hide resolved
ibc/docs/ics23.md Outdated Show resolved Hide resolved
ibc/docs/ics23.md Outdated Show resolved Hide resolved
ibc/store/proofs_ics23.go Outdated Show resolved Hide resolved
ibc/store/proofs_ics23_test.go Outdated Show resolved Hide resolved
ibc/store/proofs_ics23_test.go Outdated Show resolved Hide resolved
ibc/store/proofs_ics23_test.go Outdated Show resolved Hide resolved
ibc/store/proofs_ics23_test.go Outdated Show resolved Hide resolved
Base automatically changed from ibc/initial_module to main June 27, 2023 08:11
@h5law h5law requested a review from Olshansk June 27, 2023 09:24
@h5law
Copy link
Contributor Author

h5law commented Jun 27, 2023

🚨 I HAVE REWRITTEN HISTORY 🚨

@Olshansk I went through all the comments, and rebased off of main. The PR is now much smaller without all the unecissary files from other PRs.

ibc/docs/README.md Show resolved Hide resolved
ibc/docs/ics23.md Show resolved Hide resolved
ibc/docs/ics23.md Outdated Show resolved Hide resolved
ibc/docs/ics23.md Outdated Show resolved Hide resolved
ibc/docs/ics23.md Outdated Show resolved Hide resolved
)

var (
// Custom SMT spec as the store does not hash values
Copy link
Member

Choose a reason for hiding this comment

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

The hashing and nonhashing makes sense to me in the context of IBC and SMT in independence.

It's not a blocker for this PR, but my question/concern is moreso for the larger context of the blockchain to make sure that I'm personally not missing/misunderstanding something. For the rest of the persistence module, question is: Should we hash the values for the other trees or not?

@dylanlott do you have thoughts/opinion here?

ibc/store/proofs_ics23_test.go Show resolved Hide resolved
ibc/store/proofs_ics23_test.go Outdated Show resolved Hide resolved
ibc/store/proofs_ics23_test.go Outdated Show resolved Hide resolved
return steps
}

// getPathBit takes the hash of a key (the path) and a position (depth) and returns whether at
Copy link
Member

Choose a reason for hiding this comment

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

See the ref - Ref: https://github.com/pokt-network/smt/blob/main/utils.go

Yea, this is definitely non-trivial to implement...

This business logic is VERY closely coupled with our specific SMT implementation. I'd suggest the following:

  1. exposing GetPathBit in the smt and reusing it here
  2. Move the comments you added to the smt
  3. Add an isLeftChild helper and use it here

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 have added a techdebt comment here as I have opened smt#14 which will cover this. As I have just release v0.6.0 for the SMT i think that its best to bundle these small changes into releases to save on constantly updating the go.mod. As the functionality will not change until this issue in in progress I think its alright to leave it until then.

LMK wdyt

Copy link
Member

Choose a reason for hiding this comment

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

Going to push back on this.

I think pokt-network/smt#14 is a 1+ month research and development project, whereas exposing the GetPathBit function is something we can do before EOD.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return steps
}

// getPathBit takes the hash of a key (the path) and a position (depth) and returns whether at
Copy link
Member

Choose a reason for hiding this comment

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

Going to push back on this.

I think pokt-network/smt#14 is a 1+ month research and development project, whereas exposing the GetPathBit function is something we can do before EOD.

- `key` is in tree -> `Proof` is invalid -> exclusion QED

```mermaid
flowchart TD
Copy link
Member

Choose a reason for hiding this comment

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

Appreciate the new diagram!

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

ICS23!!!!!

@h5law h5law merged commit 7031c93 into main Jun 29, 2023
9 checks passed
@h5law h5law deleted the ibc/ics23_integration branch June 29, 2023 21:22
bryanchriswhite added a commit that referenced this pull request Jun 30, 2023
* pokt/main:
  Update E2E_FEATURE_LIST.md
  [IBC] Implement ICS-23 CommitmentProof verification for the SMT (#845)
  [Utility] trustless relays servicer token validation (#803)
bryanchriswhite added a commit that referenced this pull request Jun 30, 2023
* feat/integrate-bg-router:
  Update E2E_FEATURE_LIST.md
  [IBC] Implement ICS-23 CommitmentProof verification for the SMT (#845)
  [Utility] trustless relays servicer token validation (#803)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e-devnet-test Runs E2E tests on devnet ibc IBC specific changes large Pull request is large waiting-for-review
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[IBC] Implement ICS-23 allowing for the verification of SMT proofs
2 participants