You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/design/backfill-plugin.md
+33-14Lines changed: 33 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,8 @@
15
15
16
16
## Purpose
17
17
18
-
This plugin purpose is to detect missing gaps in the intended stored block sequence, then autonomously and asynchronously fetch the missing blocks from another source and store them.
18
+
This plugin purpose is to detect missing gaps (historica and recent) in the intended stored block sequence, then
19
+
autonomously and asynchronously fetch the missing blocks from another source and store them.
19
20
20
21
## Goals
21
22
@@ -34,9 +35,11 @@ This plugin purpose is to detect missing gaps in the intended stored block seque
34
35
<dt>Grpc Client</dt>
35
36
<dd>A client that connects to another Block Node to fetch missing blocks.</dd>
36
37
<dt>BackfilledBlockNotification</dt>
37
-
<dd>A new Notification Type that can be published to the Messaging Facility, it is intended to contain a whole block that was fetched from another source and is being backfilled into the system. </dd>
38
+
<dd>A new Notification Type that can be published to the Messaging Facility, it is intended to contain a whole block
39
+
that was fetched from another source and is being backfilled into the system. </dd>
38
40
<dt>NewestBlockKnownToNetwork</dt>
39
-
<dd>Notification sent by a plugin, including a "publisher" plugin, to indicate that the BlockNode is behind and must be brought up-to-date. This is often handled by a "backfill" plugin by immediately requesting the missing blocks.</dd>
41
+
<dd>Notification sent by a plugin, including a "publisher" plugin, to indicate that the BlockNode is behind and must
42
+
be brought up-to-date. This is often handled by a "backfill" plugin by immediately requesting the missing blocks.</dd>
40
43
<dt>BlockSource</dt>
41
44
<dd>A new Enum that will be added to existing notification types: `VerificationNotification` and `PersistedNotification` to indicate the original source where the block is coming from, currently it will only have two values: `Publisher`, `Backfill`</dd>
42
45
@@ -65,16 +68,22 @@ There are two flows for backfilling, Autonomous and On-Demand.
65
68
66
69
### Autonomous Backfill
67
70
68
-
The plugin will autonomously detect gaps in the block range and fetch missing blocks from a configured source.
71
+
The plugin will autonomously detect gaps in the block range and fetch missing blocks from a configured sources
72
+
(via `backfill_sources` config).
69
73
70
74
1. At start-up a loop is defined that runs every `backfill.scanInterval`
71
-
2. At every interval the plugin detects missing gaps in the intended block range against the actual stored blocks using the `HistoricalBlockFacility`.
75
+
2. At every interval the plugin detects missing gaps in the intended block range against the actual stored blocks using
76
+
the `HistoricalBlockFacility`. It will use a gRPC client to request the serverStatus from configured target block
77
+
nodes and determine the available range of recent blocks available.
72
78
3. If gaps are found, it initiates the backfill process.
73
-
4. The plugin uses a gRPC client to connect to another Block Node (configured via `backfill_sources`) to fetch the missing blocks.
74
-
5. Once the blocks are fetched, the plugin creates a `BlockNotification` of type `BackfilledBlockNotification` and sends it to the `MessagingFacility`.
75
-
6. The `VerificationPlugin` will then process the `BackfilledBlockNotification` and if the block is valid, it will create a `VerificationNotification` and send it to the `MessagingFacility` for further processing.
79
+
4. The plugin uses a gRPC client to connect to other Block Nodes to fetch the missing blocks.
80
+
5. Once the blocks are fetched, the plugin creates a `BlockNotification` of type `BackfilledBlockNotification` and sends
81
+
it to the `MessagingFacility`.
82
+
6. The `VerificationPlugin` will then process the `BackfilledBlockNotification` and if the block is valid, it will
83
+
create a `VerificationNotification` and send it to the `MessagingFacility` for further processing.
76
84
7. The PersistencePlugin will then store the block in the local storage.
77
-
8. The `BackfillPlugin` will receive the `PersistenceNotification` and update its internal state accordingly, marking the backfill process as complete for that block.
85
+
8. The `BackfillPlugin` will receive the `PersistenceNotification` and update its internal state accordingly, marking
The plugin can also be triggered on-demand to backfill missing blocks when the latest block known to the network is received.
137
+
The plugin can also be triggered on-demand to backfill missing blocks when the latest block known to the network is
138
+
received and periodically to ensure block node does not fall too far behind.
127
139
128
-
1. The plugin can also be triggered on-demand by sending a `NewestBlockKnownToNetwork` message to the `MessagingFacility`, usually this would be done by the `PublisherPlugin` or any other plugin that knows the latest block.
129
-
2. BackfillPlugin will handle the `NewestBlockKnownToNetwork` message and will check if there are any gaps in the block range available in the local storage.
140
+
1. The plugin can also be triggered on-demand by sending a `NewestBlockKnownToNetwork` message to the `MessagingFacility`,
141
+
usually this would be done by the `PublisherPlugin` or any other plugin that knows the latest block or wants to
142
+
ensure the Block Node is up-to-date.
143
+
2. BackfillPlugin will handle the `NewestBlockKnownToNetwork` message and will check if there are any gaps in the block
144
+
range available in the local storage. It will also use a gRPC client to request the serverStatus from configured
145
+
peer block nodes and determine the available range of recent blocks available.
130
146
3. If gaps are found, it will initiate the backfill process as described in the Autonomous Backfill section.
131
-
4. The process will be the same as the Autonomous Backfill, but it will be triggered by the `NewestBlockKnownToNetwork` message instead of the periodic scan.
147
+
4. The process will be the same as the Autonomous Backfill, but it will be triggered by the `NewestBlockKnownToNetwork`
0 commit comments