@xyo-network/chain-producer 1.20.28 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/ProducerActor.d.ts +9 -8
- package/dist/node/ProducerActor.d.ts.map +1 -1
- package/dist/node/command.d.ts +5 -0
- package/dist/node/command.d.ts.map +1 -0
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.mjs +58 -24
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{runProducer.d.ts → run.d.ts} +3 -1
- package/dist/node/run.d.ts.map +1 -0
- package/package.json +122 -116
- package/dist/node/runProducer.d.ts.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Attributes, Counter } from '@opentelemetry/api';
|
|
2
|
-
import { type ProducerConfig } from '@xyo-network/chain-orchestration';
|
|
3
|
-
import type { AccountBalanceViewer,
|
|
4
|
-
import { ActorV3 } from '@xyo-network/xl1-sdk';
|
|
2
|
+
import { type ActorCapabilityNeeds, type ActorParamsV3, ActorV3, type ProducerConfig } from '@xyo-network/chain-orchestration';
|
|
3
|
+
import type { AccountBalanceViewer, BlockRunner, BlockViewer, ChainContractViewer, ChainStakeIntent, HydratedBlockWithHashMeta, MempoolRunner, MempoolViewer, StakeTotalsViewer, XL1BlockNumber } from '@xyo-network/xl1-sdk';
|
|
5
4
|
export type ProducerActorParams = ActorParamsV3<{
|
|
6
5
|
config: ProducerConfig;
|
|
7
6
|
}>;
|
|
@@ -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
|
|
26
|
-
protected _producerActorBlockProductionChecks
|
|
27
|
-
protected _producerActorBlocksProduced
|
|
28
|
-
protected _producerActorBlocksPublished
|
|
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" | "
|
|
67
|
+
logLevel: "log" | "info" | "error" | "warn" | "debug" | "trace";
|
|
68
68
|
silent: boolean;
|
|
69
69
|
};
|
|
70
70
|
providers: {
|
|
@@ -140,6 +140,7 @@ export declare class ProducerActor extends ActorV3<ProducerActorParams> {
|
|
|
140
140
|
startHandler(): Promise<void>;
|
|
141
141
|
protected calculateBlocksUntilProducerDeclarationExpiration(currentBlock: number): number;
|
|
142
142
|
protected produceBlock(): Promise<void>;
|
|
143
|
+
protected readyHandler(): Promise<void>;
|
|
143
144
|
protected redeclareIntent(): Promise<void>;
|
|
144
145
|
protected submitRedeclarationIntent(currentBlock: XL1BlockNumber, redeclarationIntent: ChainStakeIntent): Promise<void>;
|
|
145
146
|
protected validateCurrentBalance(): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProducerActor.d.ts","sourceRoot":"","sources":["../../src/ProducerActor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAK7D,OAAO,
|
|
1
|
+
{"version":3,"file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O,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"}
|
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,
|
|
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"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
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
|
-
import { DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL } from "@xyo-network/chain-orchestration";
|
|
13
|
+
import { ActorV3, DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL } from "@xyo-network/chain-orchestration";
|
|
7
14
|
import { SimpleBlockRunner } from "@xyo-network/chain-services";
|
|
8
|
-
import { AccountBalanceViewerMoniker,
|
|
15
|
+
import { AccountBalanceViewerMoniker, asXL1BlockNumber, BlockRunnerMoniker, BlockViewerMoniker, buildTransaction, ChainContractViewerMoniker, createDeclarationIntent, FinalizationViewerMoniker, MempoolRunnerMoniker, MempoolViewerMoniker, StakeTotalsViewerMoniker } from "@xyo-network/xl1-sdk";
|
|
9
16
|
import { Mutex } from "async-mutex";
|
|
10
17
|
function _ts_decorate(decorators, target, key, desc) {
|
|
11
18
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -38,6 +45,18 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
38
45
|
* The window (in blocks) before expiration to attempt redeclaration of producer intent.
|
|
39
46
|
*/
|
|
40
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
|
+
};
|
|
41
60
|
_lastProducedBlock;
|
|
42
61
|
_lastRedeclarationIntent;
|
|
43
62
|
_metricAttributes;
|
|
@@ -97,18 +116,10 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
97
116
|
this._metricAttributes = {
|
|
98
117
|
address: this.account.address.toString()
|
|
99
118
|
};
|
|
100
|
-
this._producerActorBlockProductionChecks = this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
description: "Number of block production attempts"
|
|
105
|
-
});
|
|
106
|
-
this._producerActorBlocksProduced = this.meter?.createCounter("producer_actor_blocks_produced", {
|
|
107
|
-
description: "Number of blocks produced"
|
|
108
|
-
});
|
|
109
|
-
this._producerActorBlocksPublished = this.meter?.createCounter("producer_actor_blocks_published", {
|
|
110
|
-
description: "Number of blocks published"
|
|
111
|
-
});
|
|
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");
|
|
112
123
|
const final = await this.locator?.getInstance(FinalizationViewerMoniker);
|
|
113
124
|
await final.start();
|
|
114
125
|
this._accountBalanceViewer = assertEx(await this.locator?.getInstance(AccountBalanceViewerMoniker), () => "Unable to locate AccountBalanceViewer");
|
|
@@ -156,7 +167,7 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
156
167
|
return (this._lastRedeclarationIntent?.exp ?? currentBlock) - currentBlock;
|
|
157
168
|
}
|
|
158
169
|
async produceBlock() {
|
|
159
|
-
this._producerActorBlockProductionChecks
|
|
170
|
+
this._producerActorBlockProductionChecks.add(1, this._metricAttributes);
|
|
160
171
|
await this.spanAsync("produceBlock", async () => {
|
|
161
172
|
if (this._produceBlockMutex.isLocked()) {
|
|
162
173
|
this.logger?.debug("Skipping block production, previous production still in progress");
|
|
@@ -185,17 +196,17 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
185
196
|
this.logger?.log(`Resubmitting block due to stale head. Head ${toFormattedBlockReference(head)} unchanged for ${timeSinceHeadChange}ms`);
|
|
186
197
|
this._lastHeadChangeTime = currentTime;
|
|
187
198
|
}
|
|
188
|
-
this._producerActorBlockProductionAttempts
|
|
199
|
+
this._producerActorBlockProductionAttempts.add(1, this._metricAttributes);
|
|
189
200
|
const nextBlock = await this.blockRunner.produceNextBlock(head);
|
|
190
201
|
if (nextBlock) {
|
|
191
202
|
const displayBlockNumber = toFormattedBlockReference(nextBlock[0]);
|
|
192
203
|
this.logger?.log("Produced block:", displayBlockNumber);
|
|
193
|
-
this._producerActorBlocksProduced
|
|
204
|
+
this._producerActorBlocksProduced.add(1, this._metricAttributes);
|
|
194
205
|
await this.mempoolRunner.submitBlocks([
|
|
195
206
|
nextBlock
|
|
196
207
|
]);
|
|
197
208
|
this.logger?.log("Published block:", displayBlockNumber);
|
|
198
|
-
this._producerActorBlocksPublished
|
|
209
|
+
this._producerActorBlocksPublished.add(1, this._metricAttributes);
|
|
199
210
|
this._lastProducedBlock = nextBlock;
|
|
200
211
|
} else {
|
|
201
212
|
this.logger?.log("No block produced for submission.");
|
|
@@ -206,6 +217,9 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
206
217
|
timeBudgetLimit: 1e3
|
|
207
218
|
});
|
|
208
219
|
}
|
|
220
|
+
async readyHandler() {
|
|
221
|
+
await this.produceBlock();
|
|
222
|
+
}
|
|
209
223
|
async redeclareIntent() {
|
|
210
224
|
await this.spanAsync("redeclareIntent", async () => {
|
|
211
225
|
if (this.config.disableIntentRedeclaration) return;
|
|
@@ -279,20 +293,21 @@ ProducerActor = _ts_decorate([
|
|
|
279
293
|
creatable()
|
|
280
294
|
], ProducerActor);
|
|
281
295
|
|
|
282
|
-
// src/
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
var runProducer = /* @__PURE__ */ __name(async (config, orchestrator, locator) => {
|
|
286
|
-
const account = await initActorAccount({
|
|
296
|
+
// src/run.ts
|
|
297
|
+
var getProducerActor = /* @__PURE__ */ __name(async (config, locator) => {
|
|
298
|
+
const account = await initActorWallet({
|
|
287
299
|
...locator.context,
|
|
288
300
|
config
|
|
289
301
|
});
|
|
290
|
-
|
|
302
|
+
return await ProducerActor.create({
|
|
291
303
|
config,
|
|
292
304
|
locator,
|
|
293
305
|
name: "xl1-producer",
|
|
294
306
|
account
|
|
295
307
|
});
|
|
308
|
+
}, "getProducerActor");
|
|
309
|
+
var runProducer = /* @__PURE__ */ __name(async (config, orchestrator, locator) => {
|
|
310
|
+
const producer = await getProducerActor(config, locator);
|
|
296
311
|
const actors = [
|
|
297
312
|
producer
|
|
298
313
|
].filter(exists);
|
|
@@ -301,8 +316,27 @@ var runProducer = /* @__PURE__ */ __name(async (config, orchestrator, locator) =
|
|
|
301
316
|
}
|
|
302
317
|
await orchestrator.start();
|
|
303
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");
|
|
304
336
|
export {
|
|
305
337
|
ProducerActor,
|
|
338
|
+
getProducerActor,
|
|
339
|
+
producerCommand,
|
|
306
340
|
runProducer
|
|
307
341
|
};
|
|
308
342
|
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -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 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, ActorParamsV3,\n BlockBoundWitness,\n BlockRunner, BlockViewer, ChainContractViewer, ChainId, ChainStakeIntent, FinalizationViewer, HydratedBlockWithHashMeta, MempoolRunner,\n MempoolViewer, StakeTotalsViewer, XL1BlockNumber,\n} from '@xyo-network/xl1-sdk'\nimport {\n AccountBalanceViewerMoniker, ActorV3, 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 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 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,SACEC,+CAEK;AACP,SAASC,yBAAyB;AAQlC,SACEC,6BAA6BC,SAASC,kBAAkBC,oBAAoBC,oBAC5EC,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;;;;;;EAIjC,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,MAAMD,QAAQ,MAAM,sCAAA;EACtC;EAEA,IAAcE,uBAAuB;AACnC,WAAO,KAAKd;EACd;EAEA,IAAce,+BAA+B;AAC3C,WAAO,KAAKC,OAAOD,gCAAgC5B,eAAcE;EACnE;EAEA,IAAc4B,cAAc;AAC1B,WAAO,KAAKhB;EACd;EAEA,IAAciB,cAAc;AAC1B,WAAO,KAAKhB;EACd;EAEA,IAAciB,sBAAsB;AAClC,WAAO,KAAKhB;EACd;EAEA,IAAciB,UAAU;AACtB,WAAO,KAAKhB;EACd;EAEA,IAAcY,SAAS;AACrB,WAAO,KAAKK,OAAOL;EACrB;EAEA,IAAcM,4BAA4B;AACxC,WAAO,KAAKP,+BAA+B5B,e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AM,KAAK/E,qBAAqBgF,gBAAgB;QAAC,KAAKlE,QAAQD;SAAU;QAAE8B;MAAK,CAAA;AAChG,YAAMsC,iBAAiBF,SAAS,KAAKjE,QAAQD,OAAO,KAAK;AACzD,UAAIoE,kBAAkB,IAAI;AACxB,aAAKnF,QAAQsE,MAAM,YAAY,KAAKtD,QAAQD,OAAO,kBAAkB;AACrE,eAAO;MACT;AACA,aAAO;IACT;AACA,WAAO;EACT;EAEA,MAAgBwD,uBAAyC;AAEvD,UAAMa,uBAAuB;AAE7B,UAAMC,eAAe,MAAM,KAAKxE,kBAAkByE,eAAe,KAAKtE,QAAQD,OAAO;AACrF,QAAIsE,eAAeD,sBAAsB;AACvC,WAAKpF,QAAQsE,MAAM,YAAY,KAAKtD,QAAQD,OAAO,0BAA0B;AAC7E,aAAO;IACT;AACA,WAAO;EACT;AACF;;;;;;AC3YA,SAASwE,cAAc;AACvB,SACEC,wBAGK;AAMA,IAAMC,cAAc,8BACzBC,QACAC,cACAC,YAAAA;AAEA,QAAMC,UAAU,MAAMC,iBAAiB;IAAE,GAAGF,QAAQG;IAASL;EAAO,CAAA;AAEpE,QAAMM,WAAW,MAAMC,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","DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL","SimpleBlockRunner","AccountBalanceViewerMoniker","ActorV3","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","_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","FinalizationViewerMoniker","start","AccountBalanceViewerMoniker","BlockRunnerMoniker","BlockViewerMoniker","ChainContractViewerMoniker","MempoolRunnerMoniker","MempoolViewerMoniker","StakeTotalsViewerMoniker","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","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,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;;;;;;EAIjC,OAAgBC,sCAAsCC;;;;;EAMtD,OAAgBC,6BAA6B;;;;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ZO,IAAM+D,mBAAmB,8BAC9BC,QACAC,YAAAA;AAEA,QAAMC,UAAU,MAAMC,gBAAgB;IAAE,GAAGF,QAAQG;IAASJ;EAAO,CAAA;AACnE,SAAO,MAAMK,cAAcC,OAAO;IAChCN;IAAQC;IAASM,MAAM;IAAiCL;EAC1D,CAAA;AACF,GARgC;AAUzB,IAAMM,cAAc,8BACzBR,QACAS,cACAR,YAAAA;AAEA,QAAMS,WAAW,MAAMX,iBAAiBC,QAAQC,OAAAA;AAChD,QAAMU,SAAS;IAACD;IAAUE,OAAOC,MAAAA;AAEjC,aAAWC,SAASH,QAAQ;AAC1B,UAAMF,aAAaM,cAAcD,KAAAA;EACnC;AACA,QAAML,aAAaO,MAAK;AAC1B,GAZ2B;;;ADfpB,SAASC,gBAAgBC,kBAAgCC,uBAA4C;AAC1G,SAAO;IACLC,SAAS;IACTC,YAAY;IACZC,UAAU;IACVC,SAAS,mCAAA;AACP,YAAMC,gBAAgBN,iBAAAA;AACtB,YAAM,EAAEO,UAAUC,aAAY,IAAK,MAAMP,sBAAsB;QAAC;SAAaK,aAAAA;AAC7E,YAAMG,YAAYC,kBAAkBC,MAAMJ,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=
|
|
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.
|
|
3
|
+
"version": "1.21.0",
|
|
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.
|
|
39
|
-
"@xyo-network/chain-services": "~1.
|
|
38
|
+
"@xyo-network/chain-orchestration": "~1.21.0",
|
|
39
|
+
"@xyo-network/chain-services": "~1.21.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@bitauth/libauth": "~3.0.0",
|
|
43
|
-
"@metamask/json-rpc-engine": "^10.
|
|
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
|
-
"@opentelemetry/context-async-hooks": "~2.7.
|
|
48
|
-
"@opentelemetry/context-zone": "~2.7.
|
|
49
|
-
"@opentelemetry/core": "~2.7.
|
|
50
|
-
"@opentelemetry/exporter-prometheus": "~0.
|
|
51
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "~0.
|
|
52
|
-
"@opentelemetry/exporter-trace-otlp-http": "~0.
|
|
47
|
+
"@opentelemetry/context-async-hooks": "~2.7.1",
|
|
48
|
+
"@opentelemetry/context-zone": "~2.7.1",
|
|
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",
|
|
53
53
|
"@opentelemetry/host-metrics": "~0.38.3",
|
|
54
|
-
"@opentelemetry/instrumentation-runtime-node": "~0.
|
|
55
|
-
"@opentelemetry/resources": "~2.7.
|
|
56
|
-
"@opentelemetry/sdk-metrics": "~2.7.
|
|
57
|
-
"@opentelemetry/sdk-trace-base": "^2.7.
|
|
54
|
+
"@opentelemetry/instrumentation-runtime-node": "~0.29.0",
|
|
55
|
+
"@opentelemetry/resources": "~2.7.1",
|
|
56
|
+
"@opentelemetry/sdk-metrics": "~2.7.1",
|
|
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/
|
|
62
|
-
"@xylabs/express": "^5.
|
|
63
|
-
"@xylabs/
|
|
64
|
-
"@xylabs/
|
|
65
|
-
"@xylabs/
|
|
66
|
-
"@xylabs/
|
|
67
|
-
"@xylabs/
|
|
68
|
-
"@xylabs/
|
|
69
|
-
"@
|
|
70
|
-
"@xyo-network/account
|
|
71
|
-
"@xyo-network/
|
|
72
|
-
"@xyo-network/api
|
|
73
|
-
"@xyo-network/
|
|
74
|
-
"@xyo-network/archivist-
|
|
75
|
-
"@xyo-network/archivist-
|
|
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.7",
|
|
69
|
+
"@xylabs/tsconfig": "~7.13.7",
|
|
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.
|
|
78
|
-
"@xyo-network/boundwitness-model": "~5.
|
|
79
|
-
"@xyo-network/boundwitness-
|
|
80
|
-
"@xyo-network/
|
|
81
|
-
"@xyo-network/
|
|
82
|
-
"@xyo-network/
|
|
83
|
-
"@xyo-network/
|
|
84
|
-
"@xyo-network/payload-
|
|
85
|
-
"@xyo-network/payload-
|
|
86
|
-
"@xyo-network/payload-
|
|
87
|
-
"@xyo-network/payload-
|
|
88
|
-
"@xyo-network/
|
|
89
|
-
"@xyo-network/sdk-js": "
|
|
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.
|
|
93
|
-
"@xyo-network/wallet-model": "^5.
|
|
94
|
-
"@xyo-network/xl1-sdk": "
|
|
95
|
-
"
|
|
92
|
+
"@xyo-network/wallet": "~5.6.1",
|
|
93
|
+
"@xyo-network/wallet-model": "^5.6.2",
|
|
94
|
+
"@xyo-network/xl1-protocol-sdk": "~1.27.1",
|
|
95
|
+
"@xyo-network/xl1-sdk": "^1.27.1",
|
|
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
|
-
"
|
|
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.
|
|
118
|
-
"mapbox-gl": "^3.
|
|
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": "
|
|
135
|
+
"zod": "~4.4.3"
|
|
137
136
|
},
|
|
138
137
|
"peerDependencies": {
|
|
139
|
-
"@bitauth/libauth": ">=3.0.0 <
|
|
140
|
-
"@metamask/json-rpc-engine": ">=10.
|
|
138
|
+
"@bitauth/libauth": ">=3.0.0 <3.1",
|
|
139
|
+
"@metamask/json-rpc-engine": ">=10.3.0 <11",
|
|
141
140
|
"@metamask/providers": ">=22.1.1 <23",
|
|
142
|
-
"@metamask/utils": ">=11.11.0 <12",
|
|
141
|
+
"@metamask/utils": ">=11.11.0 <11.12",
|
|
143
142
|
"@opentelemetry/api": ">=1.9.1 <2",
|
|
144
|
-
"@opentelemetry/context-async-hooks": ">=2.7.
|
|
145
|
-
"@opentelemetry/context-zone": ">=2.7.
|
|
146
|
-
"@opentelemetry/core": ">=2.7.
|
|
147
|
-
"@opentelemetry/exporter-prometheus": ">=0.
|
|
148
|
-
"@opentelemetry/exporter-trace-otlp-grpc": ">=0.
|
|
149
|
-
"@opentelemetry/exporter-trace-otlp-http": ">=0.
|
|
150
|
-
"@opentelemetry/host-metrics": ">=0.38.3 <
|
|
151
|
-
"@opentelemetry/instrumentation-runtime-node": ">=0.
|
|
152
|
-
"@opentelemetry/resources": ">=2.7.
|
|
153
|
-
"@opentelemetry/sdk-metrics": ">=2.7.
|
|
154
|
-
"@opentelemetry/sdk-trace-base": ">=2.7.
|
|
155
|
-
"@opentelemetry/semantic-conventions": ">=1.40.0 <
|
|
156
|
-
"@scure/base": ">=2.2.0 <3",
|
|
157
|
-
"@scure/bip39": ">=2.2.0 <3",
|
|
158
|
-
"@xylabs/express": ">=5.
|
|
159
|
-
"@xylabs/
|
|
160
|
-
"@xylabs/
|
|
161
|
-
"@xylabs/
|
|
162
|
-
"@xylabs/
|
|
163
|
-
"@
|
|
164
|
-
"@xyo-network/account
|
|
165
|
-
"@xyo-network/
|
|
166
|
-
"@xyo-network/api
|
|
167
|
-
"@xyo-network/
|
|
168
|
-
"@xyo-network/archivist-
|
|
169
|
-
"@xyo-network/archivist-
|
|
170
|
-
"@xyo-network/
|
|
171
|
-
"@xyo-network/
|
|
172
|
-
"@xyo-network/boundwitness-
|
|
173
|
-
"@xyo-network/boundwitness-
|
|
174
|
-
"@xyo-network/boundwitness-wrapper": ">=5.
|
|
175
|
-
"@xyo-network/config-payload-plugin": ">=5.
|
|
176
|
-
"@xyo-network/huri": ">=5.
|
|
177
|
-
"@xyo-network/manifest-model": ">=5.
|
|
178
|
-
"@xyo-network/payload-builder": ">=5.
|
|
179
|
-
"@xyo-network/payload-model": ">=5.
|
|
180
|
-
"@xyo-network/payload-plugin": ">=5.
|
|
181
|
-
"@xyo-network/payload-wrapper": ">=5.
|
|
182
|
-
"@xyo-network/query-payload-plugin": ">=5.
|
|
183
|
-
"@xyo-network/sdk-js": ">=5.
|
|
184
|
-
"@xyo-network/sdk-protocol-js": ">=5.
|
|
143
|
+
"@opentelemetry/context-async-hooks": ">=2.7.1 <2.8",
|
|
144
|
+
"@opentelemetry/context-zone": ">=2.7.1 <2.8",
|
|
145
|
+
"@opentelemetry/core": ">=2.7.1 <2.8",
|
|
146
|
+
"@opentelemetry/exporter-prometheus": ">=0.216.0 <0.217",
|
|
147
|
+
"@opentelemetry/exporter-trace-otlp-grpc": ">=0.216.0 <0.217",
|
|
148
|
+
"@opentelemetry/exporter-trace-otlp-http": ">=0.216.0 <0.217",
|
|
149
|
+
"@opentelemetry/host-metrics": ">=0.38.3 <0.39",
|
|
150
|
+
"@opentelemetry/instrumentation-runtime-node": ">=0.29.0 <0.30",
|
|
151
|
+
"@opentelemetry/resources": ">=2.7.1 <2.8",
|
|
152
|
+
"@opentelemetry/sdk-metrics": ">=2.7.1 <2.8",
|
|
153
|
+
"@opentelemetry/sdk-trace-base": ">=2.7.1 <3",
|
|
154
|
+
"@opentelemetry/semantic-conventions": ">=1.40.0 <1.41",
|
|
155
|
+
"@scure/base": ">=2.2.0 <2.3",
|
|
156
|
+
"@scure/bip39": ">=2.2.0 <2.3",
|
|
157
|
+
"@xylabs/express": ">=5.1.1 <6",
|
|
158
|
+
"@xylabs/fetch": ">=5.1.1 <5.2",
|
|
159
|
+
"@xylabs/geo": ">=5.1.1 <6",
|
|
160
|
+
"@xylabs/mongo": ">=5.1.1 <6",
|
|
161
|
+
"@xylabs/sdk-js": ">=5.1.1 <6",
|
|
162
|
+
"@xylabs/threads": ">=5.1.1 <5.2",
|
|
163
|
+
"@xyo-network/account": ">=5.6.1 <5.7",
|
|
164
|
+
"@xyo-network/account-model": ">=5.6.2 <5.7",
|
|
165
|
+
"@xyo-network/api": ">=5.6.1 <5.7",
|
|
166
|
+
"@xyo-network/api-models": ">=5.6.2 <5.7",
|
|
167
|
+
"@xyo-network/archivist-lmdb": ">=5.6.3 <5.7",
|
|
168
|
+
"@xyo-network/archivist-mongodb": ">=5.6.3 <5.7",
|
|
169
|
+
"@xyo-network/archivist-view": ">=5.6.3 <5.7",
|
|
170
|
+
"@xyo-network/bios-model": ">=7.3.0 <7.4",
|
|
171
|
+
"@xyo-network/boundwitness-builder": ">=5.6.1 <5.7",
|
|
172
|
+
"@xyo-network/boundwitness-model": ">=5.6.2 <5.7",
|
|
173
|
+
"@xyo-network/boundwitness-wrapper": ">=5.6.1 <5.7",
|
|
174
|
+
"@xyo-network/config-payload-plugin": ">=5.6.2 <5.7",
|
|
175
|
+
"@xyo-network/huri": ">=5.6.1 <5.7",
|
|
176
|
+
"@xyo-network/manifest-model": ">=5.6.2 <5.7",
|
|
177
|
+
"@xyo-network/payload-builder": ">=5.6.1 <5.7",
|
|
178
|
+
"@xyo-network/payload-model": ">=5.6.2 <5.7",
|
|
179
|
+
"@xyo-network/payload-plugin": ">=5.6.2 <5.7",
|
|
180
|
+
"@xyo-network/payload-wrapper": ">=5.6.1 <5.7",
|
|
181
|
+
"@xyo-network/query-payload-plugin": ">=5.6.2 <5.7",
|
|
182
|
+
"@xyo-network/sdk-js": ">=5.6.3 <6",
|
|
183
|
+
"@xyo-network/sdk-protocol-js": ">=5.6.2 <5.7",
|
|
185
184
|
"@xyo-network/typechain": ">=4.1.3 <5",
|
|
186
|
-
"@xyo-network/wallet": ">=5.
|
|
187
|
-
"@xyo-network/wallet-model": ">=5.
|
|
188
|
-
"@xyo-network/xl1-sdk": ">=1.
|
|
189
|
-
"
|
|
185
|
+
"@xyo-network/wallet": ">=5.6.1 <5.7",
|
|
186
|
+
"@xyo-network/wallet-model": ">=5.6.2 <6",
|
|
187
|
+
"@xyo-network/xl1-protocol-sdk": ">=1.27.1 <1.28",
|
|
188
|
+
"@xyo-network/xl1-sdk": ">=1.27.1 <2",
|
|
189
|
+
"ajv": ">=8.20.0 <9",
|
|
190
190
|
"async-mutex": ">=0.5.0 <1",
|
|
191
|
-
"axios": ">=1.15.2 <2",
|
|
192
191
|
"bn.js": ">=5.2.3 <6",
|
|
192
|
+
"body-parser": ">=2.2.2 <2.3",
|
|
193
193
|
"buffer": ">=6.0.3 <7",
|
|
194
194
|
"chalk": ">=5.6.2 <6",
|
|
195
|
-
"compression": ">=1.8.1 <
|
|
196
|
-
"
|
|
195
|
+
"compression": ">=1.8.1 <1.9",
|
|
196
|
+
"connect": ">=3.7.0 <4",
|
|
197
|
+
"cors": ">=2.8.6 <2.9",
|
|
197
198
|
"cosmiconfig": ">=9.0.1 <10",
|
|
198
|
-
"debug": ">=4.4.3 <5",
|
|
199
|
+
"debug": ">=4.4.3 <4.5",
|
|
199
200
|
"ethers": ">=6.16.0 <7",
|
|
200
201
|
"express": ">=5.2.1 <6",
|
|
201
|
-
"
|
|
202
|
+
"express-mung": ">=0.5.1 <0.6",
|
|
203
|
+
"hash-wasm": ">=4.12.0 <4.13",
|
|
204
|
+
"http-status-codes": ">=2.3.0 <2.4",
|
|
202
205
|
"idb": ">=8.0.3 <9",
|
|
203
206
|
"lmdb": ">=3.5.4 <4",
|
|
204
|
-
"lru-cache": ">=11.3.
|
|
205
|
-
"mapbox-gl": ">=3.
|
|
207
|
+
"lru-cache": ">=11.3.6 <12",
|
|
208
|
+
"mapbox-gl": ">=3.23.1 <4",
|
|
206
209
|
"mongodb": ">=7.2.0 <8",
|
|
207
|
-
"observable-fns": ">=0.6.1 <
|
|
210
|
+
"observable-fns": ">=0.6.1 <0.7",
|
|
208
211
|
"pako": ">=2.1.0 <3",
|
|
209
|
-
"
|
|
210
|
-
"
|
|
211
|
-
"
|
|
212
|
-
"uuid": ">=14.0.0 <
|
|
213
|
-
"wasm-feature-detect": ">=1.8.0 <
|
|
214
|
-
"web3-types": ">=1.10.0 <
|
|
215
|
-
"
|
|
212
|
+
"rollbar": ">=3.1.0 <4",
|
|
213
|
+
"shallowequal": ">=1.1.0 <1.2",
|
|
214
|
+
"store2": ">=2.14.4 <2.15",
|
|
215
|
+
"uuid": ">=14.0.0 <14.1",
|
|
216
|
+
"wasm-feature-detect": ">=1.8.0 <1.9",
|
|
217
|
+
"web3-types": ">=1.10.0 <1.11",
|
|
218
|
+
"webextension-polyfill": ">=0.12.0 <1",
|
|
219
|
+
"winston": ">=3.19.0 <3.20",
|
|
220
|
+
"winston-transport": ">=4.9.0 <4.10",
|
|
221
|
+
"zod": ">=4.4.3 <4.5"
|
|
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"}
|