Skip to content

Commit

Permalink
Merge pull request input-output-hk#1363 from input-output-hk/jpraynau…
Browse files Browse the repository at this point in the history
…d/1361-deploy-relay-p2p-network

Deploy P2P network infrastructure
  • Loading branch information
jpraynaud authored Nov 23, 2023
2 parents 69ab7da + d5e468e commit 062cb14
Show file tree
Hide file tree
Showing 21 changed files with 609 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ inputs:
google_application_credentials:
description: Google Cloud application credentials (service account).
required: true
mithril_use_p2p_network:
description: Mithril use P2P network (experimental, for test only).
required: false
default: "false"
mithril_api_domain:
description: Mithril network api domain root.
required: true
Expand Down Expand Up @@ -143,6 +147,7 @@ runs:
google_compute_instance_boot_disk_size = "${{ inputs.google_compute_instance_boot_disk_size }}"
google_compute_instance_data_disk_size = "${{ inputs.google_compute_instance_data_disk_size }}"
google_service_credentials_json_file = "./google-application-credentials.json"
mithril_use_p2p_network = "${{ inputs.mithril_use_p2p_network }}"
mithril_api_domain = "${{ inputs.mithril_api_domain }}"
mithril_image_id = "${{ inputs.mithril_image_id }}"
mithril_genesis_verification_key_url = "${{ inputs.mithril_genesis_verification_key_url }}"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ jobs:
- environment: testing-preview
environment_prefix: testing
cardano_network: preview
mithril_use_p2p_network: false
mithril_api_domain: api.mithril.network
mithril_protocol_parameters: |
{
Expand Down Expand Up @@ -525,6 +526,7 @@ jobs:
google_compute_instance_boot_disk_size: ${{ matrix.google_compute_instance_boot_disk_size }}
google_compute_instance_data_disk_size: ${{ matrix.google_compute_instance_data_disk_size }}
google_application_credentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
mithril_use_p2p_network: ${{ matrix.mithril_use_p2p_network }}
mithril_api_domain: ${{ matrix.mithril_api_domain }}
mithril_image_id: ${{ env.DOCKER_IMAGE_ID }}
mithril_protocol_parameters: ${{ toJSON(matrix.mithril_protocol_parameters) }}
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- environment: dev-preview
environment_prefix: dev
cardano_network: preview
mithril_use_p2p_network: true
mithril_api_domain: api.mithril.network
mithril_protocol_parameters: |
{
Expand All @@ -44,11 +45,19 @@ jobs:
type = "unverified",
pool_id = "pool1vapqexnsx6hvc588yyysxpjecf3k43hcr5mvhmstutuvy085xpa",
},
"2" = {
type = "unverified",
pool_id = "pool1t9uuagsat8hlr0n0ga4wzge0jxlyjuhl6mugrm8atc285vzkf2e",
},
"3" = {
type = "unverified",
pool_id = "pool1r0tln8nct3mpyvehgy6uu3cdlmjnmtr2fxjcqnfl6v0qg0we42e",
},
}
terraform_backend_bucket: hydra-terraform-admin
google_region: europe-west1
google_zone: europe-west1-b
google_machine_type: e2-highmem-2
google_machine_type: e2-highmem-4
google_compute_instance_boot_disk_size: 200
google_compute_instance_data_disk_size: 250

Expand All @@ -71,12 +80,14 @@ jobs:
environment_prefix: ${{ matrix.environment_prefix }}
environment: ${{ matrix.environment }}
cardano_network: ${{ matrix.cardano_network }}
cardano_node_version: ${{ vars.CARDANO_NODE_VERSION }}
google_region: ${{ matrix.google_region }}
google_zone: ${{ matrix.google_zone }}
google_machine_type: ${{ matrix.google_machine_type }}
google_compute_instance_boot_disk_size: ${{ matrix.google_compute_instance_boot_disk_size }}
google_compute_instance_data_disk_size: ${{ matrix.google_compute_instance_data_disk_size }}
google_application_credentials: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
mithril_use_p2p_network: ${{ matrix.mithril_use_p2p_network }}
mithril_api_domain: ${{ matrix.mithril_api_domain }}
mithril_image_id: ${{ inputs.mithril_image_id }}
mithril_protocol_parameters: ${{ toJSON(matrix.mithril_protocol_parameters) }}
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion docs/runbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ This page gathers the available guides to operate a Mithril network.
| **Manage SSH access to infrastructure** | [ssh-access](./ssh-access/README.md) | Manage SSH access on the VM of the infrastructure for a user. |
| **Upgrade VM of infrastructure** | [upgrade-vm](./upgrade-vm/README.md) | Upgrade the VM of the infrastructure of a Mithril network. |
| **Create test Docker distribution** | [test-docker-distribution](./test-docker-distribution/README.md) | Create a custom test Docker distribution. |
| **Deploy a test network** | [test-docker-distribution](./test-deploy-network/README.md) | Manually deploy a test distribution to a test Mithril network. |
| **Deploy a test network** | [test-deploy-network](./test-deploy-network/README.md) | Manually deploy a test distribution to a test Mithril network. |
2 changes: 1 addition & 1 deletion docs/runbook/recompute-certificates-hash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ docker stop mithril-aggregator

Then, restore the backed up database:
```bash
cp /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3.bak.$(date +%Y-%m-%d) /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator/aggregator.sqlite3
cp /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3.bak.$(date +%Y-%m-%d) /home/curry/data/$CARDANO_NETWORK/mithril-aggregator/mithril/stores/aggregator.sqlite3
```

Then, start the aggregator:
Expand Down
2 changes: 1 addition & 1 deletion mithril-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mithril-common"
version = "0.2.135"
version = "0.2.136"
description = "Common types, interfaces, and utilities for Mithril nodes."
authors = { workspace = true }
edition = { workspace = true }
Expand Down
10 changes: 6 additions & 4 deletions mithril-common/src/test_utils/test_http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ where
F: Filter + Clone + Send + Sync + 'static,
F::Extract: Reply,
{
let port = 0_u16;
test_http_server_with_port(filters, port)
test_http_server_with_socket_address(filters, ([127, 0, 0, 1], 0).into())
}

/// Spawn a [TestHttpServer] using the given warp filters
pub fn test_http_server_with_port<F>(filters: F, port: u16) -> TestHttpServer
pub fn test_http_server_with_socket_address<F>(
filters: F,
socket_addr: SocketAddr,
) -> TestHttpServer
where
F: Filter + Clone + Send + Sync + 'static,
F::Extract: Reply,
Expand All @@ -64,7 +66,7 @@ where
.expect("new rt");
let (shutdown_tx, shutdown_rx) = oneshot::channel();
let (address, server) = rt.block_on(async move {
warp::serve(filters).bind_with_graceful_shutdown(([127, 0, 0, 1], port), async {
warp::serve(filters).bind_with_graceful_shutdown(socket_addr, async {
shutdown_rx.await.ok();
})
});
Expand Down
123 changes: 123 additions & 0 deletions mithril-infra/assets/docker/docker-compose-aggregator-auth-p2p.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
version: "3.9"

services:
cardano-node-aggregator:
image: cardano-node/${CARDANO_IMAGE_ID}-modified
container_name: cardano-node-aggregator
restart: always
build:
context: .
dockerfile: Dockerfile.cardano
args:
CARDANO_IMAGE_ID: ${CARDANO_IMAGE_ID}
user: ${CURRENT_UID}
profiles:
- cardano
- all
logging:
driver: "${LOGGING_DRIVER}"
options:
tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"
volumes:
- ../data/${NETWORK}/mithril-aggregator/cardano/config/${NETWORK}:/config
- ../data/${NETWORK}/mithril-aggregator/cardano/db:/db
- ../data/${NETWORK}/mithril-aggregator/cardano/ipc:/ipc
environment:
- CARDANO_SOCKET_PATH=/ipc/node.socket
- CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
command:
[
"run",
"--config",
"/config/cardano-node/config.json",
"--topology",
"/config/cardano-node/topology.json",
"--database-path",
"/db"
]

mithril-aggregator:
image: ghcr.io/input-output-hk/mithril-aggregator:${MITHRIL_IMAGE_ID}
container_name: mithril-aggregator
restart: always
user: ${CURRENT_UID}
profiles:
- mithril
- all
environment:
- RUST_BACKTRACE=1
- GOOGLE_APPLICATION_CREDENTIALS_JSON=${GOOGLE_APPLICATION_CREDENTIALS_JSON}
- NETWORK=${NETWORK}
- PROTOCOL_PARAMETERS__K=${PROTOCOL_PARAMETERS__K}
- PROTOCOL_PARAMETERS__M=${PROTOCOL_PARAMETERS__M}
- PROTOCOL_PARAMETERS__PHI_F=${PROTOCOL_PARAMETERS__PHI_F}
- RUN_INTERVAL=60000
- SNAPSHOT_STORE_TYPE=local
- SNAPSHOT_UPLOADER_TYPE=gcp
- SNAPSHOT_BUCKET_NAME=${SNAPSHOT_BUCKET_NAME}
- SNAPSHOT_USE_CDN_DOMAIN=${SNAPSHOT_USE_CDN_DOMAIN}
- SNAPSHOT_COMPRESSION_ALGORITHM=${SNAPSHOT_COMPRESSION_ALGORITHM}
- ZSTANDARD_PARAMETERS__LEVEL=${ZSTANDARD_PARAMETERS__LEVEL}
- ZSTANDARD_PARAMETERS__NUMBER_OF_WORKERS=${ZSTANDARD_PARAMETERS__NUMBER_OF_WORKERS}
- DATA_STORES_DIRECTORY=/mithril-aggregator/mithril/stores
- STORE_RETENTION_LIMIT=5
- CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
- CARDANO_NODE_VERSION=${CARDANO_IMAGE_ID}
- CARDANO_CLI_PATH=/app/bin/cardano-cli
- GENESIS_VERIFICATION_KEY=${GENESIS_VERIFICATION_KEY}
- GENESIS_SECRET_KEY=${GENESIS_SECRET_KEY}
- DB_DIRECTORY=/db
- SNAPSHOT_DIRECTORY=/mithril-aggregator/mithril/snapshots
- SERVER_PORT=8080
- ERA_READER_ADAPTER_TYPE=${ERA_READER_ADAPTER_TYPE}
- ERA_READER_ADAPTER_PARAMS=${ERA_READER_ADAPTER_PARAMS}
- CEXPLORER_POOLS_URL=${CEXPLORER_POOLS_URL}
volumes:
- ../data/${NETWORK}/mithril-aggregator/mithril:/mithril-aggregator/mithril
- ../data/${NETWORK}/mithril-aggregator/cardano/db:/db
- ../data/${NETWORK}/mithril-aggregator/cardano/ipc:/ipc
ports:
- "8080:8080"
command: [ "-vvv", "serve" ]
depends_on:
cardano-node-aggregator:
condition: service_started
logging:
driver: "${LOGGING_DRIVER}"
options:
tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.mithril-aggregator.rule=Host(`${AGGREGATOR_HOST}`)'
- 'traefik.http.routers.mithril-aggregator.tls=true'
- 'traefik.http.routers.mithril-aggregator.tls.certresolver=lets-encrypt'
- "traefik.http.routers.mithril-aggregator.middlewares=test-auth"
- "traefik.http.middlewares.test-auth.basicauth.users=${AUTH_USER_PASSWORD}"

mithril-aggregator-relay:
image: ghcr.io/input-output-hk/mithril-relay:${MITHRIL_IMAGE_ID}
container_name: mithril-aggregator-relay
restart: always
user: ${CURRENT_UID}
profiles:
- mithril
- all
environment:
- RUST_BACKTRACE=1
- LISTEN_PORT=${AGGREGATOR_RELAY_LISTEN_PORT}
- AGGREGATOR_ENDPOINT=http://${AGGREGATOR_CREDENTIALS}mithril-aggregator:8080/aggregator
ports:
- "${AGGREGATOR_RELAY_LISTEN_PORT}:${AGGREGATOR_RELAY_LISTEN_PORT}"
command: [ "-vvv", "aggregator" ]
depends_on:
mithril-aggregator:
condition: service_started
logging:
driver: "${LOGGING_DRIVER}"
options:
tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"

networks:
default:
name: mithril_network
external: true
121 changes: 121 additions & 0 deletions mithril-infra/assets/docker/docker-compose-aggregator-noauth-p2p.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
version: "3.9"

services:
cardano-node-aggregator:
image: cardano-node/${CARDANO_IMAGE_ID}-modified
container_name: cardano-node-aggregator
restart: always
build:
context: .
dockerfile: Dockerfile.cardano
args:
CARDANO_IMAGE_ID: ${CARDANO_IMAGE_ID}
user: ${CURRENT_UID}
profiles:
- cardano
- all
logging:
driver: "${LOGGING_DRIVER}"
options:
tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"
volumes:
- ../data/${NETWORK}/mithril-aggregator/cardano/config/${NETWORK}:/config
- ../data/${NETWORK}/mithril-aggregator/cardano/db:/db
- ../data/${NETWORK}/mithril-aggregator/cardano/ipc:/ipc
environment:
- CARDANO_SOCKET_PATH=/ipc/node.socket
- CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
command:
[
"run",
"--config",
"/config/cardano-node/config.json",
"--topology",
"/config/cardano-node/topology.json",
"--database-path",
"/db"
]

mithril-aggregator:
image: ghcr.io/input-output-hk/mithril-aggregator:${MITHRIL_IMAGE_ID}
container_name: mithril-aggregator
restart: always
user: ${CURRENT_UID}
profiles:
- mithril
- all
environment:
- RUST_BACKTRACE=1
- GOOGLE_APPLICATION_CREDENTIALS_JSON=${GOOGLE_APPLICATION_CREDENTIALS_JSON}
- NETWORK=${NETWORK}
- PROTOCOL_PARAMETERS__K=${PROTOCOL_PARAMETERS__K}
- PROTOCOL_PARAMETERS__M=${PROTOCOL_PARAMETERS__M}
- PROTOCOL_PARAMETERS__PHI_F=${PROTOCOL_PARAMETERS__PHI_F}
- RUN_INTERVAL=60000
- SNAPSHOT_STORE_TYPE=local
- SNAPSHOT_UPLOADER_TYPE=gcp
- SNAPSHOT_BUCKET_NAME=${SNAPSHOT_BUCKET_NAME}
- SNAPSHOT_USE_CDN_DOMAIN=${SNAPSHOT_USE_CDN_DOMAIN}
- SNAPSHOT_COMPRESSION_ALGORITHM=${SNAPSHOT_COMPRESSION_ALGORITHM}
- ZSTANDARD_PARAMETERS__LEVEL=${ZSTANDARD_PARAMETERS__LEVEL}
- ZSTANDARD_PARAMETERS__NUMBER_OF_WORKERS=${ZSTANDARD_PARAMETERS__NUMBER_OF_WORKERS}
- DATA_STORES_DIRECTORY=/mithril-aggregator/mithril/stores
- STORE_RETENTION_LIMIT=5
- CARDANO_NODE_SOCKET_PATH=/ipc/node.socket
- CARDANO_NODE_VERSION=${CARDANO_IMAGE_ID}
- CARDANO_CLI_PATH=/app/bin/cardano-cli
- GENESIS_VERIFICATION_KEY=${GENESIS_VERIFICATION_KEY}
- GENESIS_SECRET_KEY=${GENESIS_SECRET_KEY}
- DB_DIRECTORY=/db
- SNAPSHOT_DIRECTORY=/mithril-aggregator/mithril/snapshots
- SERVER_PORT=8080
- ERA_READER_ADAPTER_TYPE=${ERA_READER_ADAPTER_TYPE}
- ERA_READER_ADAPTER_PARAMS=${ERA_READER_ADAPTER_PARAMS}
- CEXPLORER_POOLS_URL=${CEXPLORER_POOLS_URL}
volumes:
- ../data/${NETWORK}/mithril-aggregator/mithril:/mithril-aggregator/mithril
- ../data/${NETWORK}/mithril-aggregator/cardano/db:/db
- ../data/${NETWORK}/mithril-aggregator/cardano/ipc:/ipc
ports:
- "8080:8080"
command: [ "-vvv", "serve" ]
depends_on:
cardano-node-aggregator:
condition: service_started
logging:
driver: "${LOGGING_DRIVER}"
options:
tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.mithril-aggregator.rule=Host(`${AGGREGATOR_HOST}`)'
- 'traefik.http.routers.mithril-aggregator.tls=true'
- 'traefik.http.routers.mithril-aggregator.tls.certresolver=lets-encrypt'

mithril-aggregator-relay:
image: ghcr.io/input-output-hk/mithril-relay:${MITHRIL_IMAGE_ID}
container_name: mithril-aggregator-relay
restart: always
user: ${CURRENT_UID}
profiles:
- mithril
- all
environment:
- RUST_BACKTRACE=1
- LISTEN_PORT=${AGGREGATOR_RELAY_LISTEN_PORT}
- AGGREGATOR_ENDPOINT=http://${AGGREGATOR_CREDENTIALS}mithril-aggregator:8080/aggregator
ports:
- "${AGGREGATOR_RELAY_LISTEN_PORT}:${AGGREGATOR_RELAY_LISTEN_PORT}"
command: [ "-vvv", "aggregator" ]
depends_on:
mithril-aggregator:
condition: service_started
logging:
driver: "${LOGGING_DRIVER}"
options:
tag: "{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}"

networks:
default:
name: mithril_network
external: true
Loading

0 comments on commit 062cb14

Please sign in to comment.