Skip to content

Commit

Permalink
fix l1_client_id cond
Browse files Browse the repository at this point in the history
  • Loading branch information
JSHan94 committed Apr 29, 2024
1 parent 44303e3 commit d99b805
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ TYPEORM_ENTITIES=dist/orm/*Entity.js # entity path
| BRIDGE_ID | Bridge ID | '' |
| EXECUTOR_PORT | Executor port | 5000 |
| EXECUTOR_MNEMONIC | Mnemonic seed for executor | '' |
| SLACK_WEB_HOOK | Slack web hook for notification (optional) | '' |
| BATCH_SUBMITTER_ADDR | Batch submitter address | '' |
| ENABLE_ORACLE | Enable Oracle | false |
| L1_CLIENT_ID | L1 client id for Oracle | '' |
| L1_CHAIN_ID | L1 chain id for Bridge Info | '' |
| EXECUTOR_L1_MONITOR_HEIGHT | L1 monitor start height (optional) | 0 |
| EXECUTOR_L2_MONITOR_HEIGHT | L2 monitor start height (optional) | 0 |
| ENABLE_API_ONLY | Enable API only mode (optional) | false |
| ENABLE_ORACLE | Enable Oracle (optional) | false |
| L1_CLIENT_ID | L1 client id for Oracle (optional) | '' |
| SLACK_WEB_HOOK | Slack web hook for notification (optional) | '' |

> Note that if `EXECUTOR_L1_MONITOR_HEIGHT` and `EXECUTOR_L2_MONITOR_HEIGHT` are not set, `executor` will start monitoring from height stored on `state` table. If you want to start monitoring from specific height, you should set them in `.env.executor` file.
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export const config = {
? CHALLENGER_MNEMONIC.replace(/'/g, '')
: '',
USE_LOG_FILE: USE_LOG_FILE ? JSON.parse(USE_LOG_FILE) : false,
L1_CHAIN_ID: L1_CHAIN_ID ? L1_CHAIN_ID : 'local-initia',
L2_CHAIN_ID: L2_CHAIN_ID ? L2_CHAIN_ID : 'local-minitia',
L1_CHAIN_ID: L1_CHAIN_ID ? L1_CHAIN_ID : '',
L2_CHAIN_ID: L2_CHAIN_ID ? L2_CHAIN_ID : '',
L1_CLIENT_ID: L1_CLIENT_ID ? L1_CLIENT_ID : '',
l1lcd: new LCDClientL1(
L1_LCD_URI ? L1_LCD_URI.split(',')[0] : 'http://127.0.0.1:1317',
Expand Down
4 changes: 3 additions & 1 deletion src/lib/monitor/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class MonitorHelper {
///

public extractErrorMessage(error: any): string {
return error.response?.data ? JSON.stringify(error.response.data) : error.toString();
return error.response?.data
? JSON.stringify(error.response.data)
: error.toString()
}

public async fetchAllEvents(
Expand Down
28 changes: 21 additions & 7 deletions src/lib/monitor/l1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ export class L1Monitor extends Monitor {
return 'executor_l1_monitor'
}

private async setBridgeInfo(bridgeInfoL1: BridgeInfo): Promise<void> {
private async setBridgeInfo(
bridgeInfoL1: BridgeInfo,
l1ClientId: string
): Promise<void> {
if (config.L1_CHAIN_ID == '') throw new Error('L1_CHAIN_ID is not set')
const l2Msgs = [
new MsgSetBridgeInfo(
this.executorL2.key.accAddress,
new BridgeInfo(
bridgeInfoL1.bridge_id,
bridgeInfoL1.bridge_addr,
config.L1_CHAIN_ID,
config.L1_CLIENT_ID,
l1ClientId,
bridgeInfoL1.bridge_config
)
)
Expand All @@ -61,16 +65,22 @@ export class L1Monitor extends Monitor {
if (
config.ENABLE_ORACLE &&
config.L1_CLIENT_ID &&
bridgeInfoL2.l1_client_id == ''
!bridgeInfoL2.l1_client_id
) {
await this.setBridgeInfo(bridgeInfoL1)
await this.setBridgeInfo(bridgeInfoL1, config.L1_CLIENT_ID)
}
} catch (err) {
const errMsg = this.helper.extractErrorMessage(err)
if (errMsg.includes('bridge info not found')) {
// not found bridge info in l2, set bridge info
await this.setBridgeInfo(bridgeInfoL1)
await this.setBridgeInfo(bridgeInfoL1, '')
}
this.logger.warn(
`
Failed to prepareMonitor in height: ${this.currentHeight}
Error: ${errMsg}
`
)
}
}

Expand Down Expand Up @@ -98,7 +108,9 @@ export class L1Monitor extends Monitor {
`
)
} catch (err) {
const errMsg = this.helper.extractErrorMessage(err)
const errMsg = err.response?.data
? JSON.stringify(err.response?.data)
: err.toString()
this.logger.warn(
`
Failed to submit tx in height: ${this.currentHeight}
Expand Down Expand Up @@ -196,7 +208,9 @@ export class L1Monitor extends Monitor {
`
)
} catch (err) {
const errMsg = this.helper.extractErrorMessage(err)
const errMsg = err.response?.data
? JSON.stringify(err.response?.data)
: err.toString()
this.logger.warn(
`
Failed to submit tx in height: ${this.currentHeight}
Expand Down

0 comments on commit d99b805

Please sign in to comment.