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

Commit df8c8c3

Browse files
authored
Merge pull request #636 from thehubbleproject/feature/fee-receiver-script
Token & FeeRecievers Scripts
2 parents 1cbc59d + 2c591ea commit df8c8c3

19 files changed

+604
-55
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ Users can onboard accounts to Hubble without going through L1. The coordinator c
4141

4242
## Local Development
4343

44-
See [Setup](./SETUP.md) instructions
44+
[Local Development Setup](./docs/setup/LOCAL_DEVELOPMENT.md)
45+
46+
## Node Operator
47+
48+
[Node Operator](./docs/setup/NODE_OPERATOR.md)
4549

4650
## Docker
4751

File renamed without changes.

docs/setup/NODE_OPERATOR.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Setup for Node Operators
2+
3+
## Deps
4+
5+
- [NodeJS](https://nodejs.org/en/download/)
6+
- (Recommended instead of NodeJS) [nvm](https://github.com/nvm-sh/nvm#installing-and-updating)
7+
8+
### install & generate
9+
10+
```sh
11+
npm ci && npm run generate
12+
```
13+
14+
## Deploy a new Hubble network
15+
16+
Skip if you're going to join an existing network
17+
18+
```sh
19+
# See ./scripts/deploy.ts for additional options
20+
npm run deploy -- \
21+
--url https://your.eth.provider:8545 \
22+
--key PRIVATE_KEY_HEX
23+
```
24+
25+
## Setup fee recievers
26+
27+
Skip if you only need a syncing node.
28+
29+
This script will register your public key and setup the states where your proposer will recieve fees when active.
30+
31+
Note that a proposer will need to be active on the hubble network you are joining in order to to create (pack) the new states/deposits. You may also need to create additional deposits (using the contract `DepositManager.sol:depositFor`) so that the proposer has enough deposits to pack.
32+
33+
```sh
34+
# See ./scripts/feeReceivers.ts for additional options
35+
npm run feeReceivers -- \
36+
--url https://your.eth.provider:8545 \
37+
--key PRIVATE_KEY_HEX
38+
--genesisPath ./genesis.json
39+
--configPath ./your-node-config.json
40+
```
41+
42+
## Run node
43+
44+
```
45+
npm run node -- --configPath ./your-node-config.json
46+
```
47+
48+
## Docker/container
49+
50+
TODO

package-lock.json

Lines changed: 51 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"description": "",
55
"scripts": {
6+
"node": "ts-node --files ./ts/client",
67
"dev": "ts-node --files ./ts/client --configPath config.local.json",
78
"repl": "ts-node --files ./scripts/repl.ts",
89
"test": "hardhat test",
@@ -12,8 +13,9 @@
1213
"generate": "hardhat compile && typechain --target ethers-v5 './artifacts/contracts/**/!(*.dbg).json'",
1314
"compile": "hardhat compile",
1415
"tsc": "tsc",
15-
"node": "hardhat node",
16+
"hardhat:node": "hardhat node",
1617
"deploy": "ts-node --files ./scripts/deploy.ts",
18+
"feeReceivers": "ts-node --files ./scripts/feeReceivers.ts",
1719
"keyless:check": "ts-node --files ./scripts/keyless.ts --check",
1820
"keyless:deploy": "ts-node --files ./scripts/keyless.ts --deploy",
1921
"deposit": "ts-node --files ./scripts/deposit.ts",
@@ -57,7 +59,7 @@
5759
"dependencies": {
5860
"@godaddy/terminus": "^4.9.0",
5961
"bn.js": "^5.2.0",
60-
"ethers": "5.4.0",
62+
"ethers": "5.4.3",
6163
"fastify": "^3.18.0",
6264
"level": "^7.0.0",
6365
"lodash": "^4.17.21",

scripts/deploy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { ethers } from "ethers";
22
import minimist from "minimist";
33
import { deployAndWriteGenesis } from "../ts/deploy";
44
import { DeploymentParameters } from "../ts/interfaces";
5-
import fs from "fs";
65
import { PRODUCTION_PARAMS } from "../ts/constants";
76
import { StateTree } from "../ts/stateTree";
87
import { Group } from "../ts/factory";
8+
import * as mcl from "../ts/mcl";
9+
import { readJSON } from "../ts/file";
910

1011
const { url, root, key, input, output, numPubkeys, pubkeyMnemonic } = minimist(
1112
process.argv.slice(2),
@@ -54,6 +55,7 @@ function getDefaultGenesisRoot(parameters: DeploymentParameters) {
5455

5556
async function main() {
5657
validateArgv();
58+
await mcl.init();
5759

5860
const provider = new ethers.providers.JsonRpcProvider(
5961
url ?? "http://localhost:8545"
@@ -62,9 +64,7 @@ async function main() {
6264
? new ethers.Wallet(key).connect(provider)
6365
: provider.getSigner();
6466

65-
const parameters = input
66-
? JSON.parse(fs.readFileSync(input).toString())
67-
: PRODUCTION_PARAMS;
67+
const parameters = input ? await readJSON(input) : PRODUCTION_PARAMS;
6868

6969
parameters.GENESIS_STATE_ROOT = root || getDefaultGenesisRoot(parameters);
7070
console.log("Deploy with parameters", parameters);

0 commit comments

Comments
 (0)