proof

package
v1.2.7-0...-4cd777e Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: GPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIDTag = "requestID"
)

Variables

This section is empty.

Functions

func GetMutiProofHandlerFn

func GetMutiProofHandlerFn(cliCtx context.CLIContext, route string) http.HandlerFunc

func GetProofHandlerFn

func GetProofHandlerFn(cliCtx context.CLIContext, route string) http.HandlerFunc

Types

type BlockHeaderMerkleParts

type BlockHeaderMerkleParts struct {
	VersionAndChainIdHash             tmbytes.HexBytes `json:"versionAndChainIdHash"`
	Height                            uint64           `json:"height"`
	TimeSecond                        uint64           `json:"timeSecond"`
	TimeNanoSecond                    uint32           `json:"timeNanoSecond"`
	LastBlockIDAndOther               tmbytes.HexBytes `json:"lastBlockIDAndOther"`
	NextValidatorHashAndConsensusHash tmbytes.HexBytes `json:"nextValidatorHashAndConsensusHash"`
	LastResultsHash                   tmbytes.HexBytes `json:"lastResultsHash"`
	EvidenceAndProposerHash           tmbytes.HexBytes `json:"evidenceAndProposerHash"`
}

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(codec *codec.Codec, 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:"multiStoreProof"`
	BlockHeaderMerkleParts BlockHeaderMerkleParts `json:"blockHeaderMerkleParts"`
	Signatures             []TMSignature          `json:"signatures"`
}

type IAVLMerklePath

type IAVLMerklePath struct {
	IsDataOnRight  bool             `json:"isDataOnRight"`
	SubtreeHeight  uint8            `json:"subtreeHeight"`
	SubtreeSize    uint64           `json:"subtreeSize"`
	SubtreeVersion uint64           `json:"subtreeVersion"`
	SiblingHash    tmbytes.HexBytes `json:"siblingHash"`
}

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

func GetIAVLMerklePaths

func GetIAVLMerklePaths(proof *iavl.ValueOp) []IAVLMerklePath

GetIAVLMerklePaths returns the list of IAVLMerklePath 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 JsonMultiProof

type JsonMultiProof struct {
	BlockHeight          uint64            `json:"blockHeight"`
	OracleDataMultiProof []OracleDataProof `json:"oracleDataMultiProof"`
	BlockRelayProof      BlockRelayProof   `json:"blockRelayProof"`
}

type JsonProof

type JsonProof struct {
	BlockHeight     uint64          `json:"blockHeight"`
	OracleDataProof OracleDataProof `json:"oracleDataProof"`
	BlockRelayProof BlockRelayProof `json:"blockRelayProof"`
}

type MultiProof

type MultiProof struct {
	JsonProof     JsonMultiProof   `json:"jsonProof"`
	EVMProofBytes tmbytes.HexBytes `json:"evmProofBytes"`
}

type MultiStoreProof

type MultiStoreProof struct {
	AccToGovStoresMerkleHash          tmbytes.HexBytes `json:"accToGovStoresMerkleHash"`
	MainAndMintStoresMerkleHash       tmbytes.HexBytes `json:"mainAndMintStoresMerkleHash"`
	OracleIAVLStateHash               tmbytes.HexBytes `json:"oracleIAVLStateHash"`
	ParamsStoresMerkleHash            tmbytes.HexBytes `json:"paramsStoresMerkleHash"`
	SlashingToUpgradeStoresMerkleHash tmbytes.HexBytes `json:"slashingToUpgradeStoresMerkleHash"`
}

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]_______________
                     /                                        \
          _______[I9]______                          ________[I10]________
         /                  \                       /                     \
    __[I5]__             __[I6]__              __[I7]__               __[I8]__
   /         \          /         \           /         \            /         \
 [I1]       [I2]     [I3]        [I4]       [8]        [9]          [A]        [B]
/   \      /   \    /    \      /    \

[0] [1] [2] [3] [4] [5] [6] [7] [0] - acc [1] - distr [2] - evidence [3] - gov [4] - main [5] - mint [6] - oracle [7] - params [8] - slashing [9] - staking [A] - supply [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 [6] In fact, only [7], [I3], [I5], and [I10] are needed in order to compute [AppHash].

func GetMultiStoreProof

func GetMultiStoreProof(proof rootmulti.MultiStoreProofOp) MultiStoreProof

GetMultiStoreProof compacts Multi store proof from Tendermint to MultiStoreProof version.

type MultiStoreProofEthereum

type MultiStoreProofEthereum struct {
	AccToGovStoresMerkleHash          common.Hash
	MainAndMintStoresMerkleHash       common.Hash
	OracleIAVLStateHash               common.Hash
	ParamsStoresMerkleHash            common.Hash
	SlashingToUpgradeStoresMerkleHash common.Hash
}

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

type OracleDataProof

type OracleDataProof struct {
	RequestPacket  types.OracleRequestPacketData  `json:"requestPacket"`
	ResponsePacket types.OracleResponsePacketData `json:"responsePacket"`
	Version        uint64                         `json:"version"`
	MerklePaths    []IAVLMerklePath               `json:"merklePaths"`
}

type Proof

type Proof struct {
	JsonProof     JsonProof        `json:"jsonProof"`
	EVMProofBytes tmbytes.HexBytes `json:"evmProofBytes"`
}

type RequestPacketEthereum

type RequestPacketEthereum struct {
	ClientId       string
	OracleScriptId uint64
	Params         []byte
	AskCount       uint64
	MinCount       uint64
}

RequestPacketEthereum is an Ethereum version of OracleRequestPacketData for solidity ABI-encoding.

type ResponsePacketEthereum

type ResponsePacketEthereum struct {
	ClientId      string
	RequestId     uint64
	AnsCount      uint64
	RequestTime   uint64
	ResolveTime   uint64
	ResolveStatus uint8
	Result        []byte
}

ResponsePacketEthereum is an Ethereum version of OracleResponsePacketData 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:"signedDataPrefix"`
	SignedDataSuffix tmbytes.HexBytes `json:"signedDataSuffix"`
}

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