structLightClientBlock {bytes32 prev_block_hash;bytes32 next_block_inner_hash; BlockHeaderInnerLite inner_lite;bytes32 inner_rest_hash; OptionalBlockProducers next_bps; OptionalSignature[] approvals_after_next;bytes32hash; bytes32 next_hash;}structBlockHeaderInnerLite {uint64 height; // Height of this block since the genesis block (height 0).bytes32 epoch_id; // Epoch start hash of this block's epoch. Used for retrieving validator informationbytes32 next_epoch_id;bytes32 prev_state_root; // Root hash of the state at the previous block.bytes32 outcome_root; // Root of the outcomes of transactions and receipts.uint64 timestamp; // Timestamp at which the block was built.bytes32 next_bp_hash; // Hash of the next epoch block producers setbytes32 block_merkle_root;bytes32hash; // Additional computable element}structPublicKey {bytes32 k;}structSignature {bytes32 r;bytes32 s;}structBlockProducer { PublicKey publicKey;uint128 stake;// Flag indicating if this validator proposed to be a chunk-only producer (i.e. cannot become a block producer).bool isChunkOnly;}structOptionalBlockProducers {bool some; BlockProducer[] blockProducers;bytes32hash; // Additional computable element}structOptionalSignature {bool some; Signature signature;}
structFullOutcomeProof { ExecutionOutcomeWithIdAndProof outcome_proof; MerklePath outcome_root_proof; BlockHeaderLight block_header_lite; MerklePath block_proof;}structExecutionOutcomeWithIdAndProof { MerklePath proof;bytes32 block_hash; ExecutionOutcomeWithId outcome_with_id;}structBlockHeaderLight {bytes32 prev_block_hash;bytes32 inner_rest_hash; NearDecoder.BlockHeaderInnerLite inner_lite;bytes32hash; // Computable}structExecutionStatus {uint8 enumIndex;bool unknown;bool failed;bytes successValue; // The final action succeeded and returned some value or an empty vec.bytes32 successReceiptId; // The final action of the receipt returned a promise or the signed transaction was converted to a receipt. Contains the receipt_id of the generated receipt.}structExecutionOutcome {bytes[] logs; // Logs from this transaction or receipt.bytes32[] receipt_ids; // Receipt IDs generated by this transaction or receipt.uint64 gas_burnt; // The amount of the gas burnt by the given transaction or receipt.uint128 tokens_burnt; // The total number of the tokens burnt by the given transaction or receipt.bytes executor_id; // Hash of the transaction or receipt id that produced this outcome. ExecutionStatus status; // Execution status. Contains the result in case of successful execution.bytes32[] merkelization_hashes;}structExecutionOutcomeWithId {bytes32 id; // The transaction hash or the receipt ID. ExecutionOutcome outcome;bytes32hash;}structMerklePathItem {bytes32hash;uint8 direction; // 0 = left, 1 = right}structMerklePath { MerklePathItem[] items;}
其中包括輕客戶端證明給定交易或收據的執行結果所需的一切。
證明驗證可以分為兩步,執行結果根驗證和區塊默克爾根驗證。
執行結果根驗證
如果交易或收據的結果根包含在塊“H”中,則“outcome_proof”包含“H”的塊哈希,以及其給定分片中執行結果的默克爾證明。 H 中的結果根可以重建為
bytes32hash=_computeRoot( fullOutcomeProof.outcome_proof.outcome_with_id.hash, fullOutcomeProof.outcome_proof.proof );hash=sha256(abi.encodePacked(hash));hash=_computeRoot(hash, fullOutcomeProof.outcome_root_proof);if (hash!= fullOutcomeProof.block_header_lite.inner_lite.outcome_root ) {return (false,"outcome merkle proof is not valid"); }
if (_computeRoot( fullOutcomeProof.block_header_lite.hash, fullOutcomeProof.block_proof ) != block_merkle_root ) {return (false,"block proof is not valid"); }