Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6b5f3a5
Add snapshot bootstrapping support to accounts state
lowhung Dec 5, 2025
b694369
feat: add accounts state bootstrap from snapshot
lowhung Dec 5, 2025
5109057
Simplify comments in bootstrap method for loading state data
lowhung Dec 5, 2025
9c27d8f
Refactor DRep handling in snapshot parsing and state
lowhung Dec 5, 2025
6d417ad
lift work from Alex PR for SPO state and bootstrap accounts state.
lowhung Dec 5, 2025
2682195
Remove PoolInfo import and fix DrepKeyHash import
lowhung Dec 6, 2025
7dbcc9b
Delete workspace.xml
lowhung Dec 6, 2025
d3b6468
Merge branch 'main' into lowhung/388-bootstrap-accounts-module
lowhung Dec 6, 2025
667879c
Update streaming parser example to use new ledger state types
lowhung Dec 6, 2025
499ed94
feat: bootstrap accounts_state from snapshot with mark/set/go snapshots
lowhung Dec 9, 2025
0ba9b6e
chore: cargo fmt
lowhung Dec 9, 2025
003ae63
feat: remove pot balances, rename StakeCallbacl -> AccountsCallback
lowhung Dec 9, 2025
83de63e
feat: fix race-condition on publish
lowhung Dec 9, 2025
cb375b7
fix: add warn back
lowhung Dec 9, 2025
3ef28fa
chore: remove dependencies not used anymore
lowhung Dec 10, 2025
5a16940
Merge
lowhung Dec 10, 2025
cf18571
chore: unstage .idea
lowhung Dec 10, 2025
b933bd8
chore: fix import
lowhung Dec 10, 2025
5f460a2
block publish
lowhung Dec 10, 2025
bca04ab
Fix variant ordering
lowhung Dec 10, 2025
6fd31a4
chore: fix order
lowhung Dec 10, 2025
82e72ea
Clean up snapshot parsing logs and remove unnecessary debug statements
lowhung Dec 10, 2025
da4308f
Refactor Mark, Set, Go snapshot parsing and processing
lowhung Dec 10, 2025
e9dccca
Merge
lowhung Dec 10, 2025
f20a663
Remove .idea files
lowhung Dec 10, 2025
052fa45
Update snapshot-related types and data processing
lowhung Dec 10, 2025
dea0836
Add imbl library to dependencies and refactor Snapshot types
lowhung Dec 10, 2025
498b3f5
Add imports and enable previously commented warning logs
lowhung Dec 10, 2025
0ca236f
chore: more code clean-up
lowhung Dec 10, 2025
be22c71
Refactor snapshot and state bootstrap methods to take ownership
lowhung Dec 10, 2025
8c47ab1
Simplify logging and message handling in snapshot parsing
lowhung Dec 10, 2025
7f769cc
Rename Snapshot to EpochSnapshot and update references, add comment to
lowhung Dec 10, 2025
aaf4beb
Move SnapshotsContainer and EpochSnapshot to new epoch_snapshot module
lowhung Dec 10, 2025
d2532b6
Add EpochSnapshot and related structures to common
lowhung Dec 10, 2025
e7a4e7d
Remove spdd generation
lowhung Dec 11, 2025
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ bs58 = "0.5"
chrono = { workspace = true }
crc = "3"
hex = { workspace = true }
imbl = "5.0.0"
log = "0.4"
memmap2 = "0.9"
num-rational = { version = "0.4.2", features = ["serde"] }
Expand Down
140 changes: 38 additions & 102 deletions common/examples/test_streaming_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
//
// Usage: cargo run --example test_streaming_parser --release -- <snapshot_path>

use acropolis_common::epoch_snapshot::SnapshotsContainer;
use acropolis_common::ledger_state::SPOState;
use acropolis_common::snapshot::protocol_parameters::ProtocolParameters;
use acropolis_common::snapshot::streaming_snapshot::GovernanceProtocolParametersCallback;
use acropolis_common::snapshot::EpochCallback;
use acropolis_common::snapshot::{
AccountState, DRepCallback, DRepInfo, GovernanceProposal, PoolCallback, ProposalCallback,
RawSnapshotsContainer, SnapshotCallbacks, SnapshotMetadata, SnapshotsCallback, StakeCallback,
AccountState, AccountsCallback, DRepCallback, DRepInfo, GovernanceProposal, PoolCallback,
ProposalCallback, SnapshotCallbacks, SnapshotMetadata, SnapshotsCallback,
StreamingSnapshotParser, UtxoCallback, UtxoEntry,
};
use acropolis_common::{NetworkId, PoolRegistration};
Expand Down Expand Up @@ -97,18 +98,21 @@ impl PoolCallback for CountingCallbacks {
}
}

impl StakeCallback for CountingCallbacks {
fn on_accounts(&mut self, accounts: Vec<AccountState>) -> Result<()> {
self.account_count = accounts.len();
if !accounts.is_empty() {
eprintln!("Parsed {} stake accounts", accounts.len());
impl AccountsCallback for CountingCallbacks {
fn on_accounts(
&mut self,
data: acropolis_common::snapshot::AccountsBootstrapData,
) -> Result<()> {
self.account_count = data.accounts.len();
if !data.accounts.is_empty() {
eprintln!("Parsed {} stake accounts", data.accounts.len());

// Show first 10 accounts
for (i, account) in accounts.iter().take(10).enumerate() {
for (i, account) in data.accounts.iter().take(10).enumerate() {
eprintln!(
" Account #{}: {} (utxo: {}, rewards: {}, pool: {:?}, drep: {:?})",
i + 1,
&account.stake_address[..32],
&account.stake_address.to_string().unwrap(),
account.address_state.utxo_value,
account.address_state.rewards,
account.address_state.delegated_spo.as_ref().map(|s| &s[..16]),
Expand All @@ -117,8 +121,17 @@ impl StakeCallback for CountingCallbacks {
}
}

eprintln!(
"AccountsBootstrapData: epoch={}, pools={}, retiring={}, dreps={}, snapshots={}",
data.epoch,
data.pools.len(),
data.retiring_pools.len(),
data.dreps.len(),
data.snapshots.is_some()
);

// Keep first 10 for summary
self.sample_accounts = accounts.into_iter().take(10).collect();
self.sample_accounts = data.accounts.into_iter().take(10).collect();
Ok(())
}
}
Expand All @@ -134,15 +147,15 @@ impl DRepCallback for CountingCallbacks {
eprintln!(
" DRep #{}: {} (deposit: {}) - {}",
i + 1,
drep.drep_id,
drep.drep_id.to_drep_bech32().unwrap(),
drep.deposit,
anchor.url
);
} else {
eprintln!(
" DRep #{}: {} (deposit: {})",
i + 1,
drep.drep_id,
drep.drep_id.to_drep_bech32().unwrap(),
drep.deposit
);
}
Expand Down Expand Up @@ -336,30 +349,6 @@ impl SnapshotCallbacks for CountingCallbacks {
total_blocks_current
);

// Show snapshots info if available
if let Some(snapshots_info) = &metadata.snapshots {
eprintln!(" Snapshots Info:");
eprintln!(
" Mark snapshot: {} sections",
snapshots_info.mark.sections_count
);
eprintln!(
" Set snapshot: {} sections",
snapshots_info.set.sections_count
);
eprintln!(
" Go snapshot: {} sections",
snapshots_info.go.sections_count
);
eprintln!(
" Fee value: {} lovelace ({} ADA)",
snapshots_info.fee,
snapshots_info.fee as f64 / 1_000_000.0
);
} else {
eprintln!(" No snapshots data available");
}

// Show top block producers if any
if !metadata.blocks_previous_epoch.is_empty() {
eprintln!(" Previous epoch top producers (first 3):");
Expand Down Expand Up @@ -414,67 +403,26 @@ impl SnapshotCallbacks for CountingCallbacks {
}

impl SnapshotsCallback for CountingCallbacks {
fn on_snapshots(&mut self, snapshots: RawSnapshotsContainer) -> Result<()> {
eprintln!("Raw Snapshots Data:");
fn on_snapshots(&mut self, snapshots: SnapshotsContainer) -> Result<()> {
eprintln!("Snapshots Data:");
eprintln!();

// Calculate total stakes and delegator counts from VMap data
let mark_total: i64 = snapshots.mark.0.iter().map(|(_, amount)| amount).sum();
let set_total: i64 = snapshots.set.0.iter().map(|(_, amount)| amount).sum();
let go_total: i64 = snapshots.go.0.iter().map(|(_, amount)| amount).sum();

eprintln!("Mark Snapshot:");
eprintln!(" Delegators: {}", snapshots.mark.0.len());
eprintln!("Mark Snapshot (epoch {}):", snapshots.mark.epoch);
eprintln!(" SPOs: {}", snapshots.mark.spos.len());
let mark_total: u64 = snapshots.mark.spos.values().map(|spo| spo.total_stake).sum();
eprintln!(" Total stake: {:.2} ADA", mark_total as f64 / 1_000_000.0);
if !snapshots.mark.0.is_empty() {
eprintln!(" Sample stakes (first 5):");
for (i, (cred, amount)) in snapshots.mark.0.iter().take(5).enumerate() {
let cred_str = cred.to_string().unwrap_or_default();
eprintln!(
" [{}] {} -> {:.2} ADA",
i + 1,
cred_str,
*amount as f64 / 1_000_000.0
);
}
}
eprintln!();

eprintln!("Set Snapshot:");
eprintln!(" Delegators: {}", snapshots.set.0.len());
eprintln!("Set Snapshot (epoch {}):", snapshots.set.epoch);
eprintln!(" SPOs: {}", snapshots.set.spos.len());
let set_total: u64 = snapshots.set.spos.values().map(|spo| spo.total_stake).sum();
eprintln!(" Total stake: {:.2} ADA", set_total as f64 / 1_000_000.0);
if !snapshots.set.0.is_empty() {
eprintln!(" Sample stakes (first 5):");
for (i, (cred, amount)) in snapshots.set.0.iter().take(5).enumerate() {
let cred_str = cred.to_string().unwrap_or_default();
eprintln!(
" [{}] {} -> {:.2} ADA",
i + 1,
cred_str,
*amount as f64 / 1_000_000.0
);
}
}
eprintln!();

eprintln!("Go Snapshot:");
eprintln!(" Delegators: {}", snapshots.go.0.len());
eprintln!("Go Snapshot (epoch {}):", snapshots.go.epoch);
eprintln!(" SPOs: {}", snapshots.go.spos.len());
let go_total: u64 = snapshots.go.spos.values().map(|spo| spo.total_stake).sum();
eprintln!(" Total stake: {:.2} ADA", go_total as f64 / 1_000_000.0);
if !snapshots.go.0.is_empty() {
eprintln!(" Sample stakes (first 5):");
for (i, (cred, amount)) in snapshots.go.0.iter().take(5).enumerate() {
let cred_str = cred.to_string().unwrap_or_default();
eprintln!(
" [{}] {} -> {:.2} ADA",
i + 1,
cred_str,
*amount as f64 / 1_000_000.0
);
}
}
eprintln!();

eprintln!("Fee: {:.2} ADA", snapshots.fee as f64 / 1_000_000.0);
eprintln!();

Ok(())
Expand Down Expand Up @@ -539,18 +487,6 @@ fn main() {
total_blocks_current
);

// Show snapshots info summary
if let Some(snapshots_info) = &metadata.snapshots {
println!(" Snapshots Summary:");
println!(
" Mark: {} sections, Set: {} sections, Go: {} sections, Fee: {} ADA",
snapshots_info.mark.sections_count,
snapshots_info.set.sections_count,
snapshots_info.go.sections_count,
snapshots_info.fee as f64 / 1_000_000.0
);
}

println!();
}

Expand Down Expand Up @@ -601,7 +537,7 @@ fn main() {
println!(
" {}: {} (utxo: {}, rewards: {})",
i + 1,
&account.stake_address[..32],
&account.stake_address.to_string().unwrap(),
account.address_state.utxo_value,
account.address_state.rewards
);
Expand All @@ -616,7 +552,7 @@ fn main() {
print!(
" {}: {} (deposit: {} lovelace)",
i + 1,
drep.drep_id,
drep.drep_id.to_drep_bech32().unwrap(),
drep.deposit
);
if let Some(anchor) = &drep.anchor {
Expand Down
Loading