Skip to content

Commit

Permalink
Merge branch 'feat/add-doc-endpoints' of github.com:input-output-hk/c…
Browse files Browse the repository at this point in the history
…atalyst-voices into feat/add-doc-endpoints
  • Loading branch information
stevenj committed Jan 8, 2025
2 parents 92b4296 + 1e9191b commit f5ef33e
Show file tree
Hide file tree
Showing 72 changed files with 3,426 additions and 2,053 deletions.
1 change: 1 addition & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ todos
toggleable
tojunit
tomjs
topbar
Traceback
traefik
trailings
Expand Down
29 changes: 8 additions & 21 deletions .github/workflows/flutter-uikit-example-firebase-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,25 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

env:
AWS_REGION: eu-central-1
AWS_ROLE_ARN: arn:aws:iam::332405224602:role/ci
EARTHLY_TARGET: docker
ECR_REGISTRY: 332405224602.dkr.ecr.eu-central-1.amazonaws.com

jobs:
deploy-uikit-example:
name: Deploy UIKit example on Firebase Hosting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup CI
uses: input-output-hk/catalyst-ci/actions/setup@master
- name: Install Forge
uses: input-output-hk/catalyst-forge/actions/install@ci/v1.5.0
with:
aws_role_arn: ${{ env.AWS_ROLE_ARN }}
aws_region: ${{ env.AWS_REGION }}
earthly_runner_secret: ${{ secrets.EARTHLY_RUNNER_SECRET }}

version: 0.8.0
- name: Setup CI
uses: input-output-hk/catalyst-forge/actions/setup@ci/v1.5.0
- name: Build Flutter Web
uses: input-output-hk/catalyst-ci/actions/run@master
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.5.0
if: always()
continue-on-error: true
with:
earthfile: ./catalyst_voices/utilities/uikit_example
flags: --allow-privileged
targets: local-build-web
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"

command: run
args: ./catalyst_voices/utilities/uikit_example+local-build-web
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
firebaseServiceAccount: "${{ secrets.UIKIT_FIREBASE_SERVICE_ACCOUNT }}"
Expand Down
3 changes: 2 additions & 1 deletion catalyst-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ panic = "deny"
string_slice = "deny"
unchecked_duration_subtraction = "deny"
unreachable = "deny"
missing_docs_in_private_items = "deny"
missing_docs_in_private_items = "deny"
arithmetic_side_effects = "deny"
2 changes: 1 addition & 1 deletion catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.27 AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.2.28 AS rust-ci

#cspell: words rustfmt toolsets USERARCH stdcfgs

Expand Down
2 changes: 1 addition & 1 deletion catalyst-gateway/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repository.workspace = true
workspace = true

[dependencies]
cardano-chain-follower = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.10" }
cardano-chain-follower = {version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag="v0.0.10" }
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.3" }
rbac-registration = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.8" }

Expand Down
21 changes: 13 additions & 8 deletions catalyst-gateway/bin/src/cardano/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl SyncParams {

/// Convert a result back into parameters for a retry.
fn retry(&self) -> Self {
let retry_count = self.retries + 1;
let retry_count = self.retries.saturating_add(1);

let mut backoff = None;

Expand Down Expand Up @@ -200,7 +200,7 @@ impl SyncParams {
done.first_is_immutable = first_immutable;
done.last_indexed_block = last;
done.last_is_immutable = last_immutable;
done.total_blocks_synced += synced;
done.total_blocks_synced = done.total_blocks_synced.saturating_add(synced);
done.last_blocks_synced = synced;

done.result = Arc::new(Some(result));
Expand Down Expand Up @@ -298,7 +298,7 @@ fn sync_subchain(params: SyncParams) -> tokio::task::JoinHandle<SyncParams> {
first_immutable = last_immutable;
first_indexed_block = Some(block.point());
}
blocks_synced += 1;
blocks_synced = blocks_synced.saturating_add(1);
},
cardano_chain_follower::Kind::Rollback => {
warn!("TODO: Live Chain rollback");
Expand Down Expand Up @@ -423,7 +423,11 @@ impl SyncTask {
} else if let Some(result) = finished.result.as_ref() {
match result {
Ok(()) => {
self.current_sync_tasks -= 1;
self.current_sync_tasks =
self.current_sync_tasks.checked_sub(1).unwrap_or_else(|| {
error!("current_sync_tasks -= 1 overflow");
0
});
info!(chain=%self.cfg.chain, report=%finished,
"The Immutable follower completed successfully.");

Expand Down Expand Up @@ -472,9 +476,10 @@ impl SyncTask {
if self.start_slot < self.immutable_tip_slot {
// Will also break if there are no more slots left to sync.
while self.current_sync_tasks < self.cfg.sync_tasks {
let end_slot = self
.immutable_tip_slot
.min(self.start_slot + self.cfg.sync_chunk_max_slots);
let end_slot = self.immutable_tip_slot.min(
self.start_slot
.saturating_add(self.cfg.sync_chunk_max_slots),
);

if let Some((first_point, last_point)) =
self.get_syncable_range(self.start_slot, end_slot)
Expand All @@ -484,7 +489,7 @@ impl SyncTask {
first_point,
last_point.clone(),
)));
self.current_sync_tasks += 1;
self.current_sync_tasks = self.current_sync_tasks.saturating_add(1);
}

// The one slot overlap is deliberate, it doesn't hurt anything and prevents all off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn merge_consecutive_sync_records(mut synced_chunks: Vec<SyncStatus>) -> Vec<Syn
// The new record is contained fully within the previous one.
// We will ignore the new record and use the previous one instead.
current_status = Some(current);
} else if rec.start_slot <= current.end_slot + 1 {
} else if rec.start_slot <= current.end_slot.saturating_add(1) {
// Either overlaps, or is directly consecutive.
// But not fully contained within the previous one.
current_status = Some(SyncStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,14 @@ fn build_stake_info(
for txn_map in txos_by_txn.into_values() {
for txo_info in txn_map.into_values() {
if txo_info.spent_slot_no.is_none() {
stake_info.ada_amount +=
i64::try_from(txo_info.value).map_err(|err| anyhow!(err))?;
let value = i64::try_from(txo_info.value).map_err(|err| anyhow!(err))?;
stake_info.ada_amount =
stake_info.ada_amount.checked_add(value).ok_or_else(|| {
anyhow!(
"Total stake amount overflow: {} + {value}",
stake_info.ada_amount
)
})?;

for asset in txo_info.assets.into_values().flatten() {
stake_info.native_tokens.push(StakedNativeTokenInfo {
Expand Down
8 changes: 7 additions & 1 deletion catalyst-gateway/bin/src/service/common/auth/rbac/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,13 @@ impl CatalystRBACTokenV1 {
// The token is considered old if it was issued more than max_age ago.
// And newer than an allowed clock skew value
// This is a safety measure to avoid replay attacks.
((now - max_age) < token_age) && ((now + max_skew) > token_age)
let Some(min_time) = now.checked_sub(max_age) else {
return false;
};
let Some(max_time) = now.checked_add(max_skew) else {
return false;
};
(min_time < token_age) && (max_time > token_age)
}
}

Expand Down
7 changes: 6 additions & 1 deletion catalyst-gateway/bin/src/settings/chain_follower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ impl EnvVars {
default_dl_chunk_size,
1,
MAX_DL_CHUNK_SIZE,
) * ONE_MEGABYTE;
)
.checked_mul(ONE_MEGABYTE)
.unwrap_or_else(|| {
info!("Too big 'CHAIN_FOLLOWER_DL_CHUNK_SIZE' value, default value {default_dl_chunk_size} is used");
default_dl_chunk_size
});
dl_config = dl_config.with_chunk_size(chunk_size);

let queue_ahead = StringEnvVar::new_as(
Expand Down
1 change: 1 addition & 0 deletions catalyst-gateway/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
allow-unwrap-in-tests = true
allow-expect-in-tests = true
allow-panic-in-tests = true
arithmetic-side-effects-allowed = ["num_bigint::BigInt"]
18 changes: 0 additions & 18 deletions catalyst-gateway/event-db/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.2.27 AS postgresql-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:v3.2.27 AS python-ci

# cspell: words

Expand Down Expand Up @@ -41,20 +40,3 @@ local:
IF [ "$local_registry" != "" ]
SAVE IMAGE --push --insecure $local_registry/event-db:latest
END

# Run the queries_tests.py
test:
FROM python-ci+python-base

DO python-ci+BUILDER
COPY --dir tests .
COPY --dir queries .

WITH DOCKER \
--compose "./tests/docker-compose.yml" \
--load event-db:latest=+build \
--pull alpine:3.20.3 \
--service event-db-is-running \
--allow-privileged
RUN poetry run pytest -s -m ci
END
5 changes: 0 additions & 5 deletions catalyst-gateway/event-db/blueprint.cue
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
version: "1.0.0"
project: {
name: "gateway-event-db"
ci: {
targets: {
test: privileged: true
}
}
}
Loading

0 comments on commit f5ef33e

Please sign in to comment.