From 26190e4fc30042186150b0be31a1ec730d4d8373 Mon Sep 17 00:00:00 2001 From: JSHan94 Date: Fri, 8 Dec 2023 16:45:52 +0900 Subject: [PATCH] update dockerfile --- bots/.dockerignore | 1 + bots/.envrc_sample | 7 ++++++- bots/dockerfile | 4 +++- bots/entrypoint.sh | 5 ++++- bots/src/config.ts | 16 +++++++--------- bots/src/scripts/setupL2.ts | 33 +++++++++++++++++++-------------- 6 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 bots/.dockerignore diff --git a/bots/.dockerignore b/bots/.dockerignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/bots/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/bots/.envrc_sample b/bots/.envrc_sample index 1ee2372d..41a2a02c 100644 --- a/bots/.envrc_sample +++ b/bots/.envrc_sample @@ -12,6 +12,11 @@ export USE_LOG_FILE=false export EXECUTOR_PORT=5000 export BATCH_PORT=5001 +# l2 setup (need challenger, output, executor mnemonic) +export SUBMISSION_INTERVAL=10000 +export FINALIZED_TIME=10000 +export IBC_METADATA='channel-1' + export L1_LCD_URI=http://localhost:1317 export L1_RPC_URI=http://localhost:26657 export L2_LCD_URI=http://localhost:1318 @@ -28,4 +33,4 @@ export BATCH_SUBMITTER_MNEMONIC='' export CHALLENGER_MNEMONIC='' # output submitter config -export OUTPUT_SUBMITTER_MNEMONIC='' +export OUTPUT_SUBMITTER_MNEMONIC='' \ No newline at end of file diff --git a/bots/dockerfile b/bots/dockerfile index 37687032..08c5489c 100644 --- a/bots/dockerfile +++ b/bots/dockerfile @@ -7,7 +7,9 @@ RUN npm install COPY . . -EXPOSE 3000 +EXPOSE 5000 +EXPOSE 5001 RUN ["chmod", "+x", "./entrypoint.sh"] + ENTRYPOINT [ "./entrypoint.sh" ] \ No newline at end of file diff --git a/bots/entrypoint.sh b/bots/entrypoint.sh index f69cb841..a6543ade 100644 --- a/bots/entrypoint.sh +++ b/bots/entrypoint.sh @@ -1,3 +1,6 @@ #!/usr/bin/env sh + npm run apidoc -exec npm run $1 \ No newline at end of file + +exec npm run $1 + diff --git a/bots/src/config.ts b/bots/src/config.ts index 9474f12c..0f74ea1e 100644 --- a/bots/src/config.ts +++ b/bots/src/config.ts @@ -13,7 +13,6 @@ interface ConfigInterface { EXECUTOR_MNEMONIC: string; BATCH_SUBMITTER_MNEMONIC: string; CHALLENGER_MNEMONIC: string; - EXECUTOR_ADDR: string; USE_LOG_FILE: boolean; l1lcd: LCDClient; l2lcd: LCDClient; @@ -30,7 +29,6 @@ const defaultConfig = { EXECUTOR_URI: 'https://minitia-executor.initia.tech', BRIDGE_ID: '', OUTPUT_SUBMITTER_MNEMONIC: '', - EXECUTOR_ADDR: '', EXECUTOR_MNEMONIC: '', BATCH_SUBMITTER_MNEMONIC: '', CHALLENGER_MNEMONIC: '', @@ -49,7 +47,6 @@ export class Config implements ConfigInterface { EXECUTOR_URI: string; BRIDGE_ID: number; OUTPUT_SUBMITTER_MNEMONIC: string; - EXECUTOR_ADDR: string; EXECUTOR_MNEMONIC: string; BATCH_SUBMITTER_MNEMONIC: string; CHALLENGER_MNEMONIC: string; @@ -69,7 +66,6 @@ export class Config implements ConfigInterface { EXECUTOR_URI, BRIDGE_ID, OUTPUT_SUBMITTER_MNEMONIC, - EXECUTOR_ADDR, EXECUTOR_MNEMONIC, BATCH_SUBMITTER_MNEMONIC, CHALLENGER_MNEMONIC, @@ -84,11 +80,13 @@ export class Config implements ConfigInterface { this.L2_RPC_URI = L2_RPC_URI.split(','); this.EXECUTOR_URI = EXECUTOR_URI; this.BRIDGE_ID = parseInt(BRIDGE_ID); - this.OUTPUT_SUBMITTER_MNEMONIC = OUTPUT_SUBMITTER_MNEMONIC; - this.EXECUTOR_ADDR = EXECUTOR_ADDR; - this.EXECUTOR_MNEMONIC = EXECUTOR_MNEMONIC; - this.BATCH_SUBMITTER_MNEMONIC = BATCH_SUBMITTER_MNEMONIC; - this.CHALLENGER_MNEMONIC = CHALLENGER_MNEMONIC; + this.OUTPUT_SUBMITTER_MNEMONIC = OUTPUT_SUBMITTER_MNEMONIC.replace( + /'/g, + '' + ); + this.EXECUTOR_MNEMONIC = EXECUTOR_MNEMONIC.replace(/'/g, ''); + this.BATCH_SUBMITTER_MNEMONIC = BATCH_SUBMITTER_MNEMONIC.replace(/'/g, ''); + this.CHALLENGER_MNEMONIC = CHALLENGER_MNEMONIC.replace(/'/g, ''); this.USE_LOG_FILE = !!JSON.parse(USE_LOG_FILE); this.l1lcd = new LCDClient(this.L1_LCD_URI[0], { gasPrices: '0.15uinit', diff --git a/bots/src/scripts/setupL2.ts b/bots/src/scripts/setupL2.ts index 3b6b6a1c..1091f667 100644 --- a/bots/src/scripts/setupL2.ts +++ b/bots/src/scripts/setupL2.ts @@ -4,9 +4,9 @@ import { getConfig } from 'config'; import { executor, challenger, outputSubmitter } from 'test/utils/helper'; const config = getConfig(); -const SUBMISSION_INTERVAL = 3600; // 1 hour -const FINALIZED_TIME = 3600; // 1 hour -const IBC_METADATA = 'channel-2'; // ibc channel name +const SUBMISSION_INTERVAL = parseInt(process.env.SUBMISSION_INTERVAL ?? '3600'); +const FINALIZED_TIME = parseInt(process.env.SUBMISSION_INTERVAL ?? '3600'); +const IBC_METADATA = process.env.IBC_METADATA ?? ''; // ibc channel name class L2Initializer { l2id = config.BRIDGE_ID; @@ -39,17 +39,22 @@ class L2Initializer { } async function main() { - const initializer = new L2Initializer( - SUBMISSION_INTERVAL, - FINALIZED_TIME, - IBC_METADATA - ); - console.log('=========Initializing L2========='); - console.log('submissionInterval: ', initializer.submissionInterval); - console.log('finalizedTime: ', initializer.finalizedTime); - console.log('metadata: ', initializer.metadata); - await initializer.initialize(); - console.log('=========L2 Initialized Done========='); + try { + const initializer = new L2Initializer( + SUBMISSION_INTERVAL, + FINALIZED_TIME, + IBC_METADATA + ); + console.log('=========Initializing L2========='); + console.log('submissionInterval: ', initializer.submissionInterval); + console.log('finalizedTime: ', initializer.finalizedTime); + console.log('metadata: ', initializer.metadata); + + await initializer.initialize(); + console.log('=========L2 Initialized Done========='); + } catch (e) { + console.error(e); + } } if (require.main === module) {