Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ARCO-301): simplified reorg diagram #733

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading