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

Feature bull devnet #36

Closed
wants to merge 7 commits into from
Closed
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: 4 additions & 1 deletion .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ PARENTNET_URL=https://devnetstats.apothem.network/devnet

CHECKPOINT_CONTRACT=0x16da2C7caf46D0d7270d68e590A992A90DfcF7ee

SUBNET_ZERO_CONTRACT=0x0000000
PARENTNET_WALLET_PK=0x123

# XDC-ZERO. It's optional. Don't add it if not planning to enable it
SUBNET_ZERO_CONTRACT=0x0000000
PARENTNET_ZERO_CONTRACT=0x0000000

PARENTNET_WALLET_PK=0x123

PARENTNET_ZERO_WALLET_PK=0x123

# Notification
SLACK_WEBHOOK=https://hooks.slack.com/services/blablabla
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.12.1
20.10.0
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ COPY package*.json ./
RUN npm install
RUN npm run build

RUN apk --update add redis
RUN npm install -g concurrently

EXPOSE 3000

CMD [ "npm", "run", "start" ]
CMD concurrently "/usr/bin/redis-server --bind '0.0.0.0'" "sleep 5s; npm run start"
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"homepage": "https://github.com/XinFinOrg/XDC-Relayer#readme",
"repository": "https://github.com/XinFinOrg/XDC-Relayer",
"devDependencies": {
"@types/bull": "^4.10.0",
"@types/bunyan": "^1.8.8",
"@types/cron": "^1.7.2",
"@types/jest": "^29.4.0",
Expand All @@ -31,6 +32,7 @@
"@types/koa__router": "^8.0.4",
"@types/koa-bodyparser": "^4.3.0",
"@types/koa-helmet": "^6.0.2",
"@types/lodash": "^4.14.202",
"@types/node": "^18.14.1",
"@types/node-fetch": "^2.6.9",
"@typescript-eslint/eslint-plugin": "^6.7.0",
Expand All @@ -50,12 +52,14 @@
"@koa/router": "^10.0.0",
"agentkeepalive": "^4.3.0",
"axios": "^1.3.4",
"bull": "^4.11.5",
"bunyan": "^1.8.15",
"cron": "^1.8.2",
"dotenv": "^8.2.0",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"koa-helmet": "^6.1.0",
"lodash": "^4.17.21",
"node-cache": "^5.1.2",
"node-fetch": "2",
"patch-package": "^6.5.1",
Expand Down
27 changes: 27 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,52 @@ export interface NotificationConfig {
};
}

export interface XdcZeroConfig {
isEnabled: boolean;
subnetZeroContractAddress?: string;
parentChainZeroContractAddress?: string;
walletPk?: string;
}

export interface Config {
port: number;
devMode: boolean;
cronJob: {
liteJobExpression: string;
jobExpression: string;
zeroJobExpression: string;
};
subnet: SubnetConfig;
mainnet: MainnetConfig;
reBootstrapWaitingTime: number;
notification: NotificationConfig;
chunkSize: number;
xdcZero: XdcZeroConfig;
relayerCsc: {
isEnabled: boolean;
}
}

const environment = process.env.NODE_ENV || "production";
export const devMode = environment != "production";

const getZeroConfig = (): XdcZeroConfig => {
const isEnabled: boolean = "PARENTNET_ZERO_WALLET_PK" in process.env && "SUBNET_ZERO_CONTRACT" in process.env && "PARENTNET_ZERO_CONTRACT" in process.env;
return isEnabled ? {
isEnabled,
subnetZeroContractAddress: process.env.SUBNET_ZERO_CONTRACT,
parentChainZeroContractAddress: process.env.PARENTNET_ZERO_CONTRACT,
walletPk: process.env.PARENTNET_ZERO_WALLET_PK.startsWith("0x") ? process.env.PARENTNET_ZERO_WALLET_PK : `0x${process.env.PARENTNET_ZERO_WALLET_PK}`
}: { isEnabled: false };
};

const config: Config = {
port: +(process.env.PORT || 3000),
devMode: devMode,
cronJob: {
liteJobExpression: "0 */2 * * * *", // every 2min
jobExpression: "*/20 * * * * *", // every 20s
zeroJobExpression: "*/10 * * * * *", // every 10s
},
subnet: {
url: process.env.SUBNET_URL || "https://devnetstats.apothem.network/subnet",
Expand All @@ -57,6 +80,10 @@ const config: Config = {
"0xa6538b992365dd26bbc2391ae6639bac0ed8599f8b45bca7c28c105959f02af4", // Default to a dummy key
submitTransactionWaitingTime: +process.env.MN_TX_SUBMIT_WAITING_TIME || 100,
},
relayerCsc: {
isEnabled: "PARENTNET_WALLET_PK" in process.env && "CHECKPOINT_CONTRACT" in process.env && "PARENTNET_URL" in process.env
},
xdcZero: getZeroConfig(),
reBootstrapWaitingTime: +process.env.BOOTSTRAP_FAILURE_WAIT_TIME || 120000,
notification: {
slack: process.env.SLACK_WEBHOOK
Expand Down
Loading