Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyperspace #17

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c040888
add hyperspace config
lalexgap Feb 27, 2023
25e0bd7
update simple hub
lalexgap Feb 27, 2023
e193ded
update start script to handle hyperspace
lalexgap Feb 27, 2023
c73a67f
update bignumberify to work with latest ethers
lalexgap Feb 27, 2023
25d92a9
update ethers and our local state channel packages
lalexgap Feb 27, 2023
6b7896f
disable chain id check for now
lalexgap Feb 27, 2023
e5a5239
initialize hub comms after our wallet is enabled
lalexgap Feb 27, 2023
3735171
remove preinstall
lalexgap Feb 27, 2023
c04d838
fix weird import error
lalexgap Feb 27, 2023
225fc92
check in lockfile
geoknee Feb 27, 2023
c71b6d9
use BigNumber.from() instead of utils.Bignumberify
geoknee Feb 27, 2023
9df989d
use "0x00" instead ofutils.zeroPad('0x0', 20)
geoknee Feb 27, 2023
b390c4f
Merge pull request #18 from statechannels/hyperspace-george-fixes
lalexgap Feb 27, 2023
10e0c1e
remove extra init
lalexgap Feb 27, 2023
a9c8f6f
add prod env vars
lalexgap Feb 27, 2023
7b3edb8
update to hyperspace provider
lalexgap Feb 27, 2023
ab6ac9b
get simple-hub deploying
lalexgap Feb 27, 2023
d2ad248
use heroku url for tracker
lalexgap Feb 27, 2023
54d68d5
update to TFIL denoms
lalexgap Feb 28, 2023
4900f2b
remove <p> tag
geoknee Feb 28, 2023
18903ac
networkChanged => chainChanged
geoknee Feb 28, 2023
f12b52d
patch @statechannels/iframe-channel-provider
geoknee Feb 28, 2023
24dd17b
Merge pull request #20 from statechannels/quirks
geoknee Feb 28, 2023
f175f87
Merge pull request #21 from statechannels/patch-iframe-provider
geoknee Feb 28, 2023
dc157ff
remove chatlio
lalexgap Feb 28, 2023
db33d67
update persistent seeder for hyperspace
lalexgap Feb 28, 2023
ec10b66
yarn.lock update
lalexgap Feb 28, 2023
49636dd
try longer yarn timeout for persistent seeder
lalexgap Feb 28, 2023
5831974
update FAQ link
geoknee Mar 2, 2023
cde6e74
Merge pull request #22 from statechannels/faq-link
geoknee Mar 2, 2023
198f6c3
Ethererum -> Hyperspace
Mar 3, 2023
30118cb
channels -> channel
Mar 3, 2023
ae88126
ETH -> tFIL
Mar 3, 2023
0010d4a
add link to chainlist hyperspace wallet connection
Mar 3, 2023
6ecb0eb
update to new firebase
lalexgap Mar 3, 2023
a52d905
Merge pull request #24 from statechannels/cmk.ethereum-to-hyperspace
NiloCK Mar 3, 2023
2df122b
make prettier happy
geoknee Mar 3, 2023
8d91103
Merge pull request #25 from statechannels/prettier
geoknee Mar 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .env.local-hyperspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## all
NODE_ENV = 'production'
LOG_DESTINATION = 'console'
LOG_LEVEL = 'info'
# e2e-tests
BROWSER_LOG_DESTINATION = 'browser.log'
HEADLESS = 'false'
USE_DAPPETEER = 'true'
WEB3TORRENT_URL = 'http://localhost:3000'
CLOSE_BROWSERS = 'true'

## web3torrent, xstate-wallet, rps, simple-hub
CHAIN_NETWORK_ID = '3141'

## simple-hub, e2e
INFURA_API_KEY = ''
RPC_ENDPOINT = https://api.hyperspace.node.glif.io/rpc/v1

## simple-hub, rps
FIREBASE_API_KEY = 'AIzaSyAOvhDzJir_El3O6SJ2xQlrpOisnObq6zw'
FIREBASE_PREFIX = 'netlify-hyperspace'
FIREBASE_PROJECT = 'web3torrent-default-rtdb'

## rps, xstate-wallet, ttt
TARGET_NETWORK = 'hyperspace'

## web3torrent, rps, ttt
WALLET_URL = 'http://localhost:3055'

## simple-hub, xstate-wallet
CONSENSUS_APP_ADDRESS = '0xeB1170bf49fac482fA296C98Ac04024e8a2d6519'

NITRO_ADJUDICATOR_ADDRESS = '0xaA512d99EC808FBf49b1e6491A251f2E75f913Ad'
ETH_ASSET_HOLDER_ADDRESS = '0x6abaBB7e642C794264DAa2a1477B48521AaE1553'

TRIVIAL_APP_ADDRESS = '0x95900b17Bd2CE12431C99A886FfDC5a451C14344'

## simple-hub
FIREBASE_URL = https://${FIREBASE_PROJECT}.firebaseio.com/
# This is a funded address on goerli for the hub. This is NOT the production address/key
HUB_CHAIN_PK = '0xBB72BD0824663E0B52FA3523ACED0F866550BBC1FD600D7F2DA9C45CAC509AE7'
HUB_PARTICIPANT_ID = 'firebase:simple-hub'

## xstate-wallet
# This is a funded address on goerli for the hub. This is NOT the production address/key
HUB_DESTINATION = '0x000000000000000000000000c4FB59b7fb0D8001Bda6DEA539117664573006c9'
USE_INDEXED_DB = 'true'

## web3torrent
FUNDING_STRATEGY = 'Virtual'
SINGLE_ASSET_PAYMENT_CONTRACT_ADDRESS = '0x4964f1aE3Ca9Ea0a1e7EF873a379768dBc74F034'
SKIP_PREFLIGHT_CHECK = 'true'
TRACKER_URL = 'localhost:8000'
TRACKER_URL_HTTP_PROTOCOL = 'http'
GENERATE_SOURCEMAP = 'true'

## rps
RPS_CONTRACT_ADDRESS = '0x'

## web3torrent-tracker
TRACKER_PORT = 80

## ttt
TTT_CONTRACT_ADDRESS = '0x'
FIREBASE_PROJECT_TTT = 'tic-tac-toe-production'


ADD_LOGS = true
68 changes: 68 additions & 0 deletions .env.production-hyperspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## all
NODE_ENV = 'production'
LOG_DESTINATION = 'console'
LOG_LEVEL = 'info'
# e2e-tests
BROWSER_LOG_DESTINATION = 'browser.log'
HEADLESS = 'false'
USE_DAPPETEER = 'true'
WEB3TORRENT_URL = 'https://hyperspace-torrent.statechannels.org'
CLOSE_BROWSERS = 'true'

## web3torrent, xstate-wallet, rps, simple-hub
CHAIN_NETWORK_ID = '3141'

## simple-hub, e2e
INFURA_API_KEY = ''
RPC_ENDPOINT = https://api.hyperspace.node.glif.io/rpc/v1

## simple-hub, rps
FIREBASE_API_KEY = 'AIzaSyAOvhDzJir_El3O6SJ2xQlrpOisnObq6zw'
FIREBASE_PREFIX = 'netlify-hyperspace'
FIREBASE_PROJECT = 'web3torrent-default-rtdb'

## rps, xstate-wallet, ttt
TARGET_NETWORK = 'hyperspace'

## web3torrent, rps, ttt
WALLET_URL = 'https://hyperspace-wallet.statechannels.org/'

## simple-hub, xstate-wallet
CONSENSUS_APP_ADDRESS = '0xeB1170bf49fac482fA296C98Ac04024e8a2d6519'

NITRO_ADJUDICATOR_ADDRESS = '0xaA512d99EC808FBf49b1e6491A251f2E75f913Ad'
ETH_ASSET_HOLDER_ADDRESS = '0x6abaBB7e642C794264DAa2a1477B48521AaE1553'

TRIVIAL_APP_ADDRESS = '0x95900b17Bd2CE12431C99A886FfDC5a451C14344'

## simple-hub
FIREBASE_URL = https://${FIREBASE_PROJECT}.firebaseio.com/
# This is a funded address on goerli for the hub. This is NOT the production address/key
HUB_CHAIN_PK = '0xBB72BD0824663E0B52FA3523ACED0F866550BBC1FD600D7F2DA9C45CAC509AE7'
HUB_PARTICIPANT_ID = 'firebase:simple-hub'

## xstate-wallet
# This is a funded address on goerli for the hub. This is NOT the production address/key
HUB_DESTINATION = '0x000000000000000000000000c4FB59b7fb0D8001Bda6DEA539117664573006c9'
USE_INDEXED_DB = 'true'

## web3torrent
FUNDING_STRATEGY = 'Virtual'
SINGLE_ASSET_PAYMENT_CONTRACT_ADDRESS = '0x4964f1aE3Ca9Ea0a1e7EF873a379768dBc74F034'
SKIP_PREFLIGHT_CHECK = 'true'
TRACKER_URL = 'web3torrent-tracker-hyperspace.herokuapp.com'
TRACKER_URL_HTTP_PROTOCOL = 'https'
GENERATE_SOURCEMAP = 'true'

## rps
RPS_CONTRACT_ADDRESS = '0x'

## web3torrent-tracker
TRACKER_PORT = 80

## ttt
TTT_CONTRACT_ADDRESS = '0x'
FIREBASE_PROJECT_TTT = 'tic-tac-toe-production'


ADD_LOGS = true
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"lint:check": "lerna run lint:check --no-sort --no-bail -- --max-warnings=0",
"lint:write": "lerna run lint:write --no-sort --no-bail",
"postinstall": "patch-package",
"preinstall": "npx typesync",
"prepare": "lerna run --concurrency 8 --stream prepare",
"publish": "lerna publish --yes from-package patch",
"release:netlify": "lerna run release:netlify --stream -- --auth $NETLIFY_ACCESS_TOKEN --message $(git rev-parse --short HEAD) $([ $(git rev-parse --abbrev-ref HEAD) = master ] && echo --prod)",
Expand Down
6 changes: 3 additions & 3 deletions packages/persistent-seeder/build-push-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -euf -o pipefail
BASEDIR=$(dirname "$0")

# MAIN SCRIPT
docker build -t registry.heroku.com/persistent-seeder-production/persistent-seeder -f persistent-seeder.dockerfile "$BASEDIR"/../../..
docker push registry.heroku.com/persistent-seeder-production/persistent-seeder
heroku container:release -a persistent-seeder-staging persistent-seeder
docker build -t registry.heroku.com/persistent-seeder-hyperspace/persistent-seeder -f persistent-seeder.dockerfile "$BASEDIR"/../..
docker push registry.heroku.com/persistent-seeder-hyperspace/persistent-seeder
heroku container:release -a persistent-seeder-hyperspace persistent-seeder
2 changes: 1 addition & 1 deletion packages/persistent-seeder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"scripts": {
"lint:check": "eslint \"**/*.ts\" --cache",
"lint:write": "eslint \"**/*.ts\" --fix",
"start": "SC_ENV=persistent-seeder ts-node ./persistent-seeder.ts"
"start": "SC_ENV=production-hyperspace ts-node ./persistent-seeder.ts"
}
}
14 changes: 6 additions & 8 deletions packages/persistent-seeder/persistent-seeder.dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
FROM circleci/node:12.16.3-browsers
USER root
ENV DISPLAY :99.0

ENV SC_ENV=production-hyperspace
RUN apt-get install -y xvfb libudev-dev

WORKDIR /statechannels/monorepo
WORKDIR /statechannels/apps

# Copy the necessary packages
COPY .env.* ./
COPY *.json ./
COPY yarn.lock ./
COPY ./packages/devtools packages/devtools/
COPY ./packages/persistent-seeder/ packages/persistent-seeder/
COPY ./packages/channel-provider packages/channel-provider/
COPY ./packages/client-api-schema packages/client-api-schema/

COPY ./packages/e2e-tests packages/e2e-tests/

# Add non-root, set permissions, switch user
RUN useradd --create-home --no-log-init --shell /bin/bash seeder
RUN chown -R seeder: /statechannels/monorepo
RUN chown -R seeder: /statechannels/apps
USER seeder

# Install dependencies
RUN yarn
RUN yarn --network-timeout 100000

WORKDIR /statechannels/monorepo/packages/persistent-seeder
WORKDIR /statechannels/apps/packages/persistent-seeder

COPY ./packages/persistent-seeder/entrypoint.sh /entrypoint.sh

Expand Down
6 changes: 3 additions & 3 deletions packages/simple-hub/docker/build-push-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set -euf -o pipefail
BASEDIR=$(dirname "$0")

docker build -t registry.heroku.com/simple-hub-production/simple-hub -f "$BASEDIR"/simple-hub.dockerfile "$BASEDIR"/../../..
docker push registry.heroku.com/simple-hub-production/simple-hub
heroku container:release -a simple-hub-production simple-hub
docker build -t registry.heroku.com/simple-hub-hyperspace/simple-hub -f "$BASEDIR"/simple-hub.dockerfile "$BASEDIR"/../../..
docker push registry.heroku.com/simple-hub-hyperspace/simple-hub
heroku container:release -a simple-hub-hyperspace simple-hub
38 changes: 12 additions & 26 deletions packages/simple-hub/docker/simple-hub.dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,23 @@
FROM counterfactual/statechannels:0.5.13
FROM --platform=linux/amd64 node:12.16.3
ENV SC_ENV=production-hyperspace
ENV NODE_ENV=production
WORKDIR /statechannels/apps

WORKDIR /statechannels/monorepo
# TODO: This can be narrowed down to just the simple-hub package and it's dependencies
COPY . /statechannels/apps/

# ASSUMPTIONS
#
# - That ./packages/simple-hub has been built, so a lib directory exists
# - That ./packages/nitro-protocol has been built, so the .json artifacts exist
# - That ./packages/wire-format has been built, so a lib directory exists

# INSTALL DEPENDENCIES
COPY ./package.json /statechannels/monorepo/
COPY ./packages/nitro-protocol/package.json packages/nitro-protocol/
COPY ./packages/simple-hub/package.json packages/simple-hub/
COPY ./packages/wire-format/package.json packages/wire-format/

# Remove the devtools and jest-gas-reporter devDependencies from package.json files (avoid resolution)
RUN sed -ie "/@statechannels\/devtools/d" package.json
RUN sed -ie "/@statechannels\/jest-gas-reporter/d" package.json
RUN sed -ie "/@statechannels\/devtools/d" **/*/package.json
RUN sed -ie "/@statechannels\/jest-gas-reporter/d" **/*/package.json

# Install production dependencies for simple-hub
COPY ./yarn.lock /statechannels/monorepo/
RUN yarn --production --prefer-offline
RUN yarn global add typescript ts-node
RUN yarn



# COPY SOURCE
WORKDIR /statechannels/monorepo
COPY .env.* ./
COPY ./packages/nitro-protocol/ packages/nitro-protocol/
COPY ./packages/simple-hub/ packages/simple-hub/
COPY ./packages/wire-format/ packages/wire-format/

WORKDIR /statechannels/monorepo/packages/simple-hub
WORKDIR /statechannels/apps/packages/simple-hub
RUN yarn build

# docker-entrypoint.sh starts a shell that execs the list of arguments in CMD
# This works around the following heroku constraint:
Expand Down
2 changes: 1 addition & 1 deletion packages/simple-hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"async-lock": "1.2.2",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"ethers": "5.0.0-beta.191",
"ethers": "5.5.0",
"firebase": "7.11.0",
"fp-ts": "2.5.3",
"lodash": "4.17.19",
Expand Down
11 changes: 5 additions & 6 deletions packages/simple-hub/src/blockchain/eth-asset-holder.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import AsyncLock from 'async-lock';
import {Contract, ContractFactory, ethers, providers, BigNumber, utils} from 'ethers';
import {Contract, ContractFactory, ethers, providers, BigNumber} from 'ethers';
import {ContractArtifacts} from '@statechannels/nitro-protocol';
import {cHubChainPK, cHubChainDestination} from '../constants';
import {log} from '../logger';
import {NonceManager} from '@ethersproject/experimental';
import {TransactionResponse} from '@ethersproject/providers';
import * as Sentry from '@sentry/node';

const rpcEndpoint = process.env.RPC_ENDPOINT;
const provider = new providers.JsonRpcProvider(rpcEndpoint);
const walletWithProvider = new ethers.Wallet(cHubChainPK, provider);
const nonceManager = new NonceManager(walletWithProvider);

let ethAssetHolder: Contract = null;

const lock = new AsyncLock();
Expand Down Expand Up @@ -41,6 +40,7 @@ async function fund(channelID: string, value: BigNumber): Promise<void> {
}

await lock.acquire(channelID, async () => {
console.log('SANITYTYUASDAS');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️

const expectedHeld: BigNumber = await ethAssetHolder.holdings(channelID);
if (expectedHeld.gte(value)) {
return;
Expand All @@ -58,7 +58,6 @@ async function fund(channelID: string, value: BigNumber): Promise<void> {
expectedHeld.toHexString(),
value,
{
gasPrice: utils.parseUnits('15', 'gwei'),
value: value.sub(expectedHeld)
}
);
Expand All @@ -78,7 +77,7 @@ async function createEthAssetHolder() {
try {
ethAssetHolderFactory = await ContractFactory.fromSolidity(
ContractArtifacts.EthAssetHolderArtifact,
nonceManager
walletWithProvider
);
} catch (err) {
if (err.message.match('bytecode must be a valid hex string')) {
Expand All @@ -94,7 +93,7 @@ async function createEthAssetHolder() {
{ETH_ASSET_HOLDER_ADDRESS: process.env.ETH_ASSET_HOLDER_ADDRESS},
'Connected to eth asset holder'
);

console.log(contract);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️

return contract;
}

Expand Down
6 changes: 5 additions & 1 deletion packages/simple-hub/start-dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {startServer} from './src/server';
import {log} from './src/logger';

async function setupGanacheAndContracts() {
if (getNetworkName(process.env.CHAIN_NETWORK_ID) === 'development') {
// TODO: Devtools doesn't support hyperspace yet so we manually hav e to check for it
if (
getNetworkName(process.env.CHAIN_NETWORK_ID || 0) === 'development' &&
Number(process.env.CHAIN_NETWORK_ID) !== 3141
) {
const {deployer} = await setupGanache(Number(process.env.SIMPLE_HUB_DEPLOYER_ACCOUNT_INDEX));
const deployedArtifacts = await deploy(deployer);

Expand Down
6 changes: 3 additions & 3 deletions packages/web3torrent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
"@material-ui/icons": "4.9.1",
"@rimble/connection-banner": "1.2.3",
"@sentry/browser": "5.15.5",
"@statechannels/channel-client": "0.0.6",
"@statechannels/channel-client": "0.3.0",
"@statechannels/devtools": "0.1.4",
"@statechannels/iframe-channel-provider": "0.3.0-hyperspace-patch-0",
"@svgr/webpack": "4.3.2",
"@typescript-eslint/eslint-plugin": "2.18.0",
"@typescript-eslint/parser": "2.18.0",
Expand All @@ -36,7 +37,7 @@
"css-loader": "3.4.2",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
"ethers": "4.0.45",
"ethers": "5.5.0",
"eventemitter3": "4.0.0",
"file-loader": "5.0.2",
"firebase": "7.11.0",
Expand Down Expand Up @@ -84,7 +85,6 @@
"workbox-webpack-plugin": "5.0.0"
},
"devDependencies": {
"@statechannels/channel-provider": "0.0.5",
"@storybook/addon-actions": "5.3.9",
"@storybook/addon-knobs": "5.2.5",
"@storybook/addon-notes": "5.2.5",
Expand Down
Loading