flowchart LR
subgraph Filecoin Snapshot Service
subgraph Snapshot Generation
A[Trigger Cron Job] --> B[Download Latest Filecoin Snapshot with aria2c]
B --> C[Import Snapshot into Forest Node]
C --> D[Start Forest Node & Install Utilities curl, aria2]
D --> E[Sync Forest Node with Network Head]
E --> F[Export Snapshot Including Last 2000 Blocks]
F --> G[Run Initial Validation with forest-tool]
G --> H[Stop Forest Node & Store Snapshot]
H --> I[Destroy Forest DB to Save Space]
end
subgraph Snapshot Validation
I --> J[Import Snapshot into Lotus Node]
J --> K[Start Lotus Node & Install Utilities curl, jq]
K --> L[Sync Lotus Node with Network Head]
L --> M[Verify Lotus Node Sync Status]
M --> N[Retrieve Head Epoch from Lotus Node using ChainHead RPC Method]
N --> O[Calculate Adjusted Epoch: Head Epoch - 1950]
O --> P[GET Block Hash from a remote Full Node using Adjusted Epoch with ChainGetTipSetByHeight]
P --> Q[Verify Block Hash in Local Node using ChainGetBlock RPC Meethod]
end
Q --> T[Upload Validated Snapshot to Regular S3 Bucket]
%% Failure Handling
Q -- Validation Failure --> V[Move Snapshot to Forbidden Bucket]
G -- Generation/Validation Failure --> V
%% Notifications
V --> W1[Send Alert to Team for Investigation]
W1 --> W2[On-Call Team Investigates and Escalates]
end
This document outlines the step-by-step process for generating and validating a Filecoin snapshot. The diagram above provides a quick overview of the snapshot service architecture.
The snapshot process is initiated by a cron job that triggers the service container to execute hourly. Below is a detailed step-by-step outline of how snapshots are generated and validated:
forest-tool snapshot validate forest_snapshot_*.forest.car.zst.Begin Main Validation
Filecoin.ChainHead RPC method. - Example: If the current head epoch is 4,000, the resulting epoch after subtraction will be 2,050 (4,000 - 1,950).Filecoin.ChainGetTipSetByHeight RPC method. - This retrieves the block hash from 1,950 epochs prior.Filecoin.ChainGetBlock method. - Ensure the block is available and matches the expected epoch.If any step in this process fails, an alert is sent to the team. The snapshot is then moved to a forbidden bucket for further investigation by the on-call team. If necessary, the issue is escalated for resolution.