-
Notifications
You must be signed in to change notification settings - Fork 71
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 #58
Conversation
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 be utterly inefficient and very costly (gas-wise) - compress functions: this implementation is meant be used for verification, not for proof generation - ProofSpec for tendermint and iavl definition: again, this implementation is just to verify, not to generate - Decompress functions are present but not working: currently investigating a potention buf in the protobuf runtime - Batch verification functions are temporarily disabled due to above
Hello @adizee @andynog @ethanfrey , I am investigating the issue with the Protobuf decompress functions, trying to tailor the the simplest possible example for the maintainers of the solidity-protobuf to start the investigation. |
Agree. No know implementations use this. It was just added for completeness.
Agree.
The ProofSpec is needed to verify. You don't need to export it, but the test cases should have access to those proof specs so they can verify the same data. (You don't need a solidity object for it if you don't want)
These only apply to batch proofs. Current ICS / Relayer usage seems to just include a series of existence proofs and no batching/compression, so simply throwing an error "not yet implemented" and leaving an issue to add them seems fine
|
MIT is good. I will try to review soon, but it is fine to merge with the described functionality if it works |
I will take a look at this, but might be a couple days. |
FYI: ... 🤔 ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test code looks nice and proper.
I cannot review solidity, so I would take someone else on that, but from my end, we could merge this as is (tested) and then have another pass with a solidity reviewer to ensure there are no issues in that code.
|
||
@pytest.mark.parametrize("fname", [os.path.join(IAVL_TEST_DIR, fname) for fname in cases_fname]) | ||
@pytest.mark.skip(reason="potential bug in ProtobufRuntime") | ||
def test_iavl_decompress(compress, proof, fname): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazed at how expressive these tests can be with those decorators. Nice stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shame they are skipped. But compress is not essential for v1
key = base64.b64decode(case["Key"] or "") | ||
value = base64.b64decode(case["Value"] or "") | ||
if case["IsErr"]: | ||
with brownie.reverts(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this ensure it throws an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return accounts[0].deploy(Proof_UnitTest) | ||
|
||
|
||
@pytest.mark.parametrize("fname", [os.path.join(IAVL_TEST_DIR, fname) for fname in cases_fname]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
@lightyear15 sorry for the long delay. If you want, I can merge it. Just let me know. |
Hello @ethanfrey , |
Changing the return values of functions throughout the libraries to avoid using ``require`` and ``revert``. Function callers will receive an enum encoding the Error
Separating Mock contracts from libraries
@@ -0,0 +1,2990 @@ | |||
// SPDX-License-Identifier: Apache-2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The biggest issue here is the use of this library. It is a protobuf codec that may or may not follow a non-existent protobuf spec, not an ADR-027 codec. The latter is highly recommended (read: required) to avoid the possibility of malleability attacks such as this one. You should be using the following libraries to deal with protobuf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HI @adlerjohn ,
the problem with the celestiaorg
compiler is that, as reported in the README, it does not support oneof
needed in
BatchEntry
CompressedBatchEntry
and most importantly, in
CommitmentProof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oneof
can be implemented as a library! Much better than fixing the currently-used library to be ADR-027-compliant. PRs welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have talked to the datachainlab/solidity-protobuf compiler's maintainers.
They have plans to make it ADR-27 compliant soon.
I think I will just sit and wait for it 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works too!
Datachain lab have updated their compiler which now is ADR-27 compliant. |
@ethanfrey is work on this complete? Curious! |
Hi @adlerjohn and @mkaczanowski, would you be able to take a look to see if your comments have been addressed and approve the PR if you find the time? |
Is there still interest in merging this PR? |
not on my side |
Ok, thank you. Then I will close the PR for now. |
Code is splitted in 4 different libraries, following the layout of
functions and files of the go implementation
Missing parts of the current implementation:
hash. A solidity implementation would be utterly inefficient and very
costly (gas-wise)
verification, not for proof generation
implementation is just to verify, not to generate
investigating a potention buf in the protobuf runtime