Skip to content

Commit 3cd2732

Browse files
committed
Merge branch 'main' into feat/sync-with-gateway-v2-endpoints-3362
# Conflicts: # catalyst_voices/apps/voices/lib/widgets/modals/proposals/create_new_proposal_category_selection.dart # catalyst_voices/packages/internal/catalyst_voices_blocs/lib/src/category/category_detail_cubit.dart
2 parents 336b98e + 9ce8d89 commit 3cd2732

File tree

25 files changed

+316
-129
lines changed

25 files changed

+316
-129
lines changed

catalyst-gateway/bin/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ repository.workspace = true
1515
workspace = true
1616

1717
[dependencies]
18-
cardano-chain-follower = { version = "0.0.15", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-chain-follower/v0.0.15" }
19-
rbac-registration = { version = "0.0.11", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "rbac-registration/v0.0.11" }
20-
catalyst-signed-doc = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-signed-doc/v0.0.8" }
18+
cardano-chain-follower = { version = "0.0.17", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-chain-follower/v0.0.17" }
19+
rbac-registration = { version = "0.0.13", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "rbac-registration/v0.0.13" }
20+
catalyst-signed-doc = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-signed-doc/v0.0.9" }
2121
catalyst-signed-doc-v1 = { package = "catalyst-signed-doc", version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-signed-doc/v.0.0.4" }
2222
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "c509-certificate-v0.0.3" }
23-
catalyst-types = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.8" }
23+
catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" }
2424

2525
clap = { version = "4.5.20", features = ["derive", "env"] }
2626
tracing = { version = "0.1.40", features = ["log"] }

catalyst-gateway/bin/src/cardano/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ pub(crate) const INDEXING_DB_READY_WAIT_INTERVAL: Duration = Duration::from_secs
3333

3434
/// Start syncing a particular network
3535
async fn start_sync_for(cfg: &chain_follower::EnvVars) -> anyhow::Result<()> {
36-
let chain = cfg.chain;
36+
let chain = &cfg.chain;
3737
let dl_config = cfg.dl_config.clone();
3838

39-
let mut cfg = ChainSyncConfig::default_for(chain);
39+
let mut cfg = ChainSyncConfig::default_for(chain.clone());
4040
cfg.mithril_cfg = cfg.mithril_cfg.with_dl_config(dl_config);
4141
info!(chain = %chain, "Starting Chain Sync Task");
4242

@@ -263,9 +263,9 @@ fn sync_subchain(
263263
let mut blocks_synced = 0u64;
264264

265265
let mut follower =
266-
ChainFollower::new(params.chain, params.actual_start(), params.end.clone()).await;
266+
ChainFollower::new(&params.chain, params.actual_start(), params.end.clone()).await;
267267
while let Some(chain_update) = follower.next().await {
268-
let tips = ChainFollower::get_tips(params.chain).await;
268+
let tips = ChainFollower::get_tips(&params.chain).await;
269269
let immutable_slot = tips.0.slot_or_default();
270270
let live_slot = tips.1.slot_or_default();
271271
metrics_updater::current_tip_slot(live_slot, immutable_slot);
@@ -495,7 +495,7 @@ impl SyncTask {
495495
async fn run(&mut self) {
496496
// We can't sync until the local chain data is synced.
497497
// This call will wait until we sync.
498-
let tips = ChainFollower::get_tips(self.cfg.chain).await;
498+
let tips = ChainFollower::get_tips(&self.cfg.chain).await;
499499
self.immutable_tip_slot = tips.0.slot_or_default();
500500
self.live_tip_slot = tips.1.slot_or_default();
501501
info!(chain=%self.cfg.chain, immutable_tip=?self.immutable_tip_slot, live_tip=?self.live_tip_slot, "Running the primary blockchain follower task.");
@@ -516,7 +516,7 @@ impl SyncTask {
516516
// Start the Live Chain sync task - This can never end because it is syncing to TIP.
517517
// So, if it fails, it will automatically be restarted.
518518
self.add_sync_task(SyncParams::new(
519-
self.cfg.chain,
519+
self.cfg.chain.clone(),
520520
Point::fuzzy(self.immutable_tip_slot),
521521
Point::TIP,
522522
));
@@ -542,7 +542,7 @@ impl SyncTask {
542542

543543
match completed {
544544
Ok(finished) => {
545-
let tips = ChainFollower::get_tips(self.cfg.chain).await;
545+
let tips = ChainFollower::get_tips(&self.cfg.chain).await;
546546
let immutable_tip_slot = tips.0.slot_or_default();
547547
let live_tip_slot = tips.1.slot_or_default();
548548
info!(immutable_tip_slot=?immutable_tip_slot, live_tip_slot=?live_tip_slot, "Chain Indexer task finished");
@@ -672,7 +672,7 @@ impl SyncTask {
672672
self.get_syncable_range(self.start_slot, end_slot)
673673
{
674674
self.add_sync_task(SyncParams::new(
675-
self.cfg.chain,
675+
self.cfg.chain.clone(),
676676
first_point,
677677
last_point.clone(),
678678
));

catalyst-gateway/bin/src/db/index/block/certs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ impl CertInsertQuery {
187187
) {
188188
let (stake_address, pubkey, script) = match *cred {
189189
conway::StakeCredential::AddrKeyhash(cred) => {
190-
let stake_address = StakeAddress::new(block.network(), false, cred.into());
190+
let stake_address = StakeAddress::new(block.network().clone(), false, cred.into());
191191
let addr = block.witness_for_tx(&VKeyHash::from(*cred), txn);
192192
// Note: it is totally possible for the Registration Certificate to not be
193193
// witnessed.
194194
(stake_address, addr, false)
195195
},
196196
conway::StakeCredential::ScriptHash(h) => {
197197
(
198-
StakeAddress::new(block.network(), true, h.into()),
198+
StakeAddress::new(block.network().clone(), true, h.into()),
199199
None,
200200
true,
201201
)

catalyst-gateway/bin/src/db/index/block/cip36/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ impl Cip36InsertQuery {
8585
"Valid CIP36 registration must have one stake public key"
8686
))?;
8787
let stake_pk_hash = Blake2b224Hash::new(&stake_pk.to_bytes());
88-
let stake_address = StakeAddress::new(block.network(), false, stake_pk_hash);
88+
let stake_address =
89+
StakeAddress::new(block.network().clone(), false, stake_pk_hash);
8990

9091
self.registrations.push(insert_cip36::Params::new(
9192
voting_key, slot_no, index, &cip36,
@@ -131,7 +132,8 @@ impl Cip36InsertQuery {
131132
}
132133

133134
let stake_pk_hash = Blake2b224Hash::new(&stake_pk.to_bytes());
134-
let stake_address = StakeAddress::new(block.network(), false, stake_pk_hash);
135+
let stake_address =
136+
StakeAddress::new(block.network().clone(), false, stake_pk_hash);
135137
self.stake_regs
136138
.push(certs::StakeRegistrationInsertQuery::new(
137139
stake_address,

catalyst-gateway/bin/src/db/index/block/txo/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl TxoInsertQuery {
7777
/// stake address, and still have a primary key on the table. Otherwise return the
7878
/// header and the stake key hash as a vec of 29 bytes.
7979
fn extract_stake_address(
80-
network: Network,
80+
network: &Network,
8181
txo: &cardano_chain_follower::pallas_traverse::MultiEraOutput<'_>,
8282
slot_no: Slot,
8383
txn_id: &str,
@@ -101,10 +101,10 @@ impl TxoInsertQuery {
101101

102102
let address = match address.delegation() {
103103
cardano_chain_follower::pallas_addresses::ShelleyDelegationPart::Script(hash) => {
104-
Some(StakeAddress::new(network, true, (*hash).into()))
104+
Some(StakeAddress::new(network.clone(), true, (*hash).into()))
105105
},
106106
cardano_chain_follower::pallas_addresses::ShelleyDelegationPart::Key(hash) => {
107-
Some(StakeAddress::new(network, false, (*hash).into()))
107+
Some(StakeAddress::new(network.clone(), false, (*hash).into()))
108108
},
109109
cardano_chain_follower::pallas_addresses::ShelleyDelegationPart::Pointer(_pointer) => {
110110
// These are not supported from Conway, so we don't support them
@@ -140,7 +140,7 @@ impl TxoInsertQuery {
140140
/// Index the transaction Inputs.
141141
pub(crate) fn index(
142142
&mut self,
143-
network: Network,
143+
network: &Network,
144144
txn: &cardano_chain_follower::pallas_traverse::MultiEraTx<'_>,
145145
slot_no: Slot,
146146
txn_hash: TransactionId,

catalyst-gateway/bin/src/db/index/schema/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn generate_cql_schema_version() -> String {
165165
/// Get the namespace for a particular db configuration
166166
pub(crate) fn namespace(
167167
persistent: bool,
168-
network: Network,
168+
network: &Network,
169169
) -> String {
170170
// Build and set the Keyspace to use.
171171
let namespace = if persistent { "p" } else { "v" };
@@ -181,7 +181,7 @@ async fn create_namespace(
181181
session: &mut Arc<Session>,
182182
cfg: &cassandra_db::EnvVars,
183183
persistent: bool,
184-
network: Network,
184+
network: &Network,
185185
) -> anyhow::Result<()> {
186186
let keyspace = namespace(persistent, network);
187187

@@ -222,7 +222,7 @@ pub(crate) async fn create_schema(
222222
session: &mut Arc<Session>,
223223
cfg: &cassandra_db::EnvVars,
224224
persistent: bool,
225-
network: Network,
225+
network: &Network,
226226
) -> anyhow::Result<()> {
227227
create_namespace(session, cfg, persistent, network)
228228
.await
@@ -290,7 +290,7 @@ mod tests {
290290
fn test_namespace_persistent() {
291291
let network = Network::Preprod;
292292
let persistent = true;
293-
let namespace = namespace(persistent, network);
293+
let namespace = namespace(persistent, &network);
294294
let schema_version = generate_cql_schema_version().replace('-', "_");
295295
let expected = format!("p_{network}_{schema_version}");
296296
assert_eq!(namespace, expected);
@@ -300,7 +300,7 @@ mod tests {
300300
fn test_namespace_volatile() {
301301
let network = Network::Preprod;
302302
let persistent = false;
303-
let namespace = namespace(persistent, network);
303+
let namespace = namespace(persistent, &network);
304304
let schema_version = generate_cql_schema_version().replace('-', "_");
305305
let expected = format!("v_{network}_{schema_version}");
306306
assert_eq!(namespace, expected);

catalyst-gateway/bin/src/db/index/session/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ async fn make_session(cfg: &cassandra_db::EnvVars) -> anyhow::Result<Arc<Session
399399
/// Display reasonable logs to help diagnose DB connection issues.
400400
async fn retry_init(
401401
cfg: cassandra_db::EnvVars,
402-
network: Network,
402+
network: &Network,
403403
persistent: bool,
404404
) {
405405
let mut retry_delay = Duration::from_secs(0);

catalyst-gateway/bin/src/metrics/chain_follower/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn report_mithril(
2424
stats: &Statistics,
2525
api_host_names: &str,
2626
service_id: &str,
27-
network: Network,
27+
network: &Network,
2828
) {
2929
let stats = &stats.mithril;
3030
let network = network.to_string();
@@ -109,7 +109,7 @@ fn report_live(
109109
stats: &Statistics,
110110
api_host_names: &str,
111111
service_id: &str,
112-
network: Network,
112+
network: &Network,
113113
) {
114114
let stats = &stats.live;
115115
let network = network.to_string();

catalyst-gateway/bin/src/rbac/get_chain.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@ use crate::{
2323
/// Returns the latest (including the volatile part) registration chain by the given
2424
/// Catalyst ID.
2525
pub async fn latest_rbac_chain(id: &CatalystId) -> Result<Option<ChainInfo>> {
26-
let id = id.as_short_id();
27-
2826
let volatile_session =
2927
CassandraSession::get(false).context("Failed to get volatile Cassandra session")?;
3028
// Get the persistent part of the chain and volatile registrations. Both of these parts
3129
// can be non-existing.
3230
let (chain, volatile_regs) = try_join(
33-
persistent_rbac_chain(&id),
34-
indexed_regs(&volatile_session, &id),
31+
persistent_rbac_chain(id),
32+
indexed_regs(&volatile_session, id),
3533
)
3634
.await?;
3735

@@ -70,14 +68,11 @@ pub async fn latest_rbac_chain(id: &CatalystId) -> Result<Option<ChainInfo>> {
7068
/// Returns only the persistent part of a registration chain by the given Catalyst ID.
7169
pub async fn persistent_rbac_chain(id: &CatalystId) -> Result<Option<RegistrationChain>> {
7270
let session = CassandraSession::get(true).context("Failed to get Cassandra session")?;
73-
74-
let id = id.as_short_id();
75-
76-
if let Some(chain) = cached_persistent_rbac_chain(&session, &id) {
71+
if let Some(chain) = cached_persistent_rbac_chain(&session, id) {
7772
return Ok(Some(chain));
7873
}
7974

80-
let regs = indexed_regs(&session, &id).await?;
75+
let regs = indexed_regs(&session, id).await?;
8176
let chain = build_rbac_chain(regs).await?.inspect(|c| {
8277
cache_persistent_rbac_chain(id.clone(), c.clone());
8378
});
@@ -145,7 +140,7 @@ pub async fn apply_regs(
145140

146141
/// Loads and parses a `Cip509` registration from a block using chain follower.
147142
async fn cip509(
148-
network: Network,
143+
network: &Network,
149144
slot: Slot,
150145
txn_index: TxnIndex,
151146
) -> Result<Cip509> {

catalyst-gateway/bin/src/service/api/cardano/staking/assets_get.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async fn build_full_stake_info_response(
9191
slot_num: Option<SlotNo>,
9292
) -> anyhow::Result<Option<FullStakeInfo>> {
9393
if let Some(provided_network) = provided_network {
94-
if cardano_chain_follower::Network::from(provided_network) != Settings::cardano_network() {
94+
if &cardano_chain_follower::Network::from(provided_network) != Settings::cardano_network() {
9595
return Ok(None);
9696
}
9797
}

0 commit comments

Comments
 (0)