Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdesu committed Jan 23, 2025
2 parents 03eaf30 + f026df3 commit 5f81975
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Env: mainnet

CellDeps:
# index-state-cell-type
- outPoint: { txHash: '0x5e7a84fc58274e95dad82364e89d5062fe8085ed54a7ea246f60b6e5dac3e545', index: '0x0' }
- outPoint: { txHash: '0xae3197c306c0d0b36722773cff7dafcc8e312154826f876cec4bd94d24dc61b3', index: '0x0' }
depType: 'code'
# info-cell-type
- outPoint: { txHash: '0x46d1665b650d75462ace68638c57d513f331f5456d6d9cd9c4b7f965d4bd884f', index: '0x0' }
- outPoint: { txHash: '0x3ba4c4b6cb70fd332d0159fa1c2ce021b361b7ccfe1acf2c44ad4902b1c905a5', index: '0x0' }
depType: 'code'
# ckb signall lock
- outPoint: { txHash: '0x71a7ba8fc96349fea0ed3a5c47992e3b4084b031a42264a018e0072e8172e46c', index: '0x0' }
Expand Down
2 changes: 2 additions & 0 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ export const EXCHANGES: Exchange[] = [
new ascendex({ agent }),
new kucoin({ agent })
]

export const UNKNOWN_OUT_POINT_REG = /Unknown\(OutPoint\((0x[0-9a-fA-F]+)\)\)/
28 changes: 26 additions & 2 deletions src/controller/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Logger } from 'winston'
import EventEmitter from 'events'

import config from '../config.js'
import { SinceFlag, SUM_OF_INFO_CELLS, TIME_1_M, TIME_30_S, TIME_5_S, THEORETIC_BLOCK_1_M } from '../const.js'
import { SinceFlag, SUM_OF_INFO_CELLS, TIME_1_M, TIME_30_S, TIME_5_S, THEORETIC_BLOCK_1_M, UNKNOWN_OUT_POINT_REG } from '../const.js'
import { rootLogger } from '../log.js'
import {
collectInputs,
Expand Down Expand Up @@ -281,9 +281,22 @@ export async function updateController (argv: Arguments<{ type: string }>) {
// These error are caused by cell occupation, could retry automatically.
logger.info(`Update cell failed, but can be ignored safely.(${data.code}: ${data.message})`, { cell_data: cellData, tx_hash: txHash, waited_blocks: waitedBlocks })
return
case -301:
case -301: {
// Suppress the occupation error

// But if the occupated cell is a cell_dep, the config need to be updated manually.
const match = UNKNOWN_OUT_POINT_REG.exec(data.message)
if (match.length > 0) {
txHash = match[1].slice(0, 66)
config.CellDeps.forEach((dep) => {
if (dep.outPoint.txHash === txHash) {
logger.error(`Cell_dep[${dep.outPoint.txHash}-${dep.outPoint.index}] has been spent, the config need to be updated manually.`, { cell_data: cellData, tx_hash: txHash, waited_blocks: waitedBlocks })
}
})
}

return
}
case -1111:
// Suppress the RBF rejection error
return
Expand Down Expand Up @@ -387,6 +400,17 @@ class Server extends EventEmitter {
this.logger.debug(`Received new block[${BigInt(result.number)}]`)

const status = this.eventStatus

const now = Date.now()
if (status.history.length > 0 &&now - status.history[status.history.length - 1].receivedAt < 5000) {
// Ignore the message if it is received too frequently, this is a common case when the node is syncing.
return;
}
status.history.push({ receivedAt: now })
if (status.history.length > 10) {
status.history.shift()
}

clearTimeout(status.checkTipHeight_notify)
clearTimeout(status.checkTipHeight_warn)

Expand Down

0 comments on commit 5f81975

Please sign in to comment.