Skip to content

Commit

Permalink
feat!: fx and interscheme implementation (#492)
Browse files Browse the repository at this point in the history
* feat(csi-164): parameterize 'switch' id (#482)

* fix(csi-241): fixed unit-tests (#483)

* fix(csi-241): fixed unit-tests

* fix(csi-241): fixed unit-tests

* fix(csi-241): fixed unit-tests

* fix(csi-241): fixed unit-tests

* test: temporarily disable int test shutdown

* fix: update parameters for sendRequest and update tests

* chore: update deps, re-enable int test shutdown

---------

Co-authored-by: Steven Oderayi <[email protected]>

* chore(snapshot): 15.4.0-snapshot.0

* chore(snapshot): 15.4.0-snapshot.1

* chore(snapshot): 15.4.0-snapshot.2

* chore(snapshot): 15.4.0-snapshot.3

* chore(snapshot): 15.4.0-snapshot.4

* chore(snapshot): 15.4.0-snapshot.5

* chore(snapshot): 15.4.0-snapshot.6

* chore(snapshot): 15.4.0-snapshot.7

* chore(snapshot): 15.4.0-snapshot.8

* chore(snapshot): 15.4.0-snapshot.9

* chore(snapshot): 15.4.0-snapshot.10

* chore(snapshot): 15.4.0-snapshot.11

* chore(snapshot): 15.4.0-snapshot.12

* chore(csi-16): updated deps

* chore(snapshot): 15.4.0-snapshot.13

* feat(csi-16): added proxy caching logic (#484)

* fix(csi-241): fixed unit-tests

* fix(csi-241): fixed unit-tests

* fix(csi-241): fixed unit-tests

* fix(csi-241): fixed unit-tests

* feat(csi-16): refactoring - moved getPartiesByTypeAndID to a separate file

* ci: fix docker build

* feat(csi-263): implemented getPartiesByTypeAndID proxy changes (#485)

* feat(csi-263): implemented getPartiesByTypeAndID proxy changes

* feat(csi-263): implemented getPartiesByTypeAndID proxy changes

* feat(csi-263): update npm test:... scripts

* feat(csi-263): added networks to redis in d-c

* feat(csi-263): added proxyCache logic for success PUT /parties

* feat(csi-263): added proxyCache logic for error PUT /parties

* feat(csi-263): updated proxyConfig format

* feat(csi-263): added jest-unit.config.js

* feat(csi-215): updated test-harness version to use fx

* chore(snapshot): 15.4.0-snapshot.0

* chore(snapshot): 15.4.0-snapshot.1

* chore(snapshot): 15.4.0-snapshot.2

* chore(snapshot): 15.4.0-snapshot.3

* chore(snapshot): 15.4.0-snapshot.4

* chore(snapshot): 15.4.0-snapshot.5

* chore(snapshot): 15.4.0-snapshot.6

* chore(snapshot): 15.4.0-snapshot.7

* chore(snapshot): 15.4.0-snapshot.8

* chore(snapshot): 15.4.0-snapshot.9

* chore(snapshot): 15.4.0-snapshot.10

* chore(snapshot): 15.4.0-snapshot.11

* feat: make proxy routing optional & update health check (#486)

* chore(csi-16): updated central-services-shared version

* chore(snapshot): 15.4.0-snapshot.12

* chore(snapshot): 15.4.0-snapshot.13

* chore(snapshot): 15.4.0-snapshot.14

* chore(csi-16): inited proxies cache

* chore(snapshot): 15.4.0-snapshot.15

* chore(snapshot): 15.4.0-snapshot.16

* feat(csi-263): added proxy int-test from parties handler

* feat(csi-263): added proxy int-test from parties handler

* feat(csi-263): added --runInBand to unit tests

* feat(csi-16): proxyCacheTtlSec = 40

* chore(snapshot): 15.4.0-snapshot.17

* feat(csi-16): proxyCacheTtlSec = 40

* feat(csi-16): proxyCacheTtlSec = 40

* chore(snapshot): 15.4.0-snapshot.18

* Update docker/account-lookup-service/default.json

Co-authored-by: Steven Oderayi <[email protected]>

* Update test/integration-config.json

Co-authored-by: Steven Oderayi <[email protected]>

---------

Co-authored-by: Steven Oderayi <[email protected]>

* feat(csi-334): e2e als-proxy flow validation (#487)

* feat(csi-263): implemented getPartiesByTypeAndID proxy changes

* feat(csi-263): implemented getPartiesByTypeAndID proxy changes

* feat(csi-263): update npm test:... scripts

* feat(csi-263): added networks to redis in d-c

* feat(csi-263): added proxyCache logic for success PUT /parties

* feat(csi-263): added proxyCache logic for error PUT /parties

* feat(csi-263): updated proxyConfig format

* feat(csi-263): added jest-unit.config.js

* feat(csi-215): updated test-harness version to use fx

* chore(snapshot): 15.4.0-snapshot.0

* chore(snapshot): 15.4.0-snapshot.1

* chore(snapshot): 15.4.0-snapshot.2

* chore(snapshot): 15.4.0-snapshot.3

* chore(snapshot): 15.4.0-snapshot.4

* chore(snapshot): 15.4.0-snapshot.5

* chore(snapshot): 15.4.0-snapshot.6

* chore(snapshot): 15.4.0-snapshot.7

* chore(snapshot): 15.4.0-snapshot.8

* chore(snapshot): 15.4.0-snapshot.9

* chore(snapshot): 15.4.0-snapshot.10

* chore(snapshot): 15.4.0-snapshot.11

* feat: make proxy routing optional & update health check (#486)

* chore(csi-16): updated central-services-shared version

* chore(snapshot): 15.4.0-snapshot.12

* chore(snapshot): 15.4.0-snapshot.13

* chore(snapshot): 15.4.0-snapshot.14

* chore(csi-16): inited proxies cache

* chore(snapshot): 15.4.0-snapshot.15

* chore(snapshot): 15.4.0-snapshot.16

* feat(csi-263): added proxy int-test from parties handler

* feat(csi-263): added proxy int-test from parties handler

* feat(csi-263): added --runInBand to unit tests

* feat(csi-16): proxyCacheTtlSec = 40

* chore(snapshot): 15.4.0-snapshot.17

* feat(csi-16): proxyCacheTtlSec = 40

* feat(csi-16): proxyCacheTtlSec = 40

* chore(snapshot): 15.4.0-snapshot.18

* Update docker/account-lookup-service/default.json

Co-authored-by: Steven Oderayi <[email protected]>

* Update test/integration-config.json

Co-authored-by: Steven Oderayi <[email protected]>

* feat(csi-334): added source to proxyCache for payee case

* chore(snapshot): 15.4.0-snapshot.19

* feat(csi-334): added axios-retry

* chore(snapshot): 15.4.0-snapshot.20

* fix(csi-321): fixed failed GP tests

* chore(snapshot): 15.4.0-snapshot.21

* fix(csi-321): fixed case of sendCallback to requester

* chore(snapshot): 15.4.0-snapshot.22

* fix(csi-321): added contextLogger

* fix(csi-334): add proxyLib with redis-cluster

* chore(snapshot): 15.4.0-snapshot.23

* fix(csi-334): add proxyLib with redis-cluster

* chore(snapshot): 15.4.0-snapshot.24

* fix(csi-334): fixed config

* chore(snapshot): 15.4.0-snapshot.25

* fix(csi-334): used new proxyLib

---------

Co-authored-by: Steven Oderayi <[email protected]>

* fix(csi-334): switched to redis standalone; improved logging; added int-test

* fix(csi-334): improved logging

* chore(snapshot): 15.4.0-snapshot.26

* fix(csi-418): fixed oracle update logic; added tests (#490)

* fix(csi-418): fixed oracle update logic; added tests

* chore(snapshot): 15.4.0-snapshot.27

* fix(csi-418): fixed oracle update logic; added tests

* chore(snapshot): 15.4.0-snapshot.28

* feat: PROXY_MAP

* chore(snapshot): 15.4.0-snapshot.29

* feat(mojaloop/#4000): timeout handler (#489)

---------

Co-authored-by: Steven Oderayi <[email protected]>
Co-authored-by: Kalin Krustev <[email protected]>

* chore: deps

* chore(snapshot): 15.4.0-snapshot.32

* chore(snapshot): 15.4.0-snapshot.33

* chore(snapshot): 15.4.0-snapshot.34

* fix: jws signing (#497)

* fix: config

* chore(snapshot): 15.4.0-snapshot.35

* fix: github-advanced-security alerts

* chore: addressed PR comments

* chore: added audit:check to pre-commit

* chore: added docs/Proxy

* chore: added Timeout flow docs

* Update docs/Proxy/P2P.md

Co-authored-by: Sam <[email protected]>

* chore: updated license

---------

Co-authored-by: Steven Oderayi <[email protected]>
Co-authored-by: Eugen Klymniuk <[email protected]>
Co-authored-by: geka.evk <[email protected]>
Co-authored-by: Kalin Krustev <[email protected]>
Co-authored-by: Sam <[email protected]>
  • Loading branch information
6 people authored Dec 11, 2024
1 parent 0396fc2 commit c44e5e0
Show file tree
Hide file tree
Showing 135 changed files with 12,423 additions and 4,976 deletions.
10 changes: 3 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,8 @@ jobs:
# command: |
# docker-compose pull
- run:
name: Start docker-compose
command: |
docker-compose up -d
# Check straight away to see if any containers have exited
docker-compose ps
name: Start docker compose
command: npm run dc:up
- run:
name: Wait for Health Services
command: |
Expand Down Expand Up @@ -973,4 +969,4 @@ workflows:
only: /v[0-9]+(\.[0-9]+)*\-snapshot+((\.[0-9]+)?)/
branches:
ignore:
- /.*/
- /.*/
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ admin.Dockerfile
Dockerfile
LICENSE
README.md
.circleci/
.circleci/
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ typings/
.yarn-integrity

# dotenv environment variables file
.env
#.env

# next.js build output
.next
Expand All @@ -79,3 +79,6 @@ devspace*

# General Ignore
*IGNORE*

# macOS
.DS_Store
3 changes: 2 additions & 1 deletion .ncurc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
reject: [
# TODO: v6+ (ref: https://github.com/sindresorhus/get-port/releases/tag/v6.0.0) is an ESM library and thus not compatible with CommonJS. Future story needed to resolve.
"get-port",
"@mojaloop/sdk-standard-components"
"@mojaloop/sdk-standard-components",
"@mojaloop/central-services-shared" ## need to remove before merging proxyCache functionality to main
]
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.20.3
18.19.0
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ ARG NODE_VERSION=lts-alpine
# export NODE_VERSION="$(cat .nvmrc)-alpine" \
# docker build \
# --build-arg NODE_VERSION=$NODE_VERSION \
# -t mojaloop/sdk-scheme-adapter:local \
# -t mojaloop/account-lookup-service:local \
# . \
#

# Build Image
FROM node:${NODE_VERSION} as builder
FROM node:${NODE_VERSION} AS builder
WORKDIR /opt/app

RUN apk --no-cache add git
RUN apk add --no-cache -t build-dependencies make gcc g++ python3 libtool openssl-dev autoconf automake bash \
RUN apk add --no-cache -t build-dependencies make gcc g++ py3-setuptools python3 libtool openssl-dev autoconf automake bash \
&& cd $(npm root -g)/npm

COPY package.json package-lock.json* /opt/app/
COPY package.json package-lock.json /opt/app/

RUN npm ci

COPY src /opt/app/src
COPY config /opt/app/config
COPY migrations /opt/app/migrations
COPY seeds /opt/app/seeds
COPY test /opt/app/test

FROM node:${NODE_VERSION}
WORKDIR /opt/app
Expand All @@ -36,7 +35,7 @@ RUN mkdir ./logs && touch ./logs/combined.log
RUN ln -sf /dev/stdout ./logs/combined.log

# Create a non-root user: ml-user
RUN adduser -D ml-user
RUN adduser -D ml-user
USER ml-user

COPY --chown=ml-user --from=builder /opt/app .
Expand Down
7 changes: 3 additions & 4 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

Copyright © 2020-2024 Mojaloop Foundation

The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0
(the "License") and you may not use these files except in compliance with the [License](http://www.apache.org/licenses/LICENSE-2.0).
The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License.

You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the [License](http://www.apache.org/licenses/LICENSE-2.0).
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- [Documentation](http://docs.mojaloop.io/documentation/mojaloop-technical-overview/account-lookup-service/)
- [API Swagger Reference](/src/interface/api-swagger.yaml)
- [Admin Swagger Referemce](/src/interface/admin-swagger.yaml)
- [Discovery flow diagram using proxy](./docs/Proxy/Discovery.md)
- [Proxy implementation details](./docs/Proxy/Readme.md)

## Database initialisation

Expand Down Expand Up @@ -149,7 +151,7 @@ If you want to run integration tests in a repetitive manner, you can startup the
Start containers required for Integration Tests

```bash
docker-compose -f docker-compose.yml up -d
npm run dc:up
```

Run wait script which will report once all required containers are up and running
Expand Down
5 changes: 3 additions & 2 deletions audit-ci.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"GHSA-f9xv-q969-pqx4",
"GHSA-7fh5-64p2-3v2j",
"GHSA-rm97-x556-q36h", // https://github.com/advisories/GHSA-rm97-x556-q36h
"GHSA-rv95-896h-c2vc" // https://github.com/advisories/GHSA-rv95-896h-c2vc

"GHSA-rv95-896h-c2vc", // https://github.com/advisories/GHSA-rv95-896h-c2vc
"GHSA-3xgq-45jj-v275", // https://github.com/advisories/GHSA-3xgq-45jj-v275
"GHSA-rhx6-c78j-4q9w" // https://github.com/advisories/GHSA-rhx6-c78j-4q9w
]
}
24 changes: 23 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"HUB_PARTICIPANT": {
"ID": 1,
"NAME": "Hub"
},
"ADMIN_PORT": 4001,
"API_PORT": 4002,
"DATABASE": {
Expand Down Expand Up @@ -51,10 +55,29 @@
"MAX_BYTE_SIZE": 10000000,
"EXPIRES_IN_MS": 61000
},
"PROXY_CACHE": {
"enabled": true,
"type": "redis-cluster",
"proxyConfig": {
"cluster": [
{ "host": "localhost", "port": 6379 }
]
}
},
"ERROR_HANDLING": {
"includeCauseExtension": false,
"truncateExtensions": true
},
"HANDLERS": {
"DISABLED": false,
"MONITORING_PORT": 4003,
"TIMEOUT": {
"DISABLED": false,
"TIMEXP": "*/30 * * * * *",
"TIMEZONE": "UTC",
"BATCH_SIZE": 100
}
},
"SWITCH_ENDPOINT": "http://localhost:3001",
"INSTRUMENTATION": {
"METRICS": {
Expand All @@ -74,7 +97,6 @@
"ENDPOINT_SECURITY":{
"JWS": {
"JWS_SIGN": false,
"FSPIOP_SOURCE_TO_SIGN": "switch",
"JWS_SIGNING_KEY_PATH": "secrets/jwsSigningKey.key"
}
},
Expand Down
148 changes: 131 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,94 @@
version: "3.7"

networks:
als-mojaloop-net:
name: als-mojaloop-net

# @see https://uninterrupted.tech/blog/hassle-free-redis-cluster-deployment-using-docker/
x-redis-node: &REDIS_NODE
image: docker.io/bitnami/redis-cluster:6.2.14
environment: &REDIS_ENVS
ALLOW_EMPTY_PASSWORD: yes
REDIS_CLUSTER_DYNAMIC_IPS: no
REDIS_CLUSTER_ANNOUNCE_IP: ${REDIS_CLUSTER_ANNOUNCE_IP}
REDIS_NODES: localhost:6379 localhost:6380 localhost:6381 localhost:6382 localhost:6383 localhost:6384
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
timeout: 2s
network_mode: host

services:
account-lookup-service:
x-account-lookup-service: &ACCOUNT_LOOKUP_SERVICE
image: mojaloop/account-lookup-service:local
build:
context: .
target: builder
container_name: als_account-lookup-service
user: root
command:
- "sh"
- "-c"
- "sh /opt/wait-for/wait-for-account-lookup-service.sh && node src/index.js server"
ports:
- "4001:4001"
- "4002:4002"
environment:
LOG_LEVEL: debug
networks:
- als-mojaloop-net
depends_on:
- mysql-als
- central-ledger
- proxy
- mysql-als
- redis-node-0
# - redis
volumes:
- ./secrets:/opt/app/secrets
- ./src:/opt/app/src
- ./docker/account-lookup-service/default.json:/opt/app/config/default.json
- ./docker/wait-for:/opt/wait-for
extra_hosts:
- "redis-node-0:host-gateway"

services:
account-lookup-service:
<<: *ACCOUNT_LOOKUP_SERVICE
container_name: als_account-lookup-service
command:
- "sh"
- "-c"
- "sh /opt/wait-for/wait-for-account-lookup-service.sh && node src/index.js server"
ports:
- "4001:4001"
- "4002:4002"
healthcheck:
test: ["CMD", "sh", "-c" ,"apk --no-cache add curl", ";", "curl", "http://localhost:4001/health"]
timeout: 20s
retries: 10
interval: 30s


account-lookup-service-handlers:
<<: *ACCOUNT_LOOKUP_SERVICE
container_name: als_account-lookup-service-handlers
command:
- "sh"
- "-c"
- "node src/handlers/index.js h --timeout"
depends_on:
- redis-node-0
ports:
- "4003:4003"
healthcheck:
test: ["CMD", "sh", "-c" ,"apk --no-cache add curl", ";", "curl", "http://localhost:4003/health"]
timeout: 20s
retries: 10
interval: 30s

central-ledger:
image: mojaloop/central-ledger:latest
# image: mojaloop/central-ledger:latest
image: mojaloop/central-ledger:v17.8.0.160-snapshot.4
container_name: als_central-ledger
user: root
command:
- "sh"
- "-c"
- "sh /opt/wait-for/wait-for-central-ledger.sh && node src/api/index.js"
ports:
- "3001:3001"
- "${CL_PORT:-3001}:3001"
volumes:
- ./docker/central-ledger/default.json:/opt/app/config/default.json
- ./docker/wait-for:/opt/wait-for
environment:
- LOG_LEVEL=info
- LOG_LEVEL=debug
- CLEDG_DATABASE_URI=mysql://central_ledger:password@mysql-cl:3306/central_ledger
- CLEDG_SIDECAR__DISABLED=true
- CLEDG_MONGODB__DISABLED=true
Expand All @@ -64,6 +103,17 @@ services:
retries: 10
interval: 30s

proxy:
build:
context: ./docker/mock-proxy
dockerfile: Dockerfile
restart: always
env_file: ./test/integration/.env
ports:
- "${PROXY_PORT}:${PROXY_PORT}"
networks:
- als-mojaloop-net

kafka:
image: johnnypark/kafka-zookeeper:2.3.0
container_name: als_kafka
Expand Down Expand Up @@ -124,3 +174,67 @@ services:
retries: 10
start_period: 40s
interval: 30s

redis-node-0:
<<: *REDIS_NODE
environment:
<<: *REDIS_ENVS
REDIS_CLUSTER_CREATOR: yes
REDIS_PORT_NUMBER: 6379
depends_on:
- redis-node-1
- redis-node-2
- redis-node-3
- redis-node-4
- redis-node-5
redis-node-1:
<<: *REDIS_NODE
environment:
<<: *REDIS_ENVS
REDIS_PORT_NUMBER: 6380
ports:
- "16380:16380"
redis-node-2:
<<: *REDIS_NODE
environment:
<<: *REDIS_ENVS
REDIS_PORT_NUMBER: 6381
ports:
- "16381:16381"
redis-node-3:
<<: *REDIS_NODE
environment:
<<: *REDIS_ENVS
REDIS_PORT_NUMBER: 6382
ports:
- "16382:16382"
redis-node-4:
<<: *REDIS_NODE
environment:
<<: *REDIS_ENVS
REDIS_PORT_NUMBER: 6383
ports:
- "16383:16383"
redis-node-5:
<<: *REDIS_NODE
environment:
<<: *REDIS_ENVS
REDIS_PORT_NUMBER: 6384
ports:
- "16384:16384"

## To be used with proxyCache.type === 'redis'
# redis:
# image: redis:6.2.4-alpine
# restart: "unless-stopped"
# environment:
# <<: *REDIS_ENVS
# REDIS_CLUSTER_CREATOR: yes
# depends_on:
# - redis-node-1
# - redis-node-2
# - redis-node-3
# - redis-node-4
# - redis-node-5
# ports:
# - "6379:6379"
Loading

0 comments on commit c44e5e0

Please sign in to comment.