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

Docker Image #593

Merged
merged 1 commit into from
Jun 14, 2021
Merged

Docker Image #593

merged 1 commit into from
Jun 14, 2021

Conversation

jacque006
Copy link
Collaborator

@jacque006 jacque006 commented May 25, 2021

Resolves #561

TODO

  • Get Docker image to start up
  • Build and push in CI/CD as parallel pipeline
  • Setup Docker Hub
  • Flesh out docker-compose file as example
  • Docs! ./docker/README.md

@jacque006 jacque006 added the client This PR is about implementing the client label May 25, 2021
@github-actions github-actions bot removed the client This PR is about implementing the client label May 25, 2021
docker/Dockerfile Outdated Show resolved Hide resolved
@jacque006 jacque006 force-pushed the feature/docker-image branch 3 times, most recently from 016f456 to 6a02f8d Compare June 11, 2021 00:56
@jacque006 jacque006 marked this pull request as ready for review June 11, 2021 00:57
Comment on lines +1 to +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 }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Won't be able to test this until we tag next release.

SETUP.md Outdated
Comment on lines 1 to 160
+ uint32 public constant BLOCKS_PER_SLOT = 10;
+ uint32 public constant DELTA_BLOCKS_INITIAL_SLOT = 20;

// donation numerator and demoninator are used to calculate donation amount
uint256 public constant DONATION_DENOMINATOR = 10000;


```

### generate

Compiles [Solidity](https://soliditylang.org/) contracts and [TypeChain](https://github.com/ethereum-ts/Typechain) [TypeScript](https://www.typescriptlang.org/) bindings.
```sh
npm run generate
```

### deploy

```
npm run deploy -- \
--key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--root 0xbfef011dd64abe7707cee7b3b74a00b86689c8451f548371073ce3c935e09984 \
--numPubkeys 32
```

This should generate a `genesis.json` file that looks like:

```json
{
"parameters": {
"MAX_DEPTH": 32,
"MAX_DEPOSIT_SUBTREE_DEPTH": 2,
"STAKE_AMOUNT": "100000000000000000",
"BLOCKS_TO_FINALISE": 40320,
"MIN_GAS_LEFT": 10000,
"MAX_TXS_PER_COMMIT": 32,
"USE_BURN_AUCTION": true,
"DONATION_ADDRESS": "0x00000000000000000000000000000000000000d0",
"DONATION_NUMERATOR": 7500,
"GENESIS_STATE_ROOT": "0xbfef011dd64abe7707cee7b3b74a00b86689c8451f548371073ce3c935e09984"
},
"addresses": {
"frontendGeneric": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
"frontendTransfer": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707",
"frontendMassMigration": "0x0165878A594ca255338adfa4d48449f69242Eb8F",
"frontendCreate2Transfer": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
"blsAccountRegistry": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
"tokenRegistry": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788",
"transfer": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0",
"massMigration": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
"create2Transfer": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
"burnAuction": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
"exampleToken": "0x9A676e781A523b5d0C0e43731313A708CB607508",
"spokeRegistry": "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE",
"vault": "0x68B1D87F95878fE05B998F19b66F4baba5De1aed",
"depositManager": "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c",
"rollup": "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d",
"withdrawManager": "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44"
},
"auxiliary": {
"domain": "0x4ea7799478a7af2a47ba555f04aec4ae4ba240bf410d7c859c34c310f0413892",
"genesisEth1Block": 306,
"version": "20539ad4d99b3d3e4810de24c14ba41cdd89ea2c"
}
}
```

The client will be parameterized using this file.

## Run Client (Node)

```sh
npx ts-node ./scripts/simulate.ts --proposer
```

### repl (Hubble console)

```sh
npm run repl
```

Then in repl console, run a transfer:

```sh
hubble.transfer(0, 1, 1, 1)
```

## Run Tests

Note: Full test suite run currently fails due to test state leak

```sh
npm run test
```

### fast/slow/client

```sh
npm run test -- test/fast/* # slow/client/etc.
```
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ChihChengLiang This is primarily based off setup instructions you gave me for onboarding, figured it would be useful for others as well :)

SETUP.md Outdated Show resolved Hide resolved
Comment on lines +1 to +34
import { ContractTransaction } from "ethers";
import { assert, expect } from "chai";

export async function expectRevert(
tx: Promise<ContractTransaction>,
revertReason: string
) {
await tx.then(
() => {
assert.fail(`Expect tx to fail with reason: ${revertReason}`);
},
error => {
expect(error.message).to.have.string(revertReason);
}
);
}

export async function expectCallRevert(
tx: Promise<any>,
revertReason: string | null
) {
await tx.then(
() => {
assert.fail(`Expect tx to fail with reason: ${revertReason}`);
},
error => {
if (revertReason === null) {
assert.isNull(error.reason);
} else {
expect(error.reason).to.have.string(revertReason);
}
}
);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This properly separates out test/npm devDeps from prod ones for production Node.js assets.

@jacque006
Copy link
Collaborator Author

jacque006 commented Jun 11, 2021

@jacque006
Copy link
Collaborator Author

@jacque006
Copy link
Collaborator Author

image

master: https://github.com/thehubbleproject/hubble-contracts/actions/runs/926988149
feature/docker-image aka The New CI Hotness: https://github.com/thehubbleproject/hubble-contracts/actions/runs/926988149

CI time for Node.js reduced by 9m 6s, ~53% vs. master

@jacque006 jacque006 force-pushed the feature/docker-image branch 2 times, most recently from df9386c to d2a4fc3 Compare June 14, 2021 15:24
Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

LGTM. Have a comment on docker instruction, other looks good.

docker/README.md Show resolved Hide resolved
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.
@jacque006 jacque006 merged commit ee2e05e into master Jun 14, 2021
@jacque006 jacque006 deleted the feature/docker-image branch June 14, 2021 18:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Container (Docker) Image
2 participants