Skip to content

Commit f77d2dc

Browse files
committed
Merge in main
2 parents 727ffee + 465b906 commit f77d2dc

File tree

42 files changed

+1277
-1088
lines changed

Some content is hidden

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

42 files changed

+1277
-1088
lines changed

.github/workflows/run-tests-on-push-to-main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,26 @@ jobs:
2525

2626
- name: Run Clippy
2727
run: |
28-
cargo clippy \
28+
cargo clippy --all-targets --all-features \
2929
--package acropolis_common \
3030
--package acropolis_codec \
31+
--package acropolis_module_accounts_state \
3132
--package acropolis_module_address_state \
3233
--package acropolis_module_assets_state \
3334
--package acropolis_module_block_unpacker \
3435
--package acropolis_module_chain_store \
3536
--package acropolis_module_consensus \
3637
--package acropolis_module_drdd_state \
38+
--package acropolis_module_drep_state \
3739
--package acropolis_module_epochs_state \
3840
--package acropolis_module_genesis_bootstrapper \
3941
--package acropolis_module_mithril_snapshot_fetcher \
4042
--package acropolis_module_snapshot_bootstrapper \
4143
--package acropolis_module_spdd_state \
44+
--package acropolis_module_spo_state \
4245
--package acropolis_module_stake_delta_filter \
4346
--package acropolis_module_tx_submitter \
47+
--package acropolis_module_tx_unpacker \
4448
--package acropolis_module_upstream_chain_fetcher \
4549
--package acropolis_module_utxo_state \
4650
--package acropolis_process_tx_submitter_cli

codec/src/map_parameters.rs

Lines changed: 237 additions & 197 deletions
Large diffs are not rendered by default.

common/examples/test_streaming_parser.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::env;
1212
use std::time::Instant;
1313

1414
// Simple counter callback that doesn't store data in memory
15+
#[derive(Default)]
1516
struct CountingCallbacks {
1617
metadata: Option<SnapshotMetadata>,
1718
utxo_count: u64,
@@ -26,24 +27,6 @@ struct CountingCallbacks {
2627
sample_proposals: Vec<GovernanceProposal>,
2728
}
2829

29-
impl Default for CountingCallbacks {
30-
fn default() -> Self {
31-
Self {
32-
metadata: None,
33-
utxo_count: 0,
34-
pool_count: 0,
35-
account_count: 0,
36-
drep_count: 0,
37-
proposal_count: 0,
38-
sample_utxos: Vec::new(),
39-
sample_pools: Vec::new(),
40-
sample_accounts: Vec::new(),
41-
sample_dreps: Vec::new(),
42-
sample_proposals: Vec::new(),
43-
}
44-
}
45-
}
46-
4730
impl UtxoCallback for CountingCallbacks {
4831
fn on_utxo(&mut self, utxo: UtxoEntry) -> Result<()> {
4932
self.utxo_count += 1;
@@ -62,7 +45,7 @@ impl UtxoCallback for CountingCallbacks {
6245
self.sample_utxos.push(utxo);
6346
}
6447
// Progress reporting every million UTXOs
65-
if self.utxo_count > 0 && self.utxo_count % 1000000 == 0 {
48+
if self.utxo_count > 0 && self.utxo_count.is_multiple_of(1000000) {
6649
eprintln!(" Parsed {} UTXOs...", self.utxo_count);
6750
}
6851
Ok(())
@@ -95,7 +78,7 @@ impl PoolCallback for CountingCallbacks {
9578
impl StakeCallback for CountingCallbacks {
9679
fn on_accounts(&mut self, accounts: Vec<AccountState>) -> Result<()> {
9780
self.account_count = accounts.len();
98-
if accounts.len() > 0 {
81+
if !accounts.is_empty() {
9982
eprintln!("✓ Parsed {} stake accounts", accounts.len());
10083

10184
// Show first 10 accounts
@@ -152,7 +135,7 @@ impl DRepCallback for CountingCallbacks {
152135
impl ProposalCallback for CountingCallbacks {
153136
fn on_proposals(&mut self, proposals: Vec<GovernanceProposal>) -> Result<()> {
154137
self.proposal_count = proposals.len();
155-
if proposals.len() > 0 {
138+
if !proposals.is_empty() {
156139
eprintln!("✓ Parsed {} governance proposals", proposals.len());
157140

158141
// Show first 10 proposals

common/src/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl StakeAddress {
495495

496496
impl Display for StakeAddress {
497497
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
498-
write!(f, "{}", hex::encode(self.get_credential().get_hash()))
498+
write!(f, "{}", hex::encode(self.to_binary()))
499499
}
500500
}
501501

common/src/messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub struct AssetDeltasMessage {
9090
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
9191
pub struct TxCertificatesMessage {
9292
/// Ordered set of certificates
93-
pub certificates: Vec<TxCertificate>,
93+
pub certificates: Vec<TxCertificateWithPos>,
9494
}
9595

9696
/// Address deltas message

common/src/queries/accounts.rs

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::HashMap;
22

3-
use crate::{DRepChoice, KeyHash, PoolId, PoolLiveStakeInfo, StakeAddress};
3+
use crate::{DRepChoice, KeyHash, PoolId, PoolLiveStakeInfo, StakeAddress, TxIdentifier};
44

55
pub const DEFAULT_ACCOUNTS_QUERY_TOPIC: (&str, &str) =
66
("accounts-state-query-topic", "cardano.query.accounts");
@@ -15,10 +15,10 @@ pub enum AccountsStateQuery {
1515
GetAccountInfo { stake_address: StakeAddress },
1616
GetAccountRewardHistory { stake_key: Vec<u8> },
1717
GetAccountHistory { stake_key: Vec<u8> },
18-
GetAccountDelegationHistory { stake_key: Vec<u8> },
19-
GetAccountRegistrationHistory { stake_key: Vec<u8> },
18+
GetAccountRegistrationHistory { account: StakeAddress },
19+
GetAccountDelegationHistory { account: StakeAddress },
20+
GetAccountMIRHistory { account: StakeAddress },
2021
GetAccountWithdrawalHistory { stake_key: Vec<u8> },
21-
GetAccountMIRHistory { stake_key: Vec<u8> },
2222
GetAccountAssociatedAddresses { stake_key: Vec<u8> },
2323
GetAccountAssets { stake_key: Vec<u8> },
2424
GetAccountAssetsTotals { stake_key: Vec<u8> },
@@ -49,10 +49,10 @@ pub enum AccountsStateQueryResponse {
4949
AccountInfo(AccountInfo),
5050
AccountRewardHistory(AccountRewardHistory),
5151
AccountHistory(AccountHistory),
52-
AccountDelegationHistory(AccountDelegationHistory),
53-
AccountRegistrationHistory(AccountRegistrationHistory),
52+
AccountRegistrationHistory(Vec<RegistrationUpdate>),
53+
AccountDelegationHistory(Vec<DelegationUpdate>),
54+
AccountMIRHistory(Vec<AccountWithdrawal>),
5455
AccountWithdrawalHistory(AccountWithdrawalHistory),
55-
AccountMIRHistory(AccountMIRHistory),
5656
AccountAssociatedAddresses(AccountAssociatedAddresses),
5757
AccountAssets(AccountAssets),
5858
AccountAssetsTotals(AccountAssetsTotals),
@@ -97,17 +97,52 @@ pub struct AccountRewardHistory {}
9797
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
9898
pub struct AccountHistory {}
9999

100-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
101-
pub struct AccountDelegationHistory {}
100+
#[derive(
101+
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
102+
)]
103+
pub struct DelegationUpdate {
104+
#[n(0)]
105+
pub active_epoch: u32,
106+
#[n(1)]
107+
pub tx_identifier: TxIdentifier,
108+
#[n(2)]
109+
pub amount: u64,
110+
#[n(3)]
111+
pub pool: PoolId,
112+
}
102113

103-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
104-
pub struct AccountRegistrationHistory {}
114+
#[derive(
115+
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
116+
)]
117+
pub struct RegistrationUpdate {
118+
#[n(0)]
119+
pub tx_identifier: TxIdentifier,
120+
#[n(1)]
121+
pub status: RegistrationStatus,
122+
}
105123

106-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
107-
pub struct AccountWithdrawalHistory {}
124+
#[derive(
125+
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
126+
)]
127+
pub enum RegistrationStatus {
128+
#[n(0)]
129+
Registered,
130+
#[n(1)]
131+
Deregistered,
132+
}
133+
134+
#[derive(
135+
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
136+
)]
137+
pub struct AccountWithdrawal {
138+
#[n(0)]
139+
pub tx_identifier: TxIdentifier,
140+
#[n(1)]
141+
pub amount: u64,
142+
}
108143

109144
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
110-
pub struct AccountMIRHistory {}
145+
pub struct AccountWithdrawalHistory {}
111146

112147
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
113148
pub struct AccountAssociatedAddresses {}

common/src/queries/governance.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::collections::HashMap;
22

33
use crate::{
4-
Anchor, DRepCredential, GovActionId, Lovelace, ProposalProcedure, StakeAddress, TxHash, Vote,
5-
Voter, VotingProcedure,
4+
Anchor, DRepCredential, GovActionId, Lovelace, ProposalProcedure, StakeAddress, TxHash,
5+
TxIdentifier, Vote, Voter, VotingProcedure,
66
};
77

88
pub const DEFAULT_DREPS_QUERY_TOPIC: (&str, &str) =
@@ -77,7 +77,7 @@ pub struct DRepUpdates {
7777

7878
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
7979
pub struct DRepUpdateEvent {
80-
pub tx_hash: TxHash,
80+
pub tx_identifier: TxIdentifier,
8181
pub cert_index: u64,
8282
pub action: DRepActionUpdate,
8383
}

common/src/stake_addresses.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ impl StakeAddressMap {
188188

189189
/// Get DRep Delegators with live_stakes
190190
pub fn get_drep_delegators(&self, drep: &DRepChoice) -> Vec<(KeyHash, u64)> {
191+
// Find stake addresses delegated to drep
191192
let delegators: Vec<(KeyHash, u64)> = self
192193
.inner
193194
.iter()
@@ -324,7 +325,7 @@ impl StakeAddressMap {
324325
}
325326

326327
/// Dump current Stake Pool Delegation Distribution State
327-
/// <KeyHash -> (Stake Key, Active Stakes Amount)>
328+
/// <PoolId -> (Stake Key, Active Stakes Amount)>
328329
pub fn dump_spdd_state(&self) -> HashMap<PoolId, Vec<(KeyHash, u64)>> {
329330
let entries: Vec<_> = self
330331
.inner

0 commit comments

Comments
 (0)