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

solidity implementation for ics23 #55

Closed
wants to merge 1 commit into from

Conversation

lightyear15
Copy link

Code is splitted in 4 different libraries, following the layout of
functions and files of the go implementation

  • Ops -> go/ops.go
  • Proof -> go/proof.go
  • Compress -> go/compress.go
  • Ics23 -> go/ics23.go

Missing parts of the current implementation:

  • sha512 hash option: solidity does not have built-in function for this
    hash. A solidity implementation would utterly inefficient and very
    costly (gas-wise)
  • compress functions: the implementation will very likely be used to
    verification, not for proof generation
  • ProofSpec for tendermint and iavl definition: again, this
    implementation is meant to be used to verify, not to provide proofs.

The implementation also provides a framework to run the same unit-test
cases that the go implementation has.
go-ethereum package provides a SimulatedBackend that can be used to
deploy a contract and call functions. UnitTest-specific contracts are
included in the libraries sol files.
The current go-ethereum version is the last with a working abigen
command.

This commit also refactors the go project to make room for two go
modules in the same repository

@lightyear15
Copy link
Author

lightyear15 commented Nov 10, 2021

A few points to answer yet-to-ask reviewers' questions:

  • This PR refactors the go implementation, there is no functional change, only refactoring tests code to being able to share the cases with solidity unit tests - also root-level go.mod has been removed
  • I failed at automating the protoc for solidity build step. Unfortunately there is not yet official protobuf-solidity compiler/plugin. I used an updated version of the @datachainlab compiler.
  • even though go-ethereum pkg is now at 1.10.12. The latest working version of abigen is v.1.10.0
  • circleCI does not provide any docker image with solidity tools like solc compiler. Using tools like truffle would have prevented me from reusing go unit test cases.
  • solidity dependencies have been declared in truffle-style. In order to compile the go bindings for unit testing solidity code, users must download those dependencies locally -- see README.md . Possible other options would me git submodule

If this PR is too bulky and cumbersome to review, please let me know and I will try to split it into smaller, less scary pieces.

Code is splitted in 4 different libraries, following the layout of
functions and files of the go implementation
- Ops -> go/ops.go
- Proof -> go/proof.go
- Compress -> go/compress.go
- Ics23 -> go/ics23.go

Missing parts of the current implementation:
- sha512 hash option: solidity does not have built-in function for this
hash. A solidity implementation would utterly inefficient and very
costly (gas-wise)
- compress functions: the implementation will very likely be used to
verification, not for proof generation
- ProofSpec for tendermint and iavl definition: again, this
implementation is meant to be used to verify, not to provide proofs.

The implementation also provides a framework to run the same unit-test
cases that the go implementation has.
go-ethereum package provides a ``SimulatedBackend`` that can be used to
deploy a contract and call functions. UnitTest-specific contracts are
included in the libraries sol files.
The current go-ethereum version is the last with a working ``abigen``
command.

This commit also refactors the go project to make room for two go
modules in the same repository
@lightyear15
Copy link
Author

@adizere, @andynog,
you might be interested in this.

@ethanfrey
Copy link
Contributor

I have yet to review, but 2 points.

  1. Can you do the go stuff in another pr, separate from Solidity?

  2. What is the license on the go-ethereum code you import? Much is GPL which is not good for this library.

@lightyear15
Copy link
Author

Hi @ethanfrey,
I understand that license mismatch is a problem. However, if we can't include any of the go-ethereum code, it would not make sense anymore to refactor the go code, as the only purpose of the changes was to import the test cases in the solidity unit test framework.
I can try to move to truffle framework which is licensed under MIT.

@ethanfrey
Copy link
Contributor

I have asked about licensing many times with the ICF and they are very admimant about Apache-2 only, no GPL family.

Since this package is imported by the Cosmos SDK, and thus affected every Cosmos blockchain, we need to be extra careful to maintain Apache 2 compliance.

@ethanfrey
Copy link
Contributor

Thank you for this work, and I look forward to seeing one based on MIT code

@lightyear15
Copy link
Author

Thanks @ethanfrey ,
I realised, I can move all the test cases description to json, so to be shared between go code and truffle's javascript code.
✌️

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.

2 participants