Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions docs/use-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ Check <https://hub.docker.com/r/nervos/perkins-tent>.

```bash
cd offchain-modules
# install node modules
yarn testnet-docker:install
# generate all configs
yarn testnet-docker:generate
# install and build force bridge inside docker
docker run --rm -v ${offchainModulePath}:/app -v force-bridge-node-modules:/app/node_modules node:14.18.1-bullseye bash -c 'cd /app && yarn build'

cd workdir/testnet-docker
docker-compose up -d
```
Expand Down
4 changes: 4 additions & 0 deletions eth-contracts/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ module.exports = {

networks: {
hardhat: {},
bsc_testnet: {
network_id: 97,
url: `https://data-seed-prebsc-1-s1.binance.org:8545`,
},
geth: {
url: `http://127.0.0.1:8545`,
// address [`0x17c4b5CE0605F63732bfd175feCe7aC6b4620FD2`, `0x46beaC96B726a51C5703f99eC787ce12793Dae11`]
Expand Down
21 changes: 21 additions & 0 deletions offchain-modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## v0.0.17 (2021-12-24)

### Features

- [bsc compatability support](https://github.com/nervosnetwork/force-bridge/pull/269)

## v0.0.16 (2021-12-20)

### Bug fixes

- [Fix version api of verifiers](https://github.com/nervosnetwork/force-bridge/pull/260)
- [Better hint of CKB insufficient error message](https://github.com/nervosnetwork/force-bridge/pull/262)

## v0.0.15 (2021-12-03)

### Features

- [CKB2021 address](https://github.com/nervosnetwork/rfcs/pull/239) format compatibility.
- Readonly mode for watchers. We can seperate the read and write nodes for watchers, thus scale the read nodes to
handle more requests.
- Cross chain assets monitor and audit.
2 changes: 1 addition & 1 deletion offchain-modules/lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.15",
"version": "0.0.17",
"workspaces": [
"packages/*"
],
Expand Down
2 changes: 1 addition & 1 deletion offchain-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"startDevDockers": "docker-compose -f ../workdir/dev-docker/docker-compose.yml up -d --scale ui=0",
"startDevDockersWithUi": "docker-compose -f ../workdir/dev-docker/docker-compose.yml up -d",
"destroyDevDockers": "docker-compose -f ../workdir/dev-docker/docker-compose.yml down",
"testnet-docker:generate": "DOTENV_PATH=../workdir/testnet-docker/.env ts-node packages/scripts/src/testnetDocker.ts",
"testnet-docker:generate": "docker run --rm -e FORCE_BRIDGE_PROJECT_DIR=$(dirname \"$(pwd)\") -v $(dirname \"$(pwd)\"):/app -v force-bridge-node-modules:/app/offchain-modules/node_modules node:14.18.1-bullseye bash -c 'cd /app/offchain-modules && DOTENV_PATH=../workdir/testnet-docker/.env npx ts-node packages/scripts/src/testnetDocker.ts'",
"testnet-docker:install": "docker run --rm -v $(pwd):/app -v force-bridge-node-modules:/app/node_modules node:14.18.1-bullseye bash -c 'cd /app && yarn build'"
},
"author": "",
Expand Down
14 changes: 7 additions & 7 deletions offchain-modules/packages/app-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@force-bridge/cli",
"main": "dist",
"version": "0.0.15",
"version": "0.0.17",
"bin": {
"forcecli": "./dist/index.js"
},
Expand All @@ -17,12 +17,12 @@
"@ckb-lumos/common-scripts": "^0.18.0-rc2",
"@ckb-lumos/hd": "^0.18.0-rc2",
"@ckb-lumos/helpers": "^0.18.0-rc2",
"@force-bridge/app-monitor": "^0.0.15",
"@force-bridge/app-multisign-server": "^0.0.15",
"@force-bridge/app-relayer": "^0.0.15",
"@force-bridge/app-rpc-server": "^0.0.15",
"@force-bridge/keystore": "^0.0.15",
"@force-bridge/x": "^0.0.15",
"@force-bridge/app-monitor": "^0.0.17",
"@force-bridge/app-multisign-server": "^0.0.17",
"@force-bridge/app-relayer": "^0.0.17",
"@force-bridge/app-rpc-server": "^0.0.17",
"@force-bridge/keystore": "^0.0.17",
"@force-bridge/x": "^0.0.17",
"@lay2/pw-core": "^0.3.22",
"@nervosnetwork/ckb-sdk-core": "^0.101.0",
"commander": "^8.1.0",
Expand Down
2 changes: 1 addition & 1 deletion offchain-modules/packages/app-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { sigCmd } from './sigServer';

export const program = commander.program;

const version = '0.0.15';
const version = '0.0.17';

async function main() {
program
Expand Down
6 changes: 3 additions & 3 deletions offchain-modules/packages/app-monitor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@force-bridge/app-monitor",
"version": "0.0.15",
"version": "0.0.17",
"main": "dist",
"scripts": {
"build": "yarn run clean && yarn run compile",
Expand All @@ -13,8 +13,8 @@
"access": "public"
},
"dependencies": {
"@force-bridge/x": "^0.0.15",
"@force-bridge/xchain-eth": "^0.0.15",
"@force-bridge/x": "^0.0.17",
"@force-bridge/xchain-eth": "^0.0.17",
"fetch-with-proxy": "^3.0.1"
}
}
4 changes: 2 additions & 2 deletions offchain-modules/packages/app-multisign-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"test": "yarn run build"
},
"dependencies": {
"@force-bridge/x": "^0.0.15"
"@force-bridge/x": "^0.0.17"
},
"publishConfig": {
"access": "public"
},
"version": "0.0.15"
"version": "0.0.17"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { signEthTx } from './ethSigner';
import { getPendingTx, getPendingTxResult } from './pendingTx';
import { serverStatus, serverStatusResult } from './status';

const version = '0.0.15';
const version = '0.0.17';
const apiPath = '/force-bridge/sign-server/api/v1';

const ethPendingTxKey = 'ethPendingTx';
Expand Down Expand Up @@ -156,7 +156,7 @@ export async function startSigServer(configPath: string): Promise<void> {

const server = new JSONRPCServer();
server.addMethod('version', () => {
return { version };
return SigResponse.fromData(version);
});
server.addMethod('signCkbTx', async (params: collectSignaturesParams) => {
try {
Expand Down
4 changes: 2 additions & 2 deletions offchain-modules/packages/app-relayer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"test": "yarn run build"
},
"dependencies": {
"@force-bridge/x": "^0.0.15"
"@force-bridge/x": "^0.0.17"
},
"publishConfig": {
"access": "public"
},
"version": "0.0.15"
"version": "0.0.17"
}
4 changes: 2 additions & 2 deletions offchain-modules/packages/app-rpc-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"test": "yarn run build"
},
"dependencies": {
"@force-bridge/x": "^0.0.15"
"@force-bridge/x": "^0.0.17"
},
"publishConfig": {
"access": "public"
},
"version": "0.0.15"
"version": "0.0.17"
}
3 changes: 1 addition & 2 deletions offchain-modules/packages/app-rpc-server/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ export class ForceBridgeAPIV1Client implements ForceBridgeAPIV1 {
}
break;
default:
//TODO add other chains
Promise.reject(new Error('not yet'));
throw new Error('only support Ethereum for now');
}
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions offchain-modules/packages/app-rpc-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { JSONRPCServer } from 'json-rpc-2.0';
import { ForceBridgeAPIV1Handler } from './handler';
import { GetBalancePayload, GetBridgeTransactionSummariesPayload, XChainNetWork } from './types/apiv1';

const version = '0.0.15';
const version = '0.0.17';
const forceBridgePath = '/force-bridge/api/v1';

export async function startRpcServer(configPath: string): Promise<void> {
Expand Down Expand Up @@ -46,7 +46,7 @@ export async function startRpcServer(configPath: string): Promise<void> {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
server.addMethod('version', () => {
return { version };
return version;
});
server.addMethod('generateBridgeOutNervosTransaction', forceBridgeRpc.generateBridgeOutNervosTransaction);
server.addMethod('generateBridgeInNervosTransaction', forceBridgeRpc.generateBridgeInNervosTransaction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export interface GetBridgeConfigResponse {
// TODO: change to the higher order generic when it impl
// https://github.com/microsoft/TypeScript/issues/1213
export interface ForceBridgeAPIV1 {
/*
// prettier-ignore
generateBridgeInNervosTransaction: <T extends NetworkTypes>(payload: GenerateBridgeInTransactionPayload) => Promise<GenerateTransactionResponse<T>>
// prettier-ignore
Expand Down
2 changes: 1 addition & 1 deletion offchain-modules/packages/ckb-indexer-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@force-bridge/ckb-indexer-client",
"version": "0.0.15",
"version": "0.0.17",
"main": "dist",
"scripts": {
"build": "yarn run clean && yarn run compile",
Expand Down
4 changes: 2 additions & 2 deletions offchain-modules/packages/internal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@force-bridge/internal",
"version": "0.0.15",
"version": "0.0.17",
"main": "dist",
"scripts": {
"build": "yarn run clean && yarn run compile",
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@force-bridge/keystore": "^0.0.15"
"@force-bridge/keystore": "^0.0.17"
}
}
2 changes: 1 addition & 1 deletion offchain-modules/packages/keystore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@force-bridge/keystore",
"version": "0.0.15",
"version": "0.0.17",
"main": "dist",
"scripts": {
"build": "yarn run clean && yarn run compile",
Expand Down
2 changes: 1 addition & 1 deletion offchain-modules/packages/reconc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@force-bridge/reconc",
"version": "0.0.15",
"version": "0.0.17",
"main": "dist",
"scripts": {
"build": "yarn run clean && yarn run compile",
Expand Down
16 changes: 8 additions & 8 deletions offchain-modules/packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
"test": "yarn run build"
},
"dependencies": {
"@force-bridge/app-monitor": "^0.0.15",
"@force-bridge/ckb-indexer-client": "^0.0.15",
"@force-bridge/internal": "^0.0.15",
"@force-bridge/keystore": "^0.0.15",
"@force-bridge/reconc": "^0.0.15",
"@force-bridge/x": "^0.0.15",
"@force-bridge/xchain-eth": "^0.0.15",
"@force-bridge/app-monitor": "^0.0.17",
"@force-bridge/ckb-indexer-client": "^0.0.17",
"@force-bridge/internal": "^0.0.17",
"@force-bridge/keystore": "^0.0.17",
"@force-bridge/reconc": "^0.0.17",
"@force-bridge/x": "^0.0.17",
"@force-bridge/xchain-eth": "^0.0.17",
"cheerio": "^1.0.0-rc.10",
"dotenv": "^10.0.0",
"mustache": "^4.2.0",
"node-fetch": "^1.7.3",
"shelljs": "^0.8.4"
},
"version": "0.0.15",
"version": "0.0.17",
"devDependencies": {
"@types/shelljs": "^0.8.9"
}
Expand Down
20 changes: 12 additions & 8 deletions offchain-modules/packages/scripts/src/testnetDocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import * as lodash from 'lodash';
import * as Mustache from 'mustache';
import { execShellCmd, PATH_PROJECT_ROOT, pathFromProjectRoot } from './utils';
import { deployDev } from './utils/deploy';
import { nonNullable } from '@force-bridge/x';

dotenv.config({ path: process.env.DOTENV_PATH || '.env' });

export interface VerifierConfig {
Expand Down Expand Up @@ -140,7 +142,7 @@ const dockerComposeTemplate = `
version: "3.3"
services:
script:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
volumes:
- ./script:/data
Expand All @@ -163,7 +165,7 @@ services:
ports:
- 3050:3306
watcher:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
environment:
FORCE_BRIDGE_KEYSTORE_PASSWORD: {{FORCE_BRIDGE_KEYSTORE_PASSWORD}}
Expand All @@ -188,7 +190,7 @@ services:
ports:
- 3059:3306
collector:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
environment:
FORCE_BRIDGE_KEYSTORE_PASSWORD: {{FORCE_BRIDGE_KEYSTORE_PASSWORD}}
Expand All @@ -214,7 +216,7 @@ services:
ports:
- {{db_port}}:3306
{{name}}:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
environment:
FORCE_BRIDGE_KEYSTORE_PASSWORD: {{FORCE_BRIDGE_KEYSTORE_PASSWORD}}
Expand All @@ -233,7 +235,7 @@ services:
- {{name}}_db
{{/verifiers}}
monitor:
image: node:14
image: node:14.18.1-bullseye
restart: on-failure
environment:
MONITOR_DURATION_CONFIG_PATH: /data/monitor.json
Expand All @@ -254,6 +256,8 @@ volumes:
async function main() {
initLog({ level: 'debug', identity: 'testnet-docker' });
// used for deploy and run service
// passed through: docker run -e FORCE_BRIDGE_PROJECT_DIR=$(dirname "$(pwd)")
nonNullable(process.env.FORCE_BRIDGE_PROJECT_DIR);
const CKB_RPC_URL = getFromEnv('CKB_RPC_URL');
const ETH_RPC_URL = getFromEnv('ETH_RPC_URL');
const CKB_INDEXER_URL = getFromEnv('CKB_INDEXER_URL');
Expand Down Expand Up @@ -293,7 +297,7 @@ async function main() {
},
eth: {
rpcUrl: ETH_RPC_URL,
confirmNumber: 12,
confirmNumber: 12, // 1 if Bsc
startBlockHeight: 1,
batchUnlock: {
batchNumber: 100,
Expand All @@ -305,7 +309,7 @@ async function main() {
ckbIndexerUrl: CKB_INDEXER_URL,
startBlockHeight: 1,
confirmNumber: 15,
sudtSize: 150,
sudtSize: 400,
},
};

Expand Down Expand Up @@ -354,7 +358,7 @@ async function main() {
await execShellCmd(`mkdir -p ${path.join(configPath, 'script')}`);
const dockerComposeFile = Mustache.render(dockerComposeTemplate, {
FORCE_BRIDGE_KEYSTORE_PASSWORD,
projectDir: PATH_PROJECT_ROOT,
projectDir: process.env.FORCE_BRIDGE_PROJECT_DIR,
verifiers,
});
fs.writeFileSync(path.join(configPath, 'docker-compose.yml'), dockerComposeFile);
Expand Down
10 changes: 5 additions & 5 deletions offchain-modules/packages/x/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@force-bridge/x",
"version": "0.0.15",
"version": "0.0.17",
"main": "./dist/index.js",
"license": "MIT",
"scripts": {
Expand All @@ -21,10 +21,10 @@
"@ckb-lumos/helpers": "^0.18.0-rc2",
"@ckb-lumos/rpc": "^0.18.0-rc2",
"@ckb-lumos/transaction-manager": "^0.18.0-rc2",
"@force-bridge/ckb-indexer-client": "^0.0.15",
"@force-bridge/internal": "^0.0.15",
"@force-bridge/keystore": "^0.0.15",
"@force-bridge/reconc": "^0.0.15",
"@force-bridge/ckb-indexer-client": "^0.0.17",
"@force-bridge/internal": "^0.0.17",
"@force-bridge/keystore": "^0.0.17",
"@force-bridge/reconc": "^0.0.17",
"@lay2/pw-core": "^0.3.22",
"@nervosnetwork/ckb-sdk-core": "^0.101.0",
"@nervosnetwork/ckb-sdk-utils": "^0.101.0",
Expand Down
Loading