Compare commits

...
56 Commits
Author SHA1 Message Date
dboreham 5d456f5600 Merge pull request #193 from cerc-io/dboreham/disable-docker-buildkit
Revert move to BuildKit in new Docker releases

Former-commit-id: 4fdb442263
2023-02-24 23:34:48 -07:00
dboreham ca40ffb012 Revert move to BuildKit in new Docker releases
Former-commit-id: ced6925e02
2023-02-24 23:31:17 -07:00
dboreham 6a73d3adee Merge pull request #191 from cerc-io/dboreham/builder-js-uid
Support docker containers with non-root users and host user uid not equal to 1000

Former-commit-id: 10548beedf
2023-02-24 23:06:13 -07:00
dboreham 9480b4082e usermod does not change group ownership of home dir
Former-commit-id: 17355c9e42
2023-02-24 22:44:50 -07:00
dboreham 467ff235ba Propagate build env vars
Former-commit-id: 5022e355ed
2023-02-24 22:26:02 -07:00
dboreham 25a755982e Implement new approach: build a uid-specific container
Former-commit-id: 6704cd7527
2023-02-24 22:14:28 -07:00
dboreham e3e96fa75e Work around docker uid/gid insanity
Former-commit-id: b84a28592d
2023-02-23 20:50:20 -07:00
dboreham 42696f8165 Add build stack doc
Former-commit-id: 187c06ef5a
2023-02-23 07:22:46 -07:00
dboreham c26f8552e1 Merge pull request #187 from cerc-io/dboreham/document-build-stack
Add some doc for build stack

Former-commit-id: c52f9e655d
2023-02-21 11:26:43 -07:00
dboreham 8352893d92 Add some doc
Former-commit-id: 1f57ec5326
2023-02-21 11:25:49 -07:00
RickM a92cabcb39 Merge pull request #186 from cerc-io/erc721-stack-syntax
Stack syntax for ERC721.

Former-commit-id: 9ccf3ca1af
2023-02-21 09:38:09 -06:00
RickM f841f8a2de Stack syntax for ERC721.
Former-commit-id: 463b11bb23
2023-02-21 09:30:07 -06:00
dboreham 7f652708bb Merge pull request #185 from cerc-io/dboreham/immutable-js-build
Copy build tree

Former-commit-id: b1e618142d
2023-02-21 06:59:38 -07:00
dboreham c769fce491 Copy build tree
Former-commit-id: 3b55d012be
2023-02-21 06:56:33 -07:00
dboreham 02335795fb Merge pull request #184 from cerc-io/dboreham/kubo
Add a kubo pod

Former-commit-id: 25ae0cac7d
2023-02-21 06:17:41 -07:00
dboreham c717fd8a59 Add ipfs pod
Former-commit-id: 6dddceec27
2023-02-21 06:16:59 -07:00
dboreham 0de2db7e90 Add kubo pod
Former-commit-id: 9c00aba8f3
2023-02-21 05:59:28 -07:00
dboreham 92f325a09b Update version
Former-commit-id: c4fa7fee30
2023-02-21 05:40:57 -07:00
dboreham 964edbec6f Merge pull request #182 from cerc-io/dboreham/check-for-js-builder
Check for builder container in npm build

Former-commit-id: 6c1bedc67e
2023-02-20 16:16:43 -07:00
dboreham 6f2a44ba2f Check for builder container in npm build
Former-commit-id: 156758bfa7
2023-02-20 16:16:15 -07:00
dboreham 9053d2d782 Merge pull request #180 from cerc-io/dboreham/npm-build-with-package-stack
npm build with package-registry stack

Former-commit-id: 9f07a0ed4b
2023-02-20 12:49:20 -07:00
dboreham 628fed4ef7 Working feature
Former-commit-id: f14a4a33d7
2023-02-20 12:46:56 -07:00
dboreham c737ec7ed6 Wire up to build-npms
Former-commit-id: 7e6268c39d
2023-02-20 06:43:06 -07:00
dboreham d927c92c0a Call from base stack class
Former-commit-id: f1cbce1d00
2023-02-20 06:23:21 -07:00
dboreham 142be179f4 Initial implementation
Former-commit-id: 68293cbaa3
2023-02-20 06:09:35 -07:00
dboreham 547ca561c0 Update python on whales
Former-commit-id: 7d51e4b9aa
2023-02-19 17:46:47 -07:00
dboreham 863e19211e Remove debug code
Former-commit-id: 5ceed34160
2023-02-17 15:38:24 -07:00
dboreham e20f9993d2 Merge pull request #178 from cerc-io/dboreham/package-registry-stack
Support for the package registry stack

Former-commit-id: e5197e4918
2023-02-17 15:36:28 -07:00
dboreham 9dab9b815c Add newline
Former-commit-id: 63c93acb83
2023-02-17 15:36:09 -07:00
dboreham 83115bcb9d Fix comment
Former-commit-id: 88d81f7df6
2023-02-17 15:35:31 -07:00
dboreham 46c22f4e4f Add pre/post script support
Former-commit-id: bb39d90522
2023-02-17 15:31:43 -07:00
dboreham 912483df58 Basic functionality
Former-commit-id: a1893aa153
2023-02-17 14:15:35 -07:00
dboreham ff69670db6 Initial commit
Former-commit-id: 60c1da725e
2023-02-17 13:34:51 -07:00
dboreham 871cd90456 Missed one update
Former-commit-id: 2bf50383dd
2023-02-17 11:53:58 -07:00
dboreham 639ab8cbc3 Update to use stack syntax
Former-commit-id: 6569a2a2b6
2023-02-17 11:53:05 -07:00
telackey bc5eff71b5 Use latest keycloak plugin. (#173)
Former-commit-id: 8645ab0619
2023-02-01 16:02:49 -06:00
dboreham 5ec774a300 Update version
Former-commit-id: b0520a042a
2023-01-30 22:29:38 +01:00
dboreham 9a750f0d9e Update version
Former-commit-id: 10f2fbaa37
2023-01-30 22:28:33 +01:00
dboreham 8a6ba6d01b Merge pull request #172 from cerc-io/dboreham/revert-foundry-image
Revert local foundry build

Former-commit-id: 3bd0c74e1f
2023-01-30 22:06:26 +01:00
dboreham b4ddef7ff0 Revert local foundry build
Former-commit-id: e850923e1a
2023-01-30 14:05:48 -07:00
dboreham a38ac5470d Merge pull request #171 from cerc-io/dboreham/fixturenet-loaded
Initial commit

Former-commit-id: 82c2bb78f2
2023-01-30 19:12:06 +01:00
dboreham 77380aec94 Initial commit
Former-commit-id: f01bc27660
2023-01-30 16:53:57 +01:00
dboreham ce7e5f2d82 Merge pull request #169 from cerc-io/dboreham/fix-gerbil-package-install
Install gerbil packages globally not locally in the project directory

Former-commit-id: db5775621d
2023-01-28 11:35:44 -07:00
dboreham 4dda8e2a87 Install gerbil packages globally not locally in the project directory
Former-commit-id: 5928e40721
2023-01-28 18:56:43 +01:00
dboreham 24ab259741 Merge pull request #167 from cerc-io/dboreham/release-doc
Add release process doc

Former-commit-id: 605a9aeda1
2023-01-27 22:25:53 -07:00
David Boreham 607575e4f4 Add release process doc
Former-commit-id: 1b3a14d86f
2023-01-27 21:22:43 -07:00
dboreham 86e245e272 Merge pull request #166 from cerc-io/dboreham/fix-fixturenet-status
Fix status script

Former-commit-id: fc31b44b5a
2023-01-27 08:10:32 -07:00
dboreham d677e5f369 Fix status script
Former-commit-id: 5a3bdd269d
2023-01-27 08:10:04 -07:00
dboreham 9991baa8d6 Update version
Former-commit-id: 04f61293b5
2023-01-27 07:30:14 -07:00
dboreham d033d4ff93 Merge pull request #164 from cerc-io/dboreham/fixturenet-eth-fixes
Fixes to fixturenet-eth

Former-commit-id: ecf943b593
2023-01-26 21:36:23 -07:00
dboreham f02bbee3bf Fixes to fixturenet-eth
Former-commit-id: e4229e4ceb
2023-01-26 16:47:06 -07:00
telackey bdde1b2c9e Include all eth API operation metrics. (#162)
Former-commit-id: ce0c7ee9ba
2023-01-26 13:53:02 -06:00
dboreham 96a83422e7 Merge pull request #161 from cerc-io/dboreham/run-command-in-container
Exec command inside container

Former-commit-id: 6770f7af6e
2023-01-25 23:22:57 -07:00
dboreham af03208da7 Exec command inside container
Former-commit-id: ade20fb2f5
2023-01-25 23:22:05 -07:00
dboreham 86e2407800 Update version
Former-commit-id: bf91048dbb
2023-01-25 22:47:08 -07:00
dboreham c01ff28b4f Add release description
Former-commit-id: a520cce17c
2023-01-25 22:46:37 -07:00
35 changed files with 885 additions and 124 deletions
+71
View File
@@ -0,0 +1,71 @@
# Copyright © 2022, 2023 Cerc
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# 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/>.
import os
from abc import ABC, abstractmethod
from .deploy_system import get_stack_status
def get_stack(config, stack):
if stack == "package-registry":
return package_registry_stack(config, stack)
else:
return base_stack(config, stack)
class base_stack(ABC):
def __init__(self, config, stack):
self.config = config
self.stack = stack
@abstractmethod
def ensure_available(self):
pass
@abstractmethod
def get_url(self):
pass
class package_registry_stack(base_stack):
def ensure_available(self):
self.url = "<no registry url set>"
# Check if we were given an external registry URL
url_from_environment = os.environ.get("CERC_NPM_REGISTRY_URL")
if url_from_environment:
if self.config.verbose:
print(f"Using package registry url from CERC_NPM_REGISTRY_URL: {url_from_environment}")
self.url = url_from_environment
else:
# Otherwise we expect to use the local package-registry stack
# First check if the stack is up
registry_running = get_stack_status(self.config, "package-registry")
if registry_running:
# If it is available, get its mapped port and construct its URL
if self.config.debug:
print("Found local package registry stack is up")
# TODO: get url from deploy-stack
self.url = "http://gitea.local:3000/api/packages/cerc-io/npm/"
else:
# If not, print a message about how to start it and return fail to the caller
print("ERROR: The package-registry stack is not running, and no external registry specified with CERC_NPM_REGISTRY_URL")
print("ERROR: Start the local package registry with: laconic-so --stack package-registry deploy-system up")
return False
return True
def get_url(self):
return self.url
+6 -3
View File
@@ -83,7 +83,10 @@ def command(ctx, include, exclude):
container_build_env = { container_build_env = {
"CERC_NPM_URL": "http://gitea.local:3000/api/packages/cerc-io/npm/", "CERC_NPM_URL": "http://gitea.local:3000/api/packages/cerc-io/npm/",
"CERC_NPM_AUTH_TOKEN": config("CERC_NPM_AUTH_TOKEN", default="<token-not-supplied>"), "CERC_NPM_AUTH_TOKEN": config("CERC_NPM_AUTH_TOKEN", default="<token-not-supplied>"),
"CERC_REPO_BASE_DIR": dev_root_path "CERC_REPO_BASE_DIR": dev_root_path,
"CERC_HOST_UID": f"{os.getuid()}",
"CERC_HOST_GID": f"{os.getgid()}",
"DOCKER_BUILDKIT": "0"
} }
def process_container(container): def process_container(container):
@@ -103,10 +106,10 @@ def command(ctx, include, exclude):
# Check if we have a repo for this container. If not, set the context dir to the container-build subdir # Check if we have a repo for this container. If not, set the context dir to the container-build subdir
repo_full_path = os.path.join(dev_root_path, repo_dir) repo_full_path = os.path.join(dev_root_path, repo_dir)
repo_dir_or_build_dir = repo_dir if os.path.exists(repo_full_path) else build_dir repo_dir_or_build_dir = repo_dir if os.path.exists(repo_full_path) else build_dir
build_command = os.path.join(container_build_dir, "default-build.sh") + f" {container} {repo_dir_or_build_dir}" build_command = os.path.join(container_build_dir, "default-build.sh") + f" {container}:local {repo_dir_or_build_dir}"
if not dry_run: if not dry_run:
if verbose: if verbose:
print(f"Executing: {build_command}") print(f"Executing: {build_command} with environment: {container_build_env}")
build_result = subprocess.run(build_command, shell=True, env=container_build_env) build_result = subprocess.run(build_command, shell=True, env=container_build_env)
if verbose: if verbose:
print(f"Return code is: {build_result.returncode}") print(f"Return code is: {build_result.returncode}")
+58 -6
View File
@@ -20,12 +20,16 @@
import os import os
import sys import sys
from shutil import rmtree, copytree
from decouple import config 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 .base import get_stack
from .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"
@click.command() @click.command()
@click.option('--include', help="only build these packages") @click.option('--include', help="only build these packages")
@click.option('--exclude', help="don\'t build these packages") @click.option('--exclude', help="don\'t build these packages")
@@ -41,17 +45,38 @@ def command(ctx, include, exclude):
stack = ctx.obj.stack stack = ctx.obj.stack
continue_on_error = ctx.obj.continue_on_error continue_on_error = ctx.obj.continue_on_error
_ensure_prerequisites()
# build-npms depends on having access to a writable package registry
# so we check here that it is available
package_registry_stack = get_stack(ctx.obj, "package-registry")
registry_available = package_registry_stack.ensure_available()
if not registry_available:
print("FATAL: no npm registry available for build-npms command")
sys.exit(1)
npm_registry_url = package_registry_stack.get_url()
npm_registry_url_token = config("CERC_NPM_AUTH_TOKEN", default=None)
if not npm_registry_url_token:
print("FATAL: CERC_NPM_AUTH_TOKEN is not defined")
sys.exit(1)
if local_stack: if local_stack:
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")] dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
print(f'Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}') print(f'Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}')
else: else:
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc")) dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
if not quiet: build_root_path = os.path.join(dev_root_path, "build-trees")
if verbose:
print(f'Dev Root is: {dev_root_path}') print(f'Dev Root is: {dev_root_path}')
if not os.path.isdir(dev_root_path): if not os.path.isdir(dev_root_path):
print('Dev root directory doesn\'t exist, creating') print('Dev root directory doesn\'t exist, creating')
os.makedirs(dev_root_path)
if not os.path.isdir(dev_root_path):
print('Build root directory doesn\'t exist, creating')
os.makedirs(build_root_path)
# See: https://stackoverflow.com/a/20885799/1701505 # See: https://stackoverflow.com/a/20885799/1701505
from . import data from . import data
@@ -74,21 +99,38 @@ def command(ctx, include, exclude):
print(f"Building npm package: {package}") print(f"Building npm package: {package}")
repo_dir = package repo_dir = package
repo_full_path = os.path.join(dev_root_path, repo_dir) repo_full_path = os.path.join(dev_root_path, repo_dir)
# TODO: make the npm registry url configurable. # Copy the repo and build that to avoid propagating JS tooling file changes back into the cloned repo
build_command = ["sh", "-c", "cd /workspace && build-npm-package-local-dependencies.sh http://gitea.local:3000/api/packages/cerc-io/npm/"] repo_copy_path = os.path.join(build_root_path, repo_dir)
# First delete any old build tree
if os.path.isdir(repo_copy_path):
if verbose:
print(f"Deleting old build tree: {repo_copy_path}")
if not dry_run:
rmtree(repo_copy_path)
# Now copy the repo into the build tree location
if verbose:
print(f"Copying build tree from: {repo_full_path} to: {repo_copy_path}")
if not dry_run:
copytree(repo_full_path, repo_copy_path)
build_command = ["sh", "-c", f"cd /workspace && build-npm-package-local-dependencies.sh {npm_registry_url}"]
if not dry_run: if not dry_run:
if verbose: if verbose:
print(f"Executing: {build_command}") print(f"Executing: {build_command}")
envs = {"CERC_NPM_AUTH_TOKEN": os.environ["CERC_NPM_AUTH_TOKEN"]} | ({"CERC_SCRIPT_DEBUG": "true"} if debug else {}) # Originally we used the PEP 584 merge operator:
# envs = {"CERC_NPM_AUTH_TOKEN": npm_registry_url_token} | ({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
# but that isn't available in Python 3.8 (default in Ubuntu 20) so for now we use dict.update:
envs = {"CERC_NPM_AUTH_TOKEN": npm_registry_url_token}
envs.update({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
try: try:
docker.run("cerc/builder-js", docker.run(builder_js_image_name,
remove=True, remove=True,
interactive=True, interactive=True,
tty=True, tty=True,
user=f"{os.getuid()}:{os.getgid()}", user=f"{os.getuid()}:{os.getgid()}",
envs=envs, envs=envs,
# TODO: detect this host name in npm_registry_url rather than hard-wiring it
add_hosts=[("gitea.local", "host-gateway")], add_hosts=[("gitea.local", "host-gateway")],
volumes=[(repo_full_path, "/workspace")], volumes=[(repo_copy_path, "/workspace")],
command=build_command command=build_command
) )
# Note that although the docs say that build_result should contain # Note that although the docs say that build_result should contain
@@ -111,3 +153,13 @@ def command(ctx, include, exclude):
else: else:
if verbose: if verbose:
print(f"Excluding: {package}") print(f"Excluding: {package}")
def _ensure_prerequisites():
# Check that the builder-js container is available and
# Tell the user how to build it if not
images = docker.image.list(builder_js_image_name)
if len(images) == 0:
print(f"FATAL: builder image: {builder_js_image_name} is required but was not found")
print("Please run this command to create it: laconic-so --stack build-support build-containers")
sys.exit(1)
@@ -13,6 +13,8 @@ services:
grafana: grafana:
restart: always restart: always
image: grafana/grafana image: grafana/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=changeme6325
volumes: volumes:
- ../config/fixturenet-eth-metrics/grafana/etc/provisioning/dashboards:/etc/grafana/provisioning/dashboards - ../config/fixturenet-eth-metrics/grafana/etc/provisioning/dashboards:/etc/grafana/provisioning/dashboards
- ../config/fixturenet-eth-metrics/grafana/etc/provisioning/datasources:/etc/grafana/provisioning/datasources - ../config/fixturenet-eth-metrics/grafana/etc/provisioning/datasources:/etc/grafana/provisioning/datasources
@@ -20,6 +20,7 @@ services:
CERC_REMOTE_DEBUG: "true" CERC_REMOTE_DEBUG: "true"
CERC_RUN_STATEDIFF: "detect" CERC_RUN_STATEDIFF: "detect"
CERC_STATEDIFF_DB_NODE_ID: 1 CERC_STATEDIFF_DB_NODE_ID: 1
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
env_file: env_file:
- ../config/fixturenet-eth/fixturenet-eth.env - ../config/fixturenet-eth/fixturenet-eth.env
image: cerc/fixturenet-eth-geth:local image: cerc/fixturenet-eth-geth:local
+13
View File
@@ -0,0 +1,13 @@
version: "3.2"
# See: https://docs.ipfs.tech/install/run-ipfs-inside-docker/#set-up
services:
ipfs:
image: ipfs/kubo:master-2023-02-20-714a968
restart: always
volumes:
- ./ipfs/import:/import
- ./ipfs/data:/data/ipfs
ports:
- "8080"
- "4001"
- "5001"
@@ -326,8 +326,9 @@
"uid": "jZUuGao4k" "uid": "jZUuGao4k"
}, },
"editorMode": "code", "editorMode": "code",
"expr": "rate(rpc_duration_eth_call_success_count{instance=\"${node}:6060\"}[$__rate_interval])", "expr": "rate(rpc_duration_eth_blockNumber_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"legendFormat": "eth_call", "hide": false,
"legendFormat": "eth_blockNumber",
"range": true, "range": true,
"refId": "A" "refId": "A"
}, },
@@ -337,48 +338,12 @@
"uid": "jZUuGao4k" "uid": "jZUuGao4k"
}, },
"editorMode": "code", "editorMode": "code",
"expr": "rate(rpc_duration_eth_getBlockByHash_success_count{instance=\"${node}:6060\"}[$__rate_interval])", "expr": "rate(rpc_duration_eth_call_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false, "hide": false,
"legendFormat": "eth_getBlocksByHash", "legendFormat": "eth_call",
"range": true, "range": true,
"refId": "B" "refId": "B"
}, },
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getBlockByNumber_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getBlocksByNumber",
"range": true,
"refId": "C"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getStorageAt_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "getStorageAt",
"range": true,
"refId": "D"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_statediff_writeStateDiffAt_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "statediff_writeStateDiffAt",
"range": true,
"refId": "E"
},
{ {
"datasource": { "datasource": {
"type": "prometheus", "type": "prometheus",
@@ -389,8 +354,356 @@
"hide": false, "hide": false,
"legendFormat": "eth_chainId", "legendFormat": "eth_chainId",
"range": true, "range": true,
"refId": "C"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_estimateGas_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_estimateGas",
"range": true,
"refId": "D"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_gasPrice_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_gasPrice",
"range": true,
"refId": "E"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getBalance_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getBalance",
"range": true,
"refId": "F" "refId": "F"
}, },
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getBlockByHash_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getBlockByHash",
"range": true,
"refId": "G"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getBlockByNumber_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getBlockByNumber",
"range": true,
"refId": "H"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getBlockReceipts_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getBlockReceipts",
"range": true,
"refId": "I"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getBlockTransactionCountByHash_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getBlockTransactionCountByHash",
"range": true,
"refId": "J"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getBlockTransactionCountByNumber_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getBlockTransactionCountByNumber",
"range": true,
"refId": "K"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getCode_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getCode",
"range": true,
"refId": "L"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getFilterChanges_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getFilterChanges",
"range": true,
"refId": "M"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getFilterLogs_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getFilterLogs",
"range": true,
"refId": "N"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getLogs_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getLogs",
"range": true,
"refId": "O"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getStorageAt_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getStorageAt",
"range": true,
"refId": "P"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getTransactionByBlockHashAndIndex_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getTransactionByBlockHashAndIndex",
"range": true,
"refId": "Q"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getTransactionByBlockNumberAndIndex_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getTransactionByBlockNumberAndIndex",
"range": true,
"refId": "R"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getTransactionByHash_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getTransactionByHash",
"range": true,
"refId": "S"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getTransactionCount_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getTransactionCount",
"range": true,
"refId": "T"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getTransactionReceipt_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getTransactionReceipt",
"range": true,
"refId": "U"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getUncleCountByBlockHash_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getUncleCountByBlockHash",
"range": true,
"refId": "V"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_getUncleCountByBlockNumber_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_getUncleCountByBlockNumber",
"range": true,
"refId": "W"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_mining_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_mining_success",
"range": true,
"refId": "X"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_newBlockFilter_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_newBlockFilter",
"range": true,
"refId": "Y"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_newFilter_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_newFilter",
"range": true,
"refId": "Z"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_newPendingTransactionFilter_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_newPendingTransactionFilter",
"range": true,
"refId": "AA"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_sendRawTransaction_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_sendRawTransaction",
"range": true,
"refId": "AB"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_signTransaction_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_signTransaction",
"range": true,
"refId": "AC"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_subscribe_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_subscribe",
"range": true,
"refId": "AD"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_syncing_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_syncing",
"range": true,
"refId": "AE"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_eth_unsubscribe_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "eth_unsubscribe",
"range": true,
"refId": "AF"
},
{ {
"datasource": { "datasource": {
"type": "prometheus", "type": "prometheus",
@@ -401,7 +714,19 @@
"hide": false, "hide": false,
"legendFormat": "statediff_writeStateDiffFor", "legendFormat": "statediff_writeStateDiffFor",
"range": true, "range": true,
"refId": "G" "refId": "AG"
},
{
"datasource": {
"type": "prometheus",
"uid": "jZUuGao4k"
},
"editorMode": "code",
"expr": "rate(rpc_duration_statediff_writeStateDiffAt_success_count{instance=\"${node}:6060\"}[$__rate_interval])",
"hide": false,
"legendFormat": "statediff_writeStateDiffAt",
"range": true,
"refId": "AH"
} }
], ],
"title": "geth API Requests/sec", "title": "geth API Requests/sec",
@@ -19,3 +19,5 @@ CERC_STATEDIFF_DB_USER="vdbm"
CERC_STATEDIFF_DB_PASSWORD="password" CERC_STATEDIFF_DB_PASSWORD="password"
CERC_STATEDIFF_DB_GOOSE_MIN_VER=23 CERC_STATEDIFF_DB_GOOSE_MIN_VER=23
CERC_STATEDIFF_DB_LOG_STATEMENTS="false" CERC_STATEDIFF_DB_LOG_STATEMENTS="false"
CERC_GETH_VMODULE="statediff/*=5,rpc/*=5"
@@ -16,6 +16,12 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && export DEBCONF_NO
RUN mkdir /scripts RUN mkdir /scripts
COPY install-dependencies.sh /scripts COPY install-dependencies.sh /scripts
# Override the definition of GERBIL_PATH in the base image, but
# is safe because (at present) no gerbil packages are installed in the base image
# We do this in order to allow a set of pre-installed packages from the container
# to be used with an arbitrary, potentially different set of projects bind mounted
# at /src
ENV GERBIL_PATH=/.gerbil
RUN bash /scripts/install-dependencies.sh RUN bash /scripts/install-dependencies.sh
# Needed to prevent git from raging about /src # Needed to prevent git from raging about /src
@@ -10,6 +10,7 @@ DEPS=(github.com/fare/gerbil-utils
github.com/vyzo/gerbil-libp2p github.com/vyzo/gerbil-libp2p
) ; ) ;
for i in ${DEPS[@]} ; do for i in ${DEPS[@]} ; do
echo "Installing gerbil package: $i"
gxpkg install $i && gxpkg install $i &&
gxpkg build $i gxpkg build $i
done done
@@ -1,14 +1,30 @@
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile # Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
# Which depends on: https://github.com/nodejs/docker-node/blob/main/Dockerfile-debian.template
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster # [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
ARG VARIANT=16-bullseye ARG VARIANT=16-bullseye
FROM node:${VARIANT} FROM node:${VARIANT}
# Set these args to change the uid/gid for the base container's "node" user to match that of the host user (so bind mounts work as expected).
ARG CERC_HOST_UID=1000
ARG CERC_HOST_GID=1000
# Make these values available at runtime to allow a consistency check.
ENV HOST_UID=${CERC_HOST_UID}
ENV HOST_GID=${CERC_HOST_GID}
ARG USERNAME=node ARG USERNAME=node
ARG NPM_GLOBAL=/usr/local/share/npm-global ARG NPM_GLOBAL=/usr/local/share/npm-global
# Add NPM global to PATH. # Add NPM global to PATH.
ENV PATH=${NPM_GLOBAL}/bin:${PATH} ENV PATH=${NPM_GLOBAL}/bin:${PATH}
RUN \
if [ ${CERC_HOST_GID} -ne 1000 ] ; then \
groupmod -g ${CERC_HOST_GID} ${USERNAME} ; \
fi \
&& if [ ${CERC_HOST_UID} -ne 1000 ] ; then \
usermod -u ${CERC_HOST_UID} -g ${CERC_HOST_GID} ${USERNAME} && chown ${CERC_HOST_UID}:${CERC_HOST_GID} /home/${USERNAME} ; \
fi
RUN \ RUN \
# Configure global npm install location, use group to adapt to UID/GID changes # Configure global npm install location, use group to adapt to UID/GID changes
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \ if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
@@ -39,6 +55,7 @@ RUN mkdir /scripts
COPY build-npm-package.sh /scripts COPY build-npm-package.sh /scripts
COPY yarn-local-registry-fixup.sh /scripts COPY yarn-local-registry-fixup.sh /scripts
COPY build-npm-package-local-dependencies.sh /scripts COPY build-npm-package-local-dependencies.sh /scripts
COPY check-uid.sh /scripts
ENV PATH="${PATH}:/scripts" ENV PATH="${PATH}:/scripts"
COPY entrypoint.sh . COPY entrypoint.sh .
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# Make the container usable for uid/gid != 1000
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
set -x
fi
current_uid=$(id -u)
current_gid=$(id -g)
# Don't check if running as root
if [[ ${current_uid} == 0 ]]; then
exit 0
fi
# Check the current uid/gid vs the uid/gid used to build the container.
# We do this because both bind mounts and npm tooling require the uid/gid to match.
if [[ ${current_gid} != ${HOST_GID} ]]; then
echo "Warning: running with gid: ${current_gid} which is not the gid for which this container was built (${HOST_GID})"
exit 0
fi
if [[ ${current_uid} != ${HOST_UID} ]]; then
echo "Warning: running with gid: ${current_uid} which is not the uid for which this container was built (${HOST_UID})"
exit 0
fi
@@ -1,2 +1,3 @@
#!/bin/sh #!/bin/sh
/scripts/check-uid.sh
exec "$@" exec "$@"
@@ -1,5 +1,9 @@
#!/bin/bash #!/bin/bash
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
ETHERBASE=`cat /opt/testnet/build/el/accounts.csv | head -1 | cut -d',' -f2` ETHERBASE=`cat /opt/testnet/build/el/accounts.csv | head -1 | cut -d',' -f2`
NETWORK_ID=`cat /opt/testnet/el/el-config.yaml | grep 'chain_id' | awk '{ print $2 }'` NETWORK_ID=`cat /opt/testnet/el/el-config.yaml | grep 'chain_id' | awk '{ print $2 }'`
NETRESTRICT=`ip addr | grep inet | grep -v '127.0' | awk '{print $2}'` NETRESTRICT=`ip addr | grep inet | grep -v '127.0' | awk '{print $2}'`
@@ -28,7 +32,9 @@ else
echo -n "$JWT" > /opt/testnet/build/el/jwtsecret echo -n "$JWT" > /opt/testnet/build/el/jwtsecret
if [ "$CERC_RUN_STATEDIFF" == "detect" ] && [ -n "$CERC_STATEDIFF_DB_HOST" ]; then if [ "$CERC_RUN_STATEDIFF" == "detect" ] && [ -n "$CERC_STATEDIFF_DB_HOST" ]; then
if [ -n "$(dig $CERC_STATEDIFF_DB_HOST +short)" ]; then dig_result=$(dig $CERC_STATEDIFF_DB_HOST +short)
dig_status_code=$?
if [[ $dig_status_code = 0 && -n $dig_result ]]; then
echo "Statediff DB at $CERC_STATEDIFF_DB_HOST" echo "Statediff DB at $CERC_STATEDIFF_DB_HOST"
CERC_RUN_STATEDIFF="true" CERC_RUN_STATEDIFF="true"
else else
@@ -27,4 +27,8 @@ RUN cd /opt/testnet && make genesis-cl
# Work around some bugs in lcli where the default path is always used. # Work around some bugs in lcli where the default path is always used.
RUN mkdir -p /root/.lighthouse && cd /root/.lighthouse && ln -s /opt/testnet/build/cl/testnet RUN mkdir -p /root/.lighthouse && cd /root/.lighthouse && ln -s /opt/testnet/build/cl/testnet
RUN mkdir -p /scripts
COPY scripts/status-internal.sh /scripts
COPY scripts/status.sh /scripts
ENTRYPOINT ["/opt/testnet/run.sh"] ENTRYPOINT ["/opt/testnet/run.sh"]
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Wrapper to facilitate using status.sh inside the container
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
export LIGHTHOUSE_BASE_URL="http://fixturenet-eth-lighthouse-1:8001"
export GETH_BASE_URL="http://fixturenet-eth-geth-1:8545"
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
$SCRIPT_DIR/status.sh
@@ -1,5 +1,7 @@
#!/bin/bash #!/usr/bin/env bash
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
STATUSES=("geth to generate DAG" "beacon phase0" "beacon altair" "beacon bellatrix pre-merge" "beacon bellatrix merge") STATUSES=("geth to generate DAG" "beacon phase0" "beacon altair" "beacon bellatrix pre-merge" "beacon bellatrix merge")
STATUS=0 STATUS=0
@@ -7,6 +9,8 @@ STATUS=0
LIGHTHOUSE_BASE_URL=${LIGHTHOUSE_BASE_URL} LIGHTHOUSE_BASE_URL=${LIGHTHOUSE_BASE_URL}
GETH_BASE_URL=${GETH_BASE_URL} GETH_BASE_URL=${GETH_BASE_URL}
# TODO: Docker commands below should be replaced by some interface into stack orchestrator
# or some execution environment-neutral mechanism.
if [ -z "$LIGHTHOUSE_BASE_URL" ]; then if [ -z "$LIGHTHOUSE_BASE_URL" ]; then
LIGHTHOUSE_CONTAINER=`docker ps -q -f "name=fixturenet-eth-lighthouse-1-1"` LIGHTHOUSE_CONTAINER=`docker ps -q -f "name=fixturenet-eth-lighthouse-1-1"`
LIGHTHOUSE_PORT=`docker port $LIGHTHOUSE_CONTAINER 8001 | cut -d':' -f2` LIGHTHOUSE_PORT=`docker port $LIGHTHOUSE_CONTAINER 8001 | cut -d':' -f2`
@@ -1,6 +1,4 @@
# Use locally build foundry base image to work around there being FROM ghcr.io/foundry-rs/foundry
# no aarm64 image published.
FROM foundry-rs/foundry:local
RUN apk update ; apk add --no-cache --allow-untrusted ca-certificates curl bash git jq RUN apk update ; apk add --no-cache --allow-untrusted ca-certificates curl bash git jq
RUN apk add --no-cache --upgrade grep RUN apk add --no-cache --upgrade grep
@@ -1,4 +1,4 @@
FROM quay.io/keycloak/keycloak:20.0 FROM quay.io/keycloak/keycloak:20.0
WORKDIR /opt/keycloak/providers WORKDIR /opt/keycloak/providers
RUN curl -L https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar --output keycloak-metrics-spi.jar RUN curl -L https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar --output keycloak-metrics-spi.jar
RUN curl -L https://github.com/cerc-io/keycloak-api-key-demo/releases/download/v0.2/api-key-module-0.2.jar --output api-key-module.jar RUN curl -L https://github.com/cerc-io/keycloak-api-key-demo/releases/download/v0.3/api-key-module-0.3.jar --output api-key-module.jar
+4 -1
View File
@@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Usage: default-build.sh <image-tag> [<repo-relative-path>] # Usage: default-build.sh <image-tag> [<repo-relative-path>]
# if <repo-relative-path> is not supplied, the context is the directory where the Dockerfile lives # if <repo-relative-path> is not supplied, the context is the directory where the Dockerfile lives
if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then
set -x
fi
if [[ $# -ne 2 ]]; then if [[ $# -ne 2 ]]; then
echo "Illegal number of parameters" >&2 echo "Illegal number of parameters" >&2
exit 1 exit 1
@@ -8,4 +11,4 @@ fi
image_tag=$1 image_tag=$1
build_dir=$2 build_dir=$2
echo "Building ${image_tag} in ${build_dir}" echo "Building ${image_tag} in ${build_dir}"
docker build -t ${image_tag} ${build_dir} docker build -t ${image_tag} --build-arg CERC_HOST_UID=${CERC_HOST_UID} --build-arg CERC_HOST_GID=${CERC_HOST_GID} ${build_dir}
+1
View File
@@ -18,3 +18,4 @@ test
eth-probe eth-probe
keycloak keycloak
tx-spammer tx-spammer
kubo
+30
View File
@@ -0,0 +1,30 @@
# Build Support Stack
## Instructions
JS/TS/NPM builds need an npm registry to store intermediate package artifacts.
This can be supplied by the user (e.g. using a hosted registry or even npmjs.com), or a local registry using gitea can be deployed by stack orchestrator.
To use a user-supplied registry set these environment variables:
`CERC_NPM_REGISTRY_URL` and
`CERC_NPM_AUTH_TOKEN`
Leave `CERC_NPM_REGISTRY_URL` un-set to use the local gitea registry.
### Build support containers
```
$ laconic-so --stack build-support build-containers
```
### Deploy Gitea Package Registry
```
$ laconic-so --stack package-registry setup-repositories
$ laconic-so --stack package-registry deploy-system up
This is your gitea access token: 84fe66a73698bf11edbdccd0a338236b7d1d5c45. Keep it safe and secure, it can not be fetched again from gitea.
$ export CERC_NPM_AUTH_TOKEN=84fe66a73698bf11edbdccd0a338236b7d1d5c45
```
Now npm packages can be built:
### Build npm Packages
```
$ laconic-so build-npms --include laconic-sdk
```
+6
View File
@@ -0,0 +1,6 @@
version: "1.1"
name: build-support
decription: "Build Support Components"
containers:
- cerc/builder-js
- cerc/builder-gerbil
+4 -4
View File
@@ -7,13 +7,13 @@ Instructions to deploy a local ERC20 watcher stack (core + watcher) for demonstr
Clone required repositories: Clone required repositories:
```bash ```bash
laconic-so setup-repositories --include cerc-io/go-ethereum,cerc-io/ipld-eth-db,cerc-io/ipld-eth-server,cerc-io/watcher-ts laconic-so --stack erc20 setup-repositories
``` ```
Build the core and watcher container images: Build the core and watcher container images:
```bash ```bash
laconic-so build-containers --include cerc/go-ethereum,cerc/go-ethereum-foundry,cerc/ipld-eth-db,cerc/ipld-eth-server,cerc/watcher-erc20 laconic-so --stack erc20 build-containers
``` ```
This should create the required docker images in the local image registry. This should create the required docker images in the local image registry.
@@ -21,7 +21,7 @@ This should create the required docker images in the local image registry.
Deploy the stack: Deploy the stack:
```bash ```bash
laconic-so deploy-system --include ipld-eth-db,go-ethereum-foundry,ipld-eth-server,watcher-erc20 up laconic-so --stack erc20 deploy-system up
``` ```
## Demo ## Demo
@@ -153,5 +153,5 @@ Transfer funds between different accounts using MetaMask and use the playground
To stop all the services running in background run: To stop all the services running in background run:
```bash ```bash
laconic-so deploy-system --include ipld-eth-db,go-ethereum-foundry,ipld-eth-server,watcher-erc20 down laconic-so --stack erc20 deploy-system down
``` ```
+12 -12
View File
@@ -6,23 +6,23 @@ Instructions to deploy a local ERC721 watcher stack (core + watcher) for demonst
* Clone / pull required repositories: * Clone / pull required repositories:
```bash ```bash
$ laconic-so setup-repositories --include cerc-io/go-ethereum,cerc-io/ipld-eth-db,cerc-io/ipld-eth-server,cerc-io/watcher-ts --pull laconic-so --stack erc721 setup-repositories
``` ```
* Build the core and watcher container images: * Build the core and watcher container images:
```bash ```bash
$ laconic-so build-containers --include cerc/go-ethereum,cerc/go-ethereum-foundry,cerc/ipld-eth-db,cerc/ipld-eth-server,cerc/watcher-erc721 laconic-so --stack erc721 build-containers
``` ```
This should create the required docker images in the local image registry. This should create the required docker images in the local image registry.
* Deploy the stack: * Deploy the stack:
```bash ```bash
$ laconic-so deploy-system --include db,go-ethereum-foundry,ipld-eth-server,watcher-erc721 up laconic-so --stack erc721 deploy-system up
``` ```
## Demo ## Demo
@@ -209,6 +209,6 @@ Instructions to deploy a local ERC721 watcher stack (core + watcher) for demonst
* To stop all the services running in background: * To stop all the services running in background:
```bash ```bash
$ laconic-so deploy-system --include db,go-ethereum-foundry,ipld-eth-server,watcher-erc721 down laconic-so --stack erc721 deploy-system down
``` ```
@@ -0,0 +1,6 @@
# fixturenet-eth
A "loaded" version of fixturenet-eth, with all the bells and whistles enabled.
TODO: write me
@@ -0,0 +1,24 @@
version: "1.0"
name: fixturenet-eth-loaded
decription: "Loaded Ethereum Fixturenet"
repos:
- cerc-io/go-ethereum
- cerc-io/tx-spammer
- cerc-io/ipld-eth-server
- cerc-io/ipld-eth-db
- cerc/go-ethereum
containers:
- cerc/lighthouse
- cerc/fixturenet-eth-geth
- cerc/fixturenet-eth-lighthouse
- cerc/ipld-eth-server
- cerc/ipld-eth-db
- cerc/keycloak
- cerc/tx-spammer
pods:
- fixturenet-eth
- tx-spammer
- fixturenet-eth-metrics
- keycloak
- ipld-eth-server
- ipld-eth-db
+3 -3
View File
@@ -4,12 +4,12 @@ Instructions for deploying a local a geth + lighthouse blockchain "fixturenet" f
## Clone required repositories ## Clone required repositories
``` ```
$ laconic-so setup-repositories --include cerc-io/go-ethereum $ laconic-so --stack fixturenet-eth setup-repositories
``` ```
## Build the fixturenet-eth containers ## Build the fixturenet-eth containers
``` ```
$ laconic-so build-containers --include cerc/go-ethereum,cerc/lighthouse,cerc/fixturenet-eth-geth,cerc/fixturenet-eth-lighthouse $ laconic-so --stack fixturenet-eth build-containers
``` ```
This should create several container images in the local image registry: This should create several container images in the local image registry:
@@ -20,7 +20,7 @@ This should create several container images in the local image registry:
## Deploy the stack ## Deploy the stack
``` ```
$ laconic-so deploy-system --include fixturenet-eth up $ laconic-so --stack fixturenet-eth deploy-system up
``` ```
## Check status ## Check status
+2 -1
View File
@@ -3,10 +3,11 @@ name: fixturenet-eth
decription: "Ethereum Fixturenet" decription: "Ethereum Fixturenet"
repos: repos:
- cerc-io/go-ethereum - cerc-io/go-ethereum
- cerc-io/tx-spammer
containers: containers:
- cerc/go-ethereum - cerc/go-ethereum
- cerc/lighthouse - cerc/lighthouse
- cerc/fixturenet-eth-geth - cerc/fixturenet-eth-geth
- cerc/fixturenet-eth-lighthouse - cerc/fixturenet-eth-lighthouse
pods: pods:
- fixturenet-eth - fixturenet-eth
@@ -0,0 +1,11 @@
version: "1.1"
name: package-registry
decription: "Local Package Registry"
repos:
- cerc-io/hosting
pods:
- name: gitea
repository: cerc-io/hosting
path: gitea
pre_start_command: "run-this-first.sh"
post_start_command: "initialize-gitea.sh"
+1 -1
View File
@@ -1,2 +1,2 @@
# This file should be re-generated running: scripts/update-version-file.sh script # This file should be re-generated running: scripts/update-version-file.sh script
v1.0.14-a144dde v1.0.21-c52f9e6
+156 -43
View File
@@ -16,8 +16,11 @@
# Deploys the system components using docker-compose # Deploys the system components using docker-compose
import hashlib import hashlib
import copy
import os import os
import sys import sys
from decouple import config
import subprocess
from python_on_whales import DockerClient from python_on_whales import DockerClient
import click import click
import importlib.resources import importlib.resources
@@ -37,67 +40,47 @@ def command(ctx, include, exclude, cluster, command, extra_args):
# TODO: implement option exclusion and command value constraint lost with the move from argparse to click # TODO: implement option exclusion and command value constraint lost with the move from argparse to click
debug = ctx.obj.debug
quiet = ctx.obj.quiet quiet = ctx.obj.quiet
verbose = ctx.obj.verbose verbose = ctx.obj.verbose
local_stack = ctx.obj.local_stack
dry_run = ctx.obj.dry_run dry_run = ctx.obj.dry_run
stack = ctx.obj.stack stack = ctx.obj.stack
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure cluster_context = _make_cluster_context(ctx.obj, include, exclude, cluster)
compose_dir = Path(__file__).absolute().parent.joinpath("data", "compose")
if cluster is None:
# Create default unique, stable cluster name from confile file path
# TODO: change this to the config file path
path = os.path.realpath(sys.argv[0])
hash = hashlib.md5(path.encode()).hexdigest()
cluster = f"laconic-{hash}"
if verbose:
print(f"Using cluster name: {cluster}")
# See: https://stackoverflow.com/a/20885799/1701505
from . import data
with importlib.resources.open_text(data, "pod-list.txt") as pod_list_file:
all_pods = pod_list_file.read().splitlines()
pods_in_scope = []
if stack:
stack_config = get_parsed_stack_config(stack)
# TODO: syntax check the input here
pods_in_scope = stack_config['pods']
else:
pods_in_scope = all_pods
if verbose:
print(f"Pods: {pods_in_scope}")
# Construct a docker compose command suitable for our purpose
compose_files = []
for pod in pods_in_scope:
if include_exclude_check(pod, include, exclude):
compose_file_name = os.path.join(compose_dir, f"docker-compose-{pod}.yml")
compose_files.append(compose_file_name)
else:
if verbose:
print(f"Excluding: {pod}")
if verbose:
print(f"files: {compose_files}")
# See: https://gabrieldemarmiesse.github.io/python-on-whales/sub-commands/compose/ # See: https://gabrieldemarmiesse.github.io/python-on-whales/sub-commands/compose/
docker = DockerClient(compose_files=compose_files, compose_project_name=cluster) docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster)
extra_args_list = list(extra_args) or None extra_args_list = list(extra_args) or None
if not dry_run: if not dry_run:
if command == "up": if command == "up":
if debug:
os.environ["CERC_SCRIPT_DEBUG"] = "true"
if verbose: if verbose:
print(f"Running compose up for extra_args: {extra_args_list}") print(f"Running compose up for extra_args: {extra_args_list}")
for pre_start_command in cluster_context.pre_start_commands:
_run_command(ctx.obj, cluster_context.cluster, pre_start_command)
docker.compose.up(detach=True, services=extra_args_list) docker.compose.up(detach=True, services=extra_args_list)
for post_start_command in cluster_context.post_start_commands:
_run_command(ctx.obj, cluster_context.cluster, post_start_command)
elif command == "down": elif command == "down":
if verbose: if verbose:
print("Running compose down") print("Running compose down")
docker.compose.down() docker.compose.down()
elif command == "exec":
if extra_args_list is None or len(extra_args_list) < 2:
print("Usage: exec <service> <cmd>")
sys.exit(1)
service_name = extra_args_list[0]
command_to_exec = extra_args_list[1:]
container_exec_env = {
"CERC_SCRIPT_DEBUG": "true"
} if debug else {}
if verbose:
print(f"Running compose exec {service_name} {command_to_exec}")
docker.compose.execute(service_name, command_to_exec, envs=container_exec_env)
elif command == "port": elif command == "port":
if extra_args_list is None or len(extra_args_list) < 2: if extra_args_list is None or len(extra_args_list) < 2:
print("Usage: port <service> <exposed-port>") print("Usage: port <service> <exposed-port>")
@@ -105,7 +88,7 @@ def command(ctx, include, exclude, cluster, command, extra_args):
service_name = extra_args_list[0] service_name = extra_args_list[0]
exposed_port = extra_args_list[1] exposed_port = extra_args_list[1]
if verbose: if verbose:
print("Running compose port") print(f"Running compose port {service_name} {exposed_port}")
mapped_port_data = docker.compose.port(service_name, exposed_port) mapped_port_data = docker.compose.port(service_name, exposed_port)
print(f"{mapped_port_data[0]}:{mapped_port_data[1]}") print(f"{mapped_port_data[0]}:{mapped_port_data[1]}")
elif command == "ps": elif command == "ps":
@@ -133,3 +116,133 @@ def command(ctx, include, exclude, cluster, command, extra_args):
if verbose: if verbose:
print("Running compose logs") print("Running compose logs")
docker.compose.logs() docker.compose.logs()
def get_stack_status(ctx, stack):
ctx_copy = copy.copy(ctx)
ctx_copy.stack = stack
cluster_context = _make_cluster_context(ctx_copy, None, None, None)
docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster)
# TODO: refactor to avoid duplicating this code above
if ctx.verbose:
print("Running compose ps")
container_list = docker.compose.ps()
if len(container_list) > 0:
if ctx.debug:
print(f"Container list from compose ps: {container_list}")
return True
else:
if ctx.debug:
print("No containers found from compose ps")
False
def _make_cluster_context(ctx, include, exclude, cluster):
if ctx.local_stack:
dev_root_path = os.getcwd()[0:os.getcwd().rindex("stack-orchestrator")]
print(f'Local stack dev_root_path (CERC_REPO_BASE_DIR) overridden to: {dev_root_path}')
else:
dev_root_path = os.path.expanduser(config("CERC_REPO_BASE_DIR", default="~/cerc"))
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
compose_dir = Path(__file__).absolute().parent.joinpath("data", "compose")
if cluster is None:
# Create default unique, stable cluster name from confile file path
# TODO: change this to the config file path
path = os.path.realpath(sys.argv[0])
hash = hashlib.md5(path.encode()).hexdigest()
cluster = f"laconic-{hash}"
if ctx.verbose:
print(f"Using cluster name: {cluster}")
# See: https://stackoverflow.com/a/20885799/1701505
from . import data
with importlib.resources.open_text(data, "pod-list.txt") as pod_list_file:
all_pods = pod_list_file.read().splitlines()
pods_in_scope = []
if ctx.stack:
stack_config = get_parsed_stack_config(ctx.stack)
# TODO: syntax check the input here
pods_in_scope = stack_config['pods']
else:
pods_in_scope = all_pods
# Convert all pod definitions to v1.1 format
pods_in_scope = _convert_to_new_format(pods_in_scope)
if ctx.verbose:
print(f"Pods: {pods_in_scope}")
# Construct a docker compose command suitable for our purpose
compose_files = []
pre_start_commands = []
post_start_commands = []
for pod in pods_in_scope:
pod_name = pod["name"]
pod_repository = pod["repository"]
pod_path = pod["path"]
if include_exclude_check(pod_name, include, exclude):
if pod_repository is None or pod_repository == "internal":
compose_file_name = os.path.join(compose_dir, f"docker-compose-{pod_path}.yml")
else:
pod_root_dir = os.path.join(dev_root_path, pod_repository.split("/")[-1], pod["path"])
compose_file_name = os.path.join(pod_root_dir, "docker-compose.yml")
pod_pre_start_command = pod["pre_start_command"]
pod_post_start_command = pod["post_start_command"]
if pod_pre_start_command is not None:
pre_start_commands.append(os.path.join(pod_root_dir, pod_pre_start_command))
if pod_post_start_command is not None:
post_start_commands.append(os.path.join(pod_root_dir, pod_post_start_command))
compose_files.append(compose_file_name)
else:
if ctx.verbose:
print(f"Excluding: {pod_name}")
if ctx.verbose:
print(f"files: {compose_files}")
return cluster_context(cluster, compose_files, pre_start_commands, post_start_commands)
class cluster_context:
def __init__(self, cluster, compose_files, pre_start_commands, post_start_commands) -> None:
self.cluster = cluster
self.compose_files = compose_files
self.pre_start_commands = pre_start_commands
self.post_start_commands = post_start_commands
def _convert_to_new_format(old_pod_array):
new_pod_array = []
for old_pod in old_pod_array:
if isinstance(old_pod, dict):
new_pod_array.append(old_pod)
else:
new_pod = {
"name": old_pod,
"repository": "internal",
"path": old_pod
}
new_pod_array.append(new_pod)
return new_pod_array
def _run_command(ctx, cluster_name, command):
if ctx.verbose:
print(f"Running command: {command}")
command_dir = os.path.dirname(command)
command_file = os.path.join(".", os.path.basename(command))
command_env = os.environ.copy()
command_env["CERC_SO_COMPOSE_PROJECT"] = cluster_name
if ctx.debug:
command_env["CERC_SCRIPT_DEBUG"] = "true"
command_result = subprocess.run(command_file, shell=True, env=command_env, cwd=command_dir)
if command_result.returncode != 0:
print(f"FATAL Error running command: {command}")
sys.exit(1)
+29
View File
@@ -0,0 +1,29 @@
# Release Process
## Manually publish to github releases
In order to build, the shiv and wheel packages must be installed:
```
$ pip install shiv
$ pip install wheel
```
Then:
1. Define `CERC_GH_RELEASE_SCRIPTS_DIR`
1. Define `CERC_PACKAGE_RELEASE_GITHUB_TOKEN`
1. Run `./scripts/tag_new_release.sh <major> <minor> <patch>`
1. Run `./scripts/build_shiv_package.sh`
1. Run `./scripts/publish_shiv_package_github.sh <major> <minor> <patch>`
1. Commit the new version file.
e.g.
```
$ export CERC_GH_RELEASE_SCRIPTS_DIR=~/projects/cerc/github-release-api/
$ export CERC_PACKAGE_RELEASE_GITHUB_TOKEN=github_pat_xxxxxx
$ ./scripts/tag_new_release.sh 1 0 17
$ ./scripts/build_shiv_package.sh
$ ./scripts/publish_shiv_package_github.sh 1 0 17
```
+1 -1
View File
@@ -1,6 +1,6 @@
python-decouple>=3.6 python-decouple>=3.6
GitPython>=3.1.27 GitPython>=3.1.27
tqdm>=4.64.0 tqdm>=4.64.0
python-on-whales>=0.52.0 python-on-whales>=0.58.0
click>=8.1.3 click>=8.1.3
pyyaml>=6.0 pyyaml>=6.0
+1 -1
View File
@@ -32,7 +32,7 @@ github_release_manager.sh \
-l notused -t ${CERC_PACKAGE_RELEASE_GITHUB_TOKEN} \ -l notused -t ${CERC_PACKAGE_RELEASE_GITHUB_TOKEN} \
-o ${github_org} -r ${github_repository} \ -o ${github_org} -r ${github_repository} \
-d v${major}.${minor}.${patch} \ -d v${major}.${minor}.${patch} \
-c create -c create -m "Release v${major}.${minor}.${patch}"
github_release_manager.sh \ github_release_manager.sh \
-l notused -t ${CERC_PACKAGE_RELEASE_GITHUB_TOKEN} \ -l notused -t ${CERC_PACKAGE_RELEASE_GITHUB_TOKEN} \
-o ${github_org} -r ${github_repository} \ -o ${github_org} -r ${github_repository} \