@xyo-network/chain-sdk 5.1.1 → 5.2.1

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.
Files changed (23) hide show
  1. package/dist/browser/modules/analyze/ChainHeadSelector.d.ts +32 -0
  2. package/dist/browser/modules/analyze/ChainHeadSelector.d.ts.map +1 -1
  3. package/dist/browser/modules/services/implementation/processPendingBlocks.d.ts +6 -1
  4. package/dist/browser/modules/services/implementation/processPendingBlocks.d.ts.map +1 -1
  5. package/dist/browser/modules/services/simple/block/runner/SimpleBlockRunner.d.ts +31 -2
  6. package/dist/browser/modules/services/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -1
  7. package/dist/neutral/analyze.mjs +67 -3
  8. package/dist/neutral/analyze.mjs.map +2 -2
  9. package/dist/neutral/modules/analyze/ChainHeadSelector.d.ts +32 -0
  10. package/dist/neutral/modules/analyze/ChainHeadSelector.d.ts.map +1 -1
  11. package/dist/neutral/modules/services/implementation/processPendingBlocks.d.ts +6 -1
  12. package/dist/neutral/modules/services/implementation/processPendingBlocks.d.ts.map +1 -1
  13. package/dist/neutral/modules/services/simple/block/runner/SimpleBlockRunner.d.ts +31 -2
  14. package/dist/neutral/modules/services/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -1
  15. package/dist/neutral/services.mjs +72 -26
  16. package/dist/neutral/services.mjs.map +2 -2
  17. package/dist/node/modules/analyze/ChainHeadSelector.d.ts +32 -0
  18. package/dist/node/modules/analyze/ChainHeadSelector.d.ts.map +1 -1
  19. package/dist/node/modules/services/implementation/processPendingBlocks.d.ts +6 -1
  20. package/dist/node/modules/services/implementation/processPendingBlocks.d.ts.map +1 -1
  21. package/dist/node/modules/services/simple/block/runner/SimpleBlockRunner.d.ts +31 -2
  22. package/dist/node/modules/services/simple/block/runner/SimpleBlockRunner.d.ts.map +1 -1
  23. package/package.json +7 -7
@@ -14,6 +14,11 @@ interface ProcessPendingBlocksParams {
14
14
  /** Computes producer standing, for the shadow and enforce postures. */
15
15
  eligibility?: ProducerEligibilityEvaluator;
16
16
  finalizationRunner: FinalizationRunner;
17
+ /**
18
+ * Minimum epoch spacing (ms) between transaction-less heartbeat blocks the head selector will
19
+ * qualify; transaction-carrying candidates are exempt. Undefined disables the pace check.
20
+ */
21
+ heartbeatInterval?: number;
17
22
  logger?: Logger;
18
23
  mempoolViewer: MempoolViewer;
19
24
  minCandidates?: number;
@@ -25,7 +30,7 @@ interface ProcessPendingBlocksParams {
25
30
  /** Where to publish what both admission gates concluded, in shadow posture. */
26
31
  publishAdmissionShadow?: (report: AdmissionShadowReport) => Promise<void>;
27
32
  }
28
- export declare function processPendingBlocks({ blockValidationViewer, blockViewer, context, logger, mempoolViewer, finalizationRunner, allowedProducers, backoffMs, minCandidates, deadLetterQueueRunner, observer, admission, eligibility, publishAdmissionShadow, }: ProcessPendingBlocksParams): Promise<[{
33
+ export declare function processPendingBlocks({ blockValidationViewer, blockViewer, context, logger, mempoolViewer, finalizationRunner, allowedProducers, backoffMs, heartbeatInterval, minCandidates, deadLetterQueueRunner, observer, admission, eligibility, publishAdmissionShadow, }: ProcessPendingBlocksParams): Promise<[{
29
34
  schema: "network.xyo.boundwitness" & {
30
35
  readonly __schema: true;
31
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"processPendingBlocks.d.ts","sourceRoot":"","sources":["../../../../../src/modules/services/implementation/processPendingBlocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EACV,WAAW,EAAE,qBAAqB,EAAE,WAAW,EAAE,qBAAqB,EAAE,kBAAkB,EAA6B,aAAa,EACrI,MAAM,sBAAsB,CAAA;AAK7B,OAAO,KAAK,EACV,aAAa,EAAE,qBAAqB,EAAE,4BAA4B,EACnE,MAAM,UAAU,CAAA;AAKjB,UAAU,0BAA0B;IAClC,uFAAuF;IACvF,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,WAAW,EAAE,WAAW,CAAA;IACxB,OAAO,EAAE,WAAW,CAAA;IACpB,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;IAC7C,uEAAuE;IACvE,WAAW,CAAC,EAAE,4BAA4B,CAAA;IAC1C,kBAAkB,EAAE,kBAAkB,CAAA;IACtC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,aAAa,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1E;AAgCD,wBAAsB,oBAAoB,CAAC,EACzC,qBAAqB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EACnK,SAAS,EAAE,WAAW,EAAE,sBAAsB,GAC/C,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA2E5B"}
1
+ {"version":3,"file":"processPendingBlocks.d.ts","sourceRoot":"","sources":["../../../../../src/modules/services/implementation/processPendingBlocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EACV,WAAW,EAAE,qBAAqB,EAAE,WAAW,EAAE,qBAAqB,EAAE,kBAAkB,EAA6B,aAAa,EACrI,MAAM,sBAAsB,CAAA;AAK7B,OAAO,KAAK,EACV,aAAa,EAAE,qBAAqB,EAAE,4BAA4B,EACnE,MAAM,UAAU,CAAA;AAKjB,UAAU,0BAA0B;IAClC,uFAAuF;IACvF,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,WAAW,EAAE,WAAW,CAAA;IACxB,OAAO,EAAE,WAAW,CAAA;IACpB,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;IAC7C,uEAAuE;IACvE,WAAW,CAAC,EAAE,4BAA4B,CAAA;IAC1C,kBAAkB,EAAE,kBAAkB,CAAA;IACtC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,aAAa,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAA;IAC1B,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1E;AAgCD,wBAAsB,oBAAoB,CAAC,EACzC,qBAAqB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,qBAAqB,EAAE,QAAQ,EACtL,SAAS,EAAE,WAAW,EAAE,sBAAsB,GAC/C,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBA4E5B"}
@@ -3,10 +3,23 @@ import type { AccountInstance, ArchivistInstance, WithHashMeta } from '@xyo-netw
3
3
  import type { AccountBalanceViewer, BlockBoundWitness, BlockRewardViewer, BlockRunner, BlockValidationViewer, ChainStakeIntent, CreatableProviderParams, DeadLetterQueueRunner, FinalizationViewer, HydratedBlockStateValidationFunction, MempoolViewer, SignedBlockBoundWitnessWithHashMeta, SignedHydratedBlockWithHashMeta, TimeSyncViewer, Transfer } from '@xyo-network/xl1-sdk';
4
4
  import { AbstractCreatableProvider } from '@xyo-network/xl1-sdk';
5
5
  import type { BlockRewardDiviner } from '../../../../modules/index.js';
6
+ import type { OffendingTxReason } from './identifyOffendingTransactions.js';
7
+ /** Why and at which build height a transaction was excluded from future candidates. */
8
+ interface ExcludedTransactionEntry {
9
+ excludedAtBlock: number;
10
+ reason: OffendingTxReason;
11
+ }
6
12
  /**
7
13
  * The default block size for a block
8
14
  */
9
15
  export declare const DEFAULT_BLOCK_SIZE = 10;
16
+ /**
17
+ * Default minimum age (ms) of the head before a producer emits a transaction-less heartbeat
18
+ * block. Five minutes keeps a quiet chain visibly alive without accumulating meaningful storage
19
+ * or block-reward drift. Finalizers use the same default as the floor for how fast they will
20
+ * finalize heartbeat blocks.
21
+ */
22
+ export declare const DEFAULT_HEARTBEAT_INTERVAL = 300000;
10
23
  /**
11
24
  * The amount of time for which a producer will restake their intent
12
25
  */
@@ -35,6 +48,12 @@ export interface SimpleBlockRunnerParams extends CreatableProviderParams {
35
48
  validateHydratedBlockState?: HydratedBlockStateValidationFunction;
36
49
  }
37
50
  export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleBlockRunnerParams> implements BlockRunner {
51
+ /**
52
+ * Minimum time between build attempts after a fully-rejected build (validation exhausted with
53
+ * no attributable transaction to exclude). Such a build fails identically until external state
54
+ * changes, so retrying at the production tick rate only churns build → validate → DLQ.
55
+ */
56
+ static readonly RejectedBuildBackoffMs = 1000;
38
57
  static readonly connectionTypes: readonly ["lmdb", "mongo", "memory"];
39
58
  static readonly defaultMoniker: "BlockRunner";
40
59
  static readonly dependencies: ("AccountBalanceViewer" | "MempoolViewer" | "BlockRewardViewer" | "BlockValidationViewer" | "FinalizationViewer" | "TimeSyncViewer")[];
@@ -43,7 +62,7 @@ export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleB
43
62
  moniker: "BlockRunner";
44
63
  protected _blockRewardDiviner?: BlockRewardDiviner;
45
64
  protected _deadLetterQueueRunner?: DeadLetterQueueRunner;
46
- protected _excludedTransactionHashes: Set<import("@ariestools/sdk").BrandedHash>;
65
+ protected _excludedTransactionHashes: Map<import("@ariestools/sdk").BrandedHash, ExcludedTransactionEntry>;
47
66
  protected _lastRedeclarationBlock?: number;
48
67
  protected _rejectedTransactionsArchivist?: ArchivistInstance;
49
68
  private _account?;
@@ -53,6 +72,7 @@ export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleB
53
72
  private _blockValidationViewer?;
54
73
  private _chainParamsViewer?;
55
74
  private _finalizationViewer?;
75
+ private _lastRejectedBuildAt;
56
76
  /** Cache of the last candidate this runner signed; the mempool is the source of truth. */
57
77
  private _lastSignedCandidate?;
58
78
  private _mempoolViewer?;
@@ -137,6 +157,8 @@ export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleB
137
157
  _hash: import("@ariestools/sdk").BrandedHash;
138
158
  _dataHash: import("@ariestools/sdk").BrandedHash;
139
159
  }[]] | undefined>;
160
+ private addTransferOutflow;
161
+ private commitProposedBlock;
140
162
  /**
141
163
  * Compute the cumulative outflow a single tx would charge to its `from`
142
164
  * address, using the same rule as `BlockCumulativeBalanceValidator`:
@@ -146,8 +168,13 @@ export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleB
146
168
  * reject, which would otherwise wedge the chain because the producer's
147
169
  * `_lastProducedBlock` cache mutes retries.
148
170
  */
149
- private addTransferOutflow;
150
171
  private computeTransactionOutflow;
172
+ /**
173
+ * Drops head-relative ('block-balance') exclusions once the head has advanced past the height
174
+ * they were recorded at — the sender's funding is re-evaluated by filterByFunded at the new
175
+ * head. Deterministic ('tx-invalid') exclusions are kept for the process lifetime.
176
+ */
177
+ private evictStaleExclusions;
151
178
  private filterByFunded;
152
179
  private generateTimePayload;
153
180
  /**
@@ -156,6 +183,7 @@ export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleB
156
183
  * @returns True if a heartbeat is required, false otherwise
157
184
  */
158
185
  private heartbeatRequired;
186
+ private isWithinRejectedBuildBackoff;
159
187
  /**
160
188
  * The hash of this producer's own earlier candidate at the same height and parent, if any.
161
189
  *
@@ -189,4 +217,5 @@ export declare class SimpleBlockRunner extends AbstractCreatableProvider<SimpleB
189
217
  private resolveSupersedes;
190
218
  private runBuildValidateRetryLoop;
191
219
  }
220
+ export {};
192
221
  //# sourceMappingURL=SimpleBlockRunner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleBlockRunner.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAQ,UAAU,EAC1B,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAAE,YAAY,EAChC,MAAM,kBAAkB,CAAA;AAKzB,OAAO,KAAK,EACV,oBAAoB,EAAuB,iBAAiB,EACxC,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EACzE,gBAAgB,EAAE,uBAAuB,EACzC,qBAAqB,EACrB,kBAAkB,EAClB,oCAAoC,EAAgC,aAAa,EACjF,mCAAmC,EACnC,+BAA+B,EAClB,cAAc,EAAE,QAAQ,EACtC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AASlD;;GAEG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,mCAAmC,MAAM,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAA;AAEpD,MAAM,WAAW,uBAAwB,SAAQ,uBAA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G,SAAS,CAAC;cAsBnG,qBAAqB,CAAC,IAAI,EAAE,YAAY,CAAC,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,EAAE,OAAO,EAAE,KAAK,UAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsEtH;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,yBAAyB;YAiBnB,cAAc;YAsDd,mBAAmB;IAIjC;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;;;;;;;;;OAaG;YACW,wBAAwB;YAOxB,oBAAoB;YAkBpB,4BAA4B;IAiC1C;;;;;;;;;;;;OAYG;YACW,iBAAiB;YASjB,yBAAyB;CA4DxC"}
1
+ {"version":3,"file":"SimpleBlockRunner.d.ts","sourceRoot":"","sources":["../../../../../../../src/modules/services/simple/block/runner/SimpleBlockRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAQ,UAAU,EAC1B,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAAE,YAAY,EAChC,MAAM,kBAAkB,CAAA;AAKzB,OAAO,KAAK,EACV,oBAAoB,EAAuB,iBAAiB,EACxC,iBAAiB,EAAE,WAAW,EAAE,qBAAqB,EACzE,gBAAgB,EAAE,uBAAuB,EACzC,qBAAqB,EACrB,kBAAkB,EAClB,oCAAoC,EAAgC,aAAa,EACjF,mCAAmC,EACnC,+BAA+B,EAClB,cAAc,EAAE,QAAQ,EACtC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAKlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAK3E,uFAAuF;AACvF,UAAU,wBAAwB;IAChC,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,iBA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,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,+BAA+B,CAAC;IAClH,gBAAgB,CAAC,IAAI,EAAE,mCAAmC,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,+BAA+B,GAAG,SAAS,CAAC;cAOtH,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAiB3E;;;;OAIG;IACH,SAAS,CAAC,wBAAwB,CAAC,IAAI,EAAE,YAAY,CAAC,iBAAiB,CAAC,GAAG,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAC;cAsBnG,qBAAqB,CAAC,IAAI,EAAE,YAAY,CAAC,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,EAAE,OAAO,EAAE,KAAK,UAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2DtH,OAAO,CAAC,kBAAkB;YASZ,mBAAmB;IAyBjC;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAgBjC;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;YASd,cAAc;YAsDd,mBAAmB;IAUjC;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,4BAA4B;IAMpC;;;;;;;;;;;;;OAaG;YACW,wBAAwB;YAOxB,oBAAoB;YAkBpB,4BAA4B;IAiC1C;;;;;;;;;;;;OAYG;YACW,iBAAiB;YASjB,yBAAyB;CAoExC"}
@@ -168,6 +168,7 @@ async function processPendingBlocks({
168
168
  finalizationRunner,
169
169
  allowedProducers,
170
170
  backoffMs,
171
+ heartbeatInterval,
171
172
  minCandidates,
172
173
  deadLetterQueueRunner,
173
174
  observer,
@@ -185,6 +186,7 @@ async function processPendingBlocks({
185
186
  windowedFinalizedChain: [currentBlock],
186
187
  allowedProducers,
187
188
  backoffMs,
189
+ heartbeatInterval,
188
190
  minCandidates,
189
191
  admission,
190
192
  eligibility,
@@ -450,15 +452,19 @@ function producerTuningFromConfig(config) {
450
452
 
451
453
  // src/modules/services/simple/block/runner/SimpleBlockRunner.ts
452
454
  var DEFAULT_BLOCK_SIZE = 10;
455
+ var DEFAULT_HEARTBEAT_INTERVAL = 3e5;
453
456
  var XYO_PRODUCER_REDECLARATION_DURATION = 100;
454
457
  var XYO_PRODUCER_REDECLARATION_WINDOW = 100;
455
458
  var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
456
459
  moniker = SimpleBlockRunner.defaultMoniker;
457
460
  _blockRewardDiviner;
458
461
  _deadLetterQueueRunner;
459
- // TODO(producer-exclusion-set): uncapped for v1. If memory grows in long-running producers,
460
- // add FIFO eviction or a TTL keyed off block number.
461
- _excludedTransactionHashes = /* @__PURE__ */ new Set();
462
+ // Reason-scoped: deterministic ('tx-invalid') exclusions last the process lifetime, while
463
+ // head-relative ('block-balance') exclusions evict once the head advances past the height they
464
+ // were recorded at — a sender underfunded at head H may be funded at H+k, and permanent
465
+ // exclusion would censor them. TODO(producer-exclusion-set): 'tx-invalid' entries are still
466
+ // uncapped; add FIFO eviction if memory grows in long-running producers.
467
+ _excludedTransactionHashes = /* @__PURE__ */ new Map();
462
468
  _lastRedeclarationBlock;
463
469
  _rejectedTransactionsArchivist;
464
470
  _account;
@@ -468,6 +474,7 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
468
474
  _blockValidationViewer;
469
475
  _chainParamsViewer;
470
476
  _finalizationViewer;
477
+ _lastRejectedBuildAt = 0;
471
478
  /** Cache of the last candidate this runner signed; the mempool is the source of truth. */
472
479
  _lastSignedCandidate;
473
480
  _mempoolViewer;
@@ -512,7 +519,7 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
512
519
  return this._finalizationViewer;
513
520
  }
514
521
  get heartbeatInterval() {
515
- return this.params.heartbeatInterval ?? this.producerTuning.heartbeatInterval ?? 36e5;
522
+ return this.params.heartbeatInterval ?? this.producerTuning.heartbeatInterval ?? DEFAULT_HEARTBEAT_INTERVAL;
516
523
  }
517
524
  get mempoolViewer() {
518
525
  return this._mempoolViewer;
@@ -607,10 +614,12 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
607
614
  const shouldValidateBalances = validateBalances ?? this.params.validateBalances ?? true;
608
615
  return await this.spanAsync("proposeNextValidBlock", async () => {
609
616
  try {
617
+ if (this.isWithinRejectedBuildBackoff(force)) return;
610
618
  const { block: previousBlock } = assertEx4(asBlockBoundWitness(head), () => "Invalid head block");
611
619
  const nextBlock = previousBlock + 1;
612
620
  const chainId = await this.finalizationViewer.chainId();
613
621
  const pendingTransactionsRaw = await this.mempoolViewer.pendingTransactions({ limit: SimpleBlockRunner.DefaultBlockSize });
622
+ this.evictStaleExclusions(previousBlock);
614
623
  const pendingTransactions = pendingTransactionsRaw.filter((tx) => !this._excludedTransactionHashes.has(tx[0]._hash));
615
624
  const nextBlockTransactions = await this.rejectWrongChainTransactions(pendingTransactions, chainId);
616
625
  this.logger?.log(`Pending Tx Count ${nextBlockTransactions.length}`);
@@ -621,16 +630,11 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
621
630
  const rewardTransferPayloads = await this.getBlockRewardTransfers(nextBlock);
622
631
  nonTxPayloads.push(...rewardTransferPayloads);
623
632
  const transactionTransfers = await generateTransactionFeeTransfers(this.address, nextBlockTransactions);
624
- const timeStart = Date.now();
625
633
  const timePayload = await this.generateTimePayload();
626
- const timeDuration = Date.now() - timeStart;
627
- if (timeDuration > 100) {
628
- this.logger?.warn(`[Slow] Generated time payload in ${timeDuration}ms`);
629
- }
630
634
  const [initialFundedTransactions, initialFundedTransfers] = await this.filterByFunded(head, nextBlockTransactions, transactionTransfers, shouldValidateBalances);
631
635
  const stepRewardBalances = await this.accountBalanceViewer.accountBalances([XYO_STEP_REWARD_ADDRESS]);
632
636
  const stepRewardPoolBalance = stepRewardBalances[String(XYO_STEP_REWARD_ADDRESS)];
633
- const result = await this.runBuildValidateRetryLoop({
637
+ const { block: proposedBlock, errors: proposedErrors } = await this.runBuildValidateRetryLoop({
634
638
  head,
635
639
  chainId,
636
640
  stepRewardPoolBalance,
@@ -639,17 +643,31 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
639
643
  initialFundedTransactions,
640
644
  initialFundedTransfers
641
645
  });
642
- const { block: proposedBlock, errors: proposedErrors } = result;
643
- if (isSignedHydratedBlockWithHashMeta2(proposedBlock)) {
644
- return proposedBlock;
645
- }
646
- if (proposedBlock !== void 0) await this.rejectExhaustedBlock(proposedBlock, proposedErrors);
646
+ return await this.commitProposedBlock(proposedBlock, proposedErrors);
647
647
  } catch (error) {
648
648
  this.logger?.error(`Error proposing next valid block: ${error.message}`);
649
649
  throw error;
650
650
  }
651
651
  }, this.context);
652
652
  }
653
+ addTransferOutflow(outflow, payload) {
654
+ let result = outflow;
655
+ for (const [to, amount] of Object.entries(payload.transfers)) {
656
+ if (to === payload.from) continue;
657
+ result += hexToBigInt(amount ?? "00");
658
+ }
659
+ return result;
660
+ }
661
+ async commitProposedBlock(proposedBlock, proposedErrors) {
662
+ if (proposedErrors.length === 0 && isSignedHydratedBlockWithHashMeta2(proposedBlock)) {
663
+ this._lastRejectedBuildAt = 0;
664
+ return proposedBlock;
665
+ }
666
+ if (proposedBlock !== void 0) {
667
+ this._lastRejectedBuildAt = Date.now();
668
+ await this.rejectExhaustedBlock(proposedBlock, proposedErrors);
669
+ }
670
+ }
653
671
  /**
654
672
  * Compute the cumulative outflow a single tx would charge to its `from`
655
673
  * address, using the same rule as `BlockCumulativeBalanceValidator`:
@@ -659,14 +677,6 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
659
677
  * reject, which would otherwise wedge the chain because the producer's
660
678
  * `_lastProducedBlock` cache mutes retries.
661
679
  */
662
- addTransferOutflow(outflow, payload) {
663
- let result = outflow;
664
- for (const [to, amount] of Object.entries(payload.transfers)) {
665
- if (to === payload.from) continue;
666
- result += hexToBigInt(amount ?? "00");
667
- }
668
- return result;
669
- }
670
680
  computeTransactionOutflow(tx) {
671
681
  const [bw, payloads] = tx;
672
682
  const {
@@ -684,6 +694,18 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
684
694
  }
685
695
  return outflow;
686
696
  }
697
+ /**
698
+ * Drops head-relative ('block-balance') exclusions once the head has advanced past the height
699
+ * they were recorded at — the sender's funding is re-evaluated by filterByFunded at the new
700
+ * head. Deterministic ('tx-invalid') exclusions are kept for the process lifetime.
701
+ */
702
+ evictStaleExclusions(headBlock) {
703
+ for (const [hash, entry] of this._excludedTransactionHashes) {
704
+ if (entry.reason === "block-balance" && headBlock > entry.excludedAtBlock) {
705
+ this._excludedTransactionHashes.delete(hash);
706
+ }
707
+ }
708
+ }
687
709
  // remove unfunded transactions and block transfers
688
710
  async filterByFunded(head, txs, transfers, validateBalances = false) {
689
711
  const fundedTransfers = [];
@@ -719,7 +741,13 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
719
741
  return [fundedTransactions, fundedTransfers];
720
742
  }
721
743
  async generateTimePayload() {
722
- return await this.timeSyncViewer.currentTimePayload();
744
+ const timeStart = Date.now();
745
+ const timePayload = await this.timeSyncViewer.currentTimePayload();
746
+ const timeDuration = Date.now() - timeStart;
747
+ if (timeDuration > 100) {
748
+ this.logger?.warn(`[Slow] Generated time payload in ${timeDuration}ms`);
749
+ }
750
+ return timePayload;
723
751
  }
724
752
  /**
725
753
  * Check if a heartbeat block is required based on network activity.
@@ -733,6 +761,11 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
733
761
  }
734
762
  return false;
735
763
  }
764
+ isWithinRejectedBuildBackoff(force) {
765
+ if (force || Date.now() - this._lastRejectedBuildAt >= SimpleBlockRunner.RejectedBuildBackoffMs) return false;
766
+ this.logger?.debug("Skipping block production during rejected-build backoff");
767
+ return true;
768
+ }
736
769
  /**
737
770
  * The hash of this producer's own earlier candidate at the same height and parent, if any.
738
771
  *
@@ -850,7 +883,11 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
850
883
  chainId,
851
884
  supersedes
852
885
  );
853
- const validated = await this.blockValidationViewer.validateBlock(lastBlock, { head: head._hash });
886
+ const validated = await this.blockValidationViewer.validateBlock(lastBlock, {
887
+ value: true,
888
+ state: true,
889
+ head: head._hash
890
+ });
854
891
  if (isSignedHydratedBlockWithHashMeta2(validated)) {
855
892
  this._lastSignedCandidate = {
856
893
  block: validated[0].block,
@@ -863,7 +900,9 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
863
900
  if (attempt === maxAttempts) break;
864
901
  const { offendingHashes, reason } = await identifyOffendingTransactions({ candidateTransactions, errors: validated });
865
902
  if (offendingHashes.length === 0 || reason === "unknown") break;
866
- for (const offendingHash of offendingHashes) this._excludedTransactionHashes.add(offendingHash);
903
+ for (const offendingHash of offendingHashes) {
904
+ this._excludedTransactionHashes.set(offendingHash, { excludedAtBlock: head.block, reason });
905
+ }
867
906
  const offendingSet = new Set(offendingHashes);
868
907
  candidateTransactions = candidateTransactions.filter((tx) => !offendingSet.has(tx[0]._hash));
869
908
  const remainingFromAddresses = new Set(candidateTransactions.map((tx) => tx[0].from));
@@ -874,6 +913,12 @@ var SimpleBlockRunner = class extends AbstractCreatableProvider4 {
874
913
  return { block: lastBlock, errors: lastErrors };
875
914
  }
876
915
  };
916
+ /**
917
+ * Minimum time between build attempts after a fully-rejected build (validation exhausted with
918
+ * no attributable transaction to exclude). Such a build fails identically until external state
919
+ * changes, so retrying at the production tick rate only churns build → validate → DLQ.
920
+ */
921
+ __publicField(SimpleBlockRunner, "RejectedBuildBackoffMs", 1e3);
877
922
  __publicField(SimpleBlockRunner, "connectionTypes", ["lmdb", "mongo", "memory"]);
878
923
  __publicField(SimpleBlockRunner, "defaultMoniker", BlockRunnerMoniker);
879
924
  __publicField(SimpleBlockRunner, "dependencies", [
@@ -908,6 +953,7 @@ export {
908
953
  BaseElectionService,
909
954
  BaseNetworkStakeStepRewardService,
910
955
  DEFAULT_BLOCK_SIZE,
956
+ DEFAULT_HEARTBEAT_INTERVAL,
911
957
  EvmBlockRewardViewer,
912
958
  SimpleBlockRunner,
913
959
  ValidatorMoniker,