@lodestar/beacon-node 1.50.0 → 1.51.0-dev.4157a0dec4
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/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/blocks/index.js +7 -2
- package/lib/api/impl/beacon/blocks/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +31 -17
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.d.ts +11 -13
- package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
- package/lib/chain/ColumnReconstructionTracker.js +49 -44
- package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
- package/lib/chain/archiveStore/utils/archiveBlocks.js +4 -5
- package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts +1 -1
- package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
- package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
- package/lib/chain/blocks/blockInput/utils.js +2 -2
- package/lib/chain/blocks/blockInput/utils.js.map +1 -1
- package/lib/chain/blocks/importBlock.d.ts.map +1 -1
- package/lib/chain/blocks/importBlock.js +7 -4
- package/lib/chain/blocks/importBlock.js.map +1 -1
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +4 -2
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/interface.d.ts +1 -1
- package/lib/chain/interface.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.d.ts.map +1 -1
- package/lib/chain/prepareNextSlot.js +4 -3
- package/lib/chain/prepareNextSlot.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
- package/lib/chain/produceBlock/produceBlockBody.js +8 -6
- package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
- package/lib/chain/reprocess.d.ts +2 -1
- package/lib/chain/reprocess.d.ts.map +1 -1
- package/lib/chain/reprocess.js +2 -1
- package/lib/chain/reprocess.js.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js +1 -1
- package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js +1 -1
- package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +6 -4
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/constants/constants.d.ts +1 -0
- package/lib/constants/constants.d.ts.map +1 -1
- package/lib/constants/constants.js +1 -0
- package/lib/constants/constants.js.map +1 -1
- package/lib/db/repositories/blockArchive.js +2 -2
- package/lib/db/repositories/blockArchive.js.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts +1 -1
- package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -1
- package/lib/db/repositories/blockArchiveIndex.js +1 -2
- package/lib/db/repositories/blockArchiveIndex.js.map +1 -1
- package/lib/execution/engine/index.d.ts.map +1 -1
- package/lib/execution/engine/index.js +1 -1
- package/lib/execution/engine/index.js.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
- package/lib/execution/engine/jsonRpcHttpClient.js +14 -4
- package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
- package/lib/execution/engine/restTransport.d.ts +3 -1
- package/lib/execution/engine/restTransport.d.ts.map +1 -1
- package/lib/execution/engine/restTransport.js +33 -21
- package/lib/execution/engine/restTransport.js.map +1 -1
- package/lib/execution/engine/transportMetrics.d.ts +5 -1
- package/lib/execution/engine/transportMetrics.d.ts.map +1 -1
- package/lib/execution/engine/types.d.ts.map +1 -1
- package/lib/execution/engine/types.js +12 -11
- package/lib/execution/engine/types.js.map +1 -1
- package/lib/metrics/metrics/lodestar.d.ts +11 -0
- package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
- package/lib/metrics/metrics/lodestar.js +31 -1
- package/lib/metrics/metrics/lodestar.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +3 -1
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/gossip/topic.d.ts +0 -14
- package/lib/network/gossip/topic.d.ts.map +1 -1
- package/lib/network/processor/index.js +3 -3
- package/lib/network/processor/index.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +4 -4
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +3 -3
- package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
- package/lib/network/reqresp/rateLimit.js +2 -2
- package/lib/network/reqresp/rateLimit.js.map +1 -1
- package/lib/network/subnets/attnetsService.d.ts.map +1 -1
- package/lib/network/subnets/attnetsService.js +3 -1
- package/lib/network/subnets/attnetsService.js.map +1 -1
- package/lib/node/notifier.d.ts.map +1 -1
- package/lib/node/notifier.js +12 -13
- package/lib/node/notifier.js.map +1 -1
- package/lib/sync/unknownBlock.d.ts.map +1 -1
- package/lib/sync/unknownBlock.js +3 -2
- package/lib/sync/unknownBlock.js.map +1 -1
- package/lib/util/clock.d.ts.map +1 -1
- package/lib/util/clock.js +3 -4
- package/lib/util/clock.js.map +1 -1
- package/lib/util/sszBytes.d.ts +2 -2
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +22 -14
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +15 -15
- package/src/api/impl/beacon/blocks/index.ts +10 -3
- package/src/api/impl/validator/index.ts +41 -19
- package/src/chain/ColumnReconstructionTracker.ts +63 -46
- package/src/chain/archiveStore/utils/archiveBlocks.ts +6 -7
- package/src/chain/blocks/blockInput/blockInput.ts +1 -1
- package/src/chain/blocks/blockInput/utils.ts +2 -2
- package/src/chain/blocks/importBlock.ts +8 -4
- package/src/chain/chain.ts +4 -2
- package/src/chain/interface.ts +2 -1
- package/src/chain/prepareNextSlot.ts +7 -3
- package/src/chain/produceBlock/computeNewStateRoot.ts +9 -2
- package/src/chain/produceBlock/produceBlockBody.ts +10 -5
- package/src/chain/reprocess.ts +2 -1
- package/src/chain/seenCache/seenGossipBlockInput.ts +2 -1
- package/src/chain/stateCache/persistentCheckpointsCache.ts +4 -1
- package/src/chain/validatorMonitor.ts +7 -4
- package/src/constants/constants.ts +1 -0
- package/src/db/repositories/blockArchive.ts +2 -2
- package/src/db/repositories/blockArchiveIndex.ts +2 -3
- package/src/execution/engine/index.ts +2 -1
- package/src/execution/engine/jsonRpcHttpClient.ts +12 -5
- package/src/execution/engine/restTransport.ts +53 -22
- package/src/execution/engine/transportMetrics.ts +2 -1
- package/src/execution/engine/types.ts +13 -11
- package/src/metrics/metrics/lodestar.ts +32 -1
- package/src/network/gossip/gossipsub.ts +3 -1
- package/src/network/processor/index.ts +3 -3
- package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +4 -10
- package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +3 -3
- package/src/network/reqresp/rateLimit.ts +2 -2
- package/src/network/subnets/attnetsService.ts +8 -3
- package/src/node/notifier.ts +14 -13
- package/src/sync/unknownBlock.ts +3 -2
- package/src/util/clock.ts +3 -4
- package/src/util/sszBytes.ts +25 -12
package/src/node/notifier.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
IBeaconStateView,
|
|
6
6
|
computeEpochAtSlot,
|
|
7
7
|
computeStartSlotAtEpoch,
|
|
8
|
+
computeTimeAtSlot,
|
|
8
9
|
isStatePostBellatrix,
|
|
9
10
|
} from "@lodestar/state-transition";
|
|
10
11
|
import {Epoch} from "@lodestar/types";
|
|
@@ -140,21 +141,21 @@ export async function runNodeNotifier(modules: NodeNotifierModules): Promise<voi
|
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
function timeToNextHalfSlot(config: BeaconConfig, chain: IBeaconChain, isFirstTime: boolean): number {
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
msFromGenesis < 0
|
|
148
|
-
? // For future genesis time, calculate time left in the slot
|
|
149
|
-
-msFromGenesis % msPerSlot
|
|
150
|
-
: // For past genesis time, calculate time until the next slot
|
|
151
|
-
msPerSlot - (msFromGenesis % msPerSlot);
|
|
144
|
+
const currentSlot = chain.clock.currentSlot;
|
|
145
|
+
const nextSlotTimeSec = computeTimeAtSlot(config, currentSlot + 1, chain.genesisTime);
|
|
146
|
+
const nowMs = Date.now();
|
|
147
|
+
|
|
152
148
|
if (isFirstTime) {
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
const currentSlotTimeSec = computeTimeAtSlot(config, currentSlot, chain.genesisTime);
|
|
150
|
+
const currentMidpointMs = ((currentSlotTimeSec + nextSlotTimeSec) / 2) * 1000;
|
|
151
|
+
if (currentMidpointMs > nowMs) {
|
|
152
|
+
return currentMidpointMs - nowMs;
|
|
153
|
+
}
|
|
155
154
|
}
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
|
|
156
|
+
const nextSlotEndTimeSec = computeTimeAtSlot(config, currentSlot + 2, chain.genesisTime);
|
|
157
|
+
const nextMidpointMs = ((nextSlotTimeSec + nextSlotEndTimeSec) / 2) * 1000;
|
|
158
|
+
return Math.max(0, nextMidpointMs - nowMs);
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
function getHeadExecutionInfo(
|
package/src/sync/unknownBlock.ts
CHANGED
|
@@ -918,16 +918,17 @@ export class BlockInputSync {
|
|
|
918
918
|
* Poll unknown payloads of the current slot.
|
|
919
919
|
*/
|
|
920
920
|
private async pollPayloadsAtSlot(slot: Slot, signal: AbortSignal): Promise<void> {
|
|
921
|
+
const fork = this.config.getForkName(slot);
|
|
921
922
|
// fixed tick count so the loop cannot outlive its slot: for mainnet, it's 6 ticks
|
|
922
923
|
const tickCount = Math.floor(
|
|
923
|
-
(this.config.
|
|
924
|
+
(this.config.getSlotDurationMs(fork) - this.config.getPayloadDueMs(fork)) / PAYLOAD_POLL_INTERVAL_MS
|
|
924
925
|
);
|
|
925
926
|
// a root still missing on several ticks is searched on each of them, recorded once
|
|
926
927
|
const searchedRoots = new Set<RootHex>();
|
|
927
928
|
let polls = 0;
|
|
928
929
|
|
|
929
930
|
try {
|
|
930
|
-
await sleep(Math.max(0, this.config.getPayloadDueMs() - this.chain.clock.msFromSlot(slot)), signal);
|
|
931
|
+
await sleep(Math.max(0, this.config.getPayloadDueMs(fork) - this.chain.clock.msFromSlot(slot)), signal);
|
|
931
932
|
|
|
932
933
|
for (polls = 0; polls < tickCount; polls++) {
|
|
933
934
|
let importedCount = 0;
|
package/src/util/clock.ts
CHANGED
|
@@ -78,9 +78,9 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
78
78
|
|
|
79
79
|
this.config = config;
|
|
80
80
|
this.genesisTime = genesisTime;
|
|
81
|
-
this.timeoutId = setTimeout(this.onNextSlot, this.msUntilNextSlot());
|
|
82
81
|
this.signal = signal;
|
|
83
82
|
this._currentSlot = getCurrentSlot(this.config, this.genesisTime);
|
|
83
|
+
this.timeoutId = setTimeout(this.onNextSlot, this.msUntilNextSlot());
|
|
84
84
|
this.signal.addEventListener("abort", () => clearTimeout(this.timeoutId), {once: true});
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -204,8 +204,7 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
204
204
|
};
|
|
205
205
|
|
|
206
206
|
private msUntilNextSlot(): number {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
return milliSecondsPerSlot - (diffInMilliSeconds % milliSecondsPerSlot);
|
|
207
|
+
const nextSlotTimeSec = computeTimeAtSlot(this.config, this._currentSlot + 1, this.genesisTime);
|
|
208
|
+
return Math.max(0, nextSlotTimeSec * 1000 - Date.now());
|
|
210
209
|
}
|
|
211
210
|
}
|
package/src/util/sszBytes.ts
CHANGED
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
FIELD_ELEMENTS_PER_BLOB,
|
|
7
7
|
ForkName,
|
|
8
8
|
ForkPostDeneb,
|
|
9
|
+
ForkPostGloas,
|
|
9
10
|
ForkSeq,
|
|
10
11
|
MAX_COMMITTEES_PER_SLOT,
|
|
11
12
|
isForkPostElectra,
|
|
12
13
|
isForkPostGloas,
|
|
14
|
+
isForkPostHeze,
|
|
13
15
|
} from "@lodestar/params";
|
|
14
16
|
import {BLSSignature, CommitteeIndex, RootHex, Slot, ValidatorIndex, ssz} from "@lodestar/types";
|
|
15
17
|
|
|
@@ -57,6 +59,8 @@ const ATTESTATION_DATA_SIZE = 128;
|
|
|
57
59
|
// MAX_COMMITTEES_PER_SLOT is in bit, need to convert to byte
|
|
58
60
|
const COMMITTEE_BITS_SIZE = Math.max(Math.ceil(MAX_COMMITTEES_PER_SLOT / 8), 1);
|
|
59
61
|
const SIGNATURE_SIZE = 96;
|
|
62
|
+
// SyncAggregate is a fixed-size container, so minSize is its serialized size
|
|
63
|
+
const SYNC_AGGREGATE_SIZE = ssz.altair.SyncAggregate.minSize;
|
|
60
64
|
const SINGLE_ATTESTATION_ATTDATA_OFFSET = 8 + 8;
|
|
61
65
|
const SINGLE_ATTESTATION_SLOT_OFFSET = SINGLE_ATTESTATION_ATTDATA_OFFSET;
|
|
62
66
|
const SINGLE_ATTESTATION_COMMITTEE_INDEX_OFFSET = 0;
|
|
@@ -447,30 +451,39 @@ export function getParentRootFromSignedBeaconBlockSerialized(data: Uint8Array):
|
|
|
447
451
|
* BeaconBlockBody (GLOAS) fixed section before signedExecutionPayloadBid offset pointer:
|
|
448
452
|
* randaoReveal(96) + eth1Data(72) + graffiti(32)
|
|
449
453
|
* + proposerSlashings(4) + attesterSlashings(4) + attestations(4) + deposits(4) + voluntaryExits(4)
|
|
450
|
-
* + syncAggregate(
|
|
454
|
+
* + syncAggregate(SyncAggregate.minSize) + blsToExecutionChanges(4) = 384 bytes (mainnet preset)
|
|
451
455
|
*
|
|
452
|
-
*
|
|
456
|
+
* Heze body: randaoReveal(96) + graffiti(32) + proposerSlashings(4) + attesterSlashings(4) + attestations(4) + voluntaryExits(4) + syncAggregate(SyncAggregate.minSize) + blsToExecutionChanges(4) = 308 bytes (mainnet preset)
|
|
457
|
+
*
|
|
458
|
+
* The 4-byte pointer at byte 568 (= 184+384) for Gloas and 492 (= 184+308) for Heze (mainnet preset) gives the offset of SignedExecutionPayloadBid
|
|
453
459
|
* within BeaconBlockBody. parentBlockHash is at that bid's byte 100 (after offset+sig).
|
|
454
460
|
*/
|
|
455
461
|
// BeaconBlock body starts after: msg_offset(4) + sig(96) + slot(8) + proposer_index(8) + parent_root(32) + state_root(32) + body_offset_ptr(4)
|
|
456
462
|
const GLOAS_BODY_START_IN_SIGNED_BEACON_BLOCK =
|
|
457
463
|
VARIABLE_FIELD_OFFSET + SIGNATURE_SIZE + SLOT_SIZE + 8 + ROOT_SIZE + ROOT_SIZE + VARIABLE_FIELD_OFFSET; // = 184
|
|
458
|
-
const GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY = 96 + 72 + 32 + 4 + 4 + 4 + 4 + 4 +
|
|
459
|
-
|
|
460
|
-
|
|
464
|
+
const GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY = 96 + 72 + 32 + 4 + 4 + 4 + 4 + 4 + SYNC_AGGREGATE_SIZE + 4; // = 384 at mainnet preset
|
|
465
|
+
// Heze removes eth1Data (72 B) and the deposits offset (4 B) from the body fixed section
|
|
466
|
+
const HEZE_SIGNED_BID_OFFSET_POINTER_IN_BODY = GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY - 72 - VARIABLE_FIELD_OFFSET; // = 308
|
|
461
467
|
// Within SignedExecutionPayloadBid, parentBlockHash is at byte 100 (msg_offset:4 + sig:96)
|
|
462
468
|
const PARENT_BLOCK_HASH_OFFSET_IN_SIGNED_BID = VARIABLE_FIELD_OFFSET + SIGNATURE_SIZE; // = 100
|
|
463
469
|
|
|
464
|
-
// CAUTION: update offsets if BeaconBlockBody fixed fields change after
|
|
465
|
-
export function getParentBlockHashFromGloasSignedBeaconBlockSerialized(
|
|
466
|
-
|
|
470
|
+
// CAUTION: update offsets if BeaconBlockBody fixed fields change after Heze
|
|
471
|
+
export function getParentBlockHashFromGloasSignedBeaconBlockSerialized(
|
|
472
|
+
data: Uint8Array,
|
|
473
|
+
fork: ForkPostGloas
|
|
474
|
+
): RootHex | null {
|
|
475
|
+
const bidOffsetPointer =
|
|
476
|
+
GLOAS_BODY_START_IN_SIGNED_BEACON_BLOCK +
|
|
477
|
+
(isForkPostHeze(fork) ? HEZE_SIGNED_BID_OFFSET_POINTER_IN_BODY : GLOAS_SIGNED_BID_OFFSET_POINTER_IN_BODY);
|
|
478
|
+
if (data.length < bidOffsetPointer + VARIABLE_FIELD_OFFSET) {
|
|
467
479
|
return null;
|
|
468
480
|
}
|
|
469
481
|
const bidOffset =
|
|
470
|
-
data[
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
482
|
+
(data[bidOffsetPointer] |
|
|
483
|
+
(data[bidOffsetPointer + 1] << 8) |
|
|
484
|
+
(data[bidOffsetPointer + 2] << 16) |
|
|
485
|
+
(data[bidOffsetPointer + 3] << 24)) >>>
|
|
486
|
+
0;
|
|
474
487
|
|
|
475
488
|
const parentBlockHashStart =
|
|
476
489
|
GLOAS_BODY_START_IN_SIGNED_BEACON_BLOCK + bidOffset + PARENT_BLOCK_HASH_OFFSET_IN_SIGNED_BID;
|