Skip to content

Commit 3db8f17

Browse files
minikincoire1kukkok3dtscalacdependabot[bot]
authored
feat: merge m3 (#426)
* docs: Add CatalystDataGatewayRepository docs (#388) * test: Fix tests after cat-gateway update. * docs: Add `CatalystDataGatewayRepository` usage examples. * docs: Move docs from README to code comment. * test: Update `CatalystDataGatewayRepository` tests. * test: Use Fake instead of Mock. * chore: Fix Markdown errors. * chore: Explicit use of `HttpStatus` codes. * adds one more worker and compression for catgateway logs (#400) * feat: Collect flutter code coverage (#404) * test: Fix tests after cat-gateway update. * docs: Add `CatalystDataGatewayRepository` usage examples. * docs: Move docs from README to code comment. * test: Update `CatalystDataGatewayRepository` tests. * test: Use Fake instead of Mock. * chore: Fix Markdown errors. * chore: Explicit use of `HttpStatus` codes. * chore(deps-dev): bump vite in /utilities/wallet-tester (#397) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.1.6 to 5.1.7. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v5.1.7/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.1.7/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Apisit Ritreungroj <[email protected]> * feat: Get slot number by provided date-time endpoint (#387) * fix CardanoStakeAddress error handling * refactor, add sync_state_get endpoint * refactor types * refactor * add block_hash validation * wip * wip * wip * wip * add check_network fn * fix * fix schematisis test * try * wip * try * try * try * try * wip * try * try * fix * update Network * add test_utxo test * try * fix * try * fix * wip * fix * fix docket-compose.yml file * try * try * fix * try * try * try * try * wip * fix * wip * try * try * wip * try * try * revert * wip * wip * wip * fix * fix * fix * remove mithril_snapshot loader * wip * wip * wip * wip * wip * wip * wip * add stake addr bech32 encode utils function * wip * wip * update indexing of the utxo data * fix spelling * wip * wip * finish utxo test * fix deny * fix check * fix * fix * update earthly builder versions * wip * ignore test_utxo.py in CI * dont ignore tests * add date_time_to_slot_number_get endpoint * add sql queries * fix * update slot info, fix follower indexing block time issue * add previous slot info field * fix * refactor * fix sync_state_get * wip * fix check * try * fix * finish slot_info test, fix queries * fix * cleanup * wip * wip * wip * feat: RBAC Documentation Drafting (#332) * chore: wip * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * Update 0005-flutter-app.md * docs(docs): Use latest docs builders and fix concepts page * docs(cips): Start drafting the CIPS for milestone 2 * docs(cips): More text for RBAC metadata draft * docs(cips): WIP updates to draft cip for role registration * docs(cips): define draft specification for a ULID cbor tag * docs(cips): Further WIP edits to RBAC * docs(cips): fix ulid spec binary encoding reference * docs(cips): Add a tag to the epoch time. * docs(cips): Add CBOR tag cip for ED25519-BIP32 Keys, Derivation paths and Signatures * docs(cips): Properly define the field tags to use where known, and clean up Stake Address specification. * docs(cips): Fix nonce so its reliable without needing blockchain data * docs(cips): updates * docs(docs): Add CDDL definition for POC x509 envelope metadata * fix(vscode): update vscode extension recommendations * docs(cips): rbac x509 envelope fix * docs(cips): wip updates to high level docs * docs(cips): Add overview of cardano transaction processign and data * docs(cips): update cardano block to be complete for clarity * docs(cips): fix layout engine * docs(cips): wip cddl for envelope metadata * docs(cips): Add cddl specs and diagrams for x509 rbac registration work * docs(cips): Add full transaction/metadata relationship diagram * refactor(cips): reorganize documentation ready for drafting descriptive prose about the formats and uses * docs(cips): add cip draft for catalyst roles using the x509-rbac standard * docs(cips): Add c509 cddl with restrictions and enhancements for plutus usage * docs(cips): Metadata envelope specification draft complete * Update docs/src/catalyst-standards/draft-cips/c509-plutus-restricted-certificate/c509-cert-plutus-restricted.cddl Co-authored-by: bkioshn <[email protected]> * Update docs/src/catalyst-standards/draft-cips/c509-plutus-restricted-certificate/c509-cert-plutus-restricted.cddl Co-authored-by: bkioshn <[email protected]> * Update docs/src/catalyst-standards/draft-cips/x509-role-registration-metadata/x509-roles.cddl Co-authored-by: bkioshn <[email protected]> * Update docs/src/catalyst-standards/draft-cips/x509-role-registration-metadata/x509-roles.cddl Co-authored-by: bkioshn <[email protected]> * Update docs/src/catalyst-standards/draft-cips/x509-envelope-metadata/x509-envelope.cddl Co-authored-by: bkioshn <[email protected]> * Update docs/src/catalyst-standards/draft-cips/x509-envelope-metadata/x509-envelope.cddl Co-authored-by: bkioshn <[email protected]> * Update docs/src/catalyst-standards/draft-cips/x509-envelope-metadata/x509-envelope.cddl Co-authored-by: bkioshn <[email protected]> * Update docs/src/catalyst-standards/draft-cips/c509-plutus-restricted-certificate/c509-cert-plutus-restricted.cddl Co-authored-by: bkioshn <[email protected]> * docs(cips): Fix time and algorithm comments * build(frontend): Relax flutter/dart version requirements to last minor release * docs(cips): wip * fix(cips): rename draft x509 envelope CIP so its easier to identify * docs(cips): WIP updates to x509 roles * fix(cips): rename RBAC definition CIP draft so its easier to identify * docs(cips): x509 certificate registration format fully defined * docs(cips): Document the restricted plutus subset. * docs(cips): Add document detailing how CIP-30 is used to sign the transaction * fix(cips): remove trailing spaces * fix(cips): Fix line lengths * fix(cips): Correct spelling * fix(cips): spelling * fix(frontend): revert changes to flutter/dart versions * fix(frontend): more flutter/dart version corrections * fix(frontend): Revert flutter files to same as main branch * fix(frontend): revert more flutter .yml files to those in main * fix(cips): Fix links between files * docs(cips): Add catalyst specific role registration documentation * docs(spelling): fix spelling --------- Co-authored-by: minikin <[email protected]> Co-authored-by: bkioshn <[email protected]> * ci: configure static analysis & code formatting check * style: formatting * fix: revert browser installation scripts * style: format code * ci: optimize directions include in repo-catalyst-voices-all artifact to include only needed ones * refactor: remove empty tests * ci: add melos script to generate test reports * ci: melos script to generate test report * style: revert previously generated files formatting * style: format files * ci: update melos to exclude generated code form code coverage * ci: cleanup build script * ci: generate multiple junit test reports and save them at /test_reports * ci: depend on melos analyze instead of custom command * docs: improve melos docs * ci: remove unused melos scripts * ci: format files in test & integration_test directories * ci: break code to make sure CI will report failure for demonstration purposes * style: fix lint issues * ci: change WORKDIR after creating the user to make sure it will be owned by that user * ci: restore root user * Revert "Merge branch 'main' into feat/collect-flutter-code-coverage" This reverts commit d0f66b2, reversing changes made to 39ce401. * style: format code * ci: revert test-unit target name --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Lucio Baglione <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Apisit Ritreungroj <[email protected]> Co-authored-by: Alex Pozhylenkov <[email protected]> Co-authored-by: Steven Johnson <[email protected]> Co-authored-by: minikin <[email protected]> Co-authored-by: bkioshn <[email protected]> * refactor: update schema_validation check (#414) * update schema_validation check * wip * fix --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Lucio Baglione <[email protected]> Co-authored-by: Stefano Cunego <[email protected]> Co-authored-by: Dominik Toton <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Apisit Ritreungroj <[email protected]> Co-authored-by: Alex Pozhylenkov <[email protected]> Co-authored-by: Steven Johnson <[email protected]> Co-authored-by: bkioshn <[email protected]>
1 parent 7ca47b1 commit 3db8f17

File tree

42 files changed

+651
-875
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

+651
-875
lines changed

.github/workflows/generate-allure-report.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
with:
6868
earthfile: ./catalyst_voices/
6969
flags:
70-
targets: test-unit
70+
targets: test-report
7171
target_flags:
7272
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
7373
artifact: "false"

Earthfile

+10
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,14 @@ repo-catalyst-voices-packages:
4444
WORKDIR /repo
4545
COPY --dir catalyst_voices_packages .
4646

47+
SAVE ARTIFACT /repo repo
48+
49+
# repo-catalyst-voices-all - Creates artifacts of all configuration files,
50+
# packages and folders related to catalyst_voices frontend.
51+
repo-catalyst-voices-all:
52+
FROM scratch
53+
54+
WORKDIR /repo
55+
COPY --dir catalyst_voices catalyst_voices_packages utilities melos.yaml pubspec.yaml .
56+
4757
SAVE ARTIFACT /repo repo

catalyst-gateway/bin/src/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Cli {
5858
let machine_id = settings.follower_settings.machine_uid;
5959

6060
let state = Arc::new(State::new(Some(settings.database_url)).await?);
61-
let event_db = state.event_db()?;
61+
let event_db = state.event_db();
6262

6363
tokio::spawn(async move {
6464
match service::run(&settings.docs_settings, state.clone()).await {

catalyst-gateway/bin/src/event_db/error.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Database Errors
2-
use std::env::VarError;
32
43
use bb8::RunError;
54

@@ -26,9 +25,6 @@ pub(crate) enum Error {
2625
/// Unknown error
2726
#[error("error: {0}")]
2827
Unknown(String),
29-
/// Variable error
30-
#[error(transparent)]
31-
VarErr(#[from] VarError),
3228
/// No config
3329
#[error("No config")]
3430
NoConfig,

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

+2-10
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ pub(crate) struct EventDB {
5454
///
5555
/// The env var "`DATABASE_URL`" can be set directly as an anv var, or in a
5656
/// `.env` file.
57-
pub(crate) async fn establish_connection(
58-
url: Option<String>, do_schema_check: bool,
59-
) -> Result<EventDB, Error> {
57+
pub(crate) async fn establish_connection(url: Option<String>) -> Result<EventDB, Error> {
6058
// Support env vars in a `.env` file, doesn't need to exist.
6159
dotenv().ok();
6260

@@ -72,11 +70,5 @@ pub(crate) async fn establish_connection(
7270

7371
let pool = Pool::builder().build(pg_mgr).await?;
7472

75-
let db = EventDB { pool };
76-
77-
if do_schema_check {
78-
db.schema_version_check().await?;
79-
}
80-
81-
Ok(db)
73+
Ok(EventDB { pool })
8274
}

catalyst-gateway/bin/src/service/api/cardano/date_time_to_slot_number_get.rs

+3-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//! Implementation of the GET `/date_time_to_slot_number` endpoint
22
3-
use poem_extensions::{
4-
response,
5-
UniResponse::{T200, T503},
6-
};
3+
use poem_extensions::{response, UniResponse::T200};
74
use poem_openapi::payload::Json;
85

96
use crate::{
10-
cli::Error,
117
event_db::{
128
error::Error as DBError,
139
follower::{DateTime, SlotInfoQueryType},
@@ -23,7 +19,7 @@ use crate::{
2319
resp_5xx::{server_error_response, ServerError, ServiceUnavailable},
2420
},
2521
},
26-
state::{SchemaVersionStatus, State},
22+
state::State,
2723
};
2824

2925
/// # All Responses
@@ -39,19 +35,7 @@ pub(crate) type AllResponses = response! {
3935
pub(crate) async fn endpoint(
4036
state: &State, date_time: Option<DateTime>, network: Option<Network>,
4137
) -> AllResponses {
42-
let event_db = match state.event_db() {
43-
Ok(event_db) => event_db,
44-
Err(Error::EventDb(DBError::MismatchedSchema { was, expected })) => {
45-
tracing::error!(
46-
expected = expected,
47-
current = was,
48-
"DB schema version status mismatch"
49-
);
50-
state.set_schema_version_status(SchemaVersionStatus::Mismatch);
51-
return T503(ServiceUnavailable);
52-
},
53-
Err(err) => return server_error_response!("{err}"),
54-
};
38+
let event_db = state.event_db();
5539

5640
let date_time = date_time.unwrap_or_else(chrono::Utc::now);
5741
let network = network.unwrap_or(Network::Mainnet);

catalyst-gateway/bin/src/service/api/cardano/registration_get.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
33
use poem_extensions::{
44
response,
5-
UniResponse::{T200, T400, T404, T503},
5+
UniResponse::{T200, T400, T404},
66
};
77
use poem_openapi::payload::Json;
88

99
use crate::{
10-
cli::Error,
1110
event_db::{error::Error as DBError, follower::SlotNumber},
1211
service::{
1312
common::{
@@ -22,7 +21,7 @@ use crate::{
2221
},
2322
utilities::check_network,
2423
},
25-
state::{SchemaVersionStatus, State},
24+
state::State,
2625
};
2726

2827
/// # All Responses
@@ -40,19 +39,8 @@ pub(crate) async fn endpoint(
4039
state: &State, stake_address: StakeAddress, provided_network: Option<Network>,
4140
slot_num: Option<SlotNumber>,
4241
) -> AllResponses {
43-
let event_db = match state.event_db() {
44-
Ok(event_db) => event_db,
45-
Err(Error::EventDb(DBError::MismatchedSchema { was, expected })) => {
46-
tracing::error!(
47-
expected = expected,
48-
current = was,
49-
"DB schema version status mismatch"
50-
);
51-
state.set_schema_version_status(SchemaVersionStatus::Mismatch);
52-
return T503(ServiceUnavailable);
53-
},
54-
Err(err) => return server_error_response!("{err}"),
55-
};
42+
let event_db = state.event_db();
43+
5644
let date_time = slot_num.unwrap_or(SlotNumber::MAX);
5745
let stake_credential = stake_address.payload().as_hash().to_vec();
5846
let network = match check_network(stake_address.network(), provided_network) {

catalyst-gateway/bin/src/service/api/cardano/staked_ada_get.rs

+3-16
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
33
use poem_extensions::{
44
response,
5-
UniResponse::{T200, T400, T404, T503},
5+
UniResponse::{T200, T400, T404},
66
};
77
use poem_openapi::payload::Json;
88

99
use crate::{
10-
cli::Error,
1110
event_db::{error::Error as DBError, follower::SlotNumber},
1211
service::{
1312
common::{
@@ -22,7 +21,7 @@ use crate::{
2221
},
2322
utilities::check_network,
2423
},
25-
state::{SchemaVersionStatus, State},
24+
state::State,
2625
};
2726

2827
/// # All Responses
@@ -39,19 +38,7 @@ pub(crate) async fn endpoint(
3938
state: &State, stake_address: StakeAddress, provided_network: Option<Network>,
4039
slot_num: Option<SlotNumber>,
4140
) -> AllResponses {
42-
let event_db = match state.event_db() {
43-
Ok(event_db) => event_db,
44-
Err(Error::EventDb(DBError::MismatchedSchema { was, expected })) => {
45-
tracing::error!(
46-
expected = expected,
47-
current = was,
48-
"DB schema version status mismatch"
49-
);
50-
state.set_schema_version_status(SchemaVersionStatus::Mismatch);
51-
return T503(ServiceUnavailable);
52-
},
53-
Err(err) => return server_error_response!("{err}"),
54-
};
41+
let event_db = state.event_db();
5542

5643
let date_time = slot_num.unwrap_or(SlotNumber::MAX);
5744
let stake_credential = stake_address.payload().as_hash().to_vec();

catalyst-gateway/bin/src/service/api/cardano/sync_state_get.rs

+3-16
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
33
use poem_extensions::{
44
response,
5-
UniResponse::{T200, T404, T503},
5+
UniResponse::{T200, T404},
66
};
77
use poem_openapi::payload::Json;
88

99
use crate::{
10-
cli::Error,
1110
event_db::error::Error as DBError,
1211
service::common::{
1312
objects::cardano::{network::Network, sync_state::SyncState},
@@ -17,7 +16,7 @@ use crate::{
1716
resp_5xx::{server_error_response, ServerError, ServiceUnavailable},
1817
},
1918
},
20-
state::{SchemaVersionStatus, State},
19+
state::State,
2120
};
2221

2322
/// # All Responses
@@ -32,19 +31,7 @@ pub(crate) type AllResponses = response! {
3231
/// # GET `/sync_state`
3332
#[allow(clippy::unused_async)]
3433
pub(crate) async fn endpoint(state: &State, network: Option<Network>) -> AllResponses {
35-
let event_db = match state.event_db() {
36-
Ok(event_db) => event_db,
37-
Err(Error::EventDb(DBError::MismatchedSchema { was, expected })) => {
38-
tracing::error!(
39-
expected = expected,
40-
current = was,
41-
"DB schema version status mismatch"
42-
);
43-
state.set_schema_version_status(SchemaVersionStatus::Mismatch);
44-
return T503(ServiceUnavailable);
45-
},
46-
Err(err) => return server_error_response!("{err}"),
47-
};
34+
let event_db = state.event_db();
4835

4936
let network = network.unwrap_or(Network::Mainnet);
5037

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ use poem_extensions::{
99
};
1010

1111
use crate::{
12-
cli::Error,
1312
event_db::error::Error as DBError,
1413
service::common::responses::{
1514
resp_2xx::NoContent,
1615
resp_4xx::ApiValidationError,
1716
resp_5xx::{server_error_response, ServerError, ServiceUnavailable},
1817
},
19-
state::{SchemaVersionStatus, State},
18+
state::State,
2019
};
2120

2221
/// All responses
@@ -53,22 +52,20 @@ pub(crate) type AllResponses = response! {
5352
/// but unlikely)
5453
/// * 503 Service Unavailable - Service is not ready, do not send other requests.
5554
pub(crate) async fn endpoint(state: Data<&Arc<State>>) -> AllResponses {
56-
match state.schema_version_check().await {
55+
match state.event_db().schema_version_check().await {
5756
Ok(_) => {
5857
tracing::debug!("DB schema version status ok");
59-
state.set_schema_version_status(SchemaVersionStatus::Ok);
6058
T204(NoContent)
6159
},
62-
Err(Error::EventDb(DBError::MismatchedSchema { was, expected })) => {
60+
Err(DBError::MismatchedSchema { was, expected }) => {
6361
tracing::error!(
6462
expected = expected,
6563
current = was,
6664
"DB schema version status mismatch"
6765
);
68-
state.set_schema_version_status(SchemaVersionStatus::Mismatch);
6966
T503(ServiceUnavailable)
7067
},
71-
Err(Error::EventDb(DBError::TimedOut)) => T503(ServiceUnavailable),
68+
Err(DBError::TimedOut) => T503(ServiceUnavailable),
7269
Err(err) => server_error_response!("{err}"),
7370
}
7471
}

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

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ pub(crate) enum Error {
2323
/// An IO error has occurred
2424
#[error(transparent)]
2525
Io(#[from] std::io::Error),
26-
/// A mismatch in the expected `EventDB` schema version
27-
#[error("expected schema version mismatch")]
28-
SchemaVersionMismatch,
2926
}
3027

3128
/// # Run Catalyst Gateway Service.

catalyst-gateway/bin/src/service/utilities/middleware/schema_validation.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ use std::sync::Arc;
1111

1212
use poem::{web::Data, Endpoint, EndpointExt, Middleware, Request, Result};
1313

14-
use crate::{
15-
service::common::responses::resp_5xx::ServiceUnavailable,
16-
state::{SchemaVersionStatus, State},
17-
};
14+
use crate::{service::common::responses::resp_5xx::ServiceUnavailable, state::State};
1815

1916
/// A middleware that raises an error with `ServiceUnavailable` and 503 status code
2017
/// if a DB schema version mismatch is found the existing `State`.
@@ -44,7 +41,7 @@ impl<E: Endpoint> Endpoint for SchemaVersionValidationImpl<E> {
4441
// if so, return the `ServiceUnavailable` error, which implements
4542
// `ResponseError`, with status code `503`.
4643
// Otherwise, return the endpoint as usual.
47-
if state.is_schema_version_status(&SchemaVersionStatus::Mismatch) {
44+
if state.event_db().schema_version_check().await.is_err() {
4845
return Err(ServiceUnavailable.into());
4946
}
5047
}

0 commit comments

Comments
 (0)