From 61af444ec50c242350fb3cdb32d47af155151e87 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Tue, 12 Mar 2024 14:59:50 +0800 Subject: [PATCH] Add missing top-level Block syntactic validation --- tips/TIP-0046/tip-0046.md | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/tips/TIP-0046/tip-0046.md b/tips/TIP-0046/tip-0046.md index dc224e8ae..9ff773d50 100644 --- a/tips/TIP-0046/tip-0046.md +++ b/tips/TIP-0046/tip-0046.md @@ -288,6 +288,29 @@ steps: The string format of the Block ID is the hexadecimal encoding of the `Block ID` with a `0x` prefix. +## Syntactic validation + +The Tangle can only contain syntactically valid blocks. Invalid blocks must be rejected by the node. A Block is +syntactically valid only if all of the following conditions hold: + +- The serialized size of the block does not exceed `32768`. +- The `Protocol Version` in the `Header` matches the `Version` in the used protocol parameters. +- The `Network ID` in the `Header` matches the `Network ID` from the protocol parameters, which is computed as described + in [TIP-45 (Network ID)](../TIP-0045/tip-0045.md#network-id). +- Let `Commitment Slot` be the slot index to which the block commits, which can be extracted from the header's + `Slot Commitment ID`. +- Let `Block Slot` be the slot index corresponding to the block header's `Issuing Time`. +- If `Commitment Slot > Genesis Slot`, then it must hold that `Commitment Slot + Min Committable Age <= Block Slot`. + - Note: This ensures that the commitment is not too recent, except when committing to genesis. +- It must hold that `Commitment Slot + Max Committable Age >= Block Slot`. + - Note: This ensures that the commitment is not too old. +- The contained `Body` is syntactically valid. +- There must be no trailing bytes after all block fields have been parsed. + +## Semantic Validation + +A _Block_ is semantically valid if the `Body`'s semantic validation passes. + ## Basic Block ### Schema @@ -442,11 +465,9 @@ A _Basic Block_ is the name for a _Block_ with its body set to a _Basic Block Bo ### Syntactic validation -The Tangle can only contain syntactically valid blocks. Invalid blocks must be rejected by the node. A _Basic Block_ is -syntactically valid if all of the following conditions hold: +A _Basic Block Body_ is only syntactically valid if all of the following conditions hold: - The block adheres to its schema with the rules defined in [TIP-21](../TIP-0021/tip-0021.md). -- The total length of the serialized block must not exceed `32768`. - It must hold true that 1 ≤ `Strong Parents Count` ≤ 8. - It must hold true that 0 ≤ `Weak Parents Count` ≤ 8. - It must hold true that 0 ≤ `Shallow Like Parents Count` ≤ 8. @@ -455,7 +476,6 @@ syntactically valid if all of the following conditions hold: - must not have duplicates in each list. - `Weak Parents` must be disjoint from the rest of the parents: No weak parent should be in either `Strong Parents` or `Shallow Like Parents`. -- There must be no trailing bytes after all block fields have been parsed. - If a _Basic Block_ contains a transaction payload, the block is valid only if all of the following conditions hold: - The Slot Index `Block Slot` corresponding to the `Issuing Time` of a block must be greater or equal than the `Creation Slot` of the contained transaction. @@ -465,7 +485,7 @@ syntactically valid if all of the following conditions hold: ### Semantic Validation -A _Basic Block_ is semantically valid if the following condition holds: +A _Basic Block Body_ is semantically valid if the following condition holds: - The `Signature` must pass semantic validation. @@ -638,11 +658,9 @@ A _Validation Block_ is the name for a _Block_ with its body set to a _Validatio ### Syntactic Validation -The Tangle can only contain syntactically valid blocks. Invalid blocks must be rejected by the node. A _Validation -Block_ is syntactically valid if all of the following conditions hold: +A _Validation Block Body_ is only syntactically valid if all of the following conditions hold: - The block adheres to its schema with the rules defined in [TIP-21](../TIP-0021/tip-0021.md). -- The total length of the serialized block must not exceed `32768`. - It must hold true that 1 ≤ `Strong Parents Count` ≤ 50. - It must hold true that 0 ≤ `Weak Parents Count` ≤ 50. - It must hold true that 0 ≤ `Shallow Like Parents Count` ≤ 50. @@ -652,11 +670,10 @@ Block_ is syntactically valid if all of the following conditions hold: - `Weak Parents` must be disjoint from the rest of the parents: No weak parent should be in either `Strong Parents` or `Shallow Like Parents`. - `Highest Supported Version` must be greater or equal to `Protocol Version`. -- There must be no trailing bytes after all block fields have been parsed. ### Semantic Validation -A _Validation Block_ is semantically valid if the following condition holds: +A _Validation Block Body_ is semantically valid if the following condition holds: - The `Signature` must pass semantic validation.