Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
✨ init a bunch of ops
Browse files Browse the repository at this point in the history
  • Loading branch information
bohendo committed Sep 8, 2020
1 parent 7966785 commit 7364c68
Show file tree
Hide file tree
Showing 36 changed files with 2,251 additions and 119 deletions.
168 changes: 65 additions & 103 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,66 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache
# Build Output
**/*.0x
**/.flags
**/_build/**
**/artifacts/**
**/build/**
**/dist/**
**/node_modules/**
**/tsconfig.tsbuildinfo
*.docker-compose.yml
docker-compose.yml
modules/*/package-lock.json

# Cache
**/.bot-store
**/.buidler
**/.cache
**/.config
**/.connext-store/**
**/.git
**/.jest.cache
**/.local
**/.node-gyp
**/.npm
**/.pyEnv
**/.rpt2_cache
**/.test-store
**/cache/**

# Data Storage
**/.bot-store/
**/.chaindata
**/.db-snapshots

# Docs
modules/client/docs

# IDEs and editors
**/*.launch
**/*.sublime-workspace
**/*.sw[opq]
**/.c9/
**/.classpath
**/.idea
**/.project
**/.settings/
**/.vscode

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
# Logs
**/*.*_backup
**/*.log
**/*.patch
cypress/screenshots
cypress/videos

# OS
**/.bash_history
**/.DS_Store

# Sensitive Data
**/.env
**/react-app-env.d.ts
.secret

# Local address book
address-book.json
136 changes: 136 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@

SHELL=/bin/bash # shell make will use to execute commands
VPATH=.flags # prerequisite search path
$(shell mkdir -p $(VPATH))

########################################
# Run shell commands to fetch info from environment

root=$(shell cd "$(shell dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
project=$(shell cat $(root)/package.json | grep '"name":' | head -n 1 | cut -d '"' -f 4)
commit=$(shell git rev-parse HEAD | head -c 8)

# If Linux, give the container our uid & gid so we know what to reset permissions to. If Mac, the docker-VM takes care of this for us so pass root's id (ie noop)
id=$(shell if [[ "`uname`" == "Darwin" ]]; then echo 0:0; else echo "`id -u`:`id -g`"; fi)

# Pool of images to pull cached layers from during docker build steps
image_cache=$(shell if [[ -n "${GITHUB_WORKFLOW}" ]]; then echo "--cache-from=$(project)_builder:latest,$(project)_database:latest,$(project)_ethprovider:latest,$(project)_node:latest,$(project)_proxy:latest"; else echo ""; fi)

interactive=$(shell if [[ -t 0 && -t 2 ]]; then echo "--interactive"; else echo ""; fi)

########################################
# Setup more vars

find_options=-type f -not -path "*/node_modules/*" -not -name "address-book.json" -not -name "*.swp" -not -path "*/.*" -not -path "*/cache/*" -not -path "*/build/*" -not -path "*/dist/*" -not -name "*.log"

docker_run=docker run --name=$(project)_builder $(interactive) --tty --rm --volume=$(root):/root $(project)_builder $(id)

startTime=.flags/.startTime
totalTime=.flags/.totalTime
log_start=@echo "=============";echo "[Makefile] => Start building $@"; date "+%s" > $(startTime)
log_finish=@echo $$((`date "+%s"` - `cat $(startTime)`)) > $(totalTime); rm $(startTime); echo "[Makefile] => Finished building $@ in `cat $(totalTime)` seconds";echo "=============";echo

########################################
# Build Shortcuts

default: indra
indra: database proxy node
extras: ethprovider
all: indra extras

########################################
# Command & Control Shortcuts

start: indra
bash ops/start-indra.sh

start-testnet: ethprovider
INDRA_CHAIN_LOG_LEVEL=1 bash ops/start-testnet.sh

stop:
bash ops/stop.sh indra

stop-all:
bash ops/stop.sh indra
bash ops/stop.sh testnet

clean: stop-all
docker container prune -f
rm -rf .flags/*
rm -rf node_modules/@connext modules/*/node_modules/@connext
rm -rf node_modules/@walletconnect modules/*/node_modules/@walletconnect
rm -rf modules/*/node_modules/*/.git
rm -rf modules/*/node_modules/.bin
rm -rf modules/*/build modules/*/dist
rm -rf modules/*/.*cache* modules/*/node_modules/.cache modules/contracts/cache/*.json
rm -rf modules/*/package-lock.json

reset: stop-all
docker container prune -f
docker network rm $(project) 2> /dev/null || true
docker secret rm $(project)_database_dev 2> /dev/null || true
docker volume rm $(project)_database_dev 2> /dev/null || true
docker volume rm `docker volume ls -q -f name=$(project)_database_test_*` 2> /dev/null || true

purge: clean reset

dls:
@docker service ls
@echo "====="
@docker container ls -a

########################################
# Begin Real Build Rules

# All rules from here on should only depend on rules that come before it
# ie first no dependencies, last no dependents

########################################
# Common Prerequisites

builder: $(shell find ops/builder)
$(log_start)
docker build --file ops/builder/Dockerfile $(image_cache) --tag $(project)_builder ops/builder
docker tag ${project}_builder ${project}_builder:$(commit)
$(log_finish) && mv -f $(totalTime) .flags/$@

node-modules: builder package.json $(shell ls modules/*/package.json)
$(log_start)
$(docker_run) "lerna bootstrap --hoist --no-progress"
$(log_finish) && mv -f $(totalTime) .flags/$@

########################################
# Build Core JS libs & bundles
# Keep prerequisites synced w the @connext/* dependencies of each module's package.json

isomorphic-node: node-modules $(shell find modules/isomorphic-node $(find_options))
$(log_start)
$(docker_run) "cd modules/isomorphic-node && npm run build"
$(log_finish) && mv -f $(totalTime) .flags/$@

########################################
# Build Docker Images

database: $(shell find ops/database $(find_options))
$(log_start)
docker build --file ops/database/Dockerfile $(image_cache) --tag $(project)_database ops/database
docker tag $(project)_database $(project)_database:$(commit)
$(log_finish) && mv -f $(totalTime) .flags/$@

ethprovider:
$(log_start)
@#docker build --file ops/ethprovider/Dockerfile $(image_cache) --tag $(project)_ethprovider ops/ethprovider
@#docker tag $(project)_ethprovider $(project)_ethprovider:$(commit)
$(log_finish) && mv -f $(totalTime) .flags/$@

node: isomorphic-node $(shell find modules/isomorphic-node/ops $(find_options))
$(log_start)
docker build --file modules/isomorphic-node/ops/Dockerfile $(image_cache) --tag $(project)_node modules/isomorphic-node
docker tag $(project)_node $(project)_node:$(commit)
$(log_finish) && mv -f $(totalTime) .flags/$@

proxy: $(shell find ops/proxy $(find_options))
$(log_start)
docker build $(image_cache) --tag $(project)_proxy ops/proxy
docker tag $(project)_proxy $(project)_proxy:$(commit)
$(log_finish) && mv -f $(totalTime) .flags/$@
6 changes: 3 additions & 3 deletions modules/contracts/Multisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pragma solidity ^0.6.4;
pragma experimental ABIEncoderV2;

import "../../shared/libs/LibCommitment.sol";
import "../../shared/libs/LibChannelCrypto.sol";
import "../shared/LibCommitment.sol";
import "../shared/LibChannelCrypto.sol";


/// @title Multisig - A channel multisig
Expand Down Expand Up @@ -62,7 +62,7 @@ contract Multisig is LibCommitment {

}

/// @notice Execute an n-of-n signed transaction specified by a (to, value, data, op) tuple
/// @notice Execute an n-of-n signed transaction specified by a (to, value, data, op) tuple
/// This transaction is a message CALL
/// @param to The destination address of the message call
/// @param value The amount of ETH being forwarded in the message call
Expand Down
19 changes: 19 additions & 0 deletions modules/contracts/shared/LibChannelCrypto.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.4;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/cryptography/ECDSA.sol";

library LibChannelCrypto {
function verifyChannelMessage(bytes32 hash, bytes memory signature) internal pure returns (address) {
bytes32 digest = toChannelSignedMessage(hash);
return ECDSA.recover(digest, signature);
}

function toChannelSignedMessage(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x15Indra Signed Message:\n32", hash));
}
}
18 changes: 18 additions & 0 deletions modules/contracts/shared/LibCommitment.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.4;
pragma experimental ABIEncoderV2;


/// @title LibCommitment
/// @notice Contains stuff that's useful for commitments
contract LibCommitment {

// An ID for each commitment type
enum CommitmentTarget {
MULTISIG,
SET_STATE,
CANCEL_DISPUTE
}

}
6 changes: 0 additions & 6 deletions modules/engine/package-lock.json

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

10 changes: 10 additions & 0 deletions modules/isomorphic-node/ops/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:12.16.0-alpine3.10
WORKDIR /root
ENV HOME /root
RUN apk add --update --no-cache bash curl g++ gcc git jq make python
RUN npm config set unsafe-perm true && npm install -g [email protected]
RUN curl https://raw.githubusercontent.com/vishnubob/wait-for-it/ed77b63706ea721766a62ff22d3a251d8b4a6a30/wait-for-it.sh > /bin/wait-for && chmod +x /bin/wait-for
RUN npm install pg sqlite3
COPY ops ops
COPY dist dist
ENTRYPOINT ["bash", "ops/entry.sh"]
Loading

0 comments on commit 7364c68

Please sign in to comment.