forked from cerc-io/stack-orchestrator
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8f5030976 | ||
|
|
b686540512 | ||
|
|
9e56f6357d | ||
|
|
8770b1df86 | ||
|
|
889df76f4f | ||
|
|
5d19c56b0c | ||
|
|
d57efe87b8 | ||
|
|
80b0c07736 | ||
|
|
6fa3ca2b6d | ||
|
|
3c5489681f | ||
|
|
cf039d9562 |
+1
-1
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from app.deploy import get_stack_status
|
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
from .deploy import get_stack_status
|
||||||
|
|
||||||
|
|
||||||
def get_stack(config, stack):
|
def get_stack(config, stack):
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import subprocess
|
|||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from app.util import include_exclude_check, get_parsed_stack_config
|
from .util import include_exclude_check, get_parsed_stack_config
|
||||||
from app.base import get_npm_registry_url
|
from .base import get_npm_registry_url
|
||||||
|
|
||||||
# TODO: find a place for this
|
# TODO: find a place for this
|
||||||
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
||||||
@@ -67,7 +67,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
|||||||
print('Dev root directory doesn\'t exist, creating')
|
print('Dev root directory doesn\'t exist, creating')
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
with importlib.resources.open_text(data, "container-image-list.txt") as container_list_file:
|
||||||
all_containers = container_list_file.read().splitlines()
|
all_containers = container_list_file.read().splitlines()
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -25,8 +25,8 @@ from decouple import config
|
|||||||
import click
|
import click
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
from python_on_whales import docker, DockerException
|
from python_on_whales import docker, DockerException
|
||||||
from app.base import get_stack
|
from .base import get_stack
|
||||||
from app.util import include_exclude_check, get_parsed_stack_config
|
from .util import include_exclude_check, get_parsed_stack_config
|
||||||
|
|
||||||
builder_js_image_name = "cerc/builder-js:local"
|
builder_js_image_name = "cerc/builder-js:local"
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ def command(ctx, include, exclude, force_rebuild, extra_build_args):
|
|||||||
os.makedirs(build_root_path)
|
os.makedirs(build_root_path)
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
|
with importlib.resources.open_text(data, "npm-package-list.txt") as package_list_file:
|
||||||
all_packages = package_list_file.read().splitlines()
|
all_packages = package_list_file.read().splitlines()
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -15,14 +15,14 @@
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from app.command_types import CommandOptions
|
from .command_types import CommandOptions
|
||||||
from app import setup_repositories
|
from . import setup_repositories
|
||||||
from app import build_containers
|
from . import build_containers
|
||||||
from app import build_npms
|
from . import build_npms
|
||||||
from app import deploy
|
from . import deploy
|
||||||
from app import version
|
from . import version
|
||||||
from app import deployment
|
from . import deployment
|
||||||
from app import update
|
from . import update
|
||||||
|
|
||||||
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
||||||
|
|
||||||
@@ -40,6 +40,7 @@ services:
|
|||||||
- fixturenet-eth-bootnode-geth
|
- fixturenet-eth-bootnode-geth
|
||||||
ports:
|
ports:
|
||||||
- "8545"
|
- "8545"
|
||||||
|
- "8546"
|
||||||
- "40000"
|
- "40000"
|
||||||
- "6060"
|
- "6060"
|
||||||
|
|
||||||
@@ -61,6 +62,9 @@ services:
|
|||||||
- fixturenet-eth-bootnode-geth
|
- fixturenet-eth-bootnode-geth
|
||||||
volumes:
|
volumes:
|
||||||
- fixturenet_eth_geth_2_data:/root/ethdata
|
- fixturenet_eth_geth_2_data:/root/ethdata
|
||||||
|
ports:
|
||||||
|
- "8545"
|
||||||
|
- "8546"
|
||||||
|
|
||||||
fixturenet-eth-bootnode-lighthouse:
|
fixturenet-eth-bootnode-lighthouse:
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ services:
|
|||||||
- fixturenet-eth-bootnode-geth
|
- fixturenet-eth-bootnode-geth
|
||||||
ports:
|
ports:
|
||||||
- "8545"
|
- "8545"
|
||||||
|
- "8546"
|
||||||
- "40000"
|
- "40000"
|
||||||
- "6060"
|
- "6060"
|
||||||
|
|
||||||
@@ -59,6 +60,9 @@ services:
|
|||||||
- fixturenet-eth-bootnode-geth
|
- fixturenet-eth-bootnode-geth
|
||||||
volumes:
|
volumes:
|
||||||
- fixturenet_plugeth_geth_2_data:/root/ethdata
|
- fixturenet_plugeth_geth_2_data:/root/ethdata
|
||||||
|
ports:
|
||||||
|
- "8545"
|
||||||
|
- "8546"
|
||||||
|
|
||||||
fixturenet-eth-bootnode-lighthouse:
|
fixturenet-eth-bootnode-lighthouse:
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
go-nitro:
|
||||||
|
image: cerc/go-nitro:local
|
||||||
|
hostname: go-nitro
|
||||||
|
restart: on-failure
|
||||||
|
depends_on:
|
||||||
|
# Wait for Nitro contracts to be deployed
|
||||||
|
nitro-contracts:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
environment:
|
||||||
|
CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546}
|
||||||
|
CERC_NITRO_PK: ${CERC_NITRO_PK:-2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d}
|
||||||
|
CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK:-570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597}
|
||||||
|
CERC_NITRO_USE_DURABLE_STORE: ${CERC_NITRO_USE_DURABLE_STORE:-true}
|
||||||
|
CERC_NITRO_DURABLE_STORE_FOLDER: ${CERC_NITRO_DURABLE_STORE_FOLDER:-/app/data/nitro-store}
|
||||||
|
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
|
||||||
|
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
|
||||||
|
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
|
||||||
|
entrypoint: ["bash", "-c", "/app/run-nitro-node.sh"]
|
||||||
|
volumes:
|
||||||
|
- go_nitro_data:/app/data
|
||||||
|
- nitro_deployment:/app/deployment
|
||||||
|
- ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-vz", "localhost", "4005"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
start_period: 10s
|
||||||
|
ports:
|
||||||
|
- "3005"
|
||||||
|
- "4005:4005"
|
||||||
|
- "5005:5005"
|
||||||
|
|
||||||
|
nitro-rpc-client:
|
||||||
|
image: cerc/nitro-rpc-client:local
|
||||||
|
hostname: nitro-rpc-client
|
||||||
|
restart: on-failure
|
||||||
|
depends_on:
|
||||||
|
# Wait for the go-nitro node to start
|
||||||
|
go-nitro:
|
||||||
|
condition: service_healthy
|
||||||
|
command: ["bash", "-c", "tail -f /dev/null"]
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
go_nitro_data:
|
||||||
|
nitro_deployment:
|
||||||
@@ -15,18 +15,19 @@ services:
|
|||||||
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
||||||
CERC_PUBSUB: ${CERC_PUBSUB}
|
CERC_PUBSUB: ${CERC_PUBSUB}
|
||||||
CERC_GOSSIPSUB_DIRECT_PEERS: ${CERC_GOSSIPSUB_DIRECT_PEERS}
|
CERC_GOSSIPSUB_DIRECT_PEERS: ${CERC_GOSSIPSUB_DIRECT_PEERS}
|
||||||
CERC_RELEASE: "laconic-v3"
|
|
||||||
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
|
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
|
||||||
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
|
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
|
||||||
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
|
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
|
||||||
CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL}
|
CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL}
|
||||||
CERC_PAYMENT_NITRO_ADDRESS: ${CERC_PAYMENT_NITRO_ADDRESS}
|
CERC_PAYMENT_NITRO_ADDRESS: ${CERC_PAYMENT_NITRO_ADDRESS:-0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94}
|
||||||
CERC_SNAP_URL: ${CERC_SNAP_URL}
|
CERC_SNAP_URL: ${CERC_SNAP_URL}
|
||||||
working_dir: /scripts
|
working_dir: /app
|
||||||
command: ["sh", "mobymask-app-start.sh"]
|
command: ["bash", "/scripts/mobymask-app-start.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/watcher-mobymask-v3/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
|
- ../config/watcher-mobymask-v3/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
|
||||||
- ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json
|
- peers_ids:/peers
|
||||||
|
- mobymask_deployment:/server
|
||||||
|
- nitro_deployment:/nitro
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:3004:80"
|
- "127.0.0.1:3004:80"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@@ -37,3 +38,8 @@ services:
|
|||||||
start_period: 10s
|
start_period: 10s
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
peers_ids:
|
||||||
|
mobymask_deployment:
|
||||||
|
nitro_deployment:
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
mobymask-snap:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: cerc/mobymask-snap:local
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:8080:8080"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-vz", "localhost", "8080"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
start_period: 10s
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
# Optionally deploys the Nitro contracts
|
||||||
|
nitro-contracts:
|
||||||
|
image: cerc/nitro-contracts:local
|
||||||
|
restart: on-failure
|
||||||
|
environment:
|
||||||
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
|
CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT:-http://fixturenet-eth-geth-1:8545}
|
||||||
|
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER:-0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218}
|
||||||
|
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
|
||||||
|
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
|
||||||
|
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
|
||||||
|
volumes:
|
||||||
|
- ../config/nitro-contracts/deploy.sh:/app/deploy.sh
|
||||||
|
- nitro_deployment:/app/deployment
|
||||||
|
command: ["bash", "-c", "/app/deploy.sh"]
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
nitro_deployment:
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
nitro-reverse-payment-proxy:
|
||||||
|
image: cerc/go-nitro:local
|
||||||
|
hostname: nitro-reverse-payment-proxy
|
||||||
|
restart: on-failure
|
||||||
|
depends_on:
|
||||||
|
# Wait for the go-nitro node to start
|
||||||
|
go-nitro:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
CERC_PROXY_ADDRESS: 0.0.0.0:8081
|
||||||
|
CERC_PROXY_NITRO_ENDPOINT: ${CERC_PROXY_NITRO_ENDPOINT:-go-nitro:4005/api/v1}
|
||||||
|
CERC_PROXY_DESTINATION_URL: ${CERC_PROXY_DESTINATION_URL:-http://ipld-eth-server:8081}
|
||||||
|
CERC_PROXY_COST_PER_BYTE: ${CERC_PROXY_COST_PER_BYTE:-1}
|
||||||
|
entrypoint: ["bash", "-c", "/app/run-reverse-payment-proxy.sh"]
|
||||||
|
volumes:
|
||||||
|
- ../config/go-nitro/run-reverse-payment-proxy.sh:/app/run-reverse-payment-proxy.sh
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-vz", "localhost", "8081"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
start_period: 10s
|
||||||
|
ports:
|
||||||
|
- "8081:8081"
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
ponder-app:
|
||||||
|
restart: unless-stopped
|
||||||
|
image: cerc/ponder:local
|
||||||
|
working_dir: /app/examples/token-erc20
|
||||||
|
environment:
|
||||||
|
CERC_PONDER_CHAIN_ID: ${PONDER_CHAIN_ID:-99}
|
||||||
|
CERC_PONDER_RPC_URL_1: ${PONDER_RPC_URL_1:-http://nitro-reverse-payment-proxy:8081}
|
||||||
|
CERC_PONDER_NITRO_PK: ${CERC_PONDER_NITRO_PK:-58368d20ff12f17669c06158c21d885897aa56f9be430edc789614bf9851d53f}
|
||||||
|
CERC_PONDER_NITRO_CHAIN_PK: ${CERC_PONDER_NITRO_CHAIN_PK:-fb1e9af328c283ca3e2486e7c24d13582b7912057d8b9542ff41503c85bc05c0}
|
||||||
|
CERC_PONDER_NITRO_CHAIN_URL: ${CERC_PONDER_NITRO_CHAIN_URL:-http://fixturenet-eth-geth-1:8546}
|
||||||
|
CERC_RELAY_MULTIADDR: ${CERC_RELAY_MULTIADDR}
|
||||||
|
CERC_UPSTREAM_NITRO_ADDRESS: ${CERC_UPSTREAM_NITRO_ADDRESS:-0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE}
|
||||||
|
CERC_UPSTREAM_NITRO_MULTIADDR: ${CERC_UPSTREAM_NITRO_MULTIADDR:-/dns4/go-nitro/tcp/5005/ws/p2p/16Uiu2HAmSjXJqsyBJgcBUU2HQmykxGseafSatbpq5471XmuaUqyv}
|
||||||
|
CERC_UPSTREAM_NITRO_PAY_AMOUNT: ${CERC_UPSTREAM_NITRO_PAY_AMOUNT:-5000}
|
||||||
|
command: ["bash", "./ponder-start.sh"]
|
||||||
|
volumes:
|
||||||
|
- ../config/ponder/ponder-start.sh:/app/examples/token-erc20/ponder-start.sh
|
||||||
|
- ../config/ponder/ponder.config.ts:/app/examples/token-erc20/ponder.config.ts
|
||||||
|
- peers_ids:/peers
|
||||||
|
- nitro_deployment:/nitro
|
||||||
|
- ponder_nitro_data:/app/examples/token-erc20/.ponder/nitro-db
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
peers_ids:
|
||||||
|
nitro_deployment:
|
||||||
|
ponder_nitro_data:
|
||||||
@@ -4,6 +4,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
|
CERC_TEST_PARAM_1: ${CERC_TEST_PARAM_1:-FAILED}
|
||||||
volumes:
|
volumes:
|
||||||
- test-data:/data
|
- test-data:/data
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -32,20 +32,13 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
ENV: "PROD"
|
ENV: "PROD"
|
||||||
CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC}
|
CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT}
|
||||||
CERC_L1_ACCOUNTS_CSV_URL: ${CERC_L1_ACCOUNTS_CSV_URL}
|
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER:-0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218}
|
||||||
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER}
|
|
||||||
CERC_MOBYMASK_APP_BASE_URI: ${CERC_MOBYMASK_APP_BASE_URI}
|
CERC_MOBYMASK_APP_BASE_URI: ${CERC_MOBYMASK_APP_BASE_URI}
|
||||||
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
|
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
|
||||||
CERC_L2_GETH_HOST: ${CERC_L2_GETH_HOST}
|
command: ["bash", "-c", "./deploy-and-generate-invite.sh"]
|
||||||
CERC_L2_GETH_PORT: ${CERC_L2_GETH_PORT}
|
|
||||||
CERC_L2_NODE_HOST: ${CERC_L2_NODE_HOST}
|
|
||||||
CERC_L2_NODE_PORT: ${CERC_L2_NODE_PORT}
|
|
||||||
command: ["sh", "deploy-and-generate-invite.sh"]
|
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/network/wait-for-it.sh:/app/packages/server/wait-for-it.sh
|
- ../config/watcher-mobymask-v3/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
|
||||||
- ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json
|
|
||||||
- ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
|
|
||||||
- mobymask_deployment:/app/packages/server
|
- mobymask_deployment:/app/packages/server
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
- "host.docker.internal:host-gateway"
|
- "host.docker.internal:host-gateway"
|
||||||
@@ -62,7 +55,6 @@ services:
|
|||||||
- ../config/watcher-mobymask-v2/generate-peer-ids.sh:/app/packages/peer/generate-peer-ids.sh
|
- ../config/watcher-mobymask-v2/generate-peer-ids.sh:/app/packages/peer/generate-peer-ids.sh
|
||||||
- peers_ids:/peer-ids
|
- peers_ids:/peer-ids
|
||||||
|
|
||||||
# Optionally deploys the Nitro contracts; sets them at the required path
|
|
||||||
# Starts the MobyMask v3 watcher server
|
# Starts the MobyMask v3 watcher server
|
||||||
mobymask-watcher-server:
|
mobymask-watcher-server:
|
||||||
image: cerc/watcher-mobymask-v3:local
|
image: cerc/watcher-mobymask-v3:local
|
||||||
@@ -74,13 +66,15 @@ services:
|
|||||||
condition: service_completed_successfully
|
condition: service_completed_successfully
|
||||||
mobymask:
|
mobymask:
|
||||||
condition: service_completed_successfully
|
condition: service_completed_successfully
|
||||||
|
nitro-contracts:
|
||||||
|
condition: service_completed_successfully
|
||||||
env_file:
|
env_file:
|
||||||
- ../config/watcher-mobymask-v3/mobymask-params.env
|
- ../config/watcher-mobymask-v3/mobymask-params.env
|
||||||
environment:
|
environment:
|
||||||
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC}
|
CERC_ETH_RPC_QUERY_ENDPOINT: ${CERC_ETH_RPC_QUERY_ENDPOINT}
|
||||||
CERC_L1_ACCOUNTS_CSV_URL: ${CERC_L1_ACCOUNTS_CSV_URL}
|
CERC_ETH_RPC_MUTATION_ENDPOINT: ${CERC_ETH_RPC_MUTATION_ENDPOINT}
|
||||||
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER}
|
CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL}
|
||||||
CERC_RELAY_PEERS: ${CERC_RELAY_PEERS}
|
CERC_RELAY_PEERS: ${CERC_RELAY_PEERS}
|
||||||
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
|
||||||
CERC_PUBSUB: ${CERC_PUBSUB}
|
CERC_PUBSUB: ${CERC_PUBSUB}
|
||||||
@@ -90,21 +84,22 @@ services:
|
|||||||
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
|
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
|
||||||
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
|
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
|
||||||
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
|
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
|
||||||
CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER}
|
CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER:-111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f}
|
||||||
CERC_PRIVATE_KEY_NITRO: ${CERC_PRIVATE_KEY_NITRO}
|
CERC_WATCHER_NITRO_PK: ${CERC_WATCHER_NITRO_PK:-0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4}
|
||||||
CERC_PEER_ID: ${CERC_PEER_ID}
|
CERC_PEER_ID: ${CERC_PEER_ID}
|
||||||
entrypoint: ["bash", "-c"]
|
CERC_ENABLE_UPSTREAM_PAYMENTS: ${CERC_ENABLE_UPSTREAM_PAYMENTS}
|
||||||
command: ["./deploy-nitro-contracts.sh && ./start-server.sh"]
|
CERC_UPSTREAM_NITRO_ADDRESS: ${CERC_UPSTREAM_NITRO_ADDRESS:-0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE}
|
||||||
|
CERC_UPSTREAM_NITRO_MULTIADDR: ${CERC_UPSTREAM_NITRO_MULTIADDR:-/dns4/go-nitro/tcp/5005/ws/p2p/16Uiu2HAmSjXJqsyBJgcBUU2HQmykxGseafSatbpq5471XmuaUqyv}
|
||||||
|
CERC_UPSTREAM_NITRO_PAY_AMOUNT: ${CERC_UPSTREAM_NITRO_PAY_AMOUNT:-5000}
|
||||||
|
command: ["bash", "./start-server.sh"]
|
||||||
volumes:
|
volumes:
|
||||||
- ../config/watcher-mobymask-v3/deploy-nitro-contracts.sh:/app/deploy-nitro-contracts.sh
|
|
||||||
- ../config/watcher-mobymask-v3/deploy-nitro-contracts.ts:/app/deploy-nitro-contracts.ts
|
|
||||||
- ../config/watcher-mobymask-v3/watcher-config-template.toml:/app/environments/watcher-config-template.toml
|
- ../config/watcher-mobymask-v3/watcher-config-template.toml:/app/environments/watcher-config-template.toml
|
||||||
- ../config/watcher-mobymask-v3/watcher-config-rates.toml:/app/environments/rates.toml
|
- ../config/watcher-mobymask-v3/watcher-config-rates.toml:/app/environments/rates.toml
|
||||||
- ../config/watcher-mobymask-v3/keys:/app/keys
|
- ../config/watcher-mobymask-v3/keys:/app/keys
|
||||||
- ../config/watcher-mobymask-v3/start-server.sh:/app/start-server.sh
|
- ../config/watcher-mobymask-v3/start-server.sh:/app/start-server.sh
|
||||||
- nitro_data:/app/out/nitro-db
|
- watcher_nitro_data:/app/out/nitro-db
|
||||||
- peers_ids:/app/peers
|
- peers_ids:/app/peers
|
||||||
- nitro_addresses:/nitro
|
- nitro_deployment:/nitro
|
||||||
- mobymask_deployment:/server
|
- mobymask_deployment:/server
|
||||||
# Expose GQL, metrics and relay node ports
|
# Expose GQL, metrics and relay node ports
|
||||||
ports:
|
ports:
|
||||||
@@ -124,5 +119,5 @@ volumes:
|
|||||||
mobymask_watcher_db_data:
|
mobymask_watcher_db_data:
|
||||||
peers_ids:
|
peers_ids:
|
||||||
mobymask_deployment:
|
mobymask_deployment:
|
||||||
nitro_addresses:
|
nitro_deployment:
|
||||||
nitro_data:
|
watcher_nitro_data:
|
||||||
|
|||||||
Executable
+49
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
nitro_addresses_file="/app/deployment/nitro-addresses.json"
|
||||||
|
|
||||||
|
# Check if CERC_NA_ADDRESS environment variable is set
|
||||||
|
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||||
|
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
||||||
|
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
||||||
|
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
|
||||||
|
echo "Using the above Nitro addresses"
|
||||||
|
|
||||||
|
NA_ADDRESS=${CERC_NA_ADDRESS}
|
||||||
|
VPA_ADDRESS=${CERC_VPA_ADDRESS}
|
||||||
|
CA_ADDRESS=${CERC_CA_ADDRESS}
|
||||||
|
elif [ -f ${nitro_addresses_file} ]; then
|
||||||
|
echo "Reading Nitro addresses from ${nitro_addresses_file}"
|
||||||
|
|
||||||
|
NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file})
|
||||||
|
VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file})
|
||||||
|
CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file})
|
||||||
|
else
|
||||||
|
echo "File ${nitro_addresses_file} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running Nitro node"
|
||||||
|
|
||||||
|
# Wait till chain endpoint is available
|
||||||
|
retry_interval=5
|
||||||
|
while true; do
|
||||||
|
# Assuming CERC_NITRO_CHAIN_URL is of format <ws|http>://host:port
|
||||||
|
ws_host=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 1)
|
||||||
|
ws_port=$(echo "$CERC_NITRO_CHAIN_URL" | awk -F '://' '{print $2}' | cut -d ':' -f 2)
|
||||||
|
nc -z -w 1 "$ws_host" "$ws_port"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Chain endpoint is available"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Chain endpoint not yet available, retrying in $retry_interval seconds..."
|
||||||
|
sleep $retry_interval
|
||||||
|
done
|
||||||
|
|
||||||
|
./nitro -chainurl ${CERC_NITRO_CHAIN_URL} -msgport 3005 -rpcport 4005 -wsmsgport 5005 -pk ${CERC_NITRO_PK} -chainpk ${CERC_NITRO_CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${CERC_NITRO_USE_DURABLE_STORE} -durablestorefolder ${CERC_NITRO_DURABLE_STORE_FOLDER}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running Nitro reverse payment proxy"
|
||||||
|
echo "Using CERC_PROXY_ADDRESS ${CERC_PROXY_ADDRESS}"
|
||||||
|
echo "Using CERC_PROXY_NITRO_ENDPOINT ${CERC_PROXY_NITRO_ENDPOINT}"
|
||||||
|
echo "Using CERC_PROXY_DESTINATION_URL ${CERC_PROXY_DESTINATION_URL}"
|
||||||
|
echo "Using CERC_PROXY_COST_PER_BYTE ${CERC_PROXY_COST_PER_BYTE}"
|
||||||
|
|
||||||
|
./proxy -proxyaddress ${CERC_PROXY_ADDRESS} -nitroendpoint=${CERC_PROXY_NITRO_ENDPOINT} -destinationurl=${CERC_PROXY_DESTINATION_URL} -costperbyte ${CERC_PROXY_COST_PER_BYTE} -enablepaidrpcmethods
|
||||||
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
nitro_addresses_file="/app/deployment/nitro-addresses.json"
|
||||||
|
|
||||||
|
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
|
||||||
|
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||||
|
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
||||||
|
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
||||||
|
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
|
||||||
|
echo "Skipping Nitro contracts deployment"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check and exit if a deployment already exists (on restarts)
|
||||||
|
if [ -f ${nitro_addresses_file} ]; then
|
||||||
|
echo "${nitro_addresses_file} already exists, skipping Nitro contracts deployment"
|
||||||
|
cat ${nitro_addresses_file}
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using ETH RPC endpoint ${CERC_ETH_RPC_ENDPOINT}"
|
||||||
|
|
||||||
|
# Wait till ETH RPC endpoint is available with block number > 1
|
||||||
|
retry_interval=5
|
||||||
|
while true; do
|
||||||
|
block_number_hex=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ${CERC_ETH_RPC_ENDPOINT} | jq -r '.result')
|
||||||
|
|
||||||
|
# Check if the request call was successful
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
|
||||||
|
sleep $retry_interval
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Convert hex to decimal
|
||||||
|
block_number_dec=$(printf %u ${block_number_hex})
|
||||||
|
|
||||||
|
# Check if block number is > 1 to avoid failures in the deployment
|
||||||
|
if [ "$block_number_dec" -ge 1 ]; then
|
||||||
|
echo "RPC endpoint is up"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
|
||||||
|
sleep $retry_interval
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
|
||||||
|
|
||||||
|
yarn test:deploy-contracts --chainUrl ${CERC_ETH_RPC_ENDPOINT} --key ${CERC_PRIVATE_KEY_DEPLOYER} --addressesFilePath ${nitro_addresses_file}
|
||||||
|
cat ${nitro_addresses_file}
|
||||||
Executable
+60
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
nitro_addresses_file="/nitro/nitro-addresses.json"
|
||||||
|
nitro_addresses_destination_file="/app/examples/token-erc20/nitro-addresses.json"
|
||||||
|
|
||||||
|
# Check if CERC_NA_ADDRESS environment variable is set
|
||||||
|
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||||
|
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
||||||
|
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
||||||
|
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
|
||||||
|
echo "Using the above Nitro addresses"
|
||||||
|
|
||||||
|
# Create the required JSON and write it to a file
|
||||||
|
nitro_addresses_json=$(jq -n \
|
||||||
|
--arg na "$CERC_NA_ADDRESS" \
|
||||||
|
--arg vpa "$CERC_VPA_ADDRESS" \
|
||||||
|
--arg ca "$CERC_CA_ADDRESS" \
|
||||||
|
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
|
||||||
|
echo "$nitro_addresses_json" > "${nitro_addresses_destination_file}"
|
||||||
|
elif [ -f ${nitro_addresses_file} ]; then
|
||||||
|
echo "Using Nitro addresses from ${nitro_addresses_file}:"
|
||||||
|
cat "$nitro_addresses_file"
|
||||||
|
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
|
||||||
|
else
|
||||||
|
echo "Nitro addresses not available"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using CERC_PONDER_NITRO_PK from env for Nitro account"
|
||||||
|
echo "Using CERC_PONDER_NITRO_CHAIN_PK (account with funds) from env for sending Nitro txs"
|
||||||
|
echo "Using ${CERC_PONDER_NITRO_CHAIN_URL} as the RPC endpoint for Nitro txs"
|
||||||
|
|
||||||
|
# If not set, check the mounted volume for relay peer id
|
||||||
|
if [ -z "$CERC_RELAY_MULTIADDR" ]; then
|
||||||
|
echo "CERC_RELAY_MULTIADDR not provided, taking from the mounted volume"
|
||||||
|
CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
env_file='.env.local'
|
||||||
|
echo "PONDER_TELEMETRY_DISABLED=true" > "$env_file"
|
||||||
|
echo "PONDER_LOG_LEVEL=debug" >> "$env_file"
|
||||||
|
echo "PONDER_CHAIN_ID=\"$CERC_PONDER_CHAIN_ID\"" >> "$env_file"
|
||||||
|
echo "PONDER_RPC_URL_1=\"$CERC_PONDER_RPC_URL_1\"" >> "$env_file"
|
||||||
|
echo "PONDER_NITRO_PK=\"$CERC_PONDER_NITRO_PK\"" >> "$env_file"
|
||||||
|
echo "PONDER_NITRO_CHAIN_PK=\"$CERC_PONDER_NITRO_CHAIN_PK\"" >> "$env_file"
|
||||||
|
echo "PONDER_NITRO_CHAIN_URL=\"$CERC_PONDER_NITRO_CHAIN_URL\"" >> "$env_file"
|
||||||
|
echo "RELAY_MULTIADDR=\"$CERC_RELAY_MULTIADDR\"" >> "$env_file"
|
||||||
|
echo "UPSTREAM_NITRO_ADDRESS=\"$CERC_UPSTREAM_NITRO_ADDRESS\"" >> "$env_file"
|
||||||
|
echo "UPSTREAM_NITRO_MULTIADDR=\"$CERC_UPSTREAM_NITRO_MULTIADDR\"" >> "$env_file"
|
||||||
|
echo "UPSTREAM_NITRO_PAY_AMOUNT=\"$CERC_UPSTREAM_NITRO_PAY_AMOUNT\"" >> "$env_file"
|
||||||
|
|
||||||
|
cat "$env_file"
|
||||||
|
|
||||||
|
# Keep the container running
|
||||||
|
tail -f
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import type { Config } from "@ponder/core";
|
||||||
|
|
||||||
|
import contractAddresses from "./nitro-addresses.json";
|
||||||
|
|
||||||
|
export const config: Config = {
|
||||||
|
networks: [
|
||||||
|
{
|
||||||
|
name: "fixturenet",
|
||||||
|
chainId: Number(process.env.PONDER_CHAIN_ID),
|
||||||
|
rpcUrl: process.env.PONDER_RPC_URL_1,
|
||||||
|
maxRpcRequestConcurrency: 1,
|
||||||
|
pollingInterval: 5000,
|
||||||
|
payments: {
|
||||||
|
nitro: {
|
||||||
|
address: process.env.UPSTREAM_NITRO_ADDRESS!,
|
||||||
|
multiAddr: process.env.UPSTREAM_NITRO_MULTIADDR!,
|
||||||
|
fundingAmounts: {
|
||||||
|
// TODO: Pass amounts from env
|
||||||
|
directFund: "1000000000000",
|
||||||
|
virtualFund: "1000000000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
paidRPCMethods: [
|
||||||
|
"eth_getLogs",
|
||||||
|
"eth_getBlockByNumber",
|
||||||
|
"eth_getBlockByHash",
|
||||||
|
],
|
||||||
|
amount: process.env.UPSTREAM_NITRO_PAY_AMOUNT!,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
contracts: [
|
||||||
|
{
|
||||||
|
name: "AdventureGold",
|
||||||
|
network: "fixturenet",
|
||||||
|
abi: "./abis/AdventureGold.json",
|
||||||
|
address: "0x32353A6C91143bfd6C7d363B546e62a9A2489A20",
|
||||||
|
startBlock: 5,
|
||||||
|
maxBlockRange: 100,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
nitro: {
|
||||||
|
privateKey: process.env.PONDER_NITRO_PK!,
|
||||||
|
chainPrivateKey: process.env.PONDER_NITRO_CHAIN_PK!,
|
||||||
|
chainUrl: process.env.PONDER_NITRO_CHAIN_URL!,
|
||||||
|
contractAddresses,
|
||||||
|
relayMultiAddr: process.env.RELAY_MULTIADDR!,
|
||||||
|
store: "./.ponder/nitro-db",
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
CERC_ETH_RPC_ENDPOINT="${CERC_ETH_RPC_ENDPOINT:-${DEFAULT_CERC_ETH_RPC_ENDPOINT}}"
|
||||||
|
CERC_MOBYMASK_APP_BASE_URI="${CERC_MOBYMASK_APP_BASE_URI:-${DEFAULT_CERC_MOBYMASK_APP_BASE_URI}}"
|
||||||
|
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
|
||||||
|
|
||||||
|
# Check if CERC_DEPLOYED_CONTRACT environment variable set to skip contract deployment
|
||||||
|
if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
|
||||||
|
echo "CERC_DEPLOYED_CONTRACT is set to '$CERC_DEPLOYED_CONTRACT'"
|
||||||
|
echo "Skipping contract deployment"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using ETH RPC endpoint ${CERC_ETH_RPC_ENDPOINT}"
|
||||||
|
|
||||||
|
# Wait till ETH RPC endpoint is available with block number > 1
|
||||||
|
retry_interval=5
|
||||||
|
while true; do
|
||||||
|
block_number_hex=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ${CERC_ETH_RPC_ENDPOINT} | jq -r '.result')
|
||||||
|
|
||||||
|
# Check if the request call was successful
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
|
||||||
|
sleep $retry_interval
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Convert hex to decimal
|
||||||
|
block_number_dec=$(printf %u ${block_number_hex})
|
||||||
|
|
||||||
|
# Check if block number is > 1 to avoid failures in the deployment
|
||||||
|
if [ "$block_number_dec" -ge 1 ]; then
|
||||||
|
echo "RPC endpoint is up"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
|
||||||
|
sleep $retry_interval
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
|
||||||
|
|
||||||
|
# Create the required JSON and write it to a file
|
||||||
|
secrets_file="secrets.json"
|
||||||
|
secrets_json=$(jq -n \
|
||||||
|
--arg privateKey "$CERC_PRIVATE_KEY_DEPLOYER" \
|
||||||
|
--arg rpcUrl "$CERC_ETH_RPC_ENDPOINT" \
|
||||||
|
--arg baseURI "$CERC_MOBYMASK_APP_BASE_URI" \
|
||||||
|
'.privateKey = $privateKey | .rpcUrl = $rpcUrl | .baseURI = $baseURI')
|
||||||
|
echo "$secrets_json" > "${secrets_file}"
|
||||||
|
|
||||||
|
export RPC_URL="${CERC_ETH_RPC_ENDPOINT}"
|
||||||
|
|
||||||
|
# Check and exit if a deployment already exists (on restarts)
|
||||||
|
if [ -f ./config.json ]; then
|
||||||
|
echo "config.json already exists, checking the contract deployment"
|
||||||
|
|
||||||
|
# Read JSON file
|
||||||
|
deployment_details=$(cat config.json)
|
||||||
|
deployed_contract=$(echo "$deployment_details" | jq -r '.address')
|
||||||
|
|
||||||
|
cd ../hardhat
|
||||||
|
if yarn verifyDeployment --network optimism --contract "${deployed_contract}"; then
|
||||||
|
echo "Deployment verfication successful"
|
||||||
|
cd ../server
|
||||||
|
else
|
||||||
|
echo "Deployment verfication failed, please clear MobyMask deployment volume before starting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
npm run deployAndGenerateInvite
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
|
|
||||||
CERC_NA_ADDRESS="${CERC_NA_ADDRESS:-${DEFAULT_CERC_NA_ADDRESS}}"
|
|
||||||
CERC_VPA_ADDRESS="${CERC_VPA_ADDRESS:-${DEFAULT_CERC_VPA_ADDRESS}}"
|
|
||||||
CERC_CA_ADDRESS="${CERC_CA_ADDRESS:-${DEFAULT_CERC_CA_ADDRESS}}"
|
|
||||||
|
|
||||||
NITRO_ADDRESSES_FILE_PATH="/nitro/nitro-addresses.json"
|
|
||||||
|
|
||||||
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
|
|
||||||
if [ -n "$CERC_NA_ADDRESS" ]; then
|
|
||||||
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
|
||||||
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
|
||||||
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
|
|
||||||
echo "Using the above addresses and skipping Nitro contracts deployment"
|
|
||||||
|
|
||||||
# Create the required JSON and write it to a file
|
|
||||||
nitro_addresses_json=$(jq -n \
|
|
||||||
--arg na "$CERC_NA_ADDRESS" \
|
|
||||||
--arg vpa "$CERC_VPA_ADDRESS" \
|
|
||||||
--arg ca "$CERC_CA_ADDRESS" \
|
|
||||||
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
|
|
||||||
echo "$nitro_addresses_json" > "${NITRO_ADDRESSES_FILE_PATH}"
|
|
||||||
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check and exit if a deployment already exists (on restarts)
|
|
||||||
if [ -f ${NITRO_ADDRESSES_FILE_PATH} ]; then
|
|
||||||
echo "${NITRO_ADDRESSES_FILE_PATH} already exists, skipping Nitro contracts deployment"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
|
|
||||||
|
|
||||||
if [ -n "$CERC_L1_ACCOUNTS_CSV_URL" ] && \
|
|
||||||
l1_accounts_response=$(curl -L --write-out '%{http_code}' --silent --output /dev/null "$CERC_L1_ACCOUNTS_CSV_URL") && \
|
|
||||||
[ "$l1_accounts_response" -eq 200 ];
|
|
||||||
then
|
|
||||||
echo "Fetching L1 account credentials using provided URL"
|
|
||||||
mkdir -p /geth-accounts
|
|
||||||
wget -O /geth-accounts/accounts.csv "$CERC_L1_ACCOUNTS_CSV_URL"
|
|
||||||
|
|
||||||
# Read the private key of an L1 account to deploy contract
|
|
||||||
CERC_PRIVATE_KEY_DEPLOYER=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3)
|
|
||||||
else
|
|
||||||
echo "Couldn't fetch L1 account credentials, using CERC_PRIVATE_KEY_DEPLOYER from env"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "RPC_URL=${CERC_L2_GETH_RPC}" > .env
|
|
||||||
echo "NITRO_ADDRESSES_FILE_PATH=${NITRO_ADDRESSES_FILE_PATH}" >> .env
|
|
||||||
echo "PRIVATE_KEY=${CERC_PRIVATE_KEY_DEPLOYER}" >> .env
|
|
||||||
|
|
||||||
yarn ts-node --esm deploy-nitro-contracts.ts
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import 'dotenv/config';
|
|
||||||
import fs from 'fs';
|
|
||||||
import { providers, Wallet } from 'ethers';
|
|
||||||
import { deployContracts } from '@cerc-io/nitro-util';
|
|
||||||
|
|
||||||
async function main () {
|
|
||||||
const rpcURL = process.env.RPC_URL;
|
|
||||||
const addressesFilePath = process.env.NITRO_ADDRESSES_FILE_PATH;
|
|
||||||
const deployerKey = process.env.PRIVATE_KEY;
|
|
||||||
|
|
||||||
if (!rpcURL) {
|
|
||||||
console.log('RPC_URL not set, skipping deployment');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!addressesFilePath) {
|
|
||||||
console.log('NITRO_ADDRESSES_FILE_PATH not set, skipping deployment');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!deployerKey) {
|
|
||||||
console.log('PRIVATE_KEY not set, skipping deployment');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const provider = new providers.JsonRpcProvider(process.env.RPC_URL);
|
|
||||||
const signer = new Wallet(deployerKey, provider);
|
|
||||||
|
|
||||||
const [
|
|
||||||
nitroAdjudicatorAddress,
|
|
||||||
virtualPaymentAppAddress,
|
|
||||||
consensusAppAddress
|
|
||||||
] = await deployContracts(signer as any);
|
|
||||||
|
|
||||||
const output = {
|
|
||||||
nitroAdjudicatorAddress,
|
|
||||||
virtualPaymentAppAddress,
|
|
||||||
consensusAppAddress
|
|
||||||
};
|
|
||||||
|
|
||||||
fs.writeFileSync(addressesFilePath, JSON.stringify(output, null, 2));
|
|
||||||
console.log('Nitro contracts deployed, addresses written to', addressesFilePath);
|
|
||||||
console.log('Result:', JSON.stringify(output, null, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
@@ -11,21 +11,36 @@ CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
|
|||||||
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
|
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
|
||||||
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
|
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
|
||||||
CERC_GOSSIPSUB_DIRECT_PEERS="${CERC_GOSSIPSUB_DIRECT_PEERS:-${DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS}}"
|
CERC_GOSSIPSUB_DIRECT_PEERS="${CERC_GOSSIPSUB_DIRECT_PEERS:-${DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS}}"
|
||||||
|
CERC_APP_WATCHER_URL="${CERC_APP_WATCHER_URL:-${DEFAULT_CERC_APP_WATCHER_URL}}"
|
||||||
|
CERC_SNAP_URL="${CERC_SNAP_URL:-${DEFAULT_CERC_SNAP_URL}}"
|
||||||
|
|
||||||
|
# If not set (or []), check the mounted volume for relay peer id
|
||||||
|
if [ -z "$CERC_RELAY_NODES" ] || [ "$CERC_RELAY_NODES" = "[]" ]; then
|
||||||
|
echo "CERC_RELAY_NODES not provided, taking from the mounted volume"
|
||||||
|
CERC_RELAY_NODES="[\"/ip4/127.0.0.1/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)\"]"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Using CERC_RELAY_NODES $CERC_RELAY_NODES"
|
echo "Using CERC_RELAY_NODES $CERC_RELAY_NODES"
|
||||||
|
|
||||||
if [ -z "$CERC_DEPLOYED_CONTRACT" ]; then
|
if [ -z "$CERC_DEPLOYED_CONTRACT" ]; then
|
||||||
echo "CERC_DEPLOYED_CONTRACT not set"
|
# Use config from mounted volume (when running web-app along with watcher stack)
|
||||||
exit 1
|
echo "Taking config for deployed contract from mounted volume"
|
||||||
|
while [ ! -f /server/config.json ]; do
|
||||||
|
echo "Config not found, retrying in 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
# Get deployed contract address and chain id
|
||||||
|
CERC_DEPLOYED_CONTRACT=$(jq -r '.address' /server/config.json | tr -d '"')
|
||||||
|
CERC_CHAIN_ID=$(jq -r '.chainId' /server/config.json)
|
||||||
else
|
else
|
||||||
echo "Using CERC_DEPLOYED_CONTRACT ${CERC_DEPLOYED_CONTRACT} from env as the MobyMask contract address"
|
echo "Using CERC_DEPLOYED_CONTRACT ${CERC_DEPLOYED_CONTRACT} from env as the MobyMask contract address"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checkout to the required release/branch
|
nitro_addresses_file="/nitro/nitro-addresses.json"
|
||||||
cd /app
|
nitro_addresses_destination_file="/app/src/utils/nitro-addresses.json"
|
||||||
git checkout $CERC_RELEASE
|
|
||||||
|
|
||||||
# Check if CERC_NA_ADDRESS is set
|
# Check if CERC_NA_ADDRESS environment variable is set
|
||||||
if [ -n "$CERC_NA_ADDRESS" ]; then
|
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||||
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
||||||
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
||||||
@@ -38,24 +53,31 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
|
|||||||
--arg vpa "$CERC_VPA_ADDRESS" \
|
--arg vpa "$CERC_VPA_ADDRESS" \
|
||||||
--arg ca "$CERC_CA_ADDRESS" \
|
--arg ca "$CERC_CA_ADDRESS" \
|
||||||
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
|
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
|
||||||
echo "$nitro_addresses_json" > /app/src/utils/nitro-addresses.json
|
echo "$nitro_addresses_json" > "${nitro_addresses_destination_file}"
|
||||||
|
elif [ -f ${nitro_addresses_file} ]; then
|
||||||
|
echo "Using Nitro addresses from ${nitro_addresses_file}:"
|
||||||
|
cat "$nitro_addresses_file"
|
||||||
|
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
|
||||||
else
|
else
|
||||||
echo "Nitro addresses not provided"
|
echo "Nitro addresses not available"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Export config values in a json file
|
# Export config values in a json file
|
||||||
jq --arg address "$CERC_DEPLOYED_CONTRACT" \
|
app_config_file="/app/src/utils/config.json"
|
||||||
|
app_config_json=$(jq -n \
|
||||||
|
--arg name "MobyMask" \
|
||||||
|
--argjson enableDebugInfo true \
|
||||||
|
--arg address "$CERC_DEPLOYED_CONTRACT" \
|
||||||
--argjson chainId "$CERC_CHAIN_ID" \
|
--argjson chainId "$CERC_CHAIN_ID" \
|
||||||
--argjson relayNodes "$CERC_RELAY_NODES" \
|
--argjson relayNodes "$CERC_RELAY_NODES" \
|
||||||
--argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \
|
--argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \
|
||||||
--arg pubsub "$CERC_PUBSUB" \
|
--arg pubsub "$CERC_PUBSUB" \
|
||||||
--argjson directPeers "$CERC_GOSSIPSUB_DIRECT_PEERS" \
|
--argjson directPeers "$CERC_GOSSIPSUB_DIRECT_PEERS" \
|
||||||
'.address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub | .peer.directPeers = $directPeers' \
|
'.name = $name | .address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.enableDebugInfo = $enableDebugInfo | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub | .peer.directPeers = $directPeers')
|
||||||
/app/src/mobymask-app-config.json > /app/src/utils/config.json
|
echo "$app_config_json" > "${app_config_file}"
|
||||||
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
|
REACT_APP_DEBUG_PEER=true \
|
||||||
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" \
|
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" \
|
||||||
REACT_APP_PAY_TO_NITRO_ADDRESS="$CERC_PAYMENT_NITRO_ADDRESS" \
|
REACT_APP_PAY_TO_NITRO_ADDRESS="$CERC_PAYMENT_NITRO_ADDRESS" \
|
||||||
REACT_APP_SNAP_ORIGIN="local:$CERC_SNAP_URL" \
|
REACT_APP_SNAP_ORIGIN="local:$CERC_SNAP_URL" \
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
# Defaults
|
# Defaults
|
||||||
|
|
||||||
|
# ETH RPC endpoint used for contract(s) deployment
|
||||||
|
DEFAULT_CERC_ETH_RPC_ENDPOINT="http://fixturenet-eth-geth-1:8545"
|
||||||
|
|
||||||
|
# ETH RPC endpoint used for queries in the watcher
|
||||||
|
DEFAULT_CERC_ETH_RPC_QUERY_ENDPOINT="http://nitro-reverse-payment-proxy:8081"
|
||||||
|
|
||||||
|
# ETH RPC endpoint used for mutations in the watcher
|
||||||
|
DEFAULT_CERC_ETH_RPC_MUTATION_ENDPOINT="http://fixturenet-eth-geth-1:8545"
|
||||||
|
|
||||||
|
# ETH endpoint used by watcher's Nitro node
|
||||||
|
DEFAULT_CERC_NITRO_CHAIN_URL="http://fixturenet-eth-geth-1:8546"
|
||||||
|
|
||||||
# Set of relay peers to connect to from the relay node
|
# Set of relay peers to connect to from the relay node
|
||||||
DEFAULT_CERC_RELAY_PEERS=[]
|
DEFAULT_CERC_RELAY_PEERS=[]
|
||||||
|
|
||||||
@@ -17,7 +29,13 @@ DEFAULT_CERC_ENABLE_PEER_L2_TXS=true
|
|||||||
DEFAULT_CERC_DEPLOYED_CONTRACT=
|
DEFAULT_CERC_DEPLOYED_CONTRACT=
|
||||||
|
|
||||||
# Chain ID is used by mobymask web-app for txs
|
# Chain ID is used by mobymask web-app for txs
|
||||||
DEFAULT_CERC_CHAIN_ID=42069
|
DEFAULT_CERC_CHAIN_ID=1212
|
||||||
|
|
||||||
|
# Watcher endpoint used by the web-app
|
||||||
|
DEFAULT_CERC_APP_WATCHER_URL="http://localhost:3001"
|
||||||
|
|
||||||
|
# MobyMask snap URL to be used by the web-app
|
||||||
|
DEFAULT_CERC_SNAP_URL=http://localhost:8080
|
||||||
|
|
||||||
# Set of relay nodes to be used by web-apps
|
# Set of relay nodes to be used by web-apps
|
||||||
DEFAULT_CERC_RELAY_NODES=[]
|
DEFAULT_CERC_RELAY_NODES=[]
|
||||||
@@ -31,7 +49,5 @@ DEFAULT_CERC_PUBSUB=""
|
|||||||
# Set of direct peers to be used when pubsub is set to gossipsub
|
# Set of direct peers to be used when pubsub is set to gossipsub
|
||||||
DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS=[]
|
DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS=[]
|
||||||
|
|
||||||
# Set deployed Nitro addresses to avoid deploying them in the stack
|
# Whether to enable payments to upstream ETH server
|
||||||
DEFAULT_CERC_NA_ADDRESS=
|
DEFAULT_CERC_ENABLE_UPSTREAM_PAYMENTS=true
|
||||||
DEFAULT_CERC_VPA_ADDRESS=
|
|
||||||
DEFAULT_CERC_CA_ADDRESS=
|
|
||||||
|
|||||||
@@ -5,21 +5,22 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CERC_L2_GETH_RPC="${CERC_L2_GETH_RPC:-${DEFAULT_CERC_L2_GETH_RPC}}"
|
CERC_ETH_RPC_QUERY_ENDPOINT="${CERC_ETH_RPC_QUERY_ENDPOINT:-${DEFAULT_CERC_ETH_RPC_QUERY_ENDPOINT}}"
|
||||||
|
CERC_ETH_RPC_MUTATION_ENDPOINT="${CERC_ETH_RPC_MUTATION_ENDPOINT:-${DEFAULT_CERC_ETH_RPC_MUTATION_ENDPOINT}}"
|
||||||
|
CERC_NITRO_CHAIN_URL="${CERC_NITRO_CHAIN_URL:-${DEFAULT_CERC_NITRO_CHAIN_URL}}"
|
||||||
CERC_RELAY_PEERS="${CERC_RELAY_PEERS:-${DEFAULT_CERC_RELAY_PEERS}}"
|
CERC_RELAY_PEERS="${CERC_RELAY_PEERS:-${DEFAULT_CERC_RELAY_PEERS}}"
|
||||||
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
|
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
|
||||||
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
|
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
|
||||||
CERC_RELAY_ANNOUNCE_DOMAIN="${CERC_RELAY_ANNOUNCE_DOMAIN:-${DEFAULT_CERC_RELAY_ANNOUNCE_DOMAIN}}"
|
CERC_RELAY_ANNOUNCE_DOMAIN="${CERC_RELAY_ANNOUNCE_DOMAIN:-${DEFAULT_CERC_RELAY_ANNOUNCE_DOMAIN}}"
|
||||||
CERC_ENABLE_PEER_L2_TXS="${CERC_ENABLE_PEER_L2_TXS:-${DEFAULT_CERC_ENABLE_PEER_L2_TXS}}"
|
CERC_ENABLE_PEER_L2_TXS="${CERC_ENABLE_PEER_L2_TXS:-${DEFAULT_CERC_ENABLE_PEER_L2_TXS}}"
|
||||||
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
|
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
|
||||||
|
CERC_ENABLE_UPSTREAM_PAYMENTS="${CERC_ENABLE_UPSTREAM_PAYMENTS:-${DEFAULT_CERC_ENABLE_UPSTREAM_PAYMENTS}}"
|
||||||
nitro_addresses_file="/nitro/nitro-addresses.json"
|
|
||||||
nitro_addresses_destination_file="./src/nitro-addresses.json"
|
|
||||||
|
|
||||||
watcher_keys_dir="./keys"
|
watcher_keys_dir="./keys"
|
||||||
|
|
||||||
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
|
echo "Using RPC query endpoint ${CERC_ETH_RPC_QUERY_ENDPOINT}"
|
||||||
|
echo "Using RPC mutation endpoint ${CERC_ETH_RPC_MUTATION_ENDPOINT}"
|
||||||
|
echo "Using Nitro chain URL ${CERC_NITRO_CHAIN_URL}"
|
||||||
|
|
||||||
# Use public domain for relay multiaddr in peer config if specified
|
# Use public domain for relay multiaddr in peer config if specified
|
||||||
# Otherwise, use the docker container's host IP
|
# Otherwise, use the docker container's host IP
|
||||||
@@ -37,20 +38,37 @@ else
|
|||||||
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
|
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the deployed Nitro addresses to the required path
|
nitro_addresses_file="/nitro/nitro-addresses.json"
|
||||||
if [ -f "$nitro_addresses_file" ]; then
|
nitro_addresses_destination_file="./src/nitro-addresses.json"
|
||||||
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
|
|
||||||
echo "Nitro addresses set to ${nitro_addresses_destination_file}"
|
|
||||||
|
|
||||||
# Build after setting the Nitro addresses
|
# Check if CERC_NA_ADDRESS environment variable is set
|
||||||
yarn build
|
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||||
|
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
||||||
|
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
||||||
|
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
|
||||||
|
echo "Using the above Nitro addresses"
|
||||||
|
|
||||||
|
# Create the required JSON and write it to a file
|
||||||
|
nitro_addresses_json=$(jq -n \
|
||||||
|
--arg na "$CERC_NA_ADDRESS" \
|
||||||
|
--arg vpa "$CERC_VPA_ADDRESS" \
|
||||||
|
--arg ca "$CERC_CA_ADDRESS" \
|
||||||
|
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
|
||||||
|
echo "$nitro_addresses_json" > "${nitro_addresses_destination_file}"
|
||||||
|
elif [ -f ${nitro_addresses_file} ]; then
|
||||||
|
echo "Using Nitro addresses from ${nitro_addresses_file}:"
|
||||||
|
cat "$nitro_addresses_file"
|
||||||
|
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
|
||||||
else
|
else
|
||||||
echo "File ${nitro_addresses_file} does not exist"
|
echo "Nitro addresses not available"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Build after setting the Nitro addresses
|
||||||
|
yarn build
|
||||||
|
|
||||||
echo "Using CERC_PRIVATE_KEY_PEER (account with funds) from env for sending txs to L2"
|
echo "Using CERC_PRIVATE_KEY_PEER (account with funds) from env for sending txs to L2"
|
||||||
echo "Using CERC_PRIVATE_KEY_NITRO from env for Nitro account"
|
echo "Using CERC_WATCHER_NITRO_PK from env for Nitro account"
|
||||||
|
|
||||||
if [ -n "$CERC_PEER_ID" ]; then
|
if [ -n "$CERC_PEER_ID" ]; then
|
||||||
echo "Using CERC_PEER_ID ${CERC_PEER_ID} from env for watcher fixture"
|
echo "Using CERC_PEER_ID ${CERC_PEER_ID} from env for watcher fixture"
|
||||||
@@ -107,24 +125,39 @@ else
|
|||||||
CONSENSUS_PRIVATE_KEY=''
|
CONSENSUS_PRIVATE_KEY=''
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$CERC_ENABLE_UPSTREAM_PAYMENTS" = true ]; then
|
||||||
|
UPSTREAM_NITRO_ADDRESS=${CERC_UPSTREAM_NITRO_ADDRESS}
|
||||||
|
UPSTREAM_NITRO_MULTIADDR=${CERC_UPSTREAM_NITRO_MULTIADDR}
|
||||||
|
UPSTREAM_NITRO_PAY_AMOUNT=${CERC_UPSTREAM_NITRO_PAY_AMOUNT}
|
||||||
|
else
|
||||||
|
UPSTREAM_NITRO_ADDRESS=""
|
||||||
|
UPSTREAM_NITRO_MULTIADDR=""
|
||||||
|
UPSTREAM_NITRO_PAY_AMOUNT=""
|
||||||
|
fi
|
||||||
|
|
||||||
# Read in the config template TOML file and modify it
|
# Read in the config template TOML file and modify it
|
||||||
WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml)
|
WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml)
|
||||||
WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
|
WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
|
||||||
sed -E "s|REPLACE_WITH_CERC_RELAY_PEERS|${CERC_RELAY_PEERS}|g; \
|
sed -E "s|REPLACE_WITH_CERC_RELAY_PEERS|${CERC_RELAY_PEERS}|g; \
|
||||||
s|REPLACE_WITH_CERC_DENY_MULTIADDRS|${CERC_DENY_MULTIADDRS}|g; \
|
s|REPLACE_WITH_CERC_DENY_MULTIADDRS|${CERC_DENY_MULTIADDRS}|g; \
|
||||||
s/REPLACE_WITH_CERC_PUBSUB/${CERC_PUBSUB}/g; \
|
s/REPLACE_WITH_CERC_PUBSUB/${CERC_PUBSUB}/g; \
|
||||||
s/REPLACE_WITH_CERC_RELAY_ANNOUNCE_DOMAIN/${CERC_RELAY_ANNOUNCE_DOMAIN}/g; \
|
s/REPLACE_WITH_CERC_RELAY_ANNOUNCE_DOMAIN/${CERC_RELAY_ANNOUNCE_DOMAIN}/g; \
|
||||||
s|REPLACE_WITH_CERC_RELAY_MULTIADDR|${CERC_RELAY_MULTIADDR}|g; \
|
s|REPLACE_WITH_CERC_RELAY_MULTIADDR|${CERC_RELAY_MULTIADDR}|g; \
|
||||||
s|REPLACE_WITH_PEER_ID_FILE|${PEER_ID_FILE}|g; \
|
s|REPLACE_WITH_PEER_ID_FILE|${PEER_ID_FILE}|g; \
|
||||||
s/REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS/${CERC_ENABLE_PEER_L2_TXS}/g; \
|
s/REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS/${CERC_ENABLE_PEER_L2_TXS}/g; \
|
||||||
s/REPLACE_WITH_CERC_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \
|
s/REPLACE_WITH_CERC_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \
|
||||||
s/REPLACE_WITH_CERC_PRIVATE_KEY_NITRO/${CERC_PRIVATE_KEY_NITRO}/g; \
|
s/REPLACE_WITH_CERC_WATCHER_NITRO_PK/${CERC_WATCHER_NITRO_PK}/g; \
|
||||||
s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \
|
s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \
|
||||||
s/REPLACE_WITH_CONSENSUS_ENABLED/${CONSENSUS_ENABLED}/g; \
|
s|REPLACE_WITH_CERC_NITRO_CHAIN_URL|${CERC_NITRO_CHAIN_URL}|g; \
|
||||||
s/REPLACE_WITH_CONSENSUS_PUBLIC_KEY/${CONSENSUS_PUBLIC_KEY}/g; \
|
s/REPLACE_WITH_CONSENSUS_ENABLED/${CONSENSUS_ENABLED}/g; \
|
||||||
s/REPLACE_WITH_CONSENSUS_PRIVATE_KEY/${CONSENSUS_PRIVATE_KEY}/g; \
|
s/REPLACE_WITH_CONSENSUS_PUBLIC_KEY/${CONSENSUS_PUBLIC_KEY}/g; \
|
||||||
s|REPLACE_WITH_WATCHER_PARTY_PEERS_FILE|${WATCHER_PARTY_PEERS_FILE}|g; \
|
s/REPLACE_WITH_CONSENSUS_PRIVATE_KEY/${CONSENSUS_PRIVATE_KEY}/g; \
|
||||||
s|REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT|${CERC_L2_GETH_RPC}| ")
|
s|REPLACE_WITH_WATCHER_PARTY_PEERS_FILE|${WATCHER_PARTY_PEERS_FILE}|g; \
|
||||||
|
s|REPLACE_WITH_CERC_ETH_RPC_QUERY_ENDPOINT|${CERC_ETH_RPC_QUERY_ENDPOINT}|g; \
|
||||||
|
s|REPLACE_WITH_CERC_ETH_RPC_MUTATION_ENDPOINT|${CERC_ETH_RPC_MUTATION_ENDPOINT}|g; \
|
||||||
|
s/REPLACE_WITH_UPSTREAM_NITRO_ADDRESS/${UPSTREAM_NITRO_ADDRESS}/g; \
|
||||||
|
s|REPLACE_WITH_UPSTREAM_NITRO_MULTIADDR|${UPSTREAM_NITRO_MULTIADDR}|g; \
|
||||||
|
s/REPLACE_WITH_UPSTREAM_NITRO_PAY_AMOUNT/${UPSTREAM_NITRO_PAY_AMOUNT}/ ")
|
||||||
|
|
||||||
# Write the modified content to a new file
|
# Write the modified content to a new file
|
||||||
echo "$WATCHER_CONFIG" > environments/local.toml
|
echo "$WATCHER_CONFIG" > environments/local.toml
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
# Use -1 for skipping check on block range.
|
# Use -1 for skipping check on block range.
|
||||||
maxEventsBlockRange = -1
|
maxEventsBlockRange = -1
|
||||||
|
|
||||||
|
# Flag to specify whether RPC endpoint supports block hash as block tag parameter
|
||||||
|
rpcSupportsBlockHashParam = true
|
||||||
|
|
||||||
[server.p2p]
|
[server.p2p]
|
||||||
enableRelay = true
|
enableRelay = true
|
||||||
enablePeer = true
|
enablePeer = true
|
||||||
@@ -41,14 +44,18 @@
|
|||||||
pubsub = 'REPLACE_WITH_CERC_PUBSUB'
|
pubsub = 'REPLACE_WITH_CERC_PUBSUB'
|
||||||
enableDebugInfo = true
|
enableDebugInfo = true
|
||||||
enableL2Txs = REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS
|
enableL2Txs = REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS
|
||||||
|
pingInterval = 4000
|
||||||
|
pingTimeout = 1500
|
||||||
|
maxRelayConnections = 10
|
||||||
|
|
||||||
[server.p2p.peer.l2TxsConfig]
|
[server.p2p.peer.l2TxsConfig]
|
||||||
privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
|
privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
|
||||||
contractAddress = 'REPLACE_WITH_CONTRACT_ADDRESS'
|
contractAddress = 'REPLACE_WITH_CONTRACT_ADDRESS'
|
||||||
|
|
||||||
[server.p2p.nitro]
|
[server.p2p.nitro]
|
||||||
|
chainUrl = 'REPLACE_WITH_CERC_NITRO_CHAIN_URL'
|
||||||
store = './out/nitro-db'
|
store = './out/nitro-db'
|
||||||
privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_NITRO'
|
privateKey = 'REPLACE_WITH_CERC_WATCHER_NITRO_PK'
|
||||||
chainPrivateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
|
chainPrivateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
|
||||||
|
|
||||||
[server.p2p.nitro.payments]
|
[server.p2p.nitro.payments]
|
||||||
@@ -67,7 +74,7 @@
|
|||||||
enabled = REPLACE_WITH_CONSENSUS_ENABLED
|
enabled = REPLACE_WITH_CONSENSUS_ENABLED
|
||||||
publicKey = 'REPLACE_WITH_CONSENSUS_PUBLIC_KEY'
|
publicKey = 'REPLACE_WITH_CONSENSUS_PUBLIC_KEY'
|
||||||
privateKey = 'REPLACE_WITH_CONSENSUS_PRIVATE_KEY'
|
privateKey = 'REPLACE_WITH_CONSENSUS_PRIVATE_KEY'
|
||||||
watcherPartyFile = 'REPLACE_WITH_WATCHER_PARTY_PEERS_FILE'
|
watcherPartyPeersFile = 'REPLACE_WITH_WATCHER_PARTY_PEERS_FILE'
|
||||||
|
|
||||||
[metrics]
|
[metrics]
|
||||||
host = "0.0.0.0"
|
host = "0.0.0.0"
|
||||||
@@ -88,8 +95,20 @@
|
|||||||
[upstream]
|
[upstream]
|
||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
|
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
|
||||||
rpcProviderEndpoint = "REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT"
|
rpcProviderEndpoint = 'REPLACE_WITH_CERC_ETH_RPC_QUERY_ENDPOINT'
|
||||||
blockDelayInMilliSecs = 60000
|
rpcProviderMutationEndpoint = 'REPLACE_WITH_CERC_ETH_RPC_MUTATION_ENDPOINT'
|
||||||
|
|
||||||
|
[upstream.ethServer.payments]
|
||||||
|
paidRPCMethods = ["eth_getBlockByHash", "eth_getBlockByNumber", "eth_getStorageAt"]
|
||||||
|
amount = 'REPLACE_WITH_UPSTREAM_NITRO_PAY_AMOUNT'
|
||||||
|
|
||||||
|
[upstream.ethServer.payments.nitro]
|
||||||
|
address = 'REPLACE_WITH_UPSTREAM_NITRO_ADDRESS'
|
||||||
|
multiAddr = 'REPLACE_WITH_UPSTREAM_NITRO_MULTIADDR'
|
||||||
|
|
||||||
|
[upstream.ethServer.payments.nitro.fundingAmounts]
|
||||||
|
directFund = "1000000000000"
|
||||||
|
virtualFund = "1000000000"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
@@ -101,3 +120,4 @@
|
|||||||
maxCompletionLagInSecs = 300
|
maxCompletionLagInSecs = 300
|
||||||
jobDelayInMilliSecs = 100
|
jobDelayInMilliSecs = 100
|
||||||
eventsInBatch = 50
|
eventsInBatch = 50
|
||||||
|
blockDelayInMilliSecs = 60000
|
||||||
|
|||||||
+1
@@ -13,6 +13,7 @@ NOW=${1:-`date +%s`}
|
|||||||
|
|
||||||
lcli \
|
lcli \
|
||||||
change-genesis-time \
|
change-genesis-time \
|
||||||
|
--testnet-dir $TESTNET_DIR \
|
||||||
$TESTNET_DIR/genesis.ssz \
|
$TESTNET_DIR/genesis.ssz \
|
||||||
$NOW
|
$NOW
|
||||||
|
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build cerc/go-nitro
|
||||||
|
|
||||||
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
|
||||||
|
docker build -t cerc/go-nitro:local -f ${CERC_REPO_BASE_DIR}/go-nitro/docker/local/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
FROM node:18.15.0-alpine3.16
|
||||||
|
|
||||||
|
RUN apk --update --no-cache add git python3 alpine-sdk bash
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN echo "Installing dependencies..." && \
|
||||||
|
yarn install && \
|
||||||
|
cd packages/snap
|
||||||
|
|
||||||
|
CMD ["bash", "-c", "yarn start"]
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build cerc/mobymask-snap
|
||||||
|
|
||||||
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
docker build -t cerc/mobymask-snap:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/mobymask-snap
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
FROM node:18.17.1-alpine3.18
|
||||||
|
|
||||||
|
RUN apk --update --no-cache add python3 alpine-sdk bash curl jq
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN echo "Installing dependencies" && \
|
||||||
|
yarn && yarn build:node
|
||||||
|
|
||||||
|
WORKDIR /app/packages/nitro-node
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build cerc/nitro-contracts
|
||||||
|
|
||||||
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
|
||||||
|
# See: https://stackoverflow.com/a/246128/1701505
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
docker build -t cerc/nitro-contracts:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/ts-nitro
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
FROM node:18.17.1-alpine3.18
|
||||||
|
|
||||||
|
RUN apk --update --no-cache add python3 alpine-sdk bash curl jq
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN echo "Installing dependencies" && \
|
||||||
|
yarn
|
||||||
|
|
||||||
|
RUN cd packages/nitro-rpc-client
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build cerc/nitro-rpc-client
|
||||||
|
|
||||||
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
|
||||||
|
# See: https://stackoverflow.com/a/246128/1701505
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
docker build -t cerc/nitro-rpc-client:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
FROM node:18.15.0-alpine3.16
|
||||||
|
|
||||||
|
RUN apk --update --no-cache add git alpine-sdk bash jq curl
|
||||||
|
RUN curl -L https://unpkg.com/@pnpm/self-installer | node
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN echo "Installing dependencies and building..." && \
|
||||||
|
pnpm install && pnpm build && \
|
||||||
|
cd examples/token-erc20 && \
|
||||||
|
pnpm install
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Build cerc/ponder
|
||||||
|
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
||||||
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
|
docker build -t cerc/ponder:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/ponder
|
||||||
@@ -14,6 +14,8 @@ else
|
|||||||
echo "Filesystem is fresh"
|
echo "Filesystem is fresh"
|
||||||
echo `date` > $EXISTSFILENAME
|
echo `date` > $EXISTSFILENAME
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$CERC_TEST_PARAM_1" ]; then
|
||||||
|
echo "Test-param-1: ${CERC_TEST_PARAM_1}"
|
||||||
|
fi
|
||||||
# Run nginx which will block here forever
|
# Run nginx which will block here forever
|
||||||
/usr/sbin/nginx -g "daemon off;"
|
/usr/sbin/nginx -g "daemon off;"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM node:16.17.1-alpine3.16
|
FROM node:18.17.1-alpine3.18
|
||||||
|
|
||||||
RUN apk --update --no-cache add git python3 alpine-sdk jq
|
RUN apk --update --no-cache add git python3 alpine-sdk jq
|
||||||
|
|
||||||
|
|||||||
@@ -51,3 +51,8 @@ cerc/graph-node
|
|||||||
cerc/sushiswap-subgraphs
|
cerc/sushiswap-subgraphs
|
||||||
cerc/webapp-base
|
cerc/webapp-base
|
||||||
cerc/watcher-mobymask-v3
|
cerc/watcher-mobymask-v3
|
||||||
|
cerc/go-nitro
|
||||||
|
cerc/nitro-contracts
|
||||||
|
cerc/mobymask-snap
|
||||||
|
cerc/ponder
|
||||||
|
cerc/nitro-rpc-client
|
||||||
|
|||||||
@@ -37,3 +37,8 @@ sushiswap-subgraph-v3
|
|||||||
fixturenet-sushiswap-subgraph-v3
|
fixturenet-sushiswap-subgraph-v3
|
||||||
watcher-mobymask-v3
|
watcher-mobymask-v3
|
||||||
mobymask-app-v3
|
mobymask-app-v3
|
||||||
|
go-nitro
|
||||||
|
nitro-contracts
|
||||||
|
nitro-reverse-payment-proxy
|
||||||
|
mobymask-snap
|
||||||
|
ponder
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
github.com/cerc-io/ipld-eth-db
|
git.vdb.to/cerc-io/ipld-eth-db
|
||||||
github.com/cerc-io/go-ethereum
|
git.vdb.to/cerc-io/go-ethereum
|
||||||
github.com/cerc-io/ipld-eth-server
|
git.vdb.to/cerc-io/ipld-eth-server
|
||||||
github.com/cerc-io/eth-statediff-service
|
git.vdb.to/cerc-io/eth-statediff-service
|
||||||
github.com/cerc-io/eth-statediff-fill-service
|
github.com/cerc-io/eth-statediff-fill-service
|
||||||
github.com/cerc-io/ipld-eth-db-validator
|
github.com/cerc-io/ipld-eth-db-validator
|
||||||
github.com/cerc-io/ipld-eth-beacon-indexer
|
github.com/cerc-io/ipld-eth-beacon-indexer
|
||||||
@@ -18,7 +18,7 @@ github.com/vulcanize/uniswap-watcher-ts
|
|||||||
github.com/vulcanize/uniswap-v3-info
|
github.com/vulcanize/uniswap-v3-info
|
||||||
github.com/vulcanize/assemblyscript
|
github.com/vulcanize/assemblyscript
|
||||||
github.com/cerc-io/eth-probe
|
github.com/cerc-io/eth-probe
|
||||||
github.com/cerc-io/tx-spammer
|
git.vdb.to/cerc-io/tx-spammer
|
||||||
github.com/dboreham/foundry
|
github.com/dboreham/foundry
|
||||||
github.com/lirewine/gem
|
github.com/lirewine/gem
|
||||||
github.com/lirewine/debug
|
github.com/lirewine/debug
|
||||||
@@ -30,7 +30,7 @@ github.com/ethereum-optimism/optimism
|
|||||||
github.com/pokt-network/pocket-core
|
github.com/pokt-network/pocket-core
|
||||||
github.com/pokt-network/pocket-core-deployments
|
github.com/pokt-network/pocket-core-deployments
|
||||||
github.com/cerc-io/azimuth-watcher-ts
|
github.com/cerc-io/azimuth-watcher-ts
|
||||||
github.com/cerc-io/ipld-eth-state-snapshot
|
git.vdb.to/cerc-io/ipld-eth-state-snapshot
|
||||||
github.com/cerc-io/gelato-watcher-ts
|
github.com/cerc-io/gelato-watcher-ts
|
||||||
github.com/filecoin-project/lotus
|
github.com/filecoin-project/lotus
|
||||||
git.vdb.to/cerc-io/test-project
|
git.vdb.to/cerc-io/test-project
|
||||||
@@ -43,3 +43,7 @@ github.com/cerc-io/sushiswap-v3-core
|
|||||||
github.com/cerc-io/sushiswap-v3-periphery
|
github.com/cerc-io/sushiswap-v3-periphery
|
||||||
github.com/graphprotocol/graph-node
|
github.com/graphprotocol/graph-node
|
||||||
github.com/sushiswap/subgraphs
|
github.com/sushiswap/subgraphs
|
||||||
|
github.com/cerc-io/go-nitro
|
||||||
|
github.com/cerc-io/ts-nitro
|
||||||
|
github.com/cerc-io/mobymask-snap
|
||||||
|
github.com/cerc-io/ponder
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ version: "1.0"
|
|||||||
name: chain-chunker
|
name: chain-chunker
|
||||||
description: "Stack to build containers for chain-chunker"
|
description: "Stack to build containers for chain-chunker"
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/ipld-eth-state-snapshot@v5
|
- git.vdb.to/cerc-io/ipld-eth-state-snapshot@v5
|
||||||
- github.com/cerc-io/eth-statediff-service@v5
|
- git.vdb.to/cerc-io/eth-statediff-service@v5
|
||||||
- github.com/cerc-io/ipld-eth-db@v5
|
- git.vdb.to/cerc-io/ipld-eth-db@v5
|
||||||
- github.com/cerc-io/ipld-eth-server@v5
|
- git.vdb.to/cerc-io/ipld-eth-server@v5
|
||||||
containers:
|
containers:
|
||||||
- cerc/ipld-eth-state-snapshot
|
- cerc/ipld-eth-state-snapshot
|
||||||
- cerc/eth-statediff-service
|
- cerc/eth-statediff-service
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
version: "1.0"
|
version: "1.0"
|
||||||
name: erc20-watcher
|
name: erc20-watcher
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/ipld-eth-db
|
- git.vdb.to/cerc-io/ipld-eth-db@v5
|
||||||
- github.com/cerc-io/ipld-eth-server
|
- git.vdb.to/cerc-io/ipld-eth-server@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/watcher-ts
|
- github.com/cerc-io/watcher-ts
|
||||||
- github.com/dboreham/foundry
|
- github.com/dboreham/foundry
|
||||||
containers:
|
containers:
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
version: "1.0"
|
version: "1.0"
|
||||||
name: erc721-watcher
|
name: erc721-watcher
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/ipld-eth-db
|
- git.vdb.to/cerc-io/ipld-eth-db@v5
|
||||||
- github.com/cerc-io/ipld-eth-server
|
- git.vdb.to/cerc-io/ipld-eth-server@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/watcher-ts
|
- github.com/cerc-io/watcher-ts
|
||||||
containers:
|
containers:
|
||||||
- cerc/go-ethereum
|
- cerc/go-ethereum
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ version: "1.0"
|
|||||||
name: fixturenet-eth-loaded
|
name: fixturenet-eth-loaded
|
||||||
description: "Loaded Ethereum Fixturenet"
|
description: "Loaded Ethereum Fixturenet"
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/tx-spammer
|
- git.vdb.to/cerc-io/tx-spammer
|
||||||
- github.com/cerc-io/ipld-eth-server
|
- git.vdb.to/cerc-io/ipld-eth-server@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/ipld-eth-db
|
- git.vdb.to/cerc-io/ipld-eth-db@v5
|
||||||
- github.com/cerc-io/lighthouse
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
containers:
|
containers:
|
||||||
- cerc/go-ethereum
|
- cerc/go-ethereum
|
||||||
- cerc/lighthouse
|
- cerc/lighthouse
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ version: "1.2"
|
|||||||
name: fixturenet-eth-tx
|
name: fixturenet-eth-tx
|
||||||
description: "Ethereum Fixturenet w/ tx-spammer"
|
description: "Ethereum Fixturenet w/ tx-spammer"
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/tx-spammer
|
- git.vdb.to/cerc-io/tx-spammer
|
||||||
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
- github.com/dboreham/foundry
|
- github.com/dboreham/foundry
|
||||||
- github.com/cerc-io/lighthouse
|
|
||||||
containers:
|
containers:
|
||||||
- cerc/go-ethereum
|
- cerc/go-ethereum
|
||||||
- cerc/lighthouse
|
- cerc/lighthouse
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ It is not necessary to use them all at once, but a complete example follows:
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Setup
|
# Setup
|
||||||
$ laconic-so setup-repositories --include github.com/cerc-io/go-ethereum,github.com/cerc-io/ipld-eth-db,github.com/cerc-io/ipld-eth-server,github.com/cerc-io/ipld-eth-beacon-db,github.com/cerc-io/ipld-eth-beacon-indexer,github.com/cerc-io/eth-probe,github.com/cerc-io/tx-spammer
|
$ laconic-so setup-repositories --include git.vdb.to/cerc-io/go-ethereum,git.vdb.to/cerc-io/ipld-eth-db,git.vdb.to/cerc-io/ipld-eth-server,github.com/cerc-io/ipld-eth-beacon-db,github.com/cerc-io/ipld-eth-beacon-indexer,github.com/cerc-io/eth-probe,git.vdb.to/cerc-io/tx-spammer
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
$ laconic-so build-containers --include cerc/go-ethereum,cerc/lighthouse,cerc/fixturenet-eth-geth,cerc/fixturenet-eth-lighthouse,cerc/ipld-eth-db,cerc/ipld-eth-server,cerc/ipld-eth-beacon-db,cerc/ipld-eth-beacon-indexer,cerc/eth-probe,cerc/keycloak,cerc/tx-spammer
|
$ laconic-so build-containers --include cerc/go-ethereum,cerc/lighthouse,cerc/fixturenet-eth-geth,cerc/fixturenet-eth-lighthouse,cerc/ipld-eth-db,cerc/ipld-eth-server,cerc/ipld-eth-beacon-db,cerc/ipld-eth-beacon-indexer,cerc/eth-probe,cerc/keycloak,cerc/tx-spammer
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ version: "1.1"
|
|||||||
name: fixturenet-eth
|
name: fixturenet-eth
|
||||||
description: "Ethereum Fixturenet"
|
description: "Ethereum Fixturenet"
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/lighthouse
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
- github.com/dboreham/foundry
|
- github.com/dboreham/foundry
|
||||||
containers:
|
containers:
|
||||||
- cerc/go-ethereum
|
- cerc/go-ethereum
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Prerequisite: An L1 Ethereum RPC endpoint
|
|||||||
Clone required repositories:
|
Clone required repositories:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
laconic-so --stack fixturenet-optimism setup-repositories --exclude github.com/cerc-io/go-ethereum
|
laconic-so --stack fixturenet-optimism setup-repositories --exclude git.vdb.to/cerc-io/go-ethereum
|
||||||
|
|
||||||
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
|
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ version: "1.0"
|
|||||||
name: fixturenet-optimism
|
name: fixturenet-optimism
|
||||||
description: "Optimism Fixturenet"
|
description: "Optimism Fixturenet"
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/lighthouse
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
- github.com/dboreham/foundry
|
- github.com/dboreham/foundry
|
||||||
- github.com/ethereum-optimism/optimism@v1.0.4
|
- github.com/ethereum-optimism/optimism@v1.0.4
|
||||||
- github.com/ethereum-optimism/op-geth@v1.101105.2
|
- github.com/ethereum-optimism/op-geth@v1.101105.2
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
# fixturenet-payments
|
||||||
|
|
||||||
|
Instructions to setup and deploy an end-to-end fixturenet-payments stack
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Clone required repositories:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
laconic-so --stack fixturenet-payments setup-repositories --pull
|
||||||
|
```
|
||||||
|
|
||||||
|
Build the container images:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
laconic-so --stack fixturenet-payments build-containers
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy
|
||||||
|
|
||||||
|
Deploy the stack:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
laconic-so --stack fixturenet-payments deploy --cluster payments up
|
||||||
|
|
||||||
|
# Exposed on host ports:
|
||||||
|
# 4005: go-nitro node's RPC endpoint
|
||||||
|
# 5005: go-nitro node's p2p endpoint
|
||||||
|
# 8081: reverse payment proxy's RPC endpoint
|
||||||
|
# 15432: MobyMask v3 watcher's db endpoint
|
||||||
|
# 3001: MobyMask v3 watcher endpoint
|
||||||
|
# 9090: MobyMask v3 watcher relay node endpoint
|
||||||
|
# 8080: MobyMask snap
|
||||||
|
# 3004: MobyMask v3 app
|
||||||
|
```
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|
Follow the [demo](./demo.md) to try out end-to-end payments
|
||||||
|
|
||||||
|
## Clean up
|
||||||
|
|
||||||
|
Stop all the services running in background:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
laconic-so --stack fixturenet-payments deploy --cluster payments down 30
|
||||||
|
```
|
||||||
|
|
||||||
|
Clear volumes created by this stack:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# List all relevant volumes
|
||||||
|
docker volume ls -q --filter "name=[payments"
|
||||||
|
|
||||||
|
# Remove all the listed volumes
|
||||||
|
docker volume rm $(docker volume ls -q --filter "name=[payments")
|
||||||
|
```
|
||||||
@@ -0,0 +1,275 @@
|
|||||||
|
# Demo
|
||||||
|
|
||||||
|
Stack components:
|
||||||
|
* `ipld-eth-db` database for statediffed data
|
||||||
|
* Local geth + lighthouse blockchain "fixturenet" running in statediffing mode
|
||||||
|
* `ipld-eth-server` which runs an ETH RPC API and a GQL server; serves data from `ipld-eth-db`
|
||||||
|
* A go-nitro deployment acting as the Nitro node for `ipld-eth-server`
|
||||||
|
* A modified reverse payment proxy server (based on the one from go-nitro) that proxies requests to `ipld-eth-server`'s RPC endpoint; it talks to `ipld-eth-server`'s Nitro node to accept and validate payments required for configured RPC requests
|
||||||
|
* A MobyMask v3 watcher that pays the `ipld-eth-server` for ETH RPC requests
|
||||||
|
* A MobyMask v3 app that pays the watcher for reads (GQL queries) and writes
|
||||||
|
* An example ERC20 Ponder app that pays the `ipld-eth-server` for ETH RPC requests
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
* On starting the stack, MobyMask watcher creates a payment channel with the `ipld-eth-server`'s Nitro node. Check watcher logs and wait for the same:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker logs -f $(docker ps -aq --filter name="mobymask-watcher-server")
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
# vulcanize:server Peer ID: 12D3KooWKLqLWU82VU7jmsmQMruRvZWhoBoVsf1UHchM5Nuq9ymY
|
||||||
|
# vulcanize:server Using chain URL http://fixturenet-eth-geth-1:8546 for Nitro node
|
||||||
|
# ...
|
||||||
|
# ts-nitro:util:nitro Ledger channel created with id 0x65703ccdfacab09ac35367bdbe6c5a337e7a6651aad526807607b1c59b28bc1e
|
||||||
|
# ...
|
||||||
|
# ts-nitro:util:nitro Virtual payment channel created with id 0x29ff1335d73391a50e8fde3e9b34f00c3d81c39ddc7f89187f44dd51df96140e
|
||||||
|
# vulcanize:server Starting server... +0ms
|
||||||
|
```
|
||||||
|
|
||||||
|
* Keep the above command running to keep track of incoming payments and GQL requests from the MobyMask app
|
||||||
|
|
||||||
|
* In another terminal, export the payment channel id to a variable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export WATCHER_UPSTREAM_PAYMENT_CHANNEL=<PAYMENT_CHANNEL_ID>
|
||||||
|
```
|
||||||
|
|
||||||
|
* Check the payment channel status:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec payments-nitro-rpc-client-1 npm exec -c "nitro-rpc-client get-payment-channel $WATCHER_UPSTREAM_PAYMENT_CHANNEL -h go-nitro -p 4005"
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
# {
|
||||||
|
# ID: '0x8c0d17639bd2ba07dbcd248304a8f3c6c7276bfe25c2b87fe41f461e20f33f01',
|
||||||
|
# Status: 'Open',
|
||||||
|
# Balance: {
|
||||||
|
# AssetAddress: '0x0000000000000000000000000000000000000000',
|
||||||
|
# Payee: '0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce',
|
||||||
|
# Payer: '0xbbb676f9cff8d242e9eac39d063848807d3d1d94',
|
||||||
|
# PaidSoFar: 0n,
|
||||||
|
# RemainingFunds: 1000000000n
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
* In another terminal, check the reverse payment proxy server's logs to keep track of incoming payments and RPC requests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker logs -f $(docker ps -aq --filter name="nitro-reverse-payment-proxy")
|
||||||
|
```
|
||||||
|
|
||||||
|
* MetaMask flask wallet setup for running the MobyMask app:
|
||||||
|
|
||||||
|
* Get the geth node’s port mapped to host:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker port payments-fixturenet-eth-geth-1-1 8545
|
||||||
|
```
|
||||||
|
|
||||||
|
* In MetaMask, add a custom network with the following settings:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Network name
|
||||||
|
Local fixturenet
|
||||||
|
|
||||||
|
# New RPC URL
|
||||||
|
http://127.0.0.1:<GETH_PORT>
|
||||||
|
|
||||||
|
# Chain ID
|
||||||
|
1212
|
||||||
|
|
||||||
|
# Currency symbol
|
||||||
|
ETH
|
||||||
|
```
|
||||||
|
|
||||||
|
* Import a faucet account with the following private key:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Faucet PK
|
||||||
|
# 0x570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597
|
||||||
|
```
|
||||||
|
|
||||||
|
* Create an additional account for usage in the app; fund it from the faucet account
|
||||||
|
|
||||||
|
* Get the generated root invite link for MobyMask from contract deployment container logs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker logs -f $(docker ps -aq --filter name="mobymask-1")
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
# ...
|
||||||
|
# "key": "0x60e706fda4639fe0a8eb102cb0ce81231cf6e819f41cb4eadf72d865ea4c11ad"
|
||||||
|
# }
|
||||||
|
# http://127.0.0.1:3004/#/members?invitation=<INVITATION>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
### MobyMask App
|
||||||
|
|
||||||
|
* Open app in a browser (where MetaMask was setup) using the invite link
|
||||||
|
|
||||||
|
* Run the following in browser console to enable logs:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
localStorage.debug = 'ts-nitro:*'
|
||||||
|
# Refresh the tab for taking effect
|
||||||
|
```
|
||||||
|
|
||||||
|
* In the app’s debug panel, check that the peer gets connected to relay node and watcher peer
|
||||||
|
|
||||||
|
* Open the `NITRO` tab in debug panel
|
||||||
|
* Click on `Connect Wallet` to connect to MetaMask (make sure that the newly funded account is active)
|
||||||
|
* Click on `Connect Snap` to install/connect snap
|
||||||
|
|
||||||
|
* Perform `DIRECT FUND` with the preset amount and wait for the MetaMask confirmation prompt to appear; confirm the transaction and wait for a ledger channel to be created with the watcher
|
||||||
|
|
||||||
|
* Perform `VIRTUAL FUND` with amount set to `10000` and wait for a payment channel to be created with the watcher
|
||||||
|
|
||||||
|
* Perform phisher status check queries now that a payment channel is created:
|
||||||
|
|
||||||
|
* Check the watcher logs for received payments along with the GQL queries:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Expected output:
|
||||||
|
# ...
|
||||||
|
# laconic:payments Serving a paid query for 0x86804299822212c070178B5135Ba6DdAcFC357D3
|
||||||
|
# vulcanize:resolver isPhisher 0x98ae4f9e9d01cc892adfe6871e1db0287039e0c183d3b5bb31d724228c114744 0x2B6AFbd4F479cE4101Df722cF4E05F941523EaD9 TWT:ash1
|
||||||
|
# vulcanize:indexer isPhisher: db miss, fetching from upstream server
|
||||||
|
# laconic:payments Making RPC call: eth_chainId
|
||||||
|
# laconic:payments Making RPC call: eth_getBlockByHash
|
||||||
|
# laconic:payments Making RPC call: eth_chainId
|
||||||
|
# laconic:payments Making RPC call: eth_getStorageAt
|
||||||
|
```
|
||||||
|
|
||||||
|
* The watcher makes several ETH RPC requests to `ipld-eth-server` to fetch data required for satisfying the GQL request(s); check the payment proxy server logs for charged RPC requests (`eth_getBlockByHash`, `eth_getBlockByNumber`, `eth_getStorageAt`):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Expected output:
|
||||||
|
# ...
|
||||||
|
# {"time":"2023-10-06T06:46:52.769009314Z","level":"DEBUG","msg":"Serving RPC request","method":"eth_chainId"}
|
||||||
|
# {"time":"2023-10-06T06:46:52.773006426Z","level":"DEBUG","msg":"Serving RPC request","method":"eth_getBlockByNumber"}
|
||||||
|
# {"time":"2023-10-06T06:46:52.811142054Z","level":"DEBUG","msg":"Request cost","cost-per-byte":1,"response-length":1480,"cost":1480,"method":"eth_getBlockByNumber"}
|
||||||
|
# {"time":"2023-10-06T06:46:52.811418494Z","level":"DEBUG","msg":"sent message","address":"0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE","method":"receive_voucher"}
|
||||||
|
# {"time":"2023-10-06T06:46:52.812557482Z","level":"DEBUG","msg":"Received voucher","delta":5000}
|
||||||
|
# ...
|
||||||
|
# {"time":"2023-10-06T06:46:52.87525215Z","level":"DEBUG","msg":"Serving RPC request","method":"eth_getStorageAt"}
|
||||||
|
# {"time":"2023-10-06T06:46:52.882859654Z","level":"DEBUG","msg":"Request cost","cost-per-byte":1,"response-length":104,"cost":104,"method":"eth_getStorageAt"}
|
||||||
|
# {"time":"2023-10-06T06:46:52.882946485Z","level":"DEBUG","msg":"sent message","address":"0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE","method":"receive_voucher"}
|
||||||
|
# {"time":"2023-10-06T06:46:52.884012641Z","level":"DEBUG","msg":"Received voucher","delta":5000}
|
||||||
|
# {"time":"2023-10-06T06:46:52.884032961Z","level":"DEBUG","msg":"Destination request","url":"http://ipld-eth-server:8081/"}
|
||||||
|
```
|
||||||
|
|
||||||
|
* Change the amount besides `PAY` button in debug panel to `>=100` for phisher reports next
|
||||||
|
|
||||||
|
* Perform a phisher report and check the watcher logs for received payments:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Expected output:
|
||||||
|
# ...
|
||||||
|
# vulcanize:libp2p-utils [6:50:2] Received a message on mobymask P2P network from peer: 12D3KooWRkxV9SX8uTUZYkbRjai4Fsn7yavB61J5TMnksixsabsP
|
||||||
|
# ts-nitro:engine {"msg":"Received message","_msg":{"to":"0xBBB676","from":"0x868042","payloadSummaries":[],"proposalSummaries":[],"payments":[{"amount":200,"channelId":"0x557153d729cf3323c0bdb40a36b245f98c2d4562933ba2182c9d61c5cfeda948"}],"rejectedObjectives":[]}}
|
||||||
|
# laconic:payments Received a payment voucher of 100 from 0x86804299822212c070178B5135Ba6DdAcFC357D3
|
||||||
|
# vulcanize:libp2p-utils Payment received for a mutation request from 0x86804299822212c070178B5135Ba6DdAcFC357D3
|
||||||
|
# vulcanize:libp2p-utils Transaction receipt for invoke message {
|
||||||
|
# to: '0x2B6AFbd4F479cE4101Df722cF4E05F941523EaD9',
|
||||||
|
# blockNumber: 232,
|
||||||
|
# blockHash: '0x6a188722c102662ea48af3786fe9db0d4b6c7ab7b27473eb0e628cf95746a244',
|
||||||
|
# transactionHash: '0x6521205db8a905b3222adc2b6855f9b2abc72580624d299bec2a35bcba173efa',
|
||||||
|
# effectiveGasPrice: '1500000007',
|
||||||
|
# gasUsed: '113355'
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
* Check the watcher - ipld-eth-server payment channel status after a few requests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec payments-nitro-rpc-client-1 npm exec -c "nitro-rpc-client get-payment-channel $WATCHER_UPSTREAM_PAYMENT_CHANNEL -h go-nitro -p 4005"
|
||||||
|
|
||||||
|
# Expected output ('PaidSoFar' should be non zero):
|
||||||
|
# {
|
||||||
|
# ID: '0x8c0d17639bd2ba07dbcd248304a8f3c6c7276bfe25c2b87fe41f461e20f33f01',
|
||||||
|
# Status: 'Open',
|
||||||
|
# Balance: {
|
||||||
|
# AssetAddress: '0x0000000000000000000000000000000000000000',
|
||||||
|
# Payee: '0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce',
|
||||||
|
# Payer: '0xbbb676f9cff8d242e9eac39d063848807d3d1d94',
|
||||||
|
# PaidSoFar: 30000n,
|
||||||
|
# RemainingFunds: 999970000n
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
### ERC20 Ponder App
|
||||||
|
|
||||||
|
* Run the ponder app in it's container:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it payments-ponder-app-1 bash -c "pnpm start"
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
# 09:58:54.288 INFO payment Creating ledger channel with nitro node 0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE
|
||||||
|
# ...
|
||||||
|
# 09:59:14.230 INFO payment Creating payment channel with nitro node 0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE
|
||||||
|
# ...
|
||||||
|
# 09:59:14.329 INFO payment Using payment channel 0x10f049519bc3f862e2b26e974be8666886228f30ea54aab06e2f23718afffab0
|
||||||
|
```
|
||||||
|
|
||||||
|
* On starting the Ponder app, it creates a payment channel with the `ipld-eth-server`'s Nitro node and then starts the historical sync service
|
||||||
|
|
||||||
|
* The sync service makes several ETH RPC requests to the `ipld-eth-server` to fetch required data; check the payment proxy server logs for charged RPC requests (`eth_getBlockByNumber`, `eth_getLogs`)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Expected output:
|
||||||
|
# ...
|
||||||
|
# {"time":"2023-10-06T06:51:45.214478402Z","level":"DEBUG","msg":"Serving RPC request","method":"eth_getBlockByNumber"}
|
||||||
|
# {"time":"2023-10-06T06:51:45.22251171Z","level":"DEBUG","msg":"Request cost","cost-per-byte":1,"response-length":576,"cost":576,"method":"eth_getBlockByNumber"}
|
||||||
|
# {"time":"2023-10-06T06:51:45.222641963Z","level":"DEBUG","msg":"sent message","address":"0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE","method":"receive_voucher"}
|
||||||
|
# {"time":"2023-10-06T06:51:45.224042391Z","level":"DEBUG","msg":"Received voucher","delta":5000}
|
||||||
|
# {"time":"2023-10-06T06:51:45.224061411Z","level":"DEBUG","msg":"Destination request","url":"http://ipld-eth-server:8081/"}
|
||||||
|
# {"time":"2023-10-06T06:51:45.242064953Z","level":"DEBUG","msg":"Serving RPC request","method":"eth_getLogs"}
|
||||||
|
# {"time":"2023-10-06T06:51:45.249118517Z","level":"DEBUG","msg":"Request cost","cost-per-byte":1,"response-length":61,"cost":61,"method":"eth_getLogs"}
|
||||||
|
# {"time":"2023-10-06T06:51:45.249189892Z","level":"DEBUG","msg":"sent message","address":"0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE","method":"receive_voucher"}
|
||||||
|
# {"time":"2023-10-06T06:51:45.249743149Z","level":"DEBUG","msg":"Received voucher","delta":5000}
|
||||||
|
# {"time":"2023-10-06T06:51:45.249760631Z","level":"DEBUG","msg":"Destination request","url":"http://ipld-eth-server:8081/"}
|
||||||
|
# ...
|
||||||
|
```
|
||||||
|
|
||||||
|
* Export the payment channel id to a variable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export PONDER_UPSTREAM_PAYMENT_CHANNEL=<PAYMENT_CHANNEL_ID>
|
||||||
|
```
|
||||||
|
|
||||||
|
* Check the ponder - ipld-eth-server payment channel status:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec payments-nitro-rpc-client-1 npm exec -c "nitro-rpc-client get-payment-channel $PONDER_UPSTREAM_PAYMENT_CHANNEL -h go-nitro -p 4005"
|
||||||
|
|
||||||
|
# Expected output ('PaidSoFar' is non zero):
|
||||||
|
# {
|
||||||
|
# ID: '0x1178ac0f2a43e54a122216fa6afdd30333b590e49e50317a1f9274a591da0f96',
|
||||||
|
# Status: 'Open',
|
||||||
|
# Balance: {
|
||||||
|
# AssetAddress: '0x0000000000000000000000000000000000000000',
|
||||||
|
# Payee: '0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce',
|
||||||
|
# Payer: '0x67d5b55604d1af90074fcb69b8c51838fff84f8d',
|
||||||
|
# PaidSoFar: 215000n,
|
||||||
|
# RemainingFunds: 999785000n
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
## Clean Up
|
||||||
|
|
||||||
|
* In the MobyMask app, perform `VIRTUAL DEFUND` and `DIRECT DEFUND` (in order) for closing the payment channel created with watcher
|
||||||
|
|
||||||
|
* Run the following in the browser console to delete the Nitro node's data:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
await clearNodeStorage()
|
||||||
|
```
|
||||||
|
|
||||||
|
* On a fresh restart, clear activity tab data in MetaMask for concerned accounts
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
version: "1.0"
|
||||||
|
name: fixturenet-payments
|
||||||
|
description: "Stack to demonstrate payments between various services"
|
||||||
|
repos:
|
||||||
|
# fixturenet repos
|
||||||
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
|
- git.vdb.to/cerc-io/ipld-eth-db@v5
|
||||||
|
- git.vdb.to/cerc-io/ipld-eth-server@v1.11.6-statediff-v5
|
||||||
|
# nitro repos
|
||||||
|
- github.com/cerc-io/ts-nitro@v0.1.13
|
||||||
|
- github.com/cerc-io/go-nitro@v0.1.1-ts-port-0.1.5
|
||||||
|
# mobymask watcher repos
|
||||||
|
- github.com/cerc-io/watcher-ts@v0.2.63
|
||||||
|
- github.com/cerc-io/mobymask-v2-watcher-ts@v0.2.2
|
||||||
|
- github.com/cerc-io/MobyMask@v0.1.3
|
||||||
|
# mobymask app repos
|
||||||
|
- github.com/cerc-io/mobymask-snap
|
||||||
|
- github.com/cerc-io/mobymask-ui@v0.2.1
|
||||||
|
# ponder repo
|
||||||
|
- github.com/cerc-io/ponder@laconic
|
||||||
|
containers:
|
||||||
|
# fixturenet images
|
||||||
|
- cerc/go-ethereum
|
||||||
|
- cerc/lighthouse
|
||||||
|
- cerc/lighthouse-cli
|
||||||
|
- cerc/fixturenet-eth-genesis
|
||||||
|
- cerc/fixturenet-eth-geth
|
||||||
|
- cerc/fixturenet-eth-lighthouse
|
||||||
|
- cerc/ipld-eth-db
|
||||||
|
- cerc/ipld-eth-server
|
||||||
|
- cerc/nitro-contracts
|
||||||
|
- cerc/go-nitro
|
||||||
|
- cerc/nitro-rpc-client
|
||||||
|
# mobymask watcher images
|
||||||
|
- cerc/watcher-ts
|
||||||
|
- cerc/watcher-mobymask-v3
|
||||||
|
- cerc/mobymask
|
||||||
|
# mobymask app images
|
||||||
|
- cerc/mobymask-snap
|
||||||
|
- cerc/mobymask-ui
|
||||||
|
# ponder image
|
||||||
|
- cerc/ponder
|
||||||
|
pods:
|
||||||
|
- fixturenet-eth
|
||||||
|
- ipld-eth-server
|
||||||
|
- ipld-eth-db
|
||||||
|
- nitro-contracts
|
||||||
|
- go-nitro
|
||||||
|
- nitro-reverse-payment-proxy
|
||||||
|
- watcher-mobymask-v3
|
||||||
|
- mobymask-snap
|
||||||
|
- mobymask-app-v3
|
||||||
|
- ponder
|
||||||
@@ -4,10 +4,10 @@ description: "plugeth Ethereum Fixturenet w/ tx-spammer"
|
|||||||
repos:
|
repos:
|
||||||
- git.vdb.to/cerc-io/plugeth@statediff
|
- git.vdb.to/cerc-io/plugeth@statediff
|
||||||
- git.vdb.to/cerc-io/plugeth-statediff
|
- git.vdb.to/cerc-io/plugeth-statediff
|
||||||
- github.com/cerc-io/lighthouse
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
- github.com/cerc-io/ipld-eth-db@v5
|
- git.vdb.to/cerc-io/ipld-eth-db@v5
|
||||||
- github.com/cerc-io/ipld-eth-server@v5
|
- git.vdb.to/cerc-io/ipld-eth-server@v5
|
||||||
- github.com/cerc-io/tx-spammer
|
- git.vdb.to/cerc-io/tx-spammer
|
||||||
- github.com/dboreham/foundry
|
- github.com/dboreham/foundry
|
||||||
containers:
|
containers:
|
||||||
- cerc/plugeth-statediff
|
- cerc/plugeth-statediff
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ version: "1.0"
|
|||||||
name: fixturenet-pocket
|
name: fixturenet-pocket
|
||||||
description: "A single node pocket chain that can serve relays from the geth-1 node in eth-fixturenet"
|
description: "A single node pocket chain that can serve relays from the geth-1 node in eth-fixturenet"
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/lighthouse
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
- github.com/pokt-network/pocket-core
|
- github.com/pokt-network/pocket-core
|
||||||
- github.com/pokt-network/pocket-core-deployments # contains the dockerfile
|
- github.com/pokt-network/pocket-core-deployments # contains the dockerfile
|
||||||
containers:
|
containers:
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ version: "1.2"
|
|||||||
name: mainnet-eth
|
name: mainnet-eth
|
||||||
description: "Ethereum Mainnet"
|
description: "Ethereum Mainnet"
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/lighthouse
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
- github.com/dboreham/foundry
|
- github.com/dboreham/foundry
|
||||||
- git.vdb.to/cerc-io/keycloak-reg-api
|
- git.vdb.to/cerc-io/keycloak-reg-api
|
||||||
- git.vdb.to/cerc-io/keycloak-reg-ui
|
- git.vdb.to/cerc-io/keycloak-reg-ui
|
||||||
|
|||||||
@@ -13,11 +13,11 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from app.util import get_yaml
|
from laconic_stack_orchestrator.util import get_yaml
|
||||||
from app.deploy_types import DeployCommandContext, LaconicStackSetupCommand, DeploymentContext
|
from laconic_stack_orchestrator.deploy_types import DeployCommandContext, LaconicStackSetupCommand, DeploymentContext
|
||||||
from app.stack_state import State
|
from laconic_stack_orchestrator.stack_state import State
|
||||||
from app.deploy_util import VolumeMapping, run_container_command
|
from laconic_stack_orchestrator.deploy_util import VolumeMapping, run_container_command
|
||||||
from app.command_types import CommandOptions
|
from laconic_stack_orchestrator.command_types import CommandOptions
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import copyfile, copytree
|
from shutil import copyfile, copytree
|
||||||
@@ -27,10 +27,7 @@ import sys
|
|||||||
import tomli
|
import tomli
|
||||||
import re
|
import re
|
||||||
|
|
||||||
default_spec_file_content = """config:
|
default_spec_file_content = ""
|
||||||
node_moniker: my-node-name
|
|
||||||
chain_id: my-chain-id
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
class SetupPhase(Enum):
|
class SetupPhase(Enum):
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
version: "1.0"
|
version: "1.0"
|
||||||
name: mobymask-v2
|
name: mobymask-v2
|
||||||
repos:
|
repos:
|
||||||
- github.com/cerc-io/go-ethereum
|
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||||
- github.com/cerc-io/lighthouse
|
- git.vdb.to/cerc-io/lighthouse
|
||||||
- github.com/dboreham/foundry
|
- github.com/dboreham/foundry
|
||||||
- github.com/ethereum-optimism/optimism@v1.0.4
|
- github.com/ethereum-optimism/optimism@v1.0.4
|
||||||
- github.com/ethereum-optimism/op-geth@v1.101105.2
|
- github.com/ethereum-optimism/op-geth@v1.101105.2
|
||||||
|
|||||||
@@ -2,15 +2,18 @@ version: "1.0"
|
|||||||
description: "MobyMask v3 stack"
|
description: "MobyMask v3 stack"
|
||||||
name: mobymask-v3
|
name: mobymask-v3
|
||||||
repos:
|
repos:
|
||||||
|
- github.com/cerc-io/ts-nitrov0.1.12
|
||||||
- github.com/cerc-io/watcher-ts@v0.2.57
|
- github.com/cerc-io/watcher-ts@v0.2.57
|
||||||
- github.com/cerc-io/mobymask-v2-watcher-ts@v3
|
- github.com/cerc-io/mobymask-v2-watcher-ts@v3 # TODO: Update after fixes
|
||||||
- github.com/cerc-io/MobyMask@v0.1.3
|
- github.com/cerc-io/MobyMask@v0.1.3
|
||||||
- github.com/cerc-io/mobymask-ui
|
- github.com/cerc-io/mobymask-ui@v0.2.0
|
||||||
containers:
|
containers:
|
||||||
|
- cerc/nitro-contracts
|
||||||
- cerc/watcher-ts
|
- cerc/watcher-ts
|
||||||
- cerc/watcher-mobymask-v3
|
- cerc/watcher-mobymask-v3
|
||||||
- cerc/mobymask
|
- cerc/mobymask
|
||||||
- cerc/mobymask-ui
|
- cerc/mobymask-ui
|
||||||
pods:
|
pods:
|
||||||
|
- nitro-contracts
|
||||||
- watcher-mobymask-v3
|
- watcher-mobymask-v3
|
||||||
- mobymask-app-v3
|
- mobymask-app-v3
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
Prerequisite: L2 Optimism Geth and Node RPC endpoints
|
Prerequisite: L2 Optimism Geth RPC endpoint
|
||||||
|
|
||||||
Clone required repositories:
|
Clone required repositories:
|
||||||
|
|
||||||
@@ -23,21 +23,16 @@ laconic-so --stack mobymask-v3 build-containers --exclude cerc/mobymask-ui
|
|||||||
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v3/mobymask-params.env)):
|
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v3/mobymask-params.env)):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# External L2 endpoints
|
# External ETH RPC endpoint (L2 Optimism geth)
|
||||||
CERC_L2_GETH_RPC=
|
CERC_ETH_RPC_ENDPOINT=
|
||||||
|
|
||||||
# Endpoints waited on before contract deployment
|
# External ETH RPC endpoint used for queries in the watcher
|
||||||
CERC_L2_GETH_HOST=
|
CERC_ETH_RPC_QUERY_ENDPOINT=
|
||||||
CERC_L2_GETH_PORT=
|
|
||||||
|
|
||||||
CERC_L2_NODE_HOST=
|
# External ETH RPC endpoint used for mutations in the watcher
|
||||||
CERC_L2_NODE_PORT=
|
CERC_ETH_RPC_MUTATION_ENDPOINT=
|
||||||
|
|
||||||
# URL (fixturenet-eth-bootnode-lighthouse) to get CSV with credentials for accounts on L1 to perform txs on L2
|
# Specify the an account PK for contract deployment
|
||||||
CERC_L1_ACCOUNTS_CSV_URL=
|
|
||||||
|
|
||||||
# OR
|
|
||||||
# Specify the required account credentials
|
|
||||||
CERC_PRIVATE_KEY_DEPLOYER=
|
CERC_PRIVATE_KEY_DEPLOYER=
|
||||||
|
|
||||||
# Base URI for mobymask-app
|
# Base URI for mobymask-app
|
||||||
@@ -71,11 +66,14 @@ Create and update an env file to be used in the next step ([defaults](../../conf
|
|||||||
CERC_PRIVATE_KEY_PEER=
|
CERC_PRIVATE_KEY_PEER=
|
||||||
|
|
||||||
# Specify private key for the Nitro account
|
# Specify private key for the Nitro account
|
||||||
CERC_PRIVATE_KEY_NITRO=
|
CERC_WATCHER_NITRO_PK=
|
||||||
|
|
||||||
# (Optional) Set a pre-existing peer id to be used (enables consensus)
|
# (Optional) Set a pre-existing peer id to be used (enables consensus)
|
||||||
# Uses a generated peer id if not set (disables consensus)
|
# Uses a generated peer id if not set (disables consensus)
|
||||||
CERC_PEER_ID=
|
CERC_PEER_ID=
|
||||||
|
|
||||||
|
# Disable payments to upstream ETH server
|
||||||
|
CERC_ENABLE_UPSTREAM_PAYMENTS=false
|
||||||
```
|
```
|
||||||
|
|
||||||
* NOTE: If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
|
* NOTE: If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
|
||||||
@@ -83,13 +81,13 @@ Create and update an env file to be used in the next step ([defaults](../../conf
|
|||||||
### Deploy the stack
|
### Deploy the stack
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 --env-file <PATH_TO_ENV_FILE> up
|
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 --env-file <PATH_TO_ENV_FILE> up
|
||||||
```
|
```
|
||||||
|
|
||||||
* To list down and monitor the running containers:
|
* To list down and monitor the running containers:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 ps
|
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 ps
|
||||||
|
|
||||||
# With status
|
# With status
|
||||||
docker ps -a
|
docker ps -a
|
||||||
@@ -106,18 +104,18 @@ laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mo
|
|||||||
docker logs -f $(docker ps -aq --filter name="mobymask-1")
|
docker logs -f $(docker ps -aq --filter name="mobymask-1")
|
||||||
```
|
```
|
||||||
|
|
||||||
* Check the logs of the watcher server container to get the deployed Nitro contracts' addresses:
|
* Check logs of the Nitro contracts container to get the deployed Nitro contracts' addresses:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec -it $(docker ps -q --filter name="mobymask-watcher-server") bash -c "cat /nitro/nitro-addresses.json"
|
docker exec -it $(docker ps -q --filter name="nitro-contracts") bash -c "cat /app/deployment/nitro-addresses.json"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Clean up
|
## Clean up
|
||||||
|
|
||||||
Stop all services running in the background:
|
Stop all services running in the background:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 down
|
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 down
|
||||||
```
|
```
|
||||||
|
|
||||||
Clear volumes created by this stack:
|
Clear volumes created by this stack:
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Create and update an env file to be used in the next step ([defaults](../../conf
|
|||||||
# Nitro account address to make the query and mutation payments to
|
# Nitro account address to make the query and mutation payments to
|
||||||
CERC_PAYMENT_NITRO_ADDRESS=
|
CERC_PAYMENT_NITRO_ADDRESS=
|
||||||
|
|
||||||
# Endpoint for Mobymask snap installation
|
# (Optional) Endpoint for Mobymask snap installation
|
||||||
CERC_SNAP_URL=
|
CERC_SNAP_URL=
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,14 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from app.util import get_yaml
|
from laconic_stack_orchestrator.util import get_yaml
|
||||||
from app.deploy_types import DeployCommandContext
|
from laconic_stack_orchestrator.deploy_types import DeployCommandContext
|
||||||
from app.stack_state import State
|
from laconic_stack_orchestrator.stack_state import State
|
||||||
from app.deploy_util import VolumeMapping, run_container_command
|
from laconic_stack_orchestrator.deploy_util import VolumeMapping, run_container_command
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
default_spec_file_content = """config:
|
default_spec_file_content = """config:
|
||||||
config_variable: test-value
|
test-variable-1: test-value-1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -26,11 +26,11 @@ import subprocess
|
|||||||
from python_on_whales import DockerClient, DockerException
|
from python_on_whales import DockerClient, DockerException
|
||||||
import click
|
import click
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from app.util import include_exclude_check, get_parsed_stack_config, global_options2
|
from .util import include_exclude_check, get_parsed_stack_config, global_options2
|
||||||
from app.deploy_types import ClusterContext, DeployCommandContext
|
from .deploy_types import ClusterContext, DeployCommandContext
|
||||||
from app.deployment_create import create as deployment_create
|
from .deployment_create import create as deployment_create
|
||||||
from app.deployment_create import init as deployment_init
|
from .deployment_create import init as deployment_init
|
||||||
from app.deployment_create import setup as deployment_setup
|
from .deployment_create import setup as deployment_setup
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@@ -263,7 +263,7 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
|||||||
print(f"Using cluster name: {cluster}")
|
print(f"Using cluster name: {cluster}")
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with resources.open_text(data, "pod-list.txt") as pod_list_file:
|
with resources.open_text(data, "pod-list.txt") as pod_list_file:
|
||||||
all_pods = pod_list_file.read().splitlines()
|
all_pods = pod_list_file.read().splitlines()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ from typing import List
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from python_on_whales import DockerClient
|
from python_on_whales import DockerClient
|
||||||
from app.command_types import CommandOptions
|
from .command_types import CommandOptions
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from typing import List
|
from typing import List
|
||||||
from app.deploy_types import DeployCommandContext, VolumeMapping
|
from .deploy_types import DeployCommandContext, VolumeMapping
|
||||||
from app.util import get_parsed_stack_config, get_yaml, get_compose_file_dir
|
from .util import get_parsed_stack_config, get_yaml, get_compose_file_dir
|
||||||
|
|
||||||
|
|
||||||
def _container_image_from_service(stack: str, service: str):
|
def _container_image_from_service(stack: str, service: str):
|
||||||
|
|||||||
+16
-6
@@ -17,14 +17,24 @@ import click
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
from app.deploy import up_operation, down_operation, ps_operation, port_operation
|
from .deploy import up_operation, down_operation, ps_operation, port_operation
|
||||||
from app.deploy import exec_operation, logs_operation, create_deploy_context
|
from .deploy import exec_operation, logs_operation, create_deploy_context
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DeploymentContext:
|
class DeploymentContext:
|
||||||
dir: Path
|
dir: Path
|
||||||
|
|
||||||
|
def get_stack_file(self):
|
||||||
|
return self.dir.joinpath("stack.yml")
|
||||||
|
|
||||||
|
def get_env_file(self):
|
||||||
|
return self.dir.joinpath("config.env")
|
||||||
|
|
||||||
|
# TODO: implement me
|
||||||
|
def get_cluster_name(self):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.option("--dir", required=True, help="path to deployment directory")
|
@click.option("--dir", required=True, help="path to deployment directory")
|
||||||
@@ -49,10 +59,10 @@ def command(ctx, dir):
|
|||||||
|
|
||||||
|
|
||||||
def make_deploy_context(ctx):
|
def make_deploy_context(ctx):
|
||||||
# Get the stack config file name
|
stack_file_path = ctx.obj.get_stack_file()
|
||||||
stack_file_path = ctx.obj.dir.joinpath("stack.yml")
|
env_file = ctx.obj.get_env_file()
|
||||||
# TODO: add cluster name and env file here
|
cluster_name = ctx.obj.get_cluster_name()
|
||||||
return create_deploy_context(ctx.parent.parent.obj, stack_file_path, None, None, None, None)
|
return create_deploy_context(ctx.parent.parent.obj, stack_file_path, None, None, cluster_name, env_file)
|
||||||
|
|
||||||
|
|
||||||
@command.command()
|
@command.command()
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ from pathlib import Path
|
|||||||
import random
|
import random
|
||||||
from shutil import copyfile, copytree
|
from shutil import copyfile, copytree
|
||||||
import sys
|
import sys
|
||||||
from app.util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml
|
from .util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml
|
||||||
from app.util import get_compose_file_dir
|
from .util import get_compose_file_dir
|
||||||
from app.deploy_types import DeploymentContext, LaconicStackSetupCommand
|
from .deploy_types import DeploymentContext, LaconicStackSetupCommand
|
||||||
|
|
||||||
|
|
||||||
def _make_default_deployment_dir():
|
def _make_default_deployment_dir():
|
||||||
@@ -204,22 +204,48 @@ def _get_mapped_ports(stack: str, map_recipe: str):
|
|||||||
return ports
|
return ports
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_config_variables(variable_values: str):
|
||||||
|
result = None
|
||||||
|
if variable_values:
|
||||||
|
value_pairs = variable_values.split(",")
|
||||||
|
if len(value_pairs):
|
||||||
|
result_values = {}
|
||||||
|
for value_pair in value_pairs:
|
||||||
|
variable_value_pair = value_pair.split("=")
|
||||||
|
if len(variable_value_pair) != 2:
|
||||||
|
print(f"ERROR: config argument is not valid: {variable_values}")
|
||||||
|
sys.exit(1)
|
||||||
|
variable_name = variable_value_pair[0]
|
||||||
|
variable_value = variable_value_pair[1]
|
||||||
|
result_values[variable_name] = variable_value
|
||||||
|
result = {"config": result_values}
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
@click.option("--config", help="Provide config variables for the deployment")
|
||||||
@click.option("--output", required=True, help="Write yaml spec file here")
|
@click.option("--output", required=True, help="Write yaml spec file here")
|
||||||
@click.option("--map-ports-to-host", required=False,
|
@click.option("--map-ports-to-host", required=False,
|
||||||
help="Map ports to the host as one of: any-variable-random (default), "
|
help="Map ports to the host as one of: any-variable-random (default), "
|
||||||
"localhost-same, any-same, localhost-fixed-random, any-fixed-random")
|
"localhost-same, any-same, localhost-fixed-random, any-fixed-random")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def init(ctx, output, map_ports_to_host):
|
def init(ctx, config, output, map_ports_to_host):
|
||||||
yaml = get_yaml()
|
yaml = get_yaml()
|
||||||
stack = global_options(ctx).stack
|
stack = global_options(ctx).stack
|
||||||
verbose = global_options(ctx).verbose
|
debug = global_options(ctx).debug
|
||||||
default_spec_file_content = call_stack_deploy_init(ctx.obj)
|
default_spec_file_content = call_stack_deploy_init(ctx.obj)
|
||||||
spec_file_content = {"stack": stack}
|
spec_file_content = {"stack": stack}
|
||||||
if default_spec_file_content:
|
if default_spec_file_content:
|
||||||
spec_file_content.update(default_spec_file_content)
|
spec_file_content.update(default_spec_file_content)
|
||||||
if verbose:
|
config_variables = _parse_config_variables(config)
|
||||||
print(f"Creating spec file for stack: {stack}")
|
if config_variables:
|
||||||
|
# Implement merge, since update() overwrites
|
||||||
|
orig_config = spec_file_content["config"]
|
||||||
|
new_config = config_variables["config"]
|
||||||
|
merged_config = {**new_config, **orig_config}
|
||||||
|
spec_file_content.update({"config": merged_config})
|
||||||
|
if debug:
|
||||||
|
print(f"Creating spec file for stack: {stack} with content: {spec_file_content}")
|
||||||
|
|
||||||
ports = _get_mapped_ports(stack, map_ports_to_host)
|
ports = _get_mapped_ports(stack, map_ports_to_host)
|
||||||
spec_file_content["ports"] = ports
|
spec_file_content["ports"] = ports
|
||||||
@@ -235,6 +261,16 @@ def init(ctx, output, map_ports_to_host):
|
|||||||
yaml.dump(spec_file_content, output_file)
|
yaml.dump(spec_file_content, output_file)
|
||||||
|
|
||||||
|
|
||||||
|
def _write_config_file(spec_file: Path, config_env_file: Path):
|
||||||
|
spec_content = get_parsed_deployment_spec(spec_file)
|
||||||
|
if spec_content["config"]:
|
||||||
|
config_vars = spec_content["config"]
|
||||||
|
if config_vars:
|
||||||
|
with open(config_env_file, "w") as output_file:
|
||||||
|
for variable_name, variable_value in config_vars.items():
|
||||||
|
output_file.write(f"{variable_name}={variable_value}\n")
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--spec-file", required=True, help="Spec file to use to create this deployment")
|
@click.option("--spec-file", required=True, help="Spec file to use to create this deployment")
|
||||||
@click.option("--deployment-dir", help="Create deployment files in this directory")
|
@click.option("--deployment-dir", help="Create deployment files in this directory")
|
||||||
@@ -259,6 +295,8 @@ def create(ctx, spec_file, deployment_dir, network_dir, initial_peers):
|
|||||||
# Copy spec file and the stack file into the deployment dir
|
# Copy spec file and the stack file into the deployment dir
|
||||||
copyfile(spec_file, os.path.join(deployment_dir, os.path.basename(spec_file)))
|
copyfile(spec_file, os.path.join(deployment_dir, os.path.basename(spec_file)))
|
||||||
copyfile(stack_file, os.path.join(deployment_dir, os.path.basename(stack_file)))
|
copyfile(stack_file, os.path.join(deployment_dir, os.path.basename(stack_file)))
|
||||||
|
# Copy any config varibles from the spec file into an env file suitable for compose
|
||||||
|
_write_config_file(spec_file, os.path.join(deployment_dir, "config.env"))
|
||||||
# Copy the pod files into the deployment dir, fixing up content
|
# Copy the pod files into the deployment dir, fixing up content
|
||||||
pods = parsed_stack['pods']
|
pods = parsed_stack['pods']
|
||||||
destination_compose_dir = os.path.join(deployment_dir, "compose")
|
destination_compose_dir = os.path.join(deployment_dir, "compose")
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import click
|
|||||||
import importlib.resources
|
import importlib.resources
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import yaml
|
import yaml
|
||||||
from app.util import include_exclude_check
|
from .util import include_exclude_check
|
||||||
|
|
||||||
|
|
||||||
class GitProgress(git.RemoteProgress):
|
class GitProgress(git.RemoteProgress):
|
||||||
@@ -232,7 +232,7 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches
|
|||||||
os.makedirs(dev_root_path)
|
os.makedirs(dev_root_path)
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file:
|
with importlib.resources.open_text(data, "repository-list.txt") as repository_list_file:
|
||||||
all_repos = repository_list_file.read().splitlines()
|
all_repos = repository_list_file.read().splitlines()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import sys
|
|||||||
import stat
|
import stat
|
||||||
import shutil
|
import shutil
|
||||||
import validators
|
import validators
|
||||||
from app.util import get_yaml
|
from .util import get_yaml
|
||||||
|
|
||||||
|
|
||||||
def _download_url(url: str, file_path: Path):
|
def _download_url(url: str, file_path: Path):
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ def command(ctx):
|
|||||||
'''print tool version'''
|
'''print tool version'''
|
||||||
|
|
||||||
# See: https://stackoverflow.com/a/20885799/1701505
|
# See: https://stackoverflow.com/a/20885799/1701505
|
||||||
from app import data
|
from . import data
|
||||||
with importlib.resources.open_text(data, "build_tag.txt") as version_file:
|
with importlib.resources.open_text(data, "build_tag.txt") as version_file:
|
||||||
# TODO: code better version that skips comment lines
|
# TODO: code better version that skips comment lines
|
||||||
version_string = version_file.read().splitlines()[1]
|
version_string = version_file.read().splitlines()[1]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# See https://medium.com/nerd-for-tech/how-to-build-and-distribute-a-cli-tool-with-python-537ae41d9d78
|
# See https://medium.com/nerd-for-tech/how-to-build-and-distribute-a-cli-tool-with-python-537ae41d9d78
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup
|
||||||
with open("README.md", "r", encoding="utf-8") as fh:
|
with open("README.md", "r", encoding="utf-8") as fh:
|
||||||
long_description = fh.read()
|
long_description = fh.read()
|
||||||
with open("requirements.txt", "r", encoding="utf-8") as fh:
|
with open("requirements.txt", "r", encoding="utf-8") as fh:
|
||||||
@@ -14,8 +14,9 @@ setup(
|
|||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
url='https://github.com/cerc-io/stack-orchestrator',
|
url='https://github.com/cerc-io/stack-orchestrator',
|
||||||
py_modules=['cli', 'app'],
|
packages=['laconic_stack_orchestrator'],
|
||||||
packages=find_packages(),
|
package_dir={'laconic_stack_orchestrator': 'app'},
|
||||||
|
py_modules=['laconic_stack_orchestrator', 'laconic_stack_orchestrator.cli'],
|
||||||
install_requires=[requirements],
|
install_requires=[requirements],
|
||||||
python_requires='>=3.7',
|
python_requires='>=3.7',
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
@@ -25,6 +26,6 @@ setup(
|
|||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
],
|
],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': ['laconic-so=cli:cli'],
|
'console_scripts': ['laconic-so=laconic_stack_orchestrator.cli:cli'],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ $TEST_TARGET_SO --stack test deploy down --delete-volumes
|
|||||||
# Basic test of creating a deployment
|
# Basic test of creating a deployment
|
||||||
test_deployment_dir=$CERC_REPO_BASE_DIR/test-deployment-dir
|
test_deployment_dir=$CERC_REPO_BASE_DIR/test-deployment-dir
|
||||||
test_deployment_spec=$CERC_REPO_BASE_DIR/test-deployment-spec.yml
|
test_deployment_spec=$CERC_REPO_BASE_DIR/test-deployment-spec.yml
|
||||||
$TEST_TARGET_SO --stack test deploy init --output $test_deployment_spec
|
$TEST_TARGET_SO --stack test deploy init --output $test_deployment_spec --config CERC_TEST_PARAM_1=PASSED
|
||||||
# Check the file now exists
|
# Check the file now exists
|
||||||
if [ ! -f "$test_deployment_spec" ]; then
|
if [ ! -f "$test_deployment_spec" ]; then
|
||||||
echo "deploy init test: spec file not present"
|
echo "deploy init test: spec file not present"
|
||||||
@@ -110,13 +110,20 @@ echo "deploy create output file test: passed"
|
|||||||
# Try to start the deployment
|
# Try to start the deployment
|
||||||
$TEST_TARGET_SO deployment --dir $test_deployment_dir start
|
$TEST_TARGET_SO deployment --dir $test_deployment_dir start
|
||||||
# Check logs command works
|
# Check logs command works
|
||||||
log_output_2=$( $TEST_TARGET_SO deployment --dir $test_deployment_dir logs )
|
log_output_3=$( $TEST_TARGET_SO deployment --dir $test_deployment_dir logs )
|
||||||
if [[ "$log_output_2" == *"Filesystem is fresh"* ]]; then
|
if [[ "$log_output_3" == *"Filesystem is fresh"* ]]; then
|
||||||
echo "deployment logs test: passed"
|
echo "deployment logs test: passed"
|
||||||
else
|
else
|
||||||
echo "deployment logs test: FAILED"
|
echo "deployment logs test: FAILED"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
# Check the config variable CERC_TEST_PARAM_1 was passed correctly
|
||||||
|
if [[ "$log_output_3" == *"Test-param-1: PASSED"* ]]; then
|
||||||
|
echo "deployment config test: passed"
|
||||||
|
else
|
||||||
|
echo "deployment config test: FAILED"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
# Stop and clean up
|
# Stop and clean up
|
||||||
$TEST_TARGET_SO deployment --dir $test_deployment_dir stop --delete-volumes
|
$TEST_TARGET_SO deployment --dir $test_deployment_dir stop --delete-volumes
|
||||||
echo "Test passed"
|
echo "Test passed"
|
||||||
|
|||||||
Reference in New Issue
Block a user