Skip to content

Commit e29d648

Browse files
chore(cat-gateway): Migrate to Rust 2024 edition (#3665)
* Migrate to Rust 2024 edition * Use proper tag instead of branch reference (Catalyst CI) * Fix * Update CI to 3.6 * Update clippy.toml * Fix formatting for rust catalyst_compression * Fix formatting for rust catalyst_key_derivation * BUILDER_WITH_POETRY * Update Python version * python-base-deprecated * Update poetry.lock * Update pycardano version * Regenerate poetry lock file
1 parent d61e616 commit e29d648

File tree

185 files changed

+1929
-1724
lines changed

Some content is hidden

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

185 files changed

+1929
-1724
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.5.28 AS mdlint-ci
4-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.5.28 AS cspell-ci
5-
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.5.28 AS postgresql-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.6.0 AS mdlint-ci
4+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.6.0 AS cspell-ci
5+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.6.0 AS postgresql-ci
66

77
ARG --global REGISTRY="harbor.shared-services.projectcatalyst.io/dockerhub/library"
88
FROM ${REGISTRY}/debian:stable-slim

catalyst-gateway/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[workspace]
2-
resolver = "2"
2+
resolver = "3"
33
members = [
44
"bin",
55
]
66

77
[workspace.package]
8-
edition = "2021"
8+
edition = "2024"
99
version = "0.0.1"
1010
authors = [
1111
"Steven Johnson <[email protected]>"

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.5.28 AS rust-ci
3+
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.6.0 AS rust-ci
44
IMPORT ../ AS repo-ci
55
IMPORT github.com/input-output-hk/catalyst-voices/catalyst-gateway:main AS cat-gateway-main
66

catalyst-gateway/bin/src/build_info.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ pub(crate) fn log_build_info() {
4848
let mut branch = "Unknown".to_string();
4949
let mut tags = "Unknown".to_string();
5050

51-
if let Some(ref vc) = info.version_control {
52-
if let Some(git) = vc.git() {
53-
commit_id.clone_from(&git.commit_short_id);
54-
commit_timestamp = git.commit_timestamp.to_rfc3339();
55-
if let Some(git_branch) = git.branch.clone() {
56-
branch = git_branch;
57-
}
58-
tags = git.tags.join(",");
51+
if let Some(ref vc) = info.version_control
52+
&& let Some(git) = vc.git()
53+
{
54+
commit_id.clone_from(&git.commit_short_id);
55+
commit_timestamp = git.commit_timestamp.to_rfc3339();
56+
if let Some(git_branch) = git.branch.clone() {
57+
branch = git_branch;
5958
}
59+
tags = git.tags.join(",");
6060
}
6161

6262
let ipv4 = utilities::net::get_public_ipv4().to_string();
@@ -65,15 +65,15 @@ pub(crate) fn log_build_info() {
6565
let mut interfaces: String = "Unknown".to_string();
6666

6767
// Get local IP address v4 and v6
68-
if let Ok(network_interfaces) = list_afinet_netifas() {
69-
if !network_interfaces.is_empty() {
70-
interfaces.clear();
71-
for iface in network_interfaces {
72-
if !interfaces.is_empty() {
73-
interfaces.push(',');
74-
}
75-
let _ = write!(interfaces, "{}:{}", iface.0, iface.1);
68+
if let Ok(network_interfaces) = list_afinet_netifas()
69+
&& !network_interfaces.is_empty()
70+
{
71+
interfaces.clear();
72+
for iface in network_interfaces {
73+
if !interfaces.is_empty() {
74+
interfaces.push(',');
7675
}
76+
let _ = write!(interfaces, "{}:{}", iface.0, iface.1);
7777
}
7878
}
7979

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{collections::BTreeSet, fmt::Display, sync::Arc, time::Duration};
44

55
use cardano_chain_follower::{ChainFollower, ChainSyncConfig, MultiEraBlock, Network, Point, Slot};
66
use duration_string::DurationString;
7-
use futures::{stream::FuturesUnordered, StreamExt};
7+
use futures::{StreamExt, stream::FuturesUnordered};
88
use rand::{Rng, SeedableRng};
99
use tokio::sync::watch;
1010
use tracing::{debug, error, info};
@@ -16,7 +16,7 @@ use crate::{
1616
roll_forward::{self, PurgeCondition},
1717
},
1818
queries::sync_status::{
19-
get::{get_sync_status, SyncStatus},
19+
get::{SyncStatus, get_sync_status},
2020
update::update_sync_status,
2121
},
2222
session::CassandraSession,
@@ -25,7 +25,7 @@ use crate::{
2525
service::utilities::health::{
2626
set_follower_immutable_first_reached_tip, set_follower_live_first_reached_tip,
2727
},
28-
settings::{chain_follower, Settings},
28+
settings::{Settings, chain_follower},
2929
};
3030

3131
/// How long we wait between checks for connection to the indexing DB to be ready.

catalyst-gateway/bin/src/db/event/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
use std::{
33
str::FromStr,
44
sync::{
5-
atomic::{AtomicBool, Ordering},
65
Arc, LazyLock, Mutex, OnceLock,
6+
atomic::{AtomicBool, Ordering},
77
},
88
time::Duration,
99
};
1010

1111
use error::NotFoundError;
1212
use futures::{Stream, StreamExt, TryStreamExt};
1313
use tokio::task::JoinHandle;
14-
use tokio_postgres::{types::ToSql, Row};
15-
use tracing::{debug, debug_span, error, info, Instrument};
14+
use tokio_postgres::{Row, types::ToSql};
15+
use tracing::{Instrument, debug, debug_span, error, info};
1616

1717
use crate::{
1818
service::utilities::health::{event_db_is_live, set_event_db_liveness},
@@ -58,8 +58,8 @@ pub(crate) enum EventDBConnectionError {
5858

5959
impl EventDB {
6060
/// Get a connection from the pool.
61-
async fn get_pool_connection(
62-
) -> Result<deadpool::managed::Object<deadpool_postgres::Manager>, EventDBConnectionError> {
61+
async fn get_pool_connection()
62+
-> Result<deadpool::managed::Object<deadpool_postgres::Manager>, EventDBConnectionError> {
6363
let pool = EVENT_DB_POOL
6464
.get()
6565
.ok_or(EventDBConnectionError::DbPoolUninitialized)?;
@@ -127,7 +127,7 @@ impl EventDB {
127127
pub(crate) async fn query_stream(
128128
stmt: &str,
129129
params: &[&(dyn ToSql + Sync)],
130-
) -> anyhow::Result<impl Stream<Item = anyhow::Result<Row>>> {
130+
) -> anyhow::Result<impl Stream<Item = anyhow::Result<Row>> + use<>> {
131131
if Self::is_deep_query_enabled() {
132132
Self::explain_analyze_rollback(stmt, params).await?;
133133
}

catalyst-gateway/bin/src/db/event/schema_check/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
//! Check if the schema is up-to-date.
22
3-
use crate::db::event::{EventDB, DATABASE_SCHEMA_VERSION};
3+
use crate::db::event::{DATABASE_SCHEMA_VERSION, EventDB};
44

55
/// Schema in database does not match schema supported by the Crate.
66
#[derive(thiserror::Error, Debug, PartialEq, Eq)]
7-
#[error(" Schema in database does not match schema supported by the Crate. The current schema version: {was}, the schema version we expected: {expected}")]
7+
#[error(
8+
" Schema in database does not match schema supported by the Crate. The current schema version: {was}, the schema version we expected: {expected}"
9+
)]
810
pub(crate) struct MismatchedSchemaError {
911
/// The current DB schema version.
1012
was: i32,

catalyst-gateway/bin/src/db/event/signed_docs/full_signed_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use anyhow::Context;
55
use super::SignedDocBody;
66
use crate::{
77
db::event::{EventDB, EventDBConnectionError},
8-
jinja::{get_template, JinjaTemplateSource},
8+
jinja::{JinjaTemplateSource, get_template},
99
};
1010

1111
/// Insert sql query

catalyst-gateway/bin/src/db/event/signed_docs/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ mod signed_doc_body;
88
mod tests;
99

1010
pub(crate) use doc_ref::DocumentRef;
11-
pub(crate) use full_signed_doc::{FullSignedDoc, StoreError, SELECT_SIGNED_DOCS_TEMPLATE};
11+
pub(crate) use full_signed_doc::{FullSignedDoc, SELECT_SIGNED_DOCS_TEMPLATE, StoreError};
1212
pub(crate) use query_filter::DocsQueryFilter;
1313
pub(crate) use signed_doc_body::{
14-
SignedDocBody, FILTERED_COUNT_SIGNED_DOCS_TEMPLATE, FILTERED_SELECT_SIGNED_DOCS_TEMPLATE,
14+
FILTERED_COUNT_SIGNED_DOCS_TEMPLATE, FILTERED_SELECT_SIGNED_DOCS_TEMPLATE, SignedDocBody,
1515
};

catalyst-gateway/bin/src/db/event/signed_docs/signed_doc_body.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use futures::{Stream, StreamExt};
44

55
use super::DocsQueryFilter;
66
use crate::{
7-
db::event::{common::query_limits::QueryLimits, error::NotFoundError, EventDB},
8-
jinja::{get_template, JinjaTemplateSource},
7+
db::event::{EventDB, common::query_limits::QueryLimits, error::NotFoundError},
8+
jinja::{JinjaTemplateSource, get_template},
99
};
1010

1111
/// Filtered select sql query jinja template

0 commit comments

Comments
 (0)