proof

package
v0.7.32 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIDTag = "requestID"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockHeaderMerkleParts

type BlockHeaderMerkleParts struct {
	VersionAndChainIdHash             tmbytes.HexBytes `json:"version_and_chain_id_hash"`
	Height                            uint64           `json:"height"`
	TimeSecond                        uint64           `json:"time_second"`
	TimeNanoSecond                    uint32           `json:"time_nano_second"`
	LastBlockIdAndOther               tmbytes.HexBytes `json:"last_block_id_and_other"`
	NextValidatorHashAndConsensusHash tmbytes.HexBytes `json:"next_validator_hash_and_consensus_hash"`
	LastResultsHash                   tmbytes.HexBytes `json:"last_results_hash"`
	EvidenceAndProposerHash           tmbytes.HexBytes `json:"evidence_and_proposer_hash"`
}

BlockHeaderMerkleParts stores a group of hashes using for computing Tendermint's block header hash from app hash, and height.

In Tendermint, a block header hash is the Merkle hash of a binary tree with 14 leaf nodes. Each node encodes a data piece of the blockchain. The notable data leaves are: [A] app_hash, [2] height. All data pieces are combined into one 32-byte hash to be signed by block validators. The structure of the Merkle tree is shown below.

                                 [BlockHeader]
                              /                \
                 [3A]                                    [3B]
               /      \                                /      \
       [2A]                [2B]                [2C]                [2D]
      /    \              /    \              /    \              /    \
  [1A]      [1B]      [1C]      [1D]      [1E]      [1F]        [C]    [D]
  /  \      /  \      /  \      /  \      /  \      /  \
[0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [A]  [B]

[0] - version               [1] - chain_id            [2] - height        [3] - time
[4] - last_block_id         [5] - last_commit_hash    [6] - data_hash     [7] - validators_hash
[8] - next_validators_hash  [9] - consensus_hash      [A] - app_hash      [B] - last_results_hash
[C] - evidence_hash         [D] - proposer_address

Notice that NOT all leaves of the Merkle tree are needed in order to compute the Merkle root hash, since we only want to validate the correctness of [2], [3], and [A]. In fact, only [1A], [2B], [1E], [B], and [2D] are needed in order to compute [BlockHeader].

func GetBlockHeaderMerkleParts

func GetBlockHeaderMerkleParts(block *types.Header) BlockHeaderMerkleParts

GetBlockHeaderMerkleParts converts Tendermint block header struct into BlockHeaderMerkleParts for gas-optimized proof verification.

type BlockHeaderMerklePartsEthereum

type BlockHeaderMerklePartsEthereum struct {
	VersionAndChainIdHash             common.Hash
	Height                            uint64
	TimeSecond                        uint64
	TimeNanoSecond                    uint32
	LastBlockIdAndOther               common.Hash
	NextValidatorHashAndConsensusHash common.Hash
	LastResultsHash                   common.Hash
	EvidenceAndProposerHash           common.Hash
}

BlockHeaderMerklePartsEthereum is an Ethereum version of BlockHeaderMerkleParts for solidity ABI-encoding.

type BlockRelayProof

type BlockRelayProof struct {
	MultiStoreProof        MultiStoreProof        `json:"multi_store_proof"`
	BlockHeaderMerkleParts BlockHeaderMerkleParts `json:"block_header_merkle_parts"`
	Signatures             []TMSignature          `json:"signatures"`
}

type IAVLMerklePath

type IAVLMerklePath struct {
	IsDataOnRight  bool             `json:"is_data_on_right"`
	SubtreeHeight  uint8            `json:"subtree_height"`
	SubtreeSize    uint64           `json:"subtree_size"`
	SubtreeVersion uint64           `json:"subtree_version"`
	SiblingHash    tmbytes.HexBytes `json:"sibling_hash"`
}

MerklePath represents a Merkle step to a leaf data node in an iAVL tree.

func GetMerklePaths

func GetMerklePaths(iavlEp *ics23.ExistenceProof) []IAVLMerklePath

GetMerklePaths returns the list of MerklePath elements from the given iAVL proof.

type IAVLMerklePathEthereum

type IAVLMerklePathEthereum struct {
	IsDataOnRight  bool
	SubtreeHeight  uint8
	SubtreeSize    *big.Int
	SubtreeVersion *big.Int
	SiblingHash    common.Hash
}

IAVLMerklePathEthereum is an Ethereum version of IAVLMerklePath for solidity ABI-encoding.

type MultiStoreProof

type MultiStoreProof struct {
	AuthToIbcTransferStoresMerkleHash tmbytes.HexBytes `json:"auth_to_ibc_transfer_stores_Merkle_hash"`
	MintStoreMerkleHash               tmbytes.HexBytes `json:"mint_store_merkle_hash"`
	OracleIAVLStateHash               tmbytes.HexBytes `json:"oracle_iavl_State_hash"`
	ParamsToSlashStoresMerkleHash     tmbytes.HexBytes `json:"params_to_slash_stores_merkle_hash"`
	StakingToUpgradeStoresMerkleHash  tmbytes.HexBytes `json:"staking_to_upgrade_stores_merkle_hash"`
}

MultiStoreProof stores a compact of other Cosmos-SDK modules' storage hash in multistore to compute (in combination with oracle store hash) Tendermint's application state hash at a given block.

                      ________________[AppHash]_______________
                     /                                        \
          _______[I10]______                          _______[I11]________
         /                  \                        /                    \
    __[I6]__             __[I7]__                __[I8]__              __[I9]__
   /         \          /         \            /          \           /         \
 [I0]       [I1]     [I2]        [I3]        [I4]        [I5]       [C]         [D]
/   \      /   \    /    \      /    \      /    \      /    \

[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [A] [B] [0] - auth [1] - bank [2] - capability [3] - dist [4] - evidence [5] - gov [6] - ibchost [7] - ibctransfer [8] - mint [9] - oracle [A] - params [B] - slashing [C] - staking [D] - upgrade Notice that NOT all leaves of the Merkle tree are needed in order to compute the Merkle root hash, since we only want to validate the correctness of [9] In fact, only [8], [I5], [I9], and [I10] are needed in order to compute [AppHash].

func GetMultiStoreProof

func GetMultiStoreProof(multiStoreEp *ics23.ExistenceProof) MultiStoreProof

GetMultiStoreProof compacts Multi store proof from Tendermint to MultiStoreProof version.

type MultiStoreProofEthereum

type MultiStoreProofEthereum struct {
	AuthToIbcTransferStoresMerkleHash common.Hash
	MintStoreMerkleHash               common.Hash
	OracleIAVLStateHash               common.Hash
	ParamsToSlashStoresMerkleHash     common.Hash
	StakingToUpgradeStoresMerkleHash  common.Hash
}

MultiStoreProofEthereum is an Ethereum version of MultiStoreProof for solidity ABI-encoding.

type OracleDataProof

type OracleDataProof struct {
	Result      oracletypes.Result `json:"result"`
	Version     uint64             `json:"version"`
	MerklePaths []IAVLMerklePath   `json:"merkle_paths"`
}

type RequestsCountProof

type RequestsCountProof struct {
	Count       uint64           `json:"count"`
	Version     uint64           `json:"version"`
	MerklePaths []IAVLMerklePath `json:"merkle_paths"`
}

type ResultEthereum

type ResultEthereum struct {
	ClientID       string
	OracleScriptID uint64
	Params         []byte
	AskCount       uint64
	MinCount       uint64
	RequestID      uint64
	AnsCount       uint64
	RequestTime    uint64
	ResolveTime    uint64
	ResolveStatus  uint8
	Result         []byte
}

ResultEthereum is an Ethereum version of Result for solidity ABI-encoding.

type TMSignature

type TMSignature struct {
	R                tmbytes.HexBytes `json:"r"`
	S                tmbytes.HexBytes `json:"s"`
	V                uint8            `json:"v"`
	SignedDataPrefix tmbytes.HexBytes `json:"signed_data_prefix"`
	SignedDataSuffix tmbytes.HexBytes `json:"signed_data_suffix"`
}

TMSignature contains all details of validator signature for performing signer recovery for ECDSA secp256k1 signature. Note that this struct is written specifically for signature signed on Tendermint's precommit data, which includes the block hash and some additional information prepended and appended to the block hash. The prepended part (prefix) and the appended part (suffix) are different for each signer (including signature size, machine clock, validator index, etc).

func GetSignaturesAndPrefix

func GetSignaturesAndPrefix(info *types.SignedHeader) ([]TMSignature, error)

GetSignaturesAndPrefix returns a list of TMSignature from Tendermint signed header.

type TMSignatureEthereum

type TMSignatureEthereum struct {
	R                common.Hash
	S                common.Hash
	V                uint8
	SignedDataPrefix []byte
	SignedDataSuffix []byte
}

TMSignatureEthereum is an Ethereum version of TMSignature for solidity ABI-encoding.

Jump to

Keyboard shortcuts

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