Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/add-initial-bran…
Browse files Browse the repository at this point in the history
…d-support
  • Loading branch information
coire1 committed May 6, 2024
2 parents 7b6d187 + 424975e commit 6351156
Show file tree
Hide file tree
Showing 105 changed files with 1,816 additions and 1,449 deletions.
3 changes: 3 additions & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ netifas
netkey
nextest
Oleksandr
onboarded
oneshot
openapi
opentelemetry
Expand Down Expand Up @@ -185,3 +186,5 @@ xctest
xctestrun
xcworkspace
yoroi
multiplatform
Multiplatform
2 changes: 1 addition & 1 deletion .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
with:
earthfile: ./catalyst_voices/
flags:
targets: test-report
targets: test-unit
target_flags:
runner_address: ${{ secrets.EARTHLY_SATELLITE_ADDRESS }}
artifact: "false"
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ pubspec.lock
coverage/
.idea/

# Melos
*pubspec_overrides.yaml
melos*.iml

# Secrets
dev-catalyst-voice-9f78f27c6bc5.json

Expand Down
12 changes: 0 additions & 12 deletions catalyst-gateway/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion catalyst-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ dotenvy = "0.15"
local-ip-address = "0.5.7"
gethostname = "0.4.3"
hex = "0.4.3"
async-recursion = "1.0.5"
handlebars = "5.1.2"
anyhow = "1.0.71"
cddl = "0.9.2"
Expand Down
36 changes: 18 additions & 18 deletions catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ builder:
DO github.com/input-output-hk/catalyst-ci/earthly/rust:v2.11.1+SETUP

COPY --dir .cargo .config Cargo.* clippy.toml deny.toml rustfmt.toml bin crates .
COPY --dir ./event-db/queries ./event-db/queries

## -----------------------------------------------------------------------------
##
Expand All @@ -32,8 +31,9 @@ build:
FROM +builder

TRY
RUN /scripts/std_build.py --cov_report="coverage-report.info" \
--bins="cat-gateway/cat-gateway"
RUN /scripts/std_build.py \
--cov_report="coverage-report.info" \
--bins="cat-gateway/cat-gateway"
FINALLY
SAVE ARTIFACT --if-exists target/nextest/ci/junit.xml AS LOCAL cat-gateway.junit-report.xml
SAVE ARTIFACT --if-exists coverage-report.info AS LOCAL cat-gateway.coverage-report.info
Expand All @@ -48,29 +48,29 @@ all-hosts-build:
BUILD --platform=linux/amd64 --platform=linux/arm64 +build

package-cat-gateway:
ARG tag="latest"

FROM alpine:3.19
WORKDIR /cat-gateway

RUN apk add --no-cache gcc bash

COPY +build/cat-gateway .
COPY ./scripts/entry.sh .

ENTRYPOINT ./entry.sh
SAVE IMAGE cat-gateway:$tag

package-cat-gateway-with-preprod-snapshot:
ARG tag="latest"
ARG address
ARG db_url
ARG log_level="error"

RUN apk add --no-cache gcc
FROM +package-cat-gateway

COPY +build/cat-gateway .
# copy preprod mithril snapshot to /tmp/preprod dir
COPY github.com/input-output-hk/catalyst-ci/earthly/mithril_snapshot:v2.11.1+package-preprod-snapshot/snapshot /tmp/preprod

ENTRYPOINT ./cat-gateway run --address $address --database-url $db_url --log-level $log_level
SAVE IMAGE cat-gateway:$tag

# Publish packages if all integration tests have passed. (Failure to pass tests will prevent packages being published.)
# publish:
# FROM scratch

## -----------------------------------------------------------------------------

# This step simulates the full CI run for local purposes only.
local-ci-run:
BUILD +check
BUILD +build
# BUILD +package
# BUILD +publish
42 changes: 42 additions & 0 deletions catalyst-gateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* [`./bin`](#bin)
* [`./crates`](#crates)
* [`./event-db`](#event-db)
* [Build and Run](#build-and-run)
* [Docker images](#docker-images)
* [Rust binary](#rust-binary)

The Catalyst Data Gateway is the backend of the Catalyst Voices hosted stack.

Expand All @@ -26,3 +29,42 @@ They are also able to be used stand-alone in other projects and can be published

Defines the Postgres Catalyst Event Database that the Catalyst gateway uses for running Catalyst Events.
This is DB definition and data only, the actual db interface code is located at `./bin/src/event-db`.

## Build and Run

There are several options how you can build this service,
as a Rust binary from the Rust code explicitly,
or you can build a docker image and run everything with the `docker-compose`.

### Docker images

To build and run docker images follow these steps:

1. Run `earthly +package-cat-gateway` or `earthly +package-cat-gateway-with-preprod-snapshot`
to build a cat-gateway docker image without `preprod-snapshot` or with it.
2. Run `earthly ./event-db+build` to build an event-db docker image.
3. Run `docker-compose up cat-gateway` to spin up cat-gateway with event-db from already built images.

Note that every time when you are building an image it obsoletes an old image but does not remove it,
so dont forget to cleanup dangling images of the event-db and cat-gateway in your docker environment.

### Rust binary

To build and run a Rust binary follow these steps:

1. Run `cargo build -p cat-gateway --release`
to compile a release version of the cat-gateway
2. Run `earthly ./event-db+build` to build an event-db docker image
3. If you need to have a `preprod-snapshot` unarchive snapshot data to the `/tmp/preprod/` dir.
You can download `preprod-snapshot` from this
[resource](https://mithril.network/explorer/?aggregator=https%3A%2F%2Faggregator.release-preprod.api.mithril.network%2Faggregator).
4. Run

```sh
./target/release/cat-gateway run \
--address "127.0.0.1:3030" \
--database-url=postgres://catalyst-event-dev:CHANGE_ME@localhost/CatalystEventDev \
--log-level=debug \
--log-format=compact \
--metrics-address "127.0.0.1:3032"
```
1 change: 0 additions & 1 deletion catalyst-gateway/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ rust-embed = { workspace = true }
local-ip-address = { workspace = true }
gethostname = { workspace = true }
hex = { workspace = true }
async-recursion = { workspace = true }
pallas = { workspace = true }
cardano-chain-follower= { workspace = true }
anyhow = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
registration_cbor = {
61284: key_registration,

key_registration = {
1 : [+delegation] / legacy_key_registration,
2 : $stake_credential,
3 : $payment_address,
4 : $nonce,
? 5 : $voting_purpose .default 0
}

$cip36_vote_pub_key /= bytes .size 32
Expand All @@ -12,22 +17,5 @@ delegation = [$cip36_vote_pub_key, $weight]


$stake_credential /= $staking_pub_key
$stake_witness /= $ed25519_signature
; A stake key credential, not tagged for backward compatibility
$staking_pub_key /= bytes .size 32
; Witness for a stake key credential, not tagged for backward compatibility
$ed25519_signature /= bytes .size 64


key_registration = {
1 : [+delegation] / legacy_key_registration,
2 : $stake_credential,
3 : $payment_address,
4 : $nonce,
? 5 : $voting_purpose .default 0
}


registration_witness = {
1 : $stake_witness
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
registration_cbor = {
61285: registration_witness
registration_witness = {
1 : $stake_witness
}

$stake_witness /= $ed25519_signature

; Witness for a stake key credential, not tagged for backward compatibility
$ed25519_signature /= bytes .size 64

registration_witness = {
1 : $stake_witness
}
$ed25519_signature /= bytes .size 64

0 comments on commit 6351156

Please sign in to comment.