Skip to content

Commit 3f47724

Browse files
authored
Merge pull request #396 from input-output-hk/lowhung/395-bootstrap-orchestration
feat: snapshot downloader for bootstrapper
2 parents 074bd92 + c96e201 commit 3f47724

File tree

22 files changed

+1682
-431
lines changed

22 files changed

+1682
-431
lines changed

Cargo.lock

Lines changed: 69 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,23 @@ to communicate between micro-services.
2626

2727
```mermaid
2828
graph TB
29-
3029
subgraph Process A
3130
Module1(Module 1)
3231
Module2(Module 2)
3332
Caryatid1(Caryatid Framework)
34-
3533
Module1 <--> Caryatid1
3634
Module2 <--> Caryatid1
3735
end
3836
3937
subgraph Process B
4038
Module3(Module 3)
41-
4239
Caryatid2(Caryatid Framework)
43-
4440
Module3 <--> Caryatid2
4541
4642
end
4743
4844
RabbitMQ([RabbitMQ Message Bus])
49-
style RabbitMQ fill:#eff
50-
45+
style RabbitMQ fill: #eff
5146
Caryatid1 <--> RabbitMQ
5247
Caryatid2 <--> RabbitMQ
5348
```
@@ -61,6 +56,9 @@ graph TB
6156
Fetches a chain snapshot from Mithril and replays all the blocks in it
6257
- [Genesis Bootstrapper](modules/genesis_bootstrapper) - reads the Genesis
6358
file for a chain and generates initial UTXOs
59+
- [Snapshot Bootstrapper](modules/snapshot_bootstrapper) - downloads ledger state snapshot files for configured epochs,
60+
streams and parses the CBOR data (UTXOs, pools, accounts, DReps, proposals), and publishes completion messages to
61+
signal snapshot readiness to other modules.
6462
- [Block Unpacker](modules/block_unpacker) - unpacks received blocks
6563
into individual transactions
6664
- [Tx Unpacker](modules/tx_unpacker) - parses transactions and generates UTXO
@@ -69,7 +67,8 @@ graph TB
6967
- [SPO State](modules/spo_state) - matches SPO registrations and retirements
7068
- [DRep State](modules/drep_state) - tracks DRep registrations
7169
- [Governance State](modules/governance_state) - tracks Governance Actions and voting
72-
- [Stake Delta Filter](modules/stake_delta_filter) - filters out stake address changes and handles stake pointer references
70+
- [Stake Delta Filter](modules/stake_delta_filter) - filters out stake address changes and handles stake pointer
71+
references
7372
- [Epochs State](modules/epochs_state) - track fees blocks minted and epochs history
7473
- [Accounts State](modules/accounts_state) - stake and reward accounts tracker
7574
- [Assets State](modules/assets_state) - tracks native asset supply, metadata, transactions, and addresses

common/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ thiserror = "2.0.17"
4141
sha2 = "0.10.8"
4242

4343
[dev-dependencies]
44-
caryatid_process = { workspace = true }
44+
tempfile = "3.23"
4545
config = { workspace = true }
46-
tempfile = "3"
46+
caryatid_process = { workspace = true }
47+
4748

4849
[lib]
4950
crate-type = ["rlib"]

common/src/snapshot/NOTES.md

Lines changed: 0 additions & 92 deletions
This file was deleted.

common/src/snapshot/streaming_snapshot.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ impl StreamingSnapshotParser {
15681568
if utxo_count.is_multiple_of(1000000) {
15691569
let buffer_usage = buffer.len();
15701570
info!(
1571-
" Streamed {} UTXOs, buffer: {} MB, max entry: {} bytes",
1571+
"Streamed {} UTXOs, buffer: {} MB, max entry: {} bytes",
15721572
utxo_count,
15731573
buffer_usage / 1024 / 1024,
15741574
max_single_entry_size
@@ -1625,20 +1625,17 @@ impl StreamingSnapshotParser {
16251625
}
16261626
}
16271627

1628-
info!(" 🎯 STREAMING RESULTS:");
1629-
info!(" UTXOs processed: {}", utxo_count);
1628+
info!("Streaming results:");
1629+
info!(" UTXOs processed: {}", utxo_count);
16301630
info!(
1631-
" Total data streamed: {:.2} MB",
1631+
" Total data streamed: {:.2} MB",
16321632
total_bytes_processed as f64 / 1024.0 / 1024.0
16331633
);
16341634
info!(
1635-
" Peak buffer usage: {} MB (vs 2.1GB before!)",
1635+
" Peak buffer usage: {} MB",
16361636
PARSE_BUFFER_SIZE / 1024 / 1024
16371637
);
1638-
info!(
1639-
" • Largest single entry: {} bytes",
1640-
max_single_entry_size
1641-
);
1638+
info!(" Largest single entry: {} bytes", max_single_entry_size);
16421639

16431640
Ok(utxo_count)
16441641
}

modules/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ compose the Acropolis Architecture
1010
Fetches a chain snapshot from Mithril and replays all the blocks in it
1111
* [Genesis Bootstrapper](genesis_bootstrapper) - reads the Genesis
1212
file for a chain and generates initial UTXOs
13+
* [Snapshot Bootstrapper](snapshot_bootstrapper) - downloads ledger state snapshot files for configured epochs,
14+
streams and parses the CBOR data (UTXOs, pools, accounts, DReps, proposals), and publishes completion messages to
15+
signal snapshot readiness to other modules.
1316
* [Block Unpacker](block_unpacker) - unpacks received blocks
1417
into individual transactions
1518
* [Tx Unpacker](tx_unpacker) - parses transactions and generates UTXO
@@ -19,7 +22,6 @@ compose the Acropolis Architecture
1922
* [DRep State](drep_state) - tracks DRep registrations
2023
* [Governance State](governance_state) - tracks Governance Actions and voting
2124
* [Stake Delta Filter](stake_delta_filter) - filters out stake address changes and handles stake pointer references
22-
* [Epoch Activity Counter](epoch_activity_couinter) - counts fees and block production for rewards
2325
* [Accounts State](accounts_state) - stake and reward accounts tracker
2426

2527
## How to add a new module
@@ -88,7 +90,7 @@ to call `MyModule::register()` in the process `main()`:
8890
use acropolis_module_my_module::MyModule;
8991

9092
// in main()...
91-
MyModule::register(&mut process);
93+
MyModule::register( & mut process);
9294
```
9395

9496
You also need to mention the module in (e.g.) `omnibus.toml` to get it created, even if all

modules/mithril_snapshot_fetcher/src/mithril_snapshot_fetcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl MithrilSnapshotFetcher {
379379
// Send completion message
380380
if let Some(last_block_info) = last_block_info {
381381
info!(
382-
"Finished shapshot at block {}, epoch {}",
382+
"Finished snapshot at block {}, epoch {}",
383383
last_block_info.number, last_block_info.epoch
384384
);
385385
let message_enum =

modules/snapshot_bootstrapper/Cargo.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ anyhow = { workspace = true }
1717
config = { workspace = true }
1818
tokio = { workspace = true }
1919
tracing = { workspace = true }
20+
serde = { workspace = true, features = ["rc"] }
21+
serde_json = { workspace = true }
22+
thiserror = "2.0.17"
23+
async-compression = { version = "0.4.32", features = ["tokio", "gzip"] }
24+
reqwest = { version = "0.12", features = ["stream"] }
25+
futures-util = "0.3.31"
26+
tokio-util = "0.7.17"
27+
hex = "0.4.3"
28+
29+
[dev-dependencies]
30+
wiremock = "0.6.5"
31+
flate2 = "1.1.5"
32+
tempfile = "3.23.0"
33+
2034

2135
[lib]
22-
path = "src/snapshot_bootstrapper.rs"
36+
path = "src/bootstrapper.rs"

0 commit comments

Comments
 (0)