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

Feat: state verifier #766

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Feat: state verifier #766

wants to merge 19 commits into from

Conversation

pr0n00gler
Copy link
Collaborator

This PR implements a module that allows to verify that some storage values were indeed present on a particular block height in the chain.

The idea is the similar how Neutron's KV ICQ works: each StorageValue in Cosmos SDK is stored in KV-IAVL storage.
And to be more precise it's stored in a structure called MerkleTree.
The tree allows to compose Proof for key and value pairs that can prove two things using RootHash of the tree:

  • key and value are present in the tree;
  • key is not present in the tree.

On each block the module's BeginBlocker is being called, and it saves ConsensusState of the current block height in the storage to use it for verification of storage values later:

consensusState := tendermint.ConsensusState{
    Timestamp:          ctx.BlockTime(), // current block time
    Root:               ibccommitmenttypes.NewMerkleRoot(headerInfo.AppHash), // .AppHash for the previous block
    NextValidatorsHash: cometInfo.GetValidatorsHash(), // hash of the validator set for the next block
}

For verification only .Root (header.AppHash) is used, but it's good to save all the values just in case and do not leave them empty.

The main query of the module that accepts slice of []StorageValue structures and blockHeight on which those StorageValues are present.
The module verifies the values and returns an error if values cannot be verified {valid: true} structure if values are valid.

app/app.go Outdated Show resolved Hide resolved
proto/neutron/state_verifier/v1/query.proto Show resolved Hide resolved
x/state-verifier/keeper/query.go Show resolved Hide resolved
x/state-verifier/keeper/keeper.go Outdated Show resolved Hide resolved
x/state-verifier/types/keys.go Outdated Show resolved Hide resolved
NeverHappened
NeverHappened previously approved these changes Nov 24, 2024
x/state-verifier/types/keys.go Outdated Show resolved Hide resolved
x/state-verifier/keeper/keeper.go Outdated Show resolved Hide resolved
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.

4 participants