dexbot 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/dexbot.js +1 -1
- package/dist/dexbot.js.map +1 -1
- package/dist/modules/account_orders.d.ts +8 -1
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +24 -1
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +4 -25
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.js +3 -28
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +16 -0
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +41 -0
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/constants.d.ts +0 -3
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +0 -14
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.js +1 -1
- package/dist/modules/credit_runtime.js +1 -1
- package/dist/modules/dexbot_class.d.ts +10 -2
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +187 -60
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +2 -2
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +3 -3
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +8 -9
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/key_store.d.ts +0 -36
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +0 -62
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts +2 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +5 -8
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/launch_modes.js +1 -1
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +7 -0
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.d.ts +2 -18
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +22 -49
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +10 -0
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +60 -5
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/grid.js +2 -2
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/manager.d.ts +8 -1
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +28 -14
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/strategy.d.ts +2 -49
- package/dist/modules/order/strategy.d.ts.map +1 -1
- package/dist/modules/order/strategy.js +4 -132
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts +53 -6
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +384 -204
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +8 -3
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.js +1 -1
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +1 -1
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +3 -2
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/runtime_settings.d.ts +3 -0
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +34 -1
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/types.d.ts +29 -4
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/utils/base58check.d.ts +4 -0
- package/dist/modules/utils/base58check.d.ts.map +1 -1
- package/dist/modules/utils/base58check.js +3 -1
- package/dist/modules/utils/base58check.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dexbot_class.d.ts","sourceRoot":"","sources":["../../modules/dexbot_class.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AA+DH,cAAM,MAAM;IACR,MAAM,EAAE,GAAG,CAAC;IACZ,uBAAuB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,OAAO,EAAE,GAAG,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAChC,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,aAAa,EAAE,GAAG,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACpC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,4BAA4B,EAAE,MAAM,CAAC;IACrC,8BAA8B,EAAE,MAAM,CAAC;IACvC,mBAAmB,EAAE,GAAG,CAAC;IACzB,uBAAuB,EAAE,GAAG,CAAC;IAC7B,2BAA2B,EAAE,GAAG,CAAC;IACjC,kBAAkB,EAAE,G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115
|
_blockchainFetchInterval;
|
|
117
116
|
_blockchainFetchInFlight;
|
|
@@ -166,6 +165,8 @@ class DEXBot {
|
|
|
166
165
|
this.config.feeParams = rs.feeParams;
|
|
167
166
|
this.config.incrementBounds = rs.incrementBounds;
|
|
168
167
|
this.config.timing = rs.timing;
|
|
168
|
+
this.config.fillProcessing = rs.fillProcessing;
|
|
169
|
+
this.config.pipelineTiming = rs.pipelineTiming;
|
|
169
170
|
this.config.logging = rs.logging;
|
|
170
171
|
this._fillDedupeWindowMs = this.config.timing.FILL_DEDUPE_WINDOW_MS;
|
|
171
172
|
this._fillRecordRetentionMs = this.config.timing.FILL_RECORD_RETENTION_MS;
|
|
@@ -200,7 +201,6 @@ class DEXBot {
|
|
|
200
201
|
};
|
|
201
202
|
// Shutdown state
|
|
202
203
|
this._shuttingDown = false;
|
|
203
|
-
this._shutdownStarted = false;
|
|
204
204
|
this._shutdownPromise = null;
|
|
205
205
|
// Runtime handles for graceful lifecycle management
|
|
206
206
|
this._blockchainFetchInterval = null;
|
|
@@ -322,6 +322,7 @@ class DEXBot {
|
|
|
322
322
|
* @private
|
|
323
323
|
*/
|
|
324
324
|
async _persistAndRecoverIfNeeded() {
|
|
325
|
+
this.manager._recentFillKeysSnapshot = this._getRecentFillKeysSnapshot();
|
|
325
326
|
const validation = await this.manager.persistGrid();
|
|
326
327
|
if (!validation.isValid) {
|
|
327
328
|
this._warn(`Startup validation failed: ${validation.reason}. Triggering immediate recovery...`);
|
|
@@ -329,6 +330,7 @@ class DEXBot {
|
|
|
329
330
|
const recoveryValidation = await this.manager.accountant._performStateRecovery(this.manager);
|
|
330
331
|
if (recoveryValidation.isValid) {
|
|
331
332
|
this._log(`✓ Startup recovery successful. Persistent state restored.`);
|
|
333
|
+
this.manager._recentFillKeysSnapshot = this._getRecentFillKeysSnapshot();
|
|
332
334
|
await this.manager.persistGrid();
|
|
333
335
|
}
|
|
334
336
|
else {
|
|
@@ -336,6 +338,37 @@ class DEXBot {
|
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* Snapshot the recently queued fill keys as a plain object for crash-durable persistence.
|
|
343
|
+
* Merges with any existing snapshot to avoid losing keys that were evicted from the
|
|
344
|
+
* in-memory map between persist cycles but remain within the dedup window.
|
|
345
|
+
* Only includes entries within the dedup window to avoid writing stale keys.
|
|
346
|
+
* @returns {Record<string, number>}
|
|
347
|
+
*/
|
|
348
|
+
_getRecentFillKeysSnapshot() {
|
|
349
|
+
const snapshot = {};
|
|
350
|
+
const now = Date.now();
|
|
351
|
+
// 1. Collect live keys from the in-memory map
|
|
352
|
+
for (const [key, timestamp] of this._recentlyQueuedFills) {
|
|
353
|
+
if (now - Number(timestamp) < this._fillDedupeWindowMs) {
|
|
354
|
+
snapshot[key] = Number(timestamp);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
// 2. Merge with the previous snapshot — carry forward any keys that
|
|
358
|
+
// were present in a prior persist cycle, are still within the
|
|
359
|
+
// dedup window, but have been evicted from _recentlyQueuedFills
|
|
360
|
+
// (e.g. by TTL-based pruning between two persistGrid calls).
|
|
361
|
+
// This prevents a crash + restart from losing keys that were
|
|
362
|
+
// processed but not yet persisted.
|
|
363
|
+
if (this.manager?._recentFillKeysSnapshot) {
|
|
364
|
+
for (const [key, timestamp] of Object.entries(this.manager._recentFillKeysSnapshot)) {
|
|
365
|
+
if (!(key in snapshot) && now - Number(timestamp) < this._fillDedupeWindowMs) {
|
|
366
|
+
snapshot[key] = Number(timestamp);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return snapshot;
|
|
371
|
+
}
|
|
339
372
|
/**
|
|
340
373
|
* Get current pipeline signal state for congestion checks.
|
|
341
374
|
* @returns {{incomingFillQueueLength: number, shadowLocks: number, batchInFlight: boolean, recoveryInFlight: boolean, broadcasting: boolean}}
|
|
@@ -676,8 +709,6 @@ class DEXBot {
|
|
|
676
709
|
* @returns {Promise<boolean>} True if all affected orders were repaired
|
|
677
710
|
*/
|
|
678
711
|
async _targetedOrderRepair(orderIds) {
|
|
679
|
-
const { BitShares } = require('./bitshares_client');
|
|
680
|
-
const { virtualizeOrder } = require('./order/utils/order');
|
|
681
712
|
try {
|
|
682
713
|
const objects = await BitShares.db.get_objects(orderIds);
|
|
683
714
|
if (!Array.isArray(objects) || objects.length !== orderIds.length)
|
|
@@ -801,11 +832,13 @@ class DEXBot {
|
|
|
801
832
|
const persistedBtsFeesOwed = this.accountOrders.loadBtsFeesOwed();
|
|
802
833
|
const persistedBoundaryIdx = this.accountOrders.loadBoundaryIdx();
|
|
803
834
|
const persistedBtsBalance = this.accountOrders.loadBtsBalance();
|
|
835
|
+
const persistedRecentFillKeys = this.accountOrders.loadRecentFillKeys();
|
|
804
836
|
return {
|
|
805
837
|
persistedGrid: repairedGrid,
|
|
806
838
|
persistedBtsFeesOwed,
|
|
807
839
|
persistedBoundaryIdx,
|
|
808
840
|
persistedBtsBalance,
|
|
841
|
+
persistedRecentFillKeys,
|
|
809
842
|
};
|
|
810
843
|
}
|
|
811
844
|
finally {
|
|
@@ -930,10 +963,10 @@ class DEXBot {
|
|
|
930
963
|
* @param {string} [options.context]
|
|
931
964
|
* @param {Object} [options.logger]
|
|
932
965
|
* @param {string} [options.replayMessage]
|
|
933
|
-
* @param {string} [options.persistenceMode='
|
|
966
|
+
* @param {string} [options.persistenceMode='batched']
|
|
934
967
|
* @returns {Promise<import('./types').ReplaySafeFillResult>}
|
|
935
968
|
*/
|
|
936
|
-
async _applyReplaySafeOrphanFillAccounting(fill, fillOp, { context, logger = this.manager?.logger, replayMessage, persistenceMode = PROCESSED_FILL_PERSISTENCE_MODES.
|
|
969
|
+
async _applyReplaySafeOrphanFillAccounting(fill, fillOp, { context, logger = this.manager?.logger, replayMessage, persistenceMode = PROCESSED_FILL_PERSISTENCE_MODES.BATCHED } = {}) {
|
|
937
970
|
return DexbotFillRuntime.applyReplaySafeOrphanFillAccounting(this, fill, fillOp, {
|
|
938
971
|
context,
|
|
939
972
|
logger,
|
|
@@ -956,7 +989,7 @@ class DEXBot {
|
|
|
956
989
|
* @private
|
|
957
990
|
*/
|
|
958
991
|
async _finishStartupSequence(startupState) {
|
|
959
|
-
let { persistedGrid, persistedBtsFeesOwed, persistedBoundaryIdx, persistedBtsBalance, } = startupState;
|
|
992
|
+
let { persistedGrid, persistedBtsFeesOwed, persistedBoundaryIdx, persistedBtsBalance, persistedRecentFillKeys, } = startupState;
|
|
960
993
|
try {
|
|
961
994
|
// CRITICAL: Activate fill listener EARLY - before ANY operations that place orders
|
|
962
995
|
// This ensures fills during trigger reset and grid initialization are captured
|
|
@@ -993,11 +1026,13 @@ class DEXBot {
|
|
|
993
1026
|
if (this._shuttingDown)
|
|
994
1027
|
return;
|
|
995
1028
|
if (syncResult?.filledOrders?.length > 0) {
|
|
1029
|
+
this._refreshDynamicWeightDistribution('post-reconnect sync fill');
|
|
996
1030
|
this._log(`Post-reconnect sync: ${syncResult.filledOrders.length} grid order(s) found filled.`, 'info');
|
|
997
1031
|
await this._processFillsWithBatching(syncResult.filledOrders, new Set(), 'post-reconnect sync fill');
|
|
998
1032
|
if (this._shuttingDown)
|
|
999
1033
|
return;
|
|
1000
1034
|
}
|
|
1035
|
+
this.manager._recentFillKeysSnapshot = this._getRecentFillKeysSnapshot();
|
|
1001
1036
|
await this.manager.persistGrid();
|
|
1002
1037
|
// Cancel any dust created by reconnect fills immediately.
|
|
1003
1038
|
if (!this._shuttingDown) {
|
|
@@ -1139,6 +1174,7 @@ class DEXBot {
|
|
|
1139
1174
|
}
|
|
1140
1175
|
}
|
|
1141
1176
|
await this._flushProcessedFillPersistence('post-reset-batch');
|
|
1177
|
+
this.manager._recentFillKeysSnapshot = this._getRecentFillKeysSnapshot();
|
|
1142
1178
|
await this.manager.persistGrid();
|
|
1143
1179
|
}
|
|
1144
1180
|
// STEP 2: Refresh chain truth before spread correction. Trigger
|
|
@@ -1205,6 +1241,15 @@ class DEXBot {
|
|
|
1205
1241
|
};
|
|
1206
1242
|
}
|
|
1207
1243
|
}
|
|
1244
|
+
// Restore recently queued fill keys for crash-durable dedup window.
|
|
1245
|
+
// All persisted keys are restored; the in-memory TTL (_fillDedupeWindowMs)
|
|
1246
|
+
// will naturally evict any that are already expired on the next fill cycle.
|
|
1247
|
+
if (persistedRecentFillKeys && typeof persistedRecentFillKeys === 'object') {
|
|
1248
|
+
for (const [fillKey, timestamp] of Object.entries(persistedRecentFillKeys)) {
|
|
1249
|
+
this._recentlyQueuedFills.set(fillKey, Number(timestamp));
|
|
1250
|
+
}
|
|
1251
|
+
this._log(`Restored ${Object.keys(persistedRecentFillKeys).length} recently queued fill key(s) from persisted snapshot`, 'debug');
|
|
1252
|
+
}
|
|
1208
1253
|
if (!this.config.dryRun && !this.accountId) {
|
|
1209
1254
|
throw new Error('Cannot start bot without a resolved account ID');
|
|
1210
1255
|
}
|
|
@@ -1410,6 +1455,7 @@ class DEXBot {
|
|
|
1410
1455
|
const syncResult = await this.manager.synchronizeWithChain(openOrders, 'readOpenOrders');
|
|
1411
1456
|
let aborted = false;
|
|
1412
1457
|
if (syncResult?.filledOrders?.length > 0) {
|
|
1458
|
+
this._refreshDynamicWeightDistribution(`${tag} sync-fill`);
|
|
1413
1459
|
this._log(`[SYNC-CHAIN] ${syncResult.filledOrders.length} filled order(s) found during ${tag}`, 'info');
|
|
1414
1460
|
const batchResult = await this._processFillsWithBatching(syncResult.filledOrders, new Set(), `${tag} sync-fill`);
|
|
1415
1461
|
if (!batchResult?.aborted) {
|
|
@@ -1429,7 +1475,7 @@ class DEXBot {
|
|
|
1429
1475
|
}
|
|
1430
1476
|
}
|
|
1431
1477
|
_maxConsecutiveFillConsumerFailures() {
|
|
1432
|
-
return FILL_PROCESSING.MAX_CONSECUTIVE_CONSUMER_FAILURES;
|
|
1478
|
+
return this.config.fillProcessing?.MAX_CONSECUTIVE_CONSUMER_FAILURES ?? FILL_PROCESSING.MAX_CONSECUTIVE_CONSUMER_FAILURES;
|
|
1433
1479
|
}
|
|
1434
1480
|
/**
|
|
1435
1481
|
* Compute the backoff delay for fill-consumer retries after the failure
|
|
@@ -1441,15 +1487,16 @@ class DEXBot {
|
|
|
1441
1487
|
* @private
|
|
1442
1488
|
*/
|
|
1443
1489
|
_computeFillConsumerBackoffMs(failures) {
|
|
1444
|
-
const
|
|
1445
|
-
const
|
|
1446
|
-
const
|
|
1490
|
+
const fp = this.config.fillProcessing || FILL_PROCESSING;
|
|
1491
|
+
const initial = fp.CONSUMER_BACKOFF_INITIAL_MS;
|
|
1492
|
+
const max = fp.CONSUMER_BACKOFF_MAX_MS;
|
|
1493
|
+
const stepAfterMax = Math.max(0, failures - this._maxConsecutiveFillConsumerFailures());
|
|
1447
1494
|
// 0 -> initial, 1 -> 2*initial, 2 -> 4*initial, ... capped at max.
|
|
1448
1495
|
return Math.min(max, initial * Math.pow(2, stepAfterMax));
|
|
1449
1496
|
}
|
|
1450
1497
|
_scheduleFillConsumerRestart(chainOrders) {
|
|
1451
1498
|
const failures = this._consecutiveConsumeFailures;
|
|
1452
|
-
if (failures >=
|
|
1499
|
+
if (failures >= this._maxConsecutiveFillConsumerFailures()) {
|
|
1453
1500
|
// Past the failure budget: switch from tight setImmediate loop to
|
|
1454
1501
|
// exponential backoff. The consumer continues to retry — a transient
|
|
1455
1502
|
// outage (e.g., credential daemon recovery) will resume normal
|
|
@@ -1731,24 +1778,51 @@ class DEXBot {
|
|
|
1731
1778
|
let resolvedOrders = [];
|
|
1732
1779
|
if (fillMode === 'history') {
|
|
1733
1780
|
this.manager.logger.log(`Syncing ${fillsToSync.length} fill(s) (history mode)`, 'info');
|
|
1734
|
-
for
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
const fillKey = buildFillKey({
|
|
1739
|
-
orderId: fill?.op?.[1]?.order_id,
|
|
1740
|
-
blockNum: fill?.block_num,
|
|
1741
|
-
historyId: fill?.id
|
|
1781
|
+
// Batch mode for 2+ fills: acquires _gridLock once, batches drift refetch
|
|
1782
|
+
if (fillsToSync.length >= 2) {
|
|
1783
|
+
const batchResult = await this.manager.syncFromFillHistoryBatch(fillsToSync, {
|
|
1784
|
+
persistenceMode: PROCESSED_FILL_PERSISTENCE_MODES.BATCHED
|
|
1742
1785
|
});
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1786
|
+
for (const fill of fillsToSync) {
|
|
1787
|
+
const fillKey = buildFillKey({
|
|
1788
|
+
orderId: fill?.op?.[1]?.order_id,
|
|
1789
|
+
blockNum: fill?.block_num,
|
|
1790
|
+
historyId: fill?.id
|
|
1791
|
+
});
|
|
1792
|
+
if (fillKey)
|
|
1793
|
+
pendingFillKeysForCurrentCycle.add(fillKey);
|
|
1794
|
+
}
|
|
1795
|
+
if (batchResult.filledOrders)
|
|
1796
|
+
resolvedOrders.push(...batchResult.filledOrders);
|
|
1797
|
+
if (batchResult.requiresOpenOrdersSync)
|
|
1749
1798
|
requiresOpenOrdersSync = true;
|
|
1750
|
-
if (
|
|
1751
|
-
|
|
1799
|
+
if (batchResult.ghostOrderIds?.length > 0) {
|
|
1800
|
+
for (const id of batchResult.ghostOrderIds) {
|
|
1801
|
+
pendingGhostOrders.add(id);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
else {
|
|
1806
|
+
// Single fill: use individual per-fill path
|
|
1807
|
+
for (const fill of fillsToSync) {
|
|
1808
|
+
const resultHistory = await this.manager.syncFromFillHistory(fill, {
|
|
1809
|
+
persistenceMode: PROCESSED_FILL_PERSISTENCE_MODES.BATCHED
|
|
1810
|
+
});
|
|
1811
|
+
const fillKey = buildFillKey({
|
|
1812
|
+
orderId: fill?.op?.[1]?.order_id,
|
|
1813
|
+
blockNum: fill?.block_num,
|
|
1814
|
+
historyId: fill?.id
|
|
1815
|
+
});
|
|
1816
|
+
if (fillKey)
|
|
1817
|
+
pendingFillKeysForCurrentCycle.add(fillKey);
|
|
1818
|
+
// Dust is handled by post-fill detection below.
|
|
1819
|
+
if (resultHistory.filledOrders)
|
|
1820
|
+
resolvedOrders.push(...resultHistory.filledOrders);
|
|
1821
|
+
if (resultHistory.requiresOpenOrdersSync)
|
|
1822
|
+
requiresOpenOrdersSync = true;
|
|
1823
|
+
if (resultHistory.ghostOrderId)
|
|
1824
|
+
pendingGhostOrders.add(resultHistory.ghostOrderId);
|
|
1825
|
+
}
|
|
1752
1826
|
}
|
|
1753
1827
|
}
|
|
1754
1828
|
if (fillMode !== 'history' || requiresOpenOrdersSync) {
|
|
@@ -1817,6 +1891,8 @@ class DEXBot {
|
|
|
1817
1891
|
this.manager.logger.log(`[FILL-BLOCK] Processing ${fillsWithoutBlock.length} fill(s) without block info`, 'debug');
|
|
1818
1892
|
const noBlockResult = await processValidFills(fillsWithoutBlock);
|
|
1819
1893
|
accumulatedOrders.push(...noBlockResult);
|
|
1894
|
+
if (requiresOpenOrdersSync)
|
|
1895
|
+
anyRequiresSync = true;
|
|
1820
1896
|
}
|
|
1821
1897
|
// If a fill was filtered out during validation (e.g. missing
|
|
1822
1898
|
// history ID) and no block group triggered the open-orders
|
|
@@ -1843,26 +1919,77 @@ class DEXBot {
|
|
|
1843
1919
|
// cancel tx to clean up the zombie order on chain.
|
|
1844
1920
|
// Runs in the finally so it still fires even if processValidFills
|
|
1845
1921
|
// throws after collecting ghost IDs into pendingGhostOrders.
|
|
1846
|
-
//
|
|
1847
|
-
//
|
|
1922
|
+
//
|
|
1923
|
+
// OPTIMIZATION: Batch all new ghost cancels into one executeBatch
|
|
1924
|
+
// call with multiple cancelOrder ops, reducing per-order tx fees
|
|
1925
|
+
// and broadcast overhead. Falls back to individual cancels on
|
|
1926
|
+
// batch failure.
|
|
1848
1927
|
if (pendingGhostOrders.size > 0) {
|
|
1849
1928
|
if (!this._ghostOrderCancelAttempted)
|
|
1850
1929
|
this._ghostOrderCancelAttempted = new Set();
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1930
|
+
const newGhostIds = [...pendingGhostOrders].filter(id => !this._ghostOrderCancelAttempted.has(id));
|
|
1931
|
+
if (newGhostIds.length > 0) {
|
|
1932
|
+
const MAX_OPS_PER_TX = 200;
|
|
1933
|
+
let batchFailed = false;
|
|
1934
|
+
// Build cancel ops with per-ID error tolerance.
|
|
1935
|
+
// Index correlates 1:1 with newGhostIds (allSettled preserves order).
|
|
1936
|
+
const buildResults = await Promise.allSettled(newGhostIds.map(id => chainOrders.buildCancelOrderOp(this.account, id)));
|
|
1937
|
+
const cancelOps = [];
|
|
1938
|
+
for (let i = 0; i < buildResults.length; i++) {
|
|
1939
|
+
const result = buildResults[i];
|
|
1940
|
+
const id = newGhostIds[i];
|
|
1941
|
+
if (result.status === 'fulfilled') {
|
|
1942
|
+
cancelOps.push(result.value);
|
|
1943
|
+
}
|
|
1944
|
+
else {
|
|
1945
|
+
this.manager.logger.log(`[SYNC] Failed to build cancel op for ghost order ${id}: ${result.reason?.message || result.reason}`, 'warn');
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
// Chunk into batches respecting MAX_OPS_PER_TX
|
|
1949
|
+
for (let i = 0; i < cancelOps.length; i += MAX_OPS_PER_TX) {
|
|
1950
|
+
const chunk = cancelOps.slice(i, i + MAX_OPS_PER_TX);
|
|
1951
|
+
const batchIds = newGhostIds.slice(i, i + MAX_OPS_PER_TX);
|
|
1952
|
+
try {
|
|
1953
|
+
this.manager.logger.log(`[SYNC] Batch-cancelling ${chunk.length} orphaned chain order(s) ` +
|
|
1954
|
+
`(batch ${Math.floor(i / MAX_OPS_PER_TX) + 1}/${Math.ceil(cancelOps.length / MAX_OPS_PER_TX)})`, 'info');
|
|
1955
|
+
await chainOrders.executeBatch(this.account, this.privateKey, chunk);
|
|
1956
|
+
// Mark successfully cancelled IDs immediately
|
|
1957
|
+
for (const id of batchIds) {
|
|
1958
|
+
this._ghostOrderCancelAttempted.add(id);
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
catch (batchErr) {
|
|
1962
|
+
batchFailed = true;
|
|
1963
|
+
this.manager.logger.log(`[SYNC] Batch ghost cancel failed for chunk ${Math.floor(i / MAX_OPS_PER_TX) + 1} ` +
|
|
1964
|
+
`(${chunk.length} orders): ${batchErr?.message || batchErr}`, 'warn');
|
|
1965
|
+
}
|
|
1858
1966
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1967
|
+
// Log overall success if all chunks and all builds succeeded
|
|
1968
|
+
if (!batchFailed && cancelOps.length === newGhostIds.length) {
|
|
1969
|
+
this.manager.logger.log(`[SYNC] Successfully batch-cancelled ${newGhostIds.length} orphaned chain order(s)`, 'info');
|
|
1970
|
+
}
|
|
1971
|
+
// Fallback: individual cancels for IDs that were not marked successful
|
|
1972
|
+
for (const ghostOrderId of newGhostIds) {
|
|
1973
|
+
if (this._ghostOrderCancelAttempted.has(ghostOrderId))
|
|
1974
|
+
continue;
|
|
1975
|
+
try {
|
|
1976
|
+
this.manager.logger.log(`[SYNC] Cancelling orphaned chain order ${ghostOrderId} (other-side full-fill residual)`, 'info');
|
|
1977
|
+
await chainOrders.cancelOrder(this.account, this.privateKey, ghostOrderId);
|
|
1978
|
+
this._ghostOrderCancelAttempted.add(ghostOrderId);
|
|
1979
|
+
}
|
|
1980
|
+
catch (err) {
|
|
1981
|
+
this.manager.logger.log(`[SYNC] Failed to cancel orphaned order ${ghostOrderId}: ${err?.message || err}`, 'warn');
|
|
1982
|
+
}
|
|
1861
1983
|
}
|
|
1862
1984
|
}
|
|
1863
1985
|
}
|
|
1864
1986
|
await this.manager.resumeFundRecalc();
|
|
1865
1987
|
}
|
|
1988
|
+
// Refresh dynamic weight distribution before processing fills
|
|
1989
|
+
// so the rebalance uses the latest market adapter weights, not
|
|
1990
|
+
// stale values from the last periodic refresh cycle.
|
|
1991
|
+
// Lightweight: reads local JSON snapshot file.
|
|
1992
|
+
this._refreshDynamicWeightDistribution('fill queue');
|
|
1866
1993
|
// 5. Fixed-Cap Fill Rebalance
|
|
1867
1994
|
// - 1..MAX_FILL_BATCH_SIZE fills: unified full-set planning
|
|
1868
1995
|
// - larger bursts: fixed-size chunking at MAX_FILL_BATCH_SIZE
|
|
@@ -1927,6 +2054,7 @@ class DEXBot {
|
|
|
1927
2054
|
else if (pendingFillKeysForCurrentCycle.size > 0) {
|
|
1928
2055
|
await this._flushProcessedFillPersistenceForKeys(pendingFillKeysForCurrentCycle, 'fill-batch-no-rotations');
|
|
1929
2056
|
}
|
|
2057
|
+
this.manager._recentFillKeysSnapshot = this._getRecentFillKeysSnapshot();
|
|
1930
2058
|
await retryPersistenceIfNeeded(this.manager);
|
|
1931
2059
|
// Periodically clean up old fill records after processing N fills.
|
|
1932
2060
|
// Counter is protected by _fillProcessingLock during fill consumption.
|
|
@@ -2155,14 +2283,14 @@ class DEXBot {
|
|
|
2155
2283
|
this._warn(`Credential daemon probe failed: ${err.message}. Falling back to interactive authentication.`);
|
|
2156
2284
|
}
|
|
2157
2285
|
if (!privateKey) {
|
|
2158
|
-
const unlockSecret = await
|
|
2159
|
-
privateKey = await
|
|
2286
|
+
const unlockSecret = await chainKeys.authenticate();
|
|
2287
|
+
privateKey = await chainKeys.resolvePrivateKey(this.config.preferredAccount, unlockSecret, BitShares);
|
|
2160
2288
|
}
|
|
2161
2289
|
this.privateKey = privateKey;
|
|
2162
2290
|
await this._setupAccountContext(this.config.preferredAccount);
|
|
2163
2291
|
}
|
|
2164
2292
|
catch (err) {
|
|
2165
|
-
if (
|
|
2293
|
+
if (chainKeys.isMasterPasswordFailure(err)) {
|
|
2166
2294
|
throw err;
|
|
2167
2295
|
}
|
|
2168
2296
|
this._warn(`Auto-selection of preferredAccount failed: ${err.message}`);
|
|
@@ -2253,7 +2381,7 @@ class DEXBot {
|
|
|
2253
2381
|
* @returns {number} Positive maximum number of fill-driven rotations per broadcast cycle
|
|
2254
2382
|
*/
|
|
2255
2383
|
_getMaxFillBatchSize() {
|
|
2256
|
-
return Math.max(1, FILL_PROCESSING.MAX_FILL_BATCH_SIZE);
|
|
2384
|
+
return Math.max(1, this.config.fillProcessing?.MAX_FILL_BATCH_SIZE ?? FILL_PROCESSING.MAX_FILL_BATCH_SIZE);
|
|
2257
2385
|
}
|
|
2258
2386
|
/**
|
|
2259
2387
|
* Extract operation results from a batch transaction result.
|
|
@@ -2737,7 +2865,7 @@ class DEXBot {
|
|
|
2737
2865
|
// BROADCAST_DEADLINE fires while the transaction may still be valid
|
|
2738
2866
|
// and land in the next block. Wait for up to 3 blocks (~1 BitShares
|
|
2739
2867
|
// block interval each) and re-check before permanently discarding.
|
|
2740
|
-
const UNCERTAIN_RECHECK_MAX_ATTEMPTS = PIPELINE_TIMING.RETRY_MAX_ATTEMPTS; // 3
|
|
2868
|
+
const UNCERTAIN_RECHECK_MAX_ATTEMPTS = this.config.pipelineTiming?.RETRY_MAX_ATTEMPTS ?? PIPELINE_TIMING.RETRY_MAX_ATTEMPTS; // 3
|
|
2741
2869
|
const UNCERTAIN_RECHECK_INTERVAL_MS = TIMING.MILLISECONDS_PER_SECOND * 3; // 3s
|
|
2742
2870
|
let recheckRound = 0;
|
|
2743
2871
|
while (discarded.length > 0 && recheckRound < UNCERTAIN_RECHECK_MAX_ATTEMPTS) {
|
|
@@ -3483,8 +3611,7 @@ class DEXBot {
|
|
|
3483
3611
|
this._runCredentialRecoveryAfterDaemonRestored().catch(err => {
|
|
3484
3612
|
this.manager?.logger?.log?.(`[CREDENTIAL] Deferred recovery failed: ${err.message}`, 'error');
|
|
3485
3613
|
if (this.manager) {
|
|
3486
|
-
this.manager._recoveryState = this.manager._recoveryState
|
|
3487
|
-
this.manager._recoveryState.lastFailureAt = Date.now();
|
|
3614
|
+
this.manager._recoveryState = { ...this.manager._recoveryState, lastFailureAt: Date.now() };
|
|
3488
3615
|
}
|
|
3489
3616
|
});
|
|
3490
3617
|
}, 1000);
|
|
@@ -3871,7 +3998,7 @@ class DEXBot {
|
|
|
3871
3998
|
`broadcast. Running recovery before placing replacement orders.`, 'error');
|
|
3872
3999
|
if (typeof this.manager.requestStructuralGridResync === 'function') {
|
|
3873
4000
|
if (this.manager._recoveryState)
|
|
3874
|
-
this.manager._recoveryState.structuralResyncRequested
|
|
4001
|
+
this.manager._recoveryState = { ...this.manager._recoveryState, structuralResyncRequested: true };
|
|
3875
4002
|
await this.manager.requestStructuralGridResync('pending broadcasts before COW create', { pendingBroadcasts: pendingBroadcasts.map(p => p.slotId) });
|
|
3876
4003
|
}
|
|
3877
4004
|
try {
|
|
@@ -3961,7 +4088,7 @@ class DEXBot {
|
|
|
3961
4088
|
// Request structural resync to rebuild the grid on the next cycle.
|
|
3962
4089
|
if (typeof this.manager.requestStructuralGridResync === 'function') {
|
|
3963
4090
|
if (this.manager._recoveryState)
|
|
3964
|
-
this.manager._recoveryState.structuralResyncRequested
|
|
4091
|
+
this.manager._recoveryState = { ...this.manager._recoveryState, structuralResyncRequested: true };
|
|
3965
4092
|
await this.manager.requestStructuralGridResync('unmatched chain orders before COW create', { unmatchedChainOrders: unmatchedChainOrders });
|
|
3966
4093
|
}
|
|
3967
4094
|
this.manager.logger.log(`[COW] Rejecting CREATE batch after sync: working grid invalidated by master mutation`, 'info');
|
|
@@ -4264,8 +4391,7 @@ class DEXBot {
|
|
|
4264
4391
|
`(${retryResult.reason || 'no reason'}). Master grid in memory ` +
|
|
4265
4392
|
`is ahead of disk snapshot; structural resync requested.`, 'error');
|
|
4266
4393
|
if (typeof this.manager.requestStructuralGridResync === 'function') {
|
|
4267
|
-
this.manager._recoveryState = this.manager._recoveryState
|
|
4268
|
-
this.manager._recoveryState.structuralResyncRequested = true;
|
|
4394
|
+
this.manager._recoveryState = { ...this.manager._recoveryState, structuralResyncRequested: true };
|
|
4269
4395
|
await this.manager.requestStructuralGridResync('persistence guard triggered after COW batch', { persistReason: retryResult.reason || 'unknown' });
|
|
4270
4396
|
}
|
|
4271
4397
|
}
|
|
@@ -4777,6 +4903,9 @@ class DEXBot {
|
|
|
4777
4903
|
this._warn(`Credit watchdog error: ${err.message}`);
|
|
4778
4904
|
}
|
|
4779
4905
|
}, intervalMs);
|
|
4906
|
+
if (typeof this._creditWatchdogInterval?.unref === 'function') {
|
|
4907
|
+
this._creditWatchdogInterval.unref();
|
|
4908
|
+
}
|
|
4780
4909
|
this._log(`Credit deal watchdog started (${intervalMin}min interval)`);
|
|
4781
4910
|
}
|
|
4782
4911
|
/**
|
|
@@ -4832,9 +4961,7 @@ class DEXBot {
|
|
|
4832
4961
|
const persistedResult = await this._recoverFromPersistedGrid();
|
|
4833
4962
|
if (persistedResult.success) {
|
|
4834
4963
|
if (this.manager?._recoveryState) {
|
|
4835
|
-
this.manager._recoveryState.attemptCount
|
|
4836
|
-
this.manager._recoveryState.lastAttemptAt = 0;
|
|
4837
|
-
this.manager._recoveryState.lastFailureAt = 0;
|
|
4964
|
+
this.manager._recoveryState = { ...this.manager._recoveryState, attemptCount: 0, lastAttemptAt: 0, lastFailureAt: 0 };
|
|
4838
4965
|
}
|
|
4839
4966
|
return;
|
|
4840
4967
|
}
|
|
@@ -4844,9 +4971,7 @@ class DEXBot {
|
|
|
4844
4971
|
refreshCenterPrice: true,
|
|
4845
4972
|
});
|
|
4846
4973
|
if (resetResult && this.manager?._recoveryState) {
|
|
4847
|
-
this.manager._recoveryState.attemptCount
|
|
4848
|
-
this.manager._recoveryState.lastAttemptAt = 0;
|
|
4849
|
-
this.manager._recoveryState.lastFailureAt = 0;
|
|
4974
|
+
this.manager._recoveryState = { ...this.manager._recoveryState, attemptCount: 0, lastAttemptAt: 0, lastFailureAt: 0 };
|
|
4850
4975
|
}
|
|
4851
4976
|
}
|
|
4852
4977
|
catch (err) {
|
|
@@ -4855,7 +4980,7 @@ class DEXBot {
|
|
|
4855
4980
|
finally {
|
|
4856
4981
|
this._structuralGridResyncRunning = false;
|
|
4857
4982
|
if (this.manager?._recoveryState) {
|
|
4858
|
-
this.manager._recoveryState.structuralResyncRequested
|
|
4983
|
+
this.manager._recoveryState = { ...this.manager._recoveryState, structuralResyncRequested: false };
|
|
4859
4984
|
}
|
|
4860
4985
|
}
|
|
4861
4986
|
}, 0);
|
|
@@ -4954,6 +5079,9 @@ class DEXBot {
|
|
|
4954
5079
|
// Silently retry next interval
|
|
4955
5080
|
}
|
|
4956
5081
|
}, DUST_HEALTH_CHECK_INTERVAL_MS);
|
|
5082
|
+
if (typeof this._dustHealthCheckTimer?.unref === 'function') {
|
|
5083
|
+
this._dustHealthCheckTimer.unref();
|
|
5084
|
+
}
|
|
4957
5085
|
}
|
|
4958
5086
|
/**
|
|
4959
5087
|
* Perform grid maintenance: fund thresholds, spread condition, grid health, divergence.
|
|
@@ -4990,11 +5118,11 @@ class DEXBot {
|
|
|
4990
5118
|
* @returns {Promise<void>}
|
|
4991
5119
|
*/
|
|
4992
5120
|
async shutdown() {
|
|
4993
|
-
if (this.
|
|
5121
|
+
if (this._shuttingDown) {
|
|
4994
5122
|
this._log('Shutdown already in progress; ignoring re-entrant call');
|
|
4995
5123
|
return this._shutdownPromise || Promise.resolve();
|
|
4996
5124
|
}
|
|
4997
|
-
this.
|
|
5125
|
+
this._shuttingDown = true;
|
|
4998
5126
|
const shutdownImpl = typeof this._shutdownImpl === 'function'
|
|
4999
5127
|
? this._shutdownImpl
|
|
5000
5128
|
: DEXBot.prototype._shutdownImpl;
|
|
@@ -5003,7 +5131,6 @@ class DEXBot {
|
|
|
5003
5131
|
}
|
|
5004
5132
|
async _shutdownImpl() {
|
|
5005
5133
|
this._log('Initiating graceful shutdown...');
|
|
5006
|
-
this._shuttingDown = true;
|
|
5007
5134
|
this._processedFillStore.setShuttingDown(true);
|
|
5008
5135
|
// Stop accepting new work
|
|
5009
5136
|
this._stopBlockchainFetchInterval();
|