v1

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProofOpIAVLCommitment         = "ics23:iavl"
	ProofOpSimpleMerkleCommitment = "ics23:simple"
)
View Source
const ProofOpMultiStore = "multistore"

the multi-store proof operation constant value

Variables

This section is empty.

Functions

func CommitmentOpDecoder

func CommitmentOpDecoder(pop merkle.ProofOp) (merkle.ProofOperator, error)

CommitmentOpDecoder takes a merkle.ProofOp and attempts to decode it into a CommitmentOp ProofOperator The proofOp.Data is just a marshalled CommitmentProof. The Key of the CommitmentOp is extracted from the unmarshalled proof.

func DefaultProofRuntime

func DefaultProofRuntime() (prt *merkle.ProofRuntime)

func Ics23CompatibleProofRuntime

func Ics23CompatibleProofRuntime() (prt *merkle.ProofRuntime)

func Ics23ProofRuntime

func Ics23ProofRuntime() (prt *merkle.ProofRuntime)

func MultiStoreProofOpDecoder

func MultiStoreProofOpDecoder(pop merkle.ProofOp) (merkle.ProofOperator, error)

MultiStoreProofOpDecoder returns a multi-store merkle proof operator from a given proof operation.

func QueryKeyWithProof

func QueryKeyWithProof(node rpcclient.Client, key []byte, storeName string, height int64) ([]byte, []byte, []byte, error)

func RequireProof

func RequireProof(subpath string) bool

RequireProof return whether proof is require for the subpath

Types

type Codec

type Codec = amino.Codec
var Cdc *Codec

type CommitID

type CommitID struct {
	Version int64
	Hash    []byte
}

CommitID contains the tree version number and its merkle root.

func (CommitID) IsZero

func (cid CommitID) IsZero() bool

func (CommitID) String

func (cid CommitID) String() string

type CommitInfo

type CommitInfo struct {

	// Version
	Version int64

	// Store info for
	StoreInfos []StoreInfo
}

func (CommitInfo) CommitID

func (ci CommitInfo) CommitID() CommitID

func (CommitInfo) Hash

func (ci CommitInfo) Hash() []byte

Hash returns the simple merkle root hash of the stores sorted by name.

type CommitmentOp

type CommitmentOp struct {
	Type  string
	Spec  *ics23.ProofSpec
	Key   []byte
	Proof *ics23.CommitmentProof
}

CommitmentOp implements merkle.ProofOperator by wrapping an ics23 CommitmentProof It also contains a Key field to determine which key the proof is proving. NOTE: CommitmentProof currently can either be ExistenceProof or NonexistenceProof

Type and Spec are classified by the kind of merkle proof it represents allowing the code to be reused by more types. Spec is never on the wire, but mapped from type in the code.

func (CommitmentOp) GetKey

func (op CommitmentOp) GetKey() []byte

func (CommitmentOp) ProofOp

func (op CommitmentOp) ProofOp() merkle.ProofOp

ProofOp implements ProofOperator interface and converts a CommitmentOp into a merkle.ProofOp format that can later be decoded by CommitmentOpDecoder back into a CommitmentOp for proof verification

func (CommitmentOp) Run

func (op CommitmentOp) Run(args [][]byte) ([][]byte, error)

Run takes in a list of arguments and attempts to run the proof op against these arguments. Returns the root wrapped in [][]byte if the proof op succeeds with given args. If not, it will return an error.

CommitmentOp will accept args of length 1 or length 0 If length 1 args is passed in, then CommitmentOp will attempt to prove the existence of the key with the value provided by args[0] using the embedded CommitmentProof and return the CommitmentRoot of the proof. If length 0 args is passed in, then CommitmentOp will attempt to prove the absence of the key in the CommitmentOp and return the CommitmentRoot of the proof.

type ConsensusState

type ConsensusState struct {
	ChainID             string
	Height              uint64
	AppHash             []byte
	CurValidatorSetHash []byte
	NextValidatorSet    *tmtypes.ValidatorSet
}

func DecodeConsensusState

func DecodeConsensusState(input []byte) (ConsensusState, error)

input: | chainID | height | appHash | curValidatorSetHash | [{validator pubkey, voting power}] | | 32 bytes | 8 bytes | 32 bytes | 32 bytes | [{32 bytes, 8 bytes}] |

func GetInitConsensusState

func GetInitConsensusState(node rpcclient.Client, height int64) (*ConsensusState, error)

func (*ConsensusState) ApplyHeader

func (cs *ConsensusState) ApplyHeader(header *Header) (bool, error)

func (ConsensusState) EncodeConsensusState

func (cs ConsensusState) EncodeConsensusState() ([]byte, error)

output: | chainID | height | appHash | curValidatorSetHash | [{validator pubkey, voting power}] | | 32 bytes | 8 bytes | 32 bytes | 32 bytes | [{32 bytes, 8 bytes}] |

type Header struct {
	tmtypes.SignedHeader
	ValidatorSet     *tmtypes.ValidatorSet `json:"validator_set"`
	NextValidatorSet *tmtypes.ValidatorSet `json:"next_validator_set"`
}

func DecodeHeader

func DecodeHeader(input []byte) (*Header, error)

func QueryTendermintHeader

func QueryTendermintHeader(node rpcclient.Client, height int64) (*Header, error)

func (*Header) EncodeHeader

func (h *Header) EncodeHeader() ([]byte, error)

func (*Header) Validate

func (h *Header) Validate(chainID string) error

type KeyValueMerkleProof

type KeyValueMerkleProof struct {
	Key       []byte
	Value     []byte
	StoreName string
	AppHash   []byte
	Proof     *merkle.Proof
	// contains filtered or unexported fields
}

func DecodeKeyValueMerkleProof

func DecodeKeyValueMerkleProof(input []byte) (*KeyValueMerkleProof, error)

input: | storeName | key length | key | value length | value | appHash | proof | | 32 bytes | 32 bytes | | 32 bytes | | 32 bytes | |

func (*KeyValueMerkleProof) SetKeyVerifier

func (kvmp *KeyValueMerkleProof) SetKeyVerifier(keyChecker KeyVerifier)

func (*KeyValueMerkleProof) SetOpsVerifier

func (kvmp *KeyValueMerkleProof) SetOpsVerifier(verifier merkle.ProofOpsVerifier)

func (*KeyValueMerkleProof) SetProofRuntime

func (kvmp *KeyValueMerkleProof) SetProofRuntime(prt *merkle.ProofRuntime)

func (*KeyValueMerkleProof) SetVerifiers

func (kvmp *KeyValueMerkleProof) SetVerifiers(verifiers []merkle.ProofOpVerifier)

func (*KeyValueMerkleProof) Validate

func (kvmp *KeyValueMerkleProof) Validate() bool

type KeyVerifier

type KeyVerifier func(string) error

type MultiStoreProof

type MultiStoreProof struct {
	StoreInfos []StoreInfo
}

MultiStoreProof defines a collection of store proofs in a multi-store

func NewMultiStoreProof

func NewMultiStoreProof(storeInfos []StoreInfo) *MultiStoreProof

func (*MultiStoreProof) ComputeRootHash

func (proof *MultiStoreProof) ComputeRootHash() []byte

ComputeRootHash returns the root hash for a given multi-store proof.

type MultiStoreProofOp

type MultiStoreProofOp struct {

	// To encode in ProofOp.Data.
	Proof *MultiStoreProof `json:"proof"`
	// contains filtered or unexported fields
}

TODO: document

func NewMultiStoreProofOp

func NewMultiStoreProofOp(key []byte, proof *MultiStoreProof) MultiStoreProofOp

func (MultiStoreProofOp) GetKey

func (op MultiStoreProofOp) GetKey() []byte

GetKey returns the key for a multi-store proof operation.

func (MultiStoreProofOp) ProofOp

func (op MultiStoreProofOp) ProofOp() merkle.ProofOp

ProofOp return a merkle proof operation from a given multi-store proof operation.

func (MultiStoreProofOp) Run

func (op MultiStoreProofOp) Run(args [][]byte) ([][]byte, error)

Run executes a multi-store proof operation for a given value. It returns the root hash if the value matches all the store's commitID's hash or an error otherwise.

func (MultiStoreProofOp) String

func (op MultiStoreProofOp) String() string

String implements the Stringer interface for a mult-store proof operation.

type StoreCore

type StoreCore struct {
	// StoreType StoreType
	CommitID CommitID
}

type StoreInfo

type StoreInfo struct {
	Name string
	Core StoreCore
}

StoreInfo contains the name and core reference for an underlying store. It is the leaf of the rootMultiStores top level simple merkle tree.

func (StoreInfo) Hash

func (si StoreInfo) Hash() []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL