# Discrepancy Detection

The Challenge Process begins when a **Validating Node (VN)** detects a **discrepancy** in the way transactions are processed. These discrepancies can arise in various forms, typically involving mismatches in the sequence or content of transactions. Below are examples of specific discrepancies that VNs monitor for, along with practical cases.

<figure><img src="/files/1FTd5G5GGrrWEfS3nQei" alt=""><figcaption><p>Discrepancy Detection</p></figcaption></figure>

## **Types of Discrepancies VNs Detect**

### **Incorrect Sequencing of Orders by the Off-Chain Sequencer**

The sequencer is responsible for processing off-chain orders in the correct order. If the sequencer processes these orders out of order, VNs will detect this and raise a challenge.

**Example**:

* **Order 1**: User A submits a sell order for **1 BTC** to buy **1 ETH** at 10:01 AM.
* **Order 2**: User B submits a sell order for **1 ETH** to buy **1 BTC** at 10:02 AM.

The correct sequence should be that **Order 1** is processed before **Order 2**. If the sequencer mistakenly processes **Order 2** before **Order 1**, VNs will detect this as a discrepancy in the sequencing and trigger a challenge.

***

### **Mismatch Between On-Chain and Off-Chain Data**

VNs also compare the transactions processed by the off-chain sequencer with the corresponding records on the blockchain. If the data submitted on-chain does not match the off-chain data processed by the sequencer, this can trigger a challenge.

**Example**:

* **On-Chain Data**: The blockchain shows **Order A** as Sell **1 BTC** for **1 ETH.**
* **Off-Chain Sequencer**: The sequencer records **Order A as** Sell **0.5 BTC** for **1 ETH** (incorrect data).

In this case, the on-chain transaction does not match the off-chain transaction, and the VNs detect this mismatch. They initiate a challenge to investigate why the data does not align.

***

### **Exclusion of Valid Orders by the Sequencer**

Another key role of VNs is to ensure that all valid orders are processed and included. If the sequencer excludes a valid order from being posted on-chain, VNs will catch this and trigger a challenge.

**Example**:

* **Order 1**: User A submits a valid order to sell **1 BTC** for **1 ETH**.
* **Order 2**: User B submits a valid order to sell **1 ETH** for **1 BTC**.

Both orders are valid, but only **Order 2** is posted on-chain by the sequencer. If **Order 1** is excluded (not posted on-chain), VNs will detect that it was missing, by comparing it to the on-chain orders (Submission B) method and initiate a challenge.

***

### **Practical Scenario**

Let’s consider a scenario where VNs detect an incorrect order match or exclusion.

**Example**:

* **Order A**: Sell **1 BTC** for **1 ETH** (submitted by User A).
* **Order B**: Sell **1 ETH** for **1 BTC** (submitted by User B).
* **Order C**: Sell **1 ETH** for **1 BTC** (submitted by User C).

The orders are such that **Order A** could match with either **Order B** or **Order C**. The correct match depends on the order in which **Order B** and **Order C** arrived. If **Order B** arrived first, it should match with **Order A**. If the sequencer incorrectly matches **Order A** with **Order C** (despite **Order B** arriving earlier), VNs will detect this mis-sequencing and raise a challenge.

Additionally, if **Order A** is excluded entirely from the on-chain records, VNs will flag this as an exclusion issue and initiate a challenge to investigate why the order was not included.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yamata.io/yamata-nodes/order-validation/challenge-process/discrepancy-detection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
