proof

package
v2.5.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RequestIDTag = "requestID"
)

Variables

This section is empty.

Functions

func GetMutiProofHandlerFn

func GetMutiProofHandlerFn(cliCtx client.Context) http.HandlerFunc

func GetPrefix added in v2.3.5

func GetPrefix(t tmproto.SignedMsgType, height int64, round int64) ([]byte, error)

func GetProofHandlerFn

func GetProofHandlerFn(cliCtx client.Context) http.HandlerFunc

func GetRequestsCountProofHandlerFn

func GetRequestsCountProofHandlerFn(cliCtx client.Context) http.HandlerFunc

func GetSignaturesAndPrefix

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

GetSignaturesAndPrefix returns a list of TMSignature from Tendermint signed header.

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"`
	CommonEncodedVotePart  CommonEncodedVotePart  `json:"common_encoded_vote_part"`
	Signatures             []TMSignature          `json:"signatures"`
}

type CommonEncodedVotePart added in v2.3.5

type CommonEncodedVotePart struct {
	SignedDataPrefix tmbytes.HexBytes `json:"signed_data_prefix"`
	SignedDataSuffix tmbytes.HexBytes `json:"signed_data_suffix"`
}

type CommonEncodedVotePartEthereum added in v2.3.5

type CommonEncodedVotePartEthereum struct {
	SignedDataPrefix []byte
	SignedDataSuffix []byte
}

type CountProof

type CountProof struct {
	BlockHeight     uint64             `json:"block_height"`
	CountProof      RequestsCountProof `json:"count_proof"`
	BlockRelayProof BlockRelayProof    `json:"block_relay_proof"`
}

type CountProofResponse

type CountProofResponse struct {
	Proof         CountProof       `json:"proof"`
	EVMProofBytes tmbytes.HexBytes `json:"evm_proof_bytes"`
}

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 MultiProof

type MultiProof struct {
	BlockHeight          uint64            `json:"block_height"`
	OracleDataMultiProof []OracleDataProof `json:"oracle_data_multi_proof"`
	BlockRelayProof      BlockRelayProof   `json:"block_relay_proof"`
}

type MultiProofResponse

type MultiProofResponse struct {
	Proof         MultiProof       `json:"proof"`
	EVMProofBytes tmbytes.HexBytes `json:"evm_proof_bytes"`
}

type MultiStoreProof

type MultiStoreProof struct {
	OracleIAVLStateHash               tmbytes.HexBytes `json:"oracle_iavl_state_hash"`
	ParamsStoreMerkleHash             tmbytes.HexBytes `json:"params_store_merkle_hash"`
	SlashingToStakingStoresMerkleHash tmbytes.HexBytes `json:"slashing_to_staking_stores_merkle_hash"`
	GovToMintStoresMerkleHash         tmbytes.HexBytes `json:"gov_to_mint_stores_merkle_hash"`
	AuthToFeegrantStoresMerkleHash    tmbytes.HexBytes `json:"auth_to_fee_grant_stores_merkle_hash"`
	TransferToUpgradeStoresMerkleHash tmbytes.HexBytes `json:"transfer_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]_________________
                                          /                                          \
                      _________________[I14]_________________                     __[I15]__
                     /                                        \				 /          \
          _______[I12]______                          _______[I13]________    [G]         [H]
         /                  \                        /                    \
    __[I8]__             __[I9]__                __[I10]__              __[I11]__
   /         \          /         \            /          \            /         \
 [I0]       [I1]     [I2]        [I3]        [I4]        [I5]        [I6]       [I7]
/   \      /   \    /    \      /    \      /    \      /    \      /    \     /    \

[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [A] [B] [C] [D] [E] [F] [0] - acc (auth) [1] - authz [2] - bank [3] - capability [4] - crisis [5] - dist [6] - evidence [7] - feegrant [8] - gov [9] - ibccore [A] - icahost [B] - mint [C] - oracle [D] - params [E] - slashing [F] - staking [G] - transfer [H] - 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 [C] In fact, only [D], [I7], [I10], [I12], and [I15] 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 {
	OracleIAVLStateHash               common.Hash
	ParamsStoreMerkleHash             common.Hash
	SlashingToStakingStoresMerkleHash common.Hash
	GovToMintStoresMerkleHash         common.Hash
	AuthToFeegrantStoresMerkleHash    common.Hash
	TransferToUpgradeStoresMerkleHash common.Hash
}

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

type OracleDataProof

type OracleDataProof struct {
	Result      types.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 SingleProof

type SingleProof struct {
	BlockHeight     uint64          `json:"block_height"`
	OracleDataProof OracleDataProof `json:"oracle_data_proof"`
	BlockRelayProof BlockRelayProof `json:"block_relay_proof"`
}

type SingleProofResponse

type SingleProofResponse struct {
	Proof         SingleProof      `json:"proof"`
	EVMProofBytes tmbytes.HexBytes `json:"evm_proof_bytes"`
}

type TMSignature

type TMSignature struct {
	R                tmbytes.HexBytes `json:"r"`
	S                tmbytes.HexBytes `json:"s"`
	V                uint8            `json:"v"`
	EncodedTimestamp tmbytes.HexBytes `json:"encoded_timestamp"`
}

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).

type TMSignatureEthereum

type TMSignatureEthereum struct {
	R                common.Hash
	S                common.Hash
	V                uint8
	EncodedTimestamp []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