Skip to content

Commit 605e6e4

Browse files
committed
Merge branch 'main' into sg/chain-sync-tweaks
2 parents 3b39b87 + 9ac80db commit 605e6e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3447
-575
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[workspace]
44
members = [
55
# Global message and common definitions
6+
"cardano",
67
"codec",
78
"common",
89

@@ -52,6 +53,7 @@ config = "0.15.11"
5253
dashmap = "6.1.0"
5354
hex = "0.4"
5455
imbl = { version = "5.0.0", features = ["serde"] }
56+
minicbor = { version = "0.25.1", features = ["alloc", "std", "derive"] }
5557
opentelemetry = { version = "0.30.0", features = ["trace"] }
5658
opentelemetry-otlp = { version = "0.30.0", features = ["grpc-tonic", "trace", "tls"] }
5759
opentelemetry_sdk = { version = "0.30.0", features = ["rt-tokio"] }

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

cardano/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "acropolis_cardano"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
acropolis_common = { version = "0.3.0", path = "../common" }
8+
anyhow.workspace = true

cardano/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod transaction;

cardano/src/transaction.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use acropolis_common::{Lovelace, protocol_params::ProtocolParams};
2+
use anyhow::{Error, anyhow};
3+
4+
pub fn calculate_transaction_fee(
5+
recorded_fee: &Option<Lovelace>,
6+
inputs: &[Lovelace],
7+
outputs: &[Lovelace],
8+
) -> Lovelace {
9+
match recorded_fee {
10+
Some(fee) => *fee,
11+
None => inputs.iter().sum::<Lovelace>() - outputs.iter().sum::<Lovelace>(),
12+
}
13+
}
14+
15+
pub fn calculate_deposit(
16+
pool_update_count: u64,
17+
stake_cert_count: u64,
18+
params: &ProtocolParams,
19+
) -> Result<Lovelace, Error> {
20+
match &params.shelley {
21+
Some(shelley) => Ok(stake_cert_count * shelley.protocol_params.key_deposit
22+
+ pool_update_count * shelley.protocol_params.pool_deposit),
23+
None => {
24+
if pool_update_count > 0 || stake_cert_count > 0 {
25+
Err(anyhow!("No Shelley params, but deposits present"))
26+
} else {
27+
Ok(0)
28+
}
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)