Documentation
¶
Index ¶
- Constants
- func GetMutiProofHandlerFn(cliCtx client.Context) http.HandlerFunc
- func GetProofHandlerFn(cliCtx client.Context) http.HandlerFunc
- func GetRequestsCountProofHandlerFn(cliCtx client.Context) http.HandlerFunc
- type BlockHeaderMerkleParts
- type BlockHeaderMerklePartsEthereum
- type BlockRelayProof
- type CountProof
- type CountProofResponse
- type IAVLMerklePath
- type IAVLMerklePathEthereum
- type MultiProof
- type MultiProofResponse
- type MultiStoreProof
- type MultiStoreProofEthereum
- type OracleDataProof
- type RequestsCountProof
- type ResultEthereum
- type SingleProof
- type SingleProofResponse
- type TMSignature
- type TMSignatureEthereum
Constants ¶
const (
RequestIDTag = "requestID"
)
Variables ¶
This section is empty.
Functions ¶
func GetMutiProofHandlerFn ¶
func GetMutiProofHandlerFn(cliCtx client.Context) http.HandlerFunc
func GetProofHandlerFn ¶
func GetProofHandlerFn(cliCtx client.Context) http.HandlerFunc
func GetRequestsCountProofHandlerFn ¶
func GetRequestsCountProofHandlerFn(cliCtx client.Context) http.HandlerFunc
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 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 {
AuthToFeeGrantStoresMerkleHash tmbytes.HexBytes `json:"auth_to_fee_grant_stores_Merkle_hash"`
GovToIbcCoreStoresMerkleHash tmbytes.HexBytes `json:"gov_to_ibc_core_stores_merkle_hash"`
MintStoreMerkleHash tmbytes.HexBytes `json:"mint_store_merkle_hash"`
OracleIAVLStateHash tmbytes.HexBytes `json:"oracle_iavl_State_hash"`
ParamsToTransferStoresMerkleHash tmbytes.HexBytes `json:"params_to_transfer_stores_merkle_hash"`
UpgradeStoreMerkleHash tmbytes.HexBytes `json:"upgrade_store_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]_________________ [G]
/ \
_______[I12]______ _______[I13]________
/ \ / \
__[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] - auth [1] - authz [2] - bank [3] - capability [4] - crisis [5] - dist [6] - evidence [7] - feegrant [8] - gov [9] - ibccore [A] - mint [B] - oracle [C] - params [D] - slashing [E] - staking [F] - transfer [G] - 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 [B] In fact, only [A], [I4], [I11], [I12], and [G] 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 {
AuthToFeeGrantStoresMerkleHash common.Hash
GovToIbcCoreStoresMerkleHash common.Hash
MintStoreMerkleHash common.Hash
OracleIAVLStateHash common.Hash
ParamsToTransferStoresMerkleHash common.Hash
UpgradeStoreMerkleHash 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"`
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.