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

ADR-40: update on multi-store refactor and IBC proofs #10191

Merged

Conversation

roysc
Copy link
Contributor

@roysc roysc commented Sep 17, 2021

Description

Update on the proposal for the RootStore and how to handle the new proof scheme to support IBC.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@github-actions github-actions bot added the T: ADR An issue or PR relating to an architectural decision record label Sep 17, 2021
@roysc
Copy link
Contributor Author

roysc commented Sep 17, 2021

@robert-zaremba I've made some updates on your ADR update branch to cover my root store proposal and what we've discussed on IBC in a little more depth

@roysc
Copy link
Contributor Author

roysc commented Sep 17, 2021

Would also like to solicit @AdityaSripal to check that I've correctly summarized the IBC situation 🙏

Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

Thanks for improving the design!

GetStoreCache(StoreKey, CommitKVStore) CommitKVStore
Unwrap(StoreKey) CommitKVStore
Reset()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we merge these interfaces?

  1. Do we need RootStorePersistentCache?

Copy link
Contributor Author

@roysc roysc Sep 20, 2021

Choose a reason for hiding this comment

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

I think it is desired, but on second thought it probably won't look like this. I will just remove it for now and revisit

Copy link
Collaborator

Choose a reason for hiding this comment

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

Root store should be used only by the app. We can add interfaces if we need later when implementing. Then we can create a new PR to update the design. Let's start from the minimal interface. RootStore should not allow to write objects into it. Only the "normal" stores should allow writes.


This workaround can be used until the IBC connection code is fully upgraded and supports single-element commitment proofs.
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about keeping the paragraph: "the RootStore will have only two stores....".
Maybe we can be also more specific:

  • IBC store key is 01 (2 bits)
  • "general" store key is 1 (1 bit).
    Not sure though if we can only add as much as 1-2 bits though.

Copy link
Contributor Author

@roysc roysc Sep 20, 2021

Choose a reason for hiding this comment

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

Ah, I think I may have misunderstood Aditya's comment - I had thought ibc/clients, ibc/connections were the prefixes of separate stores. Now, if I've got it right, ibc is the only store prefix for IBC data, and the rest are just parts of the key paths. I'll update it.

I'm not sure I understand the prefixes you're proposing though. If you mean how the data is partitioned in the DB, that doesn't seem to belong at this level of design, also I don't think it's feasible to have prefixes smaller than a byte - it would shift the alignment of all the following data.

For IBC proofs, I believe the IBC data must be under the ibc store key, and the general data can just use the empty string.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, my understanding is that there is one store for IBC: the ibc/. Then they have a 3 groups of objects: clients, connections, channels.
So my proposal is that in the root store we have 2 stores:

  • IBC with 01 prefix (2 bits or 1 byte). AFAIU, IBC supports changing the prefix without doing x/ibc update -- it requires a migration only.
  • "general" store for everything else.

@AdityaSripal , @colin-axner - could you validate this?

Copy link
Member

Choose a reason for hiding this comment

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

IBC does not support changing the prefix unfortunately because the prefix is in the connection which is non-upgradable.

Can the separate IBC store retain the ibc/ prefix?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, if we can't change it then we will keep it.

InitialVersion uint64

ReservePrefix(StoreKey, StoreType)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

TODO: validate if we really need all these interfaces. It seams to me that the app only needs the CommitRootStore.

We let's add this TODO into the code and merge it - we can do that check in the "main" PR.

Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

Pre-Approving. This is a good update, let's add TODOs in the "code" and merge it and continue the discussion in the main PR.

@robert-zaremba robert-zaremba merged commit 3f841fd into cosmos:robert/adr-40-update Oct 1, 2021
robert-zaremba added a commit that referenced this pull request Oct 22, 2021
* adr-40: use prefix store instead of multistore

* add note about prefix.Store

* Update SC and SS setup information and historical versions sepc

* add note about key prefix optimization

* rephrased the changes related to multistore

* Apply suggestions from code review

Co-authored-by: Ryan Christoffersen <[email protected]>

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* design update

* update merkle proofs

* Apply suggestions from code review

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* reword huffman compression paragraph

* ADR-40: update on multi-store refactor and IBC proofs (#10191)

* Update on multistore refactor and IBC proof

* cleanup whitespace

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

Co-authored-by: Robert Zaremba <[email protected]>

* revise for PR

* add todo

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

Co-authored-by: Robert Zaremba <[email protected]>

Co-authored-by: Robert Zaremba <[email protected]>

* review updates

* add todo for protobuf message type compression

* add link to a discussion

* guarantee atomic commit with IBC workaround proposal

* adding more links to references

* Apply suggestions from code review

Co-authored-by: Roy Crihfield <[email protected]>

* reword the module key compression part

Co-authored-by: Ryan Christoffersen <[email protected]>
Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Roy Crihfield <[email protected]>
creachadair pushed a commit that referenced this pull request Oct 22, 2021
* adr-40: use prefix store instead of multistore

* add note about prefix.Store

* Update SC and SS setup information and historical versions sepc

* add note about key prefix optimization

* rephrased the changes related to multistore

* Apply suggestions from code review

Co-authored-by: Ryan Christoffersen <[email protected]>

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* design update

* update merkle proofs

* Apply suggestions from code review

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* reword huffman compression paragraph

* ADR-40: update on multi-store refactor and IBC proofs (#10191)

* Update on multistore refactor and IBC proof

* cleanup whitespace

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

Co-authored-by: Robert Zaremba <[email protected]>

* revise for PR

* add todo

* Update docs/architecture/adr-040-storage-and-smt-state-commitments.md

Co-authored-by: Robert Zaremba <[email protected]>

Co-authored-by: Robert Zaremba <[email protected]>

* review updates

* add todo for protobuf message type compression

* add link to a discussion

* guarantee atomic commit with IBC workaround proposal

* adding more links to references

* Apply suggestions from code review

Co-authored-by: Roy Crihfield <[email protected]>

* reword the module key compression part

Co-authored-by: Ryan Christoffersen <[email protected]>
Co-authored-by: Federico Kunze <[email protected]>
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Roy Crihfield <[email protected]>
@roysc roysc deleted the roysc/adr-040-update-adr branch February 15, 2022 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: ADR An issue or PR relating to an architectural decision record
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants