Skip to content

Commit 98021b1

Browse files
S0naliThakurafostr
authored andcommitted
ntroduced debugFailToCommit flag to allow intentional skipping of transaction commits for debugging purposes.
formatting in StateManager and TransactionQueue
1 parent 27b0bf5 commit 98021b1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/state-manager/TransactionQueue.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,12 @@ class TransactionQueue {
14471447
* @param queueEntry
14481448
*/
14491449
async commitConsensedTransaction(queueEntry: QueueEntry): Promise<CommitConsensedTransactionResult> {
1450+
// Debug flag to intentionally skip committing account data
1451+
if (this.stateManager.debugFailToCommit) {
1452+
/* prettier-ignore */ if (logFlags.debug) this.mainLogger.debug(`debugFailToCommit active. Skipping commit for tx: ${queueEntry.logID}`)
1453+
queueEntry.accountDataSet = true
1454+
return { success: true }
1455+
}
14501456
let ourLockID = -1
14511457
let accountDataList: string | unknown[]
14521458
let uniqueKeys = []

src/state-manager/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class StateManager {
183183

184184
debugNoTxVoting: boolean
185185
debugSkipPatcherRepair: boolean
186+
debugFailToCommit: boolean
186187

187188
ignoreRecieptChance: number
188189
ignoreVoteChance: number
@@ -340,6 +341,7 @@ class StateManager {
340341

341342
this.processCycleSummaries = false //starts false and get enabled when startProcessingCycleSummaries() is called
342343
this.debugSkipPatcherRepair = config.debug.skipPatcherRepair
344+
this.debugFailToCommit = false
343345

344346
this.feature_receiptMapResults = true
345347
this.feature_partitionHashes = true
@@ -1291,6 +1293,16 @@ class StateManager {
12911293

12921294
this.partitionStats.setupHandlers()
12931295

1296+
// Debug endpoint to toggle fail-to-commit flag
1297+
Context.network.registerExternalGet('debugFailToCommit', isDebugModeMiddleware, (req, res) => {
1298+
const { enable } = req.query
1299+
if (enable !== undefined) {
1300+
const val = enable === 'true' || enable === '1'
1301+
this.debugFailToCommit = val
1302+
}
1303+
res.json({ debugFailToCommit: this.debugFailToCommit })
1304+
})
1305+
12941306
// p2p ASK
12951307
// this.p2p.registerInternal(
12961308
// 'request_receipt_for_tx_old',

0 commit comments

Comments
 (0)