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

Port over ics23-iavl #276

Merged
merged 10 commits into from
Jul 7, 2020
Merged

Port over ics23-iavl #276

merged 10 commits into from
Jul 7, 2020

Conversation

AdityaSripal
Copy link
Member

@AdityaSripal AdityaSripal commented Jun 23, 2020

Currently a simple copy of https://github.com/confio/ics23-iavl into this repo. This will remove the outside dependency sitting between iavl and SDK.

A future PR will optimize this further by directly creating the ICS proof rather than converting

cc: @ethanfrey

Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

LGTM. Pending lint fix

ics23.go/test_helpers.go Outdated Show resolved Hide resolved
Copy link
Contributor

@erikgrinaker erikgrinaker left a comment

Choose a reason for hiding this comment

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

I think at some point this should be made methods on the tree itself. Are we planning on replacing the current proofs with these, or will these be in addition?

ics23.go/proof.go Outdated Show resolved Hide resolved
@tac0turtle
Copy link
Member

tac0turtle commented Jun 24, 2020

since we are doing multiple releases of IAVL we could mark the current proofs as deprecated and add these then in the next major release remove the old ones. The sdk does not use them and other users would be using iavl the same way the sdk is so it shouldn't be a worry.

Could you add deprecated flag to the old proofs godoc

@erikgrinaker
Copy link
Contributor

since we are doing multiple releases of IAVL we could mark the current proofs as deprecated and add these then in the next major release remove the old ones. The sdk does not use them and other users would be using iavl the same way the sdk is so it shouldn't be a worry.

Could you add deprecated flag to the old proofs godoc

That might be a good idea. If so, we should make sure the API is final, and make sure there are no bugs that require breaking changes to proofs. We should also update the proof documentation.

Could someone give me a quick summary of where IAVL proofs are used today?

@tac0turtle
Copy link
Member

Could someone give me a quick summary of where IAVL proofs are used today?

I couldn't find them being used in the sdk. I looked over a few projects that are forks of the sdk and they dont use them as well.. deadcode?

@ethanfrey
Copy link
Contributor

They are turned into ProofOps when you query /store with proof: true (query raw value by raw key). It can be validated by the ProofRuntime (which seems to be in 0.33 tendermint but gone in 0.34).

On the client side, you are supposed to parse and validate all this. Theoretically, there is a light-client mode in the cli (not sure how to turn it on) and this will validate all such queries. I was using them back in the original sdk 😉 0.8 or so.... hope it didn't all get refactored away

Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

A little rename and I think it's fine.

ics23.go/proof.go Outdated Show resolved Hide resolved
ics23.go/test_helpers.go Outdated Show resolved Hide resolved
@ethanfrey
Copy link
Contributor

I think at some point this should be made methods on the tree itself. Are we planning on replacing the current proofs with these, or will these be in addition?

I agree. I kept it separate to avoid super slow PR review cycles last summer. Now the core team will use this code it definitely should use private methods and returns the proof directly (just like current range proofs). In fact, we could replace all proofs with this, and returns CompressedBatchProofs instead of range proofs (they allow you to return a whole lot of proofs, possibly continuous).

I would merge this first, then add them as first class citizens to the tree, then see if we can start deprecating what is there

@erikgrinaker
Copy link
Contributor

@AdityaSripal Could you move this into the root package and fix the linter issues please?

I'd also like to start discussing the plan for the final 0.15 proof API so that we can cut it soon.

proof_ics23.go Outdated
return steps
}

func aminoVarInt(orig int64) []byte {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really necessary? As far as I know, Amino uses standard Go variants, and we have utility functions for generating these in encoding.go - can you check if we can use any of those instead?

for i := 0; i < size; i++ {
// create random 4 byte key
// nolint:gosec
key := []byte{byte(rand.Uint64()), byte(rand.Uint64()), byte(rand.Uint64()), byte(rand.Uint64())}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use rand.Read() as well to generate random byte slices.

proof_ics23.go Outdated
GetMembershipProof will produce a CommitmentProof that the given key (and queries value) exists in the iavl tree.
If the key doesn't exist in the tree, this will return an error.
*/
func (tree *ImmutableTree) GetMembershipProof(key []byte) (*ics23.CommitmentProof, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll have to use t *ImmutableTree to appease the linter.

@erikgrinaker
Copy link
Contributor

Thanks for updating! Added a couple of minor comments - can you update the changelog as well, and then merge this?

@AdityaSripal AdityaSripal merged commit b7d621b into master Jul 7, 2020
@AdityaSripal AdityaSripal deleted the aditya/port-ics23-iavl branch July 7, 2020 18:18
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.

None yet

5 participants