struct LightClientBlock {
bytes32 prev_block_hash;
bytes32 next_block_inner_hash;
BlockHeaderInnerLite inner_lite;
bytes32 inner_rest_hash;
OptionalBlockProducers next_bps;
OptionalSignature[] approvals_after_next;
bytes32 hash;
bytes32 next_hash;
}
struct BlockHeaderInnerLite {
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 information
bytes32 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 set
bytes32 block_merkle_root;
bytes32 hash; // Additional computable element
}
struct PublicKey {
bytes32 k;
}
struct Signature {
bytes32 r;
bytes32 s;
}
struct BlockProducer {
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;
}
struct OptionalBlockProducers {
bool some;
BlockProducer[] blockProducers;
bytes32 hash; // Additional computable element
}
struct OptionalSignature {
bool some;
Signature signature;
}
struct FullOutcomeProof {
ExecutionOutcomeWithIdAndProof outcome_proof;
MerklePath outcome_root_proof;
BlockHeaderLight block_header_lite;
MerklePath block_proof;
}
struct ExecutionOutcomeWithIdAndProof {
MerklePath proof;
bytes32 block_hash;
ExecutionOutcomeWithId outcome_with_id;
}
struct BlockHeaderLight {
bytes32 prev_block_hash;
bytes32 inner_rest_hash;
NearDecoder.BlockHeaderInnerLite inner_lite;
bytes32 hash; // Computable
}
struct ExecutionStatus {
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.
}
struct ExecutionOutcome {
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;
}
struct ExecutionOutcomeWithId {
bytes32 id; // The transaction hash or the receipt ID.
ExecutionOutcome outcome;
bytes32 hash;
}
struct MerklePathItem {
bytes32 hash;
uint8 direction; // 0 = left, 1 = right
}
struct MerklePath {
MerklePathItem[] items;
}
其中包括輕客戶端證明給定交易或收據的執行結果所需的一切。
證明驗證可以分為兩步,執行結果根驗證和區塊默克爾根驗證。
執行結果根驗證
如果交易或收據的結果根包含在塊“H”中,則“outcome_proof”包含“H”的塊哈希,以及其給定分片中執行結果的默克爾證明。 H 中的結果根可以重建為
bytes32 hash = _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");
}