Skip to content

Commit 8d9f847

Browse files
iccicciginnun
authored andcommitted
feat: add blockfrost based provider server
1 parent 103f408 commit 8d9f847

File tree

11 files changed

+147
-23
lines changed

11 files changed

+147
-23
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Continuous Integration - E2E BF
2+
3+
env:
4+
TL_DEPTH: ${{ github.event.pull_request.head.repo.fork && '0' || fromJson(vars.TL_DEPTH) }}
5+
TL_LEVEL: ${{ github.event.pull_request.head.repo.fork && 'info' || vars.TL_LEVEL }}
6+
# -----------------------------------------------------------------------------------------
7+
DB_SYNC_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'
8+
KEY_MANAGEMENT_PROVIDER: 'inMemory'
9+
KEY_MANAGEMENT_PARAMS: '{"bip32Ed25519": "Sodium", "accountIndex": 0, "chainId":{"networkId": 0, "networkMagic": 888}, "passphrase":"some_passphrase","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
10+
OGMIOS_URL: 'ws://localhost:1340/'
11+
STAKE_POOL_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool'
12+
STAKE_POOL_TEST_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool_test'
13+
TEST_CLIENT_ASSET_PROVIDER: 'http'
14+
TEST_CLIENT_ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4014/"}'
15+
TEST_CLIENT_CHAIN_HISTORY_PROVIDER: 'http'
16+
TEST_CLIENT_CHAIN_HISTORY_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4001/"}'
17+
TEST_CLIENT_HANDLE_PROVIDER: 'http'
18+
TEST_CLIENT_HANDLE_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4011/"}'
19+
TEST_CLIENT_NETWORK_INFO_PROVIDER: 'ws'
20+
TEST_CLIENT_NETWORK_INFO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
21+
TEST_CLIENT_REWARDS_PROVIDER: 'http'
22+
TEST_CLIENT_REWARDS_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4001/"}'
23+
TEST_CLIENT_TX_SUBMIT_PROVIDER: 'http'
24+
TEST_CLIENT_TX_SUBMIT_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
25+
TEST_CLIENT_UTXO_PROVIDER: 'http'
26+
TEST_CLIENT_UTXO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4001/"}'
27+
TEST_CLIENT_STAKE_POOL_PROVIDER: 'http'
28+
TEST_CLIENT_STAKE_POOL_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
29+
WS_PROVIDER_URL: 'http://localhost:4100/ws'
30+
31+
on:
32+
pull_request:
33+
push:
34+
branches: ['master']
35+
tags: ['*.*.*']
36+
37+
jobs:
38+
build_and_test:
39+
strategy:
40+
matrix:
41+
os: [ubuntu-20.04]
42+
runs-on: ${{ matrix.os }}
43+
steps:
44+
- name: 📥 Checkout repository
45+
uses: actions/checkout@v3
46+
47+
- name: 🧰 Setup Node.js
48+
uses: actions/setup-node@v3
49+
with:
50+
node-version: 18.12.0
51+
52+
- name: 🔨 Build
53+
run: |
54+
yarn install --immutable --inline-builds --mode=skip-build
55+
yarn workspace @cardano-sdk/cardano-services-client build:cjs
56+
yarn workspace @cardano-sdk/cardano-services build:cjs
57+
yarn workspace @cardano-sdk/e2e build:cjs
58+
yarn workspace @cardano-sdk/util-dev build:cjs
59+
docker build --no-cache .
60+
env:
61+
NODE_OPTIONS: '--max_old_space_size=8192'
62+
63+
- name: 🌐 Setup local test network
64+
working-directory: packages/e2e
65+
run: |
66+
yarn local-network:up -d
67+
env:
68+
CARDANO_NODE_CHAINDB_LOG_LEVEL: 'Warning'
69+
CARDANO_NODE_LOG_LEVEL: 'Warning'
70+
OGMIOS_PORT: '1340'
71+
OGMIOS_URL: 'ws://ogmios:1340'
72+
POSTGRES_PORT: '5435'
73+
74+
- name: Wait for network init
75+
run: |
76+
yarn workspace @cardano-sdk/e2e wait-for-network-init
77+
78+
- name: 🔬 Test - e2e - wallet at epoch 0
79+
run: |
80+
yarn workspace @cardano-sdk/e2e test:wallet:epoch0
81+
82+
- name: Wait for epoch 3
83+
run: |
84+
yarn workspace @cardano-sdk/e2e wait-for-network-epoch-3
85+
86+
- name: 🔬 Test - e2e - wallet at epoch 3
87+
run: |
88+
yarn workspace @cardano-sdk/e2e test:wallet:epoch3
89+
yarn workspace @cardano-sdk/e2e test:blockfrost:providers
90+
91+
- name: Dump docker logs
92+
if: ${{ cancelled() || failure() }}
93+
uses: jwalton/gh-docker-logs@v2

.github/workflows/continuous-integration-e2e.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ env:
44
TL_DEPTH: ${{ github.event.pull_request.head.repo.fork && '0' || fromJson(vars.TL_DEPTH) }}
55
TL_LEVEL: ${{ github.event.pull_request.head.repo.fork && 'info' || vars.TL_LEVEL }}
66
# -----------------------------------------------------------------------------------------
7+
DB_SYNC_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'
78
KEY_MANAGEMENT_PROVIDER: 'inMemory'
89
KEY_MANAGEMENT_PARAMS: '{"bip32Ed25519": "Sodium", "accountIndex": 0, "chainId":{"networkId": 0, "networkMagic": 888}, "passphrase":"some_passphrase","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
10+
OGMIOS_URL: 'ws://localhost:1340/'
11+
STAKE_POOL_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool'
12+
STAKE_POOL_TEST_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool_test'
913
TEST_CLIENT_ASSET_PROVIDER: 'http'
1014
TEST_CLIENT_ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4014/"}'
1115
TEST_CLIENT_CHAIN_HISTORY_PROVIDER: 'ws'
1216
TEST_CLIENT_CHAIN_HISTORY_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
13-
DB_SYNC_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'
1417
TEST_CLIENT_HANDLE_PROVIDER: 'http'
1518
TEST_CLIENT_HANDLE_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4011/"}'
16-
STAKE_POOL_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool'
17-
STAKE_POOL_TEST_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool_test'
1819
TEST_CLIENT_NETWORK_INFO_PROVIDER: 'ws'
1920
TEST_CLIENT_NETWORK_INFO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
20-
OGMIOS_URL: 'ws://localhost:1340/'
2121
TEST_CLIENT_REWARDS_PROVIDER: 'http'
2222
TEST_CLIENT_REWARDS_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/"}'
2323
TEST_CLIENT_TX_SUBMIT_PROVIDER: 'http'

compose/common.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ x-provider-server-environment: &provider-server-environment
7979
TX_SUBMIT_PROVIDER: ${TX_SUBMIT_PROVIDER:-submit-node}
8080
STAKE_POOL_PROVIDER: ${STAKE_POOL_PROVIDER:-dbsync}
8181
NETWORK: ${NETWORK:-mainnet}
82-
BLOCKFROST_API_KEY: ${BLOCKFROST_API_KEY}
83-
BLOCKFROST_CUSTOM_BACKEND_URL: ${BLOCKFROST_CUSTOM_BACKEND_URL}
8482

8583
x-sdk-environment: &sdk-environment
8684
LOGGER_MIN_SEVERITY: ${LOGGER_MIN_SEVERITY:-info}
@@ -118,21 +116,23 @@ x-sdk-environment: &sdk-environment
118116
POSTGRES_USER_FILE_STAKE_POOL: /run/secrets/postgres_user
119117
POSTGRES_USER_FILE_WALLET_API: /run/secrets/postgres_user
120118
TOKEN_METADATA_SERVER_URL: https://metadata.world.dev.cardano.org
121-
USE_WEB_SOCKET_API: true
122119
WEB_SOCKET_API_URL: ws://ws-server:3000/ws
123120

124121
services:
125122
blockfrost-ryo:
126123
build:
127-
context: "https://github.com/ginnun/blockfrost-backend-ryo.git#feat/custom-network-support"
124+
context: 'https://github.com/ginnun/blockfrost-backend-ryo.git#feat/custom-network-support'
128125
dockerfile: Dockerfile
129126
environment:
130127
BLOCKFROST_CONFIG_SERVER_LISTEN_ADDRESS: 0.0.0.0
131128
depends_on:
132129
cardano-db-sync:
133130
condition: service_started
131+
healthcheck:
132+
test: ['CMD-SHELL', 'curl -s --fail http://localhost:3000/health']
134133
ports:
135-
- "3015:3000"
134+
- 3015:3000
135+
restart: always
136136

137137
cardano-db-sync:
138138
<<:
@@ -350,9 +350,34 @@ services:
350350
<<:
351351
- *sdk-environment
352352
- *provider-server-environment
353+
USE_WEB_SOCKET_API: true
353354
ports:
354355
- ${API_PORT:-4000}:3000
355356

357+
blockfrost-provider-server:
358+
<<:
359+
- *from-sdk
360+
- *logging
361+
- *provider-server
362+
- *with-postgres
363+
depends_on:
364+
blockfrost-ryo:
365+
condition: service_healthy
366+
environment:
367+
<<:
368+
- *sdk-environment
369+
- *provider-server-environment
370+
# ATM we don't have BlockfrostHandleProvider and BlockfrostStakePoolProvider
371+
ASSET_PROVIDER: blockfrost
372+
BLOCKFROST_CUSTOM_BACKEND_URL: 'http://blockfrost-ryo:3000'
373+
CHAIN_HISTORY_PROVIDER: blockfrost
374+
NETWORK_INFO_PROVIDER: blockfrost
375+
REWARDS_PROVIDER: blockfrost
376+
UTXO_PROVIDER: blockfrost
377+
ports:
378+
- ${API_PORT:-4001}:3000
379+
- 9229:9229
380+
356381
stake-pool-provider-server:
357382
<<:
358383
- *from-sdk

packages/cardano-services/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"cleanup": "rm -rf dist node_modules",
3030
"cli": "ts-node --transpile-only src/cli.ts",
3131
"compose:single:up": "yarn compose:up cardano-node ogmios postgres",
32-
"compose:up": "__FIX_UMASK__=$(chmod -R a+r ../../compose/placeholder-secrets) docker compose --env-file environments/.env.$NETWORK -p cardano-services-$NETWORK -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/pg-agent.yml -f ../../compose/$(uname -m).yml ${FILES:-} --profile ${DOCKER_COMPOSE_PROFILE:-none} up",
32+
"compose:up": "__FIX_UMASK__=$(chmod -R a+r ../../compose/placeholder-secrets) docker compose --env-file environments/.env.$NETWORK -p cardano-services-$NETWORK -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/pg-agent.yml -f ../../compose/$(uname -m).yml ${FILES:-} up",
3333
"compose:down": "docker compose -p cardano-services-$NETWORK -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/pg-agent.yml -f ../../compose/$(uname -m).yml down -t 120",
3434
"coverage": "yarn test --coverage || true",
3535
"circular-deps:check": "madge --circular dist/cjs",
@@ -38,21 +38,17 @@
3838
"generate-migration": "typeorm-ts-node-commonjs migration:generate src/Projection/migrations/migrations -d src/migrationDataSource.ts",
3939
"mainnet:single:up": "NETWORK=mainnet yarn compose:single:up",
4040
"mainnet:up": "NETWORK=mainnet SUBMIT_API_ARGS=--mainnet yarn compose:up",
41-
"mainnet:blockfrost:up": "DOCKER_COMPOSE_PROFILE='blockfrost-ryo' yarn mainnet:up",
4241
"mainnet:down": "NETWORK=mainnet yarn compose:down",
4342
"prepack": "yarn build",
4443
"preprod:single:up": "NETWORK=preprod yarn compose:single:up",
4544
"preprod:up": "NETWORK=preprod SUBMIT_API_ARGS='--testnet-magic 1' yarn compose:up",
46-
"preprod:blockfrost:up": "DOCKER_COMPOSE_PROFILE='blockfrost-ryo' yarn preprod:up",
4745
"preprod:down": "NETWORK=preprod yarn compose:down",
4846
"pretest": "yarn build",
4947
"preview:single:up": "NETWORK=preview yarn compose:single:up",
5048
"preview:up": "NETWORK=preview SUBMIT_API_ARGS='--testnet-magic 2' yarn compose:up",
51-
"preview:blockfrost:up": "DOCKER_COMPOSE_PROFILE='blockfrost-ryo' yarn preview:up",
5249
"preview:down": "NETWORK=preview yarn compose:down",
5350
"sanchonet:single:up": "NETWORK=sanchonet yarn compose:single:up",
5451
"sanchonet:up": "NETWORK=sanchonet SUBMIT_API_ARGS='--testnet-magic 4' yarn compose:up",
55-
"sanchonet:blockfrost:up": "DOCKER_COMPOSE_PROFILE='blockfrost-ryo' yarn sanchonet:up",
5652
"sanchonet:down": "NETWORK=sanchonet yarn compose:down",
5753
"test": "jest --runInBand -c ./jest.config.js --selectProjects unit",
5854
"test:build:verify": "tsc --build ./test",

packages/e2e/.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ TEST_CLIENT_STAKE_POOL_PROVIDER=http
2828
TEST_CLIENT_STAKE_POOL_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/"}'
2929
WS_PROVIDER_URL='ws://localhost:4100/ws'
3030

31+
# Uncomment following to run e2e tests agains blockfrost providers locally
32+
#TEST_CLIENT_CHAIN_HISTORY_PROVIDER=http
33+
#TEST_CLIENT_CHAIN_HISTORY_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4001/"}'
34+
#TEST_CLIENT_REWARDS_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4001/"}'
35+
#TEST_CLIENT_UTXO_PROVIDER=http
36+
#TEST_CLIENT_UTXO_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4001/"}'
37+
3138
# Required by test:ogmios, test:blockfrost
3239
DB_SYNC_CONNECTION_STRING='postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'
3340
STAKE_POOL_CONNECTION_STRING='postgresql://postgres:doNoUseThisSecret!@localhost:5435/stake_pool'

packages/e2e/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ x-logging: &logging
66
max-file: '10'
77

88
services:
9-
109
blockfrost-ryo:
1110
depends_on:
1211
local-testnet:
@@ -15,7 +14,6 @@ services:
1514
NODE_ENV: local-network
1615
volumes:
1716
- ./local-network/config/network/blockfrost-ryo:/app/config
18-
profiles: [blockfrost-ryo]
1917

2018
local-testnet:
2119
<<: *logging

packages/e2e/local-network/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG UBUNTU_VERSION=20.04
22

3-
FROM ubuntu:${UBUNTU_VERSION} as builder
3+
FROM ubuntu:${UBUNTU_VERSION} AS builder
44

55
ENV DEBIAN_FRONTEND=nonintercative
66

packages/e2e/local-network/templates/babbage/db-sync-config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@
111111
"scName": "stdout",
112112
"scRotation": null
113113
}
114-
]
114+
],
115+
"insert_options": {
116+
"tx_cbor": "enable"
117+
}
115118
}

packages/e2e/local-network/templates/blockfrost-ryo/local-network.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ dbSync:
1111
maxConnections: 5
1212
network: "custom"
1313
genesisDataFolder: '/app/config'
14-
tokenRegistryUrl: "https://metadata.cardano-testnet.iohkdev.io"
14+
tokenRegistryUrl: "https://tokens.cardano.org"
15+
tokenRegistryEnabled: false

packages/e2e/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@
4646
"test:web-extension:watch": "run-s test:web-extension:build test:web-extension:watch:bg",
4747
"test:web-extension:watch:bg": "run-p test:web-extension:watch:build test:web-extension:watch:run",
4848
"test:ws": "jest -c jest.config.js --forceExit --selectProjects ws-server --runInBand --verbose",
49-
"local-network:common": "DISABLE_DB_CACHE=${DISABLE_DB_CACHE:-true} SUBMIT_API_ARGS='--testnet-magic 888' USE_BLOCKFROST=false __FIX_UMASK__=$(chmod -R a+r ../../compose/placeholder-secrets) docker compose --env-file ../cardano-services/environments/.env.local -p local-network-e2e -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/$(uname -m).yml $FILES --profile ${DOCKER_COMPOSE_PROFILE:-none} up",
49+
"local-network:common": "DISABLE_DB_CACHE=${DISABLE_DB_CACHE:-true} SUBMIT_API_ARGS='--testnet-magic 888' USE_BLOCKFROST=false __FIX_UMASK__=$(chmod -R a+r ../../compose/placeholder-secrets) docker compose --env-file ../cardano-services/environments/.env.local -p local-network-e2e -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/$(uname -m).yml $FILES up",
5050
"local-network:up": "FILES='' yarn local-network:common",
51-
"local-network:blockfrost:up": "FILES='' DOCKER_COMPOSE_PROFILE='blockfrost-ryo' yarn local-network:common",
5251
"local-network:single:up": "FILES='' yarn local-network:common cardano-node file-server local-testnet ogmios postgres",
5352
"local-network:profile:up": "FILES='-f ../../compose/pg-agent.yml' yarn local-network:common",
5453
"local-network:down": "docker compose -p local-network-e2e -f docker-compose.yml -f ../../compose/common.yml -f ../../compose/pg-agent.yml down -v --remove-orphans",

0 commit comments

Comments
 (0)