Skip to content

Commit 8d32010

Browse files
committed
Merge branch 'main' into 2091-map-proposal-elements-for-testing
2 parents 35f0abc + 75e9b06 commit 8d32010

File tree

223 files changed

+4093
-2170
lines changed

Some content is hidden

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

223 files changed

+4093
-2170
lines changed

Earthfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.4.0 AS mdlint-ci
4-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.4.0 AS cspell-ci
5-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.4.0 AS postgresql-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.4.2 AS mdlint-ci
4+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.4.2 AS cspell-ci
5+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.4.2 AS postgresql-ci
66

77
FROM debian:stable-slim
88

catalyst-gateway/Earthfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VERSION 0.8
22

3-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.0 AS rust-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.2 AS rust-ci
44
IMPORT ../ AS repo-ci
55

66
#cspell: words rustfmt toolsets USERARCH stdcfgs

catalyst-gateway/bin/Cargo.toml

Lines changed: 11 additions & 8 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.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250428-00" }
19-
rbac-registration = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250428-00" }
20-
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250428-00" }
21-
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250428-00" }
22-
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250428-00" }
23-
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250428-00" }
18+
cardano-chain-follower = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250512-00" }
19+
rbac-registration = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250512-00" }
20+
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250512-00" }
21+
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250512-00" }
22+
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250512-00" }
23+
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250512-00" }
2424

2525
pallas = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
2626
pallas-traverse = { version = "0.30.1", git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "9b5183c8b90b90fe2cc319d986e933e9518957b3" }
@@ -45,7 +45,7 @@ tokio-postgres = { version = "0.7.12", features = [
4545
"with-chrono-0_4",
4646
"with-serde_json-1",
4747
"with-time-0_3",
48-
"with-uuid-1"
48+
"with-uuid-1",
4949
] }
5050
tokio = { version = "1.41.0", features = ["rt", "macros", "rt-multi-thread"] }
5151
dotenvy = "0.15.7"
@@ -95,7 +95,10 @@ bytes = "1.9.0"
9595
mime = "0.3.17"
9696
stats_alloc = "0.1.10"
9797
memory-stats = "1.0.0"
98-
derive_more = { version = "2.0.1", default-features = false, features = ["from", "into"] }
98+
derive_more = { version = "2.0.1", default-features = false, features = [
99+
"from",
100+
"into",
101+
] }
99102
rayon = "1.10"
100103
x509-cert = "0.2.5"
101104
minicbor = { version = "0.25.1", features = ["alloc"] }

catalyst-gateway/bin/src/db/index/block/rbac509/insert_catalyst_id_for_stake_address.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{fmt::Debug, sync::Arc};
44

55
use cardano_blockchain_types::{Slot, StakeAddress};
6-
use catalyst_types::id_uri::IdUri;
6+
use catalyst_types::catalyst_id::CatalystId;
77
use scylla::{SerializeRow, Session};
88
use tracing::error;
99

@@ -41,7 +41,7 @@ impl Debug for Params {
4141

4242
impl Params {
4343
/// Create a new record for this transaction.
44-
pub(crate) fn new(stake_address: StakeAddress, slot_no: Slot, catalyst_id: IdUri) -> Self {
44+
pub(crate) fn new(stake_address: StakeAddress, slot_no: Slot, catalyst_id: CatalystId) -> Self {
4545
Params {
4646
stake_address: stake_address.into(),
4747
catalyst_id: catalyst_id.into(),

catalyst-gateway/bin/src/db/index/block/rbac509/insert_catalyst_id_for_txn_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{fmt::Debug, sync::Arc};
44

55
use cardano_blockchain_types::TransactionId;
6-
use catalyst_types::id_uri::IdUri;
6+
use catalyst_types::catalyst_id::CatalystId;
77
use scylla::{SerializeRow, Session};
88
use tracing::error;
99

@@ -38,7 +38,7 @@ impl Debug for Params {
3838

3939
impl Params {
4040
/// Creates a new record for this transaction.
41-
pub(crate) fn new(catalyst_id: IdUri, txn_id: TransactionId) -> Self {
41+
pub(crate) fn new(catalyst_id: CatalystId, txn_id: TransactionId) -> Self {
4242
Params {
4343
txn_id: txn_id.into(),
4444
catalyst_id: catalyst_id.into(),

catalyst-gateway/bin/src/db/index/block/rbac509/insert_rbac509.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{fmt::Debug, sync::Arc};
44

55
use cardano_blockchain_types::{Slot, TransactionId, TxnIndex};
6-
use catalyst_types::{id_uri::IdUri, uuid::UuidV4};
6+
use catalyst_types::{catalyst_id::CatalystId, uuid::UuidV4};
77
use scylla::{frame::value::MaybeUnset, SerializeRow, Session};
88
use tracing::error;
99

@@ -55,7 +55,7 @@ impl Debug for Params {
5555
impl Params {
5656
/// Create a new record for this transaction.
5757
pub(crate) fn new(
58-
catalyst_id: IdUri, txn_id: TransactionId, slot_no: Slot, txn_index: TxnIndex,
58+
catalyst_id: CatalystId, txn_id: TransactionId, slot_no: Slot, txn_index: TxnIndex,
5959
purpose: UuidV4, prv_txn_id: Option<TransactionId>,
6060
) -> Self {
6161
let prv_txn_id = prv_txn_id.map_or(MaybeUnset::Unset, |v| MaybeUnset::Set(v.into()));

catalyst-gateway/bin/src/db/index/block/rbac509/insert_rbac509_invalid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::{fmt::Debug, sync::Arc};
44

55
use cardano_blockchain_types::{Slot, TransactionId, TxnIndex};
6-
use catalyst_types::{id_uri::IdUri, problem_report::ProblemReport, uuid::UuidV4};
6+
use catalyst_types::{catalyst_id::CatalystId, problem_report::ProblemReport, uuid::UuidV4};
77
use scylla::{frame::value::MaybeUnset, SerializeRow, Session};
88
use tracing::error;
99

@@ -40,7 +40,7 @@ pub(crate) struct Params {
4040
impl Params {
4141
/// Create a new record for this transaction.
4242
pub(crate) fn new(
43-
catalyst_id: IdUri, txn_id: TransactionId, slot_no: Slot, txn_index: TxnIndex,
43+
catalyst_id: CatalystId, txn_id: TransactionId, slot_no: Slot, txn_index: TxnIndex,
4444
purpose: Option<UuidV4>, prv_txn_id: Option<TransactionId>, report: &ProblemReport,
4545
) -> Self {
4646
let purpose = purpose.map_or(MaybeUnset::Unset, |v| MaybeUnset::Set(v.into()));

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use anyhow::{bail, Context};
1111
use cardano_blockchain_types::{
1212
Cip0134Uri, MultiEraBlock, Slot, StakeAddress, TransactionId, TxnIndex,
1313
};
14-
use catalyst_types::id_uri::IdUri;
14+
use catalyst_types::catalyst_id::CatalystId;
1515
use pallas::ledger::addresses::Address;
1616
use rbac_registration::cardano::cip509::{Cip509, Cip509RbacMetadata};
1717
use scylla::Session;
@@ -214,7 +214,7 @@ impl Rbac509InsertQuery {
214214
async fn catalyst_id(
215215
session: &Arc<CassandraSession>, cip509: &Cip509, txn_id: TransactionId, slot: Slot,
216216
index: TxnIndex, is_immutable: bool,
217-
) -> anyhow::Result<IdUri> {
217+
) -> anyhow::Result<CatalystId> {
218218
use crate::db::index::queries::rbac::get_catalyst_id_from_transaction_id::cache_for_transaction_id;
219219

220220
let id = match cip509.previous_transaction() {
@@ -235,7 +235,7 @@ async fn catalyst_id(
235235
/// Queries a Catalyst ID from the database by the given transaction ID.
236236
async fn query_catalyst_id(
237237
session: &Arc<CassandraSession>, txn_id: TransactionId, is_immutable: bool,
238-
) -> anyhow::Result<IdUri> {
238+
) -> anyhow::Result<CatalystId> {
239239
use crate::db::index::queries::rbac::get_catalyst_id_from_transaction_id::Query;
240240

241241
if let Some(q) = Query::get_latest(session, txn_id.into())

catalyst-gateway/bin/src/db/index/queries/rbac/get_catalyst_id_from_transaction_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::sync::{Arc, LazyLock};
44

55
use anyhow::{Context, Result};
66
use cardano_blockchain_types::{Slot, TransactionId, TxnIndex};
7-
use catalyst_types::id_uri::IdUri;
7+
use catalyst_types::catalyst_id::CatalystId;
88
use futures::StreamExt;
99
use moka::{policy::EvictionPolicy, sync::Cache};
1010
use scylla::{
@@ -102,7 +102,7 @@ impl Query {
102102

103103
/// Update the cache when a rbac registration is indexed.
104104
pub(crate) fn cache_for_transaction_id(
105-
_transaction_id: TransactionId, _catalyst_id: IdUri, _slot_no: Slot, _txn_idx: TxnIndex,
105+
_transaction_id: TransactionId, _catalyst_id: CatalystId, _slot_no: Slot, _txn_idx: TxnIndex,
106106
) {
107107
// TODO: Caching is disabled because we want to measure the performance without it and
108108
// be sure that the logic is sound. Also caches needs to be tunable.

catalyst-gateway/bin/src/db/index/queries/rbac/get_rbac_registrations.rs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::Arc;
55
use anyhow::Context;
66
use cardano_blockchain_types::{Network, Point, Slot, TxnIndex};
77
use cardano_chain_follower::ChainFollower;
8-
use catalyst_signed_doc::IdUri;
8+
use catalyst_signed_doc::CatalystId;
99
use futures::{TryFutureExt, TryStreamExt};
1010
use rbac_registration::{cardano::cip509::Cip509, registration::cardano::RegistrationChain};
1111
use scylla::{
@@ -36,6 +36,7 @@ pub(crate) struct QueryParams {
3636
#[derive(DeserializeRow, Clone)]
3737
pub(crate) struct Query {
3838
/// Registration transaction id.
39+
#[allow(dead_code)]
3940
pub txn_id: DbTransactionId,
4041
/// A block slot number.
4142
pub slot_no: DbSlot,
@@ -72,8 +73,8 @@ impl Query {
7273

7374
/// Returns a sorted list of all registrations for the given Catalyst ID from the
7475
/// database.
75-
async fn indexed_registrations(
76-
session: &CassandraSession, catalyst_id: &IdUri,
76+
pub(crate) async fn indexed_registrations(
77+
session: &CassandraSession, catalyst_id: &CatalystId,
7778
) -> anyhow::Result<Vec<Query>> {
7879
let mut result: Vec<_> = Query::execute(session, QueryParams {
7980
catalyst_id: catalyst_id.clone().into(),
@@ -86,33 +87,40 @@ async fn indexed_registrations(
8687
}
8788

8889
/// Build a registration chain from the given indexed data.
89-
pub(crate) async fn build_reg_chain(
90-
session: &CassandraSession, catalyst_id: &IdUri, network: Network,
90+
///
91+
/// # NOTE: provided `reg_queries` must be sorted by `slot_no`, look into `indexed_registrations` function.
92+
pub(crate) async fn build_reg_chain<OnSuccessFn: FnMut(bool, Slot, &RegistrationChain)>(
93+
mut reg_queries_iter: impl Iterator<Item = (bool, Query)>, network: Network,
94+
mut on_success: OnSuccessFn,
9195
) -> anyhow::Result<Option<RegistrationChain>> {
92-
let regs = indexed_registrations(session, catalyst_id).await?;
93-
let mut regs_iter = regs.iter();
94-
let Some(root) = regs_iter.next() else {
96+
let Some((is_persistent, root)) = reg_queries_iter.next() else {
9597
return Ok(None);
9698
};
9799

98-
let root = registration(network, root.slot_no.into(), root.txn_index.into())
100+
let slot_no = root.slot_no.into();
101+
let root = load_cip509_from_chain(network, root.slot_no.into(), root.txn_index.into())
99102
.await
100103
.context("Failed to get root registration")?;
101-
let mut chain = RegistrationChain::new(root).context("Invalid root registration")?;
104+
let mut chain = RegistrationChain::new(&root).context("Invalid root registration")?;
105+
on_success(is_persistent, slot_no, &chain);
102106

103-
for reg in regs_iter {
107+
for (is_persistent, reg) in reg_queries_iter {
104108
// We only store valid registrations in this table, so an error here indicates a bug in
105109
// our indexing logic.
106-
let cip509 = registration(network, reg.slot_no.into(), reg.txn_index.into())
110+
let slot_no = reg.slot_no.into();
111+
let cip509 = load_cip509_from_chain(network, reg.slot_no.into(), reg.txn_index.into())
107112
.await
108113
.with_context(|| {
109114
format!(
110115
"Invalid or missing registration at {:?} block {:?} transaction",
111116
reg.slot_no, reg.txn_index,
112117
)
113118
})?;
114-
match chain.update(cip509) {
115-
Ok(c) => chain = c,
119+
match chain.update(&cip509) {
120+
Ok(c) => {
121+
chain = c;
122+
on_success(is_persistent, slot_no, &chain);
123+
},
116124
Err(e) => {
117125
// This isn't a hard error because while the individual registration can be valid it
118126
// can be invalid in the context of the whole registration chain.
@@ -127,8 +135,9 @@ pub(crate) async fn build_reg_chain(
127135
Ok(Some(chain))
128136
}
129137

130-
/// A helper function to return a RBAC registration from the given block and slot.
131-
pub(crate) async fn registration(
138+
/// A helper function to load a RBAC registration `Cip509` by the given block and slot
139+
/// from the `cardano-chain-follower`.
140+
pub(crate) async fn load_cip509_from_chain(
132141
network: Network, slot: Slot, txn_index: TxnIndex,
133142
) -> anyhow::Result<Cip509> {
134143
let point = Point::fuzzy(slot);

0 commit comments

Comments
 (0)