Skip to content

Commit

Permalink
Merge branch 'mve3' into feat/proposal-template-models
Browse files Browse the repository at this point in the history
# Conflicts:
#	catalyst-gateway/bin/Cargo.toml
  • Loading branch information
dtscalac committed Dec 23, 2024
2 parents cfdd91d + 6cbe94c commit 5141c75
Show file tree
Hide file tree
Showing 90 changed files with 2,927 additions and 779 deletions.
6 changes: 6 additions & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ delegators
devnet
DIND
dockerhub
domcontentloaded
Dominik
dotenv
dotenvy
Expand Down Expand Up @@ -194,6 +195,7 @@ netifas
netkey
nextest
Nodetool
NuFi
oapi
OCSP
Oleksandr
Expand All @@ -202,6 +204,7 @@ oneshot
openapi
opentelemetry
overprovisioned
pageobject
Pbkdf2
pbxproj
Pdart
Expand All @@ -221,6 +224,7 @@ projectcatalyst
Prokhorenko
proptest
psql
psycopg
Ptarget
pubkey
PUBLICKEY
Expand Down Expand Up @@ -280,6 +284,7 @@ tablestats
tacho
testcov
testdocs
testid
testplan
testunit
thiserror
Expand All @@ -290,6 +295,7 @@ Toastify
todos
toggleable
tojunit
tomjs
Traceback
traefik
trailings
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ permissions:

jobs:
ci:
uses: input-output-hk/catalyst-forge/.github/workflows/ci.yml@ci/v1.2.2
uses: input-output-hk/catalyst-forge/.github/workflows/ci.yml@ci/v1.5.0
with:
forge_version: 0.5.0
forge_version: 0.8.0

test_reporting:
if: always()
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,40 @@ jobs:
- uses: actions/checkout@v4

- name: Install Forge
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.2.2
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.5.0
with:
version: 0.5.0
version: 0.8.0
if: always()

- name: Setup CI
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.2.2
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.5.0

- name: Get catalyst gateway unit test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.2.2
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.0
if: always()
continue-on-error: true
with:
command: run
args: ./catalyst-gateway+build

- name: Get schemathesis test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.2.2
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.0
if: always()
continue-on-error: true
with:
command: run
args: ./catalyst-gateway/tests/schemathesis_tests+test-fuzzer-api

- name: Get flutter unit test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.2.2
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.0
if: always()
continue-on-error: true
with:
command: run
args: ./catalyst_voices+test-unit

- name: Get python api test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.2.2
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.0
if: always()
continue-on-error: true
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:

- name: Send Slack notification
if: ${{ always() && steps.allure.outputs.report_url }}
uses: slackapi/slack-github-action@v1.27.0
uses: slackapi/slack-github-action@v2.0.0
with:
payload: |
{
Expand Down
10 changes: 5 additions & 5 deletions blueprint.cue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ global: {
"^test(-.*)?$",
]
registries: [
ci.providers.aws.registry,
ci.providers.aws.ecr.registry,
]
providers: {
aws: {
region: "eu-central-1"
registry: "332405224602.dkr.ecr.eu-central-1.amazonaws.com"
role: "arn:aws:iam::332405224602:role/ci"
region: "eu-central-1"
ecr: registry: "332405224602.dkr.ecr.eu-central-1.amazonaws.com"
role: "arn:aws:iam::332405224602:role/ci"
}

docker: credentials: {
Expand Down Expand Up @@ -49,7 +49,7 @@ global: {
]
}
deployment: {
registry: ci.providers.aws.registry
registry: ci.providers.aws.ecr.registry
repo: {
url: "https://github.com/input-output-hk/catalyst-world"
ref: "master"
Expand Down
16 changes: 16 additions & 0 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,19 @@ check-builder-src-cache:
RUN diff ../src_fingerprint.txt ../src_fingerprint_uncached.txt \
|| (echo "ERROR: Source fingerprints do not match. Caching Error Detected!!" && exit 1) \
&& echo "Source fingerprints match. Caching OK."

test:
FROM +builder-src

COPY docker-compose.yml .

ENV EVENT_DB_URL "postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev"

WITH DOCKER \
--compose "./docker-compose.yml" \
--load ./event-db+build \
--pull alpine:3.20.3 \
--service event-db-is-running
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \
cargo nextest run --release --run-ignored=only signed_docs
END
5 changes: 3 additions & 2 deletions catalyst-gateway/bin/src/db/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ pub(crate) mod config;
pub(crate) mod error;
pub(crate) mod legacy;
pub(crate) mod schema_check;
pub(crate) mod signed_docs;

/// Database version this crate matches.
/// Must equal the last Migrations Version Number from `event-db/migrations`.
pub(crate) const DATABASE_SCHEMA_VERSION: i32 = 9;
pub(crate) const DATABASE_SCHEMA_VERSION: i32 = 2;

/// Postgres Connection Manager DB Pool
type SqlDbPool = Arc<Pool<PostgresConnectionManager<NoTls>>>;
Expand Down Expand Up @@ -212,7 +213,7 @@ impl EventDB {
///
/// The env var "`DATABASE_URL`" can be set directly as an anv var, or in a
/// `.env` file.
pub(crate) fn establish_connection() {
pub fn establish_connection() {
let (url, user, pass) = Settings::event_db_settings();

// This was pre-validated and can't fail, but provide default in the impossible case it
Expand Down
32 changes: 32 additions & 0 deletions catalyst-gateway/bin/src/db/event/signed_docs/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! Signed docs queries
#[cfg(test)]
mod tests;

use super::EventDB;

/// Insert sql query
const INSERT_SIGNED_DOCS: &str = include_str!("./sql/insert_signed_documents.sql");

/// Make an insert query into the `event-db` by adding data into the `signed_docs` table
///
/// * IF the record primary key (id,ver) does not exist, then add the new record. Return
/// success.
/// * IF the record does exist, but all values are the same as stored, return Success.
/// * Otherwise return an error. (Can not over-write an existing record with new data).
///
/// # Arguments:
/// - `id` is a UUID v7
/// - `ver` is a UUID v7
/// - `doc_type` is a UUID v4
#[allow(dead_code)]
pub(crate) async fn insert_signed_docs(
id: &uuid::Uuid, ver: &uuid::Uuid, doc_type: &uuid::Uuid, author: &String,
metadata: &Option<serde_json::Value>, payload: &Option<serde_json::Value>, raw: &Vec<u8>,
) -> anyhow::Result<()> {
EventDB::modify(INSERT_SIGNED_DOCS, &[
id, ver, doc_type, author, metadata, payload, raw,
])
.await?;
Ok(())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
INSERT INTO signed_docs
(
id,
ver,
type,
author,
metadata,
payload,
raw
)
VALUES
($1, $2, $3, $4, $5, $6, $7)
50 changes: 50 additions & 0 deletions catalyst-gateway/bin/src/db/event/signed_docs/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//! Integration tests of the `signed docs` queries
use super::*;
use crate::db::event::establish_connection;

#[ignore = "An integration test which requires a running EventDB instance, disabled from `testunit` CI run"]
#[tokio::test]
async fn some_test() {
establish_connection();

let docs = [
(
uuid::Uuid::now_v7(),
uuid::Uuid::now_v7(),
uuid::Uuid::new_v4(),
"Alex".to_string(),
&Some(serde_json::Value::Null),
&Some(serde_json::Value::Null),
vec![1, 2, 3, 4],
),
(
uuid::Uuid::now_v7(),
uuid::Uuid::now_v7(),
uuid::Uuid::new_v4(),
"Steven".to_string(),
&Some(serde_json::Value::Null),
&Some(serde_json::Value::Null),
vec![5, 6, 7, 8],
),
(
uuid::Uuid::now_v7(),
uuid::Uuid::now_v7(),
uuid::Uuid::new_v4(),
"Sasha".to_string(),
&None,
&None,
vec![9, 10, 11, 12],
),
];

for (id, ver, doc_type, author, metadata, payload, raw) in &docs {
insert_signed_docs(id, ver, doc_type, author, metadata, payload, raw)
.await
.unwrap();
// // try to insert the same data again
// insert_signed_docs(id, ver, doc_type, author, metadata, payload, raw)
// .await
// .unwrap();
}
}
11 changes: 4 additions & 7 deletions catalyst-gateway/bin/src/db/index/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,10 @@ pub(crate) async fn index_block(block: &MultiEraBlock) -> anyhow::Result<()> {
}
match handle.await {
Ok(join_res) => {
match join_res {
Ok(_res) => {}, // debug!(res=?res,"Query OK")
Err(error) => {
// IF a query fails, assume everything else is broken.
error!(error=%error,"Query Failed");
result = Err(error);
},
if let Err(error) = join_res {
// IF a query fails, assume everything else is broken.
error!(error=%error,"Query Failed");
result = Err(error);
}
},
Err(error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const INSERT_CHAIN_ROOT_FOR_STAKE_ADDRESS_QUERY: &str =
#[derive(SerializeRow)]
pub(super) struct Params {
/// Stake Address Hash. 32 bytes.
stake_address: Vec<u8>,
stake_addr: Vec<u8>,
/// Block Slot Number
slot_no: num_bigint::BigInt,
/// Transaction Offset inside the block.
Expand All @@ -29,7 +29,7 @@ pub(super) struct Params {
impl Debug for Params {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Params")
.field("stake_address", &self.stake_address)
.field("stake_addr", &self.stake_addr)
.field("slot_no", &self.slot_no)
.field("txn", &self.txn)
.field("chain_root", &self.chain_root)
Expand All @@ -39,9 +39,9 @@ impl Debug for Params {

impl Params {
/// Create a new record for this transaction.
pub(super) fn new(stake_address: &[u8], chain_root: &[u8], slot_no: u64, txn: i16) -> Self {
pub(super) fn new(stake_addr: &[u8], chain_root: &[u8], slot_no: u64, txn: i16) -> Self {
Params {
stake_address: stake_address.to_vec(),
stake_addr: stake_addr.to_vec(),
slot_no: num_bigint::BigInt::from(slot_no),
txn,
chain_root: chain_root.to_vec(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::{fmt::Debug, sync::Arc};

use cardano_chain_follower::Metadata::cip509::Cip509;
use rbac_registration::cardano::cip509::Cip509;
use scylla::{frame::value::MaybeUnset, SerializeRow, Session};
use tracing::error;

Expand Down Expand Up @@ -56,7 +56,7 @@ impl Params {
Params {
chain_root: chain_root.to_vec(),
transaction_id: transaction_id.to_vec(),
purpose: cip509.purpose.to_vec(),
purpose: cip509.purpose.into(),
slot_no: num_bigint::BigInt::from(slot_no),
txn,
prv_txn_id: if let Some(tx_id) = cip509.prv_tx_id {
Expand Down
Loading

0 comments on commit 5141c75

Please sign in to comment.