Skip to content

Commit 1d6b52a

Browse files
Prettier'd
1 parent e1eba55 commit 1d6b52a

225 files changed

Lines changed: 10074 additions & 10118 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scripts/compare-problematic-cache.js

Lines changed: 498 additions & 484 deletions
Large diffs are not rendered by default.

scripts/monitor-cycle-consistency.js

Lines changed: 648 additions & 645 deletions
Large diffs are not rendered by default.

src/debug/debug.ts

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,23 @@ class Debug {
151151
this.network.registerExternalGet('debug_problematicNodeCacheExport', isDebugModeMiddleware, (_, res) => {
152152
try {
153153
const cacheData = ProblemNodeHandler.exportProblematicNodeCache()
154-
154+
155155
if (!cacheData) {
156-
res.json({
157-
success: false,
158-
error: 'Problematic node cache is not enabled or not available. Ensure enableProblematicNodeCacheBuilding is true.'
156+
res.json({
157+
success: false,
158+
error:
159+
'Problematic node cache is not enabled or not available. Ensure enableProblematicNodeCacheBuilding is true.',
159160
})
160161
return
161162
}
162163

163-
res.json({
164-
success: true,
164+
res.json({
165+
success: true,
165166
data: {
166167
compressed: true,
167168
cache: cacheData,
168-
timestamp: Date.now()
169-
}
169+
timestamp: Date.now(),
170+
},
170171
})
171172
} catch (e) {
172173
res.json({ success: false, error: e.message })
@@ -177,32 +178,39 @@ class Debug {
177178
// Check if we have a current cycle
178179
const currentCycleRecord = CycleChain.newest
179180
if (!currentCycleRecord) {
180-
res.json({
181-
success: false,
182-
error: 'No current cycle available'
181+
res.json({
182+
success: false,
183+
error: 'No current cycle available',
183184
})
184185
return
185186
}
186187

187188
// Get problematic nodes using the standard method
188189
const problematicNodeIds = ProblemNodeHandler.getProblematicNodes(currentCycleRecord)
189-
190+
190191
// Get detailed info for each problematic node
191-
const problematicNodesInfo = problematicNodeIds.map(nodeId => {
192-
const node = NodeList.nodes.get(nodeId)
193-
if (!node) return null
194-
195-
return {
196-
id: nodeId.substring(0, 8),
197-
fullId: nodeId,
198-
refuteCycles: node.refuteCycles || [],
199-
consecutiveRefutes: ProblemNodeHandler.getConsecutiveRefutes(node.refuteCycles || [], currentCycleRecord.counter),
200-
refutePercentage: (ProblemNodeHandler.getRefutePercentage(node.refuteCycles || [], currentCycleRecord.counter) * 100).toFixed(1)
201-
}
202-
}).filter(n => n !== null)
192+
const problematicNodesInfo = problematicNodeIds
193+
.map((nodeId) => {
194+
const node = NodeList.nodes.get(nodeId)
195+
if (!node) return null
196+
197+
return {
198+
id: nodeId.substring(0, 8),
199+
fullId: nodeId,
200+
refuteCycles: node.refuteCycles || [],
201+
consecutiveRefutes: ProblemNodeHandler.getConsecutiveRefutes(
202+
node.refuteCycles || [],
203+
currentCycleRecord.counter
204+
),
205+
refutePercentage: (
206+
ProblemNodeHandler.getRefutePercentage(node.refuteCycles || [], currentCycleRecord.counter) * 100
207+
).toFixed(1),
208+
}
209+
})
210+
.filter((n) => n !== null)
203211

204-
res.json({
205-
success: true,
212+
res.json({
213+
success: true,
206214
data: {
207215
currentCycle: currentCycleRecord.counter,
208216
totalActiveNodes: NodeList.activeByIdOrder.length,
@@ -212,9 +220,9 @@ class Debug {
212220
thresholds: {
213221
consecutiveRefutes: config.p2p.problematicNodeConsecutiveRefuteThreshold,
214222
refutePercentage: config.p2p.problematicNodeRefutePercentageThreshold,
215-
historyLength: config.p2p.problematicNodeHistoryLength
216-
}
217-
}
223+
historyLength: config.p2p.problematicNodeHistoryLength,
224+
},
225+
},
218226
})
219227
} catch (e) {
220228
res.json({ success: false, error: e.message })
@@ -257,23 +265,23 @@ class Debug {
257265
Context.config.debug.slowResponseChance = 0
258266
Context.config.debug.slowResponseDelay = 0
259267
}
260-
268+
261269
// Also reset network delay if it was set
262270
if (this.network.setDebugNetworkDelay) {
263271
this.network.setDebugNetworkDelay(0)
264272
}
265273

266274
nestedCountersInstance.countEvent('debug', 'simulateProblematic reset')
267-
res.json({
268-
success: true,
275+
res.json({
276+
success: true,
269277
message: 'Problematic simulation settings reset',
270278
settings: {
271279
missConsensus: 0,
272280
networkDelay: 0,
273281
dropMessages: 0,
274282
slowResponse: 0,
275-
slowDelayMs: 0
276-
}
283+
slowDelayMs: 0,
284+
},
277285
})
278286
} else {
279287
// Apply new settings
@@ -293,18 +301,21 @@ class Debug {
293301
this.network.setDebugNetworkDelay(networkDelay)
294302
}
295303

296-
nestedCountersInstance.countEvent('debug', `simulateProblematic configured: miss=${missConsensus}, delay=${networkDelay}, drop=${dropMessages}, slow=${slowResponse}/${slowDelayMs}ms`)
297-
298-
res.json({
304+
nestedCountersInstance.countEvent(
305+
'debug',
306+
`simulateProblematic configured: miss=${missConsensus}, delay=${networkDelay}, drop=${dropMessages}, slow=${slowResponse}/${slowDelayMs}ms`
307+
)
308+
309+
res.json({
299310
success: true,
300311
message: 'Problematic simulation settings applied',
301312
settings: {
302313
missConsensus,
303314
networkDelay,
304315
dropMessages,
305316
slowResponse,
306-
slowDelayMs
307-
}
317+
slowDelayMs,
318+
},
308319
})
309320
}
310321
} catch (e) {

src/network/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,15 @@ export class NetworkClass extends EventEmitter {
223223
if (this.debugNetworkDelay > 0) {
224224
await utils.sleep(this.debugNetworkDelay)
225225
}
226-
226+
227227
// Check if we should respond slowly
228228
if (config?.debug?.slowResponseChance > 0 && Math.random() < config.debug.slowResponseChance) {
229229
const delayMs = config.debug.slowResponseDelay || 3000
230230
nestedCountersInstance.countEvent('network', 'slow-response-injected')
231231
/* prettier-ignore */ if (logFlags.net_verbose) mainLogger.info(`Injecting slow response delay of ${delayMs}ms for route: ${route}`)
232232
await utils.sleep(delayMs)
233233
}
234-
234+
235235
profilerInstance.profileSectionStart('net-internl')
236236
profilerInstance.profileSectionStart(`net-internl-${route}`)
237237

@@ -297,7 +297,7 @@ export class NetworkClass extends EventEmitter {
297297
/* prettier-ignore */ if (logFlags.net_verbose) mainLogger.info(`Dropping tell message due to dropMessageChance: ${route} ${subRoute}`)
298298
continue
299299
}
300-
300+
301301
const promise = this.sn.send(node.internalPort, node.internalIp, data)
302302
promise.catch((err) => {
303303
/* prettier-ignore */ if (logFlags.error) this.mainLogger.error(`Network error (tell) on ${route} ${subRoute}: ${formatErrorMessage(err)}` )
@@ -367,7 +367,7 @@ export class NetworkClass extends EventEmitter {
367367
/* prettier-ignore */ if (logFlags.net_verbose) mainLogger.info(`Dropping tellBinary message due to dropMessageChance: ${route}`)
368368
continue
369369
}
370-
370+
371371
const promise = this.sn.sendWithHeader(node.internalPort, node.internalIp, data, appHeader)
372372
promise.catch((err) => {
373373
/* prettier-ignore */ if (logFlags.error) this.mainLogger.error(`Network error (tellBinary) on ${route}: ${formatErrorMessage(err)}`)
@@ -421,15 +421,15 @@ export class NetworkClass extends EventEmitter {
421421
reject(err)
422422
}
423423
/* prettier-ignore */ if (logFlags.playback && alreadyLogged === false) this.logger.playbackLog('self', node, 'InternalAsk', route, id, message)
424-
424+
425425
// Check if we should drop this message
426426
if (config?.debug?.dropMessageChance > 0 && Math.random() < config.debug.dropMessageChance) {
427427
nestedCountersInstance.countEvent('network', 'message-dropped-ask')
428428
/* prettier-ignore */ if (logFlags.net_verbose) mainLogger.info(`Dropping ask message due to dropMessageChance: ${route}`)
429429
reject(new Error('Message dropped due to dropMessageChance'))
430430
return
431431
}
432-
432+
433433
try {
434434
await this.sn.send(node.internalPort, node.internalIp, data, this.timeout + extraTime, onRes, onTimeout)
435435
} catch (err) {
@@ -484,15 +484,15 @@ export class NetworkClass extends EventEmitter {
484484
reject(err)
485485
}
486486
/* prettier-ignore */ if (logFlags.playback && alreadyLogged === false) this.logger.playbackLog('self', node, 'InternalAsk', route, trackerId, message)
487-
487+
488488
// Check if we should drop this message
489489
if (config?.debug?.dropMessageChance > 0 && Math.random() < config.debug.dropMessageChance) {
490490
nestedCountersInstance.countEvent('network', 'message-dropped-askBinary')
491491
/* prettier-ignore */ if (logFlags.net_verbose) mainLogger.info(`Dropping askBinary message due to dropMessageChance: ${route}`)
492492
reject(new Error('Message dropped due to dropMessageChance'))
493493
return
494494
}
495-
495+
496496
try {
497497
await this.sn.sendWithHeader(
498498
node.internalPort,

src/p2p/Active.ts

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,20 @@ const gossipActiveRoute: P2P.P2PTypes.GossipHandler<P2P.ActiveTypes.SignedActive
4141
}
4242

4343
if (addActiveTx(payload)) {
44-
fireAndForget(() => Comms.sendGossip(
45-
'gossip-active',
46-
payload,
47-
tracker,
48-
sender,
49-
nodeListFromStates([
50-
P2P.P2PTypes.NodeStatus.ACTIVE,
51-
P2P.P2PTypes.NodeStatus.READY,
52-
P2P.P2PTypes.NodeStatus.SYNCING,
53-
]),
54-
false
55-
))
44+
fireAndForget(() =>
45+
Comms.sendGossip(
46+
'gossip-active',
47+
payload,
48+
tracker,
49+
sender,
50+
nodeListFromStates([
51+
P2P.P2PTypes.NodeStatus.ACTIVE,
52+
P2P.P2PTypes.NodeStatus.READY,
53+
P2P.P2PTypes.NodeStatus.SYNCING,
54+
]),
55+
false
56+
)
57+
)
5658
}
5759
} finally {
5860
profilerInstance.scopedProfileSectionEnd('gossip-active')
@@ -269,18 +271,20 @@ export function sendRequests() {
269271
if (addActiveTx(activeTx) === false) {
270272
/* prettier-ignore */ nestedCountersInstance.countEvent('p2p', `active:sendRequests failed to add our own request`)
271273
}
272-
fireAndForget(() => Comms.sendGossip(
273-
'gossip-active',
274-
activeTx,
275-
'',
276-
null,
277-
nodeListFromStates([
278-
P2P.P2PTypes.NodeStatus.ACTIVE,
279-
P2P.P2PTypes.NodeStatus.READY,
280-
P2P.P2PTypes.NodeStatus.SYNCING,
281-
]),
282-
true
283-
))
274+
fireAndForget(() =>
275+
Comms.sendGossip(
276+
'gossip-active',
277+
activeTx,
278+
'',
279+
null,
280+
nodeListFromStates([
281+
P2P.P2PTypes.NodeStatus.ACTIVE,
282+
P2P.P2PTypes.NodeStatus.READY,
283+
P2P.P2PTypes.NodeStatus.SYNCING,
284+
]),
285+
true
286+
)
287+
)
284288

285289
// Check if we went active and try again if we didn't in 1 cycle duration
286290
const activeTimeout = setTimeout(requestActive, config.p2p.cycleDuration * 1000 + 500)

src/p2p/Archivers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ export function parseRecord(record: P2P.CycleCreatorTypes.CycleRecord): P2P.Cycl
355355
}
356356

357357
/** Not used by Archivers */
358-
export function sendRequests() { }
358+
export function sendRequests() {}
359359

360360
/** Not used by Archivers */
361-
export function queueRequest() { }
361+
export function queueRequest() {}
362362

363363
/** Original Functions */
364364

src/p2p/CycleAutoScale.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ function validateScalingRequest(scalingRequest: P2P.CycleAutoScaleTypes.SignedSc
184184
// Check if cycle counter matches
185185
if (scalingRequest.counter !== CycleCreator.currentCycle) {
186186
warn(
187-
`Invalid scaling request, not for this cycle. Current cycle:${CycleCreator.currentCycle}, cycleInScaleRequest: ${scalingRequest.counter
187+
`Invalid scaling request, not for this cycle. Current cycle:${CycleCreator.currentCycle}, cycleInScaleRequest: ${
188+
scalingRequest.counter
188189
} Request: ${Utils.safeStringify(scalingRequest)}`
189190
)
190191
return false
@@ -451,9 +452,9 @@ export function configUpdated() {
451452
// }
452453
}
453454

454-
export function queueRequest(request) { }
455+
export function queueRequest(request) {}
455456

456-
export function sendRequests() { }
457+
export function sendRequests() {}
457458

458459
//TODO please review this. It seems we get consensus on scale up/down, but then
459460
//are not using the autoscaling list for the subsequent operations?

0 commit comments

Comments
 (0)