@xyo-network/chain-producer 1.23.0 → 1.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.mjs +151 -107
- package/dist/node/index.mjs.map +7 -1
- package/package.json +17 -17
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 this.blockProductionCheckInterval *
|
|
99
|
+
return this.blockProductionCheckInterval * ProducerActor.HeadResubmissionMultiplier;
|
|
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,9 +229,7 @@ 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
|
-
nextBlock
|
|
207
|
-
]);
|
|
232
|
+
await this.mempoolRunner.submitBlocks([nextBlock]);
|
|
208
233
|
this.logger?.log("Published block:", displayBlockNumber);
|
|
209
234
|
this._producerActorBlocksPublished.add(1, this._metricAttributes);
|
|
210
235
|
this._lastProducedBlock = nextBlock;
|
|
@@ -212,10 +237,7 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
212
237
|
this.logger?.log("No block produced for submission.");
|
|
213
238
|
}
|
|
214
239
|
});
|
|
215
|
-
}, {
|
|
216
|
-
...this.context,
|
|
217
|
-
timeBudgetLimit: 1e3
|
|
218
|
-
});
|
|
240
|
+
}, { ...this.context, timeBudgetLimit: 1e3 });
|
|
219
241
|
}
|
|
220
242
|
async readyHandler() {
|
|
221
243
|
await this.produceBlock();
|
|
@@ -227,7 +249,7 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
227
249
|
if (isUndefined(head)) return;
|
|
228
250
|
const currentBlock = head.block;
|
|
229
251
|
const blocksUntilExpiration = this.calculateBlocksUntilProducerDeclarationExpiration(currentBlock);
|
|
230
|
-
if (blocksUntilExpiration >
|
|
252
|
+
if (blocksUntilExpiration > ProducerActor.RedeclarationWindow * 0.1) {
|
|
231
253
|
this._lastRedeclarationIntent = void 0;
|
|
232
254
|
return;
|
|
233
255
|
}
|
|
@@ -236,40 +258,45 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
236
258
|
this._lastRedeclarationIntent = void 0;
|
|
237
259
|
}
|
|
238
260
|
if (!await this.validateCurrentBalance()) {
|
|
239
|
-
this.logger?.error(
|
|
261
|
+
this.logger?.error(
|
|
262
|
+
`Add balance to address ${this.account.address} for the producer to declare it's intent.`
|
|
263
|
+
);
|
|
240
264
|
return;
|
|
241
265
|
}
|
|
242
266
|
if (!await this.validateCurrentStake()) {
|
|
243
|
-
this.logger?.error(
|
|
267
|
+
this.logger?.error(
|
|
268
|
+
`Add stake to contract address ${this.chainId} for the producer to declare it's intent.`
|
|
269
|
+
);
|
|
244
270
|
return;
|
|
245
271
|
}
|
|
246
272
|
this.logger?.log("Creating redeclaration intent for producer:", this.account.address);
|
|
247
|
-
const redeclarationIntent = createDeclarationIntent(
|
|
273
|
+
const redeclarationIntent = createDeclarationIntent(
|
|
274
|
+
this.account.address,
|
|
275
|
+
"producer",
|
|
276
|
+
currentBlock,
|
|
277
|
+
currentBlock + SimpleBlockRunner.RedeclarationDuration
|
|
278
|
+
);
|
|
248
279
|
await this.submitRedeclarationIntent(currentBlock, redeclarationIntent);
|
|
249
280
|
this._lastRedeclarationIntent = redeclarationIntent;
|
|
250
|
-
}, {
|
|
251
|
-
...this.context,
|
|
252
|
-
timeBudgetLimit: 1e3
|
|
253
|
-
});
|
|
281
|
+
}, { ...this.context, timeBudgetLimit: 1e3 });
|
|
254
282
|
}
|
|
255
283
|
async submitRedeclarationIntent(currentBlock, redeclarationIntent) {
|
|
256
284
|
this.logger?.log("Submitting redeclaration intent for producer:", this.account.address);
|
|
257
|
-
const tx = await buildTransaction(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
285
|
+
const tx = await buildTransaction(
|
|
286
|
+
this.chainId,
|
|
287
|
+
[redeclarationIntent],
|
|
288
|
+
[],
|
|
289
|
+
this.account,
|
|
290
|
+
currentBlock,
|
|
291
|
+
asXL1BlockNumber(currentBlock + 1e3, true)
|
|
292
|
+
);
|
|
293
|
+
await this.mempoolRunner.submitTransactions([tx]);
|
|
263
294
|
this.logger?.log("Submitted redeclaration intent for producer:", this.account.address);
|
|
264
295
|
}
|
|
265
296
|
async validateCurrentBalance() {
|
|
266
297
|
const head = (await this.blockViewer.currentBlock())?.[0]?._hash;
|
|
267
298
|
if (isDefined(head)) {
|
|
268
|
-
const balances = await this.accountBalanceViewer.accountBalances([
|
|
269
|
-
this.account.address
|
|
270
|
-
], {
|
|
271
|
-
head
|
|
272
|
-
});
|
|
299
|
+
const balances = await this.accountBalanceViewer.accountBalances([this.account.address], { head });
|
|
273
300
|
const currentBalance = balances[this.account.address] ?? 0n;
|
|
274
301
|
if (currentBalance <= 0n) {
|
|
275
302
|
this.logger?.error(`Producer ${this.account.address} has no balance.`);
|
|
@@ -289,33 +316,53 @@ var ProducerActor = class _ProducerActor extends ActorV3 {
|
|
|
289
316
|
return true;
|
|
290
317
|
}
|
|
291
318
|
};
|
|
292
|
-
|
|
319
|
+
/**
|
|
320
|
+
* The default interval time (in MS) between block production attempts.
|
|
321
|
+
*/
|
|
322
|
+
__publicField(ProducerActor, "DefaultBlockProductionCheckInterval", DEFAULT_BLOCK_PRODUCTION_CHECK_INTERVAL);
|
|
323
|
+
/**
|
|
324
|
+
* The multiplier applied to the block production check interval to determine
|
|
325
|
+
* the threshold for resubmitting the same block number if the head has not changed.
|
|
326
|
+
*/
|
|
327
|
+
__publicField(ProducerActor, "HeadResubmissionMultiplier", 30);
|
|
328
|
+
/**
|
|
329
|
+
* The window (in blocks) before expiration to attempt redeclaration of producer intent.
|
|
330
|
+
*/
|
|
331
|
+
__publicField(ProducerActor, "RedeclarationWindow", 1e3);
|
|
332
|
+
__publicField(ProducerActor, "needs", {
|
|
333
|
+
required: [
|
|
334
|
+
AccountBalanceViewerMoniker,
|
|
335
|
+
BlockRunnerMoniker,
|
|
336
|
+
BlockViewerMoniker,
|
|
337
|
+
ChainContractViewerMoniker,
|
|
338
|
+
FinalizationViewerMoniker,
|
|
339
|
+
MempoolRunnerMoniker,
|
|
340
|
+
MempoolViewerMoniker,
|
|
341
|
+
StakeTotalsViewerMoniker
|
|
342
|
+
]
|
|
343
|
+
});
|
|
344
|
+
ProducerActor = __decorateClass([
|
|
293
345
|
creatable()
|
|
294
346
|
], ProducerActor);
|
|
295
347
|
|
|
296
348
|
// src/run.ts
|
|
297
|
-
var getProducerActor =
|
|
298
|
-
const account = await initActorWallet({
|
|
299
|
-
...locator.context,
|
|
300
|
-
config
|
|
301
|
-
});
|
|
349
|
+
var getProducerActor = async (config, locator) => {
|
|
350
|
+
const account = await initActorWallet({ ...locator.context, config });
|
|
302
351
|
return await ProducerActor.create({
|
|
303
352
|
config,
|
|
304
353
|
locator,
|
|
305
354
|
name: "xl1-producer",
|
|
306
355
|
account
|
|
307
356
|
});
|
|
308
|
-
}
|
|
309
|
-
var runProducer =
|
|
357
|
+
};
|
|
358
|
+
var runProducer = async (config, orchestrator, locator) => {
|
|
310
359
|
const producer = await getProducerActor(config, locator);
|
|
311
|
-
const actors = [
|
|
312
|
-
producer
|
|
313
|
-
].filter(exists);
|
|
360
|
+
const actors = [producer].filter(exists);
|
|
314
361
|
for (const actor of actors) {
|
|
315
362
|
await orchestrator.registerActor(actor);
|
|
316
363
|
}
|
|
317
364
|
await orchestrator.start();
|
|
318
|
-
}
|
|
365
|
+
};
|
|
319
366
|
|
|
320
367
|
// src/command.ts
|
|
321
368
|
function producerCommand(getConfiguration, getLocatorsFromConfig) {
|
|
@@ -323,20 +370,17 @@ function producerCommand(getConfiguration, getLocatorsFromConfig) {
|
|
|
323
370
|
command: "producer",
|
|
324
371
|
deprecated: 'Use "start producer" instead',
|
|
325
372
|
describe: "Run a XL1 Producer Node",
|
|
326
|
-
handler:
|
|
373
|
+
handler: async () => {
|
|
327
374
|
const configuration = getConfiguration();
|
|
328
|
-
const { locators, orchestrator } = await getLocatorsFromConfig([
|
|
329
|
-
"producer"
|
|
330
|
-
], configuration);
|
|
375
|
+
const { locators, orchestrator } = await getLocatorsFromConfig(["producer"], configuration);
|
|
331
376
|
await runProducer(ProducerConfigZod.parse(locators["producer"].context.config), orchestrator, locators["producer"]);
|
|
332
|
-
}
|
|
377
|
+
}
|
|
333
378
|
};
|
|
334
379
|
}
|
|
335
|
-
__name(producerCommand, "producerCommand");
|
|
336
380
|
export {
|
|
337
381
|
ProducerActor,
|
|
338
382
|
getProducerActor,
|
|
339
383
|
producerCommand,
|
|
340
384
|
runProducer
|
|
341
385
|
};
|
|
342
|
-
//# sourceMappingURL=index.mjs.map
|
|
386
|
+
//# 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;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EA,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
|
+
{
|
|
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 * 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 \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 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"],
|
|
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;AACP,SAAS,yBAAyB;AAQlC;AAAA,EACE;AAAA,EAA6B;AAAA,EAAkB;AAAA,EAAoB;AAAA,EACnE;AAAA,EAAkB;AAAA,EAA4B;AAAA,EAAyB;AAAA,EAA2B;AAAA,EAAsB;AAAA,EAAsB;AAAA,OACzI;AACP,SAAS,aAAa;AAMtB,IAAM,6CAA6C;AACnD,IAAM,cAAc,KAAK,KAAK;AAO9B,IAAM,4BAA4B,CAAC,sBAA+D;AAChG,SAAO,GAAG,kBAAkB,KAAK,KAAK,MAAM,kBAAkB,OAAO,EAAE,QAAQ,KAAK,CAAC,CAAC;AACxF;AAGO,IAAM,gBAAN,cAA4B,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G,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": "1.23.
|
|
3
|
+
"version": "1.23.2",
|
|
4
4
|
"description": "XYO Layer One Producer",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"README.md"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@xyo-network/chain-
|
|
39
|
-
"@xyo-network/chain-
|
|
38
|
+
"@xyo-network/chain-services": "~1.23.2",
|
|
39
|
+
"@xyo-network/chain-orchestration": "~1.23.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@bitauth/libauth": "~3.0.0",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"@opentelemetry/context-async-hooks": "~2.7.1",
|
|
48
48
|
"@opentelemetry/context-zone": "~2.7.1",
|
|
49
49
|
"@opentelemetry/core": "~2.7.1",
|
|
50
|
-
"@opentelemetry/exporter-prometheus": "~0.
|
|
51
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "~0.
|
|
52
|
-
"@opentelemetry/exporter-trace-otlp-http": "~0.
|
|
50
|
+
"@opentelemetry/exporter-prometheus": "~0.218",
|
|
51
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "~0.218",
|
|
52
|
+
"@opentelemetry/exporter-trace-otlp-http": "~0.218",
|
|
53
53
|
"@opentelemetry/host-metrics": "~0.38.3",
|
|
54
|
-
"@opentelemetry/instrumentation-runtime-node": "~0.
|
|
54
|
+
"@opentelemetry/instrumentation-runtime-node": "~0.31",
|
|
55
55
|
"@opentelemetry/resources": "~2.7.1",
|
|
56
56
|
"@opentelemetry/sdk-metrics": "~2.7.1",
|
|
57
57
|
"@opentelemetry/sdk-trace-base": "^2.7.1",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"@xylabs/mongo": "^5.1.2",
|
|
66
66
|
"@xylabs/sdk-js": "^5.1.2",
|
|
67
67
|
"@xylabs/threads": "~5.1.2",
|
|
68
|
-
"@xylabs/toolchain": "~
|
|
69
|
-
"@xylabs/tsconfig": "~
|
|
68
|
+
"@xylabs/toolchain": "~8.0.4",
|
|
69
|
+
"@xylabs/tsconfig": "~8.0.4",
|
|
70
70
|
"@xyo-network/account": "~5.6.2",
|
|
71
71
|
"@xyo-network/account-model": "~5.6.3",
|
|
72
72
|
"@xyo-network/api": "~5.6.2",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"@xyo-network/typechain": "^4.1.3",
|
|
92
92
|
"@xyo-network/wallet": "~5.6.2",
|
|
93
93
|
"@xyo-network/wallet-model": "^5.6.3",
|
|
94
|
-
"@xyo-network/xl1-protocol-sdk": "~1.30.
|
|
95
|
-
"@xyo-network/xl1-sdk": "^1.30.
|
|
94
|
+
"@xyo-network/xl1-protocol-sdk": "~1.30.2",
|
|
95
|
+
"@xyo-network/xl1-sdk": "^1.30.2",
|
|
96
96
|
"ajv": "^8.20.0",
|
|
97
97
|
"async-mutex": "^0.5.0",
|
|
98
98
|
"bn.js": "^5.2.3",
|
|
@@ -123,9 +123,9 @@
|
|
|
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.
|
|
128
|
+
"vite": "^8.0.13",
|
|
129
129
|
"vitest": "^4.1.6",
|
|
130
130
|
"wasm-feature-detect": "~1.8.0",
|
|
131
131
|
"web3-types": "~1.10.0",
|
|
@@ -143,11 +143,11 @@
|
|
|
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",
|