@xyo-network/chain-producer 1.23.0 → 2.0.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 +13 -4
- package/dist/node/ProducerActor.d.ts.map +1 -1
- package/dist/node/index.mjs +166 -108
- package/dist/node/index.mjs.map +7 -1
- package/package.json +83 -83
|
@@ -10,10 +10,20 @@ export declare class ProducerActor extends ActorV3<ProducerActorParams> {
|
|
|
10
10
|
*/
|
|
11
11
|
static readonly DefaultBlockProductionCheckInterval = 10000;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Time in milliseconds the producer will wait before re-attempting block
|
|
14
|
+
* production for the same head when its last produced block has not been
|
|
15
|
+
* adopted (head hasn't advanced). 30 s is short enough to recover quickly
|
|
16
|
+
* from a transient submit-side failure (e.g. the validator rejected the
|
|
17
|
+
* block and the producer's `_lastProducedBlock` cache would otherwise mute
|
|
18
|
+
* retries) while still long enough to avoid hammering the mempool with
|
|
19
|
+
* duplicate submissions under normal latency.
|
|
20
|
+
*
|
|
21
|
+
* Previously this was `blockProductionCheckInterval × 30` which scaled with
|
|
22
|
+
* the check interval — 5 min in production, 2.5 min in our tightened test
|
|
23
|
+
* config — both far too long for a failure that needed re-action within a
|
|
24
|
+
* single block time. Made absolute to decouple from the check interval.
|
|
15
25
|
*/
|
|
16
|
-
static readonly
|
|
26
|
+
static readonly HeadResubmissionThresholdMs = 30000;
|
|
17
27
|
/**
|
|
18
28
|
* The window (in blocks) before expiration to attempt redeclaration of producer intent.
|
|
19
29
|
*/
|
|
@@ -123,7 +133,6 @@ export declare class ProducerActor extends ActorV3<ProducerActorParams> {
|
|
|
123
133
|
minStake: number;
|
|
124
134
|
dataLake?: import("@xyo-network/xl1-sdk").DataLakeConfig | undefined;
|
|
125
135
|
accountPath?: string | undefined;
|
|
126
|
-
healthCheckPort?: number | undefined;
|
|
127
136
|
allowlist?: (Lowercase<string> & {
|
|
128
137
|
readonly __hex: true;
|
|
129
138
|
} & {
|
|
@@ -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,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,OAAO,EAEP,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAA;AAGzC,OAAO,KAAK,EACV,oBAAoB,EAEpB,WAAW,EAAE,WAAW,EAAE,mBAAmB,EAAW,gBAAgB,EAAsB,yBAAyB,EAAE,aAAa,EACtI,aAAa,EAAE,iBAAiB,EAAE,cAAc,EACjD,MAAM,sBAAsB,CAAA;AAO7B,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;IAC9C,MAAM,EAAE,cAAc,CAAA;CACvB,CAAC,CAAA;AAcF,qBACa,aAAc,SAAQ,OAAO,CAAC,mBAAmB,CAAC;IAC7D;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,mCAAmC,SAA0C;IAE7F
|
|
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,EACL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,OAAO,EAEP,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAA;AAGzC,OAAO,KAAK,EACV,oBAAoB,EAEpB,WAAW,EAAE,WAAW,EAAE,mBAAmB,EAAW,gBAAgB,EAAsB,yBAAyB,EAAE,aAAa,EACtI,aAAa,EAAE,iBAAiB,EAAE,cAAc,EACjD,MAAM,sBAAsB,CAAA;AAO7B,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;IAC9C,MAAM,EAAE,cAAc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B,WAEzC;IAED,SAAS,KAAK,WAAW,gBAExB;IAED,SAAS,KAAK,WAAW,+BAExB;IAED,SAAS,KAAK,mBAAmB,wBAEhC;IAED,SAAS,KAAK,OAAO,wCAEpB;IAED,SAAS,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEnB;IAED,SAAS,KAAK,yBAAyB,WAEtC;IAED,SAAS,KAAK,aAAa,kBAE1B;IAED,SAAS,KAAK,aAAa,kBAE1B;IAED,SAAS,KAAK,iBAAiB,sBAE9B;IAEc,aAAa;IAgFb,YAAY;IAe3B,SAAS,CAAC,iDAAiD,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;cAIzE,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;cAwEpB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;cAKtC,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;cAiEhC,yBAAyB,CAAC,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;cAkB7G,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC;cAe1C,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;CAWzD"}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,62 +1,58 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
if (decorator = decorators[i])
|
|
8
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
+
if (kind && result) __defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
3
13
|
|
|
4
14
|
// src/command.ts
|
|
5
15
|
import { ProducerConfigZod } from "@xyo-network/chain-orchestration";
|
|
6
16
|
|
|
7
17
|
// src/run.ts
|
|
8
18
|
import { exists } from "@xylabs/sdk-js";
|
|
9
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
initActorWallet
|
|
21
|
+
} from "@xyo-network/chain-orchestration";
|
|
10
22
|
|
|
11
23
|
// src/ProducerActor.ts
|
|
12
|
-
import {
|
|
13
|
-
|
|
24
|
+
import {
|
|
25
|
+
assertEx,
|
|
26
|
+
creatable,
|
|
27
|
+
isDefined,
|
|
28
|
+
isUndefined,
|
|
29
|
+
toHex
|
|
30
|
+
} from "@xylabs/sdk-js";
|
|
31
|
+
import {
|
|
32
|
+
ActorV3,
|
|
33
|
+
DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL
|
|
34
|
+
} from "@xyo-network/chain-orchestration";
|
|
14
35
|
import { SimpleBlockRunner } from "@xyo-network/chain-services";
|
|
15
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
AccountBalanceViewerMoniker,
|
|
38
|
+
asXL1BlockNumber,
|
|
39
|
+
BlockRunnerMoniker,
|
|
40
|
+
BlockViewerMoniker,
|
|
41
|
+
buildTransaction,
|
|
42
|
+
ChainContractViewerMoniker,
|
|
43
|
+
createDeclarationIntent,
|
|
44
|
+
FinalizationViewerMoniker,
|
|
45
|
+
MempoolRunnerMoniker,
|
|
46
|
+
MempoolViewerMoniker,
|
|
47
|
+
StakeTotalsViewerMoniker
|
|
48
|
+
} from "@xyo-network/xl1-sdk";
|
|
16
49
|
import { Mutex } from "async-mutex";
|
|
17
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
}
|
|
23
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
24
50
|
var SHOULD_REGISTER_REDECLARATION_INTENT_TIMER = true;
|
|
25
51
|
var TEN_MINUTES = 10 * 60 * 1e3;
|
|
26
|
-
var toFormattedBlockReference =
|
|
27
|
-
return `${blockBoundWitness.block} [${toHex(blockBoundWitness._hash, {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, "toFormattedBlockReference");
|
|
31
|
-
var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
32
|
-
static {
|
|
33
|
-
__name(this, "ProducerActor");
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* The default interval time (in MS) between block production attempts.
|
|
37
|
-
*/
|
|
38
|
-
static DefaultBlockProductionCheckInterval = DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL;
|
|
39
|
-
/**
|
|
40
|
-
* The multiplier applied to the block production check interval to determine
|
|
41
|
-
* the threshold for resubmitting the same block number if the head has not changed.
|
|
42
|
-
*/
|
|
43
|
-
static HeadResubmissionMultiplier = 30;
|
|
44
|
-
/**
|
|
45
|
-
* The window (in blocks) before expiration to attempt redeclaration of producer intent.
|
|
46
|
-
*/
|
|
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
|
-
};
|
|
52
|
+
var toFormattedBlockReference = (blockBoundWitness) => {
|
|
53
|
+
return `${blockBoundWitness.block} [${toHex(blockBoundWitness._hash, { prefix: true })}]`;
|
|
54
|
+
};
|
|
55
|
+
var ProducerActor = class extends ActorV3 {
|
|
60
56
|
_lastProducedBlock;
|
|
61
57
|
_lastRedeclarationIntent;
|
|
62
58
|
_metricAttributes;
|
|
@@ -82,7 +78,7 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
82
78
|
return this._accountBalanceViewer;
|
|
83
79
|
}
|
|
84
80
|
get blockProductionCheckInterval() {
|
|
85
|
-
return this.config.blockProductionCheckInterval ??
|
|
81
|
+
return this.config.blockProductionCheckInterval ?? ProducerActor.DefaultBlockProductionCheckInterval;
|
|
86
82
|
}
|
|
87
83
|
get blockRunner() {
|
|
88
84
|
return this._blockRunner;
|
|
@@ -100,7 +96,7 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
100
96
|
return this.params.config;
|
|
101
97
|
}
|
|
102
98
|
get headResubmissionThreshold() {
|
|
103
|
-
return
|
|
99
|
+
return ProducerActor.HeadResubmissionThresholdMs;
|
|
104
100
|
}
|
|
105
101
|
get mempoolRunner() {
|
|
106
102
|
return this._mempoolRunner;
|
|
@@ -113,22 +109,53 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
113
109
|
}
|
|
114
110
|
async createHandler() {
|
|
115
111
|
await super.createHandler();
|
|
116
|
-
this._metricAttributes = {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.
|
|
122
|
-
|
|
112
|
+
this._metricAttributes = { address: this.account.address.toString() };
|
|
113
|
+
this._producerActorBlockProductionChecks = this.counter(
|
|
114
|
+
"producer_actor_block_production_checks",
|
|
115
|
+
"Number of block production checks"
|
|
116
|
+
);
|
|
117
|
+
this._producerActorBlockProductionAttempts = this.counter(
|
|
118
|
+
"producer_actor_block_production_attempts",
|
|
119
|
+
"Number of block production attempts"
|
|
120
|
+
);
|
|
121
|
+
this._producerActorBlocksProduced = this.counter(
|
|
122
|
+
"producer_actor_blocks_produced",
|
|
123
|
+
"Number of blocks produced"
|
|
124
|
+
);
|
|
125
|
+
this._producerActorBlocksPublished = this.counter(
|
|
126
|
+
"producer_actor_blocks_published",
|
|
127
|
+
"Number of blocks published"
|
|
128
|
+
);
|
|
123
129
|
const final = await this.locator?.getInstance(FinalizationViewerMoniker);
|
|
124
130
|
await final.start();
|
|
125
|
-
this._accountBalanceViewer = assertEx(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
this._accountBalanceViewer = assertEx(
|
|
132
|
+
await this.locator?.getInstance(AccountBalanceViewerMoniker),
|
|
133
|
+
() => "Unable to locate AccountBalanceViewer"
|
|
134
|
+
);
|
|
135
|
+
this._blockRunner = assertEx(
|
|
136
|
+
await this.locator?.getInstance(BlockRunnerMoniker),
|
|
137
|
+
() => "Unable to locate BlockRunner"
|
|
138
|
+
);
|
|
139
|
+
this._blockViewer = assertEx(
|
|
140
|
+
await this.locator?.getInstance(BlockViewerMoniker),
|
|
141
|
+
() => "Unable to locate BlockViewer"
|
|
142
|
+
);
|
|
143
|
+
this._chainContractViewer = assertEx(
|
|
144
|
+
await this.locator?.getInstance(ChainContractViewerMoniker),
|
|
145
|
+
() => "Unable to locate ChainContractViewer"
|
|
146
|
+
);
|
|
147
|
+
this._mempoolRunner = assertEx(
|
|
148
|
+
await this.locator?.getInstance(MempoolRunnerMoniker),
|
|
149
|
+
() => "Unable to locate MempoolRunner"
|
|
150
|
+
);
|
|
151
|
+
this._mempoolViewer = assertEx(
|
|
152
|
+
await this.locator?.getInstance(MempoolViewerMoniker),
|
|
153
|
+
() => "Unable to locate MempoolViewer"
|
|
154
|
+
);
|
|
155
|
+
this._stakeTotalsViewer = assertEx(
|
|
156
|
+
await this.locator?.getInstance(StakeTotalsViewerMoniker),
|
|
157
|
+
() => "Unable to locate StakeTotalsViewer"
|
|
158
|
+
);
|
|
132
159
|
this._chainId = await this.chainContractViewer.chainId();
|
|
133
160
|
}
|
|
134
161
|
// async initLocator() {
|
|
@@ -202,20 +229,19 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
202
229
|
const displayBlockNumber = toFormattedBlockReference(nextBlock[0]);
|
|
203
230
|
this.logger?.log("Produced block:", displayBlockNumber);
|
|
204
231
|
this._producerActorBlocksProduced.add(1, this._metricAttributes);
|
|
205
|
-
await this.mempoolRunner.submitBlocks([
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
232
|
+
const submittedHashes = await this.mempoolRunner.submitBlocks([nextBlock]);
|
|
233
|
+
if (submittedHashes.length === 0) {
|
|
234
|
+
this.logger?.error(`Submit dropped block ${displayBlockNumber} silently \u2014 archivist accepted 0 of 1 (hash ${nextBlock[0]._hash})`);
|
|
235
|
+
} else {
|
|
236
|
+
this.logger?.log("Published block:", displayBlockNumber);
|
|
237
|
+
}
|
|
209
238
|
this._producerActorBlocksPublished.add(1, this._metricAttributes);
|
|
210
239
|
this._lastProducedBlock = nextBlock;
|
|
211
240
|
} else {
|
|
212
241
|
this.logger?.log("No block produced for submission.");
|
|
213
242
|
}
|
|
214
243
|
});
|
|
215
|
-
}, {
|
|
216
|
-
...this.context,
|
|
217
|
-
timeBudgetLimit: 1e3
|
|
218
|
-
});
|
|
244
|
+
}, { ...this.context, timeBudgetLimit: 1e3 });
|
|
219
245
|
}
|
|
220
246
|
async readyHandler() {
|
|
221
247
|
await this.produceBlock();
|
|
@@ -227,7 +253,7 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
227
253
|
if (isUndefined(head)) return;
|
|
228
254
|
const currentBlock = head.block;
|
|
229
255
|
const blocksUntilExpiration = this.calculateBlocksUntilProducerDeclarationExpiration(currentBlock);
|
|
230
|
-
if (blocksUntilExpiration >
|
|
256
|
+
if (blocksUntilExpiration > ProducerActor.RedeclarationWindow * 0.1) {
|
|
231
257
|
this._lastRedeclarationIntent = void 0;
|
|
232
258
|
return;
|
|
233
259
|
}
|
|
@@ -236,40 +262,45 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
236
262
|
this._lastRedeclarationIntent = void 0;
|
|
237
263
|
}
|
|
238
264
|
if (!await this.validateCurrentBalance()) {
|
|
239
|
-
this.logger?.error(
|
|
265
|
+
this.logger?.error(
|
|
266
|
+
`Add balance to address ${this.account.address} for the producer to declare it's intent.`
|
|
267
|
+
);
|
|
240
268
|
return;
|
|
241
269
|
}
|
|
242
270
|
if (!await this.validateCurrentStake()) {
|
|
243
|
-
this.logger?.error(
|
|
271
|
+
this.logger?.error(
|
|
272
|
+
`Add stake to contract address ${this.chainId} for the producer to declare it's intent.`
|
|
273
|
+
);
|
|
244
274
|
return;
|
|
245
275
|
}
|
|
246
276
|
this.logger?.log("Creating redeclaration intent for producer:", this.account.address);
|
|
247
|
-
const redeclarationIntent = createDeclarationIntent(
|
|
277
|
+
const redeclarationIntent = createDeclarationIntent(
|
|
278
|
+
this.account.address,
|
|
279
|
+
"producer",
|
|
280
|
+
currentBlock,
|
|
281
|
+
currentBlock + SimpleBlockRunner.RedeclarationDuration
|
|
282
|
+
);
|
|
248
283
|
await this.submitRedeclarationIntent(currentBlock, redeclarationIntent);
|
|
249
284
|
this._lastRedeclarationIntent = redeclarationIntent;
|
|
250
|
-
}, {
|
|
251
|
-
...this.context,
|
|
252
|
-
timeBudgetLimit: 1e3
|
|
253
|
-
});
|
|
285
|
+
}, { ...this.context, timeBudgetLimit: 1e3 });
|
|
254
286
|
}
|
|
255
287
|
async submitRedeclarationIntent(currentBlock, redeclarationIntent) {
|
|
256
288
|
this.logger?.log("Submitting redeclaration intent for producer:", this.account.address);
|
|
257
|
-
const tx = await buildTransaction(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
289
|
+
const tx = await buildTransaction(
|
|
290
|
+
this.chainId,
|
|
291
|
+
[redeclarationIntent],
|
|
292
|
+
[],
|
|
293
|
+
this.account,
|
|
294
|
+
currentBlock,
|
|
295
|
+
asXL1BlockNumber(currentBlock + 1e3, true)
|
|
296
|
+
);
|
|
297
|
+
await this.mempoolRunner.submitTransactions([tx]);
|
|
263
298
|
this.logger?.log("Submitted redeclaration intent for producer:", this.account.address);
|
|
264
299
|
}
|
|
265
300
|
async validateCurrentBalance() {
|
|
266
301
|
const head = (await this.blockViewer.currentBlock())?.[0]?._hash;
|
|
267
302
|
if (isDefined(head)) {
|
|
268
|
-
const balances = await this.accountBalanceViewer.accountBalances([
|
|
269
|
-
this.account.address
|
|
270
|
-
], {
|
|
271
|
-
head
|
|
272
|
-
});
|
|
303
|
+
const balances = await this.accountBalanceViewer.accountBalances([this.account.address], { head });
|
|
273
304
|
const currentBalance = balances[this.account.address] ?? 0n;
|
|
274
305
|
if (currentBalance <= 0n) {
|
|
275
306
|
this.logger?.error(`Producer ${this.account.address} has no balance.`);
|
|
@@ -289,33 +320,63 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
289
320
|
return true;
|
|
290
321
|
}
|
|
291
322
|
};
|
|
292
|
-
|
|
323
|
+
/**
|
|
324
|
+
* The default interval time (in MS) between block production attempts.
|
|
325
|
+
*/
|
|
326
|
+
__publicField(ProducerActor, "DefaultBlockProductionCheckInterval", DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL);
|
|
327
|
+
/**
|
|
328
|
+
* Time in milliseconds the producer will wait before re-attempting block
|
|
329
|
+
* production for the same head when its last produced block has not been
|
|
330
|
+
* adopted (head hasn't advanced). 30 s is short enough to recover quickly
|
|
331
|
+
* from a transient submit-side failure (e.g. the validator rejected the
|
|
332
|
+
* block and the producer's `_lastProducedBlock` cache would otherwise mute
|
|
333
|
+
* retries) while still long enough to avoid hammering the mempool with
|
|
334
|
+
* duplicate submissions under normal latency.
|
|
335
|
+
*
|
|
336
|
+
* Previously this was `blockProductionCheckInterval × 30` which scaled with
|
|
337
|
+
* the check interval — 5 min in production, 2.5 min in our tightened test
|
|
338
|
+
* config — both far too long for a failure that needed re-action within a
|
|
339
|
+
* single block time. Made absolute to decouple from the check interval.
|
|
340
|
+
*/
|
|
341
|
+
__publicField(ProducerActor, "HeadResubmissionThresholdMs", 3e4);
|
|
342
|
+
/**
|
|
343
|
+
* The window (in blocks) before expiration to attempt redeclaration of producer intent.
|
|
344
|
+
*/
|
|
345
|
+
__publicField(ProducerActor, "RedeclarationWindow", 1e3);
|
|
346
|
+
__publicField(ProducerActor, "needs", {
|
|
347
|
+
required: [
|
|
348
|
+
AccountBalanceViewerMoniker,
|
|
349
|
+
BlockRunnerMoniker,
|
|
350
|
+
BlockViewerMoniker,
|
|
351
|
+
ChainContractViewerMoniker,
|
|
352
|
+
FinalizationViewerMoniker,
|
|
353
|
+
MempoolRunnerMoniker,
|
|
354
|
+
MempoolViewerMoniker,
|
|
355
|
+
StakeTotalsViewerMoniker
|
|
356
|
+
]
|
|
357
|
+
});
|
|
358
|
+
ProducerActor = __decorateClass([
|
|
293
359
|
creatable()
|
|
294
360
|
], ProducerActor);
|
|
295
361
|
|
|
296
362
|
// src/run.ts
|
|
297
|
-
var getProducerActor =
|
|
298
|
-
const account = await initActorWallet({
|
|
299
|
-
...locator.context,
|
|
300
|
-
config
|
|
301
|
-
});
|
|
363
|
+
var getProducerActor = async (config, locator) => {
|
|
364
|
+
const account = await initActorWallet({ ...locator.context, config });
|
|
302
365
|
return await ProducerActor.create({
|
|
303
366
|
config,
|
|
304
367
|
locator,
|
|
305
368
|
name: "xl1-producer",
|
|
306
369
|
account
|
|
307
370
|
});
|
|
308
|
-
}
|
|
309
|
-
var runProducer =
|
|
371
|
+
};
|
|
372
|
+
var runProducer = async (config, orchestrator, locator) => {
|
|
310
373
|
const producer = await getProducerActor(config, locator);
|
|
311
|
-
const actors = [
|
|
312
|
-
producer
|
|
313
|
-
].filter(exists);
|
|
374
|
+
const actors = [producer].filter(exists);
|
|
314
375
|
for (const actor of actors) {
|
|
315
376
|
await orchestrator.registerActor(actor);
|
|
316
377
|
}
|
|
317
378
|
await orchestrator.start();
|
|
318
|
-
}
|
|
379
|
+
};
|
|
319
380
|
|
|
320
381
|
// src/command.ts
|
|
321
382
|
function producerCommand(getConfiguration, getLocatorsFromConfig) {
|
|
@@ -323,20 +384,17 @@ function producerCommand(getConfiguration, getLocatorsFromConfig) {
|
|
|
323
384
|
command: "producer",
|
|
324
385
|
deprecated: 'Use "start producer" instead',
|
|
325
386
|
describe: "Run a XL1 Producer Node",
|
|
326
|
-
handler:
|
|
387
|
+
handler: async () => {
|
|
327
388
|
const configuration = getConfiguration();
|
|
328
|
-
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
329
|
-
"producer"
|
|
330
|
-
], configuration);
|
|
389
|
+
const { locators, orchestrator } = await getLocatorsFromConfig(["producer"], configuration);
|
|
331
390
|
await runProducer(ProducerConfigZod.parse(locators["producer"].context.config), orchestrator, locators["producer"]);
|
|
332
|
-
}
|
|
391
|
+
}
|
|
333
392
|
};
|
|
334
393
|
}
|
|
335
|
-
__name(producerCommand, "producerCommand");
|
|
336
394
|
export {
|
|
337
395
|
ProducerActor,
|
|
338
396
|
getProducerActor,
|
|
339
397
|
producerCommand,
|
|
340
398
|
runProducer
|
|
341
399
|
};
|
|
342
|
-
//# sourceMappingURL=index.mjs.map
|
|
400
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
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;;;;EAK7C,OAAgBC,sBAAsB;EAEtC,OAAgBC,QAA8B;IAC5CC,UAAU;MACRC;MACAC;MACAC;MACAC;MACAC;MACAC;MACAC;MACAC;;EAEJ;EAEUC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EAEF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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
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/command.ts", "../../src/run.ts", "../../src/ProducerActor.ts"],
|
|
4
|
+
"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 * Time in milliseconds the producer will wait before re-attempting block\n * production for the same head when its last produced block has not been\n * adopted (head hasn't advanced). 30 s is short enough to recover quickly\n * from a transient submit-side failure (e.g. the validator rejected the\n * block and the producer's `_lastProducedBlock` cache would otherwise mute\n * retries) while still long enough to avoid hammering the mempool with\n * duplicate submissions under normal latency.\n *\n * Previously this was `blockProductionCheckInterval \u00D7 30` which scaled with\n * the check interval \u2014 5 min in production, 2.5 min in our tightened test\n * config \u2014 both far too long for a failure that needed re-action within a\n * single block time. Made absolute to decouple from the check interval.\n */\n static readonly HeadResubmissionThresholdMs = 30_000\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 ProducerActor.HeadResubmissionThresholdMs\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 \u2014 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 const submittedHashes = await this.mempoolRunner.submitBlocks([nextBlock])\n if (submittedHashes.length === 0) {\n // submitBlocks resolved without throwing but the archivist did not\n // accept the block (e.g. silent hash-dedupe at the archivist layer).\n // Without this check the producer would treat a dropped block as\n // published and never retry, leaving the chain wedged. Surfacing it\n // here lets operators and tests see the failure mode.\n this.logger?.error(`Submit dropped block ${displayBlockNumber} silently \u2014 archivist accepted 0 of 1 (hash ${nextBlock[0]._hash})`)\n } else {\n this.logger?.log('Published block:', displayBlockNumber)\n }\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AACA,SAAS,yBAAyB;;;ACAlC,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,OAGK;;;ACLP;AAAA,EACE;AAAA,EAAU;AAAA,EAAW;AAAA,EAAW;AAAA,EAChC;AAAA,OACK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,OAEK;A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AA,IAChC;AAAA,IAAQ;AAAA,IAAS,MAAM;AAAA,IAAiC;AAAA,EAC1D,CAA+B;AACjC;AAEO,IAAM,cAAc,OACzB,QACA,cACA,YACG;AACH,QAAM,WAAW,MAAM,iBAAiB,QAAQ,OAAO;AACvD,QAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,MAAM;AAEvC,aAAW,SAAS,QAAQ;AAC1B,UAAM,aAAa,cAAc,KAAK;AAAA,EACxC;AACA,QAAM,aAAa,MAAM;AAC3B;;;AD3BO,SAAS,gBAAgB,kBAAgC,uBAA6D;AAC3H,SAAO;AAAA,IACL,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS,YAAY;AACnB,YAAM,gBAAgB,iBAAiB;AACvC,YAAM,EAAE,UAAU,aAAa,IAAI,MAAM,sBAAsB,CAAC,UAAU,GAAG,aAAa;AAC1F,YAAM,YAAY,kBAAkB,MAAM,SAAS,UAAU,EAAE,QAAQ,MAAM,GAAG,cAAc,SAAS,UAAU,CAAC;AAAA,IACpH;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/chain-producer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "XYO Layer One Producer",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -35,23 +35,23 @@
|
|
|
35
35
|
"README.md"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@xyo-network/chain-
|
|
39
|
-
"@xyo-network/chain-
|
|
38
|
+
"@xyo-network/chain-services": "~2.0.0",
|
|
39
|
+
"@xyo-network/chain-orchestration": "~2.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@bitauth/libauth": "~3.0.0",
|
|
43
43
|
"@metamask/json-rpc-engine": "^10.5.0",
|
|
44
44
|
"@metamask/providers": "^22.1.1",
|
|
45
|
-
"@metamask/utils": "
|
|
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": "
|
|
51
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "
|
|
52
|
-
"@opentelemetry/exporter-trace-otlp-http": "
|
|
50
|
+
"@opentelemetry/exporter-prometheus": "^0.218.0",
|
|
51
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.218.0",
|
|
52
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.218.0",
|
|
53
53
|
"@opentelemetry/host-metrics": "~0.38.3",
|
|
54
|
-
"@opentelemetry/instrumentation-runtime-node": "
|
|
54
|
+
"@opentelemetry/instrumentation-runtime-node": "^0.31.0",
|
|
55
55
|
"@opentelemetry/resources": "~2.7.1",
|
|
56
56
|
"@opentelemetry/sdk-metrics": "~2.7.1",
|
|
57
57
|
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
@@ -59,40 +59,40 @@
|
|
|
59
59
|
"@scure/base": "~2.2.0",
|
|
60
60
|
"@scure/bip39": "~2.2.0",
|
|
61
61
|
"@types/yargs": "^17.0.35",
|
|
62
|
-
"@xylabs/express": "
|
|
63
|
-
"@xylabs/fetch": "~
|
|
64
|
-
"@xylabs/geo": "
|
|
65
|
-
"@xylabs/mongo": "^
|
|
66
|
-
"@xylabs/sdk-js": "^
|
|
67
|
-
"@xylabs/threads": "~
|
|
68
|
-
"@xylabs/toolchain": "~
|
|
69
|
-
"@xylabs/tsconfig": "~
|
|
70
|
-
"@xyo-network/account": "~
|
|
71
|
-
"@xyo-network/account-model": "~
|
|
72
|
-
"@xyo-network/api": "~
|
|
73
|
-
"@xyo-network/api-models": "~
|
|
74
|
-
"@xyo-network/archivist-lmdb": "~
|
|
75
|
-
"@xyo-network/archivist-mongodb": "~
|
|
76
|
-
"@xyo-network/archivist-view": "~
|
|
77
|
-
"@xyo-network/bios-model": "~7.
|
|
78
|
-
"@xyo-network/boundwitness-builder": "~
|
|
79
|
-
"@xyo-network/boundwitness-model": "~
|
|
80
|
-
"@xyo-network/boundwitness-wrapper": "~
|
|
81
|
-
"@xyo-network/config-payload-plugin": "~
|
|
82
|
-
"@xyo-network/huri": "~
|
|
83
|
-
"@xyo-network/manifest-model": "~
|
|
84
|
-
"@xyo-network/payload-builder": "~
|
|
85
|
-
"@xyo-network/payload-model": "~
|
|
86
|
-
"@xyo-network/payload-plugin": "~
|
|
87
|
-
"@xyo-network/payload-wrapper": "~
|
|
88
|
-
"@xyo-network/query-payload-plugin": "~
|
|
89
|
-
"@xyo-network/sdk-js": "
|
|
90
|
-
"@xyo-network/sdk-protocol-js": "~
|
|
62
|
+
"@xylabs/express": "~6.0.2",
|
|
63
|
+
"@xylabs/fetch": "~6.0.2",
|
|
64
|
+
"@xylabs/geo": "~6.0.2",
|
|
65
|
+
"@xylabs/mongo": "^6.0.2",
|
|
66
|
+
"@xylabs/sdk-js": "^6.0.2",
|
|
67
|
+
"@xylabs/threads": "~6.0.2",
|
|
68
|
+
"@xylabs/toolchain": "~8.1.1",
|
|
69
|
+
"@xylabs/tsconfig": "~8.1.1",
|
|
70
|
+
"@xyo-network/account": "~6.0.0",
|
|
71
|
+
"@xyo-network/account-model": "~6.0.0",
|
|
72
|
+
"@xyo-network/api": "~6.0",
|
|
73
|
+
"@xyo-network/api-models": "~6.0",
|
|
74
|
+
"@xyo-network/archivist-lmdb": "~6.0",
|
|
75
|
+
"@xyo-network/archivist-mongodb": "~6.0.0",
|
|
76
|
+
"@xyo-network/archivist-view": "~6.0",
|
|
77
|
+
"@xyo-network/bios-model": "~7.4.2",
|
|
78
|
+
"@xyo-network/boundwitness-builder": "~6.0.0",
|
|
79
|
+
"@xyo-network/boundwitness-model": "~6.0.0",
|
|
80
|
+
"@xyo-network/boundwitness-wrapper": "~6.0.0",
|
|
81
|
+
"@xyo-network/config-payload-plugin": "~6.0.0",
|
|
82
|
+
"@xyo-network/huri": "~6.0",
|
|
83
|
+
"@xyo-network/manifest-model": "~6.0.0",
|
|
84
|
+
"@xyo-network/payload-builder": "~6.0.0",
|
|
85
|
+
"@xyo-network/payload-model": "~6.0.0",
|
|
86
|
+
"@xyo-network/payload-plugin": "~6.0",
|
|
87
|
+
"@xyo-network/payload-wrapper": "~6.0.0",
|
|
88
|
+
"@xyo-network/query-payload-plugin": "~6.0.0",
|
|
89
|
+
"@xyo-network/sdk-js": "~6.0",
|
|
90
|
+
"@xyo-network/sdk-protocol-js": "~6.0",
|
|
91
91
|
"@xyo-network/typechain": "^4.1.3",
|
|
92
|
-
"@xyo-network/wallet": "~
|
|
93
|
-
"@xyo-network/wallet-model": "^
|
|
94
|
-
"@xyo-network/xl1-protocol-sdk": "~
|
|
95
|
-
"@xyo-network/xl1-sdk": "
|
|
92
|
+
"@xyo-network/wallet": "~6.0",
|
|
93
|
+
"@xyo-network/wallet-model": "^6.0.0",
|
|
94
|
+
"@xyo-network/xl1-protocol-sdk": "~2.0",
|
|
95
|
+
"@xyo-network/xl1-sdk": "~2.0",
|
|
96
96
|
"ajv": "^8.20.0",
|
|
97
97
|
"async-mutex": "^0.5.0",
|
|
98
98
|
"bn.js": "^5.2.3",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"cosmiconfig": "^9.0.1",
|
|
106
106
|
"debug": "~4.4.3",
|
|
107
107
|
"dotenv": "~17.4.2",
|
|
108
|
-
"eslint": "^10.
|
|
108
|
+
"eslint": "^10.4.0",
|
|
109
109
|
"ethers": "^6.16.0",
|
|
110
110
|
"express": "^5.2.1",
|
|
111
111
|
"express-mung": "~0.5.1",
|
|
@@ -113,8 +113,8 @@
|
|
|
113
113
|
"http-status-codes": "~2.3.0",
|
|
114
114
|
"idb": "^8.0.3",
|
|
115
115
|
"lmdb": "^3.5.4",
|
|
116
|
-
"lru-cache": "^11.
|
|
117
|
-
"mapbox-gl": "^3.
|
|
116
|
+
"lru-cache": "^11.5.0",
|
|
117
|
+
"mapbox-gl": "^3.24.0",
|
|
118
118
|
"mongodb": "^7.2.0",
|
|
119
119
|
"nodemon": "~3.1.14",
|
|
120
120
|
"observable-fns": "~0.6.1",
|
|
@@ -123,10 +123,10 @@
|
|
|
123
123
|
"shallowequal": "~1.1.0",
|
|
124
124
|
"store2": "~2.14.4",
|
|
125
125
|
"tslib": "^2.8.1",
|
|
126
|
-
"typescript": "~
|
|
126
|
+
"typescript": "~6.0.3",
|
|
127
127
|
"uuid": "~14.0.0",
|
|
128
|
-
"vite": "^8.0.
|
|
129
|
-
"vitest": "^4.1.
|
|
128
|
+
"vite": "^8.0.13",
|
|
129
|
+
"vitest": "^4.1.7",
|
|
130
130
|
"wasm-feature-detect": "~1.8.0",
|
|
131
131
|
"web3-types": "~1.10.0",
|
|
132
132
|
"webextension-polyfill": "^0.12.0",
|
|
@@ -138,54 +138,54 @@
|
|
|
138
138
|
"@bitauth/libauth": "~3.0",
|
|
139
139
|
"@metamask/json-rpc-engine": "^10.3",
|
|
140
140
|
"@metamask/providers": "^22.1",
|
|
141
|
-
"@metamask/utils": "
|
|
141
|
+
"@metamask/utils": "^11.11",
|
|
142
142
|
"@opentelemetry/api": "^1.9",
|
|
143
143
|
"@opentelemetry/context-async-hooks": "~2.7",
|
|
144
144
|
"@opentelemetry/context-zone": "~2.7",
|
|
145
145
|
"@opentelemetry/core": "~2.7",
|
|
146
|
-
"@opentelemetry/exporter-prometheus": "~0.
|
|
147
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "~0.
|
|
148
|
-
"@opentelemetry/exporter-trace-otlp-http": "~0.
|
|
146
|
+
"@opentelemetry/exporter-prometheus": "~0.218",
|
|
147
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "~0.218",
|
|
148
|
+
"@opentelemetry/exporter-trace-otlp-http": "~0.218",
|
|
149
149
|
"@opentelemetry/host-metrics": "~0.38",
|
|
150
|
-
"@opentelemetry/instrumentation-runtime-node": "~0.
|
|
150
|
+
"@opentelemetry/instrumentation-runtime-node": "~0.31",
|
|
151
151
|
"@opentelemetry/resources": "~2.7",
|
|
152
152
|
"@opentelemetry/sdk-metrics": "~2.7",
|
|
153
153
|
"@opentelemetry/sdk-trace-base": "^2.7",
|
|
154
154
|
"@opentelemetry/semantic-conventions": "~1.41",
|
|
155
155
|
"@scure/base": "~2.2",
|
|
156
156
|
"@scure/bip39": "~2.2",
|
|
157
|
-
"@xylabs/express": "^
|
|
158
|
-
"@xylabs/fetch": "
|
|
159
|
-
"@xylabs/geo": "^
|
|
160
|
-
"@xylabs/mongo": "^
|
|
161
|
-
"@xylabs/sdk-js": "^
|
|
162
|
-
"@xylabs/threads": "~
|
|
163
|
-
"@xyo-network/account": "~
|
|
164
|
-
"@xyo-network/account-model": "~
|
|
165
|
-
"@xyo-network/api": "~
|
|
166
|
-
"@xyo-network/api-models": "~
|
|
167
|
-
"@xyo-network/archivist-lmdb": "~
|
|
168
|
-
"@xyo-network/archivist-mongodb": "~
|
|
169
|
-
"@xyo-network/archivist-view": "~
|
|
170
|
-
"@xyo-network/bios-model": "~7.
|
|
171
|
-
"@xyo-network/boundwitness-builder": "~
|
|
172
|
-
"@xyo-network/boundwitness-model": "~
|
|
173
|
-
"@xyo-network/boundwitness-wrapper": "~
|
|
174
|
-
"@xyo-network/config-payload-plugin": "~
|
|
175
|
-
"@xyo-network/huri": "~
|
|
176
|
-
"@xyo-network/manifest-model": "~
|
|
177
|
-
"@xyo-network/payload-builder": "~
|
|
178
|
-
"@xyo-network/payload-model": "~
|
|
179
|
-
"@xyo-network/payload-plugin": "~
|
|
180
|
-
"@xyo-network/payload-wrapper": "~
|
|
181
|
-
"@xyo-network/query-payload-plugin": "~
|
|
182
|
-
"@xyo-network/sdk-js": "^
|
|
183
|
-
"@xyo-network/sdk-protocol-js": "~
|
|
157
|
+
"@xylabs/express": "^6.0",
|
|
158
|
+
"@xylabs/fetch": "^6.0",
|
|
159
|
+
"@xylabs/geo": "^6.0",
|
|
160
|
+
"@xylabs/mongo": "^6.0",
|
|
161
|
+
"@xylabs/sdk-js": "^6.0",
|
|
162
|
+
"@xylabs/threads": "~6.0",
|
|
163
|
+
"@xyo-network/account": "~6.0",
|
|
164
|
+
"@xyo-network/account-model": "~6.0",
|
|
165
|
+
"@xyo-network/api": "~6.0",
|
|
166
|
+
"@xyo-network/api-models": "~6.0",
|
|
167
|
+
"@xyo-network/archivist-lmdb": "~6.0",
|
|
168
|
+
"@xyo-network/archivist-mongodb": "~6.0",
|
|
169
|
+
"@xyo-network/archivist-view": "~6.0",
|
|
170
|
+
"@xyo-network/bios-model": "~7.4",
|
|
171
|
+
"@xyo-network/boundwitness-builder": "~6.0",
|
|
172
|
+
"@xyo-network/boundwitness-model": "~6.0",
|
|
173
|
+
"@xyo-network/boundwitness-wrapper": "~6.0",
|
|
174
|
+
"@xyo-network/config-payload-plugin": "~6.0",
|
|
175
|
+
"@xyo-network/huri": "~6.0",
|
|
176
|
+
"@xyo-network/manifest-model": "~6.0",
|
|
177
|
+
"@xyo-network/payload-builder": "~6.0",
|
|
178
|
+
"@xyo-network/payload-model": "~6.0",
|
|
179
|
+
"@xyo-network/payload-plugin": "~6.0",
|
|
180
|
+
"@xyo-network/payload-wrapper": "~6.0",
|
|
181
|
+
"@xyo-network/query-payload-plugin": "~6.0",
|
|
182
|
+
"@xyo-network/sdk-js": "^6.0",
|
|
183
|
+
"@xyo-network/sdk-protocol-js": "~6.0",
|
|
184
184
|
"@xyo-network/typechain": "^4.1",
|
|
185
|
-
"@xyo-network/wallet": "~
|
|
186
|
-
"@xyo-network/wallet-model": "^
|
|
187
|
-
"@xyo-network/xl1-protocol-sdk": "~
|
|
188
|
-
"@xyo-network/xl1-sdk": "^
|
|
185
|
+
"@xyo-network/wallet": "~6.0",
|
|
186
|
+
"@xyo-network/wallet-model": "^6.0",
|
|
187
|
+
"@xyo-network/xl1-protocol-sdk": "~2.0",
|
|
188
|
+
"@xyo-network/xl1-sdk": "^2.0",
|
|
189
189
|
"ajv": "^8.20",
|
|
190
190
|
"async-mutex": "^0.5",
|
|
191
191
|
"bn.js": "^5.2",
|