Skip to content

Commit 0285070

Browse files
committed
Merge branch 'main' into 2091-map-proposal-elements-for-testing
2 parents 1c32f00 + 39f08fe commit 0285070

File tree

102 files changed

+4978
-1511
lines changed

Some content is hidden

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

102 files changed

+4978
-1511
lines changed

.config/dictionaries/project.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ IDHI
137137
IDLO
138138
ilap
139139
IMEI
140+
inappwebview
140141
insertable
141142
Instantitation
142143
integ

catalyst-gateway/bin/Cargo.toml

Lines changed: 7 additions & 7 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 = "r20250413-00" }
19-
rbac-registration = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
20-
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
21-
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
22-
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
23-
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250413-00" }
18+
cardano-chain-follower = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250425-00" }
19+
rbac-registration = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250425-00" }
20+
catalyst-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250425-00" }
21+
cardano-blockchain-types = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250425-00" }
22+
catalyst-signed-doc = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250425-00" }
23+
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "r20250425-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" }
@@ -49,7 +49,7 @@ tokio-postgres = { version = "0.7.12", features = [
4949
] }
5050
tokio = { version = "1.41.0", features = ["rt", "macros", "rt-multi-thread"] }
5151
dotenvy = "0.15.7"
52-
local-ip-address = "0.6.3"
52+
local-ip-address = "=0.6.3"
5353
gethostname = "0.5.0"
5454
hex = "0.4.3"
5555
handlebars = "6.2.0"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ impl SyncTask {
590590
let purge_to_slot =
591591
self.immutable_tip_slot - Settings::purge_backward_slot_buffer();
592592
let purge_condition = PurgeCondition::PurgeBackwards(purge_to_slot);
593+
info!(chain=%self.cfg.chain, purge_to_slot=?purge_to_slot, "Backwards purging volatile data.");
593594
if let Err(error) = roll_forward::purge_live_index(purge_condition).await {
594595
error!(chain=%self.cfg.chain, error=%error, "BUG: Purging volatile data task failed.");
595596
} else {

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub(crate) struct QueryParams {
3333
}
3434

3535
/// Get registrations by Catalyst ID query.
36-
#[allow(dead_code)]
3736
#[derive(DeserializeRow, Clone)]
3837
pub(crate) struct Query {
3938
/// Registration transaction id.
@@ -45,6 +44,7 @@ pub(crate) struct Query {
4544
/// A previous transaction id.
4645
pub prv_txn_id: Option<DbTransactionId>,
4746
/// A registration purpose.
47+
#[allow(dead_code)]
4848
pub purpose: DbUuidV4,
4949
}
5050

@@ -128,19 +128,28 @@ pub(crate) async fn build_reg_chain(
128128
}
129129

130130
/// A helper function to return a RBAC registration from the given block and slot.
131-
async fn registration(network: Network, slot: Slot, txn_index: TxnIndex) -> anyhow::Result<Cip509> {
131+
pub(crate) async fn registration(
132+
network: Network, slot: Slot, txn_index: TxnIndex,
133+
) -> anyhow::Result<Cip509> {
132134
let point = Point::fuzzy(slot);
133135
let block = ChainFollower::get_block(network, point)
134136
.await
135137
.context("Unable to get block")?
136138
.data;
137139
if block.point().slot_or_default() != slot {
138-
// The `ChainFollower::get_block` function can return the next consecutive block if
139-
// it cannot find the exact one. This shouldn't happen, but we need
140-
// to check anyway.
141-
return Err(anyhow::anyhow!("Unable to find exact block"));
140+
// The `ChainFollower::get_block` function can return the next consecutive block if it
141+
// cannot find the exact one. This shouldn't happen, but we need to check anyway.
142+
anyhow::bail!(
143+
"Unable to find exact {slot:?} block. Found block slot {:?}",
144+
block.point().slot_or_default()
145+
);
142146
}
147+
// We perform validation during indexing, so this normally should never fail.
143148
Cip509::new(&block, txn_index, &[])
144-
.context("Invalid RBAC registration")?
145-
.context("No RBAC registration at this block and txn index")
149+
.with_context(|| {
150+
format!("Invalid RBAC registration, slot = {slot:?}, transaction index = {txn_index:?}")
151+
})?
152+
.with_context(|| {
153+
format!("No RBAC registration, slot = {slot:?}, transaction index = {txn_index:?}")
154+
})
146155
}

catalyst-gateway/bin/src/service/api/cardano/cip36/mod.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
//! CIP36 Registration Endpoints
22
3-
use poem::http::HeaderMap;
4-
use poem_openapi::{param::Query, payload::Json, OpenApi};
5-
use response::Cip36RegistrationUnprocessableContent;
3+
use poem_openapi::{param::Query, OpenApi};
64

7-
use self::{cardano::slot_no::SlotNo, common::auth::none::NoAuthorization};
5+
use self::cardano::slot_no::SlotNo;
86
use crate::service::common::{
97
self,
8+
auth::api_key::InternalApiKeyAuthorization,
109
tags::ApiTags,
1110
types::cardano::{self},
1211
};
@@ -40,32 +39,16 @@ impl Api {
4039
#[oai(
4140
path = "/v1/cardano/registration/cip36",
4241
method = "get",
43-
operation_id = "cardanoRegistrationCip36"
42+
operation_id = "cardanoRegistrationCip36",
43+
hidden = true
4444
)]
4545
async fn get_registration(
4646
&self, lookup: Query<Option<cardano::query::stake_or_voter::StakeOrVoter>>,
4747
asat: Query<Option<cardano::query::AsAt>>,
4848
page: Query<Option<common::types::generic::query::pagination::Page>>,
4949
limit: Query<Option<common::types::generic::query::pagination::Limit>>,
50-
/// Headers, used if the query is requesting ALL to determine if the secret API
51-
/// Key is also defined.
52-
headers: &HeaderMap,
53-
_auth: NoAuthorization,
50+
_auth: InternalApiKeyAuthorization,
5451
) -> response::AllRegistration {
55-
// Special validation for the `lookup` parameter.
56-
// If the parameter is ALL, BUT we do not have a valid API Key, just report the parameter
57-
// is invalid.
58-
if let Some(lookup) = lookup.0.clone() {
59-
if lookup.is_all(headers).is_err() {
60-
return response::Cip36Registration::UnprocessableContent(Json(
61-
Cip36RegistrationUnprocessableContent::new(
62-
"Invalid Stake Address or Voter key",
63-
),
64-
))
65-
.into();
66-
}
67-
}
68-
6952
endpoint::cip36_registrations(
7053
lookup.0,
7154
SlotNo::into_option(asat.0),

catalyst-gateway/bin/src/service/api/cardano/cip36/response.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ pub(crate) enum Cip36Registration {
2222
/// No valid registration.
2323
#[oai(status = 404)]
2424
NotFound,
25-
/// Response for unprocessable content.
26-
#[oai(status = 422)]
27-
UnprocessableContent(Json<Cip36RegistrationUnprocessableContent>),
2825
}
2926

3027
/// All responses to a cip36 registration query
@@ -199,26 +196,3 @@ impl Cip36Details {
199196
}
200197
}
201198
}
202-
203-
/// Cip36 Registration Validation Error.
204-
#[derive(Object)]
205-
#[oai(example = true)]
206-
pub(crate) struct Cip36RegistrationUnprocessableContent {
207-
/// Error messages.
208-
error: common::types::generic::error_msg::ErrorMessage,
209-
}
210-
211-
impl Cip36RegistrationUnprocessableContent {
212-
/// Create a new instance of `Cip36RegistrationUnprocessableContent`.
213-
pub(crate) fn new(error: &(impl ToString + ?Sized)) -> Self {
214-
Self {
215-
error: error.to_string().into(),
216-
}
217-
}
218-
}
219-
220-
impl Example for Cip36RegistrationUnprocessableContent {
221-
fn example() -> Self {
222-
Self::new("Cip36 Registration in request body")
223-
}
224-
}

catalyst-gateway/bin/src/service/api/cardano/rbac/registrations_get/chain_info.rs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
33
// cspell: words rposition
44

5-
use anyhow::{bail, Context};
6-
use cardano_blockchain_types::{Network, Point, Slot, TransactionId, TxnIndex};
7-
use cardano_chain_follower::ChainFollower;
5+
use anyhow::Context;
6+
use cardano_blockchain_types::{Slot, TransactionId};
87
use catalyst_types::id_uri::IdUri;
98
use futures::{future::try_join, TryFutureExt, TryStreamExt};
10-
use rbac_registration::{cardano::cip509::Cip509, registration::cardano::RegistrationChain};
9+
use rbac_registration::registration::cardano::RegistrationChain;
1110

1211
use crate::{
1312
db::index::{
14-
queries::rbac::get_rbac_registrations::{Query, QueryParams},
13+
queries::rbac::get_rbac_registrations::{registration, Query, QueryParams},
1514
session::CassandraSession,
1615
},
1716
settings::Settings,
@@ -134,28 +133,6 @@ async fn indexed_registrations(
134133
Ok(result)
135134
}
136135

137-
/// Returns a RBAC registration from the given block and slot.
138-
async fn registration(network: Network, slot: Slot, txn_index: TxnIndex) -> anyhow::Result<Cip509> {
139-
let point = Point::fuzzy(slot);
140-
let block = ChainFollower::get_block(network, point)
141-
.await
142-
.with_context(|| format!("Unable to get {slot:?} block"))?
143-
.data;
144-
if block.point().slot_or_default() != slot {
145-
// The `ChainFollower::get_block` function can return the next consecutive block if it
146-
// cannot find the exact one. This shouldn't happen, but we need to check anyway.
147-
bail!("Unable to find exact {slot:?} block");
148-
}
149-
// We perform validation during indexing, so this normally should never fail.
150-
Cip509::new(&block, txn_index, &[])
151-
.with_context(|| {
152-
format!("Invalid RBAC registration, slot = {slot:?}, transaction index = {txn_index:?}")
153-
})?
154-
.with_context(|| {
155-
format!("No RBAC registration, slot = {slot:?}, transaction index = {txn_index:?}")
156-
})
157-
}
158-
159136
/// Updates the values depending on if the given registration is persistent or not.
160137
fn update_values(
161138
is_persistent: bool, reg: &Query, last_persistent_txn: &mut Option<TransactionId>,

catalyst-gateway/bin/src/service/api/config/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use tracing::error;
1414
use crate::{
1515
db::event::config::{key::ConfigKey, Config},
1616
service::common::{
17-
auth::{none_or_rbac::NoneOrRBAC, rbac::scheme::CatalystRBACSecurityScheme},
17+
auth::{api_key::InternalApiKeyAuthorization, none_or_rbac::NoneOrRBAC},
1818
objects::config::{frontend_config::FrontendConfig, ConfigUnprocessableContent},
1919
responses::WithErrorResponses,
2020
tags::ApiTags,
@@ -159,14 +159,15 @@ impl ConfigApi {
159159
#[oai(
160160
path = "/draft/config/frontend",
161161
method = "put",
162-
operation_id = "put_config_frontend"
162+
operation_id = "put_config_frontend",
163+
hidden = true
163164
)]
164165
async fn put_frontend(
165166
&self,
166167
/// *OPTIONAL* The IP Address to set the configuration for.
167168
#[oai(name = "IP")]
168169
ip_query: Query<Option<IpAddr>>,
169-
_auth: CatalystRBACSecurityScheme, body: Json<FrontendConfig>,
170+
body: Json<FrontendConfig>, _auth: InternalApiKeyAuthorization,
170171
) -> SetConfigAllResponses {
171172
let body_value = body.0.to_json();
172173

catalyst-gateway/bin/src/service/api/documents/templates/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{collections::HashMap, env, sync::LazyLock};
66

77
use catalyst_signed_doc::{Builder, CatalystSignedDocument, ContentEncoding, ContentType, IdUri};
88
use data::{CATEGORY_DOCUMENTS, COMMENT_TEMPLATES, PROPOSAL_TEMPLATES};
9-
use ed25519_dalek::SigningKey;
9+
use ed25519_dalek::{ed25519::signature::Signer, SigningKey};
1010
use hex::FromHex;
1111
use uuid::Uuid;
1212

@@ -112,7 +112,7 @@ fn build_signed_doc(data: &SignedDocData, sk: &SigningKey) -> (Uuid, CatalystSig
112112
.with_json_metadata(metadata.clone())
113113
.expect("Failed to build Metadata from template")
114114
.with_decoded_content(data.content.to_vec())
115-
.add_signature(sk.to_bytes(), kid)
115+
.add_signature(|m| sk.sign(&m).to_vec(), &kid)
116116
.expect("Failed to add signature for template")
117117
.build();
118118
let doc_id = doc

catalyst-gateway/bin/src/service/api/health/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! Health Endpoints
22
use poem_openapi::{param::Query, OpenApi};
33

4-
use crate::service::common::{auth::none::NoAuthorization, tags::ApiTags};
4+
use crate::service::common::{
5+
auth::{api_key::InternalApiKeyAuthorization, none::NoAuthorization},
6+
tags::ApiTags,
7+
};
58

69
mod inspection_get;
710
mod live_get;
@@ -74,7 +77,8 @@ impl HealthApi {
7477
#[oai(
7578
path = "/v1/health/inspection",
7679
method = "put",
77-
operation_id = "healthInspection"
80+
operation_id = "healthInspection",
81+
hidden = true
7882
)]
7983
async fn inspection(
8084
&self,
@@ -83,7 +87,7 @@ impl HealthApi {
8387
/// Enable or disable Verbose Query inspection in the logs. Used to find query
8488
/// performance issues.
8589
query_inspection: Query<Option<inspection_get::DeepQueryInspectionFlag>>,
86-
_auth: NoAuthorization,
90+
_auth: InternalApiKeyAuthorization,
8791
) -> inspection_get::AllResponses {
8892
inspection_get::endpoint(log_level.0, query_inspection.0).await
8993
}

0 commit comments

Comments
 (0)