Skip to content

Commit

Permalink
feat(ARCO-301): simplified reorg diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba-4chain committed Dec 23, 2024
1 parent 1477947 commit 790d918
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,36 @@ A callback with status `MINED_IN_STALE_BLOCK` will be sent for that transaction
| In longest chain, not in stale chain | `MINED_IN_STALE_BLOCK` | Transaction will be rebroadcasted and cycle through statuses again until is found in the longest chain |
| In stale chain only (no reorg) | `MINED_IN_STALE_BLOCK` | Transaction will be rebroadcasted and cycle through statuses again until is found in the longest chain |

#### Simplified flow diagram
```mermaid
flowchart TD
A[Incoming new block received from peers] --> B{Block already in DB?}
B -->|Yes| S((STOP))
B -->|NO| C[Insert block to DB]
C --> D["`Assign status to the new block based on a previous block. Status is one of:
- LONGEST
- STALE (fork)
- ORPHANED`"]
D --> E{Switch block.Status}
E --> F[ORPHANED]
F --> I[Get orphaned blocks down to non-orphan ancestor]
I --> J["Accept orphaned blocks into the chain of the non-orphan ancestor (if non-orphan ancestor exists)"]
J --> K["Perform the steps of the LONGEST or STALE case, depending on which chain was the orphan block accepted to (if any)"]
K --> Q[Publish MINED transactions to metamorph]
E --> H[STALE]
H --> L["`Compare the **chainworks** of the stale chain and the longest chain`"]
L --> M{Stale chain has greater chainwork?}
M -->|YES| N["`Perform **reorg**`"]
N --> O[Mark block from the longest chain as STALE]
O --> P[Mark blocks from the stale chain as LONGEST]
P --> Q
E --> G[LONGEST]
G --> Q
```


## Cumulative fees validation

Expand Down

0 comments on commit 790d918

Please sign in to comment.