Skip to content

Commit

Permalink
Add missing top-level Block syntactic validation
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Mar 12, 2024
1 parent 4875e8b commit 61af444
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions tips/TIP-0046/tip-0046.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.

Expand Down Expand Up @@ -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.
Expand All @@ -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.

Expand Down

0 comments on commit 61af444

Please sign in to comment.