@typeberry/lib 0.5.7-f0cc874 → 0.5.8-0dea783
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../../packages/workers/block-authorship/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../../packages/workers/block-authorship/main.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAgB3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAK9E,KAAK,MAAM,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;AAkBlD,wBAAsB,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,iBAgPpG"}
|
|
@@ -41,7 +41,15 @@ export async function main(config, comms, networkingComms) {
|
|
|
41
41
|
ed25519Secret: secrets.ed25519,
|
|
42
42
|
ed25519Public: await deriveEd25519PublicKey(secrets.ed25519),
|
|
43
43
|
})));
|
|
44
|
+
const initialHash = blocks.getBestHeaderHash();
|
|
45
|
+
const initialState = states.getState(initialHash);
|
|
44
46
|
logger.info `Block authorship validator keys: ${keys.map(({ bandersnatchPublic }, index) => `\n ${index}: ${bandersnatchPublic.toString()}`)}`;
|
|
47
|
+
if (initialState !== null) {
|
|
48
|
+
const initialKeys = await getSealingKeySeries(startTimeSlot % chainSpec.epochLength === 0, startTimeSlot, initialState);
|
|
49
|
+
if (initialKeys.isOk) {
|
|
50
|
+
logEpochBlockCreation(tryAsEpoch(Math.floor(startTimeSlot / chainSpec.epochLength)), initialKeys.ok);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
45
53
|
function getTime() {
|
|
46
54
|
const currentTime = process.hrtime.bigint() / 1000000n;
|
|
47
55
|
const timeFromStart = currentTime - startTime;
|
|
@@ -77,6 +85,21 @@ export async function main(config, comms, networkingComms) {
|
|
|
77
85
|
const currentEpoch = Math.floor(currentTimeslot / chainSpec.epochLength);
|
|
78
86
|
return currentEpoch > lastEpoch;
|
|
79
87
|
}
|
|
88
|
+
function logEpochBlockCreation(epoch, sealingKeySeries) {
|
|
89
|
+
let isCreating = false;
|
|
90
|
+
const epochStart = epoch * chainSpec.epochLength;
|
|
91
|
+
const epochEnd = epochStart + chainSpec.epochLength;
|
|
92
|
+
for (let slot = epochStart; slot < epochEnd; slot++) {
|
|
93
|
+
const key = getKeyForCurrentSlot(sealingKeySeries, keys, tryAsTimeSlot(slot));
|
|
94
|
+
if (key !== null) {
|
|
95
|
+
isCreating = true;
|
|
96
|
+
logger.info `[EPOCH ${epoch}] Validator ${key.bandersnatchPublic.toString()} will author block at slot ${slot}`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (isCreating === false) {
|
|
100
|
+
logger.info `[EPOCH ${epoch}] No blocks to author for this epoch.`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
80
103
|
async function getSealingKeySeries(isNewEpoch, timeSlot, state) {
|
|
81
104
|
if (isNewEpoch) {
|
|
82
105
|
const safrole = new Safrole(chainSpec, blake2bHasher, state);
|
|
@@ -145,6 +168,9 @@ export async function main(config, comms, networkingComms) {
|
|
|
145
168
|
if (selingKeySeriesResult.isError) {
|
|
146
169
|
continue;
|
|
147
170
|
}
|
|
171
|
+
if (isNewEpoch) {
|
|
172
|
+
logEpochBlockCreation(epoch, selingKeySeriesResult.ok);
|
|
173
|
+
}
|
|
148
174
|
const key = getKeyForCurrentSlot(selingKeySeriesResult.ok, keys, timeSlot);
|
|
149
175
|
if (key !== null && currentValidatorData !== undefined) {
|
|
150
176
|
const validatorIndex = getValidatorIndex(key, currentValidatorData);
|