Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
Add Docker image of Hubble node.
Browse files Browse the repository at this point in the history
Add alpine based Dockerfile to build production-ready version of Hubble node.
Setup Docker CI pipelines for build/push and tagging images with releases.
Paralellize Node.js testing steps to decrease CI run time.
Move minimist to prod npm deps, use import instead of require.
Move chai/testing utils to seperate util file.
Add proper error catching to a number of scripts.
Update README, add Docker README. Add local dev setup instructions.
  • Loading branch information
jacque006 committed Jun 14, 2021
1 parent d40d508 commit df9386c
Show file tree
Hide file tree
Showing 25 changed files with 525 additions and 104 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
39 changes: 39 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Docker CI Release

on:
release:
types: [published]

env:
DOCKER_IMAGE: thehubbleproject/node
DOCKER_IMAGE_SHA: ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
DOCKER_IMAGE_TAG: ${{ env.DOCKER_IMAGE }}:${{ github.event.release.tag_name }}
DOCKER_IMAGE_LATEST: ${{ env.DOCKER_IMAGE }}:latest

jobs:
pull-tag-push:
runs-on: ubuntu-latest
needs: images

steps:
- uses: actions/checkout@v2
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Pull image for git sha
run: docker pull ${{ env.DOCKER_IMAGE_SHA }}
-
name: Tag image with release
run: docker tag ${{ env.DOCKER_IMAGE_SHA }} ${{ env.DOCKER_IMAGE_TAG }}
-
name: Tag image with latest
if: ${{ github.event.release.prerelease == 'false' }}
run: docker tag ${{ env.DOCKER_IMAGE_SHA }} ${{ env.DOCKER_IMAGE_LATEST }}
-
name: Push tagged image(s)
# Pushing the image name without a tag will push all new tags.
run: docker push ${{ env.DOCKER_IMAGE }}
43 changes: 43 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
DOCKER_IMAGE: thehubbleproject/node

jobs:
build-push:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push git sha
id: docker_build
uses: docker/build-push-action@v2
with:
file: docker/Dockerfile
push: true
tags: ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
# Consider using GitHub local cache in the future
# https://docs.docker.com/ci-cd/github-actions/#optimizing-the-workflow
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}:latest
cache-to: type=inline
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
60 changes: 46 additions & 14 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,74 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

# TODO On master/release, test all valid NodeJS versions
# https://github.com/thehubbleproject/hubble-contracts/issues/567
#
# strategy:
# matrix:
# node-version: [10.x, 12.x, 14.x, 16.x]

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master, develop ]
branches: [ master ]

jobs:
build:
env:
NODEJS_VERSION: 10.x

jobs:
lint-bench:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
-
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

node-version: ${{ env.NODEJS_VERSION }}
- run: npm ci
- run: npm run lint && npm run solhint

- run: npm run lint
- run: npm run solhint
- run: npm run generate
- run: npm run keyless:check -- --offline
- run: npm run bench

test-fast-client:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
-
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODEJS_VERSION }}
- run: npm ci

- run: npm run generate
- run: npm run test -- test/fast/*
- run: npm run test -- test/client/*

test-slow-integration:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
-
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODEJS_VERSION }}
- run: npm ci

- run: npm run generate
- run: npm run test -- test/slow/*
- run: npm run test -- test/integration.test.ts
- run: npm run bench

cloc:
needs: build
needs: [lint-bench, test-fast-client, test-slow-integration]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ types/ethers-contracts/
cache/
artifacts/
build/
docker/testData
52 changes: 29 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
# Hubble Optimistic Rollup Contracts
# Hubble Optimistic Rollup Contracts & NodeJS TypeScript Client (Node)

![Node.js CI](https://github.com/thehubbleproject/RedditHubble/workflows/Node.js%20CI/badge.svg)

## About Hubble

Hubble is a token transfer solution to improve Ethereum throughput from 20 transactions per second to 2600.
Hubble is an [ERC-20](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/) token transfer solution that improves Ethereum throughput from 20 transactions per second to ~2700.

### How it work
### How it works

People sumit transfers to a coordinator, who then submits transactions and the state root of the balances update to a Ethereum contract.
Accounts submit transfers to a coordinator node who then submits transactions and the state root of the balance updates to an Ethereum smart contract ([Rollup.sol](./contracts/rollup/Rollup.sol)).

### Why can that improve the throughput
### How does this improve throughput?

The contract does not validate either the correctness of the balances update or the authenticity of the sender.
The contract does not validate either the correctness of the balance updates or the authenticity of the sender.

### What if the coordinator submit incorrect balances update?
### What if the coordinator submits incorrect balance updates?

Anyone can trigger the dispute methods of the contract and penalize the coordinator by burning the assets they staked beforehand. The contract rolls back to the last state when the balance was correct.
Anyone can trigger the dispute methods of the contract and penalize the coordinator by burning the assets they staked beforehand. The contract rolls back to the last state when the balances were correct.

### How is it different from these projects
### How is it different from other Layer 2 (L2) Ethereum projects?

- Optimism: Hubble does not support virtual machine, ... yet.
- ZK rollups: Both improve throughput but Hubble is ZK free. No zero-knowledge moon math, only boring EVM at work.
- [Optimism](https://optimism.io/): Hubble does not support the EVM virtual machine, ... yet.
- [ZK (zero knowledge proof) rollups](https://docs.ethhub.io/ethereum-roadmap/layer-2-scaling/zk-rollups/): Both improve throughput but Hubble is ZK free. No zero-knowledge moon math, only boring EVM at work.
- ZK optimistic rollups: Hubble does not address privacy.

Hubble has the highest throughput compared with all above applications, since
Hubble has the highest throughput compared with the above, since:

- We use BLS signature aggregation to reduce the size to store data on chain
- We optimize for simple transfer
- Hubble use BLS signature aggregation to reduce the size to store data on chain.
- We optimize for simple token transfers.

### What else can Hubble do

- Mass Migration: Users can migrate their tokens to other layer 2 solutions without withdraw to and deposit from layer 1 again.
- Create2Transfer: Users can onboard Hubble without going through layer 1. The coordinator can register pubkeys for them and they can acquire tokens from holders who are already in Hubble.
#### Mass Migration

Users can migrate their tokens to other L2 solutions without withdrawing to and depositing from Layer 1 (L1) again.

## Getting Started
#### Create2Transfer

```sh
npm install
npm run generate
```
Users can onboard accounts to Hubble without going through L1. The coordinator can register their public keys and then they can acquire tokens from holders who are already in the Hubble L2.

## Local Development

## Testing
See [Setup](./SETUP.md) instructions

## Docker

https://hub.docker.com/r/thehubbleproject/node

```sh
npm run test
docker pull thehubbleproject/node:latest
# or for a specific release, ...:v0.x.y
```

See [Docker](./docker/README.md) instructions.
Loading

0 comments on commit df9386c

Please sign in to comment.