@xyo-network/chain-producer 1.20.29 → 1.21.2

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.
@@ -5,7 +5,6 @@ export type ProducerActorParams = ActorParamsV3<{
5
5
  config: ProducerConfig;
6
6
  }>;
7
7
  export declare class ProducerActor extends ActorV3<ProducerActorParams> {
8
- static readonly needs: ActorCapabilityNeeds;
9
8
  /**
10
9
  * The default interval time (in MS) between block production attempts.
11
10
  */
@@ -19,13 +18,14 @@ export declare class ProducerActor extends ActorV3<ProducerActorParams> {
19
18
  * The window (in blocks) before expiration to attempt redeclaration of producer intent.
20
19
  */
21
20
  static readonly RedeclarationWindow = 1000;
21
+ static readonly needs: ActorCapabilityNeeds;
22
22
  protected _lastProducedBlock?: HydratedBlockWithHashMeta;
23
23
  protected _lastRedeclarationIntent?: ChainStakeIntent;
24
24
  protected _metricAttributes?: Attributes;
25
- protected _producerActorBlockProductionAttempts?: Counter<Attributes>;
26
- protected _producerActorBlockProductionChecks?: Counter<Attributes>;
27
- protected _producerActorBlocksProduced?: Counter<Attributes>;
28
- protected _producerActorBlocksPublished?: Counter<Attributes>;
25
+ protected _producerActorBlockProductionAttempts: Counter<Attributes>;
26
+ protected _producerActorBlockProductionChecks: Counter<Attributes>;
27
+ protected _producerActorBlocksProduced: Counter<Attributes>;
28
+ protected _producerActorBlocksPublished: Counter<Attributes>;
29
29
  private _accountBalanceViewer?;
30
30
  private _blockRunner?;
31
31
  private _blockViewer?;
@@ -64,7 +64,7 @@ export declare class ProducerActor extends ActorV3<ProducerActorParams> {
64
64
  } | undefined;
65
65
  };
66
66
  log: {
67
- logLevel: "log" | "error" | "warn" | "info" | "debug" | "trace";
67
+ logLevel: "log" | "info" | "error" | "warn" | "debug" | "trace";
68
68
  silent: boolean;
69
69
  };
70
70
  providers: {
@@ -1 +1 @@
1
- {"version":3,"file":"ProducerActor.d.ts","sourceRoot":"","sources":["../../src/ProducerActor.ts"],"names":[],"m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AAC;cAkB7G,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC;cAe1C,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;CAWzD"}
@@ -0,0 +1,5 @@
1
+ import type { GetLocatorsFromConfig } from '@xyo-network/chain-orchestration';
2
+ import type { Config } from '@xyo-network/xl1-sdk';
3
+ import type { CommandModule } from 'yargs';
4
+ export declare function producerCommand(getConfiguration: () => Config, getLocatorsFromConfig: GetLocatorsFromConfig): CommandModule;
5
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAE7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAI1C,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,MAAM,MAAM,EAAE,qBAAqB,EAAE,qBAAqB,GAAG,aAAa,CAW3H"}
@@ -1,3 +1,4 @@
1
+ export * from './command.ts';
1
2
  export * from './ProducerActor.ts';
2
- export * from './runProducer.ts';
3
+ export * from './run.ts';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,UAAU,CAAA"}
@@ -1,6 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
+ // src/command.ts
5
+ import { ProducerConfigZod } from "@xyo-network/chain-orchestration";
6
+
7
+ // src/run.ts
8
+ import { exists } from "@xylabs/sdk-js";
9
+ import { initActorWallet } from "@xyo-network/chain-orchestration";
10
+
4
11
  // src/ProducerActor.ts
5
12
  import { assertEx, creatable, isDefined, isUndefined, toHex } from "@xylabs/sdk-js";
6
13
  import { ActorV3, DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL } from "@xyo-network/chain-orchestration";
@@ -25,18 +32,6 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
25
32
  static {
26
33
  __name(this, "ProducerActor");
27
34
  }
28
- static needs = {
29
- required: [
30
- AccountBalanceViewerMoniker,
31
- BlockRunnerMoniker,
32
- BlockViewerMoniker,
33
- ChainContractViewerMoniker,
34
- FinalizationViewerMoniker,
35
- MempoolRunnerMoniker,
36
- MempoolViewerMoniker,
37
- StakeTotalsViewerMoniker
38
- ]
39
- };
40
35
  /**
41
36
  * The default interval time (in MS) between block production attempts.
42
37
  */
@@ -50,6 +45,18 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
50
45
  * The window (in blocks) before expiration to attempt redeclaration of producer intent.
51
46
  */
52
47
  static RedeclarationWindow = 1e3;
48
+ static needs = {
49
+ required: [
50
+ AccountBalanceViewerMoniker,
51
+ BlockRunnerMoniker,
52
+ BlockViewerMoniker,
53
+ ChainContractViewerMoniker,
54
+ FinalizationViewerMoniker,
55
+ MempoolRunnerMoniker,
56
+ MempoolViewerMoniker,
57
+ StakeTotalsViewerMoniker
58
+ ]
59
+ };
53
60
  _lastProducedBlock;
54
61
  _lastRedeclarationIntent;
55
62
  _metricAttributes;
@@ -109,18 +116,10 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
109
116
  this._metricAttributes = {
110
117
  address: this.account.address.toString()
111
118
  };
112
- this._producerActorBlockProductionChecks = this.meter?.createCounter("producer_actor_block_production_checks", {
113
- description: "Number of block production checks"
114
- });
115
- this._producerActorBlockProductionAttempts = this.meter?.createCounter("producer_actor_block_production_attempts", {
116
- description: "Number of block production attempts"
117
- });
118
- this._producerActorBlocksProduced = this.meter?.createCounter("producer_actor_blocks_produced", {
119
- description: "Number of blocks produced"
120
- });
121
- this._producerActorBlocksPublished = this.meter?.createCounter("producer_actor_blocks_published", {
122
- description: "Number of blocks published"
123
- });
119
+ this._producerActorBlockProductionChecks = this.counter("producer_actor_block_production_checks", "Number of block production checks");
120
+ this._producerActorBlockProductionAttempts = this.counter("producer_actor_block_production_attempts", "Number of block production attempts");
121
+ this._producerActorBlocksProduced = this.counter("producer_actor_blocks_produced", "Number of blocks produced");
122
+ this._producerActorBlocksPublished = this.counter("producer_actor_blocks_published", "Number of blocks published");
124
123
  const final = await this.locator?.getInstance(FinalizationViewerMoniker);
125
124
  await final.start();
126
125
  this._accountBalanceViewer = assertEx(await this.locator?.getInstance(AccountBalanceViewerMoniker), () => "Unable to locate AccountBalanceViewer");
@@ -168,7 +167,7 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
168
167
  return (this._lastRedeclarationIntent?.exp ?? currentBlock) - currentBlock;
169
168
  }
170
169
  async produceBlock() {
171
- this._producerActorBlockProductionChecks?.add(1, this._metricAttributes);
170
+ this._producerActorBlockProductionChecks.add(1, this._metricAttributes);
172
171
  await this.spanAsync("produceBlock", async () => {
173
172
  if (this._produceBlockMutex.isLocked()) {
174
173
  this.logger?.debug("Skipping block production, previous production still in progress");
@@ -197,17 +196,17 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
197
196
  this.logger?.log(`Resubmitting block due to stale head. Head ${toFormattedBlockReference(head)} unchanged for ${timeSinceHeadChange}ms`);
198
197
  this._lastHeadChangeTime = currentTime;
199
198
  }
200
- this._producerActorBlockProductionAttempts?.add(1, this._metricAttributes);
199
+ this._producerActorBlockProductionAttempts.add(1, this._metricAttributes);
201
200
  const nextBlock = await this.blockRunner.produceNextBlock(head);
202
201
  if (nextBlock) {
203
202
  const displayBlockNumber = toFormattedBlockReference(nextBlock[0]);
204
203
  this.logger?.log("Produced block:", displayBlockNumber);
205
- this._producerActorBlocksProduced?.add(1, this._metricAttributes);
204
+ this._producerActorBlocksProduced.add(1, this._metricAttributes);
206
205
  await this.mempoolRunner.submitBlocks([
207
206
  nextBlock
208
207
  ]);
209
208
  this.logger?.log("Published block:", displayBlockNumber);
210
- this._producerActorBlocksPublished?.add(1, this._metricAttributes);
209
+ this._producerActorBlocksPublished.add(1, this._metricAttributes);
211
210
  this._lastProducedBlock = nextBlock;
212
211
  } else {
213
212
  this.logger?.log("No block produced for submission.");
@@ -294,20 +293,21 @@ ProducerActor = _ts_decorate([
294
293
  creatable()
295
294
  ], ProducerActor);
296
295
 
297
- // src/runProducer.ts
298
- import { exists } from "@xylabs/sdk-js";
299
- import { initActorAccount } from "@xyo-network/chain-orchestration";
300
- var runProducer = /* @__PURE__ */ __name(async (config, orchestrator, locator) => {
301
- const account = await initActorAccount({
296
+ // src/run.ts
297
+ var getProducerActor = /* @__PURE__ */ __name(async (config, locator) => {
298
+ const account = await initActorWallet({
302
299
  ...locator.context,
303
300
  config
304
301
  });
305
- const producer = await ProducerActor.create({
302
+ return await ProducerActor.create({
306
303
  config,
307
304
  locator,
308
305
  name: "xl1-producer",
309
306
  account
310
307
  });
308
+ }, "getProducerActor");
309
+ var runProducer = /* @__PURE__ */ __name(async (config, orchestrator, locator) => {
310
+ const producer = await getProducerActor(config, locator);
311
311
  const actors = [
312
312
  producer
313
313
  ].filter(exists);
@@ -316,8 +316,27 @@ var runProducer = /* @__PURE__ */ __name(async (config, orchestrator, locator) =
316
316
  }
317
317
  await orchestrator.start();
318
318
  }, "runProducer");
319
+
320
+ // src/command.ts
321
+ function producerCommand(getConfiguration, getLocatorsFromConfig) {
322
+ return {
323
+ command: "producer",
324
+ deprecated: 'Use "start producer" instead',
325
+ describe: "Run a XL1 Producer Node",
326
+ handler: /* @__PURE__ */ __name(async () => {
327
+ const configuration = getConfiguration();
328
+ const { locators, orchestrator } = await getLocatorsFromConfig([
329
+ "producer"
330
+ ], configuration);
331
+ await runProducer(ProducerConfigZod.parse(locators["producer"].context.config), orchestrator, locators["producer"]);
332
+ }, "handler")
333
+ };
334
+ }
335
+ __name(producerCommand, "producerCommand");
319
336
  export {
320
337
  ProducerActor,
338
+ getProducerActor,
339
+ producerCommand,
321
340
  runProducer
322
341
  };
323
342
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ProducerActor.ts","../../src/runProducer.ts"],"sourcesContent":["import type { Attributes, Counter } from '@opentelemetry/api'\nimport {\n assertEx, creatable, isDefined, isUndefined,\n toHex,\n} from '@xylabs/sdk-js'\nimport {\n type ActorCapabilityNeeds,\n type ActorParamsV3,\n ActorV3,\n DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL,\n type ProducerConfig,\n} from '@xyo-network/chain-orchestration'\nimport { SimpleBlockRunner } from '@xyo-network/chain-services'\nimport type { WithHashMeta } from '@xyo-network/sdk-js'\nimport type {\n AccountBalanceViewer,\n BlockBoundWitness,\n BlockRunner, BlockViewer, ChainContractViewer, ChainId, ChainStakeIntent, FinalizationViewer, HydratedBlockWithHashMeta, MempoolRunner,\n MempoolViewer, StakeTotalsViewer, XL1BlockNumber,\n} from '@xyo-network/xl1-sdk'\nimport {\n AccountBalanceViewerMoniker, asXL1BlockNumber, BlockRunnerMoniker, BlockViewerMoniker,\n buildTransaction, ChainContractViewerMoniker, createDeclarationIntent, FinalizationViewerMoniker, MempoolRunnerMoniker, MempoolViewerMoniker, StakeTotalsViewerMoniker,\n} from '@xyo-network/xl1-sdk'\nimport { Mutex } from 'async-mutex'\n\nexport type ProducerActorParams = ActorParamsV3<{\n config: ProducerConfig\n}>\n\nconst SHOULD_REGISTER_REDECLARATION_INTENT_TIMER = true\nconst TEN_MINUTES = 10 * 60 * 1000 // 10 minutes in milliseconds\n\n/**\n * Formats a hydrated block with hash meta into a string representation of its hash and block number.\n * @param blockBoundWitness The hydrated block with hash meta to format\n * @returns The formatted block reference string\n */\nconst toFormattedBlockReference = (blockBoundWitness: WithHashMeta<BlockBoundWitness>): string => {\n return `${blockBoundWitness.block} [${toHex(blockBoundWitness._hash, { prefix: true })}]`\n}\n\n@creatable()\nexport class ProducerActor extends ActorV3<ProducerActorParams> {\n static readonly needs: ActorCapabilityNeeds = {\n required: [\n AccountBalanceViewerMoniker,\n BlockRunnerMoniker,\n BlockViewerMoniker,\n ChainContractViewerMoniker,\n FinalizationViewerMoniker,\n MempoolRunnerMoniker,\n MempoolViewerMoniker,\n StakeTotalsViewerMoniker,\n ],\n }\n\n /**\n * The default interval time (in MS) between block production attempts.\n */\n static readonly DefaultBlockProductionCheckInterval = DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL\n\n /**\n * The multiplier applied to the block production check interval to determine\n * the threshold for resubmitting the same block number if the head has not changed.\n */\n static readonly HeadResubmissionMultiplier = 30\n\n /**\n * The window (in blocks) before expiration to attempt redeclaration of producer intent.\n */\n static readonly RedeclarationWindow = 1000\n\n protected _lastProducedBlock?: HydratedBlockWithHashMeta\n protected _lastRedeclarationIntent?: ChainStakeIntent\n protected _metricAttributes?: Attributes\n protected _producerActorBlockProductionAttempts?: Counter<Attributes>\n protected _producerActorBlockProductionChecks?: Counter<Attributes>\n protected _producerActorBlocksProduced?: Counter<Attributes>\n protected _producerActorBlocksPublished?: Counter<Attributes>\n\n private _accountBalanceViewer?: AccountBalanceViewer\n private _blockRunner?: BlockRunner\n private _blockViewer?: BlockViewer\n private _chainContractViewer?: ChainContractViewer\n private _chainId?: ChainId\n private _lastHeadChangeTime?: number\n private _lastHeadHash?: string\n private _mempoolRunner?: MempoolRunner\n private _mempoolViewer?: MempoolViewer\n private _produceBlockMutex = new Mutex()\n private _stakeTotalsViewer?: StakeTotalsViewer\n\n override get logger() {\n return assertEx(super.logger, () => 'Logger is required for ProducerActor')\n }\n\n protected get accountBalanceViewer() {\n return this._accountBalanceViewer!\n }\n\n protected get blockProductionCheckInterval() {\n return this.config.blockProductionCheckInterval ?? ProducerActor.DefaultBlockProductionCheckInterval\n }\n\n protected get blockRunner() {\n return this._blockRunner!\n }\n\n protected get blockViewer() {\n return this._blockViewer!\n }\n\n protected get chainContractViewer() {\n return this._chainContractViewer!\n }\n\n protected get chainId() {\n return this._chainId!\n }\n\n protected get config() {\n return this.params.config\n }\n\n protected get headResubmissionThreshold() {\n return this.blockProductionCheckInterval * ProducerActor.HeadResubmissionMultiplier\n }\n\n protected get mempoolRunner() {\n return this._mempoolRunner!\n }\n\n protected get mempoolViewer() {\n return this._mempoolViewer!\n }\n\n protected get stakeTotalsViewer() {\n return this._stakeTotalsViewer!\n }\n\n override async createHandler() {\n await super.createHandler()\n // Create the consistent meter attributes that will\n // be included with all metrics from this actor\n this._metricAttributes = { address: this.account.address.toString() }\n // Create the metrics\n this._producerActorBlockProductionChecks = this.meter?.createCounter(\n 'producer_actor_block_production_checks',\n { description: 'Number of block production checks' },\n )\n this._producerActorBlockProductionAttempts = this.meter?.createCounter(\n 'producer_actor_block_production_attempts',\n { description: 'Number of block production attempts' },\n )\n this._producerActorBlocksProduced = this.meter?.createCounter(\n 'producer_actor_blocks_produced',\n { description: 'Number of blocks produced' },\n )\n this._producerActorBlocksPublished = this.meter?.createCounter(\n 'producer_actor_blocks_published',\n { description: 'Number of blocks published' },\n )\n const final = await this.locator?.getInstance<FinalizationViewer>(FinalizationViewerMoniker)\n await final.start()\n this._accountBalanceViewer = assertEx(\n await this.locator?.getInstance<AccountBalanceViewer>(AccountBalanceViewerMoniker),\n () => 'Unable to locate AccountBalanceViewer',\n )\n this._blockRunner = assertEx(\n await this.locator?.getInstance<BlockRunner>(BlockRunnerMoniker),\n () => 'Unable to locate BlockRunner',\n )\n this._blockViewer = assertEx(\n await this.locator?.getInstance<BlockViewer>(BlockViewerMoniker),\n () => 'Unable to locate BlockViewer',\n )\n this._chainContractViewer = assertEx(\n await this.locator?.getInstance<ChainContractViewer>(ChainContractViewerMoniker),\n () => 'Unable to locate ChainContractViewer',\n )\n this._mempoolRunner = assertEx(\n await this.locator?.getInstance<MempoolRunner>(MempoolRunnerMoniker),\n () => 'Unable to locate MempoolRunner',\n )\n this._mempoolViewer = assertEx(\n await this.locator?.getInstance<MempoolViewer>(MempoolViewerMoniker),\n () => 'Unable to locate MempoolViewer',\n )\n this._stakeTotalsViewer = assertEx(\n await this.locator?.getInstance<StakeTotalsViewer>(StakeTotalsViewerMoniker),\n () => 'Unable to locate StakeTotalsViewer',\n )\n this._chainId = await this.chainContractViewer.chainId()\n }\n\n // async initLocator() {\n // const config = this.config\n // const endpoint = assertEx(config.services.apiEndpoint, () => 'API endpoint is required in config.services.apiEndpoint')\n // const transportFactory: TransportFactory = (schemas: RpcSchemaMap) => new HttpRpcTransport(endpoint, schemas)\n // const locator = await buildJsonRpcProviderLocatorV2(config, transportFactory)\n\n // const version = '1.0.0'\n // const telemetryConfig = buildTelemetryConfig(config, this.name, version, DefaultMetricsScrapePorts.producer)\n // const { traceProvider, meterProvider } = await startupSpanAsync('initTelemetry', () => initTelemetry(telemetryConfig))\n\n // locator.context.traceProvider = traceProvider\n // locator.context.meterProvider = meterProvider\n\n // locator.register(SimpleBlockRewardViewer.factory<SimpleBlockRewardViewer>(SimpleBlockRewardViewer.dependencies, {}))\n // locator.register(SimpleBlockValidationViewer.factory<SimpleBlockValidationViewer>(\n // SimpleBlockValidationViewer.dependencies,\n // { state: validateHydratedBlockState, protocol: validateHydratedBlock },\n // ))\n // locator.register(SimpleBlockRunner.factory<SimpleBlockRunner>(\n // SimpleBlockRunner.dependencies,\n // { account: this.params.account, rewardAddress: this.params.rewardAddress },\n // ))\n // return await initEvmProvidersIfAvailable(locator)\n // }\n\n override async startHandler() {\n await super.startHandler()\n // Register a timer to check if we should produce a block\n this.registerTimer('BlockProductionTimer', async () => {\n await this.produceBlock()\n }, 2000, this.blockProductionCheckInterval)\n\n if (SHOULD_REGISTER_REDECLARATION_INTENT_TIMER) {\n // Register a timer to check if we should redeclare the producer\n this.registerTimer('ProducerRedeclarationTimer', async () => {\n await this.redeclareIntent()\n }, TEN_MINUTES, TEN_MINUTES)\n }\n }\n\n protected calculateBlocksUntilProducerDeclarationExpiration(currentBlock: number): number {\n return (this._lastRedeclarationIntent?.exp ?? currentBlock) - currentBlock\n }\n\n protected async produceBlock(): Promise<void> {\n this._producerActorBlockProductionChecks?.add(1, this._metricAttributes)\n await this.spanAsync('produceBlock', async () => {\n if (this._produceBlockMutex.isLocked()) {\n this.logger?.debug('Skipping block production, previous production still in progress')\n return\n }\n\n await this._produceBlockMutex.runExclusive(async () => {\n // Get the updated head\n const head = (await this.blockViewer.currentBlock())[0]\n const headHash = head._hash\n\n // Track head changes\n const currentTime = Date.now()\n if (this._lastHeadHash !== headHash) {\n const lastHeadHashHex = isDefined(this._lastHeadHash) ? `0x${this._lastHeadHash}` : 'undefined'\n const currentHeadHashHex = `0x${headHash}`\n this.logger?.log(`Found updated head ${lastHeadHashHex} -> ${currentHeadHashHex}`)\n this._lastHeadHash = headHash\n this._lastHeadChangeTime = currentTime\n }\n\n // Check if we should resubmit due to stale head\n const timeSinceHeadChange = isDefined(this._lastHeadChangeTime) ? currentTime - this._lastHeadChangeTime : 0\n\n // If we have never produced a block or the last produced block was not built on the current head we\n // need to attempt to produce a new block\n const shouldSubmit = !this._lastProducedBlock || this._lastProducedBlock[0].previous !== headHash\n\n // If the head has not changed determine if we should resubmit again based on head staleness\n const shouldResubmit = timeSinceHeadChange > this.headResubmissionThreshold\n\n // Determine if we should submit or resubmit\n const shouldSubmitBlock = shouldSubmit || shouldResubmit\n\n if (!shouldSubmitBlock) {\n this.logger?.debug('No block submission required at this time.')\n return\n }\n\n if (shouldResubmit) {\n this.logger?.log(`Resubmitting block due to stale head. Head ${toFormattedBlockReference(head)} unchanged for ${timeSinceHeadChange}ms`)\n this._lastHeadChangeTime = currentTime\n }\n this._producerActorBlockProductionAttempts?.add(1, this._metricAttributes)\n // Produce the next block (do not pass force — undefined result is valid when idle)\n const nextBlock = await this.blockRunner.produceNextBlock(head)\n if (nextBlock) {\n const displayBlockNumber = toFormattedBlockReference(nextBlock[0])\n this.logger?.log('Produced block:', displayBlockNumber)\n this._producerActorBlocksProduced?.add(1, this._metricAttributes)\n await this.mempoolRunner.submitBlocks([nextBlock])\n this.logger?.log('Published block:', displayBlockNumber)\n this._producerActorBlocksPublished?.add(1, this._metricAttributes)\n this._lastProducedBlock = nextBlock\n } else {\n this.logger?.log('No block produced for submission.')\n }\n })\n }, { ...this.context, timeBudgetLimit: 1000 })\n }\n\n protected override async readyHandler(): Promise<void> {\n // Warm pass: prove the production loop reaches its dependencies before declaring ready.\n await this.produceBlock()\n }\n\n protected async redeclareIntent(): Promise<void> {\n await this.spanAsync('redeclareIntent', async () => {\n // Decide if we should redeclare intent\n if (this.config.disableIntentRedeclaration) return\n\n // Get the current block\n const head = (await this.blockViewer.currentBlock())[0]\n if (isUndefined(head)) return\n const currentBlock = head.block\n\n // // Calculate the time until the producer's declaration expires\n const blocksUntilExpiration = this.calculateBlocksUntilProducerDeclarationExpiration(currentBlock)\n\n // Allow the producer time to redeclare itself via block production\n // (for free) before submitting a redeclaration intent transaction.\n if (blocksUntilExpiration > ProducerActor.RedeclarationWindow * 0.1) {\n // Clear any previous redeclaration intent\n this._lastRedeclarationIntent = undefined\n // No need to redeclare yet\n return\n }\n\n // If we already have a valid redeclaration intent, do not create another\n // unless it has expired.\n if (this._lastRedeclarationIntent) {\n // Check if the last redeclaration intent is still valid\n if (this._lastRedeclarationIntent.exp > currentBlock) return\n // If it has expired, clear the last redeclaration intent\n this._lastRedeclarationIntent = undefined\n }\n\n // Check if we have a valid balance before declaring intent\n if (!await this.validateCurrentBalance()) {\n this.logger?.error(\n `Add balance to address ${this.account.address} for the producer to declare it's intent.`,\n )\n return\n }\n\n // Check if we have a valid stake before declaring intent\n if (!(await this.validateCurrentStake())) {\n this.logger?.error(\n `Add stake to contract address ${this.chainId}`\n + ' for the producer to declare it\\'s intent.',\n )\n return\n }\n\n // Create a redeclaration intent\n this.logger?.log('Creating redeclaration intent for producer:', this.account.address)\n const redeclarationIntent = createDeclarationIntent(\n this.account.address,\n 'producer',\n currentBlock,\n currentBlock + SimpleBlockRunner.RedeclarationDuration,\n )\n\n // Submit the redeclaration intent\n await this.submitRedeclarationIntent(currentBlock, redeclarationIntent)\n\n // On successful submission, save the redeclaration intent\n this._lastRedeclarationIntent = redeclarationIntent\n }, { ...this.context, timeBudgetLimit: 1000 })\n }\n\n protected async submitRedeclarationIntent(currentBlock: XL1BlockNumber, redeclarationIntent: ChainStakeIntent): Promise<void> {\n this.logger?.log('Submitting redeclaration intent for producer:', this.account.address)\n // Create a transaction to submit the redeclaration intent\n const tx = await buildTransaction(\n this.chainId,\n [redeclarationIntent],\n [],\n this.account,\n currentBlock,\n asXL1BlockNumber(currentBlock + 1000, true),\n )\n\n // Submit the redeclaration intent\n await this.mempoolRunner.submitTransactions([tx])\n\n this.logger?.log('Submitted redeclaration intent for producer:', this.account.address)\n }\n\n protected async validateCurrentBalance(): Promise<boolean> {\n // Check if we have a valid balance before declaring intent\n const head = (await this.blockViewer.currentBlock())?.[0]?._hash\n if (isDefined(head)) {\n const balances = await this.accountBalanceViewer.accountBalances([this.account.address], { head })\n const currentBalance = balances[this.account.address] ?? 0n\n if (currentBalance <= 0n) {\n this.logger?.error(`Producer ${this.account.address} has no balance.`)\n return false\n }\n return true\n }\n return true\n }\n\n protected async validateCurrentStake(): Promise<boolean> {\n // Use StakeIntentService to get the required minimum stake\n const requiredMinimumStake = 1n // this.stakeIntentService.getRequiredMinimumStakeForIntent('producer')\n // Check if we have a valid stake before declaring intent\n const currentStake = await this.stakeTotalsViewer.activeByStaked(this.account.address)\n if (currentStake < requiredMinimumStake) {\n this.logger?.error(`Producer ${this.account.address} has insufficient stake.`)\n return false\n }\n return true\n }\n}\n","import type { CreatableName } from '@xylabs/sdk-js'\nimport { exists } from '@xylabs/sdk-js'\nimport {\n initActorAccount,\n type OrchestratorInstance,\n type ProducerConfig,\n} from '@xyo-network/chain-orchestration'\nimport type { ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk'\n\nimport type { ProducerActorParams } from './ProducerActor.ts'\nimport { ProducerActor } from './ProducerActor.ts'\n\nexport const runProducer = async (\n config: ProducerConfig,\n orchestrator: OrchestratorInstance,\n locator: ProviderFactoryLocatorInstance,\n) => {\n const account = await initActorAccount({ ...locator.context, config })\n // Create actors\n const producer = await ProducerActor.create({\n config, locator, name: 'xl1-producer' as CreatableName, account,\n } satisfies ProducerActorParams)\n const actors = [producer].filter(exists)\n\n for (const actor of actors) {\n // Register the actor with the orchestrator\n await orchestrator.registerActor(actor)\n }\n // Start the orchestrator => automatically activates the actor\n await orchestrator.start()\n}\n"],"mappings":";;;;AACA,SACEA,UAAUC,WAAWC,WAAWC,aAChCC,aACK;AACP,SAGEC,SACAC,+CAEK;AACP,SAASC,yBAAyB;AAQlC,SACEC,6BAA6BC,kBAAkBC,oBAAoBC,oBACnEC,kBAAkBC,4BAA4BC,yBAAyBC,2BAA2BC,sBAAsBC,sBAAsBC,gCACzI;AACP,SAASC,aAAa;;;;;;;;AAMtB,IAAMC,6CAA6C;AACnD,IAAMC,cAAc,KAAK,KAAK;AAO9B,IAAMC,4BAA4B,wBAACC,sBAAAA;AACjC,SAAO,GAAGA,kBAAkBC,KAAK,KAAKC,MAAMF,kBAAkBG,OAAO;IAAEC,QAAQ;EAAK,CAAA,CAAA;AACtF,GAFkC;AAK3B,IAAMC,gBAAN,MAAMA,uBAAsBC,QAAAA;SAAAA;;;EACjC,OAAgBC,QAA8B;IAC5CC,UAAU;MACRC;MACAC;MACAC;MACAC;MACAC;MACAC;MACAC;MACAC;;EAEJ;;;;EAKA,OAAgBC,sCAAsCC;;;;;EAMtD,OAAgBC,6BAA6B;;;;EAK7C,OAAgBC,sBAAsB;EAE5BC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EAEFC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC,qBAAqB,IAAIC,MAAAA;EACzBC;EAER,IAAaC,SAAS;AACpB,WAAOC,SAAS,M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C,cAAcC,OAAO;IAC1CR;IAAQE;IAASO,MAAM;IAAiCN;EAC1D,CAAA;AACA,QAAMO,SAAS;IAACJ;IAAUK,OAAOC,MAAAA;AAEjC,aAAWC,SAASH,QAAQ;AAE1B,UAAMT,aAAaa,cAAcD,KAAAA;EACnC;AAEA,QAAMZ,aAAac,MAAK;AAC1B,GAlB2B;","names":["assertEx","creatable","isDefined","isUndefined","toHex","ActorV3","DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL","SimpleBlockRunner","AccountBalanceViewerMoniker","asXL1BlockNumber","BlockRunnerMoniker","BlockViewerMoniker","buildTransaction","ChainContractViewerMoniker","createDeclarationIntent","FinalizationViewerMoniker","MempoolRunnerMoniker","MempoolViewerMoniker","StakeTotalsViewerMoniker","Mutex","SHOULD_REGISTER_REDECLARATION_INTENT_TIMER","TEN_MINUTES","toFormattedBlockReference","blockBoundWitness","block","toHex","_hash","prefix","ProducerActor","ActorV3","needs","required","AccountBalanceViewerMoniker","BlockRunnerMoniker","BlockViewerMoniker","ChainContractViewerMoniker","FinalizationViewerMoniker","MempoolRunnerMoniker","MempoolViewerMoniker","StakeTotalsViewerMoniker","DefaultBlockProductionCheckInterval","DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL","HeadResubmissionMultiplier","RedeclarationWindow","_lastProducedBlock","_lastRedeclarationIntent","_metricAttributes","_producerActorBlockProductionAttempts","_producerActorBlockProductionChecks","_producerActorBlocksProduced","_producerActorBlocksPublished","_accountBalanceViewer","_blockRunner","_blockViewer","_chainContractViewer","_chainId","_lastHeadChangeTime","_lastHeadHash","_mempoolRunner","_mempoolViewer","_produceBlockMutex","Mutex","_stakeTotalsViewer","logger","assertEx","accountBalanceViewer","blockProductionCheckInterval","config","blockRunner","blockViewer","chainContractViewer","chainId","params","headResubmissionThreshold","mempoolRunner","mempoolViewer","stakeTotalsViewer","createHandler","address","account","toString","meter","createCounter","description","final","locator","getInstance","start","startHandler","registerTimer","produceBlock","redeclareIntent","calculateBlocksUntilProducerDeclarationExpiration","currentBlock","exp","add","spanAsync","isLocked","debug","runExclusive","head","headHash","currentTime","Date","now","lastHeadHashHex","isDefined","currentHeadHashHex","log","timeSinceHeadChange","shouldSubmit","previous","shouldResubmit","shouldSubmitBlock","nextBlock","produceNextBlock","displayBlockNumber","submitBlocks","context","timeBudgetLimit","readyHandler","disableIntentRedeclaration","isUndefined","blocksUntilExpiration","undefined","validateCurrentBalance","error","validateCurrentStake","redeclarationIntent","createDeclarationIntent","SimpleBlockRunner","RedeclarationDuration","submitRedeclarationIntent","tx","buildTransaction","asXL1BlockNumber","submitTransactions","balances","accountBalances","currentBalance","requiredMinimumStake","currentStake","activeByStaked","exists","initActorAccount","runProducer","config","orchestrator","locator","account","initActorAccount","context","producer","ProducerActor","create","name","actors","filter","exists","actor","registerActor","start"]}
1
+ {"version":3,"sources":["../../src/command.ts","../../src/run.ts","../../src/ProducerActor.ts"],"sourcesContent":["import type { GetLocatorsFromConfig } from '@xyo-network/chain-orchestration'\nimport { ProducerConfigZod } from '@xyo-network/chain-orchestration'\nimport type { Config } from '@xyo-network/xl1-sdk'\nimport type { CommandModule } from 'yargs'\n\nimport { runProducer } from './run.ts'\n\nexport function producerCommand(getConfiguration: () => Config, getLocatorsFromConfig: GetLocatorsFromConfig): CommandModule {\n return {\n command: 'producer',\n deprecated: 'Use \"start producer\" instead',\n describe: 'Run a XL1 Producer Node',\n handler: async () => {\n const configuration = getConfiguration()\n const { locators, orchestrator } = await getLocatorsFromConfig(['producer'], configuration)\n await runProducer(ProducerConfigZod.parse(locators['producer'].context.config), orchestrator, locators['producer'])\n },\n }\n}\n","import type { CreatableName } from '@xylabs/sdk-js'\nimport { exists } from '@xylabs/sdk-js'\nimport {\n initActorWallet,\n type OrchestratorInstance,\n type ProducerConfig,\n} from '@xyo-network/chain-orchestration'\nimport type { ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk'\n\nimport type { ProducerActorParams } from './ProducerActor.ts'\nimport { ProducerActor } from './ProducerActor.ts'\n\nexport const getProducerActor = async (\n config: ProducerConfig,\n locator: ProviderFactoryLocatorInstance,\n): Promise<ProducerActor> => {\n const account = await initActorWallet({ ...locator.context, config })\n return await ProducerActor.create({\n config, locator, name: 'xl1-producer' as CreatableName, account,\n } satisfies ProducerActorParams)\n}\n\nexport const runProducer = async (\n config: ProducerConfig,\n orchestrator: OrchestratorInstance,\n locator: ProviderFactoryLocatorInstance,\n) => {\n const producer = await getProducerActor(config, locator)\n const actors = [producer].filter(exists)\n\n for (const actor of actors) {\n await orchestrator.registerActor(actor)\n }\n await orchestrator.start()\n}\n","import type { Attributes, Counter } from '@opentelemetry/api'\nimport {\n assertEx, creatable, isDefined, isUndefined,\n toHex,\n} from '@xylabs/sdk-js'\nimport {\n type ActorCapabilityNeeds,\n type ActorParamsV3,\n ActorV3,\n DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL,\n type ProducerConfig,\n} from '@xyo-network/chain-orchestration'\nimport { SimpleBlockRunner } from '@xyo-network/chain-services'\nimport type { WithHashMeta } from '@xyo-network/sdk-js'\nimport type {\n AccountBalanceViewer,\n BlockBoundWitness,\n BlockRunner, BlockViewer, ChainContractViewer, ChainId, ChainStakeIntent, FinalizationViewer, HydratedBlockWithHashMeta, MempoolRunner,\n MempoolViewer, StakeTotalsViewer, XL1BlockNumber,\n} from '@xyo-network/xl1-sdk'\nimport {\n AccountBalanceViewerMoniker, asXL1BlockNumber, BlockRunnerMoniker, BlockViewerMoniker,\n buildTransaction, ChainContractViewerMoniker, createDeclarationIntent, FinalizationViewerMoniker, MempoolRunnerMoniker, MempoolViewerMoniker, StakeTotalsViewerMoniker,\n} from '@xyo-network/xl1-sdk'\nimport { Mutex } from 'async-mutex'\n\nexport type ProducerActorParams = ActorParamsV3<{\n config: ProducerConfig\n}>\n\nconst SHOULD_REGISTER_REDECLARATION_INTENT_TIMER = true\nconst TEN_MINUTES = 10 * 60 * 1000 // 10 minutes in milliseconds\n\n/**\n * Formats a hydrated block with hash meta into a string representation of its hash and block number.\n * @param blockBoundWitness The hydrated block with hash meta to format\n * @returns The formatted block reference string\n */\nconst toFormattedBlockReference = (blockBoundWitness: WithHashMeta<BlockBoundWitness>): string => {\n return `${blockBoundWitness.block} [${toHex(blockBoundWitness._hash, { prefix: true })}]`\n}\n\n@creatable()\nexport class ProducerActor extends ActorV3<ProducerActorParams> {\n /**\n * The default interval time (in MS) between block production attempts.\n */\n static readonly DefaultBlockProductionCheckInterval = DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL\n\n /**\n * The multiplier applied to the block production check interval to determine\n * the threshold for resubmitting the same block number if the head has not changed.\n */\n static readonly HeadResubmissionMultiplier = 30\n\n /**\n * The window (in blocks) before expiration to attempt redeclaration of producer intent.\n */\n static readonly RedeclarationWindow = 1000\n\n static readonly needs: ActorCapabilityNeeds = {\n required: [\n AccountBalanceViewerMoniker,\n BlockRunnerMoniker,\n BlockViewerMoniker,\n ChainContractViewerMoniker,\n FinalizationViewerMoniker,\n MempoolRunnerMoniker,\n MempoolViewerMoniker,\n StakeTotalsViewerMoniker,\n ],\n }\n\n protected _lastProducedBlock?: HydratedBlockWithHashMeta\n protected _lastRedeclarationIntent?: ChainStakeIntent\n protected _metricAttributes?: Attributes\n protected _producerActorBlockProductionAttempts!: Counter<Attributes>\n protected _producerActorBlockProductionChecks!: Counter<Attributes>\n protected _producerActorBlocksProduced!: Counter<Attributes>\n protected _producerActorBlocksPublished!: Counter<Attributes>\n\n private _accountBalanceViewer?: AccountBalanceViewer\n private _blockRunner?: BlockRunner\n private _blockViewer?: BlockViewer\n private _chainContractViewer?: ChainContractViewer\n private _chainId?: ChainId\n private _lastHeadChangeTime?: number\n private _lastHeadHash?: string\n private _mempoolRunner?: MempoolRunner\n private _mempoolViewer?: MempoolViewer\n private _produceBlockMutex = new Mutex()\n private _stakeTotalsViewer?: StakeTotalsViewer\n\n override get logger() {\n return assertEx(super.logger, () => 'Logger is required for ProducerActor')\n }\n\n protected get accountBalanceViewer() {\n return this._accountBalanceViewer!\n }\n\n protected get blockProductionCheckInterval() {\n return this.config.blockProductionCheckInterval ?? ProducerActor.DefaultBlockProductionCheckInterval\n }\n\n protected get blockRunner() {\n return this._blockRunner!\n }\n\n protected get blockViewer() {\n return this._blockViewer!\n }\n\n protected get chainContractViewer() {\n return this._chainContractViewer!\n }\n\n protected get chainId() {\n return this._chainId!\n }\n\n protected get config() {\n return this.params.config\n }\n\n protected get headResubmissionThreshold() {\n return this.blockProductionCheckInterval * ProducerActor.HeadResubmissionMultiplier\n }\n\n protected get mempoolRunner() {\n return this._mempoolRunner!\n }\n\n protected get mempoolViewer() {\n return this._mempoolViewer!\n }\n\n protected get stakeTotalsViewer() {\n return this._stakeTotalsViewer!\n }\n\n override async createHandler() {\n await super.createHandler()\n // Create the consistent meter attributes that will\n // be included with all metrics from this actor\n this._metricAttributes = { address: this.account.address.toString() }\n // Create the metrics\n this._producerActorBlockProductionChecks = this.counter(\n 'producer_actor_block_production_checks',\n 'Number of block production checks',\n )\n this._producerActorBlockProductionAttempts = this.counter(\n 'producer_actor_block_production_attempts',\n 'Number of block production attempts',\n )\n this._producerActorBlocksProduced = this.counter(\n 'producer_actor_blocks_produced',\n 'Number of blocks produced',\n )\n this._producerActorBlocksPublished = this.counter(\n 'producer_actor_blocks_published',\n 'Number of blocks published',\n )\n const final = await this.locator?.getInstance<FinalizationViewer>(FinalizationViewerMoniker)\n await final.start()\n this._accountBalanceViewer = assertEx(\n await this.locator?.getInstance<AccountBalanceViewer>(AccountBalanceViewerMoniker),\n () => 'Unable to locate AccountBalanceViewer',\n )\n this._blockRunner = assertEx(\n await this.locator?.getInstance<BlockRunner>(BlockRunnerMoniker),\n () => 'Unable to locate BlockRunner',\n )\n this._blockViewer = assertEx(\n await this.locator?.getInstance<BlockViewer>(BlockViewerMoniker),\n () => 'Unable to locate BlockViewer',\n )\n this._chainContractViewer = assertEx(\n await this.locator?.getInstance<ChainContractViewer>(ChainContractViewerMoniker),\n () => 'Unable to locate ChainContractViewer',\n )\n this._mempoolRunner = assertEx(\n await this.locator?.getInstance<MempoolRunner>(MempoolRunnerMoniker),\n () => 'Unable to locate MempoolRunner',\n )\n this._mempoolViewer = assertEx(\n await this.locator?.getInstance<MempoolViewer>(MempoolViewerMoniker),\n () => 'Unable to locate MempoolViewer',\n )\n this._stakeTotalsViewer = assertEx(\n await this.locator?.getInstance<StakeTotalsViewer>(StakeTotalsViewerMoniker),\n () => 'Unable to locate StakeTotalsViewer',\n )\n this._chainId = await this.chainContractViewer.chainId()\n }\n\n // async initLocator() {\n // const config = this.config\n // const endpoint = assertEx(config.services.apiEndpoint, () => 'API endpoint is required in config.services.apiEndpoint')\n // const transportFactory: TransportFactory = (schemas: RpcSchemaMap) => new HttpRpcTransport(endpoint, schemas)\n // const locator = await buildJsonRpcProviderLocatorV2(config, transportFactory)\n\n // const version = '1.0.0'\n // const telemetryConfig = buildTelemetryConfig(config, this.name, version, DefaultMetricsScrapePorts.producer)\n // const { traceProvider, meterProvider } = await startupSpanAsync('initTelemetry', () => initTelemetry(telemetryConfig))\n\n // locator.context.traceProvider = traceProvider\n // locator.context.meterProvider = meterProvider\n\n // locator.register(SimpleBlockRewardViewer.factory<SimpleBlockRewardViewer>(SimpleBlockRewardViewer.dependencies, {}))\n // locator.register(SimpleBlockValidationViewer.factory<SimpleBlockValidationViewer>(\n // SimpleBlockValidationViewer.dependencies,\n // { state: validateHydratedBlockState, protocol: validateHydratedBlock },\n // ))\n // locator.register(SimpleBlockRunner.factory<SimpleBlockRunner>(\n // SimpleBlockRunner.dependencies,\n // { account: this.params.account, rewardAddress: this.params.rewardAddress },\n // ))\n // return await initEvmProvidersIfAvailable(locator)\n // }\n\n override async startHandler() {\n await super.startHandler()\n // Register a timer to check if we should produce a block\n this.registerTimer('BlockProductionTimer', async () => {\n await this.produceBlock()\n }, 2000, this.blockProductionCheckInterval)\n\n if (SHOULD_REGISTER_REDECLARATION_INTENT_TIMER) {\n // Register a timer to check if we should redeclare the producer\n this.registerTimer('ProducerRedeclarationTimer', async () => {\n await this.redeclareIntent()\n }, TEN_MINUTES, TEN_MINUTES)\n }\n }\n\n protected calculateBlocksUntilProducerDeclarationExpiration(currentBlock: number): number {\n return (this._lastRedeclarationIntent?.exp ?? currentBlock) - currentBlock\n }\n\n protected async produceBlock(): Promise<void> {\n this._producerActorBlockProductionChecks.add(1, this._metricAttributes)\n await this.spanAsync('produceBlock', async () => {\n if (this._produceBlockMutex.isLocked()) {\n this.logger?.debug('Skipping block production, previous production still in progress')\n return\n }\n\n await this._produceBlockMutex.runExclusive(async () => {\n // Get the updated head\n const head = (await this.blockViewer.currentBlock())[0]\n const headHash = head._hash\n\n // Track head changes\n const currentTime = Date.now()\n if (this._lastHeadHash !== headHash) {\n const lastHeadHashHex = isDefined(this._lastHeadHash) ? `0x${this._lastHeadHash}` : 'undefined'\n const currentHeadHashHex = `0x${headHash}`\n this.logger?.log(`Found updated head ${lastHeadHashHex} -> ${currentHeadHashHex}`)\n this._lastHeadHash = headHash\n this._lastHeadChangeTime = currentTime\n }\n\n // Check if we should resubmit due to stale head\n const timeSinceHeadChange = isDefined(this._lastHeadChangeTime) ? currentTime - this._lastHeadChangeTime : 0\n\n // If we have never produced a block or the last produced block was not built on the current head we\n // need to attempt to produce a new block\n const shouldSubmit = !this._lastProducedBlock || this._lastProducedBlock[0].previous !== headHash\n\n // If the head has not changed determine if we should resubmit again based on head staleness\n const shouldResubmit = timeSinceHeadChange > this.headResubmissionThreshold\n\n // Determine if we should submit or resubmit\n const shouldSubmitBlock = shouldSubmit || shouldResubmit\n\n if (!shouldSubmitBlock) {\n this.logger?.debug('No block submission required at this time.')\n return\n }\n\n if (shouldResubmit) {\n this.logger?.log(`Resubmitting block due to stale head. Head ${toFormattedBlockReference(head)} unchanged for ${timeSinceHeadChange}ms`)\n this._lastHeadChangeTime = currentTime\n }\n this._producerActorBlockProductionAttempts.add(1, this._metricAttributes)\n // Produce the next block (do not pass force — undefined result is valid when idle)\n const nextBlock = await this.blockRunner.produceNextBlock(head)\n if (nextBlock) {\n const displayBlockNumber = toFormattedBlockReference(nextBlock[0])\n this.logger?.log('Produced block:', displayBlockNumber)\n this._producerActorBlocksProduced.add(1, this._metricAttributes)\n await this.mempoolRunner.submitBlocks([nextBlock])\n this.logger?.log('Published block:', displayBlockNumber)\n this._producerActorBlocksPublished.add(1, this._metricAttributes)\n this._lastProducedBlock = nextBlock\n } else {\n this.logger?.log('No block produced for submission.')\n }\n })\n }, { ...this.context, timeBudgetLimit: 1000 })\n }\n\n protected override async readyHandler(): Promise<void> {\n // Warm pass: prove the production loop reaches its dependencies before declaring ready.\n await this.produceBlock()\n }\n\n protected async redeclareIntent(): Promise<void> {\n await this.spanAsync('redeclareIntent', async () => {\n // Decide if we should redeclare intent\n if (this.config.disableIntentRedeclaration) return\n\n // Get the current block\n const head = (await this.blockViewer.currentBlock())[0]\n if (isUndefined(head)) return\n const currentBlock = head.block\n\n // // Calculate the time until the producer's declaration expires\n const blocksUntilExpiration = this.calculateBlocksUntilProducerDeclarationExpiration(currentBlock)\n\n // Allow the producer time to redeclare itself via block production\n // (for free) before submitting a redeclaration intent transaction.\n if (blocksUntilExpiration > ProducerActor.RedeclarationWindow * 0.1) {\n // Clear any previous redeclaration intent\n this._lastRedeclarationIntent = undefined\n // No need to redeclare yet\n return\n }\n\n // If we already have a valid redeclaration intent, do not create another\n // unless it has expired.\n if (this._lastRedeclarationIntent) {\n // Check if the last redeclaration intent is still valid\n if (this._lastRedeclarationIntent.exp > currentBlock) return\n // If it has expired, clear the last redeclaration intent\n this._lastRedeclarationIntent = undefined\n }\n\n // Check if we have a valid balance before declaring intent\n if (!await this.validateCurrentBalance()) {\n this.logger?.error(\n `Add balance to address ${this.account.address} for the producer to declare it's intent.`,\n )\n return\n }\n\n // Check if we have a valid stake before declaring intent\n if (!(await this.validateCurrentStake())) {\n this.logger?.error(\n `Add stake to contract address ${this.chainId}`\n + ' for the producer to declare it\\'s intent.',\n )\n return\n }\n\n // Create a redeclaration intent\n this.logger?.log('Creating redeclaration intent for producer:', this.account.address)\n const redeclarationIntent = createDeclarationIntent(\n this.account.address,\n 'producer',\n currentBlock,\n currentBlock + SimpleBlockRunner.RedeclarationDuration,\n )\n\n // Submit the redeclaration intent\n await this.submitRedeclarationIntent(currentBlock, redeclarationIntent)\n\n // On successful submission, save the redeclaration intent\n this._lastRedeclarationIntent = redeclarationIntent\n }, { ...this.context, timeBudgetLimit: 1000 })\n }\n\n protected async submitRedeclarationIntent(currentBlock: XL1BlockNumber, redeclarationIntent: ChainStakeIntent): Promise<void> {\n this.logger?.log('Submitting redeclaration intent for producer:', this.account.address)\n // Create a transaction to submit the redeclaration intent\n const tx = await buildTransaction(\n this.chainId,\n [redeclarationIntent],\n [],\n this.account,\n currentBlock,\n asXL1BlockNumber(currentBlock + 1000, true),\n )\n\n // Submit the redeclaration intent\n await this.mempoolRunner.submitTransactions([tx])\n\n this.logger?.log('Submitted redeclaration intent for producer:', this.account.address)\n }\n\n protected async validateCurrentBalance(): Promise<boolean> {\n // Check if we have a valid balance before declaring intent\n const head = (await this.blockViewer.currentBlock())?.[0]?._hash\n if (isDefined(head)) {\n const balances = await this.accountBalanceViewer.accountBalances([this.account.address], { head })\n const currentBalance = balances[this.account.address] ?? 0n\n if (currentBalance <= 0n) {\n this.logger?.error(`Producer ${this.account.address} has no balance.`)\n return false\n }\n return true\n }\n return true\n }\n\n protected async validateCurrentStake(): Promise<boolean> {\n // Use StakeIntentService to get the required minimum stake\n const requiredMinimumStake = 1n // this.stakeIntentService.getRequiredMinimumStakeForIntent('producer')\n // Check if we have a valid stake before declaring intent\n const currentStake = await this.stakeTotalsViewer.activeByStaked(this.account.address)\n if (currentStake < requiredMinimumStake) {\n this.logger?.error(`Producer ${this.account.address} has insufficient stake.`)\n return false\n }\n return true\n }\n}\n"],"mappings":";;;;AACA,SAASA,yBAAyB;;;ACAlC,SAASC,cAAc;AACvB,SACEC,uBAGK;;;ACLP,SACEC,UAAUC,WAAWC,WAAWC,aA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J,SAAS,UAAA,EAAYK,QAAQC,MAAM,GAAGL,cAAcD,SAAS,UAAA,CAAW;IACpH,GAJS;EAKX;AACF;AAXgBR;","names":["ProducerConfigZod","exists","initActorWallet","assertEx","creatable","isDefined","isUndefined","toHex","ActorV3","DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL","SimpleBlockRunner","AccountBalanceViewerMoniker","asXL1BlockNumber","BlockRunnerMoniker","BlockViewerMoniker","buildTransaction","ChainContractViewerMoniker","createDeclarationIntent","FinalizationViewerMoniker","MempoolRunnerMoniker","MempoolViewerMoniker","StakeTotalsViewerMoniker","Mutex","SHOULD_REGISTER_REDECLARATION_INTENT_TIMER","TEN_MINUTES","toFormattedBlockReference","blockBoundWitness","block","toHex","_hash","prefix","ProducerActor","ActorV3","DefaultBlockProductionCheckInterval","DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL","HeadResubmissionMultiplier","RedeclarationWindow","needs","required","AccountBalanceViewerMoniker","BlockRunnerMoniker","BlockViewerMoniker","ChainContractViewerMoniker","FinalizationViewerMoniker","MempoolRunnerMoniker","MempoolViewerMoniker","StakeTotalsViewerMoniker","_lastProducedBlock","_lastRedeclarationIntent","_metricAttributes","_producerActorBlockProductionAttempts","_producerActorBlockProductionChecks","_producerActorBlocksProduced","_producerActorBlocksPublished","_accountBalanceViewer","_blockRunner","_blockViewer","_chainContractViewer","_chainId","_lastHeadChangeTime","_lastHeadHash","_mempoolRunner","_mempoolViewer","_produceBlockMutex","Mutex","_stakeTotalsViewer","logger","assertEx","accountBalanceViewer","blockProductionCheckInterval","config","blockRunner","blockViewer","chainContractViewer","chainId","params","headResubmissionThreshold","mempoolRunner","mempoolViewer","stakeTotalsViewer","createHandler","address","account","toString","counter","final","locator","getInstance","start","startHandler","registerTimer","produceBlock","redeclareIntent","calculateBlocksUntilProducerDeclarationExpiration","currentBlock","exp","add","spanAsync","isLocked","debug","runExclusive","head","headHash","currentTime","Date","now","lastHeadHashHex","isDefined","currentHeadHashHex","log","timeSinceHeadChange","shouldSubmit","previous","shouldResubmit","shouldSubmitBlock","nextBlock","produceNextBlock","displayBlockNumber","submitBlocks","context","timeBudgetLimit","readyHandler","disableIntentRedeclaration","isUndefined","blocksUntilExpiration","undefined","validateCurrentBalance","error","validateCurrentStake","redeclarationIntent","createDeclarationIntent","SimpleBlockRunner","RedeclarationDuration","submitRedeclarationIntent","tx","buildTransaction","asXL1BlockNumber","submitTransactions","balances","accountBalances","currentBalance","requiredMinimumStake","currentStake","activeByStaked","getProducerActor","config","locator","account","initActorWallet","context","ProducerActor","create","name","runProducer","orchestrator","producer","actors","filter","exists","actor","registerActor","start","producerCommand","getConfiguration","getLocatorsFromConfig","command","deprecated","describe","handler","configuration","locators","orchestrator","runProducer","ProducerConfigZod","parse","context","config"]}
@@ -1,4 +1,6 @@
1
1
  import { type OrchestratorInstance, type ProducerConfig } from '@xyo-network/chain-orchestration';
2
2
  import type { ProviderFactoryLocatorInstance } from '@xyo-network/xl1-sdk';
3
+ import { ProducerActor } from './ProducerActor.ts';
4
+ export declare const getProducerActor: (config: ProducerConfig, locator: ProviderFactoryLocatorInstance) => Promise<ProducerActor>;
3
5
  export declare const runProducer: (config: ProducerConfig, orchestrator: OrchestratorInstance, locator: ProviderFactoryLocatorInstance) => Promise<void>;
4
- //# sourceMappingURL=runProducer.d.ts.map
6
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAA;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,cAAc,EACtB,SAAS,8BAA8B,KACtC,OAAO,CAAC,aAAa,CAKvB,CAAA;AAED,eAAO,MAAM,WAAW,GACtB,QAAQ,cAAc,EACtB,cAAc,oBAAoB,EAClC,SAAS,8BAA8B,kBASxC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/chain-producer",
3
- "version": "1.20.29",
3
+ "version": "1.21.2",
4
4
  "description": "XYO Layer One Producer",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -35,66 +35,66 @@
35
35
  "README.md"
36
36
  ],
37
37
  "dependencies": {
38
- "@xyo-network/chain-orchestration": "~1.20.29",
39
- "@xyo-network/chain-services": "~1.20.29"
38
+ "@xyo-network/chain-orchestration": "~1.21.2",
39
+ "@xyo-network/chain-services": "~1.21.2"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@bitauth/libauth": "~3.0.0",
43
- "@metamask/json-rpc-engine": "^10.2.4",
43
+ "@metamask/json-rpc-engine": "^10.3.0",
44
44
  "@metamask/providers": "^22.1.1",
45
45
  "@metamask/utils": "~11.11.0",
46
46
  "@opentelemetry/api": "^1.9.1",
47
47
  "@opentelemetry/context-async-hooks": "~2.7.1",
48
48
  "@opentelemetry/context-zone": "~2.7.1",
49
49
  "@opentelemetry/core": "~2.7.1",
50
- "@opentelemetry/exporter-prometheus": "~0.216.0",
51
- "@opentelemetry/exporter-trace-otlp-grpc": "~0.216.0",
52
- "@opentelemetry/exporter-trace-otlp-http": "~0.216.0",
50
+ "@opentelemetry/exporter-prometheus": "~0.217",
51
+ "@opentelemetry/exporter-trace-otlp-grpc": "~0.217",
52
+ "@opentelemetry/exporter-trace-otlp-http": "~0.217",
53
53
  "@opentelemetry/host-metrics": "~0.38.3",
54
- "@opentelemetry/instrumentation-runtime-node": "~0.29.0",
54
+ "@opentelemetry/instrumentation-runtime-node": "~0.30",
55
55
  "@opentelemetry/resources": "~2.7.1",
56
56
  "@opentelemetry/sdk-metrics": "~2.7.1",
57
57
  "@opentelemetry/sdk-trace-base": "^2.7.1",
58
58
  "@opentelemetry/semantic-conventions": "~1.40.0",
59
59
  "@scure/base": "~2.2.0",
60
60
  "@scure/bip39": "~2.2.0",
61
- "@types/node": "^25.6.0",
62
- "@xylabs/express": "^5.0.101",
63
- "@xylabs/geo": "^5.0.101",
64
- "@xylabs/mongo": "^5.0.101",
65
- "@xylabs/sdk-js": "^5.0.101",
66
- "@xylabs/threads": "~5.0.101",
67
- "@xylabs/toolchain": "~7.12.3",
68
- "@xylabs/tsconfig": "~7.12.3",
69
- "@xyo-network/account": "~5.5.2",
70
- "@xyo-network/account-model": "~5.5.2",
71
- "@xyo-network/api": "~5.5.2",
72
- "@xyo-network/api-models": "~5.5.2",
73
- "@xyo-network/archivist-lmdb": "~5.5.6",
74
- "@xyo-network/archivist-mongodb": "~5.5.6",
75
- "@xyo-network/archivist-view": "~5.5.6",
61
+ "@types/yargs": "^17.0.35",
62
+ "@xylabs/express": "^5.1.1",
63
+ "@xylabs/fetch": "~5.1.1",
64
+ "@xylabs/geo": "^5.1.1",
65
+ "@xylabs/mongo": "^5.1.1",
66
+ "@xylabs/sdk-js": "^5.1.1",
67
+ "@xylabs/threads": "~5.1.1",
68
+ "@xylabs/toolchain": "~7.13.13",
69
+ "@xylabs/tsconfig": "~7.13.13",
70
+ "@xyo-network/account": "~5.6.1",
71
+ "@xyo-network/account-model": "~5.6.2",
72
+ "@xyo-network/api": "~5.6.1",
73
+ "@xyo-network/api-models": "~5.6.2",
74
+ "@xyo-network/archivist-lmdb": "~5.6.3",
75
+ "@xyo-network/archivist-mongodb": "~5.6.3",
76
+ "@xyo-network/archivist-view": "~5.6.3",
76
77
  "@xyo-network/bios-model": "~7.3.0",
77
- "@xyo-network/boundwitness-builder": "~5.5.2",
78
- "@xyo-network/boundwitness-model": "~5.5.2",
79
- "@xyo-network/boundwitness-validator": "~5.5.2",
80
- "@xyo-network/boundwitness-wrapper": "~5.5.2",
81
- "@xyo-network/config-payload-plugin": "~5.5.2",
82
- "@xyo-network/huri": "~5.5.2",
83
- "@xyo-network/manifest-model": "~5.5.2",
84
- "@xyo-network/payload-builder": "~5.5.2",
85
- "@xyo-network/payload-model": "~5.5.2",
86
- "@xyo-network/payload-plugin": "~5.5.2",
87
- "@xyo-network/payload-wrapper": "~5.5.2",
88
- "@xyo-network/query-payload-plugin": "~5.5.2",
89
- "@xyo-network/sdk-js": "^5.5.6",
90
- "@xyo-network/sdk-protocol-js": "~5.5.2",
78
+ "@xyo-network/boundwitness-builder": "~5.6.1",
79
+ "@xyo-network/boundwitness-model": "~5.6.2",
80
+ "@xyo-network/boundwitness-wrapper": "~5.6.1",
81
+ "@xyo-network/config-payload-plugin": "~5.6.2",
82
+ "@xyo-network/huri": "~5.6.1",
83
+ "@xyo-network/manifest-model": "~5.6.2",
84
+ "@xyo-network/payload-builder": "~5.6.1",
85
+ "@xyo-network/payload-model": "~5.6.2",
86
+ "@xyo-network/payload-plugin": "~5.6.2",
87
+ "@xyo-network/payload-wrapper": "~5.6.1",
88
+ "@xyo-network/query-payload-plugin": "~5.6.2",
89
+ "@xyo-network/sdk-js": "^5.6.3",
90
+ "@xyo-network/sdk-protocol-js": "~5.6.2",
91
91
  "@xyo-network/typechain": "^4.1.3",
92
- "@xyo-network/wallet": "~5.5.2",
93
- "@xyo-network/wallet-model": "^5.5.2",
94
- "@xyo-network/xl1-sdk": "^1.26.44",
92
+ "@xyo-network/wallet": "~5.6.1",
93
+ "@xyo-network/wallet-model": "^5.6.2",
94
+ "@xyo-network/xl1-protocol-sdk": "~1.28",
95
+ "@xyo-network/xl1-sdk": "^1.28.0",
95
96
  "ajv": "^8.20.0",
96
97
  "async-mutex": "^0.5.0",
97
- "axios": "^1.15.2",
98
98
  "bn.js": "^5.2.3",
99
99
  "body-parser": "~2.2.2",
100
100
  "buffer": "^6.0.3",
@@ -105,8 +105,7 @@
105
105
  "cosmiconfig": "^9.0.1",
106
106
  "debug": "~4.4.3",
107
107
  "dotenv": "~17.4.2",
108
- "esbuild": "^0.28.0",
109
- "eslint": "^10.2.1",
108
+ "eslint": "^10.3.0",
110
109
  "ethers": "^6.16.0",
111
110
  "express": "^5.2.1",
112
111
  "express-mung": "~0.5.1",
@@ -114,8 +113,8 @@
114
113
  "http-status-codes": "~2.3.0",
115
114
  "idb": "^8.0.3",
116
115
  "lmdb": "^3.5.4",
117
- "lru-cache": "^11.3.5",
118
- "mapbox-gl": "^3.23.0",
116
+ "lru-cache": "^11.3.6",
117
+ "mapbox-gl": "^3.23.1",
119
118
  "mongodb": "^7.2.0",
120
119
  "nodemon": "~3.1.14",
121
120
  "observable-fns": "~0.6.1",
@@ -133,86 +132,93 @@
133
132
  "webextension-polyfill": "^0.12.0",
134
133
  "winston": "~3.19.0",
135
134
  "winston-transport": "~4.9.0",
136
- "zod": "~4.4.2"
135
+ "zod": "~4.4.3"
137
136
  },
138
137
  "peerDependencies": {
139
- "@bitauth/libauth": ">=3.0.0 <3.1",
140
- "@metamask/json-rpc-engine": ">=10.2.4 <11",
141
- "@metamask/providers": ">=22.1.1 <23",
142
- "@metamask/utils": ">=11.11.0 <11.12",
143
- "@opentelemetry/api": ">=1.9.1 <2",
144
- "@opentelemetry/context-async-hooks": ">=2.7.1 <2.8",
145
- "@opentelemetry/context-zone": ">=2.7.1 <2.8",
146
- "@opentelemetry/core": ">=2.7.1 <2.8",
147
- "@opentelemetry/exporter-prometheus": ">=0.216.0 <0.217",
148
- "@opentelemetry/exporter-trace-otlp-grpc": ">=0.216.0 <0.217",
149
- "@opentelemetry/exporter-trace-otlp-http": ">=0.216.0 <0.217",
150
- "@opentelemetry/host-metrics": ">=0.38.3 <0.39",
151
- "@opentelemetry/instrumentation-runtime-node": ">=0.29.0 <0.30",
152
- "@opentelemetry/resources": ">=2.7.1 <2.8",
153
- "@opentelemetry/sdk-metrics": ">=2.7.1 <2.8",
154
- "@opentelemetry/sdk-trace-base": ">=2.7.1 <3",
155
- "@opentelemetry/semantic-conventions": ">=1.40.0 <1.41",
156
- "@scure/base": ">=2.2.0 <2.3",
157
- "@scure/bip39": ">=2.2.0 <2.3",
158
- "@xylabs/express": ">=5.0.101 <6",
159
- "@xylabs/geo": ">=5.0.101 <6",
160
- "@xylabs/mongo": ">=5.0.101 <6",
161
- "@xylabs/sdk-js": ">=5.0.101 <6",
162
- "@xylabs/threads": ">=5.0.101 <5.1",
163
- "@xyo-network/account": ">=5.5.2 <5.6",
164
- "@xyo-network/account-model": ">=5.5.2 <5.6",
165
- "@xyo-network/api": ">=5.5.2 <5.6",
166
- "@xyo-network/api-models": ">=5.5.2 <5.6",
167
- "@xyo-network/archivist-lmdb": ">=5.5.6 <5.6",
168
- "@xyo-network/archivist-mongodb": ">=5.5.6 <5.6",
169
- "@xyo-network/archivist-view": ">=5.5.6 <5.6",
170
- "@xyo-network/bios-model": ">=7.3.0 <7.4",
171
- "@xyo-network/boundwitness-builder": ">=5.5.2 <5.6",
172
- "@xyo-network/boundwitness-model": ">=5.5.2 <5.6",
173
- "@xyo-network/boundwitness-validator": ">=5.5.2 <5.6",
174
- "@xyo-network/boundwitness-wrapper": ">=5.5.2 <5.6",
175
- "@xyo-network/config-payload-plugin": ">=5.5.2 <5.6",
176
- "@xyo-network/huri": ">=5.5.2 <5.6",
177
- "@xyo-network/manifest-model": ">=5.5.2 <5.6",
178
- "@xyo-network/payload-builder": ">=5.5.2 <5.6",
179
- "@xyo-network/payload-model": ">=5.5.2 <5.6",
180
- "@xyo-network/payload-plugin": ">=5.5.2 <5.6",
181
- "@xyo-network/payload-wrapper": ">=5.5.2 <5.6",
182
- "@xyo-network/query-payload-plugin": ">=5.5.2 <5.6",
183
- "@xyo-network/sdk-js": ">=5.5.6 <6",
184
- "@xyo-network/sdk-protocol-js": ">=5.5.2 <5.6",
185
- "@xyo-network/typechain": ">=4.1.3 <5",
186
- "@xyo-network/wallet": ">=5.5.2 <5.6",
187
- "@xyo-network/wallet-model": ">=5.5.2 <6",
188
- "@xyo-network/xl1-sdk": ">=1.26.44 <2",
189
- "ajv": ">=8.20.0 <9",
190
- "async-mutex": ">=0.5.0 <1",
191
- "axios": ">=1.15.2 <2",
192
- "bn.js": ">=5.2.3 <6",
193
- "buffer": ">=6.0.3 <7",
194
- "chalk": ">=5.6.2 <6",
195
- "compression": ">=1.8.1 <1.9",
196
- "cors": ">=2.8.6 <2.9",
197
- "cosmiconfig": ">=9.0.1 <10",
198
- "debug": ">=4.4.3 <4.5",
199
- "ethers": ">=6.16.0 <7",
200
- "express": ">=5.2.1 <6",
201
- "hash-wasm": ">=4.12.0 <4.13",
202
- "idb": ">=8.0.3 <9",
203
- "lmdb": ">=3.5.4 <4",
204
- "lru-cache": ">=11.3.5 <12",
205
- "mapbox-gl": ">=3.23.0 <4",
206
- "mongodb": ">=7.2.0 <8",
207
- "observable-fns": ">=0.6.1 <0.7",
208
- "pako": ">=2.1.0 <3",
209
- "shallowequal": ">=1.1.0 <1.2",
210
- "store2": ">=2.14.4 <2.15",
211
- "typescript": ">=5.9.3 <5.10",
212
- "uuid": ">=14.0.0 <14.1",
213
- "wasm-feature-detect": ">=1.8.0 <1.9",
214
- "web3-types": ">=1.10.0 <1.11",
215
- "zod": ">=4.4.2 <4.5"
138
+ "@bitauth/libauth": "~3.0",
139
+ "@metamask/json-rpc-engine": "^10.3",
140
+ "@metamask/providers": "^22.1",
141
+ "@metamask/utils": "~11.11",
142
+ "@opentelemetry/api": "^1.9",
143
+ "@opentelemetry/context-async-hooks": "~2.7",
144
+ "@opentelemetry/context-zone": "~2.7",
145
+ "@opentelemetry/core": "~2.7",
146
+ "@opentelemetry/exporter-prometheus": "~0.217",
147
+ "@opentelemetry/exporter-trace-otlp-grpc": "~0.217",
148
+ "@opentelemetry/exporter-trace-otlp-http": "~0.217",
149
+ "@opentelemetry/host-metrics": "~0.38",
150
+ "@opentelemetry/instrumentation-runtime-node": "~0.30",
151
+ "@opentelemetry/resources": "~2.7",
152
+ "@opentelemetry/sdk-metrics": "~2.7",
153
+ "@opentelemetry/sdk-trace-base": "^2.7",
154
+ "@opentelemetry/semantic-conventions": "~1.40",
155
+ "@scure/base": "~2.2",
156
+ "@scure/bip39": "~2.2",
157
+ "@xylabs/express": "^5.1",
158
+ "@xylabs/fetch": "~5.1",
159
+ "@xylabs/geo": "^5.1",
160
+ "@xylabs/mongo": "^5.1",
161
+ "@xylabs/sdk-js": "^5.1",
162
+ "@xylabs/threads": "~5.1",
163
+ "@xyo-network/account": "~5.6",
164
+ "@xyo-network/account-model": "~5.6",
165
+ "@xyo-network/api": "~5.6",
166
+ "@xyo-network/api-models": "~5.6",
167
+ "@xyo-network/archivist-lmdb": "~5.6",
168
+ "@xyo-network/archivist-mongodb": "~5.6",
169
+ "@xyo-network/archivist-view": "~5.6",
170
+ "@xyo-network/bios-model": "~7.3",
171
+ "@xyo-network/boundwitness-builder": "~5.6",
172
+ "@xyo-network/boundwitness-model": "~5.6",
173
+ "@xyo-network/boundwitness-wrapper": "~5.6",
174
+ "@xyo-network/config-payload-plugin": "~5.6",
175
+ "@xyo-network/huri": "~5.6",
176
+ "@xyo-network/manifest-model": "~5.6",
177
+ "@xyo-network/payload-builder": "~5.6",
178
+ "@xyo-network/payload-model": "~5.6",
179
+ "@xyo-network/payload-plugin": "~5.6",
180
+ "@xyo-network/payload-wrapper": "~5.6",
181
+ "@xyo-network/query-payload-plugin": "~5.6",
182
+ "@xyo-network/sdk-js": "^5.6",
183
+ "@xyo-network/sdk-protocol-js": "~5.6",
184
+ "@xyo-network/typechain": "^4.1",
185
+ "@xyo-network/wallet": "~5.6",
186
+ "@xyo-network/wallet-model": "^5.6",
187
+ "@xyo-network/xl1-protocol-sdk": "~1.28",
188
+ "@xyo-network/xl1-sdk": "^1.28",
189
+ "ajv": "^8.20",
190
+ "async-mutex": "^0.5",
191
+ "bn.js": "^5.2",
192
+ "body-parser": "~2.2",
193
+ "buffer": "^6.0",
194
+ "chalk": "^5.6",
195
+ "compression": "~1.8",
196
+ "connect": "^3.7",
197
+ "cors": "~2.8",
198
+ "cosmiconfig": "^9.0",
199
+ "debug": "~4.4",
200
+ "ethers": "^6.16",
201
+ "express": "^5.2",
202
+ "express-mung": "~0.5",
203
+ "hash-wasm": "~4.12",
204
+ "http-status-codes": "~2.3",
205
+ "idb": "^8.0",
206
+ "lmdb": "^3.5",
207
+ "lru-cache": "^11.3",
208
+ "mapbox-gl": "^3.23",
209
+ "mongodb": "^7.2",
210
+ "observable-fns": "~0.6",
211
+ "pako": "^2.1",
212
+ "rollbar": "^3.1",
213
+ "shallowequal": "~1.1",
214
+ "store2": "~2.14",
215
+ "uuid": "~14.0",
216
+ "wasm-feature-detect": "~1.8",
217
+ "web3-types": "~1.10",
218
+ "webextension-polyfill": "^0.12",
219
+ "winston": "~3.19",
220
+ "winston-transport": "~4.9",
221
+ "zod": "~4.4"
216
222
  },
217
223
  "engines": {
218
224
  "node": ">=24"
@@ -1 +0,0 @@
1
- {"version":3,"file":"runProducer.d.ts","sourceRoot":"","sources":["../../src/runProducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAA;AACzC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAA;AAK1E,eAAO,MAAM,WAAW,GACtB,QAAQ,cAAc,EACtB,cAAc,oBAAoB,EAClC,SAAS,8BAA8B,kBAexC,CAAA"}