Skip to content

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
JSHan94 committed Dec 8, 2023
1 parent fd21d92 commit 26190e4
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 26 deletions.
1 change: 1 addition & 0 deletions bots/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
7 changes: 6 additions & 1 deletion bots/.envrc_sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,4 +33,4 @@ export BATCH_SUBMITTER_MNEMONIC=''
export CHALLENGER_MNEMONIC=''

# output submitter config
export OUTPUT_SUBMITTER_MNEMONIC=''
export OUTPUT_SUBMITTER_MNEMONIC=''
4 changes: 3 additions & 1 deletion bots/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ RUN npm install

COPY . .

EXPOSE 3000
EXPOSE 5000
EXPOSE 5001

RUN ["chmod", "+x", "./entrypoint.sh"]

ENTRYPOINT [ "./entrypoint.sh" ]
5 changes: 4 additions & 1 deletion bots/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env sh

npm run apidoc
exec npm run $1

exec npm run $1

16 changes: 7 additions & 9 deletions bots/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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: '',
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -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',
Expand Down
33 changes: 19 additions & 14 deletions bots/src/scripts/setupL2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 26190e4

Please sign in to comment.