@xyo-network/chain-services 1.5.35 → 1.5.36

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 (69) hide show
  1. package/dist/neutral/index.mjs +428 -259
  2. package/dist/neutral/index.mjs.map +1 -1
  3. package/dist/types/AccountBalance/ChainAccountBalanceServiceV2.d.ts +14 -0
  4. package/dist/types/AccountBalance/ChainAccountBalanceServiceV2.d.ts.map +1 -0
  5. package/dist/types/AccountBalance/XyoChainAccountBalanceService.d.ts +12 -8
  6. package/dist/types/AccountBalance/XyoChainAccountBalanceService.d.ts.map +1 -1
  7. package/dist/types/AccountBalance/accountBalanceServiceFromArchivist.d.ts +3 -2
  8. package/dist/types/AccountBalance/accountBalanceServiceFromArchivist.d.ts.map +1 -1
  9. package/dist/types/AccountBalance/index.d.ts +1 -0
  10. package/dist/types/AccountBalance/index.d.ts.map +1 -1
  11. package/dist/types/BaseService.d.ts +7 -8
  12. package/dist/types/BaseService.d.ts.map +1 -1
  13. package/dist/types/BlockProducer/XyoBlockProducer.d.ts +28 -9
  14. package/dist/types/BlockProducer/XyoBlockProducer.d.ts.map +1 -1
  15. package/dist/types/BlockReward/EvmBlockRewardService.d.ts +2 -1
  16. package/dist/types/BlockReward/EvmBlockRewardService.d.ts.map +1 -1
  17. package/dist/types/BlockReward/XyoBlockRewardService.d.ts +2 -1
  18. package/dist/types/BlockReward/XyoBlockRewardService.d.ts.map +1 -1
  19. package/dist/types/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts +4 -2
  20. package/dist/types/ChainBlockNumberIteration/ChainBlockNumberIterationService.d.ts.map +1 -1
  21. package/dist/types/ChainBlockNumberIteration/model/Params.d.ts +8 -0
  22. package/dist/types/ChainBlockNumberIteration/model/Params.d.ts.map +1 -0
  23. package/dist/types/ChainBlockNumberIteration/model/index.d.ts +1 -0
  24. package/dist/types/ChainBlockNumberIteration/model/index.d.ts.map +1 -1
  25. package/dist/types/ChainIndexService.d.ts +8 -5
  26. package/dist/types/ChainIndexService.d.ts.map +1 -1
  27. package/dist/types/ChainValidator/XyoValidator.d.ts +20 -9
  28. package/dist/types/ChainValidator/XyoValidator.d.ts.map +1 -1
  29. package/dist/types/Election/XyoElectionService.d.ts +2 -2
  30. package/dist/types/Election/XyoElectionService.d.ts.map +1 -1
  31. package/dist/types/Params.d.ts +9 -0
  32. package/dist/types/Params.d.ts.map +1 -0
  33. package/dist/types/PendingTransactions/PendingTransactions.d.ts +7 -5
  34. package/dist/types/PendingTransactions/PendingTransactions.d.ts.map +1 -1
  35. package/dist/types/StakeIntent/XyoStakeIntentService.d.ts +10 -6
  36. package/dist/types/StakeIntent/XyoStakeIntentService.d.ts.map +1 -1
  37. package/dist/types/Staker/Evm/Evm.d.ts +5 -5
  38. package/dist/types/Staker/Evm/Evm.d.ts.map +1 -1
  39. package/dist/types/Staker/Memory/Memory.d.ts +31 -0
  40. package/dist/types/Staker/Memory/Memory.d.ts.map +1 -0
  41. package/dist/types/Staker/Memory/index.d.ts +2 -0
  42. package/dist/types/Staker/Memory/index.d.ts.map +1 -0
  43. package/dist/types/Staker/index.d.ts +1 -0
  44. package/dist/types/Staker/index.d.ts.map +1 -1
  45. package/dist/types/index.d.ts +1 -0
  46. package/dist/types/index.d.ts.map +1 -1
  47. package/package.json +45 -44
  48. package/src/AccountBalance/ChainAccountBalanceServiceV2.ts +33 -0
  49. package/src/AccountBalance/XyoChainAccountBalanceService.ts +23 -19
  50. package/src/AccountBalance/accountBalanceServiceFromArchivist.ts +67 -35
  51. package/src/AccountBalance/index.ts +1 -0
  52. package/src/BaseService.ts +10 -23
  53. package/src/BlockProducer/XyoBlockProducer.ts +53 -30
  54. package/src/BlockReward/EvmBlockRewardService.ts +5 -5
  55. package/src/BlockReward/XyoBlockRewardService.ts +5 -3
  56. package/src/ChainBlockNumberIteration/ChainBlockNumberIterationService.ts +5 -3
  57. package/src/ChainBlockNumberIteration/model/Params.ts +9 -0
  58. package/src/ChainBlockNumberIteration/model/index.ts +1 -0
  59. package/src/ChainIndexService.ts +5 -5
  60. package/src/ChainValidator/XyoValidator.ts +9 -8
  61. package/src/Election/XyoElectionService.ts +5 -7
  62. package/src/Params.ts +9 -0
  63. package/src/PendingTransactions/PendingTransactions.ts +127 -63
  64. package/src/StakeIntent/XyoStakeIntentService.ts +30 -17
  65. package/src/Staker/Evm/Evm.ts +9 -12
  66. package/src/Staker/Memory/Memory.ts +90 -0
  67. package/src/Staker/Memory/index.ts +1 -0
  68. package/src/Staker/index.ts +1 -0
  69. package/src/index.ts +1 -0
@@ -2,72 +2,31 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/AccountBalance/accountBalanceServiceFromArchivist.ts
5
- import { isHash } from "@xylabs/hex";
6
- import { isDefined } from "@xylabs/typeof";
5
+ import { exists } from "@xylabs/exists";
6
+ import { asHash, isHash } from "@xylabs/hex";
7
7
  import { analyzeChain, BalanceAnalyzer, ChainSummaryBalancesSchema, isChainSummaryBalances } from "@xyo-network/chain-analyze";
8
- import { isPositiveBigInt } from "@xyo-network/chain-protocol";
9
- import { isBlockBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
10
- var accountBalanceServiceFromArchivist = /* @__PURE__ */ __name(async (archivist, head) => {
11
- let allAddressesBalances = {
12
- schema: ChainSummaryBalancesSchema,
13
- balances: {},
14
- firstBlock: null,
15
- lastBlock: null
16
- };
17
- const result = {
18
- getBalance: /* @__PURE__ */ __name((address) => {
19
- if (allAddressesBalances === void 0) {
20
- return "00";
21
- }
22
- const signedValue = allAddressesBalances.balances[address] ?? {
23
- positive: "00"
24
- };
25
- return isPositiveBigInt(signedValue) ? signedValue.positive : "00";
26
- }, "getBalance"),
27
- getBalances: /* @__PURE__ */ __name(() => {
28
- return Object.fromEntries(Object.entries(allAddressesBalances.balances).map(([key, value]) => [
29
- key,
30
- isPositiveBigInt(value) ? value.positive : "0"
31
- ]));
32
- }, "getBalances"),
33
- name: "ArchivistAccountBalanceService",
34
- async sync(head2) {
35
- const analysis = await analyzeChain(archivist, [
36
- new BalanceAnalyzer()
37
- ], head2, null, -1n);
38
- allAddressesBalances = analysis.find(isChainSummaryBalances) ?? {
39
- schema: ChainSummaryBalancesSchema,
40
- balances: {},
41
- firstBlock: null,
42
- lastBlock: null
43
- };
44
- return await Promise.resolve();
45
- }
46
- };
47
- if (isHash(head)) {
48
- await result.sync(head);
49
- }
50
- archivist.on("inserted", ({ payloads }) => {
51
- const block = payloads.find((p) => isBlockBoundWitnessWithStorageMeta(p));
52
- if (isDefined(block)) {
53
- void result.sync(block._hash);
54
- }
55
- });
56
- return result;
57
- }, "accountBalanceServiceFromArchivist");
58
-
59
- // src/AccountBalance/XyoChainAccountBalanceService.ts
60
- import { assertEx } from "@xylabs/assert";
61
- import { toHex } from "@xylabs/hex";
62
- import { analyzeChain as analyzeChain2, BalanceAnalyzer as BalanceAnalyzer2, ChainSummaryBalancesSchema as ChainSummaryBalancesSchema2, isChainSummaryBalances as isChainSummaryBalances2 } from "@xyo-network/chain-analyze";
63
- import { toPositiveBigInt } from "@xyo-network/chain-protocol";
64
8
  import { PayloadBuilder } from "@xyo-network/payload-builder";
9
+ import { AttoXL1 as AttoXL12 } from "@xyo-network/xl1-protocol";
10
+ import { parseSignedBigInt } from "@xyo-network/xl1-protocol-sdk";
11
+ import { LRUCache } from "lru-cache";
12
+
13
+ // src/AccountBalance/ChainAccountBalanceServiceV2.ts
14
+ import { creatable as creatable2 } from "@xylabs/creatable";
15
+ import { AttoXL1 } from "@xyo-network/xl1-protocol";
16
+ import { balanceSummary } from "@xyo-network/xl1-protocol-sdk";
65
17
 
66
18
  // src/BaseService.ts
67
- import { BaseEmitter } from "@xylabs/events";
19
+ import { AbstractCreatable, creatable } from "@xylabs/creatable";
68
20
  import { span, spanAsync } from "@xylabs/telemetry";
69
21
  import { Mutex } from "async-mutex";
70
- var BaseService = class extends BaseEmitter {
22
+ function _ts_decorate(decorators, target, key, desc) {
23
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
27
+ }
28
+ __name(_ts_decorate, "_ts_decorate");
29
+ var BaseService = class extends AbstractCreatable {
71
30
  static {
72
31
  __name(this, "BaseService");
73
32
  }
@@ -75,23 +34,14 @@ var BaseService = class extends BaseEmitter {
75
34
  static get singletons() {
76
35
  return globalThis["xyoServiceSingletons"] ?? (globalThis["xyoServiceSingletons"] = {});
77
36
  }
78
- get name() {
79
- return this.constructor.name;
80
- }
81
- static async create(params) {
82
- const result = new this(params);
83
- if (result.name === "BaseService") throw new Error("Cannot create BaseService");
84
- await result.createHandler();
85
- return result;
86
- }
87
37
  static initSingleton(params) {
88
38
  if (this.singletons[this.name]) throw new Error(`Singleton already initialized for ${this.name}`);
89
39
  return this.singletonInitMutex.runExclusive(async () => {
90
40
  return await this.create(params);
91
41
  });
92
42
  }
93
- createHandler() {
94
- return;
43
+ paramsHandler(params) {
44
+ return params;
95
45
  }
96
46
  span(name, fn) {
97
47
  return span(name, fn, this.tracer);
@@ -100,6 +50,9 @@ var BaseService = class extends BaseEmitter {
100
50
  return await spanAsync(name, fn, this.tracer);
101
51
  }
102
52
  };
53
+ BaseService = _ts_decorate([
54
+ creatable()
55
+ ], BaseService);
103
56
  var BaseAccountableService = class extends BaseService {
104
57
  static {
105
58
  __name(this, "BaseAccountableService");
@@ -112,14 +65,123 @@ function creatableService() {
112
65
  }
113
66
  __name(creatableService, "creatableService");
114
67
 
68
+ // src/AccountBalance/ChainAccountBalanceServiceV2.ts
69
+ function _ts_decorate2(decorators, target, key, desc) {
70
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
71
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
72
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
73
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
74
+ }
75
+ __name(_ts_decorate2, "_ts_decorate");
76
+ var ChainAccountBalanceServiceV2 = class extends BaseService {
77
+ static {
78
+ __name(this, "ChainAccountBalanceServiceV2");
79
+ }
80
+ async balances(head, address) {
81
+ const summary = await balanceSummary({
82
+ chainArchivist: this.params.chainArchivist,
83
+ summaryRepository: this.params.summaryRepository,
84
+ head
85
+ });
86
+ const result = {};
87
+ for (const addr of address) {
88
+ result[addr] = AttoXL1(summary[addr] ?? 0n);
89
+ }
90
+ return result;
91
+ }
92
+ };
93
+ ChainAccountBalanceServiceV2 = _ts_decorate2([
94
+ creatable2()
95
+ ], ChainAccountBalanceServiceV2);
96
+
97
+ // src/AccountBalance/accountBalanceServiceFromArchivist.ts
98
+ var accountBalanceServiceFromArchivist = /* @__PURE__ */ __name(async (archivist, head) => {
99
+ let allAddressesBalances = {
100
+ schema: ChainSummaryBalancesSchema,
101
+ balances: {},
102
+ firstBlock: null,
103
+ lastBlock: null
104
+ };
105
+ const result = {
106
+ balances: /* @__PURE__ */ __name(async (head2, addresses) => {
107
+ const sync = /* @__PURE__ */ __name(async (head3) => {
108
+ const analysis = await analyzeChain(archivist, [
109
+ new BalanceAnalyzer()
110
+ ], head3, null, -1n);
111
+ allAddressesBalances = analysis.find(isChainSummaryBalances) ?? {
112
+ schema: ChainSummaryBalancesSchema,
113
+ balances: {},
114
+ firstBlock: null,
115
+ lastBlock: null
116
+ };
117
+ return await Promise.resolve();
118
+ }, "sync");
119
+ await sync(head2);
120
+ const result2 = {};
121
+ for (const addr of addresses) {
122
+ const signedValue = parseSignedBigInt(allAddressesBalances.balances[addr] ?? {
123
+ positive: "00"
124
+ });
125
+ result2[addr] = AttoXL12(signedValue > 0n ? signedValue : 0n);
126
+ }
127
+ return result2;
128
+ }, "balances")
129
+ };
130
+ if (isHash(head)) {
131
+ await result.balances(head, []);
132
+ }
133
+ return result;
134
+ }, "accountBalanceServiceFromArchivist");
135
+ var accountBalanceServiceFromArchivistV2 = /* @__PURE__ */ __name(async (archivist) => {
136
+ const summaryArchivistCache = new LRUCache({
137
+ max: 1e5,
138
+ allowStale: true,
139
+ noDisposeOnSet: false,
140
+ updateAgeOnGet: true
141
+ });
142
+ const summaryRepository = {
143
+ get: /* @__PURE__ */ __name((hashes) => {
144
+ const results = hashes.map((hash) => {
145
+ return summaryArchivistCache.get(hash);
146
+ }).filter(exists);
147
+ return results;
148
+ }, "get"),
149
+ insert: /* @__PURE__ */ __name(async (payloads) => {
150
+ const results = (await PayloadBuilder.addStorageMeta(payloads)).map((payload) => {
151
+ const hash = asHash(payload.hash);
152
+ if (isHash(hash)) {
153
+ summaryArchivistCache.set(hash, payload);
154
+ return payload;
155
+ }
156
+ }).filter(exists);
157
+ return results;
158
+ }, "insert"),
159
+ next: /* @__PURE__ */ __name(() => {
160
+ throw new Error("Not implemented");
161
+ }, "next")
162
+ };
163
+ const service = await ChainAccountBalanceServiceV2.create({
164
+ chainArchivist: archivist,
165
+ summaryRepository
166
+ });
167
+ return service;
168
+ }, "accountBalanceServiceFromArchivistV2");
169
+
115
170
  // src/AccountBalance/XyoChainAccountBalanceService.ts
116
- function _ts_decorate(decorators, target, key, desc) {
171
+ import { assertEx } from "@xylabs/assert";
172
+ import { creatable as creatable3 } from "@xylabs/creatable";
173
+ import { isDefined } from "@xylabs/typeof";
174
+ import { analyzeChain as analyzeChain2, BalanceAnalyzer as BalanceAnalyzer2, ChainSummaryBalancesSchema as ChainSummaryBalancesSchema2, isChainSummaryBalances as isChainSummaryBalances2 } from "@xyo-network/chain-analyze";
175
+ import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
176
+ import { AttoXL1 as AttoXL13 } from "@xyo-network/xl1-protocol";
177
+ import { parseSignedBigInt as parseSignedBigInt2 } from "@xyo-network/xl1-protocol-sdk";
178
+ function _ts_decorate3(decorators, target, key, desc) {
117
179
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
118
180
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
119
181
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
120
182
  return c > 3 && r && Object.defineProperty(target, key, r), r;
121
183
  }
122
- __name(_ts_decorate, "_ts_decorate");
184
+ __name(_ts_decorate3, "_ts_decorate");
123
185
  var XyoChainAccountBalanceService = class extends BaseService {
124
186
  static {
125
187
  __name(this, "XyoChainAccountBalanceService");
@@ -136,21 +198,22 @@ var XyoChainAccountBalanceService = class extends BaseService {
136
198
  get chainArchivist() {
137
199
  return assertEx(this.params.chainArchivist, () => "chainArchivist is required");
138
200
  }
139
- getBalance(address) {
140
- return toPositiveBigInt(this._balances[address] ?? {
141
- positive: toHex(0n)
142
- }).positive;
143
- }
144
- getBalances() {
201
+ balances(head, address) {
145
202
  const result = {};
146
- const entries = Object.entries(this._balances);
147
- for (const [address, balance] of entries) {
148
- result[address] = toPositiveBigInt(balance).positive;
203
+ for (const addr of address) {
204
+ const balance = this._balances[addr];
205
+ const signedBalance = balance ? parseSignedBigInt2(balance) : 0n;
206
+ result[addr] = AttoXL13(signedBalance >= 0n ? signedBalance : 0n);
149
207
  }
150
208
  return result;
151
209
  }
210
+ async startHandler() {
211
+ if (isDefined(this.params.head)) {
212
+ await this.sync(this.params.head);
213
+ }
214
+ }
152
215
  async sync(head) {
153
- const startingBalances = new PayloadBuilder({
216
+ const startingBalances = new PayloadBuilder2({
154
217
  schema: ChainSummaryBalancesSchema2
155
218
  }).fields({
156
219
  balances: this._balances,
@@ -170,19 +233,20 @@ var XyoChainAccountBalanceService = class extends BaseService {
170
233
  if (this._lastBlock === null) this._lastBlock = allAddressesBalances.lastBlock;
171
234
  }
172
235
  };
173
- XyoChainAccountBalanceService = _ts_decorate([
174
- creatableService()
236
+ XyoChainAccountBalanceService = _ts_decorate3([
237
+ creatable3()
175
238
  ], XyoChainAccountBalanceService);
176
239
 
177
240
  // src/BlockProducer/XyoBlockProducer.ts
178
241
  import { assertEx as assertEx3 } from "@xylabs/assert";
179
- import { exists } from "@xylabs/exists";
180
- import { hexToBigInt, toHex as toHex2 } from "@xylabs/hex";
181
- import { isUndefined } from "@xylabs/typeof";
242
+ import { creatable as creatable4 } from "@xylabs/creatable";
243
+ import { exists as exists2 } from "@xylabs/exists";
244
+ import { hexToBigInt, toHex } from "@xylabs/hex";
245
+ import { isDefined as isDefined2 } from "@xylabs/typeof";
182
246
  import { FixedPercentageBlockRewardDiviner, FixedPercentageBlockRewardDivinerConfigSchema } from "@xyo-network/chain-modules";
183
- import { buildBlock } from "@xyo-network/chain-protocol";
184
- import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
185
- import { asBlockBoundWitness, BlockNumberSchema, ChainStakeIntentSchema } from "@xyo-network/xl1-protocol";
247
+ import { buildNextBlock, createDeclarationIntent } from "@xyo-network/chain-protocol";
248
+ import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
249
+ import { asBlockBoundWitness, AttoXL1 as AttoXL14, BlockNumberSchema } from "@xyo-network/xl1-protocol";
186
250
 
187
251
  // src/BlockProducer/generateTransactionFeeTransfers.ts
188
252
  import { assertEx as assertEx2 } from "@xylabs/assert";
@@ -224,24 +288,48 @@ async function generateTransactionFeeTransfers(address, transactions) {
224
288
  __name(generateTransactionFeeTransfers, "generateTransactionFeeTransfers");
225
289
 
226
290
  // src/BlockProducer/XyoBlockProducer.ts
227
- function _ts_decorate2(decorators, target, key, desc) {
291
+ function _ts_decorate4(decorators, target, key, desc) {
228
292
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
229
293
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
230
294
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
231
295
  return c > 3 && r && Object.defineProperty(target, key, r), r;
232
296
  }
233
- __name(_ts_decorate2, "_ts_decorate");
297
+ __name(_ts_decorate4, "_ts_decorate");
234
298
  var DEFAULT_BLOCK_SIZE = 10;
235
- var XYO_PRODUCER_RESTAKE_DURATION = 1e4;
236
- var XYO_PRODUCER_RESTAKE_WINDOW = 500n;
299
+ var XYO_PRODUCER_REDECLARATION_DURATION = 1e4;
300
+ var XYO_PRODUCER_REDECLARATION_WINDOW = 500;
237
301
  var XyoBlockProducer = class _XyoBlockProducer extends BaseService {
238
302
  static {
239
303
  __name(this, "XyoBlockProducer");
240
304
  }
241
305
  _blockRewardDiviner;
306
+ /**
307
+ * The default block size for a block
308
+ */
242
309
  static get DefaultBlockSize() {
243
310
  return DEFAULT_BLOCK_SIZE;
244
311
  }
312
+ /**
313
+ * The amount of time for which the producer will redeclare
314
+ * their intent to continue producing blocks
315
+ */
316
+ static get RedeclarationDuration() {
317
+ return XYO_PRODUCER_REDECLARATION_DURATION;
318
+ }
319
+ /**
320
+ * The number of blocks within which the producer will redeclare
321
+ * their intent to continue producing blocks
322
+ */
323
+ static get RedeclarationWindow() {
324
+ return XYO_PRODUCER_REDECLARATION_WINDOW;
325
+ }
326
+ /**
327
+ * Should the producer should redeclare
328
+ * their intent to continue producing blocks
329
+ */
330
+ static get RedeclareIntent() {
331
+ return isDefined2(process.env.XYO_PRODUCER_SKIP_REDECLARE_INTENT) ? false : true;
332
+ }
245
333
  get address() {
246
334
  return this.account.address;
247
335
  }
@@ -254,8 +342,8 @@ var XyoBlockProducer = class _XyoBlockProducer extends BaseService {
254
342
  get chainArchivist() {
255
343
  return assertEx3(this.params.chainArchivist, () => "chainArchivist is required");
256
344
  }
257
- get chainInfo() {
258
- return assertEx3(this.params.chainInformation, () => "chainInfo is required");
345
+ get chainId() {
346
+ return assertEx3(this.params.chainId, () => "chainId is required");
259
347
  }
260
348
  get electionService() {
261
349
  return assertEx3(this.params.electionService, () => "electionService is required");
@@ -279,9 +367,9 @@ var XyoBlockProducer = class _XyoBlockProducer extends BaseService {
279
367
  return assertEx3(this.params.validateHydratedBlockState, () => "validateHydratedBlockState is required");
280
368
  }
281
369
  async next(head) {
282
- if (head.chain !== this.chainInfo.id) return;
370
+ if (head.chain !== this.chainId) return;
283
371
  const leaders = await this.electionService.getCreatorCommitteeForNextBlock(head);
284
- if (leaders?.[0] !== this.address) return;
372
+ if (!leaders.includes(this.address)) return;
285
373
  return this.proposeNextValidBlock(head);
286
374
  }
287
375
  async getBlockRewardTransfer(block) {
@@ -296,8 +384,8 @@ var XyoBlockProducer = class _XyoBlockProducer extends BaseService {
296
384
  }
297
385
  });
298
386
  }
299
- const blockHex = assertEx3(toHex2(block), () => "Failed to convert block to hex");
300
- const blockId = new PayloadBuilder2({
387
+ const blockHex = assertEx3(toHex(block), () => "Failed to convert block to hex");
388
+ const blockId = new PayloadBuilder3({
301
389
  schema: BlockNumberSchema
302
390
  }).fields({
303
391
  block: blockHex
@@ -314,24 +402,15 @@ var XyoBlockProducer = class _XyoBlockProducer extends BaseService {
314
402
  * @returns
315
403
  */
316
404
  async getProducerRedeclaration(head) {
317
- const redeclareIntent = process.env.XYO_PRODUCER_REDECLARE_INTENT;
318
- if (isUndefined(redeclareIntent)) return;
405
+ if (!_XyoBlockProducer.RedeclareIntent) return;
319
406
  const ranges = await this.stakeIntentService.getDeclaredCandidateRanges(this.address, "producer");
320
407
  const lastRange = ranges.toSorted((a, b) => a[1] > b[1] ? 1 : -1).at(-1);
321
408
  if (!lastRange) return;
322
409
  const [, currentDeclarationEnd] = lastRange;
323
410
  const currentBlock = head.block;
324
411
  const timeToProducerExpiration = currentDeclarationEnd - currentBlock;
325
- if (timeToProducerExpiration > XYO_PRODUCER_RESTAKE_WINDOW) return;
326
- const intent = new PayloadBuilder2({
327
- schema: ChainStakeIntentSchema
328
- }).fields({
329
- from: this.address,
330
- intent: "producer",
331
- nbf: currentBlock,
332
- exp: currentBlock + XYO_PRODUCER_RESTAKE_DURATION
333
- }).build();
334
- return intent;
412
+ if (timeToProducerExpiration > _XyoBlockProducer.RedeclarationWindow) return;
413
+ return createDeclarationIntent(this.address, "producer", currentBlock, currentBlock + _XyoBlockProducer.RedeclarationDuration);
335
414
  }
336
415
  async proposeNextValidBlock(head, validateBalances = false) {
337
416
  return await this.spanAsync("proposeNextValidBlock", async () => {
@@ -346,12 +425,15 @@ var XyoBlockProducer = class _XyoBlockProducer extends BaseService {
346
425
  if (rewardTransferPayload) blockPayloads.push(rewardTransferPayload);
347
426
  const transactionTransfers = await generateTransactionFeeTransfers(this.address, nextBlockTransactions);
348
427
  const fundedTransfers = [];
349
- const fundedNextBlockTransactions = nextBlockTransactions.map((tx) => {
428
+ const fundedNextBlockTransactions = (await Promise.all(nextBlockTransactions.map(async (tx) => {
350
429
  const transfer = transactionTransfers.find((txTransfer) => txTransfer.from === tx[0].from);
351
430
  if (!transfer) return;
352
431
  const totalTransferCost = Object.values(transfer?.transfers).reduce((acc, t) => acc + hexToBigInt(t ?? "00"), 0n);
353
432
  if (validateBalances) {
354
- if (hexToBigInt(this.balanceService.getBalance(transfer.from)) >= totalTransferCost) {
433
+ const balance = (await this.balanceService.balances(head._hash, [
434
+ transfer.from
435
+ ]))[transfer.from] ?? AttoXL14(0n);
436
+ if (balance >= totalTransferCost) {
355
437
  fundedTransfers.push(transfer);
356
438
  return tx;
357
439
  }
@@ -359,13 +441,13 @@ var XyoBlockProducer = class _XyoBlockProducer extends BaseService {
359
441
  fundedTransfers.push(transfer);
360
442
  return tx;
361
443
  }
362
- }).filter(exists);
444
+ }))).filter(exists2);
363
445
  blockPayloads.push(...fundedTransfers);
364
- const block = await buildBlock(head, fundedNextBlockTransactions, blockPayloads, [
446
+ const block = await buildNextBlock(head, fundedNextBlockTransactions, blockPayloads, [
365
447
  this.account
366
448
  ]);
367
449
  this.logger?.warn(`buildBlock: ${block[0].block} with ${block[1].length} payloads`);
368
- const errors = await this.validateHydratedBlockState(block, this.chainInfo.id, {
450
+ const errors = await this.validateHydratedBlockState(block, this.chainId, {
369
451
  accountBalance: this.balanceService
370
452
  });
371
453
  if (errors.length > 0) {
@@ -378,21 +460,22 @@ var XyoBlockProducer = class _XyoBlockProducer extends BaseService {
378
460
  });
379
461
  }
380
462
  };
381
- XyoBlockProducer = _ts_decorate2([
382
- creatableService()
463
+ XyoBlockProducer = _ts_decorate4([
464
+ creatable4()
383
465
  ], XyoBlockProducer);
384
466
 
385
467
  // src/BlockReward/EvmBlockRewardService.ts
386
468
  import { assertEx as assertEx4 } from "@xylabs/assert";
469
+ import { creatable as creatable5 } from "@xylabs/creatable";
387
470
  import { toEthAddress } from "@xyo-network/chain-ethereum";
388
471
  import { XyoChainRewards__factory as XyoChainRewardsFactory } from "@xyo-network/typechain";
389
- function _ts_decorate3(decorators, target, key, desc) {
472
+ function _ts_decorate5(decorators, target, key, desc) {
390
473
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
391
474
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
392
475
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
393
476
  return c > 3 && r && Object.defineProperty(target, key, r), r;
394
477
  }
395
- __name(_ts_decorate3, "_ts_decorate");
478
+ __name(_ts_decorate5, "_ts_decorate");
396
479
  var EvmBlockRewardService = class extends BaseService {
397
480
  static {
398
481
  __name(this, "EvmBlockRewardService");
@@ -421,21 +504,22 @@ var EvmBlockRewardService = class extends BaseService {
421
504
  return await contract.calcBlockReward(blockNumber);
422
505
  }
423
506
  };
424
- EvmBlockRewardService = _ts_decorate3([
425
- creatableService()
507
+ EvmBlockRewardService = _ts_decorate5([
508
+ creatable5()
426
509
  ], EvmBlockRewardService);
427
510
 
428
511
  // src/BlockReward/XyoBlockRewardService.ts
429
512
  import { assertEx as assertEx5 } from "@xylabs/assert";
513
+ import { creatable as creatable6 } from "@xylabs/creatable";
430
514
  import { toFixedPoint } from "@xylabs/decimal-precision";
431
515
  import { rewardFromBlockNumber } from "@xyo-network/chain-protocol";
432
- function _ts_decorate4(decorators, target, key, desc) {
516
+ function _ts_decorate6(decorators, target, key, desc) {
433
517
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
434
518
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
435
519
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
436
520
  return c > 3 && r && Object.defineProperty(target, key, r), r;
437
521
  }
438
- __name(_ts_decorate4, "_ts_decorate");
522
+ __name(_ts_decorate6, "_ts_decorate");
439
523
  function _ts_metadata(k, v) {
440
524
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
441
525
  }
@@ -477,8 +561,8 @@ var XyoBlockRewardService = class extends BaseService {
477
561
  return this.rewardFromBlockNumber(blockNumber, this.initialReward, this.stepSize, this.stepFactorNumerator, this.stepFactorDenominator, this.minRewardPerBlock, this.creatorReward);
478
562
  }
479
563
  };
480
- XyoBlockRewardService = _ts_decorate4([
481
- creatableService(),
564
+ XyoBlockRewardService = _ts_decorate6([
565
+ creatable6(),
482
566
  _ts_metadata("design:type", Function),
483
567
  _ts_metadata("design:paramtypes", [
484
568
  typeof Partial === "undefined" ? Object : Partial
@@ -487,24 +571,22 @@ XyoBlockRewardService = _ts_decorate4([
487
571
 
488
572
  // src/ChainBlockNumberIteration/ChainBlockNumberIterationService.ts
489
573
  import { assertEx as assertEx6 } from "@xylabs/assert";
490
- import { isDefined as isDefined2, isNull } from "@xylabs/typeof";
491
- import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
574
+ import { isDefined as isDefined3, isNull } from "@xylabs/typeof";
575
+ import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
492
576
  import { asBlockBoundWitness as asBlockBoundWitness2, isBlockBoundWitness } from "@xyo-network/xl1-protocol";
493
- import { LRUCache } from "lru-cache";
577
+ import { LRUCache as LRUCache2 } from "lru-cache";
494
578
  var ChainBlockNumberIterationService = class extends BaseService {
495
579
  static {
496
580
  __name(this, "ChainBlockNumberIterationService");
497
581
  }
498
- _blocksByBlockNumber = new LRUCache({
582
+ _blocksByBlockNumber = new LRUCache2({
499
583
  max: 1e4
500
584
  });
501
585
  get chainArchivist() {
502
586
  return assertEx6(this.params.chainArchivist);
503
587
  }
504
- get chainIdentification() {
505
- return {
506
- id: assertEx6(this.params.head?.chain)
507
- };
588
+ get chainId() {
589
+ return assertEx6(this.params.head?.chain);
508
590
  }
509
591
  async get(block) {
510
592
  const head = await this.head();
@@ -512,11 +594,11 @@ var ChainBlockNumberIterationService = class extends BaseService {
512
594
  const cached = this._blocksByBlockNumber.get(block);
513
595
  if (cached) return cached;
514
596
  const startingBlock = head;
515
- const currentBlockHash = await PayloadBuilder3.hash(startingBlock);
597
+ const currentBlockHash = await PayloadBuilder4.hash(startingBlock);
516
598
  let currentBlock = (await this.chainArchivist.get([
517
599
  currentBlockHash
518
600
  ])).at(0);
519
- while (isDefined2(currentBlock)) {
601
+ while (isDefined3(currentBlock)) {
520
602
  assertEx6(asBlockBoundWitness2(currentBlock), () => `Expected hash to be a block bound witness [${currentBlock?._hash}]`);
521
603
  if (isBlockBoundWitness(currentBlock)) {
522
604
  this._blocksByBlockNumber.set(currentBlock.block, currentBlock);
@@ -544,7 +626,7 @@ var ChainBlockNumberIterationService = class extends BaseService {
544
626
  // and then communicate via method name and documentation
545
627
  async previous(block = void 0, count = 1) {
546
628
  const results = [];
547
- let currentBlock = isDefined2(block) ? await this.get(block) : await this.head();
629
+ let currentBlock = isDefined3(block) ? await this.get(block) : await this.head();
548
630
  while (currentBlock && results.length < count) {
549
631
  if (isBlockBoundWitness(currentBlock)) {
550
632
  results.push(currentBlock);
@@ -555,7 +637,7 @@ var ChainBlockNumberIterationService = class extends BaseService {
555
637
  ]);
556
638
  currentBlock = asBlockBoundWitness2(nextBlock[0]);
557
639
  } else {
558
- const hash = PayloadBuilder3.hash(currentBlock);
640
+ const hash = PayloadBuilder4.hash(currentBlock);
559
641
  assertEx6(asBlockBoundWitness2(currentBlock), () => `Expected hash to be a block bound witness [${hash}]`);
560
642
  }
561
643
  }
@@ -574,13 +656,14 @@ var ChainBlockNumberIterationService = class extends BaseService {
574
656
 
575
657
  // src/ChainValidator/XyoValidator.ts
576
658
  import { assertEx as assertEx7 } from "@xylabs/assert";
577
- function _ts_decorate5(decorators, target, key, desc) {
659
+ import { creatable as creatable7 } from "@xylabs/creatable";
660
+ function _ts_decorate7(decorators, target, key, desc) {
578
661
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
579
662
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
580
663
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
581
664
  return c > 3 && r && Object.defineProperty(target, key, r), r;
582
665
  }
583
- __name(_ts_decorate5, "_ts_decorate");
666
+ __name(_ts_decorate7, "_ts_decorate");
584
667
  var XyoValidator = class extends BaseService {
585
668
  static {
586
669
  __name(this, "XyoValidator");
@@ -595,7 +678,7 @@ var XyoValidator = class extends BaseService {
595
678
  return assertEx7(this.params.chainArchivist, () => "chainArchivist is required");
596
679
  }
597
680
  get chainInfo() {
598
- return assertEx7(this.params.chainInformation, () => "chainInfo is required");
681
+ return assertEx7(this.params.chainId, () => "chainInfo is required");
599
682
  }
600
683
  get electionService() {
601
684
  return assertEx7(this.params.electionService, () => "electionService is required");
@@ -618,32 +701,26 @@ var XyoValidator = class extends BaseService {
618
701
  return await Promise.resolve(true);
619
702
  }
620
703
  };
621
- XyoValidator = _ts_decorate5([
622
- creatableService()
704
+ XyoValidator = _ts_decorate7([
705
+ creatable7()
623
706
  ], XyoValidator);
624
707
 
625
708
  // src/Election/XyoElectionService.ts
626
709
  import { assertEx as assertEx8 } from "@xylabs/assert";
710
+ import { creatable as creatable8 } from "@xylabs/creatable";
627
711
  import { hexToLast4BytesInt, shuffleWithSeed } from "@xyo-network/chain-utils";
628
- import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
629
- function _ts_decorate6(decorators, target, key, desc) {
712
+ import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
713
+ function _ts_decorate8(decorators, target, key, desc) {
630
714
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
631
715
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
632
716
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
633
717
  return c > 3 && r && Object.defineProperty(target, key, r), r;
634
718
  }
635
- __name(_ts_decorate6, "_ts_decorate");
636
- function _ts_metadata2(k, v) {
637
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
638
- }
639
- __name(_ts_metadata2, "_ts_metadata");
719
+ __name(_ts_decorate8, "_ts_decorate");
640
720
  var XyoElectionService = class extends BaseService {
641
721
  static {
642
722
  __name(this, "XyoElectionService");
643
723
  }
644
- constructor(params) {
645
- super(params);
646
- }
647
724
  get chainIterator() {
648
725
  return assertEx8(this.params.chainIterator, () => "No chain iterator");
649
726
  }
@@ -657,7 +734,7 @@ var XyoElectionService = class extends BaseService {
657
734
  return await this.spanAsync("getCreatorCommitteeForNextBlock", async () => {
658
735
  const nextBlock = current.block + 1;
659
736
  const candidates = await this.stakeIntentService.getDeclaredCandidatesForBlock(nextBlock, "producer");
660
- const previousBlockHash = await PayloadBuilder4.hash(current);
737
+ const previousBlockHash = await PayloadBuilder5.hash(current);
661
738
  return this.generateCreatorCommittee(candidates, previousBlockHash);
662
739
  });
663
740
  }
@@ -668,32 +745,30 @@ var XyoElectionService = class extends BaseService {
668
745
  return creatorArray.slice(0, maxSize);
669
746
  }
670
747
  };
671
- XyoElectionService = _ts_decorate6([
672
- creatableService(),
673
- _ts_metadata2("design:type", Function),
674
- _ts_metadata2("design:paramtypes", [
675
- typeof XyoElectionServicesParams === "undefined" ? Object : XyoElectionServicesParams
676
- ])
748
+ XyoElectionService = _ts_decorate8([
749
+ creatable8()
677
750
  ], XyoElectionService);
678
751
 
679
752
  // src/PendingTransactions/PendingTransactions.ts
680
753
  import { ValueType } from "@opentelemetry/api";
681
- import { filterAsync } from "@xylabs/array";
754
+ import { filterAs, filterAsync } from "@xylabs/array";
682
755
  import { assertEx as assertEx9 } from "@xylabs/assert";
683
- import { exists as exists2 } from "@xylabs/exists";
756
+ import { creatable as creatable9 } from "@xylabs/creatable";
757
+ import { exists as exists3 } from "@xylabs/exists";
684
758
  import { forget } from "@xylabs/forget";
759
+ import { isDefined as isDefined4, isUndefined } from "@xylabs/typeof";
685
760
  import { MemoryArchivist } from "@xyo-network/archivist-memory";
761
+ import { findMostRecentBlock } from "@xyo-network/chain-protocol";
686
762
  import { globalAttributes } from "@xyo-network/chain-telemetry";
687
763
  import { validateTransaction } from "@xyo-network/chain-validation";
688
- import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
689
- import { asTransactionBoundWitnessWithStorageMeta as asTransactionBoundWitnessWithStorageMeta2, isTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
764
+ import { asBlockBoundWitnessWithHashStorageMeta, isTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
690
765
  import { Mutex as Mutex2 } from "async-mutex";
691
766
 
692
767
  // src/PendingTransactions/bundledPayloadToHydratedTransaction.ts
693
- import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
768
+ import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
694
769
  import { asTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
695
770
  var bundledPayloadToHydratedTransaction = /* @__PURE__ */ __name(async (payload) => {
696
- const withStorageMeta = await PayloadBuilder5.addStorageMeta(payload.payloads);
771
+ const withStorageMeta = await PayloadBuilder6.addStorageMeta(payload.payloads);
697
772
  const tx = asTransactionBoundWitnessWithStorageMeta(withStorageMeta.find((p) => p._hash === payload.root));
698
773
  if (tx) {
699
774
  return [
@@ -704,7 +779,7 @@ var bundledPayloadToHydratedTransaction = /* @__PURE__ */ __name(async (payload)
704
779
  }, "bundledPayloadToHydratedTransaction");
705
780
 
706
781
  // src/PendingTransactions/hydratedTransactionToPayloadBundle.ts
707
- import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
782
+ import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
708
783
  import { PayloadBundleSchema } from "@xyo-network/payload-model";
709
784
  import { flattenHydratedTransaction } from "@xyo-network/xl1-protocol-sdk";
710
785
  var hydratedTransactionToPayloadBundle = /* @__PURE__ */ __name((transaction) => {
@@ -712,8 +787,8 @@ var hydratedTransactionToPayloadBundle = /* @__PURE__ */ __name((transaction) =>
712
787
  return bundle(root, transaction);
713
788
  }, "hydratedTransactionToPayloadBundle");
714
789
  var bundle = /* @__PURE__ */ __name((root, transaction) => {
715
- const payloads = flattenHydratedTransaction(transaction).flatMap((p) => PayloadBuilder6.omitStorageMeta(p));
716
- return new PayloadBuilder6({
790
+ const payloads = flattenHydratedTransaction(transaction).flatMap((p) => PayloadBuilder7.omitStorageMeta(p));
791
+ return new PayloadBuilder7({
717
792
  schema: PayloadBundleSchema
718
793
  }).fields({
719
794
  payloads,
@@ -722,13 +797,13 @@ var bundle = /* @__PURE__ */ __name((root, transaction) => {
722
797
  }, "bundle");
723
798
 
724
799
  // src/PendingTransactions/PendingTransactions.ts
725
- function _ts_decorate7(decorators, target, key, desc) {
800
+ function _ts_decorate9(decorators, target, key, desc) {
726
801
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
727
802
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
728
803
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
729
804
  return c > 3 && r && Object.defineProperty(target, key, r), r;
730
805
  }
731
- __name(_ts_decorate7, "_ts_decorate");
806
+ __name(_ts_decorate9, "_ts_decorate");
732
807
  globalAttributes.setAttribute("XyoPendingTransactionsService:status", "unknown");
733
808
  var XyoPendingTransactionsService = class _XyoPendingTransactionsService extends BaseService {
734
809
  static {
@@ -744,13 +819,9 @@ var XyoPendingTransactionsService = class _XyoPendingTransactionsService extends
744
819
  */
745
820
  ReadTransactions: 3,
746
821
  /**
747
- * Priority for removing rejected transactions
822
+ * Priority for removing finalized/expired/rejected transactions
748
823
  */
749
- RemoveRejectedTransactions: 2,
750
- /**
751
- * Priority for removing finalized transactions
752
- */
753
- RemoveFinalizedTransactions: 1
824
+ PurgeTransactions: 1
754
825
  };
755
826
  /**
756
827
  * A mutex to ensure that the counting the number of pending transactions is
@@ -780,8 +851,8 @@ var XyoPendingTransactionsService = class _XyoPendingTransactionsService extends
780
851
  get chainArchivist() {
781
852
  return assertEx9(this.params.chainArchivist, () => "No completed blocks with data archivist");
782
853
  }
783
- get chainIdentification() {
784
- return assertEx9(this.params.chainIdentification, () => "No chain id");
854
+ get chainId() {
855
+ return assertEx9(this.params.chainId, () => "No chain id");
785
856
  }
786
857
  get pendingBundledTransactionsArchivist() {
787
858
  return assertEx9(this.params.pendingBundledTransactionsArchivist, () => "No pending bundled transactions archivist");
@@ -801,14 +872,16 @@ var XyoPendingTransactionsService = class _XyoPendingTransactionsService extends
801
872
  this._curatedPendingBundledTransactionsArchivist = await MemoryArchivist.create({
802
873
  account: "random"
803
874
  });
804
- this.pendingBundledTransactionsArchivist.on("inserted", async ({ payloads }) => {
805
- await this.insertNewTransactions(payloads);
875
+ this.pendingBundledTransactionsArchivist.on("inserted", ({ payloads }) => {
876
+ forget(this.insertNewTransactions(payloads));
806
877
  });
807
878
  this.chainArchivist.on("inserted", ({ payloads }) => {
808
879
  this.markAnyIncludedTransactionsForRemoval(payloads);
880
+ forget(this.cleanupWorker());
809
881
  });
810
882
  this.rejectedTransactionsArchivist.on("inserted", ({ payloads }) => {
811
883
  this.markAnyIncludedTransactionsForRemoval(payloads);
884
+ forget(this.cleanupWorker());
812
885
  });
813
886
  const pendingTransactionsCounter = this.meter?.createObservableUpDownCounter("xyo_pending_transactions_counter", {
814
887
  description: "The current number of pending transactions",
@@ -823,32 +896,25 @@ var XyoPendingTransactionsService = class _XyoPendingTransactionsService extends
823
896
  async getPendingTransactions(head, limit) {
824
897
  return await this.spanAsync("getPendingTransactions", async () => {
825
898
  return await this._updateCuratedPendingTransactionsArchivistMutex.runExclusive(async () => {
899
+ let [lastHead] = filterAs(await this.chainArchivist.get([
900
+ head
901
+ ]), asBlockBoundWitnessWithHashStorageMeta);
902
+ if (isUndefined(lastHead)) return [];
903
+ await this.pruneCuratedPendingTransactionsArchivist(lastHead._hash);
826
904
  const foundPendingTransactions = [];
827
- const foundPendingTransactionsToDeleteHashes = [];
828
905
  let cursor;
829
906
  while (foundPendingTransactions.length < limit) {
830
- const payloads = await this.pendingBundledTransactionsLocalArchivist.next({
907
+ const pendingBundledTransactions = await this.pendingBundledTransactionsLocalArchivist.next({
831
908
  limit: 100,
832
909
  order: "asc",
833
910
  cursor
834
911
  });
835
- if (payloads.length === 0) break;
836
- cursor = payloads.at(-1)?._sequence;
837
- const deletedTransactionBundles = payloads.filter((tx) => this._removablePendingTransactionHashes.has(tx.root));
838
- foundPendingTransactionsToDeleteHashes.push(...deletedTransactionBundles.map((tx) => tx._hash).filter(exists2));
839
- const undeletedTransactionBundles = payloads.filter((tx) => !this._removablePendingTransactionHashes.has(tx.root));
840
- const transactions = (await Promise.all(undeletedTransactionBundles.map((p) => bundledPayloadToHydratedTransaction(p)))).filter(exists2);
841
- foundPendingTransactions.push(...transactions);
842
- }
843
- await this.pendingBundledTransactionsLocalArchivist.delete(foundPendingTransactionsToDeleteHashes);
844
- for (const hash of foundPendingTransactionsToDeleteHashes) {
845
- this._removablePendingTransactionHashes.delete(hash);
846
- }
847
- if (foundPendingTransactionsToDeleteHashes.length > 0) {
848
- this.logger?.log(`foundPendingTransactionsToDeleteHashes: Found ${foundPendingTransactionsToDeleteHashes.length} deletable transactions`);
849
- for (const hash of foundPendingTransactionsToDeleteHashes) {
850
- this.logger?.log(hash);
851
- }
912
+ if (pendingBundledTransactions.length === 0) break;
913
+ cursor = pendingBundledTransactions.at(-1)?._sequence;
914
+ const undeletedTransactionBundles = pendingBundledTransactions.filter((tx) => !this._removablePendingTransactionHashes.has(tx.root));
915
+ const transactions = (await Promise.all(undeletedTransactionBundles.map((p) => bundledPayloadToHydratedTransaction(p)))).filter(exists3);
916
+ const activeTransactions = transactions.filter(isTransactionActive(lastHead.block + 1));
917
+ foundPendingTransactions.push(...activeTransactions);
852
918
  }
853
919
  if (foundPendingTransactions.length > 0) {
854
920
  this.logger?.log(`getPendingTransactions: Found ${foundPendingTransactions.length} pending transactions`);
@@ -860,6 +926,12 @@ var XyoPendingTransactionsService = class _XyoPendingTransactionsService extends
860
926
  }, _XyoPendingTransactionsService.MutexPriority.ReadTransactions);
861
927
  });
862
928
  }
929
+ async cleanupWorker() {
930
+ return await this._updateCuratedPendingTransactionsArchivistMutex.runExclusive(async () => {
931
+ const lastHead = await findMostRecentBlock(this.chainArchivist);
932
+ if (isDefined4(lastHead)) await this.pruneCuratedPendingTransactionsArchivist(lastHead._hash);
933
+ }, _XyoPendingTransactionsService.MutexPriority.PurgeTransactions);
934
+ }
863
935
  async countPendingTransactions() {
864
936
  if (this._countPendingTransactionsMutex.isLocked()) return;
865
937
  await this._countPendingTransactionsMutex.runExclusive(async () => {
@@ -881,9 +953,9 @@ var XyoPendingTransactionsService = class _XyoPendingTransactionsService extends
881
953
  const unprocessedTransactions = await this.filterAlreadyFinalizedTransactions(payloads);
882
954
  const hydratedUnprocessedTransactions = (await Promise.all(unprocessedTransactions.map(async (tx) => {
883
955
  return await bundledPayloadToHydratedTransaction(tx);
884
- }))).filter(exists2);
956
+ }))).filter(exists3);
885
957
  const validTransactions = await filterAsync(hydratedUnprocessedTransactions, async (tx) => {
886
- const errors = await validateTransaction(tx, this.chainIdentification.id);
958
+ const errors = await validateTransaction(tx, this.chainId);
887
959
  if (errors.length > 0) {
888
960
  this.logger?.warn("validateTransaction", errors);
889
961
  }
@@ -908,39 +980,69 @@ var XyoPendingTransactionsService = class _XyoPendingTransactionsService extends
908
980
  this._removablePendingTransactionHashes.add(hash);
909
981
  }
910
982
  }
911
- async removeBundledTransactions(bundledPayloads, priority) {
912
- return await this.spanAsync(priority, async () => {
913
- return await this._updateCuratedPendingTransactionsArchivistMutex.runExclusive(async () => {
914
- const bundledTransactions = (await Promise.all(bundledPayloads.map(async (payload) => {
915
- const withStorageMeta = await PayloadBuilder7.addStorageMeta(payload.payloads);
916
- const tx = asTransactionBoundWitnessWithStorageMeta2(withStorageMeta.find((p) => p._hash === payload.root));
917
- return tx !== void 0 && payload._hash !== void 0 ? tx : void 0;
918
- }))).filter(exists2);
919
- await this.pendingBundledTransactionsLocalArchivist.delete(bundledTransactions.map((btx) => btx._hash));
920
- }, _XyoPendingTransactionsService.MutexPriority[priority]);
983
+ async pruneCuratedPendingTransactionsArchivist(head) {
984
+ return await this.spanAsync("pruneCuratedPendingTransactionsArchivist", async () => {
985
+ const foundPendingTransactionsToDeleteHashes = [];
986
+ let cursor;
987
+ let [lastHead] = filterAs(await this.chainArchivist.get([
988
+ head
989
+ ]), asBlockBoundWitnessWithHashStorageMeta);
990
+ while (isDefined4(lastHead)) {
991
+ const pendingBundledTransactions = await this.pendingBundledTransactionsLocalArchivist.next({
992
+ limit: 100,
993
+ order: "asc",
994
+ cursor
995
+ });
996
+ if (pendingBundledTransactions.length === 0) {
997
+ break;
998
+ }
999
+ cursor = pendingBundledTransactions.at(-1)?._sequence;
1000
+ const deletedTransactionBundles = pendingBundledTransactions.filter((tx) => this._removablePendingTransactionHashes.has(tx.root));
1001
+ foundPendingTransactionsToDeleteHashes.push(...deletedTransactionBundles.map((tx) => tx._hash).filter(exists3));
1002
+ const undeletedTransactionBundles = pendingBundledTransactions.filter((tx) => !this._removablePendingTransactionHashes.has(tx.root));
1003
+ const transactions = (await Promise.all(undeletedTransactionBundles.map((p) => bundledPayloadToHydratedTransaction(p)))).filter(exists3);
1004
+ const expiredTransactions = transactions.filter(isTransactionExpired(lastHead.block + 1));
1005
+ const expiredBundleHashes = expiredTransactions.map((expiredHydratedTx) => (
1006
+ // Find the corresponding payload bundle hash for the expired transaction
1007
+ pendingBundledTransactions.find((bundledTx) => bundledTx.root === expiredHydratedTx[0]._hash)?._hash
1008
+ )).filter(exists3);
1009
+ foundPendingTransactionsToDeleteHashes.push(...expiredBundleHashes);
1010
+ }
1011
+ const deletedHashes = await this.pendingBundledTransactionsLocalArchivist.delete(foundPendingTransactionsToDeleteHashes);
1012
+ for (const payload of deletedHashes) {
1013
+ this._removablePendingTransactionHashes.delete(payload._hash);
1014
+ }
1015
+ if (deletedHashes.length > 0) {
1016
+ this.logger?.log(`foundPendingTransactionsToDeleteHashes: Found ${deletedHashes.length} deletable transactions`);
1017
+ for (const payload of deletedHashes) {
1018
+ this.logger?.log(payload._hash);
1019
+ }
1020
+ }
921
1021
  });
922
1022
  }
923
1023
  };
924
- XyoPendingTransactionsService = _ts_decorate7([
925
- creatableService()
1024
+ XyoPendingTransactionsService = _ts_decorate9([
1025
+ creatable9()
926
1026
  ], XyoPendingTransactionsService);
1027
+ var isTransactionExpired = /* @__PURE__ */ __name((block) => ([txBw]) => txBw.exp < block, "isTransactionExpired");
1028
+ var isTransactionActive = /* @__PURE__ */ __name((block) => ([txBw]) => txBw.nbf <= block && txBw.exp >= block, "isTransactionActive");
927
1029
 
928
1030
  // src/StakeIntent/lib/getBlockSignedStakeDeclarations.ts
929
- import { filterAs } from "@xylabs/array";
930
- import { exists as exists3 } from "@xylabs/exists";
1031
+ import { filterAs as filterAs2 } from "@xylabs/array";
1032
+ import { exists as exists4 } from "@xylabs/exists";
931
1033
  import { asOptionalBoundWitness } from "@xyo-network/boundwitness-model";
932
1034
  import { payloadSchemasContains } from "@xyo-network/boundwitness-validator";
933
1035
  import { BoundWitnessWrapper } from "@xyo-network/boundwitness-wrapper";
934
- import { asChainStakeIntent, ChainStakeIntentSchema as ChainStakeIntentSchema2 } from "@xyo-network/xl1-protocol";
1036
+ import { asChainStakeIntent, ChainStakeIntentSchema } from "@xyo-network/xl1-protocol";
935
1037
  var getBlockSignedStakeDeclarations = /* @__PURE__ */ __name(async (block, archivist, intent) => {
936
1038
  const blockData = await archivist.get(block.payload_hashes);
937
- const bwsFromBlock = filterAs(blockData, asOptionalBoundWitness);
938
- const bwsFromBlockWithDeclarations = bwsFromBlock.filter((bw) => payloadSchemasContains(bw, ChainStakeIntentSchema2));
1039
+ const bwsFromBlock = filterAs2(blockData, asOptionalBoundWitness);
1040
+ const bwsFromBlockWithDeclarations = bwsFromBlock.filter((bw) => payloadSchemasContains(bw, ChainStakeIntentSchema));
939
1041
  const validBlockBwsWithDeclarations = await filterToValidSignedBoundWitnesses(bwsFromBlockWithDeclarations);
940
1042
  return (await Promise.all(validBlockBwsWithDeclarations.map(async (bw) => {
941
- const stakeIntentHashes = validBlockBwsWithDeclarations.flatMap(mapBoundWitnessToStakeIntentHashes).filter(exists3);
1043
+ const stakeIntentHashes = validBlockBwsWithDeclarations.flatMap(mapBoundWitnessToStakeIntentHashes).filter(exists4);
942
1044
  const payloads = await archivist.get(stakeIntentHashes);
943
- const stakeIntents = filterAs(payloads, asChainStakeIntent).filter((p) => p.intent === intent).filter((p) => bw.addresses.includes(p.from));
1045
+ const stakeIntents = filterAs2(payloads, asChainStakeIntent).filter((p) => p.intent === intent).filter((p) => bw.addresses.includes(p.from));
944
1046
  return stakeIntents;
945
1047
  }))).flat();
946
1048
  }, "getBlockSignedStakeDeclarations");
@@ -949,30 +1051,28 @@ var filterToValidSignedBoundWitnesses = /* @__PURE__ */ __name(async (bws) => {
949
1051
  return bws.filter((_, index) => validBwIndexes[index]);
950
1052
  }, "filterToValidSignedBoundWitnesses");
951
1053
  var mapBoundWitnessToStakeIntentHashes = /* @__PURE__ */ __name((bw) => {
952
- return bw.payload_schemas.map((schema, index) => schema === ChainStakeIntentSchema2 ? bw.payload_hashes[index] : void 0);
1054
+ return bw.payload_schemas.map((schema, index) => schema === ChainStakeIntentSchema ? bw.payload_hashes[index] : void 0);
953
1055
  }, "mapBoundWitnessToStakeIntentHashes");
954
1056
 
955
1057
  // src/StakeIntent/XyoStakeIntentService.ts
956
- import { filterAs as filterAs2 } from "@xylabs/array";
1058
+ import { filterAs as filterAs3 } from "@xylabs/array";
957
1059
  import { assertEx as assertEx10 } from "@xylabs/assert";
1060
+ import { creatable as creatable10 } from "@xylabs/creatable";
958
1061
  import { asAddress } from "@xylabs/hex";
1062
+ import { isDefined as isDefined5, isUndefined as isUndefined2 } from "@xylabs/typeof";
959
1063
  import { analyzeChain as analyzeChain3, ChainStakeIntentAnalyzer, isChainSummaryStakeIntent } from "@xyo-network/chain-analyze";
960
1064
  import { DEFAULT_FIND_FIRST_MATCHING_NEXT_OPTIONS, findFirstMatching, IntervalMap } from "@xyo-network/chain-utils";
961
1065
  import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
962
1066
  import { asBlockBoundWitness as asBlockBoundWitness3, asBlockBoundWitnessWithStorageMeta, asChainIndexingServiceStateWithStorageMeta, asChainStakeIntent as asChainStakeIntent2, ChainIndexingServiceStateSchema, isChainIndexingServiceState } from "@xyo-network/xl1-protocol";
963
1067
  import { Mutex as Mutex3 } from "async-mutex";
964
- import { LRUCache as LRUCache2 } from "lru-cache";
965
- function _ts_decorate8(decorators, target, key, desc) {
1068
+ import { LRUCache as LRUCache3 } from "lru-cache";
1069
+ function _ts_decorate10(decorators, target, key, desc) {
966
1070
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
967
1071
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
968
1072
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
969
1073
  return c > 3 && r && Object.defineProperty(target, key, r), r;
970
1074
  }
971
- __name(_ts_decorate8, "_ts_decorate");
972
- function _ts_metadata3(k, v) {
973
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
974
- }
975
- __name(_ts_metadata3, "_ts_metadata");
1075
+ __name(_ts_decorate10, "_ts_decorate");
976
1076
  var ACTIVE_STAKE_TTL = 1e3 * 60 * 60 * 2;
977
1077
  var NO_ACTIVE_STAKE_TTL = 1e3 * 2;
978
1078
  var STAKE_CACHE_MAX_ENTRIES = 1e4;
@@ -990,16 +1090,10 @@ var XyoStakeIntentService = class extends BaseService {
990
1090
  // in performance for small sets, and (most importantly) easily
991
1091
  // persisted so we can recover state on restart.
992
1092
  _producers = new IntervalMap();
993
- _stakeCache = new LRUCache2({
1093
+ _stakeCache = new LRUCache3({
994
1094
  max: STAKE_CACHE_MAX_ENTRIES
995
1095
  });
996
1096
  _updateMutex = new Mutex3();
997
- constructor(params) {
998
- super(params);
999
- this.chainIterator.on("headUpdated", async () => {
1000
- await this.updateIndex();
1001
- });
1002
- }
1003
1097
  get chainArchivist() {
1004
1098
  return assertEx10(this.params.chainArchivist, () => "chainArchivist not set");
1005
1099
  }
@@ -1013,11 +1107,13 @@ var XyoStakeIntentService = class extends BaseService {
1013
1107
  return assertEx10(this.params.stakeIntentStateArchivist, () => "stakeIntentStateArchivist not set");
1014
1108
  }
1015
1109
  async createHandler() {
1110
+ this.chainIterator.on("headUpdated", async () => {
1111
+ await this.updateIndex();
1112
+ });
1016
1113
  const head = await this.chainIterator.head();
1114
+ if (isUndefined2(head)) return;
1017
1115
  const headHash = await PayloadBuilder8.hash(head);
1018
- if (head?.block === void 0) return;
1019
1116
  await this.recoverState(headHash);
1020
- await this.updateIndex(true);
1021
1117
  }
1022
1118
  async getDeclaredCandidateRanges(address, intent) {
1023
1119
  await Promise.resolve();
@@ -1032,15 +1128,27 @@ var XyoStakeIntentService = class extends BaseService {
1032
1128
  const candidates = [
1033
1129
  ...results
1034
1130
  ];
1035
- const validCandidates = await this.filterToValidStake(candidates, this.chainStakeViewer);
1131
+ const requiredMinimumStake = this.getRequiredMinimumStakeForIntent(intent);
1132
+ const validCandidates = await this.filterToValidStake(candidates, this.chainStakeViewer, requiredMinimumStake);
1036
1133
  return validCandidates;
1037
1134
  });
1038
1135
  }
1136
+ getRequiredMinimumStakeForIntent(intent) {
1137
+ switch (intent) {
1138
+ case "producer": {
1139
+ const requiredMinimumStake = isDefined5(process.env.XYO_PRODUCER_MIN_STAKE) ? BigInt(process.env.XYO_PRODUCER_MIN_STAKE) : 1n;
1140
+ return requiredMinimumStake;
1141
+ }
1142
+ }
1143
+ }
1039
1144
  async isStakedForBlock(block, intent, address) {
1040
1145
  const candidates = await this.getDeclaredCandidatesForBlock(block, intent);
1041
1146
  return candidates.includes(address);
1042
1147
  }
1043
- async filterToValidStake(candidates, chainStakeViewer, requiredMinimumStake = 1n) {
1148
+ async startHandler() {
1149
+ await this.updateIndex(true);
1150
+ }
1151
+ async filterToValidStake(candidates, chainStakeViewer, requiredMinimumStake) {
1044
1152
  const candidatesWithStake = await Promise.all(candidates.map(async (candidate) => {
1045
1153
  const stake = this._stakeCache.get(candidate);
1046
1154
  if (stake === void 0) {
@@ -1120,11 +1228,12 @@ var XyoStakeIntentService = class extends BaseService {
1120
1228
  await this._updateMutex.runExclusive(async () => {
1121
1229
  return await this.spanAsync("updateIndex", async () => {
1122
1230
  const currentHead = await this.chainIterator.head();
1231
+ if (isUndefined2(currentHead)) return;
1123
1232
  const currentHeadHash = await PayloadBuilder8.hash(currentHead);
1124
1233
  const result = await analyzeChain3(this.chainArchivist, [
1125
1234
  new ChainStakeIntentAnalyzer("producer")
1126
1235
  ], currentHeadHash, this._lastIndexedBlockHash);
1127
- const signedDeclarations = filterAs2(result.find(isChainSummaryStakeIntent)?.intents ?? [], asChainStakeIntent2);
1236
+ const signedDeclarations = filterAs3(result.find(isChainSummaryStakeIntent)?.intents ?? [], asChainStakeIntent2);
1128
1237
  if (currentHead.block === void 0) return;
1129
1238
  const currentHeadBlockNum = currentHead.block;
1130
1239
  if (displayProgress) this.logger?.info(`Updating index through 0x${currentHeadBlockNum}`);
@@ -1142,12 +1251,8 @@ var XyoStakeIntentService = class extends BaseService {
1142
1251
  });
1143
1252
  }
1144
1253
  };
1145
- XyoStakeIntentService = _ts_decorate8([
1146
- creatableService(),
1147
- _ts_metadata3("design:type", Function),
1148
- _ts_metadata3("design:paramtypes", [
1149
- typeof XyoStakeIntentServiceParams === "undefined" ? Object : XyoStakeIntentServiceParams
1150
- ])
1254
+ XyoStakeIntentService = _ts_decorate10([
1255
+ creatable10()
1151
1256
  ], XyoStakeIntentService);
1152
1257
 
1153
1258
  // src/Staker/Evm/Evm.ts
@@ -1160,15 +1265,15 @@ var EvmChainService = class extends BaseService {
1160
1265
  static {
1161
1266
  __name(this, "EvmChainService");
1162
1267
  }
1268
+ get chainId() {
1269
+ return assertEx11(this.params.id);
1270
+ }
1163
1271
  get contract() {
1164
1272
  if (this.params.contract === void 0) {
1165
- this.params.contract = StakedXyoChainFactory.connect(toEthAddress2(this.id), this.params.runner);
1273
+ this.params.contract = StakedXyoChainFactory.connect(toEthAddress2(this.chainId), this.params.runner);
1166
1274
  }
1167
1275
  return assertEx11(this.params.contract);
1168
1276
  }
1169
- get id() {
1170
- return assertEx11(this.params.id);
1171
- }
1172
1277
  get runner() {
1173
1278
  return assertEx11(this.params.runner);
1174
1279
  }
@@ -1186,9 +1291,6 @@ var EvmChainService = class extends BaseService {
1186
1291
  await result.wait();
1187
1292
  return true;
1188
1293
  }
1189
- async chainId() {
1190
- return toAddress(await this.contract.chainId());
1191
- }
1192
1294
  async forkedAtBlockNumber() {
1193
1295
  return await this.contract.forkedAtBlockNumber();
1194
1296
  }
@@ -1230,15 +1332,81 @@ var EvmChainService = class extends BaseService {
1230
1332
  return await this.contract.withdrawnByStaker(getAddress(staker));
1231
1333
  }
1232
1334
  };
1335
+
1336
+ // src/Staker/Memory/Memory.ts
1337
+ import { ZERO_ADDRESS } from "@xylabs/hex";
1338
+ import { isDefined as isDefined6 } from "@xylabs/typeof";
1339
+ var MemoryChainService = class extends BaseService {
1340
+ static {
1341
+ __name(this, "MemoryChainService");
1342
+ }
1343
+ _simulatedStake = 1n;
1344
+ get chainId() {
1345
+ return ZERO_ADDRESS;
1346
+ }
1347
+ async active() {
1348
+ return await Promise.resolve(this._simulatedStake);
1349
+ }
1350
+ async activeByAddressStaked(_address) {
1351
+ return await Promise.resolve(this._simulatedStake);
1352
+ }
1353
+ async activeByStaker(_address) {
1354
+ return await Promise.resolve(this._simulatedStake);
1355
+ }
1356
+ async addStake(_staked, _amount) {
1357
+ return await Promise.resolve(true);
1358
+ }
1359
+ createHandler() {
1360
+ this._simulatedStake = isDefined6(process.env.XYO_PRODUCER_MIN_STAKE) ? BigInt(process.env.XYO_PRODUCER_MIN_STAKE) : 1n;
1361
+ }
1362
+ async forkedAtBlockNumber() {
1363
+ return await Promise.resolve(0n);
1364
+ }
1365
+ async forkedAtHash() {
1366
+ return await Promise.resolve(0n);
1367
+ }
1368
+ async forkedChainId() {
1369
+ return await Promise.resolve(ZERO_ADDRESS);
1370
+ }
1371
+ async minWithdrawalBlocks() {
1372
+ return await Promise.resolve(1n);
1373
+ }
1374
+ async pending() {
1375
+ return await Promise.resolve(0n);
1376
+ }
1377
+ async pendingByStaker(_staker) {
1378
+ return await Promise.resolve(0n);
1379
+ }
1380
+ async removeStake(_slot) {
1381
+ return await Promise.resolve(true);
1382
+ }
1383
+ async rewardsContract() {
1384
+ return await Promise.resolve("");
1385
+ }
1386
+ async stakingTokenAddress() {
1387
+ return await Promise.resolve("");
1388
+ }
1389
+ async withdrawStake(_slot) {
1390
+ return await Promise.resolve(true);
1391
+ }
1392
+ async withdrawn() {
1393
+ return await Promise.resolve(0n);
1394
+ }
1395
+ async withdrawnByStaker(_staker) {
1396
+ return await Promise.resolve(0n);
1397
+ }
1398
+ };
1233
1399
  export {
1234
1400
  BaseAccountableService,
1235
1401
  BaseService,
1402
+ ChainAccountBalanceServiceV2,
1236
1403
  ChainBlockNumberIterationService,
1237
1404
  DEFAULT_BLOCK_SIZE,
1238
1405
  EvmBlockRewardService,
1239
1406
  EvmChainService,
1240
- XYO_PRODUCER_RESTAKE_DURATION,
1241
- XYO_PRODUCER_RESTAKE_WINDOW,
1407
+ MemoryChainService,
1408
+ XYO_PRODUCER_REDECLARATION_DURATION,
1409
+ XYO_PRODUCER_REDECLARATION_WINDOW,
1242
1410
  XyoBlockProducer,
1243
1411
  XyoBlockRewardService,
1244
1412
  XyoChainAccountBalanceService,
@@ -1247,6 +1415,7 @@ export {
1247
1415
  XyoStakeIntentService,
1248
1416
  XyoValidator,
1249
1417
  accountBalanceServiceFromArchivist,
1418
+ accountBalanceServiceFromArchivistV2,
1250
1419
  creatableService,
1251
1420
  getBlockSignedStakeDeclarations
1252
1421
  };